1 //==- SPUInstrInfo.td - Describe the Cell SPU Instructions -*- tablegen -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
9 // Cell SPU Instructions:
10 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
13 // TODO Items (not urgent today, but would be nice, low priority)
15 // ANDBI, ORBI: SPU constructs a 4-byte constant for these instructions by
16 // concatenating the byte argument b as "bbbb". Could recognize this bit pattern
17 // in 16-bit and 32-bit constants and reduce instruction count.
18 //===----------------------------------------------------------------------===//
20 //===----------------------------------------------------------------------===//
21 // Pseudo instructions:
22 //===----------------------------------------------------------------------===//
24 let hasCtrlDep = 1, Defs = [R1], Uses = [R1] in {
25 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm_i32:$amt),
26 "${:comment} ADJCALLSTACKDOWN",
27 [(callseq_start timm:$amt)]>;
28 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt),
29 "${:comment} ADJCALLSTACKUP",
30 [(callseq_end timm:$amt)]>;
33 //===----------------------------------------------------------------------===//
34 // DWARF debugging Pseudo Instructions
35 //===----------------------------------------------------------------------===//
37 def DWARF_LOC : Pseudo<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file),
38 ".loc $file, $line, $col",
39 [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>;
41 //===----------------------------------------------------------------------===//
43 // NB: The ordering is actually important, since the instruction selection
44 // will try each of the instructions in sequence, i.e., the D-form first with
45 // the 10-bit displacement, then the A-form with the 16 bit displacement, and
46 // finally the X-form with the register-register.
47 //===----------------------------------------------------------------------===//
49 let canFoldAsLoad = 1 in {
50 class LoadDFormVec<ValueType vectype>
51 : RI10Form<0b00101100, (outs VECREG:$rT), (ins dformaddr:$src),
54 [(set (vectype VECREG:$rT), (load dform_addr:$src))]>
57 class LoadDForm<RegisterClass rclass>
58 : RI10Form<0b00101100, (outs rclass:$rT), (ins dformaddr:$src),
61 [(set rclass:$rT, (load dform_addr:$src))]>
66 def v16i8: LoadDFormVec<v16i8>;
67 def v8i16: LoadDFormVec<v8i16>;
68 def v4i32: LoadDFormVec<v4i32>;
69 def v2i64: LoadDFormVec<v2i64>;
70 def v4f32: LoadDFormVec<v4f32>;
71 def v2f64: LoadDFormVec<v2f64>;
73 def v2i32: LoadDFormVec<v2i32>;
75 def r128: LoadDForm<GPRC>;
76 def r64: LoadDForm<R64C>;
77 def r32: LoadDForm<R32C>;
78 def f32: LoadDForm<R32FP>;
79 def f64: LoadDForm<R64FP>;
80 def r16: LoadDForm<R16C>;
81 def r8: LoadDForm<R8C>;
84 class LoadAFormVec<ValueType vectype>
85 : RI16Form<0b100001100, (outs VECREG:$rT), (ins addr256k:$src),
88 [(set (vectype VECREG:$rT), (load aform_addr:$src))]>
91 class LoadAForm<RegisterClass rclass>
92 : RI16Form<0b100001100, (outs rclass:$rT), (ins addr256k:$src),
95 [(set rclass:$rT, (load aform_addr:$src))]>
100 def v16i8: LoadAFormVec<v16i8>;
101 def v8i16: LoadAFormVec<v8i16>;
102 def v4i32: LoadAFormVec<v4i32>;
103 def v2i64: LoadAFormVec<v2i64>;
104 def v4f32: LoadAFormVec<v4f32>;
105 def v2f64: LoadAFormVec<v2f64>;
107 def v2i32: LoadAFormVec<v2i32>;
109 def r128: LoadAForm<GPRC>;
110 def r64: LoadAForm<R64C>;
111 def r32: LoadAForm<R32C>;
112 def f32: LoadAForm<R32FP>;
113 def f64: LoadAForm<R64FP>;
114 def r16: LoadAForm<R16C>;
115 def r8: LoadAForm<R8C>;
118 class LoadXFormVec<ValueType vectype>
119 : RRForm<0b00100011100, (outs VECREG:$rT), (ins memrr:$src),
122 [(set (vectype VECREG:$rT), (load xform_addr:$src))]>
125 class LoadXForm<RegisterClass rclass>
126 : RRForm<0b00100011100, (outs rclass:$rT), (ins memrr:$src),
129 [(set rclass:$rT, (load xform_addr:$src))]>
132 multiclass LoadXForms
134 def v16i8: LoadXFormVec<v16i8>;
135 def v8i16: LoadXFormVec<v8i16>;
136 def v4i32: LoadXFormVec<v4i32>;
137 def v2i64: LoadXFormVec<v2i64>;
138 def v4f32: LoadXFormVec<v4f32>;
139 def v2f64: LoadXFormVec<v2f64>;
141 def v2i32: LoadXFormVec<v2i32>;
143 def r128: LoadXForm<GPRC>;
144 def r64: LoadXForm<R64C>;
145 def r32: LoadXForm<R32C>;
146 def f32: LoadXForm<R32FP>;
147 def f64: LoadXForm<R64FP>;
148 def r16: LoadXForm<R16C>;
149 def r8: LoadXForm<R8C>;
152 defm LQA : LoadAForms;
153 defm LQD : LoadDForms;
154 defm LQX : LoadXForms;
156 /* Load quadword, PC relative: Not much use at this point in time.
157 Might be of use later for relocatable code. It's effectively the
158 same as LQA, but uses PC-relative addressing.
159 def LQR : RI16Form<0b111001100, (outs VECREG:$rT), (ins s16imm:$disp),
160 "lqr\t$rT, $disp", LoadStore,
161 [(set VECREG:$rT, (load iaddr:$disp))]>;
165 //===----------------------------------------------------------------------===//
167 //===----------------------------------------------------------------------===//
168 class StoreDFormVec<ValueType vectype>
169 : RI10Form<0b00100100, (outs), (ins VECREG:$rT, dformaddr:$src),
172 [(store (vectype VECREG:$rT), dform_addr:$src)]>
175 class StoreDForm<RegisterClass rclass>
176 : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$src),
179 [(store rclass:$rT, dform_addr:$src)]>
182 multiclass StoreDForms
184 def v16i8: StoreDFormVec<v16i8>;
185 def v8i16: StoreDFormVec<v8i16>;
186 def v4i32: StoreDFormVec<v4i32>;
187 def v2i64: StoreDFormVec<v2i64>;
188 def v4f32: StoreDFormVec<v4f32>;
189 def v2f64: StoreDFormVec<v2f64>;
191 def v2i32: StoreDFormVec<v2i32>;
193 def r128: StoreDForm<GPRC>;
194 def r64: StoreDForm<R64C>;
195 def r32: StoreDForm<R32C>;
196 def f32: StoreDForm<R32FP>;
197 def f64: StoreDForm<R64FP>;
198 def r16: StoreDForm<R16C>;
199 def r8: StoreDForm<R8C>;
202 class StoreAFormVec<ValueType vectype>
203 : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src),
206 [(store (vectype VECREG:$rT), aform_addr:$src)]>;
208 class StoreAForm<RegisterClass rclass>
209 : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src),
212 [(store rclass:$rT, aform_addr:$src)]>;
214 multiclass StoreAForms
216 def v16i8: StoreAFormVec<v16i8>;
217 def v8i16: StoreAFormVec<v8i16>;
218 def v4i32: StoreAFormVec<v4i32>;
219 def v2i64: StoreAFormVec<v2i64>;
220 def v4f32: StoreAFormVec<v4f32>;
221 def v2f64: StoreAFormVec<v2f64>;
223 def v2i32: StoreAFormVec<v2i32>;
225 def r128: StoreAForm<GPRC>;
226 def r64: StoreAForm<R64C>;
227 def r32: StoreAForm<R32C>;
228 def f32: StoreAForm<R32FP>;
229 def f64: StoreAForm<R64FP>;
230 def r16: StoreAForm<R16C>;
231 def r8: StoreAForm<R8C>;
234 class StoreXFormVec<ValueType vectype>
235 : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src),
238 [(store (vectype VECREG:$rT), xform_addr:$src)]>
241 class StoreXForm<RegisterClass rclass>
242 : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src),
245 [(store rclass:$rT, xform_addr:$src)]>
248 multiclass StoreXForms
250 def v16i8: StoreXFormVec<v16i8>;
251 def v8i16: StoreXFormVec<v8i16>;
252 def v4i32: StoreXFormVec<v4i32>;
253 def v2i64: StoreXFormVec<v2i64>;
254 def v4f32: StoreXFormVec<v4f32>;
255 def v2f64: StoreXFormVec<v2f64>;
257 def v2i32: StoreXFormVec<v2i32>;
259 def r128: StoreXForm<GPRC>;
260 def r64: StoreXForm<R64C>;
261 def r32: StoreXForm<R32C>;
262 def f32: StoreXForm<R32FP>;
263 def f64: StoreXForm<R64FP>;
264 def r16: StoreXForm<R16C>;
265 def r8: StoreXForm<R8C>;
268 defm STQD : StoreDForms;
269 defm STQA : StoreAForms;
270 defm STQX : StoreXForms;
272 /* Store quadword, PC relative: Not much use at this point in time. Might
273 be useful for relocatable code.
274 def STQR : RI16Form<0b111000100, (outs), (ins VECREG:$rT, s16imm:$disp),
275 "stqr\t$rT, $disp", LoadStore,
276 [(store VECREG:$rT, iaddr:$disp)]>;
279 //===----------------------------------------------------------------------===//
280 // Generate Controls for Insertion:
281 //===----------------------------------------------------------------------===//
283 def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
284 "cbd\t$rT, $src", ShuffleOp,
285 [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
287 def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src),
288 "cbx\t$rT, $src", ShuffleOp,
289 [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
291 def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
292 "chd\t$rT, $src", ShuffleOp,
293 [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
295 def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src),
296 "chx\t$rT, $src", ShuffleOp,
297 [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
299 def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
300 "cwd\t$rT, $src", ShuffleOp,
301 [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
303 def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
304 "cwx\t$rT, $src", ShuffleOp,
305 [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
307 def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
308 "cwd\t$rT, $src", ShuffleOp,
309 [(set (v4f32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
311 def CWXf32: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
312 "cwx\t$rT, $src", ShuffleOp,
313 [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
315 def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
316 "cdd\t$rT, $src", ShuffleOp,
317 [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
319 def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
320 "cdx\t$rT, $src", ShuffleOp,
321 [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
323 def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
324 "cdd\t$rT, $src", ShuffleOp,
325 [(set (v2f64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
327 def CDXf64: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
328 "cdx\t$rT, $src", ShuffleOp,
329 [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
331 //===----------------------------------------------------------------------===//
332 // Constant formation:
333 //===----------------------------------------------------------------------===//
336 RI16Form<0b110000010, (outs VECREG:$rT), (ins s16imm:$val),
337 "ilh\t$rT, $val", ImmLoad,
338 [(set (v8i16 VECREG:$rT), (v8i16 v8i16SExt16Imm:$val))]>;
341 RI16Form<0b110000010, (outs R16C:$rT), (ins s16imm:$val),
342 "ilh\t$rT, $val", ImmLoad,
343 [(set R16C:$rT, immSExt16:$val)]>;
345 // Cell SPU doesn't have a native 8-bit immediate load, but ILH works ("with
346 // the right constant")
348 RI16Form<0b110000010, (outs R8C:$rT), (ins s16imm_i8:$val),
349 "ilh\t$rT, $val", ImmLoad,
350 [(set R8C:$rT, immSExt8:$val)]>;
352 // IL does sign extension!
354 class ILInst<dag OOL, dag IOL, list<dag> pattern>:
355 RI16Form<0b100000010, OOL, IOL, "il\t$rT, $val",
358 class ILVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
359 ILInst<(outs VECREG:$rT), (ins immtype:$val),
360 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
362 class ILRegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
363 ILInst<(outs rclass:$rT), (ins immtype:$val),
364 [(set rclass:$rT, xform:$val)]>;
366 multiclass ImmediateLoad
368 def v2i64: ILVecInst<v2i64, s16imm_i64, v2i64SExt16Imm>;
369 def v4i32: ILVecInst<v4i32, s16imm_i32, v4i32SExt16Imm>;
371 // TODO: Need v2f64, v4f32
373 def r64: ILRegInst<R64C, s16imm_i64, immSExt16>;
374 def r32: ILRegInst<R32C, s16imm_i32, immSExt16>;
375 def f32: ILRegInst<R32FP, s16imm_f32, fpimmSExt16>;
376 def f64: ILRegInst<R64FP, s16imm_f64, fpimmSExt16>;
379 defm IL : ImmediateLoad;
381 class ILHUInst<dag OOL, dag IOL, list<dag> pattern>:
382 RI16Form<0b010000010, OOL, IOL, "ilhu\t$rT, $val",
385 class ILHUVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
386 ILHUInst<(outs VECREG:$rT), (ins immtype:$val),
387 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
389 class ILHURegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
390 ILHUInst<(outs rclass:$rT), (ins immtype:$val),
391 [(set rclass:$rT, xform:$val)]>;
393 multiclass ImmLoadHalfwordUpper
395 def v2i64: ILHUVecInst<v2i64, u16imm_i64, immILHUvec_i64>;
396 def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>;
398 def r64: ILHURegInst<R64C, u16imm_i64, hi16>;
399 def r32: ILHURegInst<R32C, u16imm_i32, hi16>;
401 // Loads the high portion of an address
402 def hi: ILHURegInst<R32C, symbolHi, hi16>;
404 // Used in custom lowering constant SFP loads:
405 def f32: ILHURegInst<R32FP, f16imm, hi16_f32>;
408 defm ILHU : ImmLoadHalfwordUpper;
410 // Immediate load address (can also be used to load 18-bit unsigned constants,
411 // see the zext 16->32 pattern)
413 class ILAInst<dag OOL, dag IOL, list<dag> pattern>:
414 RI18Form<0b1000010, OOL, IOL, "ila\t$rT, $val",
417 class ILAVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
418 ILAInst<(outs VECREG:$rT), (ins immtype:$val),
419 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
421 class ILARegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
422 ILAInst<(outs rclass:$rT), (ins immtype:$val),
423 [(set rclass:$rT, xform:$val)]>;
425 multiclass ImmLoadAddress
427 def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>;
428 def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>;
430 def r64: ILARegInst<R64C, u18imm_i64, imm18>;
431 def r32: ILARegInst<R32C, u18imm, imm18>;
432 def f32: ILARegInst<R32FP, f18imm, fpimm18>;
433 def f64: ILARegInst<R64FP, f18imm_f64, fpimm18>;
435 def hi: ILARegInst<R32C, symbolHi, imm18>;
436 def lo: ILARegInst<R32C, symbolLo, imm18>;
438 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
442 defm ILA : ImmLoadAddress;
444 // Immediate OR, Halfword Lower: The "other" part of loading large constants
445 // into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...>
446 // Note that these are really two operand instructions, but they're encoded
447 // as three operands with the first two arguments tied-to each other.
449 class IOHLInst<dag OOL, dag IOL, list<dag> pattern>:
450 RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val",
452 RegConstraint<"$rS = $rT">,
455 class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>:
456 IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val),
459 class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>:
460 IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val),
463 multiclass ImmOrHalfwordLower
465 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
466 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
468 def r32: IOHLRegInst<R32C, i32imm>;
469 def f32: IOHLRegInst<R32FP, f32imm>;
471 def lo: IOHLRegInst<R32C, symbolLo>;
474 defm IOHL: ImmOrHalfwordLower;
476 // Form select mask for bytes using immediate, used in conjunction with the
479 class FSMBIVec<ValueType vectype>:
480 RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val),
483 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
485 multiclass FormSelectMaskBytesImm
487 def v16i8: FSMBIVec<v16i8>;
488 def v8i16: FSMBIVec<v8i16>;
489 def v4i32: FSMBIVec<v4i32>;
490 def v2i64: FSMBIVec<v2i64>;
493 defm FSMBI : FormSelectMaskBytesImm;
495 // fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits
496 class FSMBInst<dag OOL, dag IOL, list<dag> pattern>:
497 RRForm_1<0b01101101100, OOL, IOL, "fsmb\t$rT, $rA", SelectOp,
500 class FSMBRegInst<RegisterClass rclass, ValueType vectype>:
501 FSMBInst<(outs VECREG:$rT), (ins rclass:$rA),
502 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
504 class FSMBVecInst<ValueType vectype>:
505 FSMBInst<(outs VECREG:$rT), (ins VECREG:$rA),
506 [(set (vectype VECREG:$rT),
507 (SPUselmask (vectype VECREG:$rA)))]>;
509 multiclass FormSelectMaskBits {
510 def v16i8_r16: FSMBRegInst<R16C, v16i8>;
511 def v16i8: FSMBVecInst<v16i8>;
514 defm FSMB: FormSelectMaskBits;
516 // fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is
517 // only 8-bits wide (even though it's input as 16-bits here)
519 class FSMHInst<dag OOL, dag IOL, list<dag> pattern>:
520 RRForm_1<0b10101101100, OOL, IOL, "fsmh\t$rT, $rA", SelectOp,
523 class FSMHRegInst<RegisterClass rclass, ValueType vectype>:
524 FSMHInst<(outs VECREG:$rT), (ins rclass:$rA),
525 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
527 class FSMHVecInst<ValueType vectype>:
528 FSMHInst<(outs VECREG:$rT), (ins VECREG:$rA),
529 [(set (vectype VECREG:$rT),
530 (SPUselmask (vectype VECREG:$rA)))]>;
532 multiclass FormSelectMaskHalfword {
533 def v8i16_r16: FSMHRegInst<R16C, v8i16>;
534 def v8i16: FSMHVecInst<v8i16>;
537 defm FSMH: FormSelectMaskHalfword;
539 // fsm: Form select mask for words. Like the other fsm* instructions,
540 // only the lower 4 bits of $rA are significant.
542 class FSMInst<dag OOL, dag IOL, list<dag> pattern>:
543 RRForm_1<0b00101101100, OOL, IOL, "fsm\t$rT, $rA", SelectOp,
546 class FSMRegInst<ValueType vectype, RegisterClass rclass>:
547 FSMInst<(outs VECREG:$rT), (ins rclass:$rA),
548 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
550 class FSMVecInst<ValueType vectype>:
551 FSMInst<(outs VECREG:$rT), (ins VECREG:$rA),
552 [(set (vectype VECREG:$rT), (SPUselmask (vectype VECREG:$rA)))]>;
554 multiclass FormSelectMaskWord {
555 def v4i32: FSMVecInst<v4i32>;
557 def r32 : FSMRegInst<v4i32, R32C>;
558 def r16 : FSMRegInst<v4i32, R16C>;
561 defm FSM : FormSelectMaskWord;
563 // Special case when used for i64 math operations
564 multiclass FormSelectMaskWord64 {
565 def r32 : FSMRegInst<v2i64, R32C>;
566 def r16 : FSMRegInst<v2i64, R16C>;
569 defm FSM64 : FormSelectMaskWord64;
571 //===----------------------------------------------------------------------===//
572 // Integer and Logical Operations:
573 //===----------------------------------------------------------------------===//
576 RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
577 "ah\t$rT, $rA, $rB", IntegerOp,
578 [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>;
580 def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)),
581 (AHv8i16 VECREG:$rA, VECREG:$rB)>;
584 RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
585 "ah\t$rT, $rA, $rB", IntegerOp,
586 [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>;
589 RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
590 "ahi\t$rT, $rA, $val", IntegerOp,
591 [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA),
592 v8i16SExt10Imm:$val))]>;
595 RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
596 "ahi\t$rT, $rA, $val", IntegerOp,
597 [(set R16C:$rT, (add R16C:$rA, i16ImmSExt10:$val))]>;
599 // v4i32, i32 add instruction:
601 class AInst<dag OOL, dag IOL, list<dag> pattern>:
602 RRForm<0b00000011000, OOL, IOL,
603 "a\t$rT, $rA, $rB", IntegerOp,
606 class AVecInst<ValueType vectype>:
607 AInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
608 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA),
609 (vectype VECREG:$rB)))]>;
611 class ARegInst<RegisterClass rclass>:
612 AInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
613 [(set rclass:$rT, (add rclass:$rA, rclass:$rB))]>;
615 multiclass AddInstruction {
616 def v4i32: AVecInst<v4i32>;
617 def v16i8: AVecInst<v16i8>;
619 def r32: ARegInst<R32C>;
622 defm A : AddInstruction;
624 class AIInst<dag OOL, dag IOL, list<dag> pattern>:
625 RI10Form<0b00111000, OOL, IOL,
626 "ai\t$rT, $rA, $val", IntegerOp,
629 class AIVecInst<ValueType vectype, PatLeaf immpred>:
630 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
631 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA), immpred:$val))]>;
633 class AIFPVecInst<ValueType vectype, PatLeaf immpred>:
634 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
637 class AIRegInst<RegisterClass rclass, PatLeaf immpred>:
638 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
639 [(set rclass:$rT, (add rclass:$rA, immpred:$val))]>;
641 // This is used to add epsilons to floating point numbers in the f32 fdiv code:
642 class AIFPInst<RegisterClass rclass, PatLeaf immpred>:
643 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
646 multiclass AddImmediate {
647 def v4i32: AIVecInst<v4i32, v4i32SExt10Imm>;
649 def r32: AIRegInst<R32C, i32ImmSExt10>;
651 def v4f32: AIFPVecInst<v4f32, v4i32SExt10Imm>;
652 def f32: AIFPInst<R32FP, i32ImmSExt10>;
655 defm AI : AddImmediate;
658 RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
659 "sfh\t$rT, $rA, $rB", IntegerOp,
660 [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA),
661 (v8i16 VECREG:$rB)))]>;
664 RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
665 "sfh\t$rT, $rA, $rB", IntegerOp,
666 [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>;
669 RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
670 "sfhi\t$rT, $rA, $val", IntegerOp,
671 [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val,
672 (v8i16 VECREG:$rA)))]>;
674 def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
675 "sfhi\t$rT, $rA, $val", IntegerOp,
676 [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>;
678 def SFvec : RRForm<0b00000010000, (outs VECREG:$rT),
679 (ins VECREG:$rA, VECREG:$rB),
680 "sf\t$rT, $rA, $rB", IntegerOp,
681 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
683 def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
684 "sf\t$rT, $rA, $rB", IntegerOp,
685 [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>;
688 RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
689 "sfi\t$rT, $rA, $val", IntegerOp,
690 [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val,
691 (v4i32 VECREG:$rA)))]>;
693 def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT),
694 (ins R32C:$rA, s10imm_i32:$val),
695 "sfi\t$rT, $rA, $val", IntegerOp,
696 [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>;
698 // ADDX: only available in vector form, doesn't match a pattern.
699 class ADDXInst<dag OOL, dag IOL, list<dag> pattern>:
700 RRForm<0b00000010110, OOL, IOL,
701 "addx\t$rT, $rA, $rB",
704 class ADDXVecInst<ValueType vectype>:
705 ADDXInst<(outs VECREG:$rT),
706 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
708 RegConstraint<"$rCarry = $rT">,
711 class ADDXRegInst<RegisterClass rclass>:
712 ADDXInst<(outs rclass:$rT),
713 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
715 RegConstraint<"$rCarry = $rT">,
718 multiclass AddExtended {
719 def v2i64 : ADDXVecInst<v2i64>;
720 def v4i32 : ADDXVecInst<v4i32>;
721 def r64 : ADDXRegInst<R64C>;
722 def r32 : ADDXRegInst<R32C>;
725 defm ADDX : AddExtended;
727 // CG: Generate carry for add
728 class CGInst<dag OOL, dag IOL, list<dag> pattern>:
729 RRForm<0b01000011000, OOL, IOL,
733 class CGVecInst<ValueType vectype>:
734 CGInst<(outs VECREG:$rT),
735 (ins VECREG:$rA, VECREG:$rB),
738 class CGRegInst<RegisterClass rclass>:
739 CGInst<(outs rclass:$rT),
740 (ins rclass:$rA, rclass:$rB),
743 multiclass CarryGenerate {
744 def v2i64 : CGVecInst<v2i64>;
745 def v4i32 : CGVecInst<v4i32>;
746 def r64 : CGRegInst<R64C>;
747 def r32 : CGRegInst<R32C>;
750 defm CG : CarryGenerate;
752 // SFX: Subract from, extended. This is used in conjunction with BG to subtract
753 // with carry (borrow, in this case)
754 class SFXInst<dag OOL, dag IOL, list<dag> pattern>:
755 RRForm<0b10000010110, OOL, IOL,
756 "sfx\t$rT, $rA, $rB",
759 class SFXVecInst<ValueType vectype>:
760 SFXInst<(outs VECREG:$rT),
761 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
763 RegConstraint<"$rCarry = $rT">,
766 class SFXRegInst<RegisterClass rclass>:
767 SFXInst<(outs rclass:$rT),
768 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
770 RegConstraint<"$rCarry = $rT">,
773 multiclass SubtractExtended {
774 def v2i64 : SFXVecInst<v2i64>;
775 def v4i32 : SFXVecInst<v4i32>;
776 def r64 : SFXRegInst<R64C>;
777 def r32 : SFXRegInst<R32C>;
780 defm SFX : SubtractExtended;
782 // BG: only available in vector form, doesn't match a pattern.
783 class BGInst<dag OOL, dag IOL, list<dag> pattern>:
784 RRForm<0b01000010000, OOL, IOL,
788 class BGVecInst<ValueType vectype>:
789 BGInst<(outs VECREG:$rT),
790 (ins VECREG:$rA, VECREG:$rB),
793 class BGRegInst<RegisterClass rclass>:
794 BGInst<(outs rclass:$rT),
795 (ins rclass:$rA, rclass:$rB),
798 multiclass BorrowGenerate {
799 def v4i32 : BGVecInst<v4i32>;
800 def v2i64 : BGVecInst<v2i64>;
801 def r64 : BGRegInst<R64C>;
802 def r32 : BGRegInst<R32C>;
805 defm BG : BorrowGenerate;
807 // BGX: Borrow generate, extended.
809 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
811 "bgx\t$rT, $rA, $rB", IntegerOp,
813 RegConstraint<"$rCarry = $rT">,
816 // Halfword multiply variants:
817 // N.B: These can be used to build up larger quantities (16x16 -> 32)
820 RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
821 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
825 RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
826 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
827 [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>;
829 // Unsigned 16-bit multiply:
831 class MPYUInst<dag OOL, dag IOL, list<dag> pattern>:
832 RRForm<0b00110011110, OOL, IOL,
833 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
837 MPYUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
841 MPYUInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
842 [(set R32C:$rT, (mul (zext R16C:$rA), (zext R16C:$rB)))]>;
845 MPYUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
848 // mpyi: multiply 16 x s10imm -> 32 result.
850 class MPYIInst<dag OOL, dag IOL, list<dag> pattern>:
851 RI10Form<0b00101110, OOL, IOL,
852 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
856 MPYIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
857 [(set (v8i16 VECREG:$rT),
858 (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
861 MPYIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
862 [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>;
864 // mpyui: same issues as other multiplies, plus, this doesn't match a
865 // pattern... but may be used during target DAG selection or lowering
867 class MPYUIInst<dag OOL, dag IOL, list<dag> pattern>:
868 RI10Form<0b10101110, OOL, IOL,
869 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
873 MPYUIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
877 MPYUIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
880 // mpya: 16 x 16 + 16 -> 32 bit result
881 class MPYAInst<dag OOL, dag IOL, list<dag> pattern>:
882 RRRForm<0b0011, OOL, IOL,
883 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
887 MPYAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
888 [(set (v4i32 VECREG:$rT),
889 (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA),
890 (v8i16 VECREG:$rB)))),
891 (v4i32 VECREG:$rC)))]>;
894 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
895 [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
899 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
900 [(set R32C:$rT, (add (mul (sext R16C:$rA), (sext R16C:$rB)),
903 def MPYAr32_sextinreg:
904 MPYAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC),
905 [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16),
906 (sext_inreg R32C:$rB, i16)),
909 // mpyh: multiply high, used to synthesize 32-bit multiplies
910 class MPYHInst<dag OOL, dag IOL, list<dag> pattern>:
911 RRForm<0b10100011110, OOL, IOL,
912 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
916 MPYHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
920 MPYHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
923 // mpys: multiply high and shift right (returns the top half of
924 // a 16-bit multiply, sign extended to 32 bits.)
926 class MPYSInst<dag OOL, dag IOL>:
927 RRForm<0b11100011110, OOL, IOL,
928 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
932 MPYSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
935 MPYSInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB)>;
937 // mpyhh: multiply high-high (returns the 32-bit result from multiplying
938 // the top 16 bits of the $rA, $rB)
940 class MPYHHInst<dag OOL, dag IOL>:
941 RRForm<0b01100011110, OOL, IOL,
942 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
946 MPYHHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
949 MPYHHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
951 // mpyhha: Multiply high-high, add to $rT:
953 class MPYHHAInst<dag OOL, dag IOL>:
954 RRForm<0b01100010110, OOL, IOL,
955 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
959 MPYHHAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
962 MPYHHAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
964 // mpyhhu: Multiply high-high, unsigned, e.g.:
966 // +-------+-------+ +-------+-------+ +---------+
967 // | a0 . a1 | x | b0 . b1 | = | a0 x b0 |
968 // +-------+-------+ +-------+-------+ +---------+
970 // where a0, b0 are the upper 16 bits of the 32-bit word
972 class MPYHHUInst<dag OOL, dag IOL>:
973 RRForm<0b01110011110, OOL, IOL,
974 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
978 MPYHHUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
981 MPYHHUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
983 // mpyhhau: Multiply high-high, unsigned
985 class MPYHHAUInst<dag OOL, dag IOL>:
986 RRForm<0b01110010110, OOL, IOL,
987 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
991 MPYHHAUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
994 MPYHHAUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
996 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
997 // clz: Count leading zeroes
998 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
999 class CLZInst<dag OOL, dag IOL, list<dag> pattern>:
1000 RRForm_1<0b10100101010, OOL, IOL, "clz\t$rT, $rA",
1001 IntegerOp, pattern>;
1003 class CLZRegInst<RegisterClass rclass>:
1004 CLZInst<(outs rclass:$rT), (ins rclass:$rA),
1005 [(set rclass:$rT, (ctlz rclass:$rA))]>;
1007 class CLZVecInst<ValueType vectype>:
1008 CLZInst<(outs VECREG:$rT), (ins VECREG:$rA),
1009 [(set (vectype VECREG:$rT), (ctlz (vectype VECREG:$rA)))]>;
1011 multiclass CountLeadingZeroes {
1012 def v4i32 : CLZVecInst<v4i32>;
1013 def r32 : CLZRegInst<R32C>;
1016 defm CLZ : CountLeadingZeroes;
1018 // cntb: Count ones in bytes (aka "population count")
1020 // NOTE: This instruction is really a vector instruction, but the custom
1021 // lowering code uses it in unorthodox ways to support CTPOP for other
1025 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1026 "cntb\t$rT, $rA", IntegerOp,
1027 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
1030 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1031 "cntb\t$rT, $rA", IntegerOp,
1032 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
1035 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1036 "cntb\t$rT, $rA", IntegerOp,
1037 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
1039 // gbb: Gather the low order bits from each byte in $rA into a single 16-bit
1040 // quantity stored into $rT's slot 0, upper 16 bits are zeroed, as are
1043 // Note: This instruction "pairs" with the fsmb instruction for all of the
1044 // various types defined here.
1046 // Note 2: The "VecInst" and "RegInst" forms refer to the result being either
1047 // a vector or register.
1049 class GBBInst<dag OOL, dag IOL, list<dag> pattern>:
1050 RRForm_1<0b01001101100, OOL, IOL, "gbb\t$rT, $rA", GatherOp, pattern>;
1052 class GBBRegInst<RegisterClass rclass, ValueType vectype>:
1053 GBBInst<(outs rclass:$rT), (ins VECREG:$rA),
1054 [/* no pattern */]>;
1056 class GBBVecInst<ValueType vectype>:
1057 GBBInst<(outs VECREG:$rT), (ins VECREG:$rA),
1058 [/* no pattern */]>;
1060 multiclass GatherBitsFromBytes {
1061 def v16i8_r32: GBBRegInst<R32C, v16i8>;
1062 def v16i8_r16: GBBRegInst<R16C, v16i8>;
1063 def v16i8: GBBVecInst<v16i8>;
1066 defm GBB: GatherBitsFromBytes;
1068 // gbh: Gather all low order bits from each halfword in $rA into a single
1069 // 8-bit quantity stored in $rT's slot 0, with the upper bits of $rT set to 0
1070 // and slots 1-3 also set to 0.
1072 // See notes for GBBInst, above.
1074 class GBHInst<dag OOL, dag IOL, list<dag> pattern>:
1075 RRForm_1<0b10001101100, OOL, IOL, "gbh\t$rT, $rA", GatherOp,
1078 class GBHRegInst<RegisterClass rclass, ValueType vectype>:
1079 GBHInst<(outs rclass:$rT), (ins VECREG:$rA),
1080 [/* no pattern */]>;
1082 class GBHVecInst<ValueType vectype>:
1083 GBHInst<(outs VECREG:$rT), (ins VECREG:$rA),
1084 [/* no pattern */]>;
1086 multiclass GatherBitsHalfword {
1087 def v8i16_r32: GBHRegInst<R32C, v8i16>;
1088 def v8i16_r16: GBHRegInst<R16C, v8i16>;
1089 def v8i16: GBHVecInst<v8i16>;
1092 defm GBH: GatherBitsHalfword;
1094 // gb: Gather all low order bits from each word in $rA into a single
1095 // 4-bit quantity stored in $rT's slot 0, upper bits in $rT set to 0,
1096 // as well as slots 1-3.
1098 // See notes for gbb, above.
1100 class GBInst<dag OOL, dag IOL, list<dag> pattern>:
1101 RRForm_1<0b00001101100, OOL, IOL, "gb\t$rT, $rA", GatherOp,
1104 class GBRegInst<RegisterClass rclass, ValueType vectype>:
1105 GBInst<(outs rclass:$rT), (ins VECREG:$rA),
1106 [/* no pattern */]>;
1108 class GBVecInst<ValueType vectype>:
1109 GBInst<(outs VECREG:$rT), (ins VECREG:$rA),
1110 [/* no pattern */]>;
1112 multiclass GatherBitsWord {
1113 def v4i32_r32: GBRegInst<R32C, v4i32>;
1114 def v4i32_r16: GBRegInst<R16C, v4i32>;
1115 def v4i32: GBVecInst<v4i32>;
1118 defm GB: GatherBitsWord;
1120 // avgb: average bytes
1122 RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1123 "avgb\t$rT, $rA, $rB", ByteOp,
1126 // absdb: absolute difference of bytes
1128 RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1129 "absdb\t$rT, $rA, $rB", ByteOp,
1132 // sumb: sum bytes into halfwords
1134 RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1135 "sumb\t$rT, $rA, $rB", ByteOp,
1138 // Sign extension operations:
1139 class XSBHInst<dag OOL, dag IOL, list<dag> pattern>:
1140 RRForm_1<0b01101101010, OOL, IOL,
1141 "xsbh\t$rDst, $rSrc",
1142 IntegerOp, pattern>;
1144 class XSBHVecInst<ValueType vectype>:
1145 XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1146 [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>;
1148 class XSBHInRegInst<RegisterClass rclass, list<dag> pattern>:
1149 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
1152 multiclass ExtendByteHalfword {
1153 def v16i8: XSBHVecInst<v8i16>;
1154 def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1155 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1156 def r16: XSBHInRegInst<R16C,
1157 [(set R16C:$rDst, (sext_inreg R16C:$rSrc, i8))]>;
1159 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
1160 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
1161 // pattern below). Intentionally doesn't match a pattern because we want the
1162 // sext 8->32 pattern to do the work for us, namely because we need the extra
1164 def r32: XSBHInRegInst<R32C, [/* no pattern */]>;
1166 // Same as the 32-bit version, but for i64
1167 def r64: XSBHInRegInst<R64C, [/* no pattern */]>;
1170 defm XSBH : ExtendByteHalfword;
1172 // Sign extend halfwords to words:
1174 class XSHWInst<dag OOL, dag IOL, list<dag> pattern>:
1175 RRForm_1<0b01101101010, OOL, IOL, "xshw\t$rDest, $rSrc",
1176 IntegerOp, pattern>;
1178 class XSHWVecInst<ValueType in_vectype, ValueType out_vectype>:
1179 XSHWInst<(outs VECREG:$rDest), (ins VECREG:$rSrc),
1180 [(set (out_vectype VECREG:$rDest),
1181 (sext (in_vectype VECREG:$rSrc)))]>;
1183 class XSHWInRegInst<RegisterClass rclass, list<dag> pattern>:
1184 XSHWInst<(outs rclass:$rDest), (ins rclass:$rSrc),
1187 class XSHWRegInst<RegisterClass rclass>:
1188 XSHWInst<(outs rclass:$rDest), (ins R16C:$rSrc),
1189 [(set rclass:$rDest, (sext R16C:$rSrc))]>;
1191 multiclass ExtendHalfwordWord {
1192 def v4i32: XSHWVecInst<v4i32, v8i16>;
1194 def r16: XSHWRegInst<R32C>;
1196 def r32: XSHWInRegInst<R32C,
1197 [(set R32C:$rDest, (sext_inreg R32C:$rSrc, i16))]>;
1198 def r64: XSHWInRegInst<R64C, [/* no pattern */]>;
1201 defm XSHW : ExtendHalfwordWord;
1203 // Sign-extend words to doublewords (32->64 bits)
1205 class XSWDInst<dag OOL, dag IOL, list<dag> pattern>:
1206 RRForm_1<0b01100101010, OOL, IOL, "xswd\t$rDst, $rSrc",
1207 IntegerOp, pattern>;
1209 class XSWDVecInst<ValueType in_vectype, ValueType out_vectype>:
1210 XSWDInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1211 [(set (out_vectype VECREG:$rDst),
1212 (sext (out_vectype VECREG:$rSrc)))]>;
1214 class XSWDRegInst<RegisterClass in_rclass, RegisterClass out_rclass>:
1215 XSWDInst<(outs out_rclass:$rDst), (ins in_rclass:$rSrc),
1216 [(set out_rclass:$rDst, (sext in_rclass:$rSrc))]>;
1218 multiclass ExtendWordToDoubleWord {
1219 def v2i64: XSWDVecInst<v4i32, v2i64>;
1220 def r64: XSWDRegInst<R32C, R64C>;
1222 def r64_inreg: XSWDInst<(outs R64C:$rDst), (ins R64C:$rSrc),
1223 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1226 defm XSWD : ExtendWordToDoubleWord;
1230 class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1231 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1232 IntegerOp, pattern>;
1234 class ANDVecInst<ValueType vectype>:
1235 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1236 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1237 (vectype VECREG:$rB)))]>;
1239 class ANDRegInst<RegisterClass rclass>:
1240 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1241 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1243 multiclass BitwiseAnd
1245 def v16i8: ANDVecInst<v16i8>;
1246 def v8i16: ANDVecInst<v8i16>;
1247 def v4i32: ANDVecInst<v4i32>;
1248 def v2i64: ANDVecInst<v2i64>;
1250 def r128: ANDRegInst<GPRC>;
1251 def r64: ANDRegInst<R64C>;
1252 def r32: ANDRegInst<R32C>;
1253 def r16: ANDRegInst<R16C>;
1254 def r8: ANDRegInst<R8C>;
1256 //===---------------------------------------------
1257 // Special instructions to perform the fabs instruction
1258 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1259 [/* Intentionally does not match a pattern */]>;
1261 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
1262 [/* Intentionally does not match a pattern */]>;
1264 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1265 [/* Intentionally does not match a pattern */]>;
1267 //===---------------------------------------------
1269 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1270 // quantities -- see 16->32 zext pattern.
1272 // This pattern is somewhat artificial, since it might match some
1273 // compiler generated pattern but it is unlikely to do so.
1275 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1276 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1279 defm AND : BitwiseAnd;
1281 // N.B.: vnot_conv is one of those special target selection pattern fragments,
1282 // in which we expect there to be a bit_convert on the constant. Bear in mind
1283 // that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1284 // constant -1 vector.)
1286 class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1287 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1288 IntegerOp, pattern>;
1290 class ANDCVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
1291 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1292 [(set (vectype VECREG:$rT),
1293 (and (vectype VECREG:$rA),
1294 (vnot_frag (vectype VECREG:$rB))))]>;
1296 class ANDCRegInst<RegisterClass rclass>:
1297 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1298 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
1300 multiclass AndComplement
1302 def v16i8: ANDCVecInst<v16i8>;
1303 def v8i16: ANDCVecInst<v8i16>;
1304 def v4i32: ANDCVecInst<v4i32>;
1305 def v2i64: ANDCVecInst<v2i64>;
1307 def r128: ANDCRegInst<GPRC>;
1308 def r64: ANDCRegInst<R64C>;
1309 def r32: ANDCRegInst<R32C>;
1310 def r16: ANDCRegInst<R16C>;
1311 def r8: ANDCRegInst<R8C>;
1313 // Sometimes, the xor pattern has a bitcast constant:
1314 def v16i8_conv: ANDCVecInst<v16i8, vnot_conv>;
1317 defm ANDC : AndComplement;
1319 class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1320 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
1323 multiclass AndByteImm
1325 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1326 [(set (v16i8 VECREG:$rT),
1327 (and (v16i8 VECREG:$rA),
1328 (v16i8 v16i8U8Imm:$val)))]>;
1330 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1331 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1334 defm ANDBI : AndByteImm;
1336 class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1337 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
1340 multiclass AndHalfwordImm
1342 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1343 [(set (v8i16 VECREG:$rT),
1344 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
1346 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1347 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
1349 // Zero-extend i8 to i16:
1350 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1351 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1354 defm ANDHI : AndHalfwordImm;
1356 class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1357 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1358 IntegerOp, pattern>;
1360 multiclass AndWordImm
1362 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1363 [(set (v4i32 VECREG:$rT),
1364 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1366 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1367 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1369 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1371 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1373 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1375 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1376 // zext 16->32 pattern below.
1378 // Note that this pattern is somewhat artificial, since it might match
1379 // something the compiler generates but is unlikely to occur in practice.
1380 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1382 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1385 defm ANDI : AndWordImm;
1387 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1388 // Bitwise OR group:
1389 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1391 // Bitwise "or" (N.B.: These are also register-register copy instructions...)
1392 class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1393 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1394 IntegerOp, pattern>;
1396 class ORVecInst<ValueType vectype>:
1397 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1398 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1399 (vectype VECREG:$rB)))]>;
1401 class ORRegInst<RegisterClass rclass>:
1402 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1403 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
1405 // ORCvtForm: OR conversion form
1407 // This is used to "convert" the preferred slot to its vector equivalent, as
1408 // well as convert a vector back to its preferred slot.
1410 // These are effectively no-ops, but need to exist for proper type conversion
1411 // and type coercion.
1413 class ORCvtForm<dag OOL, dag IOL, list<dag> pattern = [/* no pattern */]>
1414 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1418 let Pattern = pattern;
1420 let Inst{0-10} = 0b10000010000;
1421 let Inst{11-17} = RA;
1422 let Inst{18-24} = RA;
1423 let Inst{25-31} = RT;
1426 class ORPromoteScalar<RegisterClass rclass>:
1427 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
1429 class ORExtractElt<RegisterClass rclass>:
1430 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1432 /* class ORCvtRegGPRC<RegisterClass rclass>:
1433 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>; */
1435 /* class ORCvtGPRCReg<RegisterClass rclass>:
1436 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>; */
1438 class ORCvtFormR32Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1439 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA), pattern>;
1441 class ORCvtFormRegR32<RegisterClass rclass, list<dag> pattern = [ ]>:
1442 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA), pattern>;
1444 class ORCvtFormR64Reg<RegisterClass rclass, list<dag> pattern = [ ]>:
1445 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA), pattern>;
1447 class ORCvtFormRegR64<RegisterClass rclass, list<dag> pattern = [ ]>:
1448 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA), pattern>;
1451 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1454 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
1456 multiclass BitwiseOr
1458 def v16i8: ORVecInst<v16i8>;
1459 def v8i16: ORVecInst<v8i16>;
1460 def v4i32: ORVecInst<v4i32>;
1461 def v2i64: ORVecInst<v2i64>;
1463 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1464 [(set (v4f32 VECREG:$rT),
1465 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1466 (v4i32 VECREG:$rB)))))]>;
1468 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1469 [(set (v2f64 VECREG:$rT),
1470 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1471 (v2i64 VECREG:$rB)))))]>;
1473 def r128: ORRegInst<GPRC>;
1474 def r64: ORRegInst<R64C>;
1475 def r32: ORRegInst<R32C>;
1476 def r16: ORRegInst<R16C>;
1477 def r8: ORRegInst<R8C>;
1479 // OR instructions used to copy f32 and f64 registers.
1480 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1481 [/* no pattern */]>;
1483 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1484 [/* no pattern */]>;
1486 // scalar->vector promotion, prefslot2vec:
1487 def v16i8_i8: ORPromoteScalar<R8C>;
1488 def v8i16_i16: ORPromoteScalar<R16C>;
1489 def v4i32_i32: ORPromoteScalar<R32C>;
1490 def v2i64_i64: ORPromoteScalar<R64C>;
1491 def v4f32_f32: ORPromoteScalar<R32FP>;
1492 def v2f64_f64: ORPromoteScalar<R64FP>;
1494 // vector->scalar demotion, vec2prefslot:
1495 def i8_v16i8: ORExtractElt<R8C>;
1496 def i16_v8i16: ORExtractElt<R16C>;
1497 def i32_v4i32: ORExtractElt<R32C>;
1498 def i64_v2i64: ORExtractElt<R64C>;
1499 def f32_v4f32: ORExtractElt<R32FP>;
1500 def f64_v2f64: ORExtractElt<R64FP>;
1502 // Conversion from vector to GPRC
1503 def i128_vec: ORCvtVecGPRC;
1505 // Conversion from GPRC to vector
1506 def vec_i128: ORCvtGPRCVec;
1509 // Conversion from register to GPRC
1510 def i128_r64: ORCvtRegGPRC<R64C>;
1511 def i128_f64: ORCvtRegGPRC<R64FP>;
1512 def i128_r32: ORCvtRegGPRC<R32C>;
1513 def i128_f32: ORCvtRegGPRC<R32FP>;
1514 def i128_r16: ORCvtRegGPRC<R16C>;
1515 def i128_r8: ORCvtRegGPRC<R8C>;
1517 // Conversion from GPRC to register
1518 def r64_i128: ORCvtGPRCReg<R64C>;
1519 def f64_i128: ORCvtGPRCReg<R64FP>;
1520 def r32_i128: ORCvtGPRCReg<R32C>;
1521 def f32_i128: ORCvtGPRCReg<R32FP>;
1522 def r16_i128: ORCvtGPRCReg<R16C>;
1523 def r8_i128: ORCvtGPRCReg<R8C>;
1526 // Conversion from register to R32C:
1527 def r32_r16: ORCvtFormRegR32<R16C>;
1528 def r32_r8: ORCvtFormRegR32<R8C>;
1530 // Conversion from R32C to register
1531 def r32_r16: ORCvtFormR32Reg<R16C>;
1532 def r32_r8: ORCvtFormR32Reg<R8C>;
1535 // Conversion from R64C to register:
1536 def r32_r64: ORCvtFormR64Reg<R32C>;
1537 // def r16_r64: ORCvtFormR64Reg<R16C>;
1538 // def r8_r64: ORCvtFormR64Reg<R8C>;
1540 // Conversion to R64C from register:
1541 def r64_r32: ORCvtFormRegR64<R32C>;
1542 // def r64_r16: ORCvtFormRegR64<R16C>;
1543 // def r64_r8: ORCvtFormRegR64<R8C>;
1545 // bitconvert patterns:
1546 def r32_f32: ORCvtFormR32Reg<R32FP,
1547 [(set R32FP:$rT, (bitconvert R32C:$rA))]>;
1548 def f32_r32: ORCvtFormRegR32<R32FP,
1549 [(set R32C:$rT, (bitconvert R32FP:$rA))]>;
1551 def r64_f64: ORCvtFormR64Reg<R64FP,
1552 [(set R64FP:$rT, (bitconvert R64C:$rA))]>;
1553 def f64_r64: ORCvtFormRegR64<R64FP,
1554 [(set R64C:$rT, (bitconvert R64FP:$rA))]>;
1557 defm OR : BitwiseOr;
1559 // scalar->vector promotion patterns (preferred slot to vector):
1560 def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1561 (ORv16i8_i8 R8C:$rA)>;
1563 def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1564 (ORv8i16_i16 R16C:$rA)>;
1566 def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1567 (ORv4i32_i32 R32C:$rA)>;
1569 def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1570 (ORv2i64_i64 R64C:$rA)>;
1572 def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1573 (ORv4f32_f32 R32FP:$rA)>;
1575 def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1576 (ORv2f64_f64 R64FP:$rA)>;
1578 // ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1579 // known as converting the vector back to its preferred slot
1581 def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
1582 (ORi8_v16i8 VECREG:$rA)>;
1584 def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
1585 (ORi16_v8i16 VECREG:$rA)>;
1587 def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
1588 (ORi32_v4i32 VECREG:$rA)>;
1590 def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
1591 (ORi64_v2i64 VECREG:$rA)>;
1593 def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
1594 (ORf32_v4f32 VECREG:$rA)>;
1596 def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
1597 (ORf64_v2f64 VECREG:$rA)>;
1599 // Load Register: This is an assembler alias for a bitwise OR of a register
1600 // against itself. It's here because it brings some clarity to assembly
1603 let hasCtrlDep = 1 in {
1604 class LRInst<dag OOL, dag IOL>
1605 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1609 let Pattern = [/*no pattern*/];
1611 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1612 let Inst{11-17} = RA;
1613 let Inst{18-24} = RA;
1614 let Inst{25-31} = RT;
1617 class LRVecInst<ValueType vectype>:
1618 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1620 class LRRegInst<RegisterClass rclass>:
1621 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1623 multiclass LoadRegister {
1624 def v2i64: LRVecInst<v2i64>;
1625 def v2f64: LRVecInst<v2f64>;
1626 def v4i32: LRVecInst<v4i32>;
1627 def v4f32: LRVecInst<v4f32>;
1628 def v8i16: LRVecInst<v8i16>;
1629 def v16i8: LRVecInst<v16i8>;
1631 def r128: LRRegInst<GPRC>;
1632 def r64: LRRegInst<R64C>;
1633 def f64: LRRegInst<R64FP>;
1634 def r32: LRRegInst<R32C>;
1635 def f32: LRRegInst<R32FP>;
1636 def r16: LRRegInst<R16C>;
1637 def r8: LRRegInst<R8C>;
1640 defm LR: LoadRegister;
1643 // ORC: Bitwise "or" with complement (c = a | ~b)
1645 class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1646 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1647 IntegerOp, pattern>;
1649 class ORCVecInst<ValueType vectype>:
1650 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1651 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1652 (vnot (vectype VECREG:$rB))))]>;
1654 class ORCRegInst<RegisterClass rclass>:
1655 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1656 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
1658 multiclass BitwiseOrComplement
1660 def v16i8: ORCVecInst<v16i8>;
1661 def v8i16: ORCVecInst<v8i16>;
1662 def v4i32: ORCVecInst<v4i32>;
1663 def v2i64: ORCVecInst<v2i64>;
1665 def r128: ORCRegInst<GPRC>;
1666 def r64: ORCRegInst<R64C>;
1667 def r32: ORCRegInst<R32C>;
1668 def r16: ORCRegInst<R16C>;
1669 def r8: ORCRegInst<R8C>;
1672 defm ORC : BitwiseOrComplement;
1674 // OR byte immediate
1675 class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1676 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1677 IntegerOp, pattern>;
1679 class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1680 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1681 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1682 (vectype immpred:$val)))]>;
1684 multiclass BitwiseOrByteImm
1686 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1688 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1689 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1692 defm ORBI : BitwiseOrByteImm;
1694 // OR halfword immediate
1695 class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1696 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1697 IntegerOp, pattern>;
1699 class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1700 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1701 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1704 multiclass BitwiseOrHalfwordImm
1706 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1708 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1709 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1711 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1712 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1713 [(set R16C:$rT, (or (anyext R8C:$rA),
1714 i16ImmSExt10:$val))]>;
1717 defm ORHI : BitwiseOrHalfwordImm;
1719 class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1720 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1721 IntegerOp, pattern>;
1723 class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1724 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1725 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1728 // Bitwise "or" with immediate
1729 multiclass BitwiseOrImm
1731 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
1733 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1734 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
1736 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1737 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1738 // infra "anyext 16->32" pattern.)
1739 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1740 [(set R32C:$rT, (or (anyext R16C:$rA),
1741 i32ImmSExt10:$val))]>;
1743 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1744 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1745 // infra "anyext 16->32" pattern.)
1746 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1747 [(set R32C:$rT, (or (anyext R8C:$rA),
1748 i32ImmSExt10:$val))]>;
1751 defm ORI : BitwiseOrImm;
1753 // ORX: "or" across the vector: or's $rA's word slots leaving the result in
1754 // $rT[0], slots 1-3 are zeroed.
1756 // FIXME: Needs to match an intrinsic pattern.
1758 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1759 "orx\t$rT, $rA, $rB", IntegerOp,
1764 class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1765 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1766 IntegerOp, pattern>;
1768 class XORVecInst<ValueType vectype>:
1769 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1770 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1771 (vectype VECREG:$rB)))]>;
1773 class XORRegInst<RegisterClass rclass>:
1774 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1775 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1777 multiclass BitwiseExclusiveOr
1779 def v16i8: XORVecInst<v16i8>;
1780 def v8i16: XORVecInst<v8i16>;
1781 def v4i32: XORVecInst<v4i32>;
1782 def v2i64: XORVecInst<v2i64>;
1784 def r128: XORRegInst<GPRC>;
1785 def r64: XORRegInst<R64C>;
1786 def r32: XORRegInst<R32C>;
1787 def r16: XORRegInst<R16C>;
1788 def r8: XORRegInst<R8C>;
1790 // XOR instructions used to negate f32 and f64 quantities.
1792 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1793 [/* no pattern */]>;
1795 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64C:$rB),
1796 [/* no pattern */]>;
1798 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1799 [/* no pattern, see fneg{32,64} */]>;
1802 defm XOR : BitwiseExclusiveOr;
1804 //==----------------------------------------------------------
1806 class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1807 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1808 IntegerOp, pattern>;
1810 multiclass XorByteImm
1813 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1814 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1817 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1818 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1821 defm XORBI : XorByteImm;
1824 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1825 "xorhi\t$rT, $rA, $val", IntegerOp,
1826 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1827 v8i16SExt10Imm:$val))]>;
1830 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1831 "xorhi\t$rT, $rA, $val", IntegerOp,
1832 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1835 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
1836 "xori\t$rT, $rA, $val", IntegerOp,
1837 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1838 v4i32SExt10Imm:$val))]>;
1841 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1842 "xori\t$rT, $rA, $val", IntegerOp,
1843 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1847 class NANDInst<dag OOL, dag IOL, list<dag> pattern>:
1848 RRForm<0b10010011000, OOL, IOL, "nand\t$rT, $rA, $rB",
1849 IntegerOp, pattern>;
1851 class NANDVecInst<ValueType vectype>:
1852 NANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1853 [(set (vectype VECREG:$rT), (vnot (and (vectype VECREG:$rA),
1854 (vectype VECREG:$rB))))]>;
1855 class NANDRegInst<RegisterClass rclass>:
1856 NANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1857 [(set rclass:$rT, (not (and rclass:$rA, rclass:$rB)))]>;
1859 multiclass BitwiseNand
1861 def v16i8: NANDVecInst<v16i8>;
1862 def v8i16: NANDVecInst<v8i16>;
1863 def v4i32: NANDVecInst<v4i32>;
1864 def v2i64: NANDVecInst<v2i64>;
1866 def r128: NANDRegInst<GPRC>;
1867 def r64: NANDRegInst<R64C>;
1868 def r32: NANDRegInst<R32C>;
1869 def r16: NANDRegInst<R16C>;
1870 def r8: NANDRegInst<R8C>;
1873 defm NAND : BitwiseNand;
1877 class NORInst<dag OOL, dag IOL, list<dag> pattern>:
1878 RRForm<0b10010010000, OOL, IOL, "nor\t$rT, $rA, $rB",
1879 IntegerOp, pattern>;
1881 class NORVecInst<ValueType vectype>:
1882 NORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1883 [(set (vectype VECREG:$rT), (vnot (or (vectype VECREG:$rA),
1884 (vectype VECREG:$rB))))]>;
1885 class NORRegInst<RegisterClass rclass>:
1886 NORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1887 [(set rclass:$rT, (not (or rclass:$rA, rclass:$rB)))]>;
1889 multiclass BitwiseNor
1891 def v16i8: NORVecInst<v16i8>;
1892 def v8i16: NORVecInst<v8i16>;
1893 def v4i32: NORVecInst<v4i32>;
1894 def v2i64: NORVecInst<v2i64>;
1896 def r128: NORRegInst<GPRC>;
1897 def r64: NORRegInst<R64C>;
1898 def r32: NORRegInst<R32C>;
1899 def r16: NORRegInst<R16C>;
1900 def r8: NORRegInst<R8C>;
1903 defm NOR : BitwiseNor;
1906 class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1907 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1908 IntegerOp, pattern>;
1910 class SELBVecInst<ValueType vectype, PatFrag vnot_frag = vnot>:
1911 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1912 [(set (vectype VECREG:$rT),
1913 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
1914 (and (vnot_frag (vectype VECREG:$rC)),
1915 (vectype VECREG:$rA))))]>;
1917 class SELBVecVCondInst<ValueType vectype>:
1918 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1919 [(set (vectype VECREG:$rT),
1920 (select (vectype VECREG:$rC),
1921 (vectype VECREG:$rB),
1922 (vectype VECREG:$rA)))]>;
1924 class SELBVecCondInst<ValueType vectype>:
1925 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1926 [(set (vectype VECREG:$rT),
1928 (vectype VECREG:$rB),
1929 (vectype VECREG:$rA)))]>;
1931 class SELBRegInst<RegisterClass rclass>:
1932 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1934 (or (and rclass:$rB, rclass:$rC),
1935 (and rclass:$rA, (not rclass:$rC))))]>;
1937 class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1938 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1940 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1942 multiclass SelectBits
1944 def v16i8: SELBVecInst<v16i8>;
1945 def v8i16: SELBVecInst<v8i16>;
1946 def v4i32: SELBVecInst<v4i32>;
1947 def v2i64: SELBVecInst<v2i64, vnot_conv>;
1949 def r128: SELBRegInst<GPRC>;
1950 def r64: SELBRegInst<R64C>;
1951 def r32: SELBRegInst<R32C>;
1952 def r16: SELBRegInst<R16C>;
1953 def r8: SELBRegInst<R8C>;
1955 def v16i8_cond: SELBVecCondInst<v16i8>;
1956 def v8i16_cond: SELBVecCondInst<v8i16>;
1957 def v4i32_cond: SELBVecCondInst<v4i32>;
1958 def v2i64_cond: SELBVecCondInst<v2i64>;
1960 def v16i8_vcond: SELBVecCondInst<v16i8>;
1961 def v8i16_vcond: SELBVecCondInst<v8i16>;
1962 def v4i32_vcond: SELBVecCondInst<v4i32>;
1963 def v2i64_vcond: SELBVecCondInst<v2i64>;
1966 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1967 [(set (v4f32 VECREG:$rT),
1968 (select (v4i32 VECREG:$rC),
1970 (v4f32 VECREG:$rA)))]>;
1972 // SELBr64_cond is defined in SPU64InstrInfo.td
1973 def r32_cond: SELBRegCondInst<R32C, R32C>;
1974 def f32_cond: SELBRegCondInst<R32C, R32FP>;
1975 def r16_cond: SELBRegCondInst<R16C, R16C>;
1976 def r8_cond: SELBRegCondInst<R8C, R8C>;
1979 defm SELB : SelectBits;
1981 class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
1982 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1983 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
1985 def : SPUselbPatVec<v16i8, SELBv16i8>;
1986 def : SPUselbPatVec<v8i16, SELBv8i16>;
1987 def : SPUselbPatVec<v4i32, SELBv4i32>;
1988 def : SPUselbPatVec<v2i64, SELBv2i64>;
1990 class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1991 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1992 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1994 def : SPUselbPatReg<R8C, SELBr8>;
1995 def : SPUselbPatReg<R16C, SELBr16>;
1996 def : SPUselbPatReg<R32C, SELBr32>;
1997 def : SPUselbPatReg<R64C, SELBr64>;
1999 // EQV: Equivalence (1 for each same bit, otherwise 0)
2001 // Note: There are a lot of ways to match this bit operator and these patterns
2002 // attempt to be as exhaustive as possible.
2004 class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
2005 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
2006 IntegerOp, pattern>;
2008 class EQVVecInst<ValueType vectype>:
2009 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2010 [(set (vectype VECREG:$rT),
2011 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2012 (and (vnot (vectype VECREG:$rA)),
2013 (vnot (vectype VECREG:$rB)))))]>;
2015 class EQVRegInst<RegisterClass rclass>:
2016 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2017 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2018 (and (not rclass:$rA), (not rclass:$rB))))]>;
2020 class EQVVecPattern1<ValueType vectype>:
2021 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2022 [(set (vectype VECREG:$rT),
2023 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
2025 class EQVRegPattern1<RegisterClass rclass>:
2026 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2027 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
2029 class EQVVecPattern2<ValueType vectype>:
2030 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2031 [(set (vectype VECREG:$rT),
2032 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2033 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
2035 class EQVRegPattern2<RegisterClass rclass>:
2036 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2038 (or (and rclass:$rA, rclass:$rB),
2039 (not (or rclass:$rA, rclass:$rB))))]>;
2041 class EQVVecPattern3<ValueType vectype>:
2042 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2043 [(set (vectype VECREG:$rT),
2044 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
2046 class EQVRegPattern3<RegisterClass rclass>:
2047 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2048 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
2050 multiclass BitEquivalence
2052 def v16i8: EQVVecInst<v16i8>;
2053 def v8i16: EQVVecInst<v8i16>;
2054 def v4i32: EQVVecInst<v4i32>;
2055 def v2i64: EQVVecInst<v2i64>;
2057 def v16i8_1: EQVVecPattern1<v16i8>;
2058 def v8i16_1: EQVVecPattern1<v8i16>;
2059 def v4i32_1: EQVVecPattern1<v4i32>;
2060 def v2i64_1: EQVVecPattern1<v2i64>;
2062 def v16i8_2: EQVVecPattern2<v16i8>;
2063 def v8i16_2: EQVVecPattern2<v8i16>;
2064 def v4i32_2: EQVVecPattern2<v4i32>;
2065 def v2i64_2: EQVVecPattern2<v2i64>;
2067 def v16i8_3: EQVVecPattern3<v16i8>;
2068 def v8i16_3: EQVVecPattern3<v8i16>;
2069 def v4i32_3: EQVVecPattern3<v4i32>;
2070 def v2i64_3: EQVVecPattern3<v2i64>;
2072 def r128: EQVRegInst<GPRC>;
2073 def r64: EQVRegInst<R64C>;
2074 def r32: EQVRegInst<R32C>;
2075 def r16: EQVRegInst<R16C>;
2076 def r8: EQVRegInst<R8C>;
2078 def r128_1: EQVRegPattern1<GPRC>;
2079 def r64_1: EQVRegPattern1<R64C>;
2080 def r32_1: EQVRegPattern1<R32C>;
2081 def r16_1: EQVRegPattern1<R16C>;
2082 def r8_1: EQVRegPattern1<R8C>;
2084 def r128_2: EQVRegPattern2<GPRC>;
2085 def r64_2: EQVRegPattern2<R64C>;
2086 def r32_2: EQVRegPattern2<R32C>;
2087 def r16_2: EQVRegPattern2<R16C>;
2088 def r8_2: EQVRegPattern2<R8C>;
2090 def r128_3: EQVRegPattern3<GPRC>;
2091 def r64_3: EQVRegPattern3<R64C>;
2092 def r32_3: EQVRegPattern3<R32C>;
2093 def r16_3: EQVRegPattern3<R16C>;
2094 def r8_3: EQVRegPattern3<R8C>;
2097 defm EQV: BitEquivalence;
2099 //===----------------------------------------------------------------------===//
2100 // Vector shuffle...
2101 //===----------------------------------------------------------------------===//
2102 // SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2103 // See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2104 // matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2105 // the SPUISD::SHUFB opcode.
2106 //===----------------------------------------------------------------------===//
2108 class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2109 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2110 IntegerOp, pattern>;
2112 class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
2113 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
2114 [(set (resultvec VECREG:$rT),
2115 (SPUshuffle (resultvec VECREG:$rA),
2116 (resultvec VECREG:$rB),
2117 (maskvec VECREG:$rC)))]>;
2119 class SHUFBGPRCInst:
2120 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2121 [/* no pattern */]>;
2123 multiclass ShuffleBytes
2125 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2126 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2127 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2128 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2129 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2130 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2131 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2132 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
2134 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2135 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2137 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2138 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
2140 def gprc : SHUFBGPRCInst;
2143 defm SHUFB : ShuffleBytes;
2145 //===----------------------------------------------------------------------===//
2146 // Shift and rotate group:
2147 //===----------------------------------------------------------------------===//
2149 class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2150 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2151 RotateShift, pattern>;
2153 class SHLHVecInst<ValueType vectype>:
2154 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2155 [(set (vectype VECREG:$rT),
2156 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
2158 multiclass ShiftLeftHalfword
2160 def v8i16: SHLHVecInst<v8i16>;
2161 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2162 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2163 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2164 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2167 defm SHLH : ShiftLeftHalfword;
2169 //===----------------------------------------------------------------------===//
2171 class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2172 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2173 RotateShift, pattern>;
2175 class SHLHIVecInst<ValueType vectype>:
2176 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2177 [(set (vectype VECREG:$rT),
2178 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2180 multiclass ShiftLeftHalfwordImm
2182 def v8i16: SHLHIVecInst<v8i16>;
2183 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2184 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2187 defm SHLHI : ShiftLeftHalfwordImm;
2189 def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2190 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
2192 def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
2193 (SHLHIr16 R16C:$rA, uimm7:$val)>;
2195 //===----------------------------------------------------------------------===//
2197 class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2198 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2199 RotateShift, pattern>;
2201 multiclass ShiftLeftWord
2204 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2205 [(set (v4i32 VECREG:$rT),
2206 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2208 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2209 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2212 defm SHL: ShiftLeftWord;
2214 //===----------------------------------------------------------------------===//
2216 class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2217 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2218 RotateShift, pattern>;
2220 multiclass ShiftLeftWordImm
2223 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2224 [(set (v4i32 VECREG:$rT),
2225 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
2228 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2229 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2232 defm SHLI : ShiftLeftWordImm;
2234 //===----------------------------------------------------------------------===//
2235 // SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2236 // register) to the left. Vector form is here to ensure type correctness.
2238 // The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2239 // of 7 bits is actually possible.
2241 // Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2242 // to shift i64 and i128. SHLQBI is the residual left over after shifting by
2243 // bytes with SHLQBY.
2245 class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2246 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2247 RotateShift, pattern>;
2249 class SHLQBIVecInst<ValueType vectype>:
2250 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2251 [(set (vectype VECREG:$rT),
2252 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2254 class SHLQBIRegInst<RegisterClass rclass>:
2255 SHLQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2256 [/* no pattern */]>;
2258 multiclass ShiftLeftQuadByBits
2260 def v16i8: SHLQBIVecInst<v16i8>;
2261 def v8i16: SHLQBIVecInst<v8i16>;
2262 def v4i32: SHLQBIVecInst<v4i32>;
2263 def v4f32: SHLQBIVecInst<v4f32>;
2264 def v2i64: SHLQBIVecInst<v2i64>;
2265 def v2f64: SHLQBIVecInst<v2f64>;
2267 def r128: SHLQBIRegInst<GPRC>;
2270 defm SHLQBI : ShiftLeftQuadByBits;
2272 // See note above on SHLQBI. In this case, the predicate actually does then
2273 // enforcement, whereas with SHLQBI, we have to "take it on faith."
2274 class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2275 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2276 RotateShift, pattern>;
2278 class SHLQBIIVecInst<ValueType vectype>:
2279 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2280 [(set (vectype VECREG:$rT),
2281 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2283 multiclass ShiftLeftQuadByBitsImm
2285 def v16i8 : SHLQBIIVecInst<v16i8>;
2286 def v8i16 : SHLQBIIVecInst<v8i16>;
2287 def v4i32 : SHLQBIIVecInst<v4i32>;
2288 def v4f32 : SHLQBIIVecInst<v4f32>;
2289 def v2i64 : SHLQBIIVecInst<v2i64>;
2290 def v2f64 : SHLQBIIVecInst<v2f64>;
2293 defm SHLQBII : ShiftLeftQuadByBitsImm;
2295 // SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
2296 // not by bits. See notes above on SHLQBI.
2298 class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2299 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
2300 RotateShift, pattern>;
2302 class SHLQBYVecInst<ValueType vectype>:
2303 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2304 [(set (vectype VECREG:$rT),
2305 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
2307 multiclass ShiftLeftQuadBytes
2309 def v16i8: SHLQBYVecInst<v16i8>;
2310 def v8i16: SHLQBYVecInst<v8i16>;
2311 def v4i32: SHLQBYVecInst<v4i32>;
2312 def v4f32: SHLQBYVecInst<v4f32>;
2313 def v2i64: SHLQBYVecInst<v2i64>;
2314 def v2f64: SHLQBYVecInst<v2f64>;
2315 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2316 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2319 defm SHLQBY: ShiftLeftQuadBytes;
2321 class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2322 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2323 RotateShift, pattern>;
2325 class SHLQBYIVecInst<ValueType vectype>:
2326 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2327 [(set (vectype VECREG:$rT),
2328 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2330 multiclass ShiftLeftQuadBytesImm
2332 def v16i8: SHLQBYIVecInst<v16i8>;
2333 def v8i16: SHLQBYIVecInst<v8i16>;
2334 def v4i32: SHLQBYIVecInst<v4i32>;
2335 def v4f32: SHLQBYIVecInst<v4f32>;
2336 def v2i64: SHLQBYIVecInst<v2i64>;
2337 def v2f64: SHLQBYIVecInst<v2f64>;
2338 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2340 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2343 defm SHLQBYI : ShiftLeftQuadBytesImm;
2345 class SHLQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2346 RRForm<0b00111001111, OOL, IOL, "shlqbybi\t$rT, $rA, $rB",
2347 RotateShift, pattern>;
2349 class SHLQBYBIVecInst<ValueType vectype>:
2350 SHLQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2351 [/* no pattern */]>;
2353 class SHLQBYBIRegInst<RegisterClass rclass>:
2354 SHLQBYBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2355 [/* no pattern */]>;
2357 multiclass ShiftLeftQuadBytesBitCount
2359 def v16i8: SHLQBYBIVecInst<v16i8>;
2360 def v8i16: SHLQBYBIVecInst<v8i16>;
2361 def v4i32: SHLQBYBIVecInst<v4i32>;
2362 def v4f32: SHLQBYBIVecInst<v4f32>;
2363 def v2i64: SHLQBYBIVecInst<v2i64>;
2364 def v2f64: SHLQBYBIVecInst<v2f64>;
2366 def r128: SHLQBYBIRegInst<GPRC>;
2369 defm SHLQBYBI : ShiftLeftQuadBytesBitCount;
2371 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2373 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2374 class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2375 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2376 RotateShift, pattern>;
2378 class ROTHVecInst<ValueType vectype>:
2379 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2380 [(set (vectype VECREG:$rT),
2381 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
2383 class ROTHRegInst<RegisterClass rclass>:
2384 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2385 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2387 multiclass RotateLeftHalfword
2389 def v8i16: ROTHVecInst<v8i16>;
2390 def r16: ROTHRegInst<R16C>;
2393 defm ROTH: RotateLeftHalfword;
2395 def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2396 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2398 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2399 // Rotate halfword, immediate:
2400 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2401 class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2402 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2403 RotateShift, pattern>;
2405 class ROTHIVecInst<ValueType vectype>:
2406 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2407 [(set (vectype VECREG:$rT),
2408 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2410 multiclass RotateLeftHalfwordImm
2412 def v8i16: ROTHIVecInst<v8i16>;
2413 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2414 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2415 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2416 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2419 defm ROTHI: RotateLeftHalfwordImm;
2421 def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
2422 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
2424 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2426 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2428 class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2429 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2430 RotateShift, pattern>;
2432 class ROTVecInst<ValueType vectype>:
2433 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2434 [(set (vectype VECREG:$rT),
2435 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
2437 class ROTRegInst<RegisterClass rclass>:
2438 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2440 (rotl rclass:$rA, R32C:$rB))]>;
2442 multiclass RotateLeftWord
2444 def v4i32: ROTVecInst<v4i32>;
2445 def r32: ROTRegInst<R32C>;
2448 defm ROT: RotateLeftWord;
2450 // The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2452 def ROTr32_r16_anyext:
2453 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2454 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
2456 def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2457 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2459 def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2460 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2462 def ROTr32_r8_anyext:
2463 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2464 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
2466 def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2467 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2469 def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2470 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2472 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2473 // Rotate word, immediate
2474 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2476 class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2477 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2478 RotateShift, pattern>;
2480 class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2481 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2482 [(set (vectype VECREG:$rT),
2483 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
2485 class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2486 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2487 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
2489 multiclass RotateLeftWordImm
2491 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2492 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2493 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
2495 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2496 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2497 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2500 defm ROTI : RotateLeftWordImm;
2502 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2503 // Rotate quad by byte (count)
2504 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2506 class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2507 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2508 RotateShift, pattern>;
2510 class ROTQBYVecInst<ValueType vectype>:
2511 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2512 [(set (vectype VECREG:$rT),
2513 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2515 multiclass RotateQuadLeftByBytes
2517 def v16i8: ROTQBYVecInst<v16i8>;
2518 def v8i16: ROTQBYVecInst<v8i16>;
2519 def v4i32: ROTQBYVecInst<v4i32>;
2520 def v4f32: ROTQBYVecInst<v4f32>;
2521 def v2i64: ROTQBYVecInst<v2i64>;
2522 def v2f64: ROTQBYVecInst<v2f64>;
2525 defm ROTQBY: RotateQuadLeftByBytes;
2527 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2528 // Rotate quad by byte (count), immediate
2529 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2531 class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2532 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2533 RotateShift, pattern>;
2535 class ROTQBYIVecInst<ValueType vectype>:
2536 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2537 [(set (vectype VECREG:$rT),
2538 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2540 multiclass RotateQuadByBytesImm
2542 def v16i8: ROTQBYIVecInst<v16i8>;
2543 def v8i16: ROTQBYIVecInst<v8i16>;
2544 def v4i32: ROTQBYIVecInst<v4i32>;
2545 def v4f32: ROTQBYIVecInst<v4f32>;
2546 def v2i64: ROTQBYIVecInst<v2i64>;
2547 def vfi64: ROTQBYIVecInst<v2f64>;
2550 defm ROTQBYI: RotateQuadByBytesImm;
2552 // See ROTQBY note above.
2553 class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2554 RI7Form<0b00110011100, OOL, IOL,
2555 "rotqbybi\t$rT, $rA, $shift",
2556 RotateShift, pattern>;
2558 class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2559 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2560 [(set (vectype VECREG:$rT),
2561 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2563 multiclass RotateQuadByBytesByBitshift {
2564 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2565 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2566 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2567 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2570 defm ROTQBYBI : RotateQuadByBytesByBitshift;
2572 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2573 // See ROTQBY note above.
2575 // Assume that the user of this instruction knows to shift the rotate count
2577 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2579 class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2580 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2581 RotateShift, pattern>;
2583 class ROTQBIVecInst<ValueType vectype>:
2584 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2585 [/* no pattern yet */]>;
2587 class ROTQBIRegInst<RegisterClass rclass>:
2588 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2589 [/* no pattern yet */]>;
2591 multiclass RotateQuadByBitCount
2593 def v16i8: ROTQBIVecInst<v16i8>;
2594 def v8i16: ROTQBIVecInst<v8i16>;
2595 def v4i32: ROTQBIVecInst<v4i32>;
2596 def v2i64: ROTQBIVecInst<v2i64>;
2598 def r128: ROTQBIRegInst<GPRC>;
2599 def r64: ROTQBIRegInst<R64C>;
2602 defm ROTQBI: RotateQuadByBitCount;
2604 class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2605 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2606 RotateShift, pattern>;
2608 class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2610 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2611 [/* no pattern yet */]>;
2613 class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2615 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2616 [/* no pattern yet */]>;
2618 multiclass RotateQuadByBitCountImm
2620 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2621 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2622 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2623 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2625 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2626 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2629 defm ROTQBII : RotateQuadByBitCountImm;
2631 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2632 // ROTHM v8i16 form:
2633 // NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2634 // so this only matches a synthetically generated/lowered code
2636 // NOTE(2): $rB must be negated before the right rotate!
2637 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2639 class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2640 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2641 RotateShift, pattern>;
2644 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2645 [/* see patterns below - $rB must be negated */]>;
2647 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
2648 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2650 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
2651 (ROTHMv8i16 VECREG:$rA,
2652 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2654 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
2655 (ROTHMv8i16 VECREG:$rA,
2656 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2658 // ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2659 // Note: This instruction doesn't match a pattern because rB must be negated
2660 // for the instruction to work. Thus, the pattern below the instruction!
2663 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2664 [/* see patterns below - $rB must be negated! */]>;
2666 def : Pat<(srl R16C:$rA, R32C:$rB),
2667 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2669 def : Pat<(srl R16C:$rA, R16C:$rB),
2671 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2673 def : Pat<(srl R16C:$rA, R8C:$rB),
2675 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2677 // ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2678 // that the immediate can be complemented, so that the user doesn't have to
2681 class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2682 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2683 RotateShift, pattern>;
2686 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2687 [/* no pattern */]>;
2689 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2690 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2692 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
2693 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2695 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
2696 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2699 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2700 [/* no pattern */]>;
2702 def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2703 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2705 def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2706 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2708 def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2709 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2711 // ROTM v4i32 form: See the ROTHM v8i16 comments.
2712 class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2713 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2714 RotateShift, pattern>;
2717 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2718 [/* see patterns below - $rB must be negated */]>;
2720 def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
2721 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2723 def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
2724 (ROTMv4i32 VECREG:$rA,
2725 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2727 def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
2728 (ROTMv4i32 VECREG:$rA,
2729 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2732 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2733 [/* see patterns below - $rB must be negated */]>;
2735 def : Pat<(srl R32C:$rA, R32C:$rB),
2736 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2738 def : Pat<(srl R32C:$rA, R16C:$rB),
2740 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2742 def : Pat<(srl R32C:$rA, R8C:$rB),
2744 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2746 // ROTMI v4i32 form: See the comment for ROTHM v8i16.
2748 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2749 "rotmi\t$rT, $rA, $val", RotateShift,
2750 [(set (v4i32 VECREG:$rT),
2751 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
2753 def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
2754 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2756 def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
2757 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2759 // ROTMI r32 form: know how to complement the immediate value.
2761 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2762 "rotmi\t$rT, $rA, $val", RotateShift,
2763 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2765 def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2766 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2768 def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2769 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2771 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2772 // ROTQMBY: This is a vector form merely so that when used in an
2773 // instruction pattern, type checking will succeed. This instruction assumes
2774 // that the user knew to negate $rB.
2775 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2777 class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2778 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2779 RotateShift, pattern>;
2781 class ROTQMBYVecInst<ValueType vectype>:
2782 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2783 [/* no pattern, $rB must be negated */]>;
2785 class ROTQMBYRegInst<RegisterClass rclass>:
2786 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2787 [/* no pattern */]>;
2789 multiclass RotateQuadBytes
2791 def v16i8: ROTQMBYVecInst<v16i8>;
2792 def v8i16: ROTQMBYVecInst<v8i16>;
2793 def v4i32: ROTQMBYVecInst<v4i32>;
2794 def v2i64: ROTQMBYVecInst<v2i64>;
2796 def r128: ROTQMBYRegInst<GPRC>;
2797 def r64: ROTQMBYRegInst<R64C>;
2800 defm ROTQMBY : RotateQuadBytes;
2802 class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2803 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2804 RotateShift, pattern>;
2806 class ROTQMBYIVecInst<ValueType vectype>:
2807 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2808 [/* no pattern */]>;
2810 class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2812 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2813 [/* no pattern */]>;
2815 // 128-bit zero extension form:
2816 class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2817 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2818 [/* no pattern */]>;
2820 multiclass RotateQuadBytesImm
2822 def v16i8: ROTQMBYIVecInst<v16i8>;
2823 def v8i16: ROTQMBYIVecInst<v8i16>;
2824 def v4i32: ROTQMBYIVecInst<v4i32>;
2825 def v2i64: ROTQMBYIVecInst<v2i64>;
2827 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2828 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
2830 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2831 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2832 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2833 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
2836 defm ROTQMBYI : RotateQuadBytesImm;
2838 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2839 // Rotate right and mask by bit count
2840 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2842 class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2843 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2844 RotateShift, pattern>;
2846 class ROTQMBYBIVecInst<ValueType vectype>:
2847 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2848 [/* no pattern, */]>;
2850 multiclass RotateMaskQuadByBitCount
2852 def v16i8: ROTQMBYBIVecInst<v16i8>;
2853 def v8i16: ROTQMBYBIVecInst<v8i16>;
2854 def v4i32: ROTQMBYBIVecInst<v4i32>;
2855 def v2i64: ROTQMBYBIVecInst<v2i64>;
2858 defm ROTQMBYBI: RotateMaskQuadByBitCount;
2860 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2861 // Rotate quad and mask by bits
2862 // Note that the rotate amount has to be negated
2863 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2865 class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2866 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2867 RotateShift, pattern>;
2869 class ROTQMBIVecInst<ValueType vectype>:
2870 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2871 [/* no pattern */]>;
2873 class ROTQMBIRegInst<RegisterClass rclass>:
2874 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2875 [/* no pattern */]>;
2877 multiclass RotateMaskQuadByBits
2879 def v16i8: ROTQMBIVecInst<v16i8>;
2880 def v8i16: ROTQMBIVecInst<v8i16>;
2881 def v4i32: ROTQMBIVecInst<v4i32>;
2882 def v2i64: ROTQMBIVecInst<v2i64>;
2884 def r128: ROTQMBIRegInst<GPRC>;
2885 def r64: ROTQMBIRegInst<R64C>;
2888 defm ROTQMBI: RotateMaskQuadByBits;
2890 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2891 // Rotate quad and mask by bits, immediate
2892 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2894 class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2895 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2896 RotateShift, pattern>;
2898 class ROTQMBIIVecInst<ValueType vectype>:
2899 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2900 [/* no pattern */]>;
2902 class ROTQMBIIRegInst<RegisterClass rclass>:
2903 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
2904 [/* no pattern */]>;
2906 multiclass RotateMaskQuadByBitsImm
2908 def v16i8: ROTQMBIIVecInst<v16i8>;
2909 def v8i16: ROTQMBIIVecInst<v8i16>;
2910 def v4i32: ROTQMBIIVecInst<v4i32>;
2911 def v2i64: ROTQMBIIVecInst<v2i64>;
2913 def r128: ROTQMBIIRegInst<GPRC>;
2914 def r64: ROTQMBIIRegInst<R64C>;
2917 defm ROTQMBII: RotateMaskQuadByBitsImm;
2919 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2920 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2923 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2924 "rotmah\t$rT, $rA, $rB", RotateShift,
2925 [/* see patterns below - $rB must be negated */]>;
2927 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2928 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2930 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2931 (ROTMAHv8i16 VECREG:$rA,
2932 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2934 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2935 (ROTMAHv8i16 VECREG:$rA,
2936 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2939 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2940 "rotmah\t$rT, $rA, $rB", RotateShift,
2941 [/* see patterns below - $rB must be negated */]>;
2943 def : Pat<(sra R16C:$rA, R32C:$rB),
2944 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2946 def : Pat<(sra R16C:$rA, R16C:$rB),
2947 (ROTMAHr16 R16C:$rA,
2948 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2950 def : Pat<(sra R16C:$rA, R8C:$rB),
2951 (ROTMAHr16 R16C:$rA,
2952 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2955 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2956 "rotmahi\t$rT, $rA, $val", RotateShift,
2957 [(set (v8i16 VECREG:$rT),
2958 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
2960 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
2961 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2963 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
2964 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2967 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2968 "rotmahi\t$rT, $rA, $val", RotateShift,
2969 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2971 def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2972 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2974 def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2975 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2978 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2979 "rotma\t$rT, $rA, $rB", RotateShift,
2980 [/* see patterns below - $rB must be negated */]>;
2982 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2983 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2985 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2986 (ROTMAv4i32 (v4i32 VECREG:$rA),
2987 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2989 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2990 (ROTMAv4i32 (v4i32 VECREG:$rA),
2991 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2994 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2995 "rotma\t$rT, $rA, $rB", RotateShift,
2996 [/* see patterns below - $rB must be negated */]>;
2998 def : Pat<(sra R32C:$rA, R32C:$rB),
2999 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
3001 def : Pat<(sra R32C:$rA, R16C:$rB),
3003 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
3005 def : Pat<(sra R32C:$rA, R8C:$rB),
3007 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
3009 class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
3010 RRForm<0b01011110000, OOL, IOL,
3011 "rotmai\t$rT, $rA, $val",
3012 RotateShift, pattern>;
3014 class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
3015 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
3016 [(set (vectype VECREG:$rT),
3017 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
3019 class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
3020 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
3021 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
3023 multiclass RotateMaskAlgebraicImm {
3024 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
3025 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
3026 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
3027 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
3030 defm ROTMAI : RotateMaskAlgebraicImm;
3032 //===----------------------------------------------------------------------===//
3033 // Branch and conditionals:
3034 //===----------------------------------------------------------------------===//
3036 let isTerminator = 1, isBarrier = 1 in {
3037 // Halt If Equal (r32 preferred slot only, no vector form)
3039 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3040 "heq\t$rA, $rB", BranchResolv,
3041 [/* no pattern to match */]>;
3044 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3045 "heqi\t$rA, $val", BranchResolv,
3046 [/* no pattern to match */]>;
3048 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3049 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3051 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3052 "hgt\t$rA, $rB", BranchResolv,
3053 [/* no pattern to match */]>;
3056 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3057 "hgti\t$rA, $val", BranchResolv,
3058 [/* no pattern to match */]>;
3061 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3062 "hlgt\t$rA, $rB", BranchResolv,
3063 [/* no pattern to match */]>;
3066 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3067 "hlgti\t$rA, $val", BranchResolv,
3068 [/* no pattern to match */]>;
3071 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3072 // Comparison operators for i8, i16 and i32:
3073 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3075 class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3076 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3079 multiclass CmpEqualByte
3082 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3083 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3084 (v8i16 VECREG:$rB)))]>;
3087 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3088 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3091 class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3092 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3095 multiclass CmpEqualByteImm
3098 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3099 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3100 v16i8SExt8Imm:$val))]>;
3102 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3103 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3106 class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3107 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3110 multiclass CmpEqualHalfword
3112 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3113 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3114 (v8i16 VECREG:$rB)))]>;
3116 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3117 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3120 class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3121 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3124 multiclass CmpEqualHalfwordImm
3126 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3127 [(set (v8i16 VECREG:$rT),
3128 (seteq (v8i16 VECREG:$rA),
3129 (v8i16 v8i16SExt10Imm:$val)))]>;
3130 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3131 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3134 class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3135 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3138 multiclass CmpEqualWord
3140 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3141 [(set (v4i32 VECREG:$rT),
3142 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3144 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3145 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3148 class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3149 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3152 multiclass CmpEqualWordImm
3154 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3155 [(set (v4i32 VECREG:$rT),
3156 (seteq (v4i32 VECREG:$rA),
3157 (v4i32 v4i32SExt16Imm:$val)))]>;
3159 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3160 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3163 class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3164 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3167 multiclass CmpGtrByte
3170 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3171 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3172 (v8i16 VECREG:$rB)))]>;
3175 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3176 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3179 class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3180 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3183 multiclass CmpGtrByteImm
3186 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3187 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3188 v16i8SExt8Imm:$val))]>;
3190 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3191 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
3194 class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3195 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3198 multiclass CmpGtrHalfword
3200 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3201 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3202 (v8i16 VECREG:$rB)))]>;
3204 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3205 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3208 class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3209 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3212 multiclass CmpGtrHalfwordImm
3214 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3215 [(set (v8i16 VECREG:$rT),
3216 (setgt (v8i16 VECREG:$rA),
3217 (v8i16 v8i16SExt10Imm:$val)))]>;
3218 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3219 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3222 class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3223 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3226 multiclass CmpGtrWord
3228 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3229 [(set (v4i32 VECREG:$rT),
3230 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3232 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3233 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3236 class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3237 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3240 multiclass CmpGtrWordImm
3242 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3243 [(set (v4i32 VECREG:$rT),
3244 (setgt (v4i32 VECREG:$rA),
3245 (v4i32 v4i32SExt16Imm:$val)))]>;
3247 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3248 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
3250 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3251 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3252 [(set (v4i32 VECREG:$rT),
3253 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3254 (v4i32 v4i32SExt16Imm:$val)))]>;
3256 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
3257 [/* no pattern */]>;
3260 class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3261 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
3264 multiclass CmpLGtrByte
3267 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3268 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3269 (v8i16 VECREG:$rB)))]>;
3272 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3273 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3276 class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3277 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
3280 multiclass CmpLGtrByteImm
3283 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3284 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3285 v16i8SExt8Imm:$val))]>;
3287 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3288 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3291 class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3292 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
3295 multiclass CmpLGtrHalfword
3297 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3298 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3299 (v8i16 VECREG:$rB)))]>;
3301 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3302 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3305 class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3306 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
3309 multiclass CmpLGtrHalfwordImm
3311 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3312 [(set (v8i16 VECREG:$rT),
3313 (setugt (v8i16 VECREG:$rA),
3314 (v8i16 v8i16SExt10Imm:$val)))]>;
3315 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3316 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3319 class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
3320 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
3323 multiclass CmpLGtrWord
3325 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3326 [(set (v4i32 VECREG:$rT),
3327 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3329 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3330 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3333 class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3334 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
3337 multiclass CmpLGtrWordImm
3339 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3340 [(set (v4i32 VECREG:$rT),
3341 (setugt (v4i32 VECREG:$rA),
3342 (v4i32 v4i32SExt16Imm:$val)))]>;
3344 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3345 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
3348 defm CEQB : CmpEqualByte;
3349 defm CEQBI : CmpEqualByteImm;
3350 defm CEQH : CmpEqualHalfword;
3351 defm CEQHI : CmpEqualHalfwordImm;
3352 defm CEQ : CmpEqualWord;
3353 defm CEQI : CmpEqualWordImm;
3354 defm CGTB : CmpGtrByte;
3355 defm CGTBI : CmpGtrByteImm;
3356 defm CGTH : CmpGtrHalfword;
3357 defm CGTHI : CmpGtrHalfwordImm;
3358 defm CGT : CmpGtrWord;
3359 defm CGTI : CmpGtrWordImm;
3360 defm CLGTB : CmpLGtrByte;
3361 defm CLGTBI : CmpLGtrByteImm;
3362 defm CLGTH : CmpLGtrHalfword;
3363 defm CLGTHI : CmpLGtrHalfwordImm;
3364 defm CLGT : CmpLGtrWord;
3365 defm CLGTI : CmpLGtrWordImm;
3367 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3368 // For SETCC primitives not supported above (setlt, setle, setge, etc.)
3369 // define a pattern to generate the right code, as a binary operator
3370 // (in a manner of speaking.)
3373 // 1. This only matches the setcc set of conditionals. Special pattern
3374 // matching is used for select conditionals.
3376 // 2. The "DAG" versions of these classes is almost exclusively used for
3377 // i64 comparisons. See the tblgen fundamentals documentation for what
3378 // ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3379 // class for where ResultInstrs originates.
3380 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3382 class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3383 SPUInstr xorinst, SPUInstr cmpare>:
3384 Pat<(cond rclass:$rA, rclass:$rB),
3385 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3387 class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3388 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3389 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3390 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3392 def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
3393 def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3395 def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
3396 def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3398 def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3399 def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
3401 class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3402 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3403 Pat<(cond rclass:$rA, rclass:$rB),
3404 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3405 (cmpOp2 rclass:$rA, rclass:$rB))>;
3407 class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3409 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3410 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3411 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3412 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3414 def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3415 def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3416 def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3417 def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3418 def : Pat<(setle R8C:$rA, R8C:$rB),
3419 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3420 def : Pat<(setle R8C:$rA, immU8:$imm),
3421 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3423 def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3424 def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3425 ORr16, CGTHIr16, CEQHIr16>;
3426 def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3427 def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3428 def : Pat<(setle R16C:$rA, R16C:$rB),
3429 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3430 def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3431 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3433 def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3434 def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3435 ORr32, CGTIr32, CEQIr32>;
3436 def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3437 def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3438 def : Pat<(setle R32C:$rA, R32C:$rB),
3439 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3440 def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3441 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3443 def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3444 def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3445 def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3446 def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3447 def : Pat<(setule R8C:$rA, R8C:$rB),
3448 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3449 def : Pat<(setule R8C:$rA, immU8:$imm),
3450 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3452 def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3453 def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3454 ORr16, CLGTHIr16, CEQHIr16>;
3455 def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3456 def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3457 CLGTHIr16, CEQHIr16>;
3458 def : Pat<(setule R16C:$rA, R16C:$rB),
3459 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3460 def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
3461 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3463 def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
3464 def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
3465 ORr32, CLGTIr32, CEQIr32>;
3466 def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
3467 def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
3468 def : Pat<(setule R32C:$rA, R32C:$rB),
3469 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3470 def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3471 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3473 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3474 // select conditional patterns:
3475 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3477 class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3478 SPUInstr selinstr, SPUInstr cmpare>:
3479 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3480 rclass:$rTrue, rclass:$rFalse),
3481 (selinstr rclass:$rTrue, rclass:$rFalse,
3482 (cmpare rclass:$rA, rclass:$rB))>;
3484 class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3485 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3486 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
3487 rclass:$rTrue, rclass:$rFalse),
3488 (selinstr rclass:$rTrue, rclass:$rFalse,
3489 (cmpare rclass:$rA, immpred:$imm))>;
3491 def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3492 def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3493 def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3494 def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3495 def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3496 def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3498 def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3499 def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3500 def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3501 def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3502 def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3503 def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3505 def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3506 def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3507 def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3508 def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3509 def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3510 def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3512 class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3513 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3515 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3516 rclass:$rTrue, rclass:$rFalse),
3517 (selinstr rclass:$rFalse, rclass:$rTrue,
3518 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3519 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3521 class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3523 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3525 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
3526 rclass:$rTrue, rclass:$rFalse),
3527 (selinstr rclass:$rFalse, rclass:$rTrue,
3528 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3529 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3531 def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3532 def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3533 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3535 def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3536 def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3537 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3539 def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3540 def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3541 SELBr32, ORr32, CGTIr32, CEQIr32>;
3543 def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3544 def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3545 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3547 def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3548 def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3549 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3551 def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3552 def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3553 SELBr32, ORr32, CLGTIr32, CEQIr32>;
3555 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3558 // All calls clobber the non-callee-saved registers:
3559 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3560 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3561 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3562 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3563 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3564 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3565 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3566 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3567 // All of these instructions use $lr (aka $0)
3569 // Branch relative and set link: Used if we actually know that the target
3570 // is within [-32768, 32767] bytes of the target
3572 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3573 "brsl\t$$lr, $func",
3574 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3576 // Branch absolute and set link: Used if we actually know that the target
3577 // is an absolute address
3579 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3580 "brasl\t$$lr, $func",
3581 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
3583 // Branch indirect and set link if external data. These instructions are not
3584 // actually generated, matched by an intrinsic:
3585 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3586 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3587 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3588 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3590 // Branch indirect and set link. This is the "X-form" address version of a
3593 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3596 // Support calls to external symbols:
3597 def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3598 (BRSL texternalsym:$func)>;
3600 def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3601 (BRASL texternalsym:$func)>;
3603 // Unconditional branches:
3604 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
3606 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3610 // Unconditional, absolute address branch
3612 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3614 [/* no pattern */]>;
3618 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3620 // Conditional branches:
3621 class BRNZInst<dag IOL, list<dag> pattern>:
3622 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3623 BranchResolv, pattern>;
3625 class BRNZRegInst<RegisterClass rclass>:
3626 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3627 [(brcond rclass:$rCond, bb:$dest)]>;
3629 class BRNZVecInst<ValueType vectype>:
3630 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3631 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
3633 multiclass BranchNotZero {
3634 def v4i32 : BRNZVecInst<v4i32>;
3635 def r32 : BRNZRegInst<R32C>;
3638 defm BRNZ : BranchNotZero;
3640 class BRZInst<dag IOL, list<dag> pattern>:
3641 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3642 BranchResolv, pattern>;
3644 class BRZRegInst<RegisterClass rclass>:
3645 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3647 class BRZVecInst<ValueType vectype>:
3648 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3650 multiclass BranchZero {
3651 def v4i32: BRZVecInst<v4i32>;
3652 def r32: BRZRegInst<R32C>;
3655 defm BRZ: BranchZero;
3657 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3660 class BINZInst<dag IOL, list<dag> pattern>:
3661 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3663 class BINZRegInst<RegisterClass rclass>:
3664 BINZInst<(ins rclass:$rA, brtarget:$dest),
3665 [(brcond rclass:$rA, R32C:$dest)]>;
3667 class BINZVecInst<ValueType vectype>:
3668 BINZInst<(ins VECREG:$rA, R32C:$dest),
3669 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3671 multiclass BranchNotZeroIndirect {
3672 def v4i32: BINZVecInst<v4i32>;
3673 def r32: BINZRegInst<R32C>;
3676 defm BINZ: BranchNotZeroIndirect;
3678 class BIZInst<dag IOL, list<dag> pattern>:
3679 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3681 class BIZRegInst<RegisterClass rclass>:
3682 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3684 class BIZVecInst<ValueType vectype>:
3685 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3687 multiclass BranchZeroIndirect {
3688 def v4i32: BIZVecInst<v4i32>;
3689 def r32: BIZRegInst<R32C>;
3692 defm BIZ: BranchZeroIndirect;
3695 class BRHNZInst<dag IOL, list<dag> pattern>:
3696 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3699 class BRHNZRegInst<RegisterClass rclass>:
3700 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3701 [(brcond rclass:$rCond, bb:$dest)]>;
3703 class BRHNZVecInst<ValueType vectype>:
3704 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3706 multiclass BranchNotZeroHalfword {
3707 def v8i16: BRHNZVecInst<v8i16>;
3708 def r16: BRHNZRegInst<R16C>;
3711 defm BRHNZ: BranchNotZeroHalfword;
3713 class BRHZInst<dag IOL, list<dag> pattern>:
3714 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3717 class BRHZRegInst<RegisterClass rclass>:
3718 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3720 class BRHZVecInst<ValueType vectype>:
3721 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3723 multiclass BranchZeroHalfword {
3724 def v8i16: BRHZVecInst<v8i16>;
3725 def r16: BRHZRegInst<R16C>;
3728 defm BRHZ: BranchZeroHalfword;
3731 //===----------------------------------------------------------------------===//
3732 // setcc and brcond patterns:
3733 //===----------------------------------------------------------------------===//
3735 def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3736 (BRHZr16 R16C:$rA, bb:$dest)>;
3737 def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3738 (BRHNZr16 R16C:$rA, bb:$dest)>;
3740 def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3741 (BRZr32 R32C:$rA, bb:$dest)>;
3742 def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3743 (BRNZr32 R32C:$rA, bb:$dest)>;
3745 multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3747 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3748 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3750 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3751 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3753 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3754 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3756 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3757 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3760 defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3761 defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
3763 multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3765 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3766 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3768 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3769 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3771 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3772 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3774 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3775 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3778 defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3779 defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
3781 multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3782 SPUInstr orinst32, SPUInstr brinst32>
3784 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3785 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3786 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3789 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3790 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3791 (CEQHr16 R16C:$rA, R16:$rB)),
3794 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3795 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3796 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3799 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3800 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3801 (CEQr32 R32C:$rA, R32C:$rB)),
3805 defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3806 defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
3808 multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3810 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3811 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3813 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3814 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3816 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3817 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3819 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3820 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3823 defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3824 defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
3826 multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3827 SPUInstr orinst32, SPUInstr brinst32>
3829 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3830 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3831 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3834 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3835 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3836 (CEQHr16 R16C:$rA, R16:$rB)),
3839 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3840 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3841 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3844 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3845 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3846 (CEQr32 R32C:$rA, R32C:$rB)),
3850 defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3851 defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
3853 let isTerminator = 1, isBarrier = 1 in {
3854 let isReturn = 1 in {
3856 RETForm<"bi\t$$lr", [(retflag)]>;
3860 //===----------------------------------------------------------------------===//
3861 // Single precision floating point instructions
3862 //===----------------------------------------------------------------------===//
3864 class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3865 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
3868 class FAVecInst<ValueType vectype>:
3869 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3870 [(set (vectype VECREG:$rT),
3871 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
3875 def v4f32: FAVecInst<v4f32>;
3876 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3877 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
3882 class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3883 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
3886 class FSVecInst<ValueType vectype>:
3887 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3888 [(set (vectype VECREG:$rT),
3889 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
3893 def v4f32: FSVecInst<v4f32>;
3894 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3895 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
3900 // Floating point reciprocal estimate
3902 class FRESTInst<dag OOL, dag IOL>:
3903 RRForm_1<0b00110111000, OOL, IOL,
3904 "frest\t$rT, $rA", SPrecFP,
3905 [/* no pattern */]>;
3908 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3911 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
3913 // Floating point interpolate (used in conjunction with reciprocal estimate)
3915 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3916 "fi\t$rT, $rA, $rB", SPrecFP,
3917 [/* no pattern */]>;
3920 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3921 "fi\t$rT, $rA, $rB", SPrecFP,
3922 [/* no pattern */]>;
3924 //--------------------------------------------------------------------------
3925 // Basic single precision floating point comparisons:
3927 // Note: There is no support on SPU for single precision NaN. Consequently,
3928 // ordered and unordered comparisons are the same.
3929 //--------------------------------------------------------------------------
3932 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3933 "fceq\t$rT, $rA, $rB", SPrecFP,
3934 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3936 def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3937 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
3940 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3941 "fcmeq\t$rT, $rA, $rB", SPrecFP,
3942 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3944 def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3945 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
3948 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3949 "fcgt\t$rT, $rA, $rB", SPrecFP,
3950 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3952 def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3953 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
3956 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3957 "fcmgt\t$rT, $rA, $rB", SPrecFP,
3958 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3960 def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3961 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3963 //--------------------------------------------------------------------------
3964 // Single precision floating point comparisons and SETCC equivalents:
3965 //--------------------------------------------------------------------------
3967 def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3968 def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3970 def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3971 def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3973 def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3974 def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3976 def : Pat<(setule R32FP:$rA, R32FP:$rB),
3977 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3978 def : Pat<(setole R32FP:$rA, R32FP:$rB),
3979 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3981 // FP Status and Control Register Write
3982 // Why isn't rT a don't care in the ISA?
3983 // Should we create a special RRForm_3 for this guy and zero out the rT?
3985 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3986 "fscrwr\t$rA", SPrecFP,
3987 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3989 // FP Status and Control Register Read
3991 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3992 "fscrrd\t$rT", SPrecFP,
3993 [/* This instruction requires an intrinsic */]>;
3995 // llvm instruction space
3996 // How do these map onto cell instructions?
3998 // frest rC rB # c = 1/b (both lines)
4000 // fm rD rA rC # d = a * 1/b
4001 // fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
4002 // fma rB rB rC rD # b = b * c + d
4003 // = -(d *b -a) * c + d
4004 // = a * c - c ( a *b *c - a)
4009 // These llvm instructions will actually map to library calls.
4010 // All that's needed, then, is to check that the appropriate library is
4011 // imported and do a brsl to the proper function name.
4012 // frem # fmod(x, y): x - (x/y) * y
4013 // (Note: fmod(double, double), fmodf(float,float)
4017 // Unimplemented SPU instruction space
4018 // floating reciprocal absolute square root estimate (frsqest)
4020 // The following are probably just intrinsics
4021 // status and control register write
4022 // status and control register read
4024 //--------------------------------------
4025 // Floating point multiply instructions
4026 //--------------------------------------
4029 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4030 "fm\t$rT, $rA, $rB", SPrecFP,
4031 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
4032 (v4f32 VECREG:$rB)))]>;
4035 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4036 "fm\t$rT, $rA, $rB", SPrecFP,
4037 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4039 // Floating point multiply and add
4040 // e.g. d = c + (a * b)
4042 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4043 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4044 [(set (v4f32 VECREG:$rT),
4045 (fadd (v4f32 VECREG:$rC),
4046 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4049 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4050 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4051 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4053 // FP multiply and subtract
4054 // Subtracts value in rC from product
4057 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4058 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4059 [(set (v4f32 VECREG:$rT),
4060 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4061 (v4f32 VECREG:$rC)))]>;
4064 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4065 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4067 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4069 // Floating Negative Mulitply and Subtract
4070 // Subtracts product from value in rC
4071 // res = fneg(fms a b c)
4074 // NOTE: subtraction order
4078 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4079 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4080 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4083 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4084 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4085 [(set (v4f32 VECREG:$rT),
4086 (fsub (v4f32 VECREG:$rC),
4087 (fmul (v4f32 VECREG:$rA),
4088 (v4f32 VECREG:$rB))))]>;
4090 //--------------------------------------
4091 // Floating Point Conversions
4092 // Signed conversions:
4094 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4095 "csflt\t$rT, $rA, 0", SPrecFP,
4096 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4098 // Convert signed integer to floating point
4100 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4101 "csflt\t$rT, $rA, 0", SPrecFP,
4102 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4104 // Convert unsigned into to float
4106 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4107 "cuflt\t$rT, $rA, 0", SPrecFP,
4108 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4111 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4112 "cuflt\t$rT, $rA, 0", SPrecFP,
4113 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4115 // Convert float to unsigned int
4116 // Assume that scale = 0
4119 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4120 "cfltu\t$rT, $rA, 0", SPrecFP,
4121 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4124 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4125 "cfltu\t$rT, $rA, 0", SPrecFP,
4126 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4128 // Convert float to signed int
4129 // Assume that scale = 0
4132 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4133 "cflts\t$rT, $rA, 0", SPrecFP,
4134 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4137 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4138 "cflts\t$rT, $rA, 0", SPrecFP,
4139 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4141 //===----------------------------------------------------------------------==//
4142 // Single<->Double precision conversions
4143 //===----------------------------------------------------------------------==//
4145 // NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4146 // v4f32, output is v2f64--which goes in the name?)
4148 // Floating point extend single to double
4149 // NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4150 // operates on two double-word slots (i.e. 1st and 3rd fp numbers
4153 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4154 "fesd\t$rT, $rA", SPrecFP,
4155 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
4158 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4159 "fesd\t$rT, $rA", SPrecFP,
4160 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4162 // Floating point round double to single
4164 // RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4165 // "frds\t$rT, $rA,", SPrecFP,
4166 // [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4169 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4170 "frds\t$rT, $rA", SPrecFP,
4171 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4173 //ToDo include anyextend?
4175 //===----------------------------------------------------------------------==//
4176 // Double precision floating point instructions
4177 //===----------------------------------------------------------------------==//
4179 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4180 "dfa\t$rT, $rA, $rB", DPrecFP,
4181 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4184 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4185 "dfa\t$rT, $rA, $rB", DPrecFP,
4186 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4189 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4190 "dfs\t$rT, $rA, $rB", DPrecFP,
4191 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4194 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4195 "dfs\t$rT, $rA, $rB", DPrecFP,
4196 [(set (v2f64 VECREG:$rT),
4197 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4200 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4201 "dfm\t$rT, $rA, $rB", DPrecFP,
4202 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4205 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4206 "dfm\t$rT, $rA, $rB", DPrecFP,
4207 [(set (v2f64 VECREG:$rT),
4208 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4211 RRForm<0b00111010110, (outs R64FP:$rT),
4212 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4213 "dfma\t$rT, $rA, $rB", DPrecFP,
4214 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4215 RegConstraint<"$rC = $rT">,
4219 RRForm<0b00111010110, (outs VECREG:$rT),
4220 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4221 "dfma\t$rT, $rA, $rB", DPrecFP,
4222 [(set (v2f64 VECREG:$rT),
4223 (fadd (v2f64 VECREG:$rC),
4224 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4225 RegConstraint<"$rC = $rT">,
4229 RRForm<0b10111010110, (outs R64FP:$rT),
4230 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4231 "dfms\t$rT, $rA, $rB", DPrecFP,
4232 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4233 RegConstraint<"$rC = $rT">,
4237 RRForm<0b10111010110, (outs VECREG:$rT),
4238 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4239 "dfms\t$rT, $rA, $rB", DPrecFP,
4240 [(set (v2f64 VECREG:$rT),
4241 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4242 (v2f64 VECREG:$rC)))]>;
4244 // DFNMS: - (a * b - c)
4245 // - (a * b) + c => c - (a * b)
4247 class DFNMSInst<dag OOL, dag IOL, list<dag> pattern>:
4248 RRForm<0b01111010110, OOL, IOL, "dfnms\t$rT, $rA, $rB",
4250 RegConstraint<"$rC = $rT">,
4253 class DFNMSVecInst<list<dag> pattern>:
4254 DFNMSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4257 class DFNMSRegInst<list<dag> pattern>:
4258 DFNMSInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4261 multiclass DFMultiplySubtract
4263 def v2f64 : DFNMSVecInst<[(set (v2f64 VECREG:$rT),
4264 (fsub (v2f64 VECREG:$rC),
4265 (fmul (v2f64 VECREG:$rA),
4266 (v2f64 VECREG:$rB))))]>;
4268 def f64 : DFNMSRegInst<[(set R64FP:$rT,
4270 (fmul R64FP:$rA, R64FP:$rB)))]>;
4273 defm DFNMS : DFMultiplySubtract;
4278 RRForm<0b11111010110, (outs R64FP:$rT),
4279 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4280 "dfnma\t$rT, $rA, $rB", DPrecFP,
4281 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4282 RegConstraint<"$rC = $rT">,
4286 RRForm<0b11111010110, (outs VECREG:$rT),
4287 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4288 "dfnma\t$rT, $rA, $rB", DPrecFP,
4289 [(set (v2f64 VECREG:$rT),
4290 (fneg (fadd (v2f64 VECREG:$rC),
4291 (fmul (v2f64 VECREG:$rA),
4292 (v2f64 VECREG:$rB)))))]>,
4293 RegConstraint<"$rC = $rT">,
4296 //===----------------------------------------------------------------------==//
4297 // Floating point negation and absolute value
4298 //===----------------------------------------------------------------------==//
4300 def : Pat<(fneg (v4f32 VECREG:$rA)),
4301 (XORfnegvec (v4f32 VECREG:$rA),
4302 (v4f32 (ILHUv4i32 0x8000)))>;
4304 def : Pat<(fneg R32FP:$rA),
4305 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
4307 // Floating point absolute value
4308 // Note: f64 fabs is custom-selected.
4310 def : Pat<(fabs R32FP:$rA),
4311 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4313 def : Pat<(fabs (v4f32 VECREG:$rA)),
4314 (ANDfabsvec (v4f32 VECREG:$rA),
4315 (IOHLv4i32 (ILHUv4i32 0x7fff), 0xffff))>;
4317 //===----------------------------------------------------------------------===//
4318 // Hint for branch instructions:
4319 //===----------------------------------------------------------------------===//
4321 /* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4323 //===----------------------------------------------------------------------===//
4324 // Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4325 // in the odd pipeline)
4326 //===----------------------------------------------------------------------===//
4328 def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
4331 let Inst{0-10} = 0b10000000010;
4332 let Inst{11-17} = 0;
4333 let Inst{18-24} = 0;
4334 let Inst{25-31} = 0;
4337 def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
4340 let Inst{0-10} = 0b10000000000;
4341 let Inst{11-17} = 0;
4342 let Inst{18-24} = 0;
4343 let Inst{25-31} = 0;
4346 //===----------------------------------------------------------------------===//
4347 // Bit conversions (type conversions between vector/packed types)
4348 // NOTE: Promotions are handled using the XS* instructions.
4349 //===----------------------------------------------------------------------===//
4350 def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4351 def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4352 def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4353 def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4354 def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4356 def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4357 def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4358 def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4359 def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4360 def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4362 def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4363 def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4364 def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4365 def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4366 def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4368 def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4369 def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4370 def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4371 def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4372 def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4374 def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4375 def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4376 def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4377 def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4378 def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4380 def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4381 def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4382 def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4383 def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4384 def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4386 def : Pat<(i128 (bitconvert (v16i8 VECREG:$src))),
4387 (ORi128_vec VECREG:$src)>;
4388 def : Pat<(i128 (bitconvert (v8i16 VECREG:$src))),
4389 (ORi128_vec VECREG:$src)>;
4390 def : Pat<(i128 (bitconvert (v4i32 VECREG:$src))),
4391 (ORi128_vec VECREG:$src)>;
4392 def : Pat<(i128 (bitconvert (v2i64 VECREG:$src))),
4393 (ORi128_vec VECREG:$src)>;
4394 def : Pat<(i128 (bitconvert (v4f32 VECREG:$src))),
4395 (ORi128_vec VECREG:$src)>;
4396 def : Pat<(i128 (bitconvert (v2f64 VECREG:$src))),
4397 (ORi128_vec VECREG:$src)>;
4399 def : Pat<(v16i8 (bitconvert (i128 GPRC:$src))),
4400 (v16i8 (ORvec_i128 GPRC:$src))>;
4401 def : Pat<(v8i16 (bitconvert (i128 GPRC:$src))),
4402 (v8i16 (ORvec_i128 GPRC:$src))>;
4403 def : Pat<(v4i32 (bitconvert (i128 GPRC:$src))),
4404 (v4i32 (ORvec_i128 GPRC:$src))>;
4405 def : Pat<(v2i64 (bitconvert (i128 GPRC:$src))),
4406 (v2i64 (ORvec_i128 GPRC:$src))>;
4407 def : Pat<(v4f32 (bitconvert (i128 GPRC:$src))),
4408 (v4f32 (ORvec_i128 GPRC:$src))>;
4409 def : Pat<(v2f64 (bitconvert (i128 GPRC:$src))),
4410 (v2f64 (ORvec_i128 GPRC:$src))>;
4412 //===----------------------------------------------------------------------===//
4413 // Instruction patterns:
4414 //===----------------------------------------------------------------------===//
4416 // General 32-bit constants:
4417 def : Pat<(i32 imm:$imm),
4418 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4420 // Single precision float constants:
4421 def : Pat<(f32 fpimm:$imm),
4422 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4424 // General constant 32-bit vectors
4425 def : Pat<(v4i32 v4i32Imm:$imm),
4426 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4427 (LO16_vec v4i32Imm:$imm))>;
4430 def : Pat<(i8 imm:$imm),
4433 //===----------------------------------------------------------------------===//
4434 // Zero/Any/Sign extensions
4435 //===----------------------------------------------------------------------===//
4437 // sext 8->32: Sign extend bytes to words
4438 def : Pat<(sext_inreg R32C:$rSrc, i8),
4439 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4441 def : Pat<(i32 (sext R8C:$rSrc)),
4442 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4444 // sext 8->64: Sign extend bytes to double word
4445 def : Pat<(sext_inreg R64C:$rSrc, i8),
4446 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4448 def : Pat<(i64 (sext R8C:$rSrc)),
4449 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4451 // zext 8->16: Zero extend bytes to halfwords
4452 def : Pat<(i16 (zext R8C:$rSrc)),
4453 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
4455 // zext 8->32: Zero extend bytes to words
4456 def : Pat<(i32 (zext R8C:$rSrc)),
4457 (ANDIi8i32 R8C:$rSrc, 0xff)>;
4459 // zext 8->64: Zero extend bytes to double words
4460 def : Pat<(i64 (zext R8C:$rSrc)),
4461 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4462 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4465 (FSMBIv4i32 0x0f0f)))>;
4467 // anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
4468 def : Pat<(i16 (anyext R8C:$rSrc)),
4469 (ORHIi8i16 R8C:$rSrc, 0)>;
4471 // anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
4472 def : Pat<(i32 (anyext R8C:$rSrc)),
4473 (ORIi8i32 R8C:$rSrc, 0)>;
4475 // sext 16->64: Sign extend halfword to double word
4476 def : Pat<(sext_inreg R64C:$rSrc, i16),
4477 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4479 def : Pat<(sext R16C:$rSrc),
4480 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4482 // zext 16->32: Zero extend halfwords to words
4483 def : Pat<(i32 (zext R16C:$rSrc)),
4484 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
4486 def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
4487 (ANDIi16i32 R16C:$rSrc, 0xf)>;
4489 def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
4490 (ANDIi16i32 R16C:$rSrc, 0xff)>;
4492 def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
4493 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
4495 // anyext 16->32: Extend 16->32 bits, irrespective of sign
4496 def : Pat<(i32 (anyext R16C:$rSrc)),
4497 (ORIi16i32 R16C:$rSrc, 0)>;
4499 //===----------------------------------------------------------------------===//
4501 // These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4502 // above are custom lowered.
4503 //===----------------------------------------------------------------------===//
4505 def : Pat<(i8 (trunc GPRC:$src)),
4507 (SHUFBgprc GPRC:$src, GPRC:$src,
4508 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4510 def : Pat<(i8 (trunc R64C:$src)),
4513 (ORv2i64_i64 R64C:$src),
4514 (ORv2i64_i64 R64C:$src),
4515 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4517 def : Pat<(i8 (trunc R32C:$src)),
4520 (ORv4i32_i32 R32C:$src),
4521 (ORv4i32_i32 R32C:$src),
4522 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4524 def : Pat<(i8 (trunc R16C:$src)),
4527 (ORv8i16_i16 R16C:$src),
4528 (ORv8i16_i16 R16C:$src),
4529 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4531 def : Pat<(i16 (trunc GPRC:$src)),
4533 (SHUFBgprc GPRC:$src, GPRC:$src,
4534 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4536 def : Pat<(i16 (trunc R64C:$src)),
4539 (ORv2i64_i64 R64C:$src),
4540 (ORv2i64_i64 R64C:$src),
4541 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4543 def : Pat<(i16 (trunc R32C:$src)),
4546 (ORv4i32_i32 R32C:$src),
4547 (ORv4i32_i32 R32C:$src),
4548 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4550 def : Pat<(i32 (trunc GPRC:$src)),
4552 (SHUFBgprc GPRC:$src, GPRC:$src,
4553 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4555 def : Pat<(i32 (trunc R64C:$src)),
4558 (ORv2i64_i64 R64C:$src),
4559 (ORv2i64_i64 R64C:$src),
4560 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4562 //===----------------------------------------------------------------------===//
4563 // Address generation: SPU, like PPC, has to split addresses into high and
4564 // low parts in order to load them into a register.
4565 //===----------------------------------------------------------------------===//
4567 def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4568 def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4569 def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4570 def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4572 def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4573 (SPUlo tglobaladdr:$in, 0)),
4574 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4576 def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4577 (SPUlo texternalsym:$in, 0)),
4578 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4580 def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4581 (SPUlo tjumptable:$in, 0)),
4582 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4584 def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4585 (SPUlo tconstpool:$in, 0)),
4586 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4588 def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4589 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4591 def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4592 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4594 def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4595 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4597 def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4598 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4601 include "CellSDKIntrinsics.td"
4602 // Various math operator instruction sequences
4603 include "SPUMathInstr.td"
4604 // 64-bit "instructions"/support
4605 include "SPU64InstrInfo.td"
4606 // 128-bit "instructions"/support
4607 include "SPU128InstrInfo.td"