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 "${:comment} .loc $file, $line, $col",
39 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
42 //===----------------------------------------------------------------------===//
44 // NB: The ordering is actually important, since the instruction selection
45 // will try each of the instructions in sequence, i.e., the D-form first with
46 // the 10-bit displacement, then the A-form with the 16 bit displacement, and
47 // finally the X-form with the register-register.
48 //===----------------------------------------------------------------------===//
50 let canFoldAsLoad = 1 in {
51 class LoadDFormVec<ValueType vectype>
52 : RI10Form<0b00101100, (outs VECREG:$rT), (ins memri10:$src),
55 [(set (vectype VECREG:$rT), (load dform_addr:$src))]>
58 class LoadDForm<RegisterClass rclass>
59 : RI10Form<0b00101100, (outs rclass:$rT), (ins memri10:$src),
62 [(set rclass:$rT, (load dform_addr:$src))]>
67 def v16i8: LoadDFormVec<v16i8>;
68 def v8i16: LoadDFormVec<v8i16>;
69 def v4i32: LoadDFormVec<v4i32>;
70 def v2i64: LoadDFormVec<v2i64>;
71 def v4f32: LoadDFormVec<v4f32>;
72 def v2f64: LoadDFormVec<v2f64>;
74 def r128: LoadDForm<GPRC>;
75 def r64: LoadDForm<R64C>;
76 def r32: LoadDForm<R32C>;
77 def f32: LoadDForm<R32FP>;
78 def f64: LoadDForm<R64FP>;
79 def r16: LoadDForm<R16C>;
80 def r8: LoadDForm<R8C>;
83 class LoadAFormVec<ValueType vectype>
84 : RI16Form<0b100001100, (outs VECREG:$rT), (ins addr256k:$src),
87 [(set (vectype VECREG:$rT), (load aform_addr:$src))]>
90 class LoadAForm<RegisterClass rclass>
91 : RI16Form<0b100001100, (outs rclass:$rT), (ins addr256k:$src),
94 [(set rclass:$rT, (load aform_addr:$src))]>
99 def v16i8: LoadAFormVec<v16i8>;
100 def v8i16: LoadAFormVec<v8i16>;
101 def v4i32: LoadAFormVec<v4i32>;
102 def v2i64: LoadAFormVec<v2i64>;
103 def v4f32: LoadAFormVec<v4f32>;
104 def v2f64: LoadAFormVec<v2f64>;
106 def r128: LoadAForm<GPRC>;
107 def r64: LoadAForm<R64C>;
108 def r32: LoadAForm<R32C>;
109 def f32: LoadAForm<R32FP>;
110 def f64: LoadAForm<R64FP>;
111 def r16: LoadAForm<R16C>;
112 def r8: LoadAForm<R8C>;
115 class LoadXFormVec<ValueType vectype>
116 : RRForm<0b00100011100, (outs VECREG:$rT), (ins memrr:$src),
119 [(set (vectype VECREG:$rT), (load xform_addr:$src))]>
122 class LoadXForm<RegisterClass rclass>
123 : RRForm<0b00100011100, (outs rclass:$rT), (ins memrr:$src),
126 [(set rclass:$rT, (load xform_addr:$src))]>
129 multiclass LoadXForms
131 def v16i8: LoadXFormVec<v16i8>;
132 def v8i16: LoadXFormVec<v8i16>;
133 def v4i32: LoadXFormVec<v4i32>;
134 def v2i64: LoadXFormVec<v2i64>;
135 def v4f32: LoadXFormVec<v4f32>;
136 def v2f64: LoadXFormVec<v2f64>;
138 def r128: LoadXForm<GPRC>;
139 def r64: LoadXForm<R64C>;
140 def r32: LoadXForm<R32C>;
141 def f32: LoadXForm<R32FP>;
142 def f64: LoadXForm<R64FP>;
143 def r16: LoadXForm<R16C>;
144 def r8: LoadXForm<R8C>;
147 defm LQA : LoadAForms;
148 defm LQD : LoadDForms;
149 defm LQX : LoadXForms;
151 /* Load quadword, PC relative: Not much use at this point in time.
152 Might be of use later for relocatable code. It's effectively the
153 same as LQA, but uses PC-relative addressing.
154 def LQR : RI16Form<0b111001100, (outs VECREG:$rT), (ins s16imm:$disp),
155 "lqr\t$rT, $disp", LoadStore,
156 [(set VECREG:$rT, (load iaddr:$disp))]>;
160 //===----------------------------------------------------------------------===//
162 //===----------------------------------------------------------------------===//
163 class StoreDFormVec<ValueType vectype>
164 : RI10Form<0b00100100, (outs), (ins VECREG:$rT, memri10:$src),
167 [(store (vectype VECREG:$rT), dform_addr:$src)]>
170 class StoreDForm<RegisterClass rclass>
171 : RI10Form<0b00100100, (outs), (ins rclass:$rT, memri10:$src),
174 [(store rclass:$rT, dform_addr:$src)]>
177 multiclass StoreDForms
179 def v16i8: StoreDFormVec<v16i8>;
180 def v8i16: StoreDFormVec<v8i16>;
181 def v4i32: StoreDFormVec<v4i32>;
182 def v2i64: StoreDFormVec<v2i64>;
183 def v4f32: StoreDFormVec<v4f32>;
184 def v2f64: StoreDFormVec<v2f64>;
186 def r128: StoreDForm<GPRC>;
187 def r64: StoreDForm<R64C>;
188 def r32: StoreDForm<R32C>;
189 def f32: StoreDForm<R32FP>;
190 def f64: StoreDForm<R64FP>;
191 def r16: StoreDForm<R16C>;
192 def r8: StoreDForm<R8C>;
195 class StoreAFormVec<ValueType vectype>
196 : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src),
199 [(store (vectype VECREG:$rT), aform_addr:$src)]>;
201 class StoreAForm<RegisterClass rclass>
202 : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src),
205 [(store rclass:$rT, aform_addr:$src)]>;
207 multiclass StoreAForms
209 def v16i8: StoreAFormVec<v16i8>;
210 def v8i16: StoreAFormVec<v8i16>;
211 def v4i32: StoreAFormVec<v4i32>;
212 def v2i64: StoreAFormVec<v2i64>;
213 def v4f32: StoreAFormVec<v4f32>;
214 def v2f64: StoreAFormVec<v2f64>;
216 def r128: StoreAForm<GPRC>;
217 def r64: StoreAForm<R64C>;
218 def r32: StoreAForm<R32C>;
219 def f32: StoreAForm<R32FP>;
220 def f64: StoreAForm<R64FP>;
221 def r16: StoreAForm<R16C>;
222 def r8: StoreAForm<R8C>;
225 class StoreXFormVec<ValueType vectype>
226 : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src),
229 [(store (vectype VECREG:$rT), xform_addr:$src)]>
232 class StoreXForm<RegisterClass rclass>
233 : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src),
236 [(store rclass:$rT, xform_addr:$src)]>
239 multiclass StoreXForms
241 def v16i8: StoreXFormVec<v16i8>;
242 def v8i16: StoreXFormVec<v8i16>;
243 def v4i32: StoreXFormVec<v4i32>;
244 def v2i64: StoreXFormVec<v2i64>;
245 def v4f32: StoreXFormVec<v4f32>;
246 def v2f64: StoreXFormVec<v2f64>;
248 def r128: StoreXForm<GPRC>;
249 def r64: StoreXForm<R64C>;
250 def r32: StoreXForm<R32C>;
251 def f32: StoreXForm<R32FP>;
252 def f64: StoreXForm<R64FP>;
253 def r16: StoreXForm<R16C>;
254 def r8: StoreXForm<R8C>;
257 defm STQD : StoreDForms;
258 defm STQA : StoreAForms;
259 defm STQX : StoreXForms;
261 /* Store quadword, PC relative: Not much use at this point in time. Might
262 be useful for relocatable code.
263 def STQR : RI16Form<0b111000100, (outs), (ins VECREG:$rT, s16imm:$disp),
264 "stqr\t$rT, $disp", LoadStore,
265 [(store VECREG:$rT, iaddr:$disp)]>;
268 //===----------------------------------------------------------------------===//
269 // Generate Controls for Insertion:
270 //===----------------------------------------------------------------------===//
272 def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins memri7:$src),
273 "cbd\t$rT, $src", ShuffleOp,
274 [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
276 def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src),
277 "cbx\t$rT, $src", ShuffleOp,
278 [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
280 def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins memri7:$src),
281 "chd\t$rT, $src", ShuffleOp,
282 [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
284 def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src),
285 "chx\t$rT, $src", ShuffleOp,
286 [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
288 def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins memri7:$src),
289 "cwd\t$rT, $src", ShuffleOp,
290 [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
292 def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
293 "cwx\t$rT, $src", ShuffleOp,
294 [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
296 def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins memri7:$src),
297 "cwd\t$rT, $src", ShuffleOp,
298 [(set (v4f32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
300 def CWXf32: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
301 "cwx\t$rT, $src", ShuffleOp,
302 [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
304 def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins memri7:$src),
305 "cdd\t$rT, $src", ShuffleOp,
306 [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
308 def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
309 "cdx\t$rT, $src", ShuffleOp,
310 [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
312 def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins memri7:$src),
313 "cdd\t$rT, $src", ShuffleOp,
314 [(set (v2f64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
316 def CDXf64: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
317 "cdx\t$rT, $src", ShuffleOp,
318 [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
320 //===----------------------------------------------------------------------===//
321 // Constant formation:
322 //===----------------------------------------------------------------------===//
325 RI16Form<0b110000010, (outs VECREG:$rT), (ins s16imm:$val),
326 "ilh\t$rT, $val", ImmLoad,
327 [(set (v8i16 VECREG:$rT), (v8i16 v8i16SExt16Imm:$val))]>;
330 RI16Form<0b110000010, (outs R16C:$rT), (ins s16imm:$val),
331 "ilh\t$rT, $val", ImmLoad,
332 [(set R16C:$rT, immSExt16:$val)]>;
334 // Cell SPU doesn't have a native 8-bit immediate load, but ILH works ("with
335 // the right constant")
337 RI16Form<0b110000010, (outs R8C:$rT), (ins s16imm_i8:$val),
338 "ilh\t$rT, $val", ImmLoad,
339 [(set R8C:$rT, immSExt8:$val)]>;
341 // IL does sign extension!
343 class ILInst<dag OOL, dag IOL, list<dag> pattern>:
344 RI16Form<0b100000010, OOL, IOL, "il\t$rT, $val",
347 class ILVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
348 ILInst<(outs VECREG:$rT), (ins immtype:$val),
349 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
351 class ILRegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
352 ILInst<(outs rclass:$rT), (ins immtype:$val),
353 [(set rclass:$rT, xform:$val)]>;
355 multiclass ImmediateLoad
357 def v2i64: ILVecInst<v2i64, s16imm_i64, v2i64SExt16Imm>;
358 def v4i32: ILVecInst<v4i32, s16imm_i32, v4i32SExt16Imm>;
360 // TODO: Need v2f64, v4f32
362 def r64: ILRegInst<R64C, s16imm_i64, immSExt16>;
363 def r32: ILRegInst<R32C, s16imm_i32, immSExt16>;
364 def f32: ILRegInst<R32FP, s16imm_f32, fpimmSExt16>;
365 def f64: ILRegInst<R64FP, s16imm_f64, fpimmSExt16>;
368 defm IL : ImmediateLoad;
370 class ILHUInst<dag OOL, dag IOL, list<dag> pattern>:
371 RI16Form<0b010000010, OOL, IOL, "ilhu\t$rT, $val",
374 class ILHUVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
375 ILHUInst<(outs VECREG:$rT), (ins immtype:$val),
376 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
378 class ILHURegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
379 ILHUInst<(outs rclass:$rT), (ins immtype:$val),
380 [(set rclass:$rT, xform:$val)]>;
382 multiclass ImmLoadHalfwordUpper
384 def v2i64: ILHUVecInst<v2i64, u16imm_i64, immILHUvec_i64>;
385 def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>;
387 def r64: ILHURegInst<R64C, u16imm_i64, hi16>;
388 def r32: ILHURegInst<R32C, u16imm_i32, hi16>;
390 // Loads the high portion of an address
391 def hi: ILHURegInst<R32C, symbolHi, hi16>;
393 // Used in custom lowering constant SFP loads:
394 def f32: ILHURegInst<R32FP, f16imm, hi16_f32>;
397 defm ILHU : ImmLoadHalfwordUpper;
399 // Immediate load address (can also be used to load 18-bit unsigned constants,
400 // see the zext 16->32 pattern)
402 class ILAInst<dag OOL, dag IOL, list<dag> pattern>:
403 RI18Form<0b1000010, OOL, IOL, "ila\t$rT, $val",
406 class ILAVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
407 ILAInst<(outs VECREG:$rT), (ins immtype:$val),
408 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
410 class ILARegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
411 ILAInst<(outs rclass:$rT), (ins immtype:$val),
412 [(set rclass:$rT, xform:$val)]>;
414 multiclass ImmLoadAddress
416 def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>;
417 def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>;
419 def r64: ILARegInst<R64C, u18imm_i64, imm18>;
420 def r32: ILARegInst<R32C, u18imm, imm18>;
421 def f32: ILARegInst<R32FP, f18imm, fpimm18>;
422 def f64: ILARegInst<R64FP, f18imm_f64, fpimm18>;
424 def lo: ILARegInst<R32C, symbolLo, imm18>;
426 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
430 defm ILA : ImmLoadAddress;
432 // Immediate OR, Halfword Lower: The "other" part of loading large constants
433 // into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...>
434 // Note that these are really two operand instructions, but they're encoded
435 // as three operands with the first two arguments tied-to each other.
437 class IOHLInst<dag OOL, dag IOL, list<dag> pattern>:
438 RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val",
440 RegConstraint<"$rS = $rT">,
443 class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>:
444 IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val),
447 class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>:
448 IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val),
451 multiclass ImmOrHalfwordLower
453 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
454 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
456 def r32: IOHLRegInst<R32C, i32imm>;
457 def f32: IOHLRegInst<R32FP, f32imm>;
459 def lo: IOHLRegInst<R32C, symbolLo>;
462 defm IOHL: ImmOrHalfwordLower;
464 // Form select mask for bytes using immediate, used in conjunction with the
467 class FSMBIVec<ValueType vectype>:
468 RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val),
471 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
473 multiclass FormSelectMaskBytesImm
475 def v16i8: FSMBIVec<v16i8>;
476 def v8i16: FSMBIVec<v8i16>;
477 def v4i32: FSMBIVec<v4i32>;
478 def v2i64: FSMBIVec<v2i64>;
481 defm FSMBI : FormSelectMaskBytesImm;
483 // fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits
485 RRForm_1<0b01101101100, (outs VECREG:$rT), (ins R16C:$rA),
486 "fsmb\t$rT, $rA", SelectOp,
487 [(set (v16i8 VECREG:$rT), (SPUselmask R16C:$rA))]>;
489 // fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is
490 // only 8-bits wide (even though it's input as 16-bits here)
492 RRForm_1<0b10101101100, (outs VECREG:$rT), (ins R16C:$rA),
493 "fsmh\t$rT, $rA", SelectOp,
494 [(set (v8i16 VECREG:$rT), (SPUselmask R16C:$rA))]>;
496 // fsm: Form select mask for words. Like the other fsm* instructions,
497 // only the lower 4 bits of $rA are significant.
498 class FSMInst<ValueType vectype, RegisterClass rclass>:
499 RRForm_1<0b00101101100, (outs VECREG:$rT), (ins rclass:$rA),
502 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
504 multiclass FormSelectMaskWord {
505 def r32 : FSMInst<v4i32, R32C>;
506 def r16 : FSMInst<v4i32, R16C>;
509 defm FSM : FormSelectMaskWord;
511 // Special case when used for i64 math operations
512 multiclass FormSelectMaskWord64 {
513 def r32 : FSMInst<v2i64, R32C>;
514 def r16 : FSMInst<v2i64, R16C>;
517 defm FSM64 : FormSelectMaskWord64;
519 //===----------------------------------------------------------------------===//
520 // Integer and Logical Operations:
521 //===----------------------------------------------------------------------===//
524 RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
525 "ah\t$rT, $rA, $rB", IntegerOp,
526 [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>;
528 def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)),
529 (AHv8i16 VECREG:$rA, VECREG:$rB)>;
532 RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
533 "ah\t$rT, $rA, $rB", IntegerOp,
534 [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>;
537 RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
538 "ahi\t$rT, $rA, $val", IntegerOp,
539 [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA),
540 v8i16SExt10Imm:$val))]>;
543 RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
544 "ahi\t$rT, $rA, $val", IntegerOp,
545 [(set R16C:$rT, (add R16C:$rA, v8i16SExt10Imm:$val))]>;
548 RRForm<0b00000011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
549 "a\t$rT, $rA, $rB", IntegerOp,
550 [(set (v4i32 VECREG:$rT), (add (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
552 def : Pat<(add (v16i8 VECREG:$rA), (v16i8 VECREG:$rB)),
553 (Avec VECREG:$rA, VECREG:$rB)>;
556 RRForm<0b00000011000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
557 "a\t$rT, $rA, $rB", IntegerOp,
558 [(set R32C:$rT, (add R32C:$rA, R32C:$rB))]>;
561 RRForm<0b00000011000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
562 "a\t$rT, $rA, $rB", IntegerOp,
566 RI10Form<0b00111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
567 "ai\t$rT, $rA, $val", IntegerOp,
568 [(set (v4i32 VECREG:$rT), (add (v4i32 VECREG:$rA),
569 v4i32SExt10Imm:$val))]>;
572 RI10Form<0b00111000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
573 "ai\t$rT, $rA, $val", IntegerOp,
574 [(set R32C:$rT, (add R32C:$rA, i32ImmSExt10:$val))]>;
577 RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
578 "sfh\t$rT, $rA, $rB", IntegerOp,
579 [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA),
580 (v8i16 VECREG:$rB)))]>;
583 RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
584 "sfh\t$rT, $rA, $rB", IntegerOp,
585 [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>;
588 RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
589 "sfhi\t$rT, $rA, $val", IntegerOp,
590 [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val,
591 (v8i16 VECREG:$rA)))]>;
593 def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
594 "sfhi\t$rT, $rA, $val", IntegerOp,
595 [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>;
597 def SFvec : RRForm<0b00000010000, (outs VECREG:$rT),
598 (ins VECREG:$rA, VECREG:$rB),
599 "sf\t$rT, $rA, $rB", IntegerOp,
600 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
602 def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
603 "sf\t$rT, $rA, $rB", IntegerOp,
604 [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>;
607 RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
608 "sfi\t$rT, $rA, $val", IntegerOp,
609 [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val,
610 (v4i32 VECREG:$rA)))]>;
612 def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT),
613 (ins R32C:$rA, s10imm_i32:$val),
614 "sfi\t$rT, $rA, $val", IntegerOp,
615 [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>;
617 // ADDX: only available in vector form, doesn't match a pattern.
618 class ADDXInst<dag OOL, dag IOL, list<dag> pattern>:
619 RRForm<0b00000010110, OOL, IOL,
620 "addx\t$rT, $rA, $rB",
623 class ADDXVecInst<ValueType vectype>:
624 ADDXInst<(outs VECREG:$rT),
625 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
626 [(set (vectype VECREG:$rT),
627 (SPUaddx (vectype VECREG:$rA), (vectype VECREG:$rB),
628 (vectype VECREG:$rCarry)))]>,
629 RegConstraint<"$rCarry = $rT">,
632 class ADDXRegInst<RegisterClass rclass>:
633 ADDXInst<(outs rclass:$rT),
634 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
636 (SPUaddx rclass:$rA, rclass:$rB, rclass:$rCarry))]>,
637 RegConstraint<"$rCarry = $rT">,
640 multiclass AddExtended {
641 def v2i64 : ADDXVecInst<v2i64>;
642 def v4i32 : ADDXVecInst<v4i32>;
643 def r64 : ADDXRegInst<R64C>;
644 def r32 : ADDXRegInst<R32C>;
647 defm ADDX : AddExtended;
649 // CG: Generate carry for add
650 class CGInst<dag OOL, dag IOL, list<dag> pattern>:
651 RRForm<0b01000011000, OOL, IOL,
655 class CGVecInst<ValueType vectype>:
656 CGInst<(outs VECREG:$rT),
657 (ins VECREG:$rA, VECREG:$rB),
658 [(set (vectype VECREG:$rT),
659 (SPUcarry_gen (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
661 class CGRegInst<RegisterClass rclass>:
662 CGInst<(outs rclass:$rT),
663 (ins rclass:$rA, rclass:$rB),
665 (SPUcarry_gen rclass:$rA, rclass:$rB))]>;
667 multiclass CarryGenerate {
668 def v2i64 : CGVecInst<v2i64>;
669 def v4i32 : CGVecInst<v4i32>;
670 def r64 : CGRegInst<R64C>;
671 def r32 : CGRegInst<R32C>;
674 defm CG : CarryGenerate;
676 // SFX: Subract from, extended. This is used in conjunction with BG to subtract
677 // with carry (borrow, in this case)
678 class SFXInst<dag OOL, dag IOL, list<dag> pattern>:
679 RRForm<0b10000010110, OOL, IOL,
680 "sfx\t$rT, $rA, $rB",
683 class SFXVecInst<ValueType vectype>:
684 SFXInst<(outs VECREG:$rT),
685 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
686 [(set (vectype VECREG:$rT),
687 (SPUsubx (vectype VECREG:$rA), (vectype VECREG:$rB),
688 (vectype VECREG:$rCarry)))]>,
689 RegConstraint<"$rCarry = $rT">,
692 class SFXRegInst<RegisterClass rclass>:
693 SFXInst<(outs rclass:$rT),
694 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
696 (SPUsubx rclass:$rA, rclass:$rB, rclass:$rCarry))]>,
697 RegConstraint<"$rCarry = $rT">,
700 multiclass SubtractExtended {
701 def v2i64 : SFXVecInst<v2i64>;
702 def v4i32 : SFXVecInst<v4i32>;
703 def r64 : SFXRegInst<R64C>;
704 def r32 : SFXRegInst<R32C>;
707 defm SFX : SubtractExtended;
709 // BG: only available in vector form, doesn't match a pattern.
710 class BGInst<dag OOL, dag IOL, list<dag> pattern>:
711 RRForm<0b01000010000, OOL, IOL,
715 class BGVecInst<ValueType vectype>:
716 BGInst<(outs VECREG:$rT),
717 (ins VECREG:$rA, VECREG:$rB),
718 [(set (vectype VECREG:$rT),
719 (SPUborrow_gen (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
721 class BGRegInst<RegisterClass rclass>:
722 BGInst<(outs rclass:$rT),
723 (ins rclass:$rA, rclass:$rB),
725 (SPUborrow_gen rclass:$rA, rclass:$rB))]>;
727 multiclass BorrowGenerate {
728 def v4i32 : BGVecInst<v4i32>;
729 def v2i64 : BGVecInst<v2i64>;
730 def r64 : BGRegInst<R64C>;
731 def r32 : BGRegInst<R32C>;
734 defm BG : BorrowGenerate;
736 // BGX: Borrow generate, extended.
738 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
740 "bgx\t$rT, $rA, $rB", IntegerOp,
742 RegConstraint<"$rCarry = $rT">,
745 // Halfword multiply variants:
746 // N.B: These can be used to build up larger quantities (16x16 -> 32)
749 RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
750 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
751 [(set (v8i16 VECREG:$rT), (SPUmpy_v8i16 (v8i16 VECREG:$rA),
752 (v8i16 VECREG:$rB)))]>;
755 RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
756 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
757 [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>;
760 RRForm<0b00110011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
761 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
762 [(set (v4i32 VECREG:$rT),
763 (SPUmpyu_v4i32 (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
766 RRForm<0b00110011110, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
767 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
768 [(set R32C:$rT, (mul (zext R16C:$rA),
772 RRForm<0b00110011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
773 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
774 [(set R32C:$rT, (SPUmpyu_i32 R32C:$rA, R32C:$rB))]>;
776 // mpyi: multiply 16 x s10imm -> 32 result (custom lowering for 32 bit result,
777 // this only produces the lower 16 bits)
779 RI10Form<0b00101110, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
780 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
781 [(set (v8i16 VECREG:$rT), (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
784 RI10Form<0b00101110, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
785 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
786 [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>;
788 // mpyui: same issues as other multiplies, plus, this doesn't match a
789 // pattern... but may be used during target DAG selection or lowering
791 RI10Form<0b10101110, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
792 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
796 RI10Form<0b10101110, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
797 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
800 // mpya: 16 x 16 + 16 -> 32 bit result
802 RRRForm<0b0011, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
803 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
804 [(set (v4i32 VECREG:$rT), (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA),
805 (v8i16 VECREG:$rB)))),
806 (v4i32 VECREG:$rC)))]>;
809 RRRForm<0b0011, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
810 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
811 [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
814 def : Pat<(add (mul (sext R16C:$rA), (sext R16C:$rB)), R32C:$rC),
815 (MPYAr32 R16C:$rA, R16C:$rB, R32C:$rC)>;
817 def MPYAr32_sextinreg:
818 RRRForm<0b0011, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC),
819 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
820 [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16),
821 (sext_inreg R32C:$rB, i16)),
825 // RRRForm<0b0011, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
826 // "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
827 // [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
830 // mpyh: multiply high, used to synthesize 32-bit multiplies
832 RRForm<0b10100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
833 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
834 [(set (v4i32 VECREG:$rT),
835 (SPUmpyh_v4i32 (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
838 RRForm<0b10100011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
839 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
840 [(set R32C:$rT, (SPUmpyh_i32 R32C:$rA, R32C:$rB))]>;
842 // mpys: multiply high and shift right (returns the top half of
843 // a 16-bit multiply, sign extended to 32 bits.)
845 RRForm<0b11100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
846 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
850 RRForm<0b11100011110, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
851 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
854 // mpyhh: multiply high-high (returns the 32-bit result from multiplying
855 // the top 16 bits of the $rA, $rB)
857 RRForm<0b01100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
858 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
859 [(set (v8i16 VECREG:$rT),
860 (SPUmpyhh_v8i16 (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)))]>;
863 RRForm<0b01100011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
864 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
867 // mpyhha: Multiply high-high, add to $rT:
869 RRForm<0b01100010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
870 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
874 RRForm<0b01100010110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
875 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
878 // mpyhhu: Multiply high-high, unsigned
880 RRForm<0b01110011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
881 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
885 RRForm<0b01110011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
886 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
889 // mpyhhau: Multiply high-high, unsigned
891 RRForm<0b01110010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
892 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
896 RRForm<0b01110010110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
897 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
900 // clz: Count leading zeroes
902 RRForm_1<0b10100101010, (outs VECREG:$rT), (ins VECREG:$rA),
903 "clz\t$rT, $rA", IntegerOp,
907 RRForm_1<0b10100101010, (outs R32C:$rT), (ins R32C:$rA),
908 "clz\t$rT, $rA", IntegerOp,
909 [(set R32C:$rT, (ctlz R32C:$rA))]>;
911 // cntb: Count ones in bytes (aka "population count")
912 // NOTE: This instruction is really a vector instruction, but the custom
913 // lowering code uses it in unorthodox ways to support CTPOP for other
916 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
917 "cntb\t$rT, $rA", IntegerOp,
918 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
921 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
922 "cntb\t$rT, $rA", IntegerOp,
923 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
926 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
927 "cntb\t$rT, $rA", IntegerOp,
928 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
930 // gbb: Gather all low order bits from each byte in $rA into a single 16-bit
931 // quantity stored into $rT
933 RRForm_1<0b01001101100, (outs R16C:$rT), (ins VECREG:$rA),
934 "gbb\t$rT, $rA", GatherOp,
937 // gbh: Gather all low order bits from each halfword in $rA into a single
938 // 8-bit quantity stored in $rT
940 RRForm_1<0b10001101100, (outs R16C:$rT), (ins VECREG:$rA),
941 "gbh\t$rT, $rA", GatherOp,
944 // gb: Gather all low order bits from each word in $rA into a single
945 // 4-bit quantity stored in $rT
947 RRForm_1<0b00001101100, (outs R16C:$rT), (ins VECREG:$rA),
948 "gb\t$rT, $rA", GatherOp,
951 // avgb: average bytes
953 RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
954 "avgb\t$rT, $rA, $rB", ByteOp,
957 // absdb: absolute difference of bytes
959 RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
960 "absdb\t$rT, $rA, $rB", ByteOp,
963 // sumb: sum bytes into halfwords
965 RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
966 "sumb\t$rT, $rA, $rB", ByteOp,
969 // Sign extension operations:
970 class XSBHInst<dag OOL, dag IOL, list<dag> pattern>:
971 RRForm_1<0b01101101010, OOL, IOL,
972 "xsbh\t$rDst, $rSrc",
975 class XSBHVecInst<ValueType vectype>:
976 XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
977 [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>;
979 class XSBHRegInst<RegisterClass rclass>:
980 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
981 [(set rclass:$rDst, (sext_inreg rclass:$rSrc, i8))]>;
983 multiclass ExtendByteHalfword {
984 def v16i8: XSBHVecInst<v8i16>;
985 def r16: XSBHRegInst<R16C>;
987 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
988 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
989 // pattern below). Intentionally doesn't match a pattern because we want the
990 // sext 8->32 pattern to do the work for us, namely because we need the extra
992 def r32: XSBHRegInst<R32C>;
995 defm XSBH : ExtendByteHalfword;
997 // Sign-extend, but take an 8-bit register to a 16-bit register (not done as
1000 XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1001 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1003 // Sign extend halfwords to words:
1005 RRForm_1<0b01101101010, (outs VECREG:$rDest), (ins VECREG:$rSrc),
1006 "xshw\t$rDest, $rSrc", IntegerOp,
1007 [(set (v4i32 VECREG:$rDest), (sext (v8i16 VECREG:$rSrc)))]>;
1010 RRForm_1<0b01101101010, (outs R32C:$rDst), (ins R32C:$rSrc),
1011 "xshw\t$rDst, $rSrc", IntegerOp,
1012 [(set R32C:$rDst, (sext_inreg R32C:$rSrc, i16))]>;
1015 RRForm_1<0b01101101010, (outs R32C:$rDst), (ins R16C:$rSrc),
1016 "xshw\t$rDst, $rSrc", IntegerOp,
1017 [(set R32C:$rDst, (sext R16C:$rSrc))]>;
1020 RRForm_1<0b01100101010, (outs VECREG:$rDst), (ins VECREG:$rSrc),
1021 "xswd\t$rDst, $rSrc", IntegerOp,
1022 [(set (v2i64 VECREG:$rDst), (sext (v4i32 VECREG:$rSrc)))]>;
1025 RRForm_1<0b01100101010, (outs R64C:$rDst), (ins R64C:$rSrc),
1026 "xswd\t$rDst, $rSrc", IntegerOp,
1027 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1030 RRForm_1<0b01100101010, (outs R64C:$rDst), (ins R32C:$rSrc),
1031 "xswd\t$rDst, $rSrc", IntegerOp,
1032 [(set R64C:$rDst, (SPUsext32_to_64 R32C:$rSrc))]>;
1034 def : Pat<(sext R32C:$inp),
1035 (XSWDr32 R32C:$inp)>;
1039 class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1040 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1041 IntegerOp, pattern>;
1043 class ANDVecInst<ValueType vectype>:
1044 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1045 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1046 (vectype VECREG:$rB)))]>;
1048 class ANDRegInst<RegisterClass rclass>:
1049 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1050 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1052 multiclass BitwiseAnd
1054 def v16i8: ANDVecInst<v16i8>;
1055 def v8i16: ANDVecInst<v8i16>;
1056 def v4i32: ANDVecInst<v4i32>;
1057 def v2i64: ANDVecInst<v2i64>;
1059 def r128: ANDRegInst<GPRC>;
1060 def r64: ANDRegInst<R64C>;
1061 def r32: ANDRegInst<R32C>;
1062 def r16: ANDRegInst<R16C>;
1063 def r8: ANDRegInst<R8C>;
1065 //===---------------------------------------------
1066 // Special instructions to perform the fabs instruction
1067 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1068 [/* Intentionally does not match a pattern */]>;
1070 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1071 [/* Intentionally does not match a pattern */]>;
1073 // Could use v4i32, but won't for clarity
1074 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1075 [/* Intentionally does not match a pattern */]>;
1077 //===---------------------------------------------
1079 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1080 // quantities -- see 16->32 zext pattern.
1082 // This pattern is somewhat artificial, since it might match some
1083 // compiler generated pattern but it is unlikely to do so.
1085 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1086 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1089 defm AND : BitwiseAnd;
1091 // N.B.: vnot_conv is one of those special target selection pattern fragments,
1092 // in which we expect there to be a bit_convert on the constant. Bear in mind
1093 // that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1094 // constant -1 vector.)
1096 class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1097 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1098 IntegerOp, pattern>;
1100 class ANDCVecInst<ValueType vectype>:
1101 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1102 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1103 (vnot (vectype VECREG:$rB))))]>;
1105 class ANDCRegInst<RegisterClass rclass>:
1106 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1107 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
1109 multiclass AndComplement
1111 def v16i8: ANDCVecInst<v16i8>;
1112 def v8i16: ANDCVecInst<v8i16>;
1113 def v4i32: ANDCVecInst<v4i32>;
1114 def v2i64: ANDCVecInst<v2i64>;
1116 def r128: ANDCRegInst<GPRC>;
1117 def r64: ANDCRegInst<R64C>;
1118 def r32: ANDCRegInst<R32C>;
1119 def r16: ANDCRegInst<R16C>;
1120 def r8: ANDCRegInst<R8C>;
1123 defm ANDC : AndComplement;
1125 class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1126 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
1127 IntegerOp, pattern>;
1129 multiclass AndByteImm
1131 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1132 [(set (v16i8 VECREG:$rT),
1133 (and (v16i8 VECREG:$rA),
1134 (v16i8 v16i8U8Imm:$val)))]>;
1136 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1137 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1140 defm ANDBI : AndByteImm;
1142 class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1143 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
1144 IntegerOp, pattern>;
1146 multiclass AndHalfwordImm
1148 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1149 [(set (v8i16 VECREG:$rT),
1150 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
1152 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1153 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
1155 // Zero-extend i8 to i16:
1156 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1157 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1160 defm ANDHI : AndHalfwordImm;
1162 class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1163 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1164 IntegerOp, pattern>;
1166 multiclass AndWordImm
1168 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1169 [(set (v4i32 VECREG:$rT),
1170 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1172 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1173 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1175 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1177 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1179 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1181 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1182 // zext 16->32 pattern below.
1184 // Note that this pattern is somewhat artificial, since it might match
1185 // something the compiler generates but is unlikely to occur in practice.
1186 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1188 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1191 defm ANDI : AndWordImm;
1193 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1194 // Bitwise OR group:
1195 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1197 // Bitwise "or" (N.B.: These are also register-register copy instructions...)
1198 class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1199 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1200 IntegerOp, pattern>;
1202 class ORVecInst<ValueType vectype>:
1203 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1204 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1205 (vectype VECREG:$rB)))]>;
1207 class ORRegInst<RegisterClass rclass>:
1208 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1209 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
1211 class ORPromoteScalar<RegisterClass rclass>:
1212 ORInst<(outs VECREG:$rT), (ins rclass:$rA, rclass:$rB),
1213 [/* no pattern */]>;
1215 class ORExtractElt<RegisterClass rclass>:
1216 ORInst<(outs rclass:$rT), (ins VECREG:$rA, VECREG:$rB),
1217 [/* no pattern */]>;
1219 multiclass BitwiseOr
1221 def v16i8: ORVecInst<v16i8>;
1222 def v8i16: ORVecInst<v8i16>;
1223 def v4i32: ORVecInst<v4i32>;
1224 def v2i64: ORVecInst<v2i64>;
1226 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1227 [(set (v4f32 VECREG:$rT),
1228 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1229 (v4i32 VECREG:$rB)))))]>;
1231 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1232 [(set (v2f64 VECREG:$rT),
1233 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1234 (v2i64 VECREG:$rB)))))]>;
1236 def r64: ORRegInst<R64C>;
1237 def r32: ORRegInst<R32C>;
1238 def r16: ORRegInst<R16C>;
1239 def r8: ORRegInst<R8C>;
1241 // OR instructions used to copy f32 and f64 registers.
1242 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1243 [/* no pattern */]>;
1245 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1246 [/* no pattern */]>;
1248 // scalar->vector promotion:
1249 def v16i8_i8: ORPromoteScalar<R8C>;
1250 def v8i16_i16: ORPromoteScalar<R16C>;
1251 def v4i32_i32: ORPromoteScalar<R32C>;
1252 def v2i64_i64: ORPromoteScalar<R64C>;
1253 def v4f32_f32: ORPromoteScalar<R32FP>;
1254 def v2f64_f64: ORPromoteScalar<R64FP>;
1256 // extract element 0:
1257 def i8_v16i8: ORExtractElt<R8C>;
1258 def i16_v8i16: ORExtractElt<R16C>;
1259 def i32_v4i32: ORExtractElt<R32C>;
1260 def i64_v2i64: ORExtractElt<R64C>;
1261 def f32_v4f32: ORExtractElt<R32FP>;
1262 def f64_v2f64: ORExtractElt<R64FP>;
1265 defm OR : BitwiseOr;
1267 // scalar->vector promotion patterns:
1268 def : Pat<(v16i8 (SPUpromote_scalar R8C:$rA)),
1269 (ORv16i8_i8 R8C:$rA, R8C:$rA)>;
1271 def : Pat<(v8i16 (SPUpromote_scalar R16C:$rA)),
1272 (ORv8i16_i16 R16C:$rA, R16C:$rA)>;
1274 def : Pat<(v4i32 (SPUpromote_scalar R32C:$rA)),
1275 (ORv4i32_i32 R32C:$rA, R32C:$rA)>;
1277 def : Pat<(v2i64 (SPUpromote_scalar R64C:$rA)),
1278 (ORv2i64_i64 R64C:$rA, R64C:$rA)>;
1280 def : Pat<(v4f32 (SPUpromote_scalar R32FP:$rA)),
1281 (ORv4f32_f32 R32FP:$rA, R32FP:$rA)>;
1283 def : Pat<(v2f64 (SPUpromote_scalar R64FP:$rA)),
1284 (ORv2f64_f64 R64FP:$rA, R64FP:$rA)>;
1286 // ORi*_v*: Used to extract vector element 0 (the preferred slot)
1288 def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
1289 (ORi8_v16i8 VECREG:$rA, VECREG:$rA)>;
1291 def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
1292 (ORi16_v8i16 VECREG:$rA, VECREG:$rA)>;
1294 def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
1295 (ORi32_v4i32 VECREG:$rA, VECREG:$rA)>;
1297 def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
1298 (ORi64_v2i64 VECREG:$rA, VECREG:$rA)>;
1300 def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
1301 (ORf32_v4f32 VECREG:$rA, VECREG:$rA)>;
1303 def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
1304 (ORf64_v2f64 VECREG:$rA, VECREG:$rA)>;
1306 // ORC: Bitwise "or" with complement (c = a | ~b)
1308 class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1309 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1310 IntegerOp, pattern>;
1312 class ORCVecInst<ValueType vectype>:
1313 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1314 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1315 (vnot (vectype VECREG:$rB))))]>;
1317 class ORCRegInst<RegisterClass rclass>:
1318 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1319 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
1321 multiclass BitwiseOrComplement
1323 def v16i8: ORCVecInst<v16i8>;
1324 def v8i16: ORCVecInst<v8i16>;
1325 def v4i32: ORCVecInst<v4i32>;
1326 def v2i64: ORCVecInst<v2i64>;
1328 def r64: ORCRegInst<R64C>;
1329 def r32: ORCRegInst<R32C>;
1330 def r16: ORCRegInst<R16C>;
1331 def r8: ORCRegInst<R8C>;
1334 defm ORC : BitwiseOrComplement;
1336 // OR byte immediate
1337 class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1338 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1339 IntegerOp, pattern>;
1341 class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1342 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1343 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1344 (vectype immpred:$val)))]>;
1346 multiclass BitwiseOrByteImm
1348 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1350 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1351 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1354 defm ORBI : BitwiseOrByteImm;
1356 // OR halfword immediate
1357 class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1358 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1359 IntegerOp, pattern>;
1361 class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1362 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1363 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1366 multiclass BitwiseOrHalfwordImm
1368 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1370 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1371 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1373 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1374 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1375 [(set R16C:$rT, (or (anyext R8C:$rA),
1376 i16ImmSExt10:$val))]>;
1379 defm ORHI : BitwiseOrHalfwordImm;
1381 class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1382 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1383 IntegerOp, pattern>;
1385 class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1386 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1387 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1390 // Bitwise "or" with immediate
1391 multiclass BitwiseOrImm
1393 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
1395 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1396 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
1398 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1399 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1400 // infra "anyext 16->32" pattern.)
1401 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1402 [(set R32C:$rT, (or (anyext R16C:$rA),
1403 i32ImmSExt10:$val))]>;
1405 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1406 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1407 // infra "anyext 16->32" pattern.)
1408 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1409 [(set R32C:$rT, (or (anyext R8C:$rA),
1410 i32ImmSExt10:$val))]>;
1413 defm ORI : BitwiseOrImm;
1415 // ORX: "or" across the vector: or's $rA's word slots leaving the result in
1416 // $rT[0], slots 1-3 are zeroed.
1418 // FIXME: Needs to match an intrinsic pattern.
1420 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1421 "orx\t$rT, $rA, $rB", IntegerOp,
1426 class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1427 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1428 IntegerOp, pattern>;
1430 class XORVecInst<ValueType vectype>:
1431 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1432 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1433 (vectype VECREG:$rB)))]>;
1435 class XORRegInst<RegisterClass rclass>:
1436 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1437 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1439 multiclass BitwiseExclusiveOr
1441 def v16i8: XORVecInst<v16i8>;
1442 def v8i16: XORVecInst<v8i16>;
1443 def v4i32: XORVecInst<v4i32>;
1444 def v2i64: XORVecInst<v2i64>;
1446 def r128: XORRegInst<GPRC>;
1447 def r64: XORRegInst<R64C>;
1448 def r32: XORRegInst<R32C>;
1449 def r16: XORRegInst<R16C>;
1450 def r8: XORRegInst<R8C>;
1452 // Special forms for floating point instructions.
1453 // fneg and fabs require bitwise logical ops to manipulate the sign bit.
1455 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1456 [/* no pattern */]>;
1458 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1459 [/* no pattern */]>;
1461 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1462 [/* no pattern, see fneg{32,64} */]>;
1465 defm XOR : BitwiseExclusiveOr;
1467 //==----------------------------------------------------------
1469 class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1470 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1471 IntegerOp, pattern>;
1473 multiclass XorByteImm
1476 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1477 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1480 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1481 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1484 defm XORBI : XorByteImm;
1487 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1488 "xorhi\t$rT, $rA, $val", IntegerOp,
1489 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1490 v8i16SExt10Imm:$val))]>;
1493 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1494 "xorhi\t$rT, $rA, $val", IntegerOp,
1495 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1498 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
1499 "xori\t$rT, $rA, $val", IntegerOp,
1500 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1501 v4i32SExt10Imm:$val))]>;
1504 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1505 "xori\t$rT, $rA, $val", IntegerOp,
1506 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1510 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1511 "nand\t$rT, $rA, $rB", IntegerOp,
1512 [(set (v16i8 VECREG:$rT), (vnot (and (v16i8 VECREG:$rA),
1513 (v16i8 VECREG:$rB))))]>;
1516 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1517 "nand\t$rT, $rA, $rB", IntegerOp,
1518 [(set (v8i16 VECREG:$rT), (vnot (and (v8i16 VECREG:$rA),
1519 (v8i16 VECREG:$rB))))]>;
1522 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1523 "nand\t$rT, $rA, $rB", IntegerOp,
1524 [(set (v4i32 VECREG:$rT), (vnot (and (v4i32 VECREG:$rA),
1525 (v4i32 VECREG:$rB))))]>;
1528 RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1529 "nand\t$rT, $rA, $rB", IntegerOp,
1530 [(set R32C:$rT, (not (and R32C:$rA, R32C:$rB)))]>;
1533 RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1534 "nand\t$rT, $rA, $rB", IntegerOp,
1535 [(set R16C:$rT, (not (and R16C:$rA, R16C:$rB)))]>;
1538 RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
1539 "nand\t$rT, $rA, $rB", IntegerOp,
1540 [(set R8C:$rT, (not (and R8C:$rA, R8C:$rB)))]>;
1544 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1545 "nor\t$rT, $rA, $rB", IntegerOp,
1546 [(set (v16i8 VECREG:$rT), (vnot (or (v16i8 VECREG:$rA),
1547 (v16i8 VECREG:$rB))))]>;
1550 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1551 "nor\t$rT, $rA, $rB", IntegerOp,
1552 [(set (v8i16 VECREG:$rT), (vnot (or (v8i16 VECREG:$rA),
1553 (v8i16 VECREG:$rB))))]>;
1556 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1557 "nor\t$rT, $rA, $rB", IntegerOp,
1558 [(set (v4i32 VECREG:$rT), (vnot (or (v4i32 VECREG:$rA),
1559 (v4i32 VECREG:$rB))))]>;
1562 RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1563 "nor\t$rT, $rA, $rB", IntegerOp,
1564 [(set R32C:$rT, (not (or R32C:$rA, R32C:$rB)))]>;
1567 RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1568 "nor\t$rT, $rA, $rB", IntegerOp,
1569 [(set R16C:$rT, (not (or R16C:$rA, R16C:$rB)))]>;
1572 RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
1573 "nor\t$rT, $rA, $rB", IntegerOp,
1574 [(set R8C:$rT, (not (or R8C:$rA, R8C:$rB)))]>;
1577 class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1578 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1579 IntegerOp, pattern>;
1581 class SELBVecInst<ValueType vectype>:
1582 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1583 [(set (vectype VECREG:$rT),
1584 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
1585 (and (vnot (vectype VECREG:$rC)),
1586 (vectype VECREG:$rA))))]>;
1588 class SELBRegInst<RegisterClass rclass>:
1589 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1591 (or (and rclass:$rA, rclass:$rC),
1592 (and rclass:$rB, (not rclass:$rC))))]>;
1594 multiclass SelectBits
1596 def v16i8: SELBVecInst<v16i8>;
1597 def v8i16: SELBVecInst<v8i16>;
1598 def v4i32: SELBVecInst<v4i32>;
1599 def v2i64: SELBVecInst<v2i64>;
1601 def r128: SELBRegInst<GPRC>;
1602 def r64: SELBRegInst<R64C>;
1603 def r32: SELBRegInst<R32C>;
1604 def r16: SELBRegInst<R16C>;
1605 def r8: SELBRegInst<R8C>;
1608 defm SELB : SelectBits;
1610 class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
1611 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1612 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
1614 def : SPUselbPatVec<v16i8, SELBv16i8>;
1615 def : SPUselbPatVec<v8i16, SELBv8i16>;
1616 def : SPUselbPatVec<v4i32, SELBv4i32>;
1617 def : SPUselbPatVec<v2i64, SELBv2i64>;
1619 class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1620 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1621 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1623 def : SPUselbPatReg<R8C, SELBr8>;
1624 def : SPUselbPatReg<R16C, SELBr16>;
1625 def : SPUselbPatReg<R32C, SELBr32>;
1626 def : SPUselbPatReg<R64C, SELBr64>;
1628 class SelectConditional<RegisterClass rclass, SPUInstr inst>:
1629 Pat<(select rclass:$rCond, rclass:$rTrue, rclass:$rFalse),
1630 (inst rclass:$rFalse, rclass:$rTrue, rclass:$rCond)>;
1632 def : SelectConditional<R32C, SELBr32>;
1633 def : SelectConditional<R16C, SELBr16>;
1634 def : SelectConditional<R8C, SELBr8>;
1636 // EQV: Equivalence (1 for each same bit, otherwise 0)
1638 // Note: There are a lot of ways to match this bit operator and these patterns
1639 // attempt to be as exhaustive as possible.
1641 class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
1642 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
1643 IntegerOp, pattern>;
1645 class EQVVecInst<ValueType vectype>:
1646 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1647 [(set (vectype VECREG:$rT),
1648 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
1649 (and (vnot (vectype VECREG:$rA)),
1650 (vnot (vectype VECREG:$rB)))))]>;
1652 class EQVRegInst<RegisterClass rclass>:
1653 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1654 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
1655 (and (not rclass:$rA), (not rclass:$rB))))]>;
1657 class EQVVecPattern1<ValueType vectype>:
1658 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1659 [(set (vectype VECREG:$rT),
1660 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
1662 class EQVRegPattern1<RegisterClass rclass>:
1663 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1664 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
1666 class EQVVecPattern2<ValueType vectype>:
1667 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1668 [(set (vectype VECREG:$rT),
1669 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
1670 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
1672 class EQVRegPattern2<RegisterClass rclass>:
1673 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1675 (or (and rclass:$rA, rclass:$rB),
1676 (not (or rclass:$rA, rclass:$rB))))]>;
1678 class EQVVecPattern3<ValueType vectype>:
1679 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1680 [(set (vectype VECREG:$rT),
1681 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
1683 class EQVRegPattern3<RegisterClass rclass>:
1684 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1685 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
1687 multiclass BitEquivalence
1689 def v16i8: EQVVecInst<v16i8>;
1690 def v8i16: EQVVecInst<v8i16>;
1691 def v4i32: EQVVecInst<v4i32>;
1692 def v2i64: EQVVecInst<v2i64>;
1694 def v16i8_1: EQVVecPattern1<v16i8>;
1695 def v8i16_1: EQVVecPattern1<v8i16>;
1696 def v4i32_1: EQVVecPattern1<v4i32>;
1697 def v2i64_1: EQVVecPattern1<v2i64>;
1699 def v16i8_2: EQVVecPattern2<v16i8>;
1700 def v8i16_2: EQVVecPattern2<v8i16>;
1701 def v4i32_2: EQVVecPattern2<v4i32>;
1702 def v2i64_2: EQVVecPattern2<v2i64>;
1704 def v16i8_3: EQVVecPattern3<v16i8>;
1705 def v8i16_3: EQVVecPattern3<v8i16>;
1706 def v4i32_3: EQVVecPattern3<v4i32>;
1707 def v2i64_3: EQVVecPattern3<v2i64>;
1709 def r128: EQVRegInst<GPRC>;
1710 def r64: EQVRegInst<R64C>;
1711 def r32: EQVRegInst<R32C>;
1712 def r16: EQVRegInst<R16C>;
1713 def r8: EQVRegInst<R8C>;
1715 def r128_1: EQVRegPattern1<GPRC>;
1716 def r64_1: EQVRegPattern1<R64C>;
1717 def r32_1: EQVRegPattern1<R32C>;
1718 def r16_1: EQVRegPattern1<R16C>;
1719 def r8_1: EQVRegPattern1<R8C>;
1721 def r128_2: EQVRegPattern2<GPRC>;
1722 def r64_2: EQVRegPattern2<R64C>;
1723 def r32_2: EQVRegPattern2<R32C>;
1724 def r16_2: EQVRegPattern2<R16C>;
1725 def r8_2: EQVRegPattern2<R8C>;
1727 def r128_3: EQVRegPattern3<GPRC>;
1728 def r64_3: EQVRegPattern3<R64C>;
1729 def r32_3: EQVRegPattern3<R32C>;
1730 def r16_3: EQVRegPattern3<R16C>;
1731 def r8_3: EQVRegPattern3<R8C>;
1734 defm EQV: BitEquivalence;
1736 //===----------------------------------------------------------------------===//
1737 // Vector shuffle...
1738 //===----------------------------------------------------------------------===//
1739 // SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
1740 // See the SPUshuffle SDNode operand above, which sets up the DAG pattern
1741 // matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
1742 // the SPUISD::SHUFB opcode.
1743 //===----------------------------------------------------------------------===//
1745 class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
1746 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
1747 IntegerOp, pattern>;
1749 class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
1750 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1751 [(set (resultvec VECREG:$rT),
1752 (SPUshuffle (resultvec VECREG:$rA),
1753 (resultvec VECREG:$rB),
1754 (maskvec VECREG:$rC)))]>;
1756 multiclass ShuffleBytes
1758 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
1759 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
1760 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
1761 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
1762 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
1763 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
1764 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
1765 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
1767 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
1768 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
1770 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
1771 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
1774 defm SHUFB : ShuffleBytes;
1776 //===----------------------------------------------------------------------===//
1777 // Shift and rotate group:
1778 //===----------------------------------------------------------------------===//
1780 class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
1781 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
1782 RotateShift, pattern>;
1784 class SHLHVecInst<ValueType vectype>:
1785 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
1786 [(set (vectype VECREG:$rT),
1787 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
1789 // $rB gets promoted to 32-bit register type when confronted with
1790 // this llvm assembly code:
1792 // define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
1793 // %A = shl i16 %arg1, %arg2
1797 multiclass ShiftLeftHalfword
1799 def v8i16: SHLHVecInst<v8i16>;
1800 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1801 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
1802 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
1803 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
1806 defm SHLH : ShiftLeftHalfword;
1808 //===----------------------------------------------------------------------===//
1810 class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
1811 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
1812 RotateShift, pattern>;
1814 class SHLHIVecInst<ValueType vectype>:
1815 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
1816 [(set (vectype VECREG:$rT),
1817 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
1819 multiclass ShiftLeftHalfwordImm
1821 def v8i16: SHLHIVecInst<v8i16>;
1822 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
1823 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
1826 defm SHLHI : ShiftLeftHalfwordImm;
1828 def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
1829 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
1831 def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
1832 (SHLHIr16 R16C:$rA, uimm7:$val)>;
1834 //===----------------------------------------------------------------------===//
1836 class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
1837 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
1838 RotateShift, pattern>;
1840 multiclass ShiftLeftWord
1843 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
1844 [(set (v4i32 VECREG:$rT),
1845 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
1847 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1848 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
1851 defm SHL: ShiftLeftWord;
1853 //===----------------------------------------------------------------------===//
1855 class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
1856 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
1857 RotateShift, pattern>;
1859 multiclass ShiftLeftWordImm
1862 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
1863 [(set (v4i32 VECREG:$rT),
1864 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
1867 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
1868 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
1871 defm SHLI : ShiftLeftWordImm;
1873 //===----------------------------------------------------------------------===//
1874 // SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
1875 // register) to the left. Vector form is here to ensure type correctness.
1877 // The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
1878 // of 7 bits is actually possible.
1880 // Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
1881 // to shift i64 and i128. SHLQBI is the residual left over after shifting by
1882 // bytes with SHLQBY.
1884 class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
1885 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
1886 RotateShift, pattern>;
1888 class SHLQBIVecInst<ValueType vectype>:
1889 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
1890 [(set (vectype VECREG:$rT),
1891 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
1893 multiclass ShiftLeftQuadByBits
1895 def v16i8: SHLQBIVecInst<v16i8>;
1896 def v8i16: SHLQBIVecInst<v8i16>;
1897 def v4i32: SHLQBIVecInst<v4i32>;
1898 def v4f32: SHLQBIVecInst<v4f32>;
1899 def v2i64: SHLQBIVecInst<v2i64>;
1900 def v2f64: SHLQBIVecInst<v2f64>;
1903 defm SHLQBI : ShiftLeftQuadByBits;
1905 // See note above on SHLQBI. In this case, the predicate actually does then
1906 // enforcement, whereas with SHLQBI, we have to "take it on faith."
1907 class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
1908 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
1909 RotateShift, pattern>;
1911 class SHLQBIIVecInst<ValueType vectype>:
1912 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
1913 [(set (vectype VECREG:$rT),
1914 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
1916 multiclass ShiftLeftQuadByBitsImm
1918 def v16i8 : SHLQBIIVecInst<v16i8>;
1919 def v8i16 : SHLQBIIVecInst<v8i16>;
1920 def v4i32 : SHLQBIIVecInst<v4i32>;
1921 def v4f32 : SHLQBIIVecInst<v4f32>;
1922 def v2i64 : SHLQBIIVecInst<v2i64>;
1923 def v2f64 : SHLQBIIVecInst<v2f64>;
1926 defm SHLQBII : ShiftLeftQuadByBitsImm;
1928 // SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
1929 // not by bits. See notes above on SHLQBI.
1931 class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
1932 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
1933 RotateShift, pattern>;
1935 class SHLQBYVecInst<ValueType vectype>:
1936 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
1937 [(set (vectype VECREG:$rT),
1938 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
1940 multiclass ShiftLeftQuadBytes
1942 def v16i8: SHLQBYVecInst<v16i8>;
1943 def v8i16: SHLQBYVecInst<v8i16>;
1944 def v4i32: SHLQBYVecInst<v4i32>;
1945 def v4f32: SHLQBYVecInst<v4f32>;
1946 def v2i64: SHLQBYVecInst<v2i64>;
1947 def v2f64: SHLQBYVecInst<v2f64>;
1948 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
1949 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
1952 defm SHLQBY: ShiftLeftQuadBytes;
1954 class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
1955 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
1956 RotateShift, pattern>;
1958 class SHLQBYIVecInst<ValueType vectype>:
1959 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
1960 [(set (vectype VECREG:$rT),
1961 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
1963 multiclass ShiftLeftQuadBytesImm
1965 def v16i8: SHLQBYIVecInst<v16i8>;
1966 def v8i16: SHLQBYIVecInst<v8i16>;
1967 def v4i32: SHLQBYIVecInst<v4i32>;
1968 def v4f32: SHLQBYIVecInst<v4f32>;
1969 def v2i64: SHLQBYIVecInst<v2i64>;
1970 def v2f64: SHLQBYIVecInst<v2f64>;
1971 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
1973 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
1976 defm SHLQBYI : ShiftLeftQuadBytesImm;
1978 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1980 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1981 class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
1982 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
1983 RotateShift, pattern>;
1985 class ROTHVecInst<ValueType vectype>:
1986 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1987 [(set (vectype VECREG:$rT),
1988 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
1990 class ROTHRegInst<RegisterClass rclass>:
1991 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1992 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
1994 multiclass RotateLeftHalfword
1996 def v8i16: ROTHVecInst<v8i16>;
1997 def r16: ROTHRegInst<R16C>;
2000 defm ROTH: RotateLeftHalfword;
2002 def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2003 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2005 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2006 // Rotate halfword, immediate:
2007 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2008 class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2009 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2010 RotateShift, pattern>;
2012 class ROTHIVecInst<ValueType vectype>:
2013 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2014 [(set (vectype VECREG:$rT),
2015 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2017 multiclass RotateLeftHalfwordImm
2019 def v8i16: ROTHIVecInst<v8i16>;
2020 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2021 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2022 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2023 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2026 defm ROTHI: RotateLeftHalfwordImm;
2028 def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
2029 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
2031 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2033 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2035 class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2036 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2037 RotateShift, pattern>;
2039 class ROTVecInst<ValueType vectype>:
2040 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2041 [(set (vectype VECREG:$rT),
2042 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
2044 class ROTRegInst<RegisterClass rclass>:
2045 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2047 (rotl rclass:$rA, R32C:$rB))]>;
2049 multiclass RotateLeftWord
2051 def v4i32: ROTVecInst<v4i32>;
2052 def r32: ROTRegInst<R32C>;
2055 defm ROT: RotateLeftWord;
2057 // The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2059 def ROTr32_r16_anyext:
2060 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2061 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
2063 def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2064 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2066 def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2067 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2069 def ROTr32_r8_anyext:
2070 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2071 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
2073 def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2074 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2076 def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2077 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2079 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2080 // Rotate word, immediate
2081 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2083 class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2084 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2085 RotateShift, pattern>;
2087 class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2088 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2089 [(set (vectype VECREG:$rT),
2090 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
2092 class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2093 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2094 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
2096 multiclass RotateLeftWordImm
2098 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2099 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2100 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
2102 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2103 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2104 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2107 defm ROTI : RotateLeftWordImm;
2109 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2110 // Rotate quad by byte (count)
2111 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2113 class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2114 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2115 RotateShift, pattern>;
2117 class ROTQBYVecInst<ValueType vectype>:
2118 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2119 [(set (vectype VECREG:$rT),
2120 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2122 multiclass RotateQuadLeftByBytes
2124 def v16i8: ROTQBYVecInst<v16i8>;
2125 def v8i16: ROTQBYVecInst<v8i16>;
2126 def v4i32: ROTQBYVecInst<v4i32>;
2127 def v2i64: ROTQBYVecInst<v2i64>;
2130 defm ROTQBY: RotateQuadLeftByBytes;
2132 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2133 // Rotate quad by byte (count), immediate
2134 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2136 class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2137 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2138 RotateShift, pattern>;
2140 class ROTQBYIVecInst<ValueType vectype>:
2141 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2142 [(set (vectype VECREG:$rT),
2143 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2145 multiclass RotateQuadByBytesImm
2147 def v16i8: ROTQBYIVecInst<v16i8>;
2148 def v8i16: ROTQBYIVecInst<v8i16>;
2149 def v4i32: ROTQBYIVecInst<v4i32>;
2150 def v2i64: ROTQBYIVecInst<v2i64>;
2153 defm ROTQBYI: RotateQuadByBytesImm;
2155 // See ROTQBY note above.
2156 class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2157 RI7Form<0b00110011100, OOL, IOL,
2158 "rotqbybi\t$rT, $rA, $shift",
2159 RotateShift, pattern>;
2161 class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2162 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2163 [(set (vectype VECREG:$rT),
2164 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2166 multiclass RotateQuadByBytesByBitshift {
2167 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2168 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2169 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2170 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2173 defm ROTQBYBI : RotateQuadByBytesByBitshift;
2175 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2176 // See ROTQBY note above.
2178 // Assume that the user of this instruction knows to shift the rotate count
2180 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2182 class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2183 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2184 RotateShift, pattern>;
2186 class ROTQBIVecInst<ValueType vectype>:
2187 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2188 [/* no pattern yet */]>;
2190 class ROTQBIRegInst<RegisterClass rclass>:
2191 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2192 [/* no pattern yet */]>;
2194 multiclass RotateQuadByBitCount
2196 def v16i8: ROTQBIVecInst<v16i8>;
2197 def v8i16: ROTQBIVecInst<v8i16>;
2198 def v4i32: ROTQBIVecInst<v4i32>;
2199 def v2i64: ROTQBIVecInst<v2i64>;
2201 def r128: ROTQBIRegInst<GPRC>;
2202 def r64: ROTQBIRegInst<R64C>;
2205 defm ROTQBI: RotateQuadByBitCount;
2207 class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2208 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2209 RotateShift, pattern>;
2211 class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2213 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2214 [/* no pattern yet */]>;
2216 class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2218 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2219 [/* no pattern yet */]>;
2221 multiclass RotateQuadByBitCountImm
2223 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2224 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2225 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2226 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2228 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2229 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2232 defm ROTQBII : RotateQuadByBitCountImm;
2234 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2235 // ROTHM v8i16 form:
2236 // NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2237 // so this only matches a synthetically generated/lowered code
2239 // NOTE(2): $rB must be negated before the right rotate!
2240 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2242 class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2243 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2244 RotateShift, pattern>;
2247 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2248 [/* see patterns below - $rB must be negated */]>;
2250 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
2251 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2253 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
2254 (ROTHMv8i16 VECREG:$rA,
2255 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2257 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
2258 (ROTHMv8i16 VECREG:$rA,
2259 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2261 // ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2262 // Note: This instruction doesn't match a pattern because rB must be negated
2263 // for the instruction to work. Thus, the pattern below the instruction!
2266 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2267 [/* see patterns below - $rB must be negated! */]>;
2269 def : Pat<(srl R16C:$rA, R32C:$rB),
2270 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2272 def : Pat<(srl R16C:$rA, R16C:$rB),
2274 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2276 def : Pat<(srl R16C:$rA, R8C:$rB),
2278 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2280 // ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2281 // that the immediate can be complemented, so that the user doesn't have to
2284 class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2285 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2286 RotateShift, pattern>;
2289 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2290 [/* no pattern */]>;
2292 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2293 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2295 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
2296 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2298 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
2299 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2302 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2303 [/* no pattern */]>;
2305 def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2306 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2308 def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2309 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2311 def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2312 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2314 // ROTM v4i32 form: See the ROTHM v8i16 comments.
2315 class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2316 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2317 RotateShift, pattern>;
2320 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2321 [/* see patterns below - $rB must be negated */]>;
2323 def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
2324 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2326 def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
2327 (ROTMv4i32 VECREG:$rA,
2328 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2330 def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
2331 (ROTMv4i32 VECREG:$rA,
2332 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2335 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2336 [/* see patterns below - $rB must be negated */]>;
2338 def : Pat<(srl R32C:$rA, R32C:$rB),
2339 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2341 def : Pat<(srl R32C:$rA, R16C:$rB),
2343 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2345 def : Pat<(srl R32C:$rA, R8C:$rB),
2347 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2349 // ROTMI v4i32 form: See the comment for ROTHM v8i16.
2351 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2352 "rotmi\t$rT, $rA, $val", RotateShift,
2353 [(set (v4i32 VECREG:$rT),
2354 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
2356 def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
2357 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2359 def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
2360 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2362 // ROTMI r32 form: know how to complement the immediate value.
2364 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2365 "rotmi\t$rT, $rA, $val", RotateShift,
2366 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2368 def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2369 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2371 def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2372 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2374 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2375 // ROTQMBYvec: This is a vector form merely so that when used in an
2376 // instruction pattern, type checking will succeed. This instruction assumes
2377 // that the user knew to negate $rB.
2379 // Using the SPUrotquad_rz_bytes target-specific DAG node, the patterns
2380 // ensure that $rB is negated.
2381 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2383 class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2384 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2385 RotateShift, pattern>;
2387 class ROTQMBYVecInst<ValueType vectype>:
2388 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2389 [/* no pattern, $rB must be negated */]>;
2391 class ROTQMBYRegInst<RegisterClass rclass>:
2392 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2394 (SPUrotquad_rz_bytes rclass:$rA, R32C:$rB))]>;
2396 multiclass RotateQuadBytes
2398 def v16i8: ROTQMBYVecInst<v16i8>;
2399 def v8i16: ROTQMBYVecInst<v8i16>;
2400 def v4i32: ROTQMBYVecInst<v4i32>;
2401 def v2i64: ROTQMBYVecInst<v2i64>;
2403 def r128: ROTQMBYRegInst<GPRC>;
2404 def r64: ROTQMBYRegInst<R64C>;
2407 defm ROTQMBY : RotateQuadBytes;
2409 def : Pat<(SPUrotquad_rz_bytes (v16i8 VECREG:$rA), R32C:$rB),
2410 (ROTQMBYv16i8 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2411 def : Pat<(SPUrotquad_rz_bytes (v8i16 VECREG:$rA), R32C:$rB),
2412 (ROTQMBYv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2413 def : Pat<(SPUrotquad_rz_bytes (v4i32 VECREG:$rA), R32C:$rB),
2414 (ROTQMBYv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2415 def : Pat<(SPUrotquad_rz_bytes (v2i64 VECREG:$rA), R32C:$rB),
2416 (ROTQMBYv2i64 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2417 def : Pat<(SPUrotquad_rz_bytes GPRC:$rA, R32C:$rB),
2418 (ROTQMBYr128 GPRC:$rA, (SFIr32 R32C:$rB, 0))>;
2419 def : Pat<(SPUrotquad_rz_bytes R64C:$rA, R32C:$rB),
2420 (ROTQMBYr64 R64C:$rA, (SFIr32 R32C:$rB, 0))>;
2422 class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2423 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2424 RotateShift, pattern>;
2426 class ROTQMBYIVecInst<ValueType vectype>:
2427 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2428 [(set (vectype VECREG:$rT),
2429 (SPUrotquad_rz_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2431 class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2432 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2434 (SPUrotquad_rz_bytes rclass:$rA, (inttype pred:$val)))]>;
2436 multiclass RotateQuadBytesImm
2438 def v16i8: ROTQMBYIVecInst<v16i8>;
2439 def v8i16: ROTQMBYIVecInst<v8i16>;
2440 def v4i32: ROTQMBYIVecInst<v4i32>;
2441 def v2i64: ROTQMBYIVecInst<v2i64>;
2443 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2444 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
2447 defm ROTQMBYI : RotateQuadBytesImm;
2449 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2450 // Rotate right and mask by bit count
2451 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2453 class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2454 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2455 RotateShift, pattern>;
2457 class ROTQMBYBIVecInst<ValueType vectype>:
2458 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2459 [/* no pattern, intrinsic? */]>;
2461 multiclass RotateMaskQuadByBitCount
2463 def v16i8: ROTQMBYBIVecInst<v16i8>;
2464 def v8i16: ROTQMBYBIVecInst<v8i16>;
2465 def v4i32: ROTQMBYBIVecInst<v4i32>;
2466 def v2i64: ROTQMBYBIVecInst<v2i64>;
2469 defm ROTQMBYBI: RotateMaskQuadByBitCount;
2471 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2472 // Rotate quad and mask by bits
2473 // Note that the rotate amount has to be negated
2474 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2476 class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2477 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2478 RotateShift, pattern>;
2480 class ROTQMBIVecInst<ValueType vectype>:
2481 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2482 [/* no pattern */]>;
2484 class ROTQMBIRegInst<RegisterClass rclass>:
2485 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2486 [/* no pattern */]>;
2488 multiclass RotateMaskQuadByBits
2490 def v16i8: ROTQMBIVecInst<v16i8>;
2491 def v8i16: ROTQMBIVecInst<v8i16>;
2492 def v4i32: ROTQMBIVecInst<v4i32>;
2493 def v2i64: ROTQMBIVecInst<v2i64>;
2495 def r128: ROTQMBIRegInst<GPRC>;
2496 def r64: ROTQMBIRegInst<R64C>;
2499 defm ROTQMBI: RotateMaskQuadByBits;
2501 def : Pat<(SPUrotquad_rz_bits (v16i8 VECREG:$rA), R32C:$rB),
2502 (ROTQMBIv16i8 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2503 def : Pat<(SPUrotquad_rz_bits (v8i16 VECREG:$rA), R32C:$rB),
2504 (ROTQMBIv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2505 def : Pat<(SPUrotquad_rz_bits (v4i32 VECREG:$rA), R32C:$rB),
2506 (ROTQMBIv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2507 def : Pat<(SPUrotquad_rz_bits (v2i64 VECREG:$rA), R32C:$rB),
2508 (ROTQMBIv2i64 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2509 def : Pat<(SPUrotquad_rz_bits GPRC:$rA, R32C:$rB),
2510 (ROTQMBIr128 GPRC:$rA, (SFIr32 R32C:$rB, 0))>;
2511 def : Pat<(SPUrotquad_rz_bits R64C:$rA, R32C:$rB),
2512 (ROTQMBIr64 R64C:$rA, (SFIr32 R32C:$rB, 0))>;
2514 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2515 // Rotate quad and mask by bits, immediate
2516 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2518 class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2519 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2520 RotateShift, pattern>;
2522 class ROTQMBIIVecInst<ValueType vectype>:
2523 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2524 [(set (vectype VECREG:$rT),
2525 (SPUrotquad_rz_bits (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2527 class ROTQMBIIRegInst<RegisterClass rclass>:
2528 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
2530 (SPUrotquad_rz_bits rclass:$rA, (i32 uimm7:$val)))]>;
2532 multiclass RotateMaskQuadByBitsImm
2534 def v16i8: ROTQMBIIVecInst<v16i8>;
2535 def v8i16: ROTQMBIIVecInst<v8i16>;
2536 def v4i32: ROTQMBIIVecInst<v4i32>;
2537 def v2i64: ROTQMBIIVecInst<v2i64>;
2539 def r128: ROTQMBIIRegInst<GPRC>;
2540 def r64: ROTQMBIIRegInst<R64C>;
2543 defm ROTQMBII: RotateMaskQuadByBitsImm;
2545 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2546 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2549 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2550 "rotmah\t$rT, $rA, $rB", RotateShift,
2551 [/* see patterns below - $rB must be negated */]>;
2553 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2554 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2556 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2557 (ROTMAHv8i16 VECREG:$rA,
2558 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2560 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2561 (ROTMAHv8i16 VECREG:$rA,
2562 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2565 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2566 "rotmah\t$rT, $rA, $rB", RotateShift,
2567 [/* see patterns below - $rB must be negated */]>;
2569 def : Pat<(sra R16C:$rA, R32C:$rB),
2570 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2572 def : Pat<(sra R16C:$rA, R16C:$rB),
2573 (ROTMAHr16 R16C:$rA,
2574 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2576 def : Pat<(sra R16C:$rA, R8C:$rB),
2577 (ROTMAHr16 R16C:$rA,
2578 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2581 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2582 "rotmahi\t$rT, $rA, $val", RotateShift,
2583 [(set (v8i16 VECREG:$rT),
2584 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
2586 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
2587 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2589 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
2590 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2593 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2594 "rotmahi\t$rT, $rA, $val", RotateShift,
2595 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2597 def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2598 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2600 def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2601 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2604 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2605 "rotma\t$rT, $rA, $rB", RotateShift,
2606 [/* see patterns below - $rB must be negated */]>;
2608 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2609 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2611 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2612 (ROTMAv4i32 (v4i32 VECREG:$rA),
2613 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2615 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2616 (ROTMAv4i32 (v4i32 VECREG:$rA),
2617 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2620 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2621 "rotma\t$rT, $rA, $rB", RotateShift,
2622 [/* see patterns below - $rB must be negated */]>;
2624 def : Pat<(sra R32C:$rA, R32C:$rB),
2625 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2627 def : Pat<(sra R32C:$rA, R16C:$rB),
2629 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2631 def : Pat<(sra R32C:$rA, R8C:$rB),
2633 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2635 class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
2636 RRForm<0b01011110000, OOL, IOL,
2637 "rotmai\t$rT, $rA, $val",
2638 RotateShift, pattern>;
2640 class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
2641 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
2642 [(set (vectype VECREG:$rT),
2643 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
2645 class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
2646 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
2647 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
2649 multiclass RotateMaskAlgebraicImm {
2650 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
2651 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
2652 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
2653 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
2656 defm ROTMAI : RotateMaskAlgebraicImm;
2658 //===----------------------------------------------------------------------===//
2659 // Branch and conditionals:
2660 //===----------------------------------------------------------------------===//
2662 let isTerminator = 1, isBarrier = 1 in {
2663 // Halt If Equal (r32 preferred slot only, no vector form)
2665 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
2666 "heq\t$rA, $rB", BranchResolv,
2667 [/* no pattern to match */]>;
2670 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
2671 "heqi\t$rA, $val", BranchResolv,
2672 [/* no pattern to match */]>;
2674 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
2675 // contrasting with HLGT/HLGTI, which use unsigned comparison:
2677 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
2678 "hgt\t$rA, $rB", BranchResolv,
2679 [/* no pattern to match */]>;
2682 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
2683 "hgti\t$rA, $val", BranchResolv,
2684 [/* no pattern to match */]>;
2687 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
2688 "hlgt\t$rA, $rB", BranchResolv,
2689 [/* no pattern to match */]>;
2692 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
2693 "hlgti\t$rA, $val", BranchResolv,
2694 [/* no pattern to match */]>;
2697 //------------------------------------------------------------------------
2698 // Comparison operators:
2699 //------------------------------------------------------------------------
2701 class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
2702 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
2705 multiclass CmpEqualByte
2708 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2709 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
2710 (v8i16 VECREG:$rB)))]>;
2713 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
2714 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
2717 class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
2718 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
2721 multiclass CmpEqualByteImm
2724 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
2725 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
2726 v16i8SExt8Imm:$val))]>;
2728 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
2729 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
2732 class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
2733 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
2736 multiclass CmpEqualHalfword
2738 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2739 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
2740 (v8i16 VECREG:$rB)))]>;
2742 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2743 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
2746 class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
2747 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
2750 multiclass CmpEqualHalfwordImm
2752 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
2753 [(set (v8i16 VECREG:$rT),
2754 (seteq (v8i16 VECREG:$rA),
2755 (v8i16 v8i16SExt10Imm:$val)))]>;
2756 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
2757 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
2760 class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
2761 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
2764 multiclass CmpEqualWord
2766 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2767 [(set (v4i32 VECREG:$rT),
2768 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
2770 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2771 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
2774 class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
2775 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
2778 multiclass CmpEqualWordImm
2780 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
2781 [(set (v4i32 VECREG:$rT),
2782 (seteq (v4i32 VECREG:$rA),
2783 (v4i32 v4i32SExt16Imm:$val)))]>;
2785 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
2786 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
2789 class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
2790 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
2793 multiclass CmpGtrByte
2796 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2797 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
2798 (v8i16 VECREG:$rB)))]>;
2801 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
2802 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
2805 class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
2806 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
2809 multiclass CmpGtrByteImm
2812 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
2813 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
2814 v16i8SExt8Imm:$val))]>;
2816 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
2817 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
2820 class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
2821 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
2824 multiclass CmpGtrHalfword
2826 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2827 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
2828 (v8i16 VECREG:$rB)))]>;
2830 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2831 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
2834 class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
2835 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
2838 multiclass CmpGtrHalfwordImm
2840 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
2841 [(set (v8i16 VECREG:$rT),
2842 (setgt (v8i16 VECREG:$rA),
2843 (v8i16 v8i16SExt10Imm:$val)))]>;
2844 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
2845 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
2848 class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
2849 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
2852 multiclass CmpGtrWord
2854 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2855 [(set (v4i32 VECREG:$rT),
2856 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
2858 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2859 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
2862 class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
2863 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
2866 multiclass CmpGtrWordImm
2868 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
2869 [(set (v4i32 VECREG:$rT),
2870 (setgt (v4i32 VECREG:$rA),
2871 (v4i32 v4i32SExt16Imm:$val)))]>;
2873 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
2874 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
2877 class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
2878 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
2881 multiclass CmpLGtrByte
2884 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2885 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
2886 (v8i16 VECREG:$rB)))]>;
2889 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
2890 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
2893 class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
2894 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
2897 multiclass CmpLGtrByteImm
2900 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
2901 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
2902 v16i8SExt8Imm:$val))]>;
2904 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
2905 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
2908 class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
2909 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
2912 multiclass CmpLGtrHalfword
2914 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2915 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
2916 (v8i16 VECREG:$rB)))]>;
2918 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2919 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
2922 class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
2923 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
2926 multiclass CmpLGtrHalfwordImm
2928 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
2929 [(set (v8i16 VECREG:$rT),
2930 (setugt (v8i16 VECREG:$rA),
2931 (v8i16 v8i16SExt10Imm:$val)))]>;
2932 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
2933 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
2936 class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
2937 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
2940 multiclass CmpLGtrWord
2942 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2943 [(set (v4i32 VECREG:$rT),
2944 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
2946 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2947 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
2950 class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
2951 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
2954 multiclass CmpLGtrWordImm
2956 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
2957 [(set (v4i32 VECREG:$rT),
2958 (setugt (v4i32 VECREG:$rA),
2959 (v4i32 v4i32SExt16Imm:$val)))]>;
2961 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
2962 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
2965 defm CEQB : CmpEqualByte;
2966 defm CEQBI : CmpEqualByteImm;
2967 defm CEQH : CmpEqualHalfword;
2968 defm CEQHI : CmpEqualHalfwordImm;
2969 defm CEQ : CmpEqualWord;
2970 defm CEQI : CmpEqualWordImm;
2971 defm CGTB : CmpGtrByte;
2972 defm CGTBI : CmpGtrByteImm;
2973 defm CGTH : CmpGtrHalfword;
2974 defm CGTHI : CmpGtrHalfwordImm;
2975 defm CGT : CmpGtrWord;
2976 defm CGTI : CmpGtrWordImm;
2977 defm CLGTB : CmpLGtrByte;
2978 defm CLGTBI : CmpLGtrByteImm;
2979 defm CLGTH : CmpLGtrHalfword;
2980 defm CLGTHI : CmpLGtrHalfwordImm;
2981 defm CLGT : CmpLGtrWord;
2982 defm CLGTI : CmpLGtrWordImm;
2984 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2985 // For SETCC primitives not supported above (setlt, setle, setge, etc.)
2986 // define a pattern to generate the right code, as a binary operator
2987 // (in a manner of speaking.)
2989 // N.B.: This only matches the setcc set of conditionals. Special pattern
2990 // matching is used for select conditionals.
2991 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2993 class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
2994 SPUInstr xorinst, SPUInstr cmpare>:
2995 Pat<(cond rclass:$rA, rclass:$rB),
2996 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
2998 class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
2999 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3000 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3001 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3003 def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
3004 def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3006 def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
3007 def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3009 def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3010 def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
3012 class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3013 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3014 Pat<(cond rclass:$rA, rclass:$rB),
3015 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3016 (cmpOp2 rclass:$rA, rclass:$rB))>;
3018 class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3020 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3021 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3022 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3023 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3025 def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3026 def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3027 def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3028 def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3029 def : Pat<(setle R8C:$rA, R8C:$rB),
3030 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3031 def : Pat<(setle R8C:$rA, immU8:$imm),
3032 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3034 def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3035 def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3036 ORr16, CGTHIr16, CEQHIr16>;
3037 def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3038 def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3039 def : Pat<(setle R16C:$rA, R16C:$rB),
3040 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3041 def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3042 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3044 def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3045 def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3046 ORr32, CGTIr32, CEQIr32>;
3047 def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3048 def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3049 def : Pat<(setle R32C:$rA, R32C:$rB),
3050 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3051 def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3052 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3054 def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3055 def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3056 def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3057 def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3058 def : Pat<(setule R8C:$rA, R8C:$rB),
3059 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3060 def : Pat<(setule R8C:$rA, immU8:$imm),
3061 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3063 def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3064 def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3065 ORr16, CLGTHIr16, CEQHIr16>;
3066 def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3067 def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3068 CLGTHIr16, CEQHIr16>;
3069 def : Pat<(setule R16C:$rA, R16C:$rB),
3070 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3071 def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
3072 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3074 def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
3075 def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
3076 ORr32, CLGTIr32, CEQIr32>;
3077 def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
3078 def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
3079 def : Pat<(setule R32C:$rA, R32C:$rB),
3080 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3081 def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3082 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3084 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3085 // select conditional patterns:
3086 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3088 class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3089 SPUInstr selinstr, SPUInstr cmpare>:
3090 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3091 rclass:$rTrue, rclass:$rFalse),
3092 (selinstr rclass:$rTrue, rclass:$rFalse,
3093 (cmpare rclass:$rA, rclass:$rB))>;
3095 class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3096 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3097 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
3098 rclass:$rTrue, rclass:$rFalse),
3099 (selinstr rclass:$rTrue, rclass:$rFalse,
3100 (cmpare rclass:$rA, immpred:$imm))>;
3102 def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3103 def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3104 def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3105 def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3106 def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3107 def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3109 def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3110 def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3111 def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3112 def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3113 def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3114 def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3116 def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3117 def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3118 def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3119 def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3120 def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3121 def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3123 class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3124 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3126 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3127 rclass:$rFalse, rclass:$rTrue),
3128 (selinstr rclass:$rTrue, rclass:$rFalse,
3129 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3130 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3132 class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3134 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3136 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
3137 rclass:$rTrue, rclass:$rFalse),
3138 (selinstr rclass:$rFalse, rclass:$rTrue,
3139 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3140 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3142 def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3143 def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3144 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3146 def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3147 def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3148 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3150 def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3151 def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3152 SELBr32, ORr32, CGTIr32, CEQIr32>;
3154 def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3155 def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3156 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3158 def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3159 def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3160 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3162 def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3163 def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3164 SELBr32, ORr32, CLGTIr32, CEQIr32>;
3166 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3169 // All calls clobber the non-callee-saved registers:
3170 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3171 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3172 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3173 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3174 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3175 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3176 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3177 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3178 // All of these instructions use $lr (aka $0)
3180 // Branch relative and set link: Used if we actually know that the target
3181 // is within [-32768, 32767] bytes of the target
3183 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3184 "brsl\t$$lr, $func",
3185 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3187 // Branch absolute and set link: Used if we actually know that the target
3188 // is an absolute address
3190 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3191 "brasl\t$$lr, $func",
3192 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
3194 // Branch indirect and set link if external data. These instructions are not
3195 // actually generated, matched by an intrinsic:
3196 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3197 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3198 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3199 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3201 // Branch indirect and set link. This is the "X-form" address version of a
3204 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3207 // Unconditional branches:
3208 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
3210 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3214 // Unconditional, absolute address branch
3216 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3218 [/* no pattern */]>;
3222 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3224 // Various branches:
3226 RI16Form<0b010000100, (outs), (ins R32C:$rCond, brtarget:$dest),
3227 "brnz\t$rCond,$dest",
3229 [(brcond R32C:$rCond, bb:$dest)]>;
3232 RI16Form<0b000000100, (outs), (ins R32C:$rT, brtarget:$dest),
3235 [/* no pattern */]>;
3238 RI16Form<0b011000100, (outs), (ins R16C:$rCond, brtarget:$dest),
3239 "brhnz\t$rCond,$dest",
3241 [(brcond R16C:$rCond, bb:$dest)]>;
3244 RI16Form<0b001000100, (outs), (ins R16C:$rT, brtarget:$dest),
3247 [/* no pattern */]>;
3251 BICondForm<0b10010100100, "binz\t$rA, $func",
3252 [(SPUbinz R32C:$rA, R32C:$func)]>;
3255 BICondForm<0b00010100100, "biz\t$rA, $func",
3256 [(SPUbiz R32C:$rA, R32C:$func)]>;
3260 //===----------------------------------------------------------------------===//
3261 // setcc and brcond patterns:
3262 //===----------------------------------------------------------------------===//
3264 def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3265 (BRHZ R16C:$rA, bb:$dest)>;
3266 def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3267 (BRHNZ R16C:$rA, bb:$dest)>;
3269 def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3270 (BRZ R32C:$rA, bb:$dest)>;
3271 def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3272 (BRNZ R32C:$rA, bb:$dest)>;
3274 multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3276 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3277 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3279 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3280 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3282 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3283 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3285 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3286 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3289 defm BRCONDeq : BranchCondEQ<seteq, BRHZ, BRZ>;
3290 defm BRCONDne : BranchCondEQ<setne, BRHNZ, BRNZ>;
3292 multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3294 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3295 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3297 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3298 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3300 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3301 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3303 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3304 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3307 defm BRCONDugt : BranchCondLGT<setugt, BRHNZ, BRNZ>;
3308 defm BRCONDule : BranchCondLGT<setule, BRHZ, BRZ>;
3310 multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3311 SPUInstr orinst32, SPUInstr brinst32>
3313 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3314 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3315 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3318 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3319 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3320 (CEQHr16 R16C:$rA, R16:$rB)),
3323 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3324 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3325 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3328 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3329 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3330 (CEQr32 R32C:$rA, R32C:$rB)),
3334 defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZ, ORr32, BRNZ>;
3335 defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZ, ORr32, BRZ>;
3337 multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3339 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3340 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3342 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3343 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3345 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3346 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3348 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3349 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3352 defm BRCONDgt : BranchCondGT<setgt, BRHNZ, BRNZ>;
3353 defm BRCONDle : BranchCondGT<setle, BRHZ, BRZ>;
3355 multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3356 SPUInstr orinst32, SPUInstr brinst32>
3358 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3359 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3360 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3363 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3364 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3365 (CEQHr16 R16C:$rA, R16:$rB)),
3368 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3369 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3370 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3373 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3374 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3375 (CEQr32 R32C:$rA, R32C:$rB)),
3379 defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZ, ORr32, BRNZ>;
3380 defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZ, ORr32, BRZ>;
3382 let isTerminator = 1, isBarrier = 1 in {
3383 let isReturn = 1 in {
3385 RETForm<"bi\t$$lr", [(retflag)]>;
3389 //===----------------------------------------------------------------------===//
3390 // Single precision floating point instructions
3391 //===----------------------------------------------------------------------===//
3394 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3395 "fa\t$rT, $rA, $rB", SPrecFP,
3396 [(set (v4f32 VECREG:$rT), (fadd (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)))]>;
3399 RRForm<0b00100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3400 "fa\t$rT, $rA, $rB", SPrecFP,
3401 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
3404 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3405 "fs\t$rT, $rA, $rB", SPrecFP,
3406 [(set (v4f32 VECREG:$rT), (fsub (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)))]>;
3409 RRForm<0b10100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3410 "fs\t$rT, $rA, $rB", SPrecFP,
3411 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
3413 // Floating point reciprocal estimate
3415 RRForm_1<0b00011101100, (outs VECREG:$rT), (ins VECREG:$rA),
3416 "frest\t$rT, $rA", SPrecFP,
3417 [(set (v4f32 VECREG:$rT), (SPUreciprocalEst (v4f32 VECREG:$rA)))]>;
3420 RRForm_1<0b00011101100, (outs R32FP:$rT), (ins R32FP:$rA),
3421 "frest\t$rT, $rA", SPrecFP,
3422 [(set R32FP:$rT, (SPUreciprocalEst R32FP:$rA))]>;
3424 // Floating point interpolate (used in conjunction with reciprocal estimate)
3426 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3427 "fi\t$rT, $rA, $rB", SPrecFP,
3428 [(set (v4f32 VECREG:$rT), (SPUinterpolate (v4f32 VECREG:$rA),
3429 (v4f32 VECREG:$rB)))]>;
3432 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3433 "fi\t$rT, $rA, $rB", SPrecFP,
3434 [(set R32FP:$rT, (SPUinterpolate R32FP:$rA, R32FP:$rB))]>;
3436 //--------------------------------------------------------------------------
3437 // Basic single precision floating point comparisons:
3439 // Note: There is no support on SPU for single precision NaN. Consequently,
3440 // ordered and unordered comparisons are the same.
3441 //--------------------------------------------------------------------------
3444 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3445 "fceq\t$rT, $rA, $rB", SPrecFP,
3446 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3448 def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3449 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
3452 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3453 "fcmeq\t$rT, $rA, $rB", SPrecFP,
3454 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3456 def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3457 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
3460 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3461 "fcgt\t$rT, $rA, $rB", SPrecFP,
3462 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3464 def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3465 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
3468 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3469 "fcmgt\t$rT, $rA, $rB", SPrecFP,
3470 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3472 def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3473 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3475 //--------------------------------------------------------------------------
3476 // Single precision floating point comparisons and SETCC equivalents:
3477 //--------------------------------------------------------------------------
3479 def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3480 def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3482 def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3483 def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3485 def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3486 def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3488 def : Pat<(setule R32FP:$rA, R32FP:$rB),
3489 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3490 def : Pat<(setole R32FP:$rA, R32FP:$rB),
3491 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3493 // FP Status and Control Register Write
3494 // Why isn't rT a don't care in the ISA?
3495 // Should we create a special RRForm_3 for this guy and zero out the rT?
3497 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3498 "fscrwr\t$rA", SPrecFP,
3499 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3501 // FP Status and Control Register Read
3503 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3504 "fscrrd\t$rT", SPrecFP,
3505 [/* This instruction requires an intrinsic */]>;
3507 // llvm instruction space
3508 // How do these map onto cell instructions?
3510 // frest rC rB # c = 1/b (both lines)
3512 // fm rD rA rC # d = a * 1/b
3513 // fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
3514 // fma rB rB rC rD # b = b * c + d
3515 // = -(d *b -a) * c + d
3516 // = a * c - c ( a *b *c - a)
3521 // These llvm instructions will actually map to library calls.
3522 // All that's needed, then, is to check that the appropriate library is
3523 // imported and do a brsl to the proper function name.
3524 // frem # fmod(x, y): x - (x/y) * y
3525 // (Note: fmod(double, double), fmodf(float,float)
3529 // Unimplemented SPU instruction space
3530 // floating reciprocal absolute square root estimate (frsqest)
3532 // The following are probably just intrinsics
3533 // status and control register write
3534 // status and control register read
3536 //--------------------------------------
3537 // Floating point multiply instructions
3538 //--------------------------------------
3541 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3542 "fm\t$rT, $rA, $rB", SPrecFP,
3543 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
3544 (v4f32 VECREG:$rB)))]>;
3547 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3548 "fm\t$rT, $rA, $rB", SPrecFP,
3549 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
3551 // Floating point multiply and add
3552 // e.g. d = c + (a * b)
3554 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3555 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
3556 [(set (v4f32 VECREG:$rT),
3557 (fadd (v4f32 VECREG:$rC),
3558 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
3561 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
3562 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
3563 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
3565 // FP multiply and subtract
3566 // Subtracts value in rC from product
3569 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3570 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
3571 [(set (v4f32 VECREG:$rT),
3572 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
3573 (v4f32 VECREG:$rC)))]>;
3576 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
3577 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
3579 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
3581 // Floating Negative Mulitply and Subtract
3582 // Subtracts product from value in rC
3583 // res = fneg(fms a b c)
3586 // NOTE: subtraction order
3590 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
3591 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
3592 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
3595 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3596 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
3597 [(set (v4f32 VECREG:$rT),
3598 (fsub (v4f32 VECREG:$rC),
3599 (fmul (v4f32 VECREG:$rA),
3600 (v4f32 VECREG:$rB))))]>;
3602 //--------------------------------------
3603 // Floating Point Conversions
3604 // Signed conversions:
3606 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
3607 "csflt\t$rT, $rA, 0", SPrecFP,
3608 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
3610 // Convert signed integer to floating point
3612 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
3613 "csflt\t$rT, $rA, 0", SPrecFP,
3614 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
3616 // Convert unsigned into to float
3618 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
3619 "cuflt\t$rT, $rA, 0", SPrecFP,
3620 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
3623 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
3624 "cuflt\t$rT, $rA, 0", SPrecFP,
3625 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
3627 // Convert float to unsigned int
3628 // Assume that scale = 0
3631 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
3632 "cfltu\t$rT, $rA, 0", SPrecFP,
3633 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
3636 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
3637 "cfltu\t$rT, $rA, 0", SPrecFP,
3638 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
3640 // Convert float to signed int
3641 // Assume that scale = 0
3644 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
3645 "cflts\t$rT, $rA, 0", SPrecFP,
3646 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
3649 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
3650 "cflts\t$rT, $rA, 0", SPrecFP,
3651 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
3653 //===----------------------------------------------------------------------==//
3654 // Single<->Double precision conversions
3655 //===----------------------------------------------------------------------==//
3657 // NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
3658 // v4f32, output is v2f64--which goes in the name?)
3660 // Floating point extend single to double
3661 // NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
3662 // operates on two double-word slots (i.e. 1st and 3rd fp numbers
3665 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
3666 "fesd\t$rT, $rA", SPrecFP,
3667 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
3670 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
3671 "fesd\t$rT, $rA", SPrecFP,
3672 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
3674 // Floating point round double to single
3676 // RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
3677 // "frds\t$rT, $rA,", SPrecFP,
3678 // [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
3681 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
3682 "frds\t$rT, $rA", SPrecFP,
3683 [(set R32FP:$rT, (fround R64FP:$rA))]>;
3685 //ToDo include anyextend?
3687 //===----------------------------------------------------------------------==//
3688 // Double precision floating point instructions
3689 //===----------------------------------------------------------------------==//
3691 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
3692 "dfa\t$rT, $rA, $rB", DPrecFP,
3693 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
3696 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3697 "dfa\t$rT, $rA, $rB", DPrecFP,
3698 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
3701 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
3702 "dfs\t$rT, $rA, $rB", DPrecFP,
3703 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
3706 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3707 "dfs\t$rT, $rA, $rB", DPrecFP,
3708 [(set (v2f64 VECREG:$rT),
3709 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
3712 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
3713 "dfm\t$rT, $rA, $rB", DPrecFP,
3714 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
3717 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3718 "dfm\t$rT, $rA, $rB", DPrecFP,
3719 [(set (v2f64 VECREG:$rT),
3720 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
3723 RRForm<0b00111010110, (outs R64FP:$rT),
3724 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
3725 "dfma\t$rT, $rA, $rB", DPrecFP,
3726 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
3727 RegConstraint<"$rC = $rT">,
3731 RRForm<0b00111010110, (outs VECREG:$rT),
3732 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3733 "dfma\t$rT, $rA, $rB", DPrecFP,
3734 [(set (v2f64 VECREG:$rT),
3735 (fadd (v2f64 VECREG:$rC),
3736 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
3737 RegConstraint<"$rC = $rT">,
3741 RRForm<0b10111010110, (outs R64FP:$rT),
3742 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
3743 "dfms\t$rT, $rA, $rB", DPrecFP,
3744 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
3745 RegConstraint<"$rC = $rT">,
3749 RRForm<0b10111010110, (outs VECREG:$rT),
3750 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3751 "dfms\t$rT, $rA, $rB", DPrecFP,
3752 [(set (v2f64 VECREG:$rT),
3753 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
3754 (v2f64 VECREG:$rC)))]>;
3756 // FNMS: - (a * b - c)
3757 // - (a * b) + c => c - (a * b)
3759 RRForm<0b01111010110, (outs R64FP:$rT),
3760 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
3761 "dfnms\t$rT, $rA, $rB", DPrecFP,
3762 [(set R64FP:$rT, (fsub R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
3763 RegConstraint<"$rC = $rT">,
3766 def : Pat<(fneg (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC)),
3767 (FNMSf64 R64FP:$rA, R64FP:$rB, R64FP:$rC)>;
3770 RRForm<0b01111010110, (outs VECREG:$rT),
3771 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3772 "dfnms\t$rT, $rA, $rB", DPrecFP,
3773 [(set (v2f64 VECREG:$rT),
3774 (fsub (v2f64 VECREG:$rC),
3775 (fmul (v2f64 VECREG:$rA),
3776 (v2f64 VECREG:$rB))))]>,
3777 RegConstraint<"$rC = $rT">,
3780 def : Pat<(fneg (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
3781 (v2f64 VECREG:$rC))),
3782 (FNMSv2f64 VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
3787 RRForm<0b11111010110, (outs R64FP:$rT),
3788 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
3789 "dfnma\t$rT, $rA, $rB", DPrecFP,
3790 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
3791 RegConstraint<"$rC = $rT">,
3795 RRForm<0b11111010110, (outs VECREG:$rT),
3796 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3797 "dfnma\t$rT, $rA, $rB", DPrecFP,
3798 [(set (v2f64 VECREG:$rT),
3799 (fneg (fadd (v2f64 VECREG:$rC),
3800 (fmul (v2f64 VECREG:$rA),
3801 (v2f64 VECREG:$rB)))))]>,
3802 RegConstraint<"$rC = $rT">,
3805 //===----------------------------------------------------------------------==//
3806 // Floating point negation and absolute value
3807 //===----------------------------------------------------------------------==//
3809 def : Pat<(fneg (v4f32 VECREG:$rA)),
3810 (XORfnegvec (v4f32 VECREG:$rA),
3811 (v4f32 (ILHUv4i32 0x8000)))>;
3813 def : Pat<(fneg R32FP:$rA),
3814 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
3816 def : Pat<(fneg (v2f64 VECREG:$rA)),
3817 (XORfnegvec (v2f64 VECREG:$rA),
3818 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80)))>;
3820 def : Pat<(fneg R64FP:$rA),
3821 (XORfneg64 R64FP:$rA,
3822 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80))>;
3824 // Floating point absolute value
3826 def : Pat<(fabs R32FP:$rA),
3827 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
3829 def : Pat<(fabs (v4f32 VECREG:$rA)),
3830 (ANDfabsvec (v4f32 VECREG:$rA),
3831 (v4f32 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
3833 def : Pat<(fabs R64FP:$rA),
3834 (ANDfabs64 R64FP:$rA, (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f))>;
3836 def : Pat<(fabs (v2f64 VECREG:$rA)),
3837 (ANDfabsvec (v2f64 VECREG:$rA),
3838 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
3840 //===----------------------------------------------------------------------===//
3841 // Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
3842 // in the odd pipeline)
3843 //===----------------------------------------------------------------------===//
3845 def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
3848 let Inst{0-10} = 0b10000000010;
3849 let Inst{11-17} = 0;
3850 let Inst{18-24} = 0;
3851 let Inst{25-31} = 0;
3854 def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
3857 let Inst{0-10} = 0b10000000000;
3858 let Inst{11-17} = 0;
3859 let Inst{18-24} = 0;
3860 let Inst{25-31} = 0;
3863 //===----------------------------------------------------------------------===//
3864 // Bit conversions (type conversions between vector/packed types)
3865 // NOTE: Promotions are handled using the XS* instructions. Truncation
3867 //===----------------------------------------------------------------------===//
3868 def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
3869 def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
3870 def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
3871 def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
3872 def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
3874 def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
3875 def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
3876 def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
3877 def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
3878 def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
3880 def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
3881 def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
3882 def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
3883 def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
3884 def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
3886 def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
3887 def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
3888 def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
3889 def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
3890 def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
3892 def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
3893 def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
3894 def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
3895 def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
3896 def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
3898 def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
3899 def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
3900 def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
3901 def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
3902 def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
3904 def : Pat<(f32 (bitconvert (i32 R32C:$src))), (f32 R32FP:$src)>;
3905 def : Pat<(f64 (bitconvert (i64 R64C:$src))), (f64 R64FP:$src)>;
3907 //===----------------------------------------------------------------------===//
3908 // Instruction patterns:
3909 //===----------------------------------------------------------------------===//
3911 // General 32-bit constants:
3912 def : Pat<(i32 imm:$imm),
3913 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
3915 // Single precision float constants:
3916 def : Pat<(f32 fpimm:$imm),
3917 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
3919 // General constant 32-bit vectors
3920 def : Pat<(v4i32 v4i32Imm:$imm),
3921 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
3922 (LO16_vec v4i32Imm:$imm))>;
3925 def : Pat<(i8 imm:$imm),
3928 //===----------------------------------------------------------------------===//
3929 // Call instruction patterns:
3930 //===----------------------------------------------------------------------===//
3935 //===----------------------------------------------------------------------===//
3936 // Zero/Any/Sign extensions
3937 //===----------------------------------------------------------------------===//
3939 // sext 8->32: Sign extend bytes to words
3940 def : Pat<(sext_inreg R32C:$rSrc, i8),
3941 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
3943 def : Pat<(i32 (sext R8C:$rSrc)),
3944 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
3946 // zext 8->16: Zero extend bytes to halfwords
3947 def : Pat<(i16 (zext R8C:$rSrc)),
3948 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
3950 // zext 8->32: Zero extend bytes to words
3951 def : Pat<(i32 (zext R8C:$rSrc)),
3952 (ANDIi8i32 R8C:$rSrc, 0xff)>;
3954 // anyext 8->16: Extend 8->16 bits, irrespective of sign
3955 def : Pat<(i16 (anyext R8C:$rSrc)),
3956 (ORHIi8i16 R8C:$rSrc, 0)>;
3958 // anyext 8->32: Extend 8->32 bits, irrespective of sign
3959 def : Pat<(i32 (anyext R8C:$rSrc)),
3960 (ORIi8i32 R8C:$rSrc, 0)>;
3962 // zext 16->32: Zero extend halfwords to words
3963 def : Pat<(i32 (zext R16C:$rSrc)),
3964 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
3966 def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
3967 (ANDIi16i32 R16C:$rSrc, 0xf)>;
3969 def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
3970 (ANDIi16i32 R16C:$rSrc, 0xff)>;
3972 def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
3973 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
3975 // anyext 16->32: Extend 16->32 bits, irrespective of sign
3976 def : Pat<(i32 (anyext R16C:$rSrc)),
3977 (ORIi16i32 R16C:$rSrc, 0)>;
3979 //===----------------------------------------------------------------------===//
3980 // Address generation: SPU, like PPC, has to split addresses into high and
3981 // low parts in order to load them into a register.
3982 //===----------------------------------------------------------------------===//
3984 def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
3985 def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
3986 def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
3987 def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
3989 def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
3990 (SPUlo tglobaladdr:$in, 0)),
3991 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
3993 def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
3994 (SPUlo texternalsym:$in, 0)),
3995 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
3997 def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
3998 (SPUlo tjumptable:$in, 0)),
3999 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4001 def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4002 (SPUlo tconstpool:$in, 0)),
4003 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4005 def : Pat<(SPUindirect R32C:$sp, i32ImmSExt10:$imm),
4006 (AIr32 R32C:$sp, i32ImmSExt10:$imm)>;
4008 def : Pat<(SPUindirect R32C:$sp, imm:$imm),
4010 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm)))>;
4012 def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4013 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4015 def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4016 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4018 def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4019 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4021 def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4022 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4025 include "CellSDKIntrinsics.td"