llvm.org GIT mirror llvm / 177d114
AMDGPU/GlobalISel: Basic legality for load/store git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327772 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 2 years ago
3 changed file(s) with 292 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
1313
1414 #include "AMDGPU.h"
1515 #include "AMDGPULegalizerInfo.h"
16 #include "AMDGPUTargetMachine.h"
1617 #include "llvm/CodeGen/TargetOpcodes.h"
1718 #include "llvm/CodeGen/ValueTypes.h"
1819 #include "llvm/IR/DerivedTypes.h"
2627 const GCNTargetMachine &TM) {
2728 using namespace TargetOpcode;
2829
29 const LLT S1= LLT::scalar(1);
30 auto GetAddrSpacePtr = [&TM](unsigned AS) {
31 return LLT::pointer(AS, TM.getPointerSizeInBits(AS));
32 };
33
34 const LLT S1 = LLT::scalar(1);
3035 const LLT V2S16 = LLT::vector(2, 16);
36
3137 const LLT S32 = LLT::scalar(32);
3238 const LLT S64 = LLT::scalar(64);
33 const LLT P1 = LLT::pointer(AMDGPUAS::GLOBAL_ADDRESS, 64);
34 const LLT P2 = LLT::pointer(AMDGPUAS::CONSTANT_ADDRESS, 64);
39
40 const LLT GlobalPtr = GetAddrSpacePtr(AMDGPUAS::GLOBAL_ADDRESS);
41 const LLT ConstantPtr = GetAddrSpacePtr(AMDGPUAS::CONSTANT_ADDRESS);
42
3543
3644 setAction({G_ADD, S32}, Legal);
3745 setAction({G_MUL, S32}, Legal);
7583 setAction({G_FPTOUI, S32}, Legal);
7684 setAction({G_FPTOUI, 1, S32}, Legal);
7785
78 setAction({G_GEP, P1}, Legal);
79 setAction({G_GEP, P2}, Legal);
86 setAction({G_GEP, GlobalPtr}, Legal);
87 setAction({G_GEP, ConstantPtr}, Legal);
8088 setAction({G_GEP, 1, S64}, Legal);
8189
8290 setAction({G_ICMP, S1}, Legal);
8391 setAction({G_ICMP, 1, S32}, Legal);
8492
85 setAction({G_LOAD, P1}, Legal);
86 setAction({G_LOAD, P2}, Legal);
87 setAction({G_LOAD, S32}, Legal);
88 setAction({G_LOAD, 1, P1}, Legal);
89 setAction({G_LOAD, 1, P2}, Legal);
93
94 getActionDefinitionsBuilder({G_LOAD, G_STORE})
95 .legalIf([=, &ST](const LegalityQuery &Query) {
96 const LLT &Ty0 = Query.Types[0];
97
98 // TODO: Decompose private loads into 4-byte components.
99 // TODO: Illegal flat loads on SI
100 switch (Ty0.getSizeInBits()) {
101 case 32:
102 case 64:
103 case 128:
104 return true;
105
106 case 96:
107 // XXX hasLoadX3
108 return (ST.getGeneration() >= AMDGPUSubtarget::SEA_ISLANDS);
109
110 case 256:
111 case 512:
112 // TODO: constant loads
113 default:
114 return false;
115 }
116 });
117
118
90119
91120 setAction({G_SELECT, S32}, Legal);
92121 setAction({G_SELECT, 1, S1}, Legal);
93122
94123 setAction({G_SHL, S32}, Legal);
95124
96 setAction({G_STORE, S32}, Legal);
97 setAction({G_STORE, 1, P1}, Legal);
98125
99126 // FIXME: When RegBankSelect inserts copies, it will only create new
100127 // registers with scalar types. This means we can end up with
103130 // if it sees a generic instruction which isn't legal, so we need to
104131 // tell it that scalar types are legal for pointer operands
105132 setAction({G_GEP, S64}, Legal);
106 setAction({G_LOAD, 1, S64}, Legal);
107 setAction({G_STORE, 1, S64}, Legal);
108133
109134 for (unsigned Op : {G_EXTRACT_VECTOR_ELT, G_INSERT_VECTOR_ELT}) {
110135 getActionDefinitionsBuilder(Op)
0 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -O0 -run-pass=legalizer -global-isel %s -o - | FileCheck %s
2
3 ---
4 name: test_load_global_i32
5 body: |
6 bb.0:
7 liveins: $vgpr0_vgpr1
8
9 ; CHECK-LABEL: name: test_load_global_i32
10 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
11 ; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
12 ; CHECK: $vgpr0 = COPY [[LOAD]](s32)
13 %0:_(p1) = COPY $vgpr0_vgpr1
14 %1:_(s32) = G_LOAD %0 :: (load 4, addrspace 1)
15
16 $vgpr0 = COPY %1
17 ...
18
19 ---
20 name: test_load_global_i64
21 body: |
22 bb.0:
23 liveins: $vgpr0_vgpr1
24
25 ; CHECK-LABEL: name: test_load_global_i64
26 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
27 ; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
28 ; CHECK: $vgpr0 = COPY [[LOAD]](s32)
29 %0:_(p1) = COPY $vgpr0_vgpr1
30 %1:_(s32) = G_LOAD %0 :: (load 4, addrspace 1)
31
32 $vgpr0 = COPY %1
33 ...
34
35 ---
36 name: test_load_global_p1
37 body: |
38 bb.0:
39 liveins: $vgpr0_vgpr1
40
41 ; CHECK-LABEL: name: test_load_global_p1
42 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
43 ; CHECK: [[LOAD:%[0-9]+]]:_(p1) = G_LOAD [[COPY]](p1) :: (load 8, addrspace 1)
44 ; CHECK: $vgpr0_vgpr1 = COPY [[LOAD]](p1)
45 %0:_(p1) = COPY $vgpr0_vgpr1
46 %1:_(p1) = G_LOAD %0 :: (load 8, addrspace 1)
47
48 $vgpr0_vgpr1 = COPY %1
49 ...
50
51 ---
52 name: test_load_global_p4
53 body: |
54 bb.0:
55 liveins: $vgpr0_vgpr1
56
57 ; CHECK-LABEL: name: test_load_global_p4
58 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
59 ; CHECK: [[LOAD:%[0-9]+]]:_(p4) = G_LOAD [[COPY]](p1) :: (load 8, addrspace 1)
60 ; CHECK: $vgpr0_vgpr1 = COPY [[LOAD]](p4)
61 %0:_(p1) = COPY $vgpr0_vgpr1
62 %1:_(p4) = G_LOAD %0 :: (load 8, addrspace 1)
63
64 $vgpr0_vgpr1 = COPY %1
65 ...
66
67
68 ---
69 name: test_load_global_p3
70 body: |
71 bb.0:
72 liveins: $vgpr0_vgpr1
73
74 ; CHECK-LABEL: name: test_load_global_p3
75 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
76 ; CHECK: [[LOAD:%[0-9]+]]:_(p3) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
77 ; CHECK: $vgpr0 = COPY [[LOAD]](p3)
78 %0:_(p1) = COPY $vgpr0_vgpr1
79 %1:_(p3) = G_LOAD %0 :: (load 4, addrspace 1)
80
81 $vgpr0 = COPY %1
82 ...
83
84 ---
85 name: test_load_global_v2s32
86 body: |
87 bb.0:
88 liveins: $vgpr0_vgpr1
89
90 ; CHECK-LABEL: name: test_load_global_v2s32
91 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
92 ; CHECK: [[LOAD:%[0-9]+]]:_(<2 x s32>) = G_LOAD [[COPY]](p1) :: (load 8, addrspace 1)
93 ; CHECK: $vgpr0_vgpr1 = COPY [[LOAD]](<2 x s32>)
94 %0:_(p1) = COPY $vgpr0_vgpr1
95 %1:_(<2 x s32>) = G_LOAD %0 :: (load 8, addrspace 1)
96
97 $vgpr0_vgpr1 = COPY %1
98 ...
99
100 ---
101
102 name: test_load_global_v2s16
103 body: |
104 bb.0:
105 liveins: $vgpr0_vgpr1
106
107 ; CHECK-LABEL: name: test_load_global_v2s16
108 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
109 ; CHECK: [[LOAD:%[0-9]+]]:_(<2 x s16>) = G_LOAD [[COPY]](p1) :: (load 4, addrspace 1)
110 ; CHECK: $vgpr0 = COPY [[LOAD]](<2 x s16>)
111 %0:_(p1) = COPY $vgpr0_vgpr1
112 %1:_(<2 x s16>) = G_LOAD %0 :: (load 4, addrspace 1)
113 $vgpr0 = COPY %1
114 ...
115
116 ---
117 name: test_load_global_v3i32
118 body: |
119 bb.0:
120 liveins: $vgpr0_vgpr1
121
122 ; CHECK-LABEL: name: test_load_global_v3i32
123 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
124 ; CHECK: [[LOAD:%[0-9]+]]:_(<3 x s32>) = G_LOAD [[COPY]](p1) :: (load 12, align 4, addrspace 1)
125 ; CHECK: $vgpr0_vgpr1_vgpr2 = COPY [[LOAD]](<3 x s32>)
126 %0:_(p1) = COPY $vgpr0_vgpr1
127 %1:_(<3 x s32>) = G_LOAD %0 :: (load 12, align 4, addrspace 1)
128
129 $vgpr0_vgpr1_vgpr2 = COPY %1
130 ...
0 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
1 # RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=fiji -O0 -run-pass=legalizer -global-isel %s -o - | FileCheck %s
2
3 ---
4 name: test_store_global_i32
5 body: |
6 bb.0:
7 liveins: $vgpr0_vgpr1, $vgpr2
8
9 ; CHECK-LABEL: name: test_store_global_i32
10 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
11 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $vgpr2
12 ; CHECK: G_STORE [[COPY1]](s32), [[COPY]](p1) :: (store 4, addrspace 1)
13 %0:_(p1) = COPY $vgpr0_vgpr1
14 %1:_(s32) = COPY $vgpr2
15 G_STORE %1, %0 :: (store 4, addrspace 1)
16 ...
17
18 ---
19 name: test_store_global_i64
20 body: |
21 bb.0:
22 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
23
24 ; CHECK-LABEL: name: test_store_global_i64
25 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
26 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $vgpr2_vgpr3
27 ; CHECK: G_STORE [[COPY1]](s64), [[COPY]](p1) :: (store 8, addrspace 1)
28 %0:_(p1) = COPY $vgpr0_vgpr1
29 %1:_(s64) = COPY $vgpr2_vgpr3
30 G_STORE %1, %0 :: (store 8, addrspace 1)
31 ...
32
33 ---
34 name: test_store_global_p1
35 body: |
36 bb.0:
37 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
38
39 ; CHECK-LABEL: name: test_store_global_p1
40 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
41 ; CHECK: [[COPY1:%[0-9]+]]:_(p1) = COPY $vgpr2_vgpr3
42 ; CHECK: G_STORE [[COPY1]](p1), [[COPY]](p1) :: (store 8, addrspace 1)
43 %0:_(p1) = COPY $vgpr0_vgpr1
44 %1:_(p1) = COPY $vgpr2_vgpr3
45 G_STORE %1, %0 :: (store 8, addrspace 1)
46 ...
47
48 ---
49 name: test_store_global_p4
50 body: |
51 bb.0:
52 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
53
54 ; CHECK-LABEL: name: test_store_global_p4
55 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
56 ; CHECK: [[COPY1:%[0-9]+]]:_(p4) = COPY $vgpr2_vgpr3
57 ; CHECK: G_STORE [[COPY1]](p4), [[COPY]](p1) :: (store 8, addrspace 1)
58 %0:_(p1) = COPY $vgpr0_vgpr1
59 %1:_(p4) = COPY $vgpr2_vgpr3
60 G_STORE %1, %0 :: (store 8, addrspace 1)
61 ...
62
63 ---
64 name: test_store_global_p3
65 body: |
66 bb.0:
67 liveins: $vgpr0_vgpr1, $vgpr2
68
69 ; CHECK-LABEL: name: test_store_global_p3
70 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
71 ; CHECK: [[COPY1:%[0-9]+]]:_(p3) = COPY $vgpr2
72 ; CHECK: G_STORE [[COPY1]](p3), [[COPY]](p1) :: (store 4, addrspace 1)
73 %0:_(p1) = COPY $vgpr0_vgpr1
74 %1:_(p3) = COPY $vgpr2
75 G_STORE %1, %0 :: (store 4, addrspace 1)
76 ...
77
78 ---
79 name: test_store_global_v2s32
80 body: |
81 bb.0:
82 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
83
84 ; CHECK-LABEL: name: test_store_global_v2s32
85 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
86 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s32>) = COPY $vgpr2_vgpr3
87 ; CHECK: G_STORE [[COPY1]](<2 x s32>), [[COPY]](p1) :: (store 8, addrspace 1)
88 %0:_(p1) = COPY $vgpr0_vgpr1
89 %1:_(<2 x s32>) = COPY $vgpr2_vgpr3
90 G_STORE %1, %0 :: (store 8, addrspace 1)
91 ...
92
93 ---
94 name: test_store_global_v2s16
95 body: |
96 bb.0:
97 liveins: $vgpr0_vgpr1, $vgpr2
98
99 ; CHECK-LABEL: name: test_store_global_v2s16
100 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
101 ; CHECK: [[COPY1:%[0-9]+]]:_(<2 x s16>) = COPY $vgpr2
102 ; CHECK: G_STORE [[COPY1]](<2 x s16>), [[COPY]](p1) :: (store 4, addrspace 1)
103 %0:_(p1) = COPY $vgpr0_vgpr1
104 %1:_(<2 x s16>) = COPY $vgpr2
105 G_STORE %1, %0 :: (store 4, addrspace 1)
106 ...
107
108 ---
109 name: test_store_global_v3s32
110 body: |
111 bb.0:
112 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3_vgpr4
113
114 ; CHECK-LABEL: name: test_store_global_v3s32
115 ; CHECK: [[COPY:%[0-9]+]]:_(p1) = COPY $vgpr0_vgpr1
116 ; CHECK: [[COPY1:%[0-9]+]]:_(<3 x s32>) = COPY $vgpr2_vgpr3_vgpr4
117 ; CHECK: G_STORE [[COPY1]](<3 x s32>), [[COPY]](p1) :: (store 12, align 4, addrspace 1)
118 %0:_(p1) = COPY $vgpr0_vgpr1
119 %1:_(<3 x s32>) = COPY $vgpr2_vgpr3_vgpr4
120 G_STORE %1, %0 :: (store 12, align 4, addrspace 1)
121 ...