blob: 1d370aba6da3496929725f665470c1aad7cb6ee3 [file] [log] [blame]
Matt Arsenaultcaa12882015-02-18 02:04:38 +00001; RUN: llc -march=amdgcn -mcpu=verde -show-mc-encoding -verify-machineinstrs < %s | FileCheck %s
2; RUN: llc -march=amdgcn -mcpu=tonga -show-mc-encoding -verify-machineinstrs < %s | FileCheck %s
Michel Danzer13736222014-01-27 07:20:51 +00003
4; Example of a simple geometry shader loading vertex attributes from the
5; ESGS ring buffer
6
Matt Arsenaultcaa12882015-02-18 02:04:38 +00007; FIXME: Out of bounds immediate offset crashes
Michel Danzer13736222014-01-27 07:20:51 +00008
Matt Arsenaultcaa12882015-02-18 02:04:38 +00009; CHECK-LABEL: {{^}}main:
Nikolay Haustov4f672a32016-04-29 09:02:30 +000010; CHECK: buffer_load_dword {{v[0-9]+}}, off, {{s\[[0-9]+:[0-9]+\]}}, 0 glc slc
Matt Arsenaultcaa12882015-02-18 02:04:38 +000011; CHECK: buffer_load_dword {{v[0-9]+}}, {{v[0-9]+}}, {{s\[[0-9]+:[0-9]+\]}}, 0 offen glc slc
12; CHECK: buffer_load_dword {{v[0-9]+}}, {{v[0-9]+}}, {{s\[[0-9]+:[0-9]+\]}}, 0 idxen glc slc
13; CHECK: buffer_load_dword {{v[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, 0 idxen offen glc slc
14; CHECK: s_movk_i32 [[K:s[0-9]+]], 0x4d2 ; encoding
15; CHECK: buffer_load_dword {{v[0-9]+}}, {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}, [[K]] idxen offen offset:65535 glc slc
16
Yaxun Liu0124b542018-02-13 18:00:25 +000017define amdgpu_vs void @main([17 x <4 x i32>] addrspace(4)* byval %arg, [32 x <4 x i32>] addrspace(4)* byval %arg1, [16 x <32 x i8>] addrspace(4)* byval %arg2, [2 x <4 x i32>] addrspace(4)* byval %arg3, [17 x <4 x i32>] addrspace(4)* inreg %arg4, [17 x <4 x i32>] addrspace(4)* inreg %arg5, i32 %arg6, i32 %arg7, i32 %arg8, i32 %arg9) {
Michel Danzer13736222014-01-27 07:20:51 +000018main_body:
Yaxun Liu0124b542018-02-13 18:00:25 +000019 %tmp = getelementptr [2 x <4 x i32>], [2 x <4 x i32>] addrspace(4)* %arg3, i64 0, i32 1
20 %tmp10 = load <4 x i32>, <4 x i32> addrspace(4)* %tmp, !tbaa !0
Matt Arsenaultcaa12882015-02-18 02:04:38 +000021 %tmp11 = shl i32 %arg6, 2
Matt Arsenault7c525902017-06-28 21:38:50 +000022 %tmp12 = call i32 @llvm.SI.buffer.load.dword.i32.i32(<4 x i32> %tmp10, i32 0, i32 0, i32 0, i32 0, i32 0, i32 1, i32 1, i32 0)
Matt Arsenaultcaa12882015-02-18 02:04:38 +000023 %tmp13 = bitcast i32 %tmp12 to float
Matt Arsenault7c525902017-06-28 21:38:50 +000024 %tmp14 = call i32 @llvm.SI.buffer.load.dword.i32.i32(<4 x i32> %tmp10, i32 %tmp11, i32 0, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0)
Matt Arsenaultcaa12882015-02-18 02:04:38 +000025 %tmp15 = bitcast i32 %tmp14 to float
Matt Arsenault7c525902017-06-28 21:38:50 +000026 %tmp16 = call i32 @llvm.SI.buffer.load.dword.i32.i32(<4 x i32> %tmp10, i32 %tmp11, i32 0, i32 0, i32 0, i32 1, i32 1, i32 1, i32 0)
Matt Arsenaultcaa12882015-02-18 02:04:38 +000027 %tmp17 = bitcast i32 %tmp16 to float
Matt Arsenault7c525902017-06-28 21:38:50 +000028 %tmp18 = call i32 @llvm.SI.buffer.load.dword.i32.v2i32(<4 x i32> %tmp10, <2 x i32> zeroinitializer, i32 0, i32 0, i32 1, i32 1, i32 1, i32 1, i32 0)
Matt Arsenaultcaa12882015-02-18 02:04:38 +000029 %tmp19 = bitcast i32 %tmp18 to float
30
Matt Arsenault7c525902017-06-28 21:38:50 +000031 %tmp20 = call i32 @llvm.SI.buffer.load.dword.i32.v2i32(<4 x i32> %tmp10, <2 x i32> zeroinitializer, i32 0, i32 123, i32 1, i32 1, i32 1, i32 1, i32 0)
Matt Arsenaultcaa12882015-02-18 02:04:38 +000032 %tmp21 = bitcast i32 %tmp20 to float
33
Matt Arsenault7c525902017-06-28 21:38:50 +000034 %tmp22 = call i32 @llvm.SI.buffer.load.dword.i32.v2i32(<4 x i32> %tmp10, <2 x i32> zeroinitializer, i32 1234, i32 65535, i32 1, i32 1, i32 1, i32 1, i32 0)
Matt Arsenaultcaa12882015-02-18 02:04:38 +000035 %tmp23 = bitcast i32 %tmp22 to float
36
Matt Arsenault3e90f842017-04-04 16:34:39 +000037 call void @llvm.amdgcn.exp.f32(i32 15, i32 12, float %tmp13, float %tmp15, float %tmp17, float %tmp19, i1 false, i1 false)
38 call void @llvm.amdgcn.exp.f32(i32 15, i32 12, float %tmp21, float %tmp23, float %tmp23, float %tmp23, i1 true, i1 false)
Michel Danzer13736222014-01-27 07:20:51 +000039 ret void
40}
41
42; Function Attrs: nounwind readonly
Matt Arsenault7c525902017-06-28 21:38:50 +000043declare i32 @llvm.SI.buffer.load.dword.i32.i32(<4 x i32>, i32, i32, i32, i32, i32, i32, i32, i32) #0
Michel Danzer13736222014-01-27 07:20:51 +000044
45; Function Attrs: nounwind readonly
Matt Arsenault7c525902017-06-28 21:38:50 +000046declare i32 @llvm.SI.buffer.load.dword.i32.v2i32(<4 x i32>, <2 x i32>, i32, i32, i32, i32, i32, i32, i32) #0
Michel Danzer13736222014-01-27 07:20:51 +000047
Matt Arsenault3e90f842017-04-04 16:34:39 +000048declare void @llvm.amdgcn.exp.f32(i32, i32, float, float, float, float, i1, i1) #1
Michel Danzer13736222014-01-27 07:20:51 +000049
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000050attributes #0 = { nounwind readonly }
Matt Arsenault3e90f842017-04-04 16:34:39 +000051attributes #1 = { nounwind inaccessiblememonly }
Michel Danzer13736222014-01-27 07:20:51 +000052
Sanjoy Das3336f682016-12-11 20:07:15 +000053!0 = !{!"const", !1, i32 1}
54!1 = !{!"tbaa root"}