diff options
Diffstat (limited to 'gcc/testsuite/brig.dg/test/gimple/variables.hsail')
-rw-r--r-- | gcc/testsuite/brig.dg/test/gimple/variables.hsail | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/gcc/testsuite/brig.dg/test/gimple/variables.hsail b/gcc/testsuite/brig.dg/test/gimple/variables.hsail new file mode 100644 index 00000000000..c76ea606575 --- /dev/null +++ b/gcc/testsuite/brig.dg/test/gimple/variables.hsail @@ -0,0 +1,124 @@ +module &module:1:0:$full:$large:$default; + +/* Tests for different variable scopes and address spaces. */ + +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +prog align(256) private_u32 &prog_private; +private_u32 &mod_private; + +prog group_u32 &prog_group; +group_u32 &mod_group; + +prog global_u32 &prog_global; +global_u32 &mod_global; + +decl prog global_u32 &prog_global_host_def; + +prog readonly_u32 &prog_readonly; +readonly_u32 &mod_readonly; + +prog function &subfunction(arg_u32 %return_value)(arg_u32 %arg) { + + private_u32 %func_private; + group_u32 %func_group; + align(256) global_u32 %func_global; + readonly_u32 %func_readonly; + + ld_private_u32 $s200, [%func_private]; + st_private_u32 $s200, [&prog_private]; + + ld_group_u32 $s203, [%func_group]; + st_group_u32 $s203, [&prog_group]; + + ld_global_u32 $s204, [%func_global]; + st_global_u32 $s204, [&prog_global]; + + ld_readonly_u32 $s205, [%func_readonly]; + st_global_u32 $s205, [%func_global]; + + st_arg_u32 $s2, [%return_value]; + ret; +}; + +prog kernel &kernel(kernarg_u64 %input_ptr, kernarg_u64 %output_ptr) +{ + private_u32 %kern_private; + group_u32 %kern_group; + global_u32 %kern_global; + readonly_u32 %kern_readonly; + + ld_kernarg_u64 $d0, [%input_ptr]; + ld_global_u32 $s0, [$d0]; + + ld_private_u32 $s2, [&prog_private]; + st_private_u32 $s2, [%kern_private]; + ld_private_u32 $s3, [&mod_private]; + st_private_u32 $s3, [&prog_private]; + + ld_group_u32 $s4, [&prog_group]; + st_group_u32 $s4, [%kern_group]; + ld_group_u32 $s5, [&mod_group]; + st_group_u32 $s5, [&prog_group]; + + ld_global_u32 $s6, [&prog_global]; + st_global_u32 $s6, [%kern_global]; + ld_global_u32 $s7, [&mod_global]; + st_global_u32 $s7, [&prog_global]; + + ld_readonly_u32 $s8, [&prog_readonly]; + st_global_u32 $s8, [%kern_global]; + ld_readonly_u32 $s9, [&mod_readonly]; + st_global_u32 $s9, [&prog_global]; + + ld_readonly_u32 $s10, [%kern_readonly]; + st_global_u32 $s10, [%kern_global]; + ld_readonly_u32 $s11, [%kern_readonly]; + st_global_u32 $s11, [&prog_global_host_def]; + + { + arg_u32 %arg; + arg_u32 %return_value; + st_arg_u32 $s1, [%arg]; + call &subfunction(%return_value)(%arg); + ld_arg_u32 $s1, [%return_value]; + } + ld_kernarg_u64 $d1, [%output_ptr]; + st_global_u32 $s1, [$d0]; +}; + +/* Private variable offsets assigned in the order of their appearance */ +/* + prog_private @0 (align 256) -> until 254 to ensure all WIs + mod_private @256 have their chunks aligned + func_private @260 + kern_private @264 +*/ + +/* Group variable offsets assigned in the order of their appearance */ +/* + prog_group @0 (2) + mod_group @4 (4) + func_group @8 (1) + kern_group @12 (3) +*/ + +/* { dg-final { scan-tree-dump "\\\+ 8;.*\\\+ 12;.*\\\+ 4;" "gimple" } } */ + +/* The "mangling" of the global and readonly vars. */ +/* { dg-final { scan-tree-dump "\[ \]*prog_global = s204;" "gimple" } } */ + +/* { dg-final { scan-tree-dump "\.module.mod_global;" "gimple" } } */ + +/* Host defined variables need indirect access as the address is + known only at run time. */ +/* { dg-final { scan-tree-dump "\\\*\\\__phsa.host_def.prog_global_host_def.\[0-9\]+_\[0-9\]+ = s11;" "gimple" } } */ + +/* { dg-final { scan-tree-dump "\.subfunction.func_global;" "gimple" } } */ +/* { dg-final { scan-tree-dump "\.subfunction.func_readonly;" "gimple" } } */ + +/* { dg-final { scan-tree-dump "kernel.kern_global" "gimple" } } */ +/* { dg-final { scan-tree-dump "kernel.kern_readonly" "gimple" } } */ + + |