llvm.org GIT mirror llvm / 3d8c2ce
Clean up some of the shuffle decoding code for UNPCK instructions. Add instruction commenting for AVX/AVX2 forms for integer UNPCKs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145924 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 8 years ago
4 changed file(s) with 157 addition(s) and 84 deletion(s). Raw diff Collapse all Expand all
105105 // FALL THROUGH.
106106 case X86::PUNPCKHBWrm:
107107 Src1Name = getRegName(MI->getOperand(0).getReg());
108 DecodePUNPCKHMask(16, ShuffleMask);
108 DecodeUNPCKHMask(MVT::v16i8, ShuffleMask);
109 break;
110 case X86::VPUNPCKHBWrr:
111 Src2Name = getRegName(MI->getOperand(2).getReg());
112 // FALL THROUGH.
113 case X86::VPUNPCKHBWrm:
114 Src1Name = getRegName(MI->getOperand(1).getReg());
115 DestName = getRegName(MI->getOperand(0).getReg());
116 DecodeUNPCKHMask(MVT::v16i8, ShuffleMask);
117 break;
118 case X86::VPUNPCKHBWYrr:
119 Src2Name = getRegName(MI->getOperand(2).getReg());
120 // FALL THROUGH.
121 case X86::VPUNPCKHBWYrm:
122 Src1Name = getRegName(MI->getOperand(1).getReg());
123 DestName = getRegName(MI->getOperand(0).getReg());
124 DecodeUNPCKHMask(MVT::v32i8, ShuffleMask);
109125 break;
110126 case X86::PUNPCKHWDrr:
111127 Src2Name = getRegName(MI->getOperand(2).getReg());
112128 // FALL THROUGH.
113129 case X86::PUNPCKHWDrm:
114130 Src1Name = getRegName(MI->getOperand(0).getReg());
115 DecodePUNPCKHMask(8, ShuffleMask);
131 DecodeUNPCKHMask(MVT::v8i16, ShuffleMask);
132 break;
133 case X86::VPUNPCKHWDrr:
134 Src2Name = getRegName(MI->getOperand(2).getReg());
135 // FALL THROUGH.
136 case X86::VPUNPCKHWDrm:
137 Src1Name = getRegName(MI->getOperand(1).getReg());
138 DestName = getRegName(MI->getOperand(0).getReg());
139 DecodeUNPCKHMask(MVT::v8i16, ShuffleMask);
140 break;
141 case X86::VPUNPCKHWDYrr:
142 Src2Name = getRegName(MI->getOperand(2).getReg());
143 // FALL THROUGH.
144 case X86::VPUNPCKHWDYrm:
145 Src1Name = getRegName(MI->getOperand(1).getReg());
146 DestName = getRegName(MI->getOperand(0).getReg());
147 DecodeUNPCKHMask(MVT::v16i16, ShuffleMask);
116148 break;
117149 case X86::PUNPCKHDQrr:
118150 Src2Name = getRegName(MI->getOperand(2).getReg());
119151 // FALL THROUGH.
120152 case X86::PUNPCKHDQrm:
121153 Src1Name = getRegName(MI->getOperand(0).getReg());
122 DecodePUNPCKHMask(4, ShuffleMask);
154 DecodeUNPCKHMask(MVT::v4i32, ShuffleMask);
155 break;
156 case X86::VPUNPCKHDQrr:
157 Src2Name = getRegName(MI->getOperand(2).getReg());
158 // FALL THROUGH.
159 case X86::VPUNPCKHDQrm:
160 Src1Name = getRegName(MI->getOperand(1).getReg());
161 DestName = getRegName(MI->getOperand(0).getReg());
162 DecodeUNPCKHMask(MVT::v4i32, ShuffleMask);
163 break;
164 case X86::VPUNPCKHDQYrr:
165 Src2Name = getRegName(MI->getOperand(2).getReg());
166 // FALL THROUGH.
167 case X86::VPUNPCKHDQYrm:
168 Src1Name = getRegName(MI->getOperand(1).getReg());
169 DestName = getRegName(MI->getOperand(0).getReg());
170 DecodeUNPCKHMask(MVT::v8i32, ShuffleMask);
123171 break;
124172 case X86::PUNPCKHQDQrr:
125173 Src2Name = getRegName(MI->getOperand(2).getReg());
126174 // FALL THROUGH.
127175 case X86::PUNPCKHQDQrm:
128176 Src1Name = getRegName(MI->getOperand(0).getReg());
129 DecodePUNPCKHMask(2, ShuffleMask);
177 DecodeUNPCKHMask(MVT::v2i64, ShuffleMask);
178 break;
179 case X86::VPUNPCKHQDQrr:
180 Src2Name = getRegName(MI->getOperand(2).getReg());
181 // FALL THROUGH.
182 case X86::VPUNPCKHQDQrm:
183 Src1Name = getRegName(MI->getOperand(1).getReg());
184 DestName = getRegName(MI->getOperand(0).getReg());
185 DecodeUNPCKHMask(MVT::v2i64, ShuffleMask);
186 break;
187 case X86::VPUNPCKHQDQYrr:
188 Src2Name = getRegName(MI->getOperand(2).getReg());
189 // FALL THROUGH.
190 case X86::VPUNPCKHQDQYrm:
191 Src1Name = getRegName(MI->getOperand(1).getReg());
192 DestName = getRegName(MI->getOperand(0).getReg());
193 DecodeUNPCKHMask(MVT::v4i64, ShuffleMask);
130194 break;
131195
132196 case X86::PUNPCKLBWrr:
134198 // FALL THROUGH.
135199 case X86::PUNPCKLBWrm:
136200 Src1Name = getRegName(MI->getOperand(0).getReg());
137 DecodePUNPCKLBWMask(16, ShuffleMask);
201 DecodeUNPCKLMask(MVT::v16i8, ShuffleMask);
202 break;
203 case X86::VPUNPCKLBWrr:
204 Src2Name = getRegName(MI->getOperand(2).getReg());
205 // FALL THROUGH.
206 case X86::VPUNPCKLBWrm:
207 Src1Name = getRegName(MI->getOperand(1).getReg());
208 DestName = getRegName(MI->getOperand(0).getReg());
209 DecodeUNPCKLMask(MVT::v16i8, ShuffleMask);
210 break;
211 case X86::VPUNPCKLBWYrr:
212 Src2Name = getRegName(MI->getOperand(2).getReg());
213 // FALL THROUGH.
214 case X86::VPUNPCKLBWYrm:
215 Src1Name = getRegName(MI->getOperand(1).getReg());
216 DestName = getRegName(MI->getOperand(0).getReg());
217 DecodeUNPCKLMask(MVT::v32i8, ShuffleMask);
138218 break;
139219 case X86::PUNPCKLWDrr:
140220 Src2Name = getRegName(MI->getOperand(2).getReg());
141221 // FALL THROUGH.
142222 case X86::PUNPCKLWDrm:
143223 Src1Name = getRegName(MI->getOperand(0).getReg());
144 DecodePUNPCKLWDMask(8, ShuffleMask);
224 DecodeUNPCKLMask(MVT::v8i16, ShuffleMask);
225 break;
226 case X86::VPUNPCKLWDrr:
227 Src2Name = getRegName(MI->getOperand(2).getReg());
228 // FALL THROUGH.
229 case X86::VPUNPCKLWDrm:
230 Src1Name = getRegName(MI->getOperand(1).getReg());
231 DestName = getRegName(MI->getOperand(0).getReg());
232 DecodeUNPCKLMask(MVT::v8i16, ShuffleMask);
233 break;
234 case X86::VPUNPCKLWDYrr:
235 Src2Name = getRegName(MI->getOperand(2).getReg());
236 // FALL THROUGH.
237 case X86::VPUNPCKLWDYrm:
238 Src1Name = getRegName(MI->getOperand(1).getReg());
239 DestName = getRegName(MI->getOperand(0).getReg());
240 DecodeUNPCKLMask(MVT::v16i16, ShuffleMask);
145241 break;
146242 case X86::PUNPCKLDQrr:
147243 Src2Name = getRegName(MI->getOperand(2).getReg());
148244 // FALL THROUGH.
149245 case X86::PUNPCKLDQrm:
150246 Src1Name = getRegName(MI->getOperand(0).getReg());
151 DecodePUNPCKLDQMask(4, ShuffleMask);
247 DecodeUNPCKLMask(MVT::v4i32, ShuffleMask);
248 break;
249 case X86::VPUNPCKLDQrr:
250 Src2Name = getRegName(MI->getOperand(2).getReg());
251 // FALL THROUGH.
252 case X86::VPUNPCKLDQrm:
253 Src1Name = getRegName(MI->getOperand(1).getReg());
254 DestName = getRegName(MI->getOperand(0).getReg());
255 DecodeUNPCKLMask(MVT::v4i32, ShuffleMask);
256 break;
257 case X86::VPUNPCKLDQYrr:
258 Src2Name = getRegName(MI->getOperand(2).getReg());
259 // FALL THROUGH.
260 case X86::VPUNPCKLDQYrm:
261 Src1Name = getRegName(MI->getOperand(1).getReg());
262 DestName = getRegName(MI->getOperand(0).getReg());
263 DecodeUNPCKLMask(MVT::v8i32, ShuffleMask);
152264 break;
153265 case X86::PUNPCKLQDQrr:
154266 Src2Name = getRegName(MI->getOperand(2).getReg());
155267 // FALL THROUGH.
156268 case X86::PUNPCKLQDQrm:
157269 Src1Name = getRegName(MI->getOperand(0).getReg());
158 DecodePUNPCKLQDQMask(2, ShuffleMask);
270 DecodeUNPCKLMask(MVT::v2i64, ShuffleMask);
271 break;
272 case X86::VPUNPCKLQDQrr:
273 Src2Name = getRegName(MI->getOperand(2).getReg());
274 // FALL THROUGH.
275 case X86::VPUNPCKLQDQrm:
276 Src1Name = getRegName(MI->getOperand(1).getReg());
277 DestName = getRegName(MI->getOperand(0).getReg());
278 DecodeUNPCKLMask(MVT::v2i64, ShuffleMask);
279 break;
280 case X86::VPUNPCKLQDQYrr:
281 Src2Name = getRegName(MI->getOperand(2).getReg());
282 // FALL THROUGH.
283 case X86::VPUNPCKLQDQYrm:
284 Src1Name = getRegName(MI->getOperand(1).getReg());
285 DestName = getRegName(MI->getOperand(0).getReg());
286 DecodeUNPCKLMask(MVT::v4i64, ShuffleMask);
159287 break;
160288
161289 case X86::SHUFPDrri:
216344 Src2Name = getRegName(MI->getOperand(2).getReg());
217345 // FALL THROUGH.
218346 case X86::UNPCKLPDrm:
219 DecodeUNPCKLPMask(MVT::v2f64, ShuffleMask);
347 DecodeUNPCKLMask(MVT::v2f64, ShuffleMask);
220348 Src1Name = getRegName(MI->getOperand(0).getReg());
221349 break;
222350 case X86::VUNPCKLPDrr:
223351 Src2Name = getRegName(MI->getOperand(2).getReg());
224352 // FALL THROUGH.
225353 case X86::VUNPCKLPDrm:
226 DecodeUNPCKLPMask(MVT::v2f64, ShuffleMask);
354 DecodeUNPCKLMask(MVT::v2f64, ShuffleMask);
227355 Src1Name = getRegName(MI->getOperand(1).getReg());
228356 DestName = getRegName(MI->getOperand(0).getReg());
229357 break;
231359 Src2Name = getRegName(MI->getOperand(2).getReg());
232360 // FALL THROUGH.
233361 case X86::VUNPCKLPDYrm:
234 DecodeUNPCKLPMask(MVT::v4f64, ShuffleMask);
362 DecodeUNPCKLMask(MVT::v4f64, ShuffleMask);
235363 Src1Name = getRegName(MI->getOperand(1).getReg());
236364 DestName = getRegName(MI->getOperand(0).getReg());
237365 break;
239367 Src2Name = getRegName(MI->getOperand(2).getReg());
240368 // FALL THROUGH.
241369 case X86::UNPCKLPSrm:
242 DecodeUNPCKLPMask(MVT::v4f32, ShuffleMask);
370 DecodeUNPCKLMask(MVT::v4f32, ShuffleMask);
243371 Src1Name = getRegName(MI->getOperand(0).getReg());
244372 break;
245373 case X86::VUNPCKLPSrr:
246374 Src2Name = getRegName(MI->getOperand(2).getReg());
247375 // FALL THROUGH.
248376 case X86::VUNPCKLPSrm:
249 DecodeUNPCKLPMask(MVT::v4f32, ShuffleMask);
377 DecodeUNPCKLMask(MVT::v4f32, ShuffleMask);
250378 Src1Name = getRegName(MI->getOperand(1).getReg());
251379 DestName = getRegName(MI->getOperand(0).getReg());
252380 break;
254382 Src2Name = getRegName(MI->getOperand(2).getReg());
255383 // FALL THROUGH.
256384 case X86::VUNPCKLPSYrm:
257 DecodeUNPCKLPMask(MVT::v8f32, ShuffleMask);
385 DecodeUNPCKLMask(MVT::v8f32, ShuffleMask);
258386 Src1Name = getRegName(MI->getOperand(1).getReg());
259387 DestName = getRegName(MI->getOperand(0).getReg());
260388 break;
262390 Src2Name = getRegName(MI->getOperand(2).getReg());
263391 // FALL THROUGH.
264392 case X86::UNPCKHPDrm:
265 DecodeUNPCKHPMask(MVT::v2f64, ShuffleMask);
393 DecodeUNPCKHMask(MVT::v2f64, ShuffleMask);
266394 Src1Name = getRegName(MI->getOperand(0).getReg());
267395 break;
268396 case X86::VUNPCKHPDrr:
269397 Src2Name = getRegName(MI->getOperand(2).getReg());
270398 // FALL THROUGH.
271399 case X86::VUNPCKHPDrm:
272 DecodeUNPCKHPMask(MVT::v2f64, ShuffleMask);
400 DecodeUNPCKHMask(MVT::v2f64, ShuffleMask);
273401 Src1Name = getRegName(MI->getOperand(1).getReg());
274402 DestName = getRegName(MI->getOperand(0).getReg());
275403 break;
277405 Src2Name = getRegName(MI->getOperand(2).getReg());
278406 // FALL THROUGH.
279407 case X86::VUNPCKHPDYrm:
280 DecodeUNPCKLPMask(MVT::v4f64, ShuffleMask);
408 DecodeUNPCKHMask(MVT::v4f64, ShuffleMask);
281409 Src1Name = getRegName(MI->getOperand(1).getReg());
282410 DestName = getRegName(MI->getOperand(0).getReg());
283411 break;
285413 Src2Name = getRegName(MI->getOperand(2).getReg());
286414 // FALL THROUGH.
287415 case X86::UNPCKHPSrm:
288 DecodeUNPCKHPMask(MVT::v4f32, ShuffleMask);
416 DecodeUNPCKHMask(MVT::v4f32, ShuffleMask);
289417 Src1Name = getRegName(MI->getOperand(0).getReg());
290418 break;
291419 case X86::VUNPCKHPSrr:
292420 Src2Name = getRegName(MI->getOperand(2).getReg());
293421 // FALL THROUGH.
294422 case X86::VUNPCKHPSrm:
295 DecodeUNPCKHPMask(MVT::v4f32, ShuffleMask);
423 DecodeUNPCKHMask(MVT::v4f32, ShuffleMask);
296424 Src1Name = getRegName(MI->getOperand(1).getReg());
297425 DestName = getRegName(MI->getOperand(0).getReg());
298426 break;
300428 Src2Name = getRegName(MI->getOperand(2).getReg());
301429 // FALL THROUGH.
302430 case X86::VUNPCKHPSYrm:
303 DecodeUNPCKHPMask(MVT::v8f32, ShuffleMask);
431 DecodeUNPCKHMask(MVT::v8f32, ShuffleMask);
304432 Src1Name = getRegName(MI->getOperand(1).getReg());
305433 DestName = getRegName(MI->getOperand(0).getReg());
306434 break;
9494 ShuffleMask.push_back(7);
9595 }
9696
97 void DecodePUNPCKLBWMask(unsigned NElts,
98 SmallVectorImpl &ShuffleMask) {
99 DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i8, NElts), ShuffleMask);
100 }
101
102 void DecodePUNPCKLWDMask(unsigned NElts,
103 SmallVectorImpl &ShuffleMask) {
104 DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i16, NElts), ShuffleMask);
105 }
106
107 void DecodePUNPCKLDQMask(unsigned NElts,
108 SmallVectorImpl &ShuffleMask) {
109 DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i32, NElts), ShuffleMask);
110 }
111
112 void DecodePUNPCKLQDQMask(unsigned NElts,
113 SmallVectorImpl &ShuffleMask) {
114 DecodeUNPCKLPMask(MVT::getVectorVT(MVT::i64, NElts), ShuffleMask);
115 }
116
117 void DecodePUNPCKLMask(EVT VT,
118 SmallVectorImpl &ShuffleMask) {
119 DecodeUNPCKLPMask(VT, ShuffleMask);
120 }
121
122 void DecodePUNPCKHMask(unsigned NElts,
123 SmallVectorImpl &ShuffleMask) {
124 for (unsigned i = 0; i != NElts/2; ++i) {
125 ShuffleMask.push_back(i+NElts/2);
126 ShuffleMask.push_back(i+NElts+NElts/2);
127 }
128 }
129
13097 void DecodeSHUFPMask(EVT VT, unsigned Imm,
13198 SmallVectorImpl &ShuffleMask) {
13299 unsigned NumElts = VT.getVectorNumElements();
151118 }
152119 }
153120
154 void DecodeUNPCKHPMask(EVT VT, SmallVectorImpl &ShuffleMask) {
121 void DecodeUNPCKHMask(EVT VT, SmallVectorImpl &ShuffleMask) {
155122 unsigned NumElts = VT.getVectorNumElements();
156123
157124 // Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
170137 }
171138 }
172139
173 /// DecodeUNPCKLPMask - This decodes the shuffle masks for unpcklps/unpcklpd
140 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
174141 /// etc. VT indicates the type of the vector allowing it to handle different
175142 /// datatypes and vector widths.
176 void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl &ShuffleMask) {
143 void DecodeUNPCKLMask(EVT VT, SmallVectorImpl &ShuffleMask) {
177144 unsigned NumElts = VT.getVectorNumElements();
178145
179146 // Handle 128 and 256-bit vector lengths. AVX defines UNPCK* to operate
4545 void DecodePSHUFLWMask(unsigned Imm,
4646 SmallVectorImpl &ShuffleMask);
4747
48 void DecodePUNPCKLBWMask(unsigned NElts,
49 SmallVectorImpl &ShuffleMask);
50
51 void DecodePUNPCKLWDMask(unsigned NElts,
52 SmallVectorImpl &ShuffleMask);
53
54 void DecodePUNPCKLDQMask(unsigned NElts,
55 SmallVectorImpl &ShuffleMask);
56
57 void DecodePUNPCKLQDQMask(unsigned NElts,
58 SmallVectorImpl &ShuffleMask);
59
60 void DecodePUNPCKLMask(EVT VT,
61 SmallVectorImpl &ShuffleMask);
62
63 void DecodePUNPCKHMask(unsigned NElts,
64 SmallVectorImpl &ShuffleMask);
65
6648 void DecodeSHUFPMask(EVT VT, unsigned Imm,
6749 SmallVectorImpl &ShuffleMask);
6850
69 /// DecodeUNPCKHPMask - This decodes the shuffle masks for unpckhps/unpckhpd
51 /// DecodeUNPCKHMask - This decodes the shuffle masks for unpckhps/unpckhpd
7052 /// etc. VT indicates the type of the vector allowing it to handle different
7153 /// datatypes and vector widths.
72 void DecodeUNPCKHPMask(EVT VT, SmallVectorImpl &ShuffleMask);
54 void DecodeUNPCKHMask(EVT VT, SmallVectorImpl &ShuffleMask);
7355
74 /// DecodeUNPCKLPMask - This decodes the shuffle masks for unpcklps/unpcklpd
56 /// DecodeUNPCKLMask - This decodes the shuffle masks for unpcklps/unpcklpd
7557 /// etc. VT indicates the type of the vector allowing it to handle different
7658 /// datatypes and vector widths.
77 void DecodeUNPCKLPMask(EVT VT, SmallVectorImpl &ShuffleMask);
59 void DecodeUNPCKLMask(EVT VT, SmallVectorImpl &ShuffleMask);
7860
7961
8062 // DecodeVPERMILPMask - Decodes VPERMILPS/ VPERMILPD permutes for any 128-bit
44604460 ShuffleMask);
44614461 break;
44624462 case X86ISD::PUNPCKH:
4463 DecodePUNPCKHMask(NumElems, ShuffleMask);
4464 break;
44654463 case X86ISD::UNPCKHP:
4466 DecodeUNPCKHPMask(VT, ShuffleMask);
4464 DecodeUNPCKHMask(VT, ShuffleMask);
44674465 break;
44684466 case X86ISD::PUNPCKL:
4469 DecodePUNPCKLMask(VT, ShuffleMask);
4470 break;
44714467 case X86ISD::UNPCKLP:
4472 DecodeUNPCKLPMask(VT, ShuffleMask);
4468 DecodeUNPCKLMask(VT, ShuffleMask);
44734469 break;
44744470 case X86ISD::MOVHLPS:
44754471 DecodeMOVHLPSMask(NumElems, ShuffleMask);