blob: c108be5cd8aa809ad23c97eeee1fbc62840e506b [file] [log] [blame]
Tom Stellard0b76fc4c2016-09-16 21:34:26 +00001; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefixes=CO-V2,HSA,ALL %s
2; RUN: llc -mtriple=amdgcn-mesa-mesa3d -verify-machineinstrs < %s | FileCheck -check-prefixes=CO-V2,OS-MESA3D,MESA,ALL %s
3; RUN: llc -mtriple=amdgcn-mesa-unknown -verify-machineinstrs < %s | FileCheck -check-prefixes=OS-UNKNOWN,MESA,ALL %s
Matt Arsenaultdc4ebad2016-04-29 21:16:52 +00004
5; ALL-LABEL: {{^}}test:
Tom Stellard0b76fc4c2016-09-16 21:34:26 +00006; CO-V2: enable_sgpr_kernarg_segment_ptr = 1
7; CO-V2: s_load_dword s{{[0-9]+}}, s[4:5], 0xa
Matt Arsenaultdc4ebad2016-04-29 21:16:52 +00008
Tom Stellard0b76fc4c2016-09-16 21:34:26 +00009; OS-UNKNOWN: s_load_dword s{{[0-9]+}}, s[0:1], 0xa
Matt Arsenaultdc4ebad2016-04-29 21:16:52 +000010define void @test(i32 addrspace(1)* %out) #1 {
11 %kernarg.segment.ptr = call noalias i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
12 %header.ptr = bitcast i8 addrspace(2)* %kernarg.segment.ptr to i32 addrspace(2)*
13 %gep = getelementptr i32, i32 addrspace(2)* %header.ptr, i64 10
14 %value = load i32, i32 addrspace(2)* %gep
15 store i32 %value, i32 addrspace(1)* %out
16 ret void
17}
18
Jan Veselyfea814d2016-06-21 20:46:20 +000019; ALL-LABEL: {{^}}test_implicit:
20; 10 + 9 (36 prepended implicit bytes) + 2(out pointer) = 21 = 0x15
Tom Stellard0b76fc4c2016-09-16 21:34:26 +000021; OS-UNKNOWN: s_load_dword s{{[0-9]+}}, s[0:1], 0x15
Jan Veselyfea814d2016-06-21 20:46:20 +000022define void @test_implicit(i32 addrspace(1)* %out) #1 {
23 %implicitarg.ptr = call noalias i8 addrspace(2)* @llvm.amdgcn.implicitarg.ptr()
24 %header.ptr = bitcast i8 addrspace(2)* %implicitarg.ptr to i32 addrspace(2)*
25 %gep = getelementptr i32, i32 addrspace(2)* %header.ptr, i64 10
26 %value = load i32, i32 addrspace(2)* %gep
27 store i32 %value, i32 addrspace(1)* %out
28 ret void
29}
30
Tom Stellardba573082016-08-31 18:46:07 +000031; ALL-LABEL: {{^}}test_implicit_alignment
Tom Stellard0b76fc4c2016-09-16 21:34:26 +000032; OS-UNKNOWN: s_load_dword [[VAL:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0xc
Tom Stellardb2869eb2016-09-09 19:28:00 +000033; HSA: s_load_dword [[VAL:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0x4
Tom Stellard0b76fc4c2016-09-16 21:34:26 +000034; OS-MESA3D: s_load_dword [[VAL:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0x3
Tom Stellardba573082016-08-31 18:46:07 +000035; ALL: v_mov_b32_e32 [[V_VAL:v[0-9]+]], [[VAL]]
36; MESA: buffer_store_dword [[V_VAL]]
37; HSA: flat_store_dword v[{{[0-9]+:[0-9]+}}], [[V_VAL]]
38define void @test_implicit_alignment(i32 addrspace(1)* %out, <2 x i8> %in) #1 {
39 %implicitarg.ptr = call noalias i8 addrspace(2)* @llvm.amdgcn.implicitarg.ptr()
40 %arg.ptr = bitcast i8 addrspace(2)* %implicitarg.ptr to i32 addrspace(2)*
41 %val = load i32, i32 addrspace(2)* %arg.ptr
42 store i32 %val, i32 addrspace(1)* %out
43 ret void
44}
45
Matt Arsenaultdc4ebad2016-04-29 21:16:52 +000046declare i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr() #0
Jan Veselyfea814d2016-06-21 20:46:20 +000047declare i8 addrspace(2)* @llvm.amdgcn.implicitarg.ptr() #0
Matt Arsenaultdc4ebad2016-04-29 21:16:52 +000048
49attributes #0 = { nounwind readnone }
50attributes #1 = { nounwind }