blob: 5fe03f09176eb7ea6b49661ca30eeff85cc56b45 [file] [log] [blame]
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +00001;RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck %s
2;RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck %s
3
4;CHECK-LABEL: {{^}}image_load_v4i32:
Nikolay Haustov2f684f12016-02-26 09:51:05 +00005;CHECK: image_load v[0:3], v[0:3], s[0:7] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +00006;CHECK: s_waitcnt vmcnt(0)
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +00007define amdgpu_ps <4 x float> @image_load_v4i32(<8 x i32> inreg %rsrc, <4 x i32> %c) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +00008main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +00009 %tex = call <4 x float> @llvm.amdgcn.image.load.v4f32.v4i32.v8i32(<4 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000010 ret <4 x float> %tex
11}
12
13;CHECK-LABEL: {{^}}image_load_v2i32:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000014;CHECK: image_load v[0:3], v[0:1], s[0:7] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000015;CHECK: s_waitcnt vmcnt(0)
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000016define amdgpu_ps <4 x float> @image_load_v2i32(<8 x i32> inreg %rsrc, <2 x i32> %c) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000017main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000018 %tex = call <4 x float> @llvm.amdgcn.image.load.v4f32.v2i32.v8i32(<2 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000019 ret <4 x float> %tex
20}
21
22;CHECK-LABEL: {{^}}image_load_i32:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000023;CHECK: image_load v[0:3], v0, s[0:7] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000024;CHECK: s_waitcnt vmcnt(0)
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000025define amdgpu_ps <4 x float> @image_load_i32(<8 x i32> inreg %rsrc, i32 %c) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000026main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000027 %tex = call <4 x float> @llvm.amdgcn.image.load.v4f32.i32.v8i32(i32 %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000028 ret <4 x float> %tex
29}
30
31;CHECK-LABEL: {{^}}image_load_mip:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000032;CHECK: image_load_mip v[0:3], v[0:3], s[0:7] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000033;CHECK: s_waitcnt vmcnt(0)
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000034define amdgpu_ps <4 x float> @image_load_mip(<8 x i32> inreg %rsrc, <4 x i32> %c) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000035main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000036 %tex = call <4 x float> @llvm.amdgcn.image.load.mip.v4f32.v4i32.v8i32(<4 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000037 ret <4 x float> %tex
38}
39
40;CHECK-LABEL: {{^}}image_load_1:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000041;CHECK: image_load v0, v[0:3], s[0:7] dmask:0x1 unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000042;CHECK: s_waitcnt vmcnt(0)
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000043define amdgpu_ps float @image_load_1(<8 x i32> inreg %rsrc, <4 x i32> %c) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000044main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000045 %tex = call <4 x float> @llvm.amdgcn.image.load.v4f32.v4i32.v8i32(<4 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000046 %elt = extractelement <4 x float> %tex, i32 0
47; Only first component used, test that dmask etc. is changed accordingly
48 ret float %elt
49}
50
51;CHECK-LABEL: {{^}}image_store_v4i32:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000052;CHECK: image_store v[0:3], v[4:7], s[0:7] dmask:0xf unorm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000053define amdgpu_ps void @image_store_v4i32(<8 x i32> inreg %rsrc, <4 x float> %data, <4 x i32> %coords) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000054main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000055 call void @llvm.amdgcn.image.store.v4f32.v4i32.v8i32(<4 x float> %data, <4 x i32> %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000056 ret void
57}
58
59;CHECK-LABEL: {{^}}image_store_v2i32:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000060;CHECK: image_store v[0:3], v[4:5], s[0:7] dmask:0xf unorm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000061define amdgpu_ps void @image_store_v2i32(<8 x i32> inreg %rsrc, <4 x float> %data, <2 x i32> %coords) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000062main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000063 call void @llvm.amdgcn.image.store.v4f32.v2i32.v8i32(<4 x float> %data, <2 x i32> %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000064 ret void
65}
66
67;CHECK-LABEL: {{^}}image_store_i32:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000068;CHECK: image_store v[0:3], v4, s[0:7] dmask:0xf unorm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000069define amdgpu_ps void @image_store_i32(<8 x i32> inreg %rsrc, <4 x float> %data, i32 %coords) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000070main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000071 call void @llvm.amdgcn.image.store.v4f32.i32.v8i32(<4 x float> %data, i32 %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000072 ret void
73}
74
75;CHECK-LABEL: {{^}}image_store_mip:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000076;CHECK: image_store_mip v[0:3], v[4:7], s[0:7] dmask:0xf unorm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000077define amdgpu_ps void @image_store_mip(<8 x i32> inreg %rsrc, <4 x float> %data, <4 x i32> %coords) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000078main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +000079 call void @llvm.amdgcn.image.store.mip.v4f32.v4i32.v8i32(<4 x float> %data, <4 x i32> %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000080 ret void
81}
82
Tom Stellardfac248c2016-10-12 16:35:29 +000083;CHECK-LABEL: {{^}}getresinfo:
84;CHECK: image_get_resinfo {{v\[[0-9]+:[0-9]+\]}}, {{v[0-9]+}}, {{s\[[0-9]+:[0-9]+\]}} dmask:0xf
85define amdgpu_ps void @getresinfo() {
86main_body:
87 %r = call <4 x float> @llvm.amdgcn.image.getresinfo.v4f32.i32.v8i32(i32 undef, <8 x i32> undef, i32 15, i1 0, i1 0, i1 0, i1 0)
88 %r0 = extractelement <4 x float> %r, i32 0
89 %r1 = extractelement <4 x float> %r, i32 1
90 %r2 = extractelement <4 x float> %r, i32 2
91 %r3 = extractelement <4 x float> %r, i32 3
92 call void @llvm.SI.export(i32 15, i32 1, i32 1, i32 0, i32 1, float %r0, float %r1, float %r2, float %r3)
93 ret void
94}
95
96
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000097; Ideally, the register allocator would avoid the wait here
98;
99;CHECK-LABEL: {{^}}image_store_wait:
Nikolay Haustov2f684f12016-02-26 09:51:05 +0000100;CHECK: image_store v[0:3], v4, s[0:7] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000101;CHECK: s_waitcnt vmcnt(0) expcnt(0)
Nikolay Haustov2f684f12016-02-26 09:51:05 +0000102;CHECK: image_load v[0:3], v4, s[8:15] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000103;CHECK: s_waitcnt vmcnt(0)
Nikolay Haustov2f684f12016-02-26 09:51:05 +0000104;CHECK: image_store v[0:3], v4, s[16:23] dmask:0xf unorm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000105define amdgpu_ps void @image_store_wait(<8 x i32> inreg, <8 x i32> inreg, <8 x i32> inreg, <4 x float>, i32) {
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000106main_body:
Tom Stellardfac248c2016-10-12 16:35:29 +0000107 call void @llvm.amdgcn.image.store.v4f32.i32.v8i32(<4 x float> %3, i32 %4, <8 x i32> %0, i32 15, i1 0, i1 0, i1 0, i1 0)
108 %data = call <4 x float> @llvm.amdgcn.image.load.v4f32.i32.v8i32(i32 %4, <8 x i32> %1, i32 15, i1 0, i1 0, i1 0, i1 0)
109 call void @llvm.amdgcn.image.store.v4f32.i32.v8i32(<4 x float> %data, i32 %4, <8 x i32> %2, i32 15, i1 0, i1 0, i1 0, i1 0)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000110 ret void
111}
112
Tom Stellardfac248c2016-10-12 16:35:29 +0000113declare void @llvm.amdgcn.image.store.v4f32.i32.v8i32(<4 x float>, i32, <8 x i32>, i32, i1, i1, i1, i1) #0
114declare void @llvm.amdgcn.image.store.v4f32.v2i32.v8i32(<4 x float>, <2 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #0
115declare void @llvm.amdgcn.image.store.v4f32.v4i32.v8i32(<4 x float>, <4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #0
116declare void @llvm.amdgcn.image.store.mip.v4f32.v4i32.v8i32(<4 x float>, <4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #0
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000117
Tom Stellardfac248c2016-10-12 16:35:29 +0000118declare <4 x float> @llvm.amdgcn.image.load.v4f32.i32.v8i32(i32, <8 x i32>, i32, i1, i1, i1, i1) #1
119declare <4 x float> @llvm.amdgcn.image.load.v4f32.v2i32.v8i32(<2 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
120declare <4 x float> @llvm.amdgcn.image.load.v4f32.v4i32.v8i32(<4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
121declare <4 x float> @llvm.amdgcn.image.load.mip.v4f32.v4i32.v8i32(<4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
122
123declare <4 x float> @llvm.amdgcn.image.getresinfo.v4f32.i32.v8i32(i32, <8 x i32>, i32, i1, i1, i1, i1) #0
124
125declare void @llvm.SI.export(i32, i32, i32, i32, i32, float, float, float, float)
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000126
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000127attributes #0 = { nounwind }
128attributes #1 = { nounwind readonly }