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 dformaddr:$src),
55 [(set (vectype VECREG:$rT), (load dform_addr:$src))]>
58 class LoadDForm<RegisterClass rclass>
59 : RI10Form<0b00101100, (outs rclass:$rT), (ins dformaddr:$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, dformaddr:$src),
167 [(store (vectype VECREG:$rT), dform_addr:$src)]>
170 class StoreDForm<RegisterClass rclass>
171 : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$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 shufaddr:$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 shufaddr:$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 shufaddr:$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 shufaddr:$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 shufaddr:$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 shufaddr:$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 hi: ILARegInst<R32C, symbolHi, imm18>;
425 def lo: ILARegInst<R32C, symbolLo, imm18>;
427 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
431 defm ILA : ImmLoadAddress;
433 // Immediate OR, Halfword Lower: The "other" part of loading large constants
434 // into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...>
435 // Note that these are really two operand instructions, but they're encoded
436 // as three operands with the first two arguments tied-to each other.
438 class IOHLInst<dag OOL, dag IOL, list<dag> pattern>:
439 RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val",
441 RegConstraint<"$rS = $rT">,
444 class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>:
445 IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val),
448 class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>:
449 IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val),
452 multiclass ImmOrHalfwordLower
454 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
455 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
457 def r32: IOHLRegInst<R32C, i32imm>;
458 def f32: IOHLRegInst<R32FP, f32imm>;
460 def lo: IOHLRegInst<R32C, symbolLo>;
463 defm IOHL: ImmOrHalfwordLower;
465 // Form select mask for bytes using immediate, used in conjunction with the
468 class FSMBIVec<ValueType vectype>:
469 RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val),
472 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
474 multiclass FormSelectMaskBytesImm
476 def v16i8: FSMBIVec<v16i8>;
477 def v8i16: FSMBIVec<v8i16>;
478 def v4i32: FSMBIVec<v4i32>;
479 def v2i64: FSMBIVec<v2i64>;
482 defm FSMBI : FormSelectMaskBytesImm;
484 // fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits
485 class FSMBInst<dag OOL, dag IOL, list<dag> pattern>:
486 RRForm_1<0b01101101100, OOL, IOL, "fsmb\t$rT, $rA", SelectOp,
489 class FSMBRegInst<RegisterClass rclass, ValueType vectype>:
490 FSMBInst<(outs VECREG:$rT), (ins rclass:$rA),
491 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
493 class FSMBVecInst<ValueType vectype>:
494 FSMBInst<(outs VECREG:$rT), (ins VECREG:$rA),
495 [(set (vectype VECREG:$rT),
496 (SPUselmask (vectype VECREG:$rA)))]>;
498 multiclass FormSelectMaskBits {
499 def v16i8_r16: FSMBRegInst<R16C, v16i8>;
500 def v16i8: FSMBVecInst<v16i8>;
503 defm FSMB: FormSelectMaskBits;
505 // fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is
506 // only 8-bits wide (even though it's input as 16-bits here)
508 class FSMHInst<dag OOL, dag IOL, list<dag> pattern>:
509 RRForm_1<0b10101101100, OOL, IOL, "fsmh\t$rT, $rA", SelectOp,
512 class FSMHRegInst<RegisterClass rclass, ValueType vectype>:
513 FSMHInst<(outs VECREG:$rT), (ins rclass:$rA),
514 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
516 class FSMHVecInst<ValueType vectype>:
517 FSMHInst<(outs VECREG:$rT), (ins VECREG:$rA),
518 [(set (vectype VECREG:$rT),
519 (SPUselmask (vectype VECREG:$rA)))]>;
521 multiclass FormSelectMaskHalfword {
522 def v8i16_r16: FSMHRegInst<R16C, v8i16>;
523 def v8i16: FSMHVecInst<v8i16>;
526 defm FSMH: FormSelectMaskHalfword;
528 // fsm: Form select mask for words. Like the other fsm* instructions,
529 // only the lower 4 bits of $rA are significant.
531 class FSMInst<dag OOL, dag IOL, list<dag> pattern>:
532 RRForm_1<0b00101101100, OOL, IOL, "fsm\t$rT, $rA", SelectOp,
535 class FSMRegInst<ValueType vectype, RegisterClass rclass>:
536 FSMInst<(outs VECREG:$rT), (ins rclass:$rA),
537 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
539 class FSMVecInst<ValueType vectype>:
540 FSMInst<(outs VECREG:$rT), (ins VECREG:$rA),
541 [(set (vectype VECREG:$rT), (SPUselmask (vectype VECREG:$rA)))]>;
543 multiclass FormSelectMaskWord {
544 def v4i32: FSMVecInst<v4i32>;
546 def r32 : FSMRegInst<v4i32, R32C>;
547 def r16 : FSMRegInst<v4i32, R16C>;
550 defm FSM : FormSelectMaskWord;
552 // Special case when used for i64 math operations
553 multiclass FormSelectMaskWord64 {
554 def r32 : FSMRegInst<v2i64, R32C>;
555 def r16 : FSMRegInst<v2i64, R16C>;
558 defm FSM64 : FormSelectMaskWord64;
560 //===----------------------------------------------------------------------===//
561 // Integer and Logical Operations:
562 //===----------------------------------------------------------------------===//
565 RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
566 "ah\t$rT, $rA, $rB", IntegerOp,
567 [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>;
569 def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)),
570 (AHv8i16 VECREG:$rA, VECREG:$rB)>;
573 RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
574 "ah\t$rT, $rA, $rB", IntegerOp,
575 [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>;
578 RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
579 "ahi\t$rT, $rA, $val", IntegerOp,
580 [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA),
581 v8i16SExt10Imm:$val))]>;
584 RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
585 "ahi\t$rT, $rA, $val", IntegerOp,
586 [(set R16C:$rT, (add R16C:$rA, v8i16SExt10Imm:$val))]>;
588 class AInst<dag OOL, dag IOL, list<dag> pattern>:
589 RRForm<0b00000011000, OOL, IOL,
590 "a\t$rT, $rA, $rB", IntegerOp,
593 class AVecInst<ValueType vectype>:
594 AInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
595 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA),
596 (vectype VECREG:$rB)))]>;
598 class ARegInst<RegisterClass rclass>:
599 AInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
600 [(set rclass:$rT, (add rclass:$rA, rclass:$rB))]>;
602 multiclass AddInstruction {
603 def v4i32: AVecInst<v4i32>;
604 def v16i8: AVecInst<v16i8>;
606 def r32: ARegInst<R32C>;
607 def r8: AInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB), [/* no pattern */]>;
610 defm A : AddInstruction;
613 RI10Form<0b00111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
614 "ai\t$rT, $rA, $val", IntegerOp,
615 [(set (v4i32 VECREG:$rT), (add (v4i32 VECREG:$rA),
616 v4i32SExt10Imm:$val))]>;
619 RI10Form<0b00111000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
620 "ai\t$rT, $rA, $val", IntegerOp,
621 [(set R32C:$rT, (add R32C:$rA, i32ImmSExt10:$val))]>;
624 RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
625 "sfh\t$rT, $rA, $rB", IntegerOp,
626 [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA),
627 (v8i16 VECREG:$rB)))]>;
630 RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
631 "sfh\t$rT, $rA, $rB", IntegerOp,
632 [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>;
635 RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
636 "sfhi\t$rT, $rA, $val", IntegerOp,
637 [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val,
638 (v8i16 VECREG:$rA)))]>;
640 def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
641 "sfhi\t$rT, $rA, $val", IntegerOp,
642 [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>;
644 def SFvec : RRForm<0b00000010000, (outs VECREG:$rT),
645 (ins VECREG:$rA, VECREG:$rB),
646 "sf\t$rT, $rA, $rB", IntegerOp,
647 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
649 def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
650 "sf\t$rT, $rA, $rB", IntegerOp,
651 [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>;
654 RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
655 "sfi\t$rT, $rA, $val", IntegerOp,
656 [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val,
657 (v4i32 VECREG:$rA)))]>;
659 def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT),
660 (ins R32C:$rA, s10imm_i32:$val),
661 "sfi\t$rT, $rA, $val", IntegerOp,
662 [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>;
664 // ADDX: only available in vector form, doesn't match a pattern.
665 class ADDXInst<dag OOL, dag IOL, list<dag> pattern>:
666 RRForm<0b00000010110, OOL, IOL,
667 "addx\t$rT, $rA, $rB",
670 class ADDXVecInst<ValueType vectype>:
671 ADDXInst<(outs VECREG:$rT),
672 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
673 [(set (vectype VECREG:$rT),
674 (SPUaddx (vectype VECREG:$rA), (vectype VECREG:$rB),
675 (vectype VECREG:$rCarry)))]>,
676 RegConstraint<"$rCarry = $rT">,
679 class ADDXRegInst<RegisterClass rclass>:
680 ADDXInst<(outs rclass:$rT),
681 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
683 (SPUaddx rclass:$rA, rclass:$rB, rclass:$rCarry))]>,
684 RegConstraint<"$rCarry = $rT">,
687 multiclass AddExtended {
688 def v2i64 : ADDXVecInst<v2i64>;
689 def v4i32 : ADDXVecInst<v4i32>;
690 def r64 : ADDXRegInst<R64C>;
691 def r32 : ADDXRegInst<R32C>;
694 defm ADDX : AddExtended;
696 // CG: Generate carry for add
697 class CGInst<dag OOL, dag IOL, list<dag> pattern>:
698 RRForm<0b01000011000, OOL, IOL,
702 class CGVecInst<ValueType vectype>:
703 CGInst<(outs VECREG:$rT),
704 (ins VECREG:$rA, VECREG:$rB),
705 [(set (vectype VECREG:$rT),
706 (SPUcarry_gen (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
708 class CGRegInst<RegisterClass rclass>:
709 CGInst<(outs rclass:$rT),
710 (ins rclass:$rA, rclass:$rB),
712 (SPUcarry_gen rclass:$rA, rclass:$rB))]>;
714 multiclass CarryGenerate {
715 def v2i64 : CGVecInst<v2i64>;
716 def v4i32 : CGVecInst<v4i32>;
717 def r64 : CGRegInst<R64C>;
718 def r32 : CGRegInst<R32C>;
721 defm CG : CarryGenerate;
723 // SFX: Subract from, extended. This is used in conjunction with BG to subtract
724 // with carry (borrow, in this case)
725 class SFXInst<dag OOL, dag IOL, list<dag> pattern>:
726 RRForm<0b10000010110, OOL, IOL,
727 "sfx\t$rT, $rA, $rB",
730 class SFXVecInst<ValueType vectype>:
731 SFXInst<(outs VECREG:$rT),
732 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
733 [(set (vectype VECREG:$rT),
734 (SPUsubx (vectype VECREG:$rA), (vectype VECREG:$rB),
735 (vectype VECREG:$rCarry)))]>,
736 RegConstraint<"$rCarry = $rT">,
739 class SFXRegInst<RegisterClass rclass>:
740 SFXInst<(outs rclass:$rT),
741 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
743 (SPUsubx rclass:$rA, rclass:$rB, rclass:$rCarry))]>,
744 RegConstraint<"$rCarry = $rT">,
747 multiclass SubtractExtended {
748 def v2i64 : SFXVecInst<v2i64>;
749 def v4i32 : SFXVecInst<v4i32>;
750 def r64 : SFXRegInst<R64C>;
751 def r32 : SFXRegInst<R32C>;
754 defm SFX : SubtractExtended;
756 // BG: only available in vector form, doesn't match a pattern.
757 class BGInst<dag OOL, dag IOL, list<dag> pattern>:
758 RRForm<0b01000010000, OOL, IOL,
762 class BGVecInst<ValueType vectype>:
763 BGInst<(outs VECREG:$rT),
764 (ins VECREG:$rA, VECREG:$rB),
765 [(set (vectype VECREG:$rT),
766 (SPUborrow_gen (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
768 class BGRegInst<RegisterClass rclass>:
769 BGInst<(outs rclass:$rT),
770 (ins rclass:$rA, rclass:$rB),
772 (SPUborrow_gen rclass:$rA, rclass:$rB))]>;
774 multiclass BorrowGenerate {
775 def v4i32 : BGVecInst<v4i32>;
776 def v2i64 : BGVecInst<v2i64>;
777 def r64 : BGRegInst<R64C>;
778 def r32 : BGRegInst<R32C>;
781 defm BG : BorrowGenerate;
783 // BGX: Borrow generate, extended.
785 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
787 "bgx\t$rT, $rA, $rB", IntegerOp,
789 RegConstraint<"$rCarry = $rT">,
792 // Halfword multiply variants:
793 // N.B: These can be used to build up larger quantities (16x16 -> 32)
796 RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
797 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
798 [(set (v8i16 VECREG:$rT), (SPUmpy_vec (v8i16 VECREG:$rA),
799 (v8i16 VECREG:$rB)))]>;
802 RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
803 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
804 [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>;
806 // Unsigned 16-bit multiply:
808 class MPYUInst<dag OOL, dag IOL, list<dag> pattern>:
809 RRForm<0b00110011110, OOL, IOL,
810 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
814 MPYUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
815 [(set (v4i32 VECREG:$rT),
816 (SPUmpyu_vec (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
819 MPYUInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
820 [(set R32C:$rT, (mul (zext R16C:$rA), (zext R16C:$rB)))]>;
823 MPYUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
824 [(set R32C:$rT, (SPUmpyu_int R32C:$rA, R32C:$rB))]>;
826 // mpyi: multiply 16 x s10imm -> 32 result.
828 class MPYIInst<dag OOL, dag IOL, list<dag> pattern>:
829 RI10Form<0b00101110, OOL, IOL,
830 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
834 MPYIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
835 [(set (v8i16 VECREG:$rT),
836 (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
839 MPYIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
840 [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>;
842 // mpyui: same issues as other multiplies, plus, this doesn't match a
843 // pattern... but may be used during target DAG selection or lowering
845 class MPYUIInst<dag OOL, dag IOL, list<dag> pattern>:
846 RI10Form<0b10101110, OOL, IOL,
847 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
851 MPYUIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
855 MPYUIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
858 // mpya: 16 x 16 + 16 -> 32 bit result
859 class MPYAInst<dag OOL, dag IOL, list<dag> pattern>:
860 RRRForm<0b0011, OOL, IOL,
861 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
865 MPYAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
866 [(set (v4i32 VECREG:$rT),
867 (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA),
868 (v8i16 VECREG:$rB)))),
869 (v4i32 VECREG:$rC)))]>;
872 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
873 [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
877 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
878 [(set R32C:$rT, (add (mul (sext R16C:$rA), (sext R16C:$rB)),
881 def MPYAr32_sextinreg:
882 MPYAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC),
883 [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16),
884 (sext_inreg R32C:$rB, i16)),
887 // mpyh: multiply high, used to synthesize 32-bit multiplies
888 class MPYHInst<dag OOL, dag IOL, list<dag> pattern>:
889 RRForm<0b10100011110, OOL, IOL,
890 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
894 MPYHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
895 [(set (v4i32 VECREG:$rT),
896 (SPUmpyh_vec (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
899 MPYHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
900 [(set R32C:$rT, (SPUmpyh_int R32C:$rA, R32C:$rB))]>;
902 // mpys: multiply high and shift right (returns the top half of
903 // a 16-bit multiply, sign extended to 32 bits.)
905 RRForm<0b11100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
906 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
910 RRForm<0b11100011110, (outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
911 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
914 // mpyhh: multiply high-high (returns the 32-bit result from multiplying
915 // the top 16 bits of the $rA, $rB)
917 RRForm<0b01100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
918 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
919 [(set (v8i16 VECREG:$rT),
920 (SPUmpyhh_vec (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)))]>;
923 RRForm<0b01100011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
924 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
927 // mpyhha: Multiply high-high, add to $rT:
929 RRForm<0b01100010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
930 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
934 RRForm<0b01100010110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
935 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
938 // mpyhhu: Multiply high-high, unsigned
940 RRForm<0b01110011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
941 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
945 RRForm<0b01110011110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
946 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
949 // mpyhhau: Multiply high-high, unsigned
951 RRForm<0b01110010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
952 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
956 RRForm<0b01110010110, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
957 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
960 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
961 // v4i32, i32 multiply instruction sequence:
962 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
964 Pat<(mul (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)),
966 (Av4i32 (MPYHv4i32 VECREG:$rA, VECREG:$rB),
967 (MPYHv4i32 VECREG:$rB, VECREG:$rA)),
968 (MPYUv4i32 VECREG:$rA, VECREG:$rB))>;
971 Pat<(mul R32C:$rA, R32C:$rB),
973 (Ar32 (MPYHr32 R32C:$rA, R32C:$rB),
974 (MPYHr32 R32C:$rB, R32C:$rA)),
975 (MPYUr32 R32C:$rA, R32C:$rB))>;
977 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
978 // clz: Count leading zeroes
979 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
980 class CLZInst<dag OOL, dag IOL, list<dag> pattern>:
981 RRForm_1<0b10100101010, OOL, IOL, "clz\t$rT, $rA",
984 class CLZRegInst<RegisterClass rclass>:
985 CLZInst<(outs rclass:$rT), (ins rclass:$rA),
986 [(set rclass:$rT, (ctlz rclass:$rA))]>;
988 class CLZVecInst<ValueType vectype>:
989 CLZInst<(outs VECREG:$rT), (ins VECREG:$rA),
990 [(set (vectype VECREG:$rT), (ctlz (vectype VECREG:$rA)))]>;
992 multiclass CountLeadingZeroes {
993 def v4i32 : CLZVecInst<v4i32>;
994 def r32 : CLZRegInst<R32C>;
997 defm CLZ : CountLeadingZeroes;
999 // cntb: Count ones in bytes (aka "population count")
1001 // NOTE: This instruction is really a vector instruction, but the custom
1002 // lowering code uses it in unorthodox ways to support CTPOP for other
1006 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1007 "cntb\t$rT, $rA", IntegerOp,
1008 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
1011 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1012 "cntb\t$rT, $rA", IntegerOp,
1013 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
1016 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1017 "cntb\t$rT, $rA", IntegerOp,
1018 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
1020 // gbb: Gather the low order bits from each byte in $rA into a single 16-bit
1021 // quantity stored into $rT's slot 0, upper 16 bits are zeroed, as are
1024 // Note: This instruction "pairs" with the fsmb instruction for all of the
1025 // various types defined here.
1027 // Note 2: The "VecInst" and "RegInst" forms refer to the result being either
1028 // a vector or register.
1030 class GBBInst<dag OOL, dag IOL, list<dag> pattern>:
1031 RRForm_1<0b01001101100, OOL, IOL, "gbb\t$rT, $rA", GatherOp, pattern>;
1033 class GBBRegInst<RegisterClass rclass, ValueType vectype>:
1034 GBBInst<(outs rclass:$rT), (ins VECREG:$rA),
1035 [(set rclass:$rT, (SPUgatherbits (vectype VECREG:$rA)))]>;
1037 class GBBVecInst<ValueType vectype>:
1038 GBBInst<(outs VECREG:$rT), (ins VECREG:$rA),
1039 [(set (vectype VECREG:$rT), (SPUgatherbits (vectype VECREG:$rA)))]>;
1041 multiclass GatherBitsFromBytes {
1042 def v16i8_r32: GBBRegInst<R32C, v16i8>;
1043 def v16i8_r16: GBBRegInst<R16C, v16i8>;
1044 def v16i8: GBBVecInst<v16i8>;
1047 defm GBB: GatherBitsFromBytes;
1049 // gbh: Gather all low order bits from each halfword in $rA into a single
1050 // 8-bit quantity stored in $rT's slot 0, with the upper bits of $rT set to 0
1051 // and slots 1-3 also set to 0.
1053 // See notes for GBBInst, above.
1055 class GBHInst<dag OOL, dag IOL, list<dag> pattern>:
1056 RRForm_1<0b10001101100, OOL, IOL, "gbh\t$rT, $rA", GatherOp,
1059 class GBHRegInst<RegisterClass rclass, ValueType vectype>:
1060 GBHInst<(outs rclass:$rT), (ins VECREG:$rA),
1061 [(set rclass:$rT, (SPUgatherbits (vectype VECREG:$rA)))]>;
1063 class GBHVecInst<ValueType vectype>:
1064 GBHInst<(outs VECREG:$rT), (ins VECREG:$rA),
1065 [(set (vectype VECREG:$rT),
1066 (SPUgatherbits (vectype VECREG:$rA)))]>;
1068 multiclass GatherBitsHalfword {
1069 def v8i16_r32: GBHRegInst<R32C, v8i16>;
1070 def v8i16_r16: GBHRegInst<R16C, v8i16>;
1071 def v8i16: GBHVecInst<v8i16>;
1074 defm GBH: GatherBitsHalfword;
1076 // gb: Gather all low order bits from each word in $rA into a single
1077 // 4-bit quantity stored in $rT's slot 0, upper bits in $rT set to 0,
1078 // as well as slots 1-3.
1080 // See notes for gbb, above.
1082 class GBInst<dag OOL, dag IOL, list<dag> pattern>:
1083 RRForm_1<0b00001101100, OOL, IOL, "gb\t$rT, $rA", GatherOp,
1086 class GBRegInst<RegisterClass rclass, ValueType vectype>:
1087 GBInst<(outs rclass:$rT), (ins VECREG:$rA),
1088 [(set rclass:$rT, (SPUgatherbits (vectype VECREG:$rA)))]>;
1090 class GBVecInst<ValueType vectype>:
1091 GBInst<(outs VECREG:$rT), (ins VECREG:$rA),
1092 [(set (vectype VECREG:$rT),
1093 (SPUgatherbits (vectype VECREG:$rA)))]>;
1095 multiclass GatherBitsWord {
1096 def v4i32_r32: GBRegInst<R32C, v4i32>;
1097 def v4i32_r16: GBRegInst<R16C, v4i32>;
1098 def v4i32: GBVecInst<v4i32>;
1101 defm GB: GatherBitsWord;
1103 // avgb: average bytes
1105 RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1106 "avgb\t$rT, $rA, $rB", ByteOp,
1109 // absdb: absolute difference of bytes
1111 RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1112 "absdb\t$rT, $rA, $rB", ByteOp,
1115 // sumb: sum bytes into halfwords
1117 RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1118 "sumb\t$rT, $rA, $rB", ByteOp,
1121 // Sign extension operations:
1122 class XSBHInst<dag OOL, dag IOL, list<dag> pattern>:
1123 RRForm_1<0b01101101010, OOL, IOL,
1124 "xsbh\t$rDst, $rSrc",
1125 IntegerOp, pattern>;
1127 class XSBHVecInst<ValueType vectype>:
1128 XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1129 [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>;
1131 class XSBHInRegInst<RegisterClass rclass>:
1132 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
1133 [(set rclass:$rDst, (sext_inreg rclass:$rSrc, i8))]>;
1135 multiclass ExtendByteHalfword {
1136 def v16i8: XSBHVecInst<v8i16>;
1137 def r16: XSBHInRegInst<R16C>;
1138 def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1139 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1141 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
1142 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
1143 // pattern below). Intentionally doesn't match a pattern because we want the
1144 // sext 8->32 pattern to do the work for us, namely because we need the extra
1146 def r32: XSBHInRegInst<R32C>;
1149 defm XSBH : ExtendByteHalfword;
1151 // Sign extend halfwords to words:
1153 RRForm_1<0b01101101010, (outs VECREG:$rDest), (ins VECREG:$rSrc),
1154 "xshw\t$rDest, $rSrc", IntegerOp,
1155 [(set (v4i32 VECREG:$rDest), (sext (v8i16 VECREG:$rSrc)))]>;
1158 RRForm_1<0b01101101010, (outs R32C:$rDst), (ins R32C:$rSrc),
1159 "xshw\t$rDst, $rSrc", IntegerOp,
1160 [(set R32C:$rDst, (sext_inreg R32C:$rSrc, i16))]>;
1163 RRForm_1<0b01101101010, (outs R32C:$rDst), (ins R16C:$rSrc),
1164 "xshw\t$rDst, $rSrc", IntegerOp,
1165 [(set R32C:$rDst, (sext R16C:$rSrc))]>;
1168 RRForm_1<0b01100101010, (outs VECREG:$rDst), (ins VECREG:$rSrc),
1169 "xswd\t$rDst, $rSrc", IntegerOp,
1170 [(set (v2i64 VECREG:$rDst), (sext (v4i32 VECREG:$rSrc)))]>;
1173 RRForm_1<0b01100101010, (outs R64C:$rDst), (ins R64C:$rSrc),
1174 "xswd\t$rDst, $rSrc", IntegerOp,
1175 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1178 RRForm_1<0b01100101010, (outs R64C:$rDst), (ins R32C:$rSrc),
1179 "xswd\t$rDst, $rSrc", IntegerOp,
1180 [(set R64C:$rDst, (SPUsext32_to_64 R32C:$rSrc))]>;
1182 def : Pat<(sext R32C:$inp),
1183 (XSWDr32 R32C:$inp)>;
1187 class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1188 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1189 IntegerOp, pattern>;
1191 class ANDVecInst<ValueType vectype>:
1192 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1193 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1194 (vectype VECREG:$rB)))]>;
1196 class ANDRegInst<RegisterClass rclass>:
1197 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1198 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1200 multiclass BitwiseAnd
1202 def v16i8: ANDVecInst<v16i8>;
1203 def v8i16: ANDVecInst<v8i16>;
1204 def v4i32: ANDVecInst<v4i32>;
1205 def v2i64: ANDVecInst<v2i64>;
1207 def r128: ANDRegInst<GPRC>;
1208 def r64: ANDRegInst<R64C>;
1209 def r32: ANDRegInst<R32C>;
1210 def r16: ANDRegInst<R16C>;
1211 def r8: ANDRegInst<R8C>;
1213 //===---------------------------------------------
1214 // Special instructions to perform the fabs instruction
1215 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1216 [/* Intentionally does not match a pattern */]>;
1218 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1219 [/* Intentionally does not match a pattern */]>;
1221 // Could use v4i32, but won't for clarity
1222 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1223 [/* Intentionally does not match a pattern */]>;
1225 //===---------------------------------------------
1227 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1228 // quantities -- see 16->32 zext pattern.
1230 // This pattern is somewhat artificial, since it might match some
1231 // compiler generated pattern but it is unlikely to do so.
1233 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1234 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1237 defm AND : BitwiseAnd;
1239 // N.B.: vnot_conv is one of those special target selection pattern fragments,
1240 // in which we expect there to be a bit_convert on the constant. Bear in mind
1241 // that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1242 // constant -1 vector.)
1244 class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1245 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1246 IntegerOp, pattern>;
1248 class ANDCVecInst<ValueType vectype>:
1249 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1250 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1251 (vnot (vectype VECREG:$rB))))]>;
1253 class ANDCRegInst<RegisterClass rclass>:
1254 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1255 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
1257 multiclass AndComplement
1259 def v16i8: ANDCVecInst<v16i8>;
1260 def v8i16: ANDCVecInst<v8i16>;
1261 def v4i32: ANDCVecInst<v4i32>;
1262 def v2i64: ANDCVecInst<v2i64>;
1264 def r128: ANDCRegInst<GPRC>;
1265 def r64: ANDCRegInst<R64C>;
1266 def r32: ANDCRegInst<R32C>;
1267 def r16: ANDCRegInst<R16C>;
1268 def r8: ANDCRegInst<R8C>;
1271 defm ANDC : AndComplement;
1273 class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1274 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
1277 multiclass AndByteImm
1279 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1280 [(set (v16i8 VECREG:$rT),
1281 (and (v16i8 VECREG:$rA),
1282 (v16i8 v16i8U8Imm:$val)))]>;
1284 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1285 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1288 defm ANDBI : AndByteImm;
1290 class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1291 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
1294 multiclass AndHalfwordImm
1296 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1297 [(set (v8i16 VECREG:$rT),
1298 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
1300 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1301 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
1303 // Zero-extend i8 to i16:
1304 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1305 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1308 defm ANDHI : AndHalfwordImm;
1310 class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1311 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1312 IntegerOp, pattern>;
1314 multiclass AndWordImm
1316 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1317 [(set (v4i32 VECREG:$rT),
1318 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1320 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1321 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1323 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1325 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1327 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1329 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1330 // zext 16->32 pattern below.
1332 // Note that this pattern is somewhat artificial, since it might match
1333 // something the compiler generates but is unlikely to occur in practice.
1334 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1336 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1339 defm ANDI : AndWordImm;
1341 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1342 // Bitwise OR group:
1343 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1345 // Bitwise "or" (N.B.: These are also register-register copy instructions...)
1346 class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1347 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1348 IntegerOp, pattern>;
1350 class ORVecInst<ValueType vectype>:
1351 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1352 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1353 (vectype VECREG:$rB)))]>;
1355 class ORRegInst<RegisterClass rclass>:
1356 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1357 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
1359 // ORCvtForm: OR conversion form
1361 // This is used to "convert" the preferred slot to its vector equivalent, as
1362 // well as convert a vector back to its preferred slot.
1364 // These are effectively no-ops, but need to exist for proper type conversion
1365 // and type coercion.
1367 class ORCvtForm<dag OOL, dag IOL>
1368 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1372 let Pattern = [/* no pattern */];
1374 let Inst{0-10} = 0b10000010000;
1375 let Inst{11-17} = RA;
1376 let Inst{18-24} = RA;
1377 let Inst{25-31} = RT;
1380 class ORPromoteScalar<RegisterClass rclass>:
1381 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
1383 class ORExtractElt<RegisterClass rclass>:
1384 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1386 class ORCvtRegGPRC<RegisterClass rclass>:
1387 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>;
1390 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
1392 class ORCvtGPRCReg<RegisterClass rclass>:
1393 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>;
1396 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1398 multiclass BitwiseOr
1400 def v16i8: ORVecInst<v16i8>;
1401 def v8i16: ORVecInst<v8i16>;
1402 def v4i32: ORVecInst<v4i32>;
1403 def v2i64: ORVecInst<v2i64>;
1405 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1406 [(set (v4f32 VECREG:$rT),
1407 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1408 (v4i32 VECREG:$rB)))))]>;
1410 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1411 [(set (v2f64 VECREG:$rT),
1412 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1413 (v2i64 VECREG:$rB)))))]>;
1415 def r64: ORRegInst<R64C>;
1416 def r32: ORRegInst<R32C>;
1417 def r16: ORRegInst<R16C>;
1418 def r8: ORRegInst<R8C>;
1420 // OR instructions used to copy f32 and f64 registers.
1421 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1422 [/* no pattern */]>;
1424 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1425 [/* no pattern */]>;
1427 // scalar->vector promotion:
1428 def v16i8_i8: ORPromoteScalar<R8C>;
1429 def v8i16_i16: ORPromoteScalar<R16C>;
1430 def v4i32_i32: ORPromoteScalar<R32C>;
1431 def v2i64_i64: ORPromoteScalar<R64C>;
1432 def v4f32_f32: ORPromoteScalar<R32FP>;
1433 def v2f64_f64: ORPromoteScalar<R64FP>;
1435 // extract element 0:
1436 def i8_v16i8: ORExtractElt<R8C>;
1437 def i16_v8i16: ORExtractElt<R16C>;
1438 def i32_v4i32: ORExtractElt<R32C>;
1439 def i64_v2i64: ORExtractElt<R64C>;
1440 def f32_v4f32: ORExtractElt<R32FP>;
1441 def f64_v2f64: ORExtractElt<R64FP>;
1443 // Conversion from GPRC to register
1444 def i128_r64: ORCvtRegGPRC<R64C>;
1445 def i128_f64: ORCvtRegGPRC<R64FP>;
1446 def i128_r32: ORCvtRegGPRC<R32C>;
1447 def i128_f32: ORCvtRegGPRC<R32FP>;
1448 def i128_r16: ORCvtRegGPRC<R16C>;
1449 def i128_r8: ORCvtRegGPRC<R8C>;
1451 // Conversion from GPRC to vector
1452 def i128_vec: ORCvtVecGPRC;
1454 // Conversion from register to GPRC
1455 def r64_i128: ORCvtGPRCReg<R64C>;
1456 def f64_i128: ORCvtGPRCReg<R64FP>;
1457 def r32_i128: ORCvtGPRCReg<R32C>;
1458 def f32_i128: ORCvtGPRCReg<R32FP>;
1459 def r16_i128: ORCvtGPRCReg<R16C>;
1460 def r8_i128: ORCvtGPRCReg<R8C>;
1462 // Conversion from vector to GPRC
1463 def vec_i128: ORCvtGPRCVec;
1466 defm OR : BitwiseOr;
1468 // scalar->vector promotion patterns (preferred slot to vector):
1469 def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1470 (ORv16i8_i8 R8C:$rA)>;
1472 def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1473 (ORv8i16_i16 R16C:$rA)>;
1475 def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1476 (ORv4i32_i32 R32C:$rA)>;
1478 def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1479 (ORv2i64_i64 R64C:$rA)>;
1481 def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1482 (ORv4f32_f32 R32FP:$rA)>;
1484 def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1485 (ORv2f64_f64 R64FP:$rA)>;
1487 // ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1488 // known as converting the vector back to its preferred slot
1490 def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
1491 (ORi8_v16i8 VECREG:$rA)>;
1493 def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
1494 (ORi16_v8i16 VECREG:$rA)>;
1496 def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
1497 (ORi32_v4i32 VECREG:$rA)>;
1499 def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
1500 (ORi64_v2i64 VECREG:$rA)>;
1502 def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
1503 (ORf32_v4f32 VECREG:$rA)>;
1505 def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
1506 (ORf64_v2f64 VECREG:$rA)>;
1508 // Load Register: This is an assembler alias for a bitwise OR of a register
1509 // against itself. It's here because it brings some clarity to assembly
1512 let hasCtrlDep = 1 in {
1513 class LRInst<dag OOL, dag IOL>
1514 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1518 let Pattern = [/*no pattern*/];
1520 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1521 let Inst{11-17} = RA;
1522 let Inst{18-24} = RA;
1523 let Inst{25-31} = RT;
1526 class LRVecInst<ValueType vectype>:
1527 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1529 class LRRegInst<RegisterClass rclass>:
1530 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1532 multiclass LoadRegister {
1533 def v2i64: LRVecInst<v2i64>;
1534 def v2f64: LRVecInst<v2f64>;
1535 def v4i32: LRVecInst<v4i32>;
1536 def v4f32: LRVecInst<v4f32>;
1537 def v8i16: LRVecInst<v8i16>;
1538 def v16i8: LRVecInst<v16i8>;
1540 def r128: LRRegInst<GPRC>;
1541 def r64: LRRegInst<R64C>;
1542 def f64: LRRegInst<R64FP>;
1543 def r32: LRRegInst<R32C>;
1544 def f32: LRRegInst<R32FP>;
1545 def r16: LRRegInst<R16C>;
1546 def r8: LRRegInst<R8C>;
1549 defm LR: LoadRegister;
1552 // ORC: Bitwise "or" with complement (c = a | ~b)
1554 class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1555 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1556 IntegerOp, pattern>;
1558 class ORCVecInst<ValueType vectype>:
1559 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1560 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1561 (vnot (vectype VECREG:$rB))))]>;
1563 class ORCRegInst<RegisterClass rclass>:
1564 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1565 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
1567 multiclass BitwiseOrComplement
1569 def v16i8: ORCVecInst<v16i8>;
1570 def v8i16: ORCVecInst<v8i16>;
1571 def v4i32: ORCVecInst<v4i32>;
1572 def v2i64: ORCVecInst<v2i64>;
1574 def r64: ORCRegInst<R64C>;
1575 def r32: ORCRegInst<R32C>;
1576 def r16: ORCRegInst<R16C>;
1577 def r8: ORCRegInst<R8C>;
1580 defm ORC : BitwiseOrComplement;
1582 // OR byte immediate
1583 class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1584 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1585 IntegerOp, pattern>;
1587 class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1588 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1589 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1590 (vectype immpred:$val)))]>;
1592 multiclass BitwiseOrByteImm
1594 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1596 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1597 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1600 defm ORBI : BitwiseOrByteImm;
1602 // OR halfword immediate
1603 class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1604 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1605 IntegerOp, pattern>;
1607 class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1608 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1609 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1612 multiclass BitwiseOrHalfwordImm
1614 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1616 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1617 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1619 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1620 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1621 [(set R16C:$rT, (or (anyext R8C:$rA),
1622 i16ImmSExt10:$val))]>;
1625 defm ORHI : BitwiseOrHalfwordImm;
1627 class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1628 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1629 IntegerOp, pattern>;
1631 class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1632 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1633 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1636 // Bitwise "or" with immediate
1637 multiclass BitwiseOrImm
1639 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
1641 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1642 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
1644 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1645 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1646 // infra "anyext 16->32" pattern.)
1647 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1648 [(set R32C:$rT, (or (anyext R16C:$rA),
1649 i32ImmSExt10:$val))]>;
1651 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1652 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1653 // infra "anyext 16->32" pattern.)
1654 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1655 [(set R32C:$rT, (or (anyext R8C:$rA),
1656 i32ImmSExt10:$val))]>;
1659 defm ORI : BitwiseOrImm;
1661 // ORX: "or" across the vector: or's $rA's word slots leaving the result in
1662 // $rT[0], slots 1-3 are zeroed.
1664 // FIXME: Needs to match an intrinsic pattern.
1666 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1667 "orx\t$rT, $rA, $rB", IntegerOp,
1672 class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1673 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1674 IntegerOp, pattern>;
1676 class XORVecInst<ValueType vectype>:
1677 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1678 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1679 (vectype VECREG:$rB)))]>;
1681 class XORRegInst<RegisterClass rclass>:
1682 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1683 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1685 multiclass BitwiseExclusiveOr
1687 def v16i8: XORVecInst<v16i8>;
1688 def v8i16: XORVecInst<v8i16>;
1689 def v4i32: XORVecInst<v4i32>;
1690 def v2i64: XORVecInst<v2i64>;
1692 def r128: XORRegInst<GPRC>;
1693 def r64: XORRegInst<R64C>;
1694 def r32: XORRegInst<R32C>;
1695 def r16: XORRegInst<R16C>;
1696 def r8: XORRegInst<R8C>;
1698 // Special forms for floating point instructions.
1699 // fneg and fabs require bitwise logical ops to manipulate the sign bit.
1701 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1702 [/* no pattern */]>;
1704 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1705 [/* no pattern */]>;
1707 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1708 [/* no pattern, see fneg{32,64} */]>;
1711 defm XOR : BitwiseExclusiveOr;
1713 //==----------------------------------------------------------
1715 class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1716 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1717 IntegerOp, pattern>;
1719 multiclass XorByteImm
1722 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1723 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1726 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1727 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1730 defm XORBI : XorByteImm;
1733 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1734 "xorhi\t$rT, $rA, $val", IntegerOp,
1735 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1736 v8i16SExt10Imm:$val))]>;
1739 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1740 "xorhi\t$rT, $rA, $val", IntegerOp,
1741 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1744 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
1745 "xori\t$rT, $rA, $val", IntegerOp,
1746 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1747 v4i32SExt10Imm:$val))]>;
1750 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1751 "xori\t$rT, $rA, $val", IntegerOp,
1752 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1756 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1757 "nand\t$rT, $rA, $rB", IntegerOp,
1758 [(set (v16i8 VECREG:$rT), (vnot (and (v16i8 VECREG:$rA),
1759 (v16i8 VECREG:$rB))))]>;
1762 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1763 "nand\t$rT, $rA, $rB", IntegerOp,
1764 [(set (v8i16 VECREG:$rT), (vnot (and (v8i16 VECREG:$rA),
1765 (v8i16 VECREG:$rB))))]>;
1768 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1769 "nand\t$rT, $rA, $rB", IntegerOp,
1770 [(set (v4i32 VECREG:$rT), (vnot (and (v4i32 VECREG:$rA),
1771 (v4i32 VECREG:$rB))))]>;
1774 RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1775 "nand\t$rT, $rA, $rB", IntegerOp,
1776 [(set R32C:$rT, (not (and R32C:$rA, R32C:$rB)))]>;
1779 RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1780 "nand\t$rT, $rA, $rB", IntegerOp,
1781 [(set R16C:$rT, (not (and R16C:$rA, R16C:$rB)))]>;
1784 RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
1785 "nand\t$rT, $rA, $rB", IntegerOp,
1786 [(set R8C:$rT, (not (and R8C:$rA, R8C:$rB)))]>;
1790 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1791 "nor\t$rT, $rA, $rB", IntegerOp,
1792 [(set (v16i8 VECREG:$rT), (vnot (or (v16i8 VECREG:$rA),
1793 (v16i8 VECREG:$rB))))]>;
1796 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1797 "nor\t$rT, $rA, $rB", IntegerOp,
1798 [(set (v8i16 VECREG:$rT), (vnot (or (v8i16 VECREG:$rA),
1799 (v8i16 VECREG:$rB))))]>;
1802 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1803 "nor\t$rT, $rA, $rB", IntegerOp,
1804 [(set (v4i32 VECREG:$rT), (vnot (or (v4i32 VECREG:$rA),
1805 (v4i32 VECREG:$rB))))]>;
1808 RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1809 "nor\t$rT, $rA, $rB", IntegerOp,
1810 [(set R32C:$rT, (not (or R32C:$rA, R32C:$rB)))]>;
1813 RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1814 "nor\t$rT, $rA, $rB", IntegerOp,
1815 [(set R16C:$rT, (not (or R16C:$rA, R16C:$rB)))]>;
1818 RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
1819 "nor\t$rT, $rA, $rB", IntegerOp,
1820 [(set R8C:$rT, (not (or R8C:$rA, R8C:$rB)))]>;
1823 class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1824 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1825 IntegerOp, pattern>;
1827 class SELBVecInst<ValueType vectype>:
1828 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1829 [(set (vectype VECREG:$rT),
1830 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
1831 (and (vnot (vectype VECREG:$rC)),
1832 (vectype VECREG:$rA))))]>;
1834 class SELBVecCondInst<ValueType vectype>:
1835 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1836 [(set (vectype VECREG:$rT),
1838 (vectype VECREG:$rB),
1839 (vectype VECREG:$rA)))]>;
1841 class SELBRegInst<RegisterClass rclass>:
1842 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1844 (or (and rclass:$rB, rclass:$rC),
1845 (and rclass:$rA, (not rclass:$rC))))]>;
1847 class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1848 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1850 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1852 multiclass SelectBits
1854 def v16i8: SELBVecInst<v16i8>;
1855 def v8i16: SELBVecInst<v8i16>;
1856 def v4i32: SELBVecInst<v4i32>;
1857 def v2i64: SELBVecInst<v2i64>;
1859 def r128: SELBRegInst<GPRC>;
1860 def r64: SELBRegInst<R64C>;
1861 def r32: SELBRegInst<R32C>;
1862 def r16: SELBRegInst<R16C>;
1863 def r8: SELBRegInst<R8C>;
1865 def v16i8_cond: SELBVecCondInst<v16i8>;
1866 def v8i16_cond: SELBVecCondInst<v8i16>;
1867 def v4i32_cond: SELBVecCondInst<v4i32>;
1868 def v2i64_cond: SELBVecCondInst<v2i64>;
1870 // SELBr64_cond is defined further down, look for i64 comparisons
1871 def r32_cond: SELBRegCondInst<R32C, R32C>;
1872 def r16_cond: SELBRegCondInst<R16C, R16C>;
1873 def r8_cond: SELBRegCondInst<R8C, R8C>;
1876 defm SELB : SelectBits;
1878 class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
1879 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1880 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
1882 def : SPUselbPatVec<v16i8, SELBv16i8>;
1883 def : SPUselbPatVec<v8i16, SELBv8i16>;
1884 def : SPUselbPatVec<v4i32, SELBv4i32>;
1885 def : SPUselbPatVec<v2i64, SELBv2i64>;
1887 class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1888 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1889 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1891 def : SPUselbPatReg<R8C, SELBr8>;
1892 def : SPUselbPatReg<R16C, SELBr16>;
1893 def : SPUselbPatReg<R32C, SELBr32>;
1894 def : SPUselbPatReg<R64C, SELBr64>;
1896 // EQV: Equivalence (1 for each same bit, otherwise 0)
1898 // Note: There are a lot of ways to match this bit operator and these patterns
1899 // attempt to be as exhaustive as possible.
1901 class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
1902 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
1903 IntegerOp, pattern>;
1905 class EQVVecInst<ValueType vectype>:
1906 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1907 [(set (vectype VECREG:$rT),
1908 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
1909 (and (vnot (vectype VECREG:$rA)),
1910 (vnot (vectype VECREG:$rB)))))]>;
1912 class EQVRegInst<RegisterClass rclass>:
1913 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1914 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
1915 (and (not rclass:$rA), (not rclass:$rB))))]>;
1917 class EQVVecPattern1<ValueType vectype>:
1918 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1919 [(set (vectype VECREG:$rT),
1920 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
1922 class EQVRegPattern1<RegisterClass rclass>:
1923 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1924 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
1926 class EQVVecPattern2<ValueType vectype>:
1927 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1928 [(set (vectype VECREG:$rT),
1929 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
1930 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
1932 class EQVRegPattern2<RegisterClass rclass>:
1933 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1935 (or (and rclass:$rA, rclass:$rB),
1936 (not (or rclass:$rA, rclass:$rB))))]>;
1938 class EQVVecPattern3<ValueType vectype>:
1939 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1940 [(set (vectype VECREG:$rT),
1941 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
1943 class EQVRegPattern3<RegisterClass rclass>:
1944 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1945 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
1947 multiclass BitEquivalence
1949 def v16i8: EQVVecInst<v16i8>;
1950 def v8i16: EQVVecInst<v8i16>;
1951 def v4i32: EQVVecInst<v4i32>;
1952 def v2i64: EQVVecInst<v2i64>;
1954 def v16i8_1: EQVVecPattern1<v16i8>;
1955 def v8i16_1: EQVVecPattern1<v8i16>;
1956 def v4i32_1: EQVVecPattern1<v4i32>;
1957 def v2i64_1: EQVVecPattern1<v2i64>;
1959 def v16i8_2: EQVVecPattern2<v16i8>;
1960 def v8i16_2: EQVVecPattern2<v8i16>;
1961 def v4i32_2: EQVVecPattern2<v4i32>;
1962 def v2i64_2: EQVVecPattern2<v2i64>;
1964 def v16i8_3: EQVVecPattern3<v16i8>;
1965 def v8i16_3: EQVVecPattern3<v8i16>;
1966 def v4i32_3: EQVVecPattern3<v4i32>;
1967 def v2i64_3: EQVVecPattern3<v2i64>;
1969 def r128: EQVRegInst<GPRC>;
1970 def r64: EQVRegInst<R64C>;
1971 def r32: EQVRegInst<R32C>;
1972 def r16: EQVRegInst<R16C>;
1973 def r8: EQVRegInst<R8C>;
1975 def r128_1: EQVRegPattern1<GPRC>;
1976 def r64_1: EQVRegPattern1<R64C>;
1977 def r32_1: EQVRegPattern1<R32C>;
1978 def r16_1: EQVRegPattern1<R16C>;
1979 def r8_1: EQVRegPattern1<R8C>;
1981 def r128_2: EQVRegPattern2<GPRC>;
1982 def r64_2: EQVRegPattern2<R64C>;
1983 def r32_2: EQVRegPattern2<R32C>;
1984 def r16_2: EQVRegPattern2<R16C>;
1985 def r8_2: EQVRegPattern2<R8C>;
1987 def r128_3: EQVRegPattern3<GPRC>;
1988 def r64_3: EQVRegPattern3<R64C>;
1989 def r32_3: EQVRegPattern3<R32C>;
1990 def r16_3: EQVRegPattern3<R16C>;
1991 def r8_3: EQVRegPattern3<R8C>;
1994 defm EQV: BitEquivalence;
1996 //===----------------------------------------------------------------------===//
1997 // Vector shuffle...
1998 //===----------------------------------------------------------------------===//
1999 // SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2000 // See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2001 // matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2002 // the SPUISD::SHUFB opcode.
2003 //===----------------------------------------------------------------------===//
2005 class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2006 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2007 IntegerOp, pattern>;
2009 class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
2010 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
2011 [(set (resultvec VECREG:$rT),
2012 (SPUshuffle (resultvec VECREG:$rA),
2013 (resultvec VECREG:$rB),
2014 (maskvec VECREG:$rC)))]>;
2016 class SHUFBGPRCInst:
2017 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2018 [/* no pattern */]>;
2020 multiclass ShuffleBytes
2022 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2023 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2024 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2025 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2026 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2027 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2028 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2029 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
2031 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2032 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2034 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2035 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
2037 def gprc : SHUFBGPRCInst;
2040 defm SHUFB : ShuffleBytes;
2042 //===----------------------------------------------------------------------===//
2043 // Shift and rotate group:
2044 //===----------------------------------------------------------------------===//
2046 class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2047 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2048 RotateShift, pattern>;
2050 class SHLHVecInst<ValueType vectype>:
2051 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2052 [(set (vectype VECREG:$rT),
2053 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
2055 // $rB gets promoted to 32-bit register type when confronted with
2056 // this llvm assembly code:
2058 // define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
2059 // %A = shl i16 %arg1, %arg2
2063 multiclass ShiftLeftHalfword
2065 def v8i16: SHLHVecInst<v8i16>;
2066 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2067 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2068 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2069 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2072 defm SHLH : ShiftLeftHalfword;
2074 //===----------------------------------------------------------------------===//
2076 class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2077 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2078 RotateShift, pattern>;
2080 class SHLHIVecInst<ValueType vectype>:
2081 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2082 [(set (vectype VECREG:$rT),
2083 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2085 multiclass ShiftLeftHalfwordImm
2087 def v8i16: SHLHIVecInst<v8i16>;
2088 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2089 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2092 defm SHLHI : ShiftLeftHalfwordImm;
2094 def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2095 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
2097 def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
2098 (SHLHIr16 R16C:$rA, uimm7:$val)>;
2100 //===----------------------------------------------------------------------===//
2102 class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2103 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2104 RotateShift, pattern>;
2106 multiclass ShiftLeftWord
2109 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2110 [(set (v4i32 VECREG:$rT),
2111 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2113 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2114 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2117 defm SHL: ShiftLeftWord;
2119 //===----------------------------------------------------------------------===//
2121 class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2122 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2123 RotateShift, pattern>;
2125 multiclass ShiftLeftWordImm
2128 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2129 [(set (v4i32 VECREG:$rT),
2130 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
2133 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2134 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2137 defm SHLI : ShiftLeftWordImm;
2139 //===----------------------------------------------------------------------===//
2140 // SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2141 // register) to the left. Vector form is here to ensure type correctness.
2143 // The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2144 // of 7 bits is actually possible.
2146 // Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2147 // to shift i64 and i128. SHLQBI is the residual left over after shifting by
2148 // bytes with SHLQBY.
2150 class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2151 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2152 RotateShift, pattern>;
2154 class SHLQBIVecInst<ValueType vectype>:
2155 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2156 [(set (vectype VECREG:$rT),
2157 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2159 multiclass ShiftLeftQuadByBits
2161 def v16i8: SHLQBIVecInst<v16i8>;
2162 def v8i16: SHLQBIVecInst<v8i16>;
2163 def v4i32: SHLQBIVecInst<v4i32>;
2164 def v4f32: SHLQBIVecInst<v4f32>;
2165 def v2i64: SHLQBIVecInst<v2i64>;
2166 def v2f64: SHLQBIVecInst<v2f64>;
2169 defm SHLQBI : ShiftLeftQuadByBits;
2171 // See note above on SHLQBI. In this case, the predicate actually does then
2172 // enforcement, whereas with SHLQBI, we have to "take it on faith."
2173 class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2174 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2175 RotateShift, pattern>;
2177 class SHLQBIIVecInst<ValueType vectype>:
2178 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2179 [(set (vectype VECREG:$rT),
2180 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2182 multiclass ShiftLeftQuadByBitsImm
2184 def v16i8 : SHLQBIIVecInst<v16i8>;
2185 def v8i16 : SHLQBIIVecInst<v8i16>;
2186 def v4i32 : SHLQBIIVecInst<v4i32>;
2187 def v4f32 : SHLQBIIVecInst<v4f32>;
2188 def v2i64 : SHLQBIIVecInst<v2i64>;
2189 def v2f64 : SHLQBIIVecInst<v2f64>;
2192 defm SHLQBII : ShiftLeftQuadByBitsImm;
2194 // SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
2195 // not by bits. See notes above on SHLQBI.
2197 class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2198 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
2199 RotateShift, pattern>;
2201 class SHLQBYVecInst<ValueType vectype>:
2202 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2203 [(set (vectype VECREG:$rT),
2204 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
2206 multiclass ShiftLeftQuadBytes
2208 def v16i8: SHLQBYVecInst<v16i8>;
2209 def v8i16: SHLQBYVecInst<v8i16>;
2210 def v4i32: SHLQBYVecInst<v4i32>;
2211 def v4f32: SHLQBYVecInst<v4f32>;
2212 def v2i64: SHLQBYVecInst<v2i64>;
2213 def v2f64: SHLQBYVecInst<v2f64>;
2214 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2215 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2218 defm SHLQBY: ShiftLeftQuadBytes;
2220 class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2221 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2222 RotateShift, pattern>;
2224 class SHLQBYIVecInst<ValueType vectype>:
2225 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2226 [(set (vectype VECREG:$rT),
2227 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2229 multiclass ShiftLeftQuadBytesImm
2231 def v16i8: SHLQBYIVecInst<v16i8>;
2232 def v8i16: SHLQBYIVecInst<v8i16>;
2233 def v4i32: SHLQBYIVecInst<v4i32>;
2234 def v4f32: SHLQBYIVecInst<v4f32>;
2235 def v2i64: SHLQBYIVecInst<v2i64>;
2236 def v2f64: SHLQBYIVecInst<v2f64>;
2237 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2239 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2242 defm SHLQBYI : ShiftLeftQuadBytesImm;
2244 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2246 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2247 class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2248 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2249 RotateShift, pattern>;
2251 class ROTHVecInst<ValueType vectype>:
2252 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2253 [(set (vectype VECREG:$rT),
2254 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
2256 class ROTHRegInst<RegisterClass rclass>:
2257 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2258 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2260 multiclass RotateLeftHalfword
2262 def v8i16: ROTHVecInst<v8i16>;
2263 def r16: ROTHRegInst<R16C>;
2266 defm ROTH: RotateLeftHalfword;
2268 def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2269 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2271 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2272 // Rotate halfword, immediate:
2273 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2274 class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2275 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2276 RotateShift, pattern>;
2278 class ROTHIVecInst<ValueType vectype>:
2279 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2280 [(set (vectype VECREG:$rT),
2281 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2283 multiclass RotateLeftHalfwordImm
2285 def v8i16: ROTHIVecInst<v8i16>;
2286 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2287 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2288 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2289 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2292 defm ROTHI: RotateLeftHalfwordImm;
2294 def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
2295 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
2297 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2299 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2301 class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2302 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2303 RotateShift, pattern>;
2305 class ROTVecInst<ValueType vectype>:
2306 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2307 [(set (vectype VECREG:$rT),
2308 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
2310 class ROTRegInst<RegisterClass rclass>:
2311 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2313 (rotl rclass:$rA, R32C:$rB))]>;
2315 multiclass RotateLeftWord
2317 def v4i32: ROTVecInst<v4i32>;
2318 def r32: ROTRegInst<R32C>;
2321 defm ROT: RotateLeftWord;
2323 // The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2325 def ROTr32_r16_anyext:
2326 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2327 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
2329 def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2330 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2332 def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2333 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2335 def ROTr32_r8_anyext:
2336 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2337 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
2339 def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2340 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2342 def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2343 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2345 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2346 // Rotate word, immediate
2347 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2349 class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2350 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2351 RotateShift, pattern>;
2353 class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2354 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2355 [(set (vectype VECREG:$rT),
2356 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
2358 class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2359 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2360 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
2362 multiclass RotateLeftWordImm
2364 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2365 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2366 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
2368 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2369 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2370 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2373 defm ROTI : RotateLeftWordImm;
2375 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2376 // Rotate quad by byte (count)
2377 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2379 class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2380 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2381 RotateShift, pattern>;
2383 class ROTQBYVecInst<ValueType vectype>:
2384 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2385 [(set (vectype VECREG:$rT),
2386 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2388 multiclass RotateQuadLeftByBytes
2390 def v16i8: ROTQBYVecInst<v16i8>;
2391 def v8i16: ROTQBYVecInst<v8i16>;
2392 def v4i32: ROTQBYVecInst<v4i32>;
2393 def v4f32: ROTQBYVecInst<v4f32>;
2394 def v2i64: ROTQBYVecInst<v2i64>;
2395 def v2f64: ROTQBYVecInst<v2f64>;
2398 defm ROTQBY: RotateQuadLeftByBytes;
2400 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2401 // Rotate quad by byte (count), immediate
2402 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2404 class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2405 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2406 RotateShift, pattern>;
2408 class ROTQBYIVecInst<ValueType vectype>:
2409 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2410 [(set (vectype VECREG:$rT),
2411 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2413 multiclass RotateQuadByBytesImm
2415 def v16i8: ROTQBYIVecInst<v16i8>;
2416 def v8i16: ROTQBYIVecInst<v8i16>;
2417 def v4i32: ROTQBYIVecInst<v4i32>;
2418 def v4f32: ROTQBYIVecInst<v4f32>;
2419 def v2i64: ROTQBYIVecInst<v2i64>;
2420 def vfi64: ROTQBYIVecInst<v2f64>;
2423 defm ROTQBYI: RotateQuadByBytesImm;
2425 // See ROTQBY note above.
2426 class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2427 RI7Form<0b00110011100, OOL, IOL,
2428 "rotqbybi\t$rT, $rA, $shift",
2429 RotateShift, pattern>;
2431 class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2432 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2433 [(set (vectype VECREG:$rT),
2434 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2436 multiclass RotateQuadByBytesByBitshift {
2437 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2438 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2439 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2440 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2443 defm ROTQBYBI : RotateQuadByBytesByBitshift;
2445 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2446 // See ROTQBY note above.
2448 // Assume that the user of this instruction knows to shift the rotate count
2450 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2452 class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2453 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2454 RotateShift, pattern>;
2456 class ROTQBIVecInst<ValueType vectype>:
2457 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2458 [/* no pattern yet */]>;
2460 class ROTQBIRegInst<RegisterClass rclass>:
2461 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2462 [/* no pattern yet */]>;
2464 multiclass RotateQuadByBitCount
2466 def v16i8: ROTQBIVecInst<v16i8>;
2467 def v8i16: ROTQBIVecInst<v8i16>;
2468 def v4i32: ROTQBIVecInst<v4i32>;
2469 def v2i64: ROTQBIVecInst<v2i64>;
2471 def r128: ROTQBIRegInst<GPRC>;
2472 def r64: ROTQBIRegInst<R64C>;
2475 defm ROTQBI: RotateQuadByBitCount;
2477 class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2478 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2479 RotateShift, pattern>;
2481 class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2483 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2484 [/* no pattern yet */]>;
2486 class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2488 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2489 [/* no pattern yet */]>;
2491 multiclass RotateQuadByBitCountImm
2493 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2494 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2495 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2496 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2498 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2499 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2502 defm ROTQBII : RotateQuadByBitCountImm;
2504 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2505 // ROTHM v8i16 form:
2506 // NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2507 // so this only matches a synthetically generated/lowered code
2509 // NOTE(2): $rB must be negated before the right rotate!
2510 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2512 class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2513 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2514 RotateShift, pattern>;
2517 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2518 [/* see patterns below - $rB must be negated */]>;
2520 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
2521 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2523 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
2524 (ROTHMv8i16 VECREG:$rA,
2525 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2527 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
2528 (ROTHMv8i16 VECREG:$rA,
2529 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2531 // ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2532 // Note: This instruction doesn't match a pattern because rB must be negated
2533 // for the instruction to work. Thus, the pattern below the instruction!
2536 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2537 [/* see patterns below - $rB must be negated! */]>;
2539 def : Pat<(srl R16C:$rA, R32C:$rB),
2540 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2542 def : Pat<(srl R16C:$rA, R16C:$rB),
2544 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2546 def : Pat<(srl R16C:$rA, R8C:$rB),
2548 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2550 // ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2551 // that the immediate can be complemented, so that the user doesn't have to
2554 class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2555 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2556 RotateShift, pattern>;
2559 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2560 [/* no pattern */]>;
2562 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2563 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2565 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
2566 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2568 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
2569 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2572 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2573 [/* no pattern */]>;
2575 def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2576 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2578 def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2579 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2581 def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2582 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2584 // ROTM v4i32 form: See the ROTHM v8i16 comments.
2585 class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2586 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2587 RotateShift, pattern>;
2590 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2591 [/* see patterns below - $rB must be negated */]>;
2593 def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
2594 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2596 def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
2597 (ROTMv4i32 VECREG:$rA,
2598 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2600 def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
2601 (ROTMv4i32 VECREG:$rA,
2602 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2605 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2606 [/* see patterns below - $rB must be negated */]>;
2608 def : Pat<(srl R32C:$rA, R32C:$rB),
2609 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2611 def : Pat<(srl R32C:$rA, R16C:$rB),
2613 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2615 def : Pat<(srl R32C:$rA, R8C:$rB),
2617 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2619 // ROTMI v4i32 form: See the comment for ROTHM v8i16.
2621 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2622 "rotmi\t$rT, $rA, $val", RotateShift,
2623 [(set (v4i32 VECREG:$rT),
2624 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
2626 def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
2627 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2629 def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
2630 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2632 // ROTMI r32 form: know how to complement the immediate value.
2634 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2635 "rotmi\t$rT, $rA, $val", RotateShift,
2636 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2638 def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2639 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2641 def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2642 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2644 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2645 // ROTQMBYvec: This is a vector form merely so that when used in an
2646 // instruction pattern, type checking will succeed. This instruction assumes
2647 // that the user knew to negate $rB.
2649 // Using the SPUrotquad_rz_bytes target-specific DAG node, the patterns
2650 // ensure that $rB is negated.
2651 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2653 class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2654 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2655 RotateShift, pattern>;
2657 class ROTQMBYVecInst<ValueType vectype>:
2658 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2659 [/* no pattern, $rB must be negated */]>;
2661 class ROTQMBYRegInst<RegisterClass rclass>:
2662 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2664 (SPUrotquad_rz_bytes rclass:$rA, R32C:$rB))]>;
2666 multiclass RotateQuadBytes
2668 def v16i8: ROTQMBYVecInst<v16i8>;
2669 def v8i16: ROTQMBYVecInst<v8i16>;
2670 def v4i32: ROTQMBYVecInst<v4i32>;
2671 def v2i64: ROTQMBYVecInst<v2i64>;
2673 def r128: ROTQMBYRegInst<GPRC>;
2674 def r64: ROTQMBYRegInst<R64C>;
2677 defm ROTQMBY : RotateQuadBytes;
2679 def : Pat<(SPUrotquad_rz_bytes (v16i8 VECREG:$rA), R32C:$rB),
2680 (ROTQMBYv16i8 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2681 def : Pat<(SPUrotquad_rz_bytes (v8i16 VECREG:$rA), R32C:$rB),
2682 (ROTQMBYv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2683 def : Pat<(SPUrotquad_rz_bytes (v4i32 VECREG:$rA), R32C:$rB),
2684 (ROTQMBYv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2685 def : Pat<(SPUrotquad_rz_bytes (v2i64 VECREG:$rA), R32C:$rB),
2686 (ROTQMBYv2i64 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2687 def : Pat<(SPUrotquad_rz_bytes GPRC:$rA, R32C:$rB),
2688 (ROTQMBYr128 GPRC:$rA, (SFIr32 R32C:$rB, 0))>;
2689 def : Pat<(SPUrotquad_rz_bytes R64C:$rA, R32C:$rB),
2690 (ROTQMBYr64 R64C:$rA, (SFIr32 R32C:$rB, 0))>;
2692 class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2693 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2694 RotateShift, pattern>;
2696 class ROTQMBYIVecInst<ValueType vectype>:
2697 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2698 [(set (vectype VECREG:$rT),
2699 (SPUrotquad_rz_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2701 class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2702 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2704 (SPUrotquad_rz_bytes rclass:$rA, (inttype pred:$val)))]>;
2706 multiclass RotateQuadBytesImm
2708 def v16i8: ROTQMBYIVecInst<v16i8>;
2709 def v8i16: ROTQMBYIVecInst<v8i16>;
2710 def v4i32: ROTQMBYIVecInst<v4i32>;
2711 def v2i64: ROTQMBYIVecInst<v2i64>;
2713 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2714 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
2717 defm ROTQMBYI : RotateQuadBytesImm;
2719 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2720 // Rotate right and mask by bit count
2721 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2723 class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2724 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2725 RotateShift, pattern>;
2727 class ROTQMBYBIVecInst<ValueType vectype>:
2728 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2729 [/* no pattern, intrinsic? */]>;
2731 multiclass RotateMaskQuadByBitCount
2733 def v16i8: ROTQMBYBIVecInst<v16i8>;
2734 def v8i16: ROTQMBYBIVecInst<v8i16>;
2735 def v4i32: ROTQMBYBIVecInst<v4i32>;
2736 def v2i64: ROTQMBYBIVecInst<v2i64>;
2739 defm ROTQMBYBI: RotateMaskQuadByBitCount;
2741 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2742 // Rotate quad and mask by bits
2743 // Note that the rotate amount has to be negated
2744 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2746 class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2747 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2748 RotateShift, pattern>;
2750 class ROTQMBIVecInst<ValueType vectype>:
2751 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2752 [/* no pattern */]>;
2754 class ROTQMBIRegInst<RegisterClass rclass>:
2755 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2756 [/* no pattern */]>;
2758 multiclass RotateMaskQuadByBits
2760 def v16i8: ROTQMBIVecInst<v16i8>;
2761 def v8i16: ROTQMBIVecInst<v8i16>;
2762 def v4i32: ROTQMBIVecInst<v4i32>;
2763 def v2i64: ROTQMBIVecInst<v2i64>;
2765 def r128: ROTQMBIRegInst<GPRC>;
2766 def r64: ROTQMBIRegInst<R64C>;
2769 defm ROTQMBI: RotateMaskQuadByBits;
2771 def : Pat<(SPUrotquad_rz_bits (v16i8 VECREG:$rA), R32C:$rB),
2772 (ROTQMBIv16i8 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2773 def : Pat<(SPUrotquad_rz_bits (v8i16 VECREG:$rA), R32C:$rB),
2774 (ROTQMBIv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2775 def : Pat<(SPUrotquad_rz_bits (v4i32 VECREG:$rA), R32C:$rB),
2776 (ROTQMBIv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2777 def : Pat<(SPUrotquad_rz_bits (v2i64 VECREG:$rA), R32C:$rB),
2778 (ROTQMBIv2i64 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2779 def : Pat<(SPUrotquad_rz_bits GPRC:$rA, R32C:$rB),
2780 (ROTQMBIr128 GPRC:$rA, (SFIr32 R32C:$rB, 0))>;
2781 def : Pat<(SPUrotquad_rz_bits R64C:$rA, R32C:$rB),
2782 (ROTQMBIr64 R64C:$rA, (SFIr32 R32C:$rB, 0))>;
2784 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2785 // Rotate quad and mask by bits, immediate
2786 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2788 class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2789 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2790 RotateShift, pattern>;
2792 class ROTQMBIIVecInst<ValueType vectype>:
2793 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2794 [(set (vectype VECREG:$rT),
2795 (SPUrotquad_rz_bits (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2797 class ROTQMBIIRegInst<RegisterClass rclass>:
2798 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
2800 (SPUrotquad_rz_bits rclass:$rA, (i32 uimm7:$val)))]>;
2802 multiclass RotateMaskQuadByBitsImm
2804 def v16i8: ROTQMBIIVecInst<v16i8>;
2805 def v8i16: ROTQMBIIVecInst<v8i16>;
2806 def v4i32: ROTQMBIIVecInst<v4i32>;
2807 def v2i64: ROTQMBIIVecInst<v2i64>;
2809 def r128: ROTQMBIIRegInst<GPRC>;
2810 def r64: ROTQMBIIRegInst<R64C>;
2813 defm ROTQMBII: RotateMaskQuadByBitsImm;
2815 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2816 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2819 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2820 "rotmah\t$rT, $rA, $rB", RotateShift,
2821 [/* see patterns below - $rB must be negated */]>;
2823 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2824 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2826 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2827 (ROTMAHv8i16 VECREG:$rA,
2828 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2830 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2831 (ROTMAHv8i16 VECREG:$rA,
2832 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2835 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2836 "rotmah\t$rT, $rA, $rB", RotateShift,
2837 [/* see patterns below - $rB must be negated */]>;
2839 def : Pat<(sra R16C:$rA, R32C:$rB),
2840 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2842 def : Pat<(sra R16C:$rA, R16C:$rB),
2843 (ROTMAHr16 R16C:$rA,
2844 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2846 def : Pat<(sra R16C:$rA, R8C:$rB),
2847 (ROTMAHr16 R16C:$rA,
2848 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2851 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2852 "rotmahi\t$rT, $rA, $val", RotateShift,
2853 [(set (v8i16 VECREG:$rT),
2854 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
2856 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
2857 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2859 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
2860 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2863 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2864 "rotmahi\t$rT, $rA, $val", RotateShift,
2865 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2867 def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2868 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2870 def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2871 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2874 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2875 "rotma\t$rT, $rA, $rB", RotateShift,
2876 [/* see patterns below - $rB must be negated */]>;
2878 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2879 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2881 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2882 (ROTMAv4i32 (v4i32 VECREG:$rA),
2883 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2885 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2886 (ROTMAv4i32 (v4i32 VECREG:$rA),
2887 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2890 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2891 "rotma\t$rT, $rA, $rB", RotateShift,
2892 [/* see patterns below - $rB must be negated */]>;
2894 def : Pat<(sra R32C:$rA, R32C:$rB),
2895 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2897 def : Pat<(sra R32C:$rA, R16C:$rB),
2899 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2901 def : Pat<(sra R32C:$rA, R8C:$rB),
2903 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2905 class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
2906 RRForm<0b01011110000, OOL, IOL,
2907 "rotmai\t$rT, $rA, $val",
2908 RotateShift, pattern>;
2910 class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
2911 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
2912 [(set (vectype VECREG:$rT),
2913 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
2915 class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
2916 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
2917 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
2919 multiclass RotateMaskAlgebraicImm {
2920 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
2921 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
2922 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
2923 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
2926 defm ROTMAI : RotateMaskAlgebraicImm;
2928 //===----------------------------------------------------------------------===//
2929 // Branch and conditionals:
2930 //===----------------------------------------------------------------------===//
2932 let isTerminator = 1, isBarrier = 1 in {
2933 // Halt If Equal (r32 preferred slot only, no vector form)
2935 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
2936 "heq\t$rA, $rB", BranchResolv,
2937 [/* no pattern to match */]>;
2940 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
2941 "heqi\t$rA, $val", BranchResolv,
2942 [/* no pattern to match */]>;
2944 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
2945 // contrasting with HLGT/HLGTI, which use unsigned comparison:
2947 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
2948 "hgt\t$rA, $rB", BranchResolv,
2949 [/* no pattern to match */]>;
2952 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
2953 "hgti\t$rA, $val", BranchResolv,
2954 [/* no pattern to match */]>;
2957 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
2958 "hlgt\t$rA, $rB", BranchResolv,
2959 [/* no pattern to match */]>;
2962 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
2963 "hlgti\t$rA, $val", BranchResolv,
2964 [/* no pattern to match */]>;
2967 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2968 // Comparison operators for i8, i16 and i32:
2969 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2971 class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
2972 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
2975 multiclass CmpEqualByte
2978 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2979 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
2980 (v8i16 VECREG:$rB)))]>;
2983 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
2984 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
2987 class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
2988 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
2991 multiclass CmpEqualByteImm
2994 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
2995 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
2996 v16i8SExt8Imm:$val))]>;
2998 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
2999 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3002 class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3003 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3006 multiclass CmpEqualHalfword
3008 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3009 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3010 (v8i16 VECREG:$rB)))]>;
3012 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3013 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3016 class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3017 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3020 multiclass CmpEqualHalfwordImm
3022 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3023 [(set (v8i16 VECREG:$rT),
3024 (seteq (v8i16 VECREG:$rA),
3025 (v8i16 v8i16SExt10Imm:$val)))]>;
3026 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3027 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3030 class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3031 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3034 multiclass CmpEqualWord
3036 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3037 [(set (v4i32 VECREG:$rT),
3038 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3040 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3041 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3044 class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3045 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3048 multiclass CmpEqualWordImm
3050 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3051 [(set (v4i32 VECREG:$rT),
3052 (seteq (v4i32 VECREG:$rA),
3053 (v4i32 v4i32SExt16Imm:$val)))]>;
3055 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3056 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3059 class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3060 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3063 multiclass CmpGtrByte
3066 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3067 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3068 (v8i16 VECREG:$rB)))]>;
3071 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3072 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3075 class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3076 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3079 multiclass CmpGtrByteImm
3082 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3083 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3084 v16i8SExt8Imm:$val))]>;
3086 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3087 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
3090 class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3091 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3094 multiclass CmpGtrHalfword
3096 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3097 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3098 (v8i16 VECREG:$rB)))]>;
3100 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3101 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3104 class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3105 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3108 multiclass CmpGtrHalfwordImm
3110 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3111 [(set (v8i16 VECREG:$rT),
3112 (setgt (v8i16 VECREG:$rA),
3113 (v8i16 v8i16SExt10Imm:$val)))]>;
3114 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3115 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3118 class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3119 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3122 multiclass CmpGtrWord
3124 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3125 [(set (v4i32 VECREG:$rT),
3126 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3128 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3129 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3132 class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3133 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3136 multiclass CmpGtrWordImm
3138 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3139 [(set (v4i32 VECREG:$rT),
3140 (setgt (v4i32 VECREG:$rA),
3141 (v4i32 v4i32SExt16Imm:$val)))]>;
3143 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3144 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
3147 class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3148 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
3151 multiclass CmpLGtrByte
3154 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3155 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3156 (v8i16 VECREG:$rB)))]>;
3159 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3160 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3163 class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3164 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
3167 multiclass CmpLGtrByteImm
3170 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3171 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3172 v16i8SExt8Imm:$val))]>;
3174 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3175 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3178 class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3179 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
3182 multiclass CmpLGtrHalfword
3184 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3185 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3186 (v8i16 VECREG:$rB)))]>;
3188 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3189 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3192 class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3193 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
3196 multiclass CmpLGtrHalfwordImm
3198 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3199 [(set (v8i16 VECREG:$rT),
3200 (setugt (v8i16 VECREG:$rA),
3201 (v8i16 v8i16SExt10Imm:$val)))]>;
3202 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3203 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3206 class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
3207 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
3210 multiclass CmpLGtrWord
3212 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3213 [(set (v4i32 VECREG:$rT),
3214 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3216 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3217 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3220 class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3221 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
3224 multiclass CmpLGtrWordImm
3226 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3227 [(set (v4i32 VECREG:$rT),
3228 (setugt (v4i32 VECREG:$rA),
3229 (v4i32 v4i32SExt16Imm:$val)))]>;
3231 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3232 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
3235 defm CEQB : CmpEqualByte;
3236 defm CEQBI : CmpEqualByteImm;
3237 defm CEQH : CmpEqualHalfword;
3238 defm CEQHI : CmpEqualHalfwordImm;
3239 defm CEQ : CmpEqualWord;
3240 defm CEQI : CmpEqualWordImm;
3241 defm CGTB : CmpGtrByte;
3242 defm CGTBI : CmpGtrByteImm;
3243 defm CGTH : CmpGtrHalfword;
3244 defm CGTHI : CmpGtrHalfwordImm;
3245 defm CGT : CmpGtrWord;
3246 defm CGTI : CmpGtrWordImm;
3247 defm CLGTB : CmpLGtrByte;
3248 defm CLGTBI : CmpLGtrByteImm;
3249 defm CLGTH : CmpLGtrHalfword;
3250 defm CLGTHI : CmpLGtrHalfwordImm;
3251 defm CLGT : CmpLGtrWord;
3252 defm CLGTI : CmpLGtrWordImm;
3254 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3255 // For SETCC primitives not supported above (setlt, setle, setge, etc.)
3256 // define a pattern to generate the right code, as a binary operator
3257 // (in a manner of speaking.)
3260 // 1. This only matches the setcc set of conditionals. Special pattern
3261 // matching is used for select conditionals.
3263 // 2. The "DAG" versions of these classes is almost exclusively used for
3264 // i64 comparisons. See the tblgen fundamentals documentation for what
3265 // ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3266 // class for where ResultInstrs originates.
3267 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3269 class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3270 SPUInstr xorinst, SPUInstr cmpare>:
3271 Pat<(cond rclass:$rA, rclass:$rB),
3272 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3274 class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3275 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3276 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3277 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3279 def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
3280 def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3282 def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
3283 def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3285 def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3286 def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
3288 class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3289 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3290 Pat<(cond rclass:$rA, rclass:$rB),
3291 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3292 (cmpOp2 rclass:$rA, rclass:$rB))>;
3294 class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3296 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3297 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3298 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3299 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3301 def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3302 def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3303 def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3304 def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3305 def : Pat<(setle R8C:$rA, R8C:$rB),
3306 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3307 def : Pat<(setle R8C:$rA, immU8:$imm),
3308 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3310 def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3311 def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3312 ORr16, CGTHIr16, CEQHIr16>;
3313 def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3314 def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3315 def : Pat<(setle R16C:$rA, R16C:$rB),
3316 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3317 def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3318 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3320 def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3321 def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3322 ORr32, CGTIr32, CEQIr32>;
3323 def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3324 def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3325 def : Pat<(setle R32C:$rA, R32C:$rB),
3326 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3327 def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3328 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3330 def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3331 def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3332 def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3333 def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3334 def : Pat<(setule R8C:$rA, R8C:$rB),
3335 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3336 def : Pat<(setule R8C:$rA, immU8:$imm),
3337 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3339 def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3340 def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3341 ORr16, CLGTHIr16, CEQHIr16>;
3342 def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3343 def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3344 CLGTHIr16, CEQHIr16>;
3345 def : Pat<(setule R16C:$rA, R16C:$rB),
3346 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3347 def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
3348 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3350 def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
3351 def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
3352 ORr32, CLGTIr32, CEQIr32>;
3353 def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
3354 def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
3355 def : Pat<(setule R32C:$rA, R32C:$rB),
3356 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3357 def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3358 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3360 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3361 // select conditional patterns:
3362 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3364 class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3365 SPUInstr selinstr, SPUInstr cmpare>:
3366 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3367 rclass:$rTrue, rclass:$rFalse),
3368 (selinstr rclass:$rTrue, rclass:$rFalse,
3369 (cmpare rclass:$rA, rclass:$rB))>;
3371 class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3372 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3373 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
3374 rclass:$rTrue, rclass:$rFalse),
3375 (selinstr rclass:$rTrue, rclass:$rFalse,
3376 (cmpare rclass:$rA, immpred:$imm))>;
3378 def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3379 def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3380 def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3381 def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3382 def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3383 def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3385 def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3386 def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3387 def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3388 def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3389 def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3390 def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3392 def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3393 def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3394 def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3395 def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3396 def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3397 def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3399 class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3400 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3402 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3403 rclass:$rTrue, rclass:$rFalse),
3404 (selinstr rclass:$rFalse, rclass:$rTrue,
3405 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3406 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3408 class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3410 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3412 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
3413 rclass:$rTrue, rclass:$rFalse),
3414 (selinstr rclass:$rFalse, rclass:$rTrue,
3415 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3416 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3418 def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3419 def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3420 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3422 def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3423 def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3424 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3426 def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3427 def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3428 SELBr32, ORr32, CGTIr32, CEQIr32>;
3430 def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3431 def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3432 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3434 def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3435 def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3436 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3438 def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3439 def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3440 SELBr32, ORr32, CLGTIr32, CEQIr32>;
3442 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3445 // All calls clobber the non-callee-saved registers:
3446 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3447 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3448 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3449 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3450 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3451 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3452 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3453 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3454 // All of these instructions use $lr (aka $0)
3456 // Branch relative and set link: Used if we actually know that the target
3457 // is within [-32768, 32767] bytes of the target
3459 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3460 "brsl\t$$lr, $func",
3461 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3463 // Branch absolute and set link: Used if we actually know that the target
3464 // is an absolute address
3466 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3467 "brasl\t$$lr, $func",
3468 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
3470 // Branch indirect and set link if external data. These instructions are not
3471 // actually generated, matched by an intrinsic:
3472 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3473 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3474 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3475 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3477 // Branch indirect and set link. This is the "X-form" address version of a
3480 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3483 // Support calls to external symbols:
3484 def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3485 (BRSL texternalsym:$func)>;
3487 def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3488 (BRASL texternalsym:$func)>;
3490 // Unconditional branches:
3491 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
3493 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3497 // Unconditional, absolute address branch
3499 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3501 [/* no pattern */]>;
3505 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3507 // Various branches:
3508 class BRNZInst<dag IOL, list<dag> pattern>:
3509 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3510 BranchResolv, pattern>;
3512 class BRNZRegInst<RegisterClass rclass>:
3513 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3514 [(brcond rclass:$rCond, bb:$dest)]>;
3516 class BRNZVecInst<ValueType vectype>:
3517 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3518 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
3520 multiclass BranchNotZero {
3521 def v4i32 : BRNZVecInst<v4i32>;
3522 def r32 : BRNZRegInst<R32C>;
3525 defm BRNZ : BranchNotZero;
3527 class BRZInst<dag IOL, list<dag> pattern>:
3528 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3529 BranchResolv, pattern>;
3531 class BRZRegInst<RegisterClass rclass>:
3532 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3534 class BRZVecInst<ValueType vectype>:
3535 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3537 multiclass BranchZero {
3538 def v4i32: BRZVecInst<v4i32>;
3539 def r32: BRZRegInst<R32C>;
3542 defm BRZ: BranchZero;
3544 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3547 class BINZInst<dag IOL, list<dag> pattern>:
3548 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3550 class BINZRegInst<RegisterClass rclass>:
3551 BINZInst<(ins rclass:$rA, brtarget:$dest),
3552 [(brcond rclass:$rA, R32C:$dest)]>;
3554 class BINZVecInst<ValueType vectype>:
3555 BINZInst<(ins VECREG:$rA, R32C:$dest),
3556 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3558 multiclass BranchNotZeroIndirect {
3559 def v4i32: BINZVecInst<v4i32>;
3560 def r32: BINZRegInst<R32C>;
3563 defm BINZ: BranchNotZeroIndirect;
3565 class BIZInst<dag IOL, list<dag> pattern>:
3566 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3568 class BIZRegInst<RegisterClass rclass>:
3569 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3571 class BIZVecInst<ValueType vectype>:
3572 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3574 multiclass BranchZeroIndirect {
3575 def v4i32: BIZVecInst<v4i32>;
3576 def r32: BIZRegInst<R32C>;
3579 defm BIZ: BranchZeroIndirect;
3582 class BRHNZInst<dag IOL, list<dag> pattern>:
3583 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3586 class BRHNZRegInst<RegisterClass rclass>:
3587 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3588 [(brcond rclass:$rCond, bb:$dest)]>;
3590 class BRHNZVecInst<ValueType vectype>:
3591 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3593 multiclass BranchNotZeroHalfword {
3594 def v8i16: BRHNZVecInst<v8i16>;
3595 def r16: BRHNZRegInst<R16C>;
3598 defm BRHNZ: BranchNotZeroHalfword;
3600 class BRHZInst<dag IOL, list<dag> pattern>:
3601 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3604 class BRHZRegInst<RegisterClass rclass>:
3605 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3607 class BRHZVecInst<ValueType vectype>:
3608 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3610 multiclass BranchZeroHalfword {
3611 def v8i16: BRHZVecInst<v8i16>;
3612 def r16: BRHZRegInst<R16C>;
3615 defm BRHZ: BranchZeroHalfword;
3618 //===----------------------------------------------------------------------===//
3619 // setcc and brcond patterns:
3620 //===----------------------------------------------------------------------===//
3622 def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3623 (BRHZr16 R16C:$rA, bb:$dest)>;
3624 def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3625 (BRHNZr16 R16C:$rA, bb:$dest)>;
3627 def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3628 (BRZr32 R32C:$rA, bb:$dest)>;
3629 def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3630 (BRNZr32 R32C:$rA, bb:$dest)>;
3632 multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3634 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3635 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3637 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3638 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3640 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3641 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3643 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3644 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3647 defm BRCONDeq : BranchCondEQ<seteq, BRHZr16, BRZr32>;
3648 defm BRCONDne : BranchCondEQ<setne, BRHNZr16, BRNZr32>;
3650 multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3652 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3653 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3655 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3656 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3658 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3659 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3661 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3662 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3665 defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3666 defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
3668 multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3669 SPUInstr orinst32, SPUInstr brinst32>
3671 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3672 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3673 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3676 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3677 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3678 (CEQHr16 R16C:$rA, R16:$rB)),
3681 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3682 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3683 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3686 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3687 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3688 (CEQr32 R32C:$rA, R32C:$rB)),
3692 defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3693 defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
3695 multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3697 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3698 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3700 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3701 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3703 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3704 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3706 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3707 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3710 defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3711 defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
3713 multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3714 SPUInstr orinst32, SPUInstr brinst32>
3716 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3717 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3718 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3721 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3722 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3723 (CEQHr16 R16C:$rA, R16:$rB)),
3726 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3727 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3728 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3731 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3732 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3733 (CEQr32 R32C:$rA, R32C:$rB)),
3737 defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3738 defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
3740 let isTerminator = 1, isBarrier = 1 in {
3741 let isReturn = 1 in {
3743 RETForm<"bi\t$$lr", [(retflag)]>;
3747 //===----------------------------------------------------------------------===//
3748 // Single precision floating point instructions
3749 //===----------------------------------------------------------------------===//
3751 class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3752 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
3755 class FAVecInst<ValueType vectype>:
3756 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3757 [(set (vectype VECREG:$rT),
3758 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
3762 def v4f32: FAVecInst<v4f32>;
3763 def r32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3764 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
3769 class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3770 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
3773 class FSVecInst<ValueType vectype>:
3774 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3775 [(set (vectype VECREG:$rT),
3776 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
3780 def v4f32: FSVecInst<v4f32>;
3781 def r32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3782 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
3787 // Floating point reciprocal estimate
3789 RRForm_1<0b00011101100, (outs VECREG:$rT), (ins VECREG:$rA),
3790 "frest\t$rT, $rA", SPrecFP,
3791 [(set (v4f32 VECREG:$rT), (SPUreciprocalEst (v4f32 VECREG:$rA)))]>;
3794 RRForm_1<0b00011101100, (outs R32FP:$rT), (ins R32FP:$rA),
3795 "frest\t$rT, $rA", SPrecFP,
3796 [(set R32FP:$rT, (SPUreciprocalEst R32FP:$rA))]>;
3798 // Floating point interpolate (used in conjunction with reciprocal estimate)
3800 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3801 "fi\t$rT, $rA, $rB", SPrecFP,
3802 [(set (v4f32 VECREG:$rT), (SPUinterpolate (v4f32 VECREG:$rA),
3803 (v4f32 VECREG:$rB)))]>;
3806 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3807 "fi\t$rT, $rA, $rB", SPrecFP,
3808 [(set R32FP:$rT, (SPUinterpolate R32FP:$rA, R32FP:$rB))]>;
3810 //--------------------------------------------------------------------------
3811 // Basic single precision floating point comparisons:
3813 // Note: There is no support on SPU for single precision NaN. Consequently,
3814 // ordered and unordered comparisons are the same.
3815 //--------------------------------------------------------------------------
3818 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3819 "fceq\t$rT, $rA, $rB", SPrecFP,
3820 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3822 def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3823 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
3826 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3827 "fcmeq\t$rT, $rA, $rB", SPrecFP,
3828 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3830 def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3831 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
3834 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3835 "fcgt\t$rT, $rA, $rB", SPrecFP,
3836 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3838 def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3839 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
3842 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3843 "fcmgt\t$rT, $rA, $rB", SPrecFP,
3844 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3846 def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3847 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3849 //--------------------------------------------------------------------------
3850 // Single precision floating point comparisons and SETCC equivalents:
3851 //--------------------------------------------------------------------------
3853 def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3854 def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3856 def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3857 def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3859 def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3860 def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3862 def : Pat<(setule R32FP:$rA, R32FP:$rB),
3863 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3864 def : Pat<(setole R32FP:$rA, R32FP:$rB),
3865 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3867 // FP Status and Control Register Write
3868 // Why isn't rT a don't care in the ISA?
3869 // Should we create a special RRForm_3 for this guy and zero out the rT?
3871 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3872 "fscrwr\t$rA", SPrecFP,
3873 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3875 // FP Status and Control Register Read
3877 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3878 "fscrrd\t$rT", SPrecFP,
3879 [/* This instruction requires an intrinsic */]>;
3881 // llvm instruction space
3882 // How do these map onto cell instructions?
3884 // frest rC rB # c = 1/b (both lines)
3886 // fm rD rA rC # d = a * 1/b
3887 // fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
3888 // fma rB rB rC rD # b = b * c + d
3889 // = -(d *b -a) * c + d
3890 // = a * c - c ( a *b *c - a)
3895 // These llvm instructions will actually map to library calls.
3896 // All that's needed, then, is to check that the appropriate library is
3897 // imported and do a brsl to the proper function name.
3898 // frem # fmod(x, y): x - (x/y) * y
3899 // (Note: fmod(double, double), fmodf(float,float)
3903 // Unimplemented SPU instruction space
3904 // floating reciprocal absolute square root estimate (frsqest)
3906 // The following are probably just intrinsics
3907 // status and control register write
3908 // status and control register read
3910 //--------------------------------------
3911 // Floating point multiply instructions
3912 //--------------------------------------
3915 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3916 "fm\t$rT, $rA, $rB", SPrecFP,
3917 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
3918 (v4f32 VECREG:$rB)))]>;
3921 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3922 "fm\t$rT, $rA, $rB", SPrecFP,
3923 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
3925 // Floating point multiply and add
3926 // e.g. d = c + (a * b)
3928 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3929 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
3930 [(set (v4f32 VECREG:$rT),
3931 (fadd (v4f32 VECREG:$rC),
3932 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
3935 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
3936 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
3937 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
3939 // FP multiply and subtract
3940 // Subtracts value in rC from product
3943 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3944 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
3945 [(set (v4f32 VECREG:$rT),
3946 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
3947 (v4f32 VECREG:$rC)))]>;
3950 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
3951 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
3953 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
3955 // Floating Negative Mulitply and Subtract
3956 // Subtracts product from value in rC
3957 // res = fneg(fms a b c)
3960 // NOTE: subtraction order
3964 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
3965 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
3966 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
3969 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
3970 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
3971 [(set (v4f32 VECREG:$rT),
3972 (fsub (v4f32 VECREG:$rC),
3973 (fmul (v4f32 VECREG:$rA),
3974 (v4f32 VECREG:$rB))))]>;
3976 //--------------------------------------
3977 // Floating Point Conversions
3978 // Signed conversions:
3980 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
3981 "csflt\t$rT, $rA, 0", SPrecFP,
3982 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
3984 // Convert signed integer to floating point
3986 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
3987 "csflt\t$rT, $rA, 0", SPrecFP,
3988 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
3990 // Convert unsigned into to float
3992 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
3993 "cuflt\t$rT, $rA, 0", SPrecFP,
3994 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
3997 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
3998 "cuflt\t$rT, $rA, 0", SPrecFP,
3999 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4001 // Convert float to unsigned int
4002 // Assume that scale = 0
4005 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4006 "cfltu\t$rT, $rA, 0", SPrecFP,
4007 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4010 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4011 "cfltu\t$rT, $rA, 0", SPrecFP,
4012 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4014 // Convert float to signed int
4015 // Assume that scale = 0
4018 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4019 "cflts\t$rT, $rA, 0", SPrecFP,
4020 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4023 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4024 "cflts\t$rT, $rA, 0", SPrecFP,
4025 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4027 //===----------------------------------------------------------------------==//
4028 // Single<->Double precision conversions
4029 //===----------------------------------------------------------------------==//
4031 // NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4032 // v4f32, output is v2f64--which goes in the name?)
4034 // Floating point extend single to double
4035 // NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4036 // operates on two double-word slots (i.e. 1st and 3rd fp numbers
4039 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4040 "fesd\t$rT, $rA", SPrecFP,
4041 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
4044 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4045 "fesd\t$rT, $rA", SPrecFP,
4046 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4048 // Floating point round double to single
4050 // RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4051 // "frds\t$rT, $rA,", SPrecFP,
4052 // [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4055 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4056 "frds\t$rT, $rA", SPrecFP,
4057 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4059 //ToDo include anyextend?
4061 //===----------------------------------------------------------------------==//
4062 // Double precision floating point instructions
4063 //===----------------------------------------------------------------------==//
4065 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4066 "dfa\t$rT, $rA, $rB", DPrecFP,
4067 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4070 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4071 "dfa\t$rT, $rA, $rB", DPrecFP,
4072 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4075 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4076 "dfs\t$rT, $rA, $rB", DPrecFP,
4077 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4080 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4081 "dfs\t$rT, $rA, $rB", DPrecFP,
4082 [(set (v2f64 VECREG:$rT),
4083 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4086 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4087 "dfm\t$rT, $rA, $rB", DPrecFP,
4088 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4091 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4092 "dfm\t$rT, $rA, $rB", DPrecFP,
4093 [(set (v2f64 VECREG:$rT),
4094 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4097 RRForm<0b00111010110, (outs R64FP:$rT),
4098 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4099 "dfma\t$rT, $rA, $rB", DPrecFP,
4100 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4101 RegConstraint<"$rC = $rT">,
4105 RRForm<0b00111010110, (outs VECREG:$rT),
4106 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4107 "dfma\t$rT, $rA, $rB", DPrecFP,
4108 [(set (v2f64 VECREG:$rT),
4109 (fadd (v2f64 VECREG:$rC),
4110 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4111 RegConstraint<"$rC = $rT">,
4115 RRForm<0b10111010110, (outs R64FP:$rT),
4116 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4117 "dfms\t$rT, $rA, $rB", DPrecFP,
4118 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4119 RegConstraint<"$rC = $rT">,
4123 RRForm<0b10111010110, (outs VECREG:$rT),
4124 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4125 "dfms\t$rT, $rA, $rB", DPrecFP,
4126 [(set (v2f64 VECREG:$rT),
4127 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4128 (v2f64 VECREG:$rC)))]>;
4130 // FNMS: - (a * b - c)
4131 // - (a * b) + c => c - (a * b)
4133 RRForm<0b01111010110, (outs R64FP:$rT),
4134 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4135 "dfnms\t$rT, $rA, $rB", DPrecFP,
4136 [(set R64FP:$rT, (fsub R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4137 RegConstraint<"$rC = $rT">,
4140 def : Pat<(fneg (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC)),
4141 (FNMSf64 R64FP:$rA, R64FP:$rB, R64FP:$rC)>;
4144 RRForm<0b01111010110, (outs VECREG:$rT),
4145 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4146 "dfnms\t$rT, $rA, $rB", DPrecFP,
4147 [(set (v2f64 VECREG:$rT),
4148 (fsub (v2f64 VECREG:$rC),
4149 (fmul (v2f64 VECREG:$rA),
4150 (v2f64 VECREG:$rB))))]>,
4151 RegConstraint<"$rC = $rT">,
4154 def : Pat<(fneg (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4155 (v2f64 VECREG:$rC))),
4156 (FNMSv2f64 VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
4161 RRForm<0b11111010110, (outs R64FP:$rT),
4162 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4163 "dfnma\t$rT, $rA, $rB", DPrecFP,
4164 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4165 RegConstraint<"$rC = $rT">,
4169 RRForm<0b11111010110, (outs VECREG:$rT),
4170 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4171 "dfnma\t$rT, $rA, $rB", DPrecFP,
4172 [(set (v2f64 VECREG:$rT),
4173 (fneg (fadd (v2f64 VECREG:$rC),
4174 (fmul (v2f64 VECREG:$rA),
4175 (v2f64 VECREG:$rB)))))]>,
4176 RegConstraint<"$rC = $rT">,
4179 //===----------------------------------------------------------------------==//
4180 // Floating point negation and absolute value
4181 //===----------------------------------------------------------------------==//
4183 def : Pat<(fneg (v4f32 VECREG:$rA)),
4184 (XORfnegvec (v4f32 VECREG:$rA),
4185 (v4f32 (ILHUv4i32 0x8000)))>;
4187 def : Pat<(fneg R32FP:$rA),
4188 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
4190 def : Pat<(fneg (v2f64 VECREG:$rA)),
4191 (XORfnegvec (v2f64 VECREG:$rA),
4192 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80)))>;
4194 def : Pat<(fneg R64FP:$rA),
4195 (XORfneg64 R64FP:$rA,
4196 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80))>;
4198 // Floating point absolute value
4200 def : Pat<(fabs R32FP:$rA),
4201 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4203 def : Pat<(fabs (v4f32 VECREG:$rA)),
4204 (ANDfabsvec (v4f32 VECREG:$rA),
4205 (v4f32 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
4207 def : Pat<(fabs R64FP:$rA),
4208 (ANDfabs64 R64FP:$rA, (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f))>;
4210 def : Pat<(fabs (v2f64 VECREG:$rA)),
4211 (ANDfabsvec (v2f64 VECREG:$rA),
4212 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
4214 //===----------------------------------------------------------------------===//
4215 // Hint for branch instructions:
4216 //===----------------------------------------------------------------------===//
4218 /* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4220 //===----------------------------------------------------------------------===//
4221 // Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4222 // in the odd pipeline)
4223 //===----------------------------------------------------------------------===//
4225 def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
4228 let Inst{0-10} = 0b10000000010;
4229 let Inst{11-17} = 0;
4230 let Inst{18-24} = 0;
4231 let Inst{25-31} = 0;
4234 def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
4237 let Inst{0-10} = 0b10000000000;
4238 let Inst{11-17} = 0;
4239 let Inst{18-24} = 0;
4240 let Inst{25-31} = 0;
4243 //===----------------------------------------------------------------------===//
4244 // Bit conversions (type conversions between vector/packed types)
4245 // NOTE: Promotions are handled using the XS* instructions. Truncation
4247 //===----------------------------------------------------------------------===//
4248 def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4249 def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4250 def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4251 def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4252 def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4254 def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4255 def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4256 def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4257 def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4258 def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4260 def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4261 def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4262 def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4263 def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4264 def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4266 def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4267 def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4268 def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4269 def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4270 def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4272 def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4273 def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4274 def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4275 def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4276 def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4278 def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4279 def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4280 def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4281 def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4282 def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4284 def : Pat<(f32 (bitconvert (i32 R32C:$src))), (f32 R32FP:$src)>;
4285 def : Pat<(f64 (bitconvert (i64 R64C:$src))), (f64 R64FP:$src)>;
4287 //===----------------------------------------------------------------------===//
4288 // Instruction patterns:
4289 //===----------------------------------------------------------------------===//
4291 // General 32-bit constants:
4292 def : Pat<(i32 imm:$imm),
4293 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4295 // Single precision float constants:
4296 def : Pat<(f32 fpimm:$imm),
4297 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4299 // General constant 32-bit vectors
4300 def : Pat<(v4i32 v4i32Imm:$imm),
4301 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4302 (LO16_vec v4i32Imm:$imm))>;
4305 def : Pat<(i8 imm:$imm),
4308 //===----------------------------------------------------------------------===//
4309 // Call instruction patterns:
4310 //===----------------------------------------------------------------------===//
4315 //===----------------------------------------------------------------------===//
4316 // Zero/Any/Sign extensions
4317 //===----------------------------------------------------------------------===//
4319 // sext 8->32: Sign extend bytes to words
4320 def : Pat<(sext_inreg R32C:$rSrc, i8),
4321 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4323 def : Pat<(i32 (sext R8C:$rSrc)),
4324 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4326 // zext 8->16: Zero extend bytes to halfwords
4327 def : Pat<(i16 (zext R8C:$rSrc)),
4328 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
4330 // zext 8->32: Zero extend bytes to words
4331 def : Pat<(i32 (zext R8C:$rSrc)),
4332 (ANDIi8i32 R8C:$rSrc, 0xff)>;
4334 // anyext 8->16: Extend 8->16 bits, irrespective of sign
4335 def : Pat<(i16 (anyext R8C:$rSrc)),
4336 (ORHIi8i16 R8C:$rSrc, 0)>;
4338 // anyext 8->32: Extend 8->32 bits, irrespective of sign
4339 def : Pat<(i32 (anyext R8C:$rSrc)),
4340 (ORIi8i32 R8C:$rSrc, 0)>;
4342 // zext 16->32: Zero extend halfwords to words
4343 def : Pat<(i32 (zext R16C:$rSrc)),
4344 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
4346 def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
4347 (ANDIi16i32 R16C:$rSrc, 0xf)>;
4349 def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
4350 (ANDIi16i32 R16C:$rSrc, 0xff)>;
4352 def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
4353 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
4355 // anyext 16->32: Extend 16->32 bits, irrespective of sign
4356 def : Pat<(i32 (anyext R16C:$rSrc)),
4357 (ORIi16i32 R16C:$rSrc, 0)>;
4359 //===----------------------------------------------------------------------===//
4361 // These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4362 // above are custom lowered.
4363 //===----------------------------------------------------------------------===//
4365 def : Pat<(i8 (trunc GPRC:$src)),
4367 (SHUFBgprc GPRC:$src, GPRC:$src,
4368 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4370 def : Pat<(i8 (trunc R64C:$src)),
4373 (ORv2i64_i64 R64C:$src),
4374 (ORv2i64_i64 R64C:$src),
4375 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4377 def : Pat<(i8 (trunc R32C:$src)),
4380 (ORv4i32_i32 R32C:$src),
4381 (ORv4i32_i32 R32C:$src),
4382 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4384 def : Pat<(i8 (trunc R16C:$src)),
4387 (ORv8i16_i16 R16C:$src),
4388 (ORv8i16_i16 R16C:$src),
4389 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4391 def : Pat<(i16 (trunc GPRC:$src)),
4393 (SHUFBgprc GPRC:$src, GPRC:$src,
4394 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4396 def : Pat<(i16 (trunc R64C:$src)),
4399 (ORv2i64_i64 R64C:$src),
4400 (ORv2i64_i64 R64C:$src),
4401 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4403 def : Pat<(i16 (trunc R32C:$src)),
4406 (ORv4i32_i32 R32C:$src),
4407 (ORv4i32_i32 R32C:$src),
4408 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4410 def : Pat<(i32 (trunc GPRC:$src)),
4412 (SHUFBgprc GPRC:$src, GPRC:$src,
4413 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4415 def : Pat<(i32 (trunc R64C:$src)),
4418 (ORv2i64_i64 R64C:$src),
4419 (ORv2i64_i64 R64C:$src),
4420 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4422 //===----------------------------------------------------------------------===//
4423 // Address generation: SPU, like PPC, has to split addresses into high and
4424 // low parts in order to load them into a register.
4425 //===----------------------------------------------------------------------===//
4427 def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4428 def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4429 def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4430 def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4432 def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4433 (SPUlo tglobaladdr:$in, 0)),
4434 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4436 def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4437 (SPUlo texternalsym:$in, 0)),
4438 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4440 def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4441 (SPUlo tjumptable:$in, 0)),
4442 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4444 def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4445 (SPUlo tconstpool:$in, 0)),
4446 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4448 def : Pat<(SPUindirect R32C:$sp, i32ImmSExt10:$imm),
4449 (AIr32 R32C:$sp, i32ImmSExt10:$imm)>;
4451 def : Pat<(SPUindirect R32C:$sp, imm:$imm),
4453 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm)))>;
4455 def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4456 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4458 def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4459 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4461 def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4462 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4464 def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4465 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4468 include "CellSDKIntrinsics.td"
4469 // 64-bit "instructions"/support
4470 include "SPU64InstrInfo.td"