blob: f0d23b93119d7aadea128c39ba662a31f2f1708c [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:
9 %tex = call <4 x float> @llvm.amdgcn.image.load.v4i32(<4 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
10 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:
18 %tex = call <4 x float> @llvm.amdgcn.image.load.v2i32(<2 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
19 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:
27 %tex = call <4 x float> @llvm.amdgcn.image.load.i32(i32 %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
28 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:
36 %tex = call <4 x float> @llvm.amdgcn.image.load.mip.v4i32(<4 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
37 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:
45 %tex = call <4 x float> @llvm.amdgcn.image.load.v4i32(<4 x i32> %c, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
46 %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:
55 call void @llvm.amdgcn.image.store.v4i32(<4 x float> %data, <4 x i32> %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
56 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:
63 call void @llvm.amdgcn.image.store.v2i32(<4 x float> %data, <2 x i32> %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
64 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:
71 call void @llvm.amdgcn.image.store.i32(<4 x float> %data, i32 %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
72 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:
79 call void @llvm.amdgcn.image.store.mip.v4i32(<4 x float> %data, <4 x i32> %coords, <8 x i32> %rsrc, i32 15, i1 0, i1 0, i1 0, i1 0)
80 ret void
81}
82
83; Ideally, the register allocator would avoid the wait here
84;
85;CHECK-LABEL: {{^}}image_store_wait:
Nikolay Haustov2f684f12016-02-26 09:51:05 +000086;CHECK: image_store v[0:3], v4, s[0:7] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000087;CHECK: s_waitcnt vmcnt(0) expcnt(0)
Nikolay Haustov2f684f12016-02-26 09:51:05 +000088;CHECK: image_load v[0:3], v4, s[8:15] dmask:0xf unorm
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +000089;CHECK: s_waitcnt vmcnt(0)
Nikolay Haustov2f684f12016-02-26 09:51:05 +000090;CHECK: image_store v[0:3], v4, s[16:23] dmask:0xf unorm
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000091define 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 +000092main_body:
93 call void @llvm.amdgcn.image.store.i32(<4 x float> %3, i32 %4, <8 x i32> %0, i32 15, i1 0, i1 0, i1 0, i1 0)
94 %data = call <4 x float> @llvm.amdgcn.image.load.i32(i32 %4, <8 x i32> %1, i32 15, i1 0, i1 0, i1 0, i1 0)
95 call void @llvm.amdgcn.image.store.i32(<4 x float> %data, i32 %4, <8 x i32> %2, i32 15, i1 0, i1 0, i1 0, i1 0)
96 ret void
97}
98
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000099declare void @llvm.amdgcn.image.store.i32(<4 x float>, i32, <8 x i32>, i32, i1, i1, i1, i1) #0
100declare void @llvm.amdgcn.image.store.v2i32(<4 x float>, <2 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #0
101declare void @llvm.amdgcn.image.store.v4i32(<4 x float>, <4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #0
102declare void @llvm.amdgcn.image.store.mip.v4i32(<4 x float>, <4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #0
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000103
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000104declare <4 x float> @llvm.amdgcn.image.load.i32(i32, <8 x i32>, i32, i1, i1, i1, i1) #1
105declare <4 x float> @llvm.amdgcn.image.load.v2i32(<2 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
106declare <4 x float> @llvm.amdgcn.image.load.v4i32(<4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
107declare <4 x float> @llvm.amdgcn.image.load.mip.v4i32(<4 x i32>, <8 x i32>, i32, i1, i1, i1, i1) #1
Nicolai Haehnlef2c64db2016-02-18 16:44:18 +0000108
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000109attributes #0 = { nounwind }
110attributes #1 = { nounwind readonly }