1module &module:1:0:$full:$large:$default;
2
3/* Tests for alloca. */
4
5/* { dg-do compile } */
6/* { dg-options "-fdump-tree-gimple" } */
7
8prog function &subfunction(arg_u32 %return_value)() {
9     alloca_align(1)_u32 $s2, 256;
10     st_arg_u32 $s2, [%return_value];
11     ret;
12};
13
14prog kernel &kernel(kernarg_u64 %input_ptr, kernarg_u64 %output_ptr)
15{
16        ld_kernarg_u64 $d0, [%input_ptr];
17        ld_global_u32 $s0, [$d0];
18
19	alloca_align(256)_u32 $s1, 16;
20	{
21		arg_u32 %return_value;
22		call &subfunction(%return_value)();
23		ld_arg_u32 $s1, [%return_value];
24	}
25        ld_kernarg_u64 $d1, [%output_ptr];
26        st_global_u32 $s1, [$d0];
27};
28
29/* { dg-final { scan-tree-dump "s2 = __builtin___hsail_alloca \\\(256, 1, __context\\\);" "gimple" } } */
30
31/* { dg-final { scan-tree-dump "s1 = __builtin___hsail_alloca \\\(16, 256, __context\\\);" "gimple" } } */
32
33
34/* Both functions should have an alloca frame push and pop. */
35/* { dg-final { scan-tree-dump-times "__builtin___hsail_alloca_push_frame \\\(__context\\\);" 2 "gimple" } } */
36
37/* { dg-final { scan-tree-dump-times "__builtin___hsail_alloca_pop_frame \\\(__context\\\);" 2 "gimple" } } */
38