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 v2i32: LoadDFormVec<v2i32>;
76 def r128: LoadDForm<GPRC>;
77 def r64: LoadDForm<R64C>;
78 def r32: LoadDForm<R32C>;
79 def f32: LoadDForm<R32FP>;
80 def f64: LoadDForm<R64FP>;
81 def r16: LoadDForm<R16C>;
82 def r8: LoadDForm<R8C>;
85 class LoadAFormVec<ValueType vectype>
86 : RI16Form<0b100001100, (outs VECREG:$rT), (ins addr256k:$src),
89 [(set (vectype VECREG:$rT), (load aform_addr:$src))]>
92 class LoadAForm<RegisterClass rclass>
93 : RI16Form<0b100001100, (outs rclass:$rT), (ins addr256k:$src),
96 [(set rclass:$rT, (load aform_addr:$src))]>
101 def v16i8: LoadAFormVec<v16i8>;
102 def v8i16: LoadAFormVec<v8i16>;
103 def v4i32: LoadAFormVec<v4i32>;
104 def v2i64: LoadAFormVec<v2i64>;
105 def v4f32: LoadAFormVec<v4f32>;
106 def v2f64: LoadAFormVec<v2f64>;
108 def v2i32: LoadAFormVec<v2i32>;
110 def r128: LoadAForm<GPRC>;
111 def r64: LoadAForm<R64C>;
112 def r32: LoadAForm<R32C>;
113 def f32: LoadAForm<R32FP>;
114 def f64: LoadAForm<R64FP>;
115 def r16: LoadAForm<R16C>;
116 def r8: LoadAForm<R8C>;
119 class LoadXFormVec<ValueType vectype>
120 : RRForm<0b00100011100, (outs VECREG:$rT), (ins memrr:$src),
123 [(set (vectype VECREG:$rT), (load xform_addr:$src))]>
126 class LoadXForm<RegisterClass rclass>
127 : RRForm<0b00100011100, (outs rclass:$rT), (ins memrr:$src),
130 [(set rclass:$rT, (load xform_addr:$src))]>
133 multiclass LoadXForms
135 def v16i8: LoadXFormVec<v16i8>;
136 def v8i16: LoadXFormVec<v8i16>;
137 def v4i32: LoadXFormVec<v4i32>;
138 def v2i64: LoadXFormVec<v2i64>;
139 def v4f32: LoadXFormVec<v4f32>;
140 def v2f64: LoadXFormVec<v2f64>;
142 def v2i32: LoadXFormVec<v2i32>;
144 def r128: LoadXForm<GPRC>;
145 def r64: LoadXForm<R64C>;
146 def r32: LoadXForm<R32C>;
147 def f32: LoadXForm<R32FP>;
148 def f64: LoadXForm<R64FP>;
149 def r16: LoadXForm<R16C>;
150 def r8: LoadXForm<R8C>;
153 defm LQA : LoadAForms;
154 defm LQD : LoadDForms;
155 defm LQX : LoadXForms;
157 /* Load quadword, PC relative: Not much use at this point in time.
158 Might be of use later for relocatable code. It's effectively the
159 same as LQA, but uses PC-relative addressing.
160 def LQR : RI16Form<0b111001100, (outs VECREG:$rT), (ins s16imm:$disp),
161 "lqr\t$rT, $disp", LoadStore,
162 [(set VECREG:$rT, (load iaddr:$disp))]>;
166 //===----------------------------------------------------------------------===//
168 //===----------------------------------------------------------------------===//
169 class StoreDFormVec<ValueType vectype>
170 : RI10Form<0b00100100, (outs), (ins VECREG:$rT, dformaddr:$src),
173 [(store (vectype VECREG:$rT), dform_addr:$src)]>
176 class StoreDForm<RegisterClass rclass>
177 : RI10Form<0b00100100, (outs), (ins rclass:$rT, dformaddr:$src),
180 [(store rclass:$rT, dform_addr:$src)]>
183 multiclass StoreDForms
185 def v16i8: StoreDFormVec<v16i8>;
186 def v8i16: StoreDFormVec<v8i16>;
187 def v4i32: StoreDFormVec<v4i32>;
188 def v2i64: StoreDFormVec<v2i64>;
189 def v4f32: StoreDFormVec<v4f32>;
190 def v2f64: StoreDFormVec<v2f64>;
192 def v2i32: StoreDFormVec<v2i32>;
194 def r128: StoreDForm<GPRC>;
195 def r64: StoreDForm<R64C>;
196 def r32: StoreDForm<R32C>;
197 def f32: StoreDForm<R32FP>;
198 def f64: StoreDForm<R64FP>;
199 def r16: StoreDForm<R16C>;
200 def r8: StoreDForm<R8C>;
203 class StoreAFormVec<ValueType vectype>
204 : RI16Form<0b0010010, (outs), (ins VECREG:$rT, addr256k:$src),
207 [(store (vectype VECREG:$rT), aform_addr:$src)]>;
209 class StoreAForm<RegisterClass rclass>
210 : RI16Form<0b001001, (outs), (ins rclass:$rT, addr256k:$src),
213 [(store rclass:$rT, aform_addr:$src)]>;
215 multiclass StoreAForms
217 def v16i8: StoreAFormVec<v16i8>;
218 def v8i16: StoreAFormVec<v8i16>;
219 def v4i32: StoreAFormVec<v4i32>;
220 def v2i64: StoreAFormVec<v2i64>;
221 def v4f32: StoreAFormVec<v4f32>;
222 def v2f64: StoreAFormVec<v2f64>;
224 def v2i32: StoreAFormVec<v2i32>;
226 def r128: StoreAForm<GPRC>;
227 def r64: StoreAForm<R64C>;
228 def r32: StoreAForm<R32C>;
229 def f32: StoreAForm<R32FP>;
230 def f64: StoreAForm<R64FP>;
231 def r16: StoreAForm<R16C>;
232 def r8: StoreAForm<R8C>;
235 class StoreXFormVec<ValueType vectype>
236 : RRForm<0b00100100, (outs), (ins VECREG:$rT, memrr:$src),
239 [(store (vectype VECREG:$rT), xform_addr:$src)]>
242 class StoreXForm<RegisterClass rclass>
243 : RRForm<0b00100100, (outs), (ins rclass:$rT, memrr:$src),
246 [(store rclass:$rT, xform_addr:$src)]>
249 multiclass StoreXForms
251 def v16i8: StoreXFormVec<v16i8>;
252 def v8i16: StoreXFormVec<v8i16>;
253 def v4i32: StoreXFormVec<v4i32>;
254 def v2i64: StoreXFormVec<v2i64>;
255 def v4f32: StoreXFormVec<v4f32>;
256 def v2f64: StoreXFormVec<v2f64>;
258 def v2i32: StoreXFormVec<v2i32>;
260 def r128: StoreXForm<GPRC>;
261 def r64: StoreXForm<R64C>;
262 def r32: StoreXForm<R32C>;
263 def f32: StoreXForm<R32FP>;
264 def f64: StoreXForm<R64FP>;
265 def r16: StoreXForm<R16C>;
266 def r8: StoreXForm<R8C>;
269 defm STQD : StoreDForms;
270 defm STQA : StoreAForms;
271 defm STQX : StoreXForms;
273 /* Store quadword, PC relative: Not much use at this point in time. Might
274 be useful for relocatable code.
275 def STQR : RI16Form<0b111000100, (outs), (ins VECREG:$rT, s16imm:$disp),
276 "stqr\t$rT, $disp", LoadStore,
277 [(store VECREG:$rT, iaddr:$disp)]>;
280 //===----------------------------------------------------------------------===//
281 // Generate Controls for Insertion:
282 //===----------------------------------------------------------------------===//
284 def CBD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
285 "cbd\t$rT, $src", ShuffleOp,
286 [(set (v16i8 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
288 def CBX: RRForm<0b00101011100, (outs VECREG:$rT), (ins memrr:$src),
289 "cbx\t$rT, $src", ShuffleOp,
290 [(set (v16i8 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
292 def CHD: RI7Form<0b10101111100, (outs VECREG:$rT), (ins shufaddr:$src),
293 "chd\t$rT, $src", ShuffleOp,
294 [(set (v8i16 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
296 def CHX: RRForm<0b10101011100, (outs VECREG:$rT), (ins memrr:$src),
297 "chx\t$rT, $src", ShuffleOp,
298 [(set (v8i16 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
300 def CWD: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
301 "cwd\t$rT, $src", ShuffleOp,
302 [(set (v4i32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
304 def CWX: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
305 "cwx\t$rT, $src", ShuffleOp,
306 [(set (v4i32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
308 def CWDf32: RI7Form<0b01101111100, (outs VECREG:$rT), (ins shufaddr:$src),
309 "cwd\t$rT, $src", ShuffleOp,
310 [(set (v4f32 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
312 def CWXf32: RRForm<0b01101011100, (outs VECREG:$rT), (ins memrr:$src),
313 "cwx\t$rT, $src", ShuffleOp,
314 [(set (v4f32 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
316 def CDD: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
317 "cdd\t$rT, $src", ShuffleOp,
318 [(set (v2i64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
320 def CDX: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
321 "cdx\t$rT, $src", ShuffleOp,
322 [(set (v2i64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
324 def CDDf64: RI7Form<0b11101111100, (outs VECREG:$rT), (ins shufaddr:$src),
325 "cdd\t$rT, $src", ShuffleOp,
326 [(set (v2f64 VECREG:$rT), (SPUshufmask dform2_addr:$src))]>;
328 def CDXf64: RRForm<0b11101011100, (outs VECREG:$rT), (ins memrr:$src),
329 "cdx\t$rT, $src", ShuffleOp,
330 [(set (v2f64 VECREG:$rT), (SPUshufmask xform_addr:$src))]>;
332 //===----------------------------------------------------------------------===//
333 // Constant formation:
334 //===----------------------------------------------------------------------===//
337 RI16Form<0b110000010, (outs VECREG:$rT), (ins s16imm:$val),
338 "ilh\t$rT, $val", ImmLoad,
339 [(set (v8i16 VECREG:$rT), (v8i16 v8i16SExt16Imm:$val))]>;
342 RI16Form<0b110000010, (outs R16C:$rT), (ins s16imm:$val),
343 "ilh\t$rT, $val", ImmLoad,
344 [(set R16C:$rT, immSExt16:$val)]>;
346 // Cell SPU doesn't have a native 8-bit immediate load, but ILH works ("with
347 // the right constant")
349 RI16Form<0b110000010, (outs R8C:$rT), (ins s16imm_i8:$val),
350 "ilh\t$rT, $val", ImmLoad,
351 [(set R8C:$rT, immSExt8:$val)]>;
353 // IL does sign extension!
355 class ILInst<dag OOL, dag IOL, list<dag> pattern>:
356 RI16Form<0b100000010, OOL, IOL, "il\t$rT, $val",
359 class ILVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
360 ILInst<(outs VECREG:$rT), (ins immtype:$val),
361 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
363 class ILRegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
364 ILInst<(outs rclass:$rT), (ins immtype:$val),
365 [(set rclass:$rT, xform:$val)]>;
367 multiclass ImmediateLoad
369 def v2i64: ILVecInst<v2i64, s16imm_i64, v2i64SExt16Imm>;
370 def v4i32: ILVecInst<v4i32, s16imm_i32, v4i32SExt16Imm>;
372 // TODO: Need v2f64, v4f32
374 def r64: ILRegInst<R64C, s16imm_i64, immSExt16>;
375 def r32: ILRegInst<R32C, s16imm_i32, immSExt16>;
376 def f32: ILRegInst<R32FP, s16imm_f32, fpimmSExt16>;
377 def f64: ILRegInst<R64FP, s16imm_f64, fpimmSExt16>;
380 defm IL : ImmediateLoad;
382 class ILHUInst<dag OOL, dag IOL, list<dag> pattern>:
383 RI16Form<0b010000010, OOL, IOL, "ilhu\t$rT, $val",
386 class ILHUVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
387 ILHUInst<(outs VECREG:$rT), (ins immtype:$val),
388 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
390 class ILHURegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
391 ILHUInst<(outs rclass:$rT), (ins immtype:$val),
392 [(set rclass:$rT, xform:$val)]>;
394 multiclass ImmLoadHalfwordUpper
396 def v2i64: ILHUVecInst<v2i64, u16imm_i64, immILHUvec_i64>;
397 def v4i32: ILHUVecInst<v4i32, u16imm_i32, immILHUvec>;
399 def r64: ILHURegInst<R64C, u16imm_i64, hi16>;
400 def r32: ILHURegInst<R32C, u16imm_i32, hi16>;
402 // Loads the high portion of an address
403 def hi: ILHURegInst<R32C, symbolHi, hi16>;
405 // Used in custom lowering constant SFP loads:
406 def f32: ILHURegInst<R32FP, f16imm, hi16_f32>;
409 defm ILHU : ImmLoadHalfwordUpper;
411 // Immediate load address (can also be used to load 18-bit unsigned constants,
412 // see the zext 16->32 pattern)
414 class ILAInst<dag OOL, dag IOL, list<dag> pattern>:
415 RI18Form<0b1000010, OOL, IOL, "ila\t$rT, $val",
418 class ILAVecInst<ValueType vectype, Operand immtype, PatLeaf xform>:
419 ILAInst<(outs VECREG:$rT), (ins immtype:$val),
420 [(set (vectype VECREG:$rT), (vectype xform:$val))]>;
422 class ILARegInst<RegisterClass rclass, Operand immtype, PatLeaf xform>:
423 ILAInst<(outs rclass:$rT), (ins immtype:$val),
424 [(set rclass:$rT, xform:$val)]>;
426 multiclass ImmLoadAddress
428 def v2i64: ILAVecInst<v2i64, u18imm, v2i64Uns18Imm>;
429 def v4i32: ILAVecInst<v4i32, u18imm, v4i32Uns18Imm>;
431 def r64: ILARegInst<R64C, u18imm_i64, imm18>;
432 def r32: ILARegInst<R32C, u18imm, imm18>;
433 def f32: ILARegInst<R32FP, f18imm, fpimm18>;
434 def f64: ILARegInst<R64FP, f18imm_f64, fpimm18>;
436 def hi: ILARegInst<R32C, symbolHi, imm18>;
437 def lo: ILARegInst<R32C, symbolLo, imm18>;
439 def lsa: ILAInst<(outs R32C:$rT), (ins symbolLSA:$val),
443 defm ILA : ImmLoadAddress;
445 // Immediate OR, Halfword Lower: The "other" part of loading large constants
446 // into 32-bit registers. See the anonymous pattern Pat<(i32 imm:$imm), ...>
447 // Note that these are really two operand instructions, but they're encoded
448 // as three operands with the first two arguments tied-to each other.
450 class IOHLInst<dag OOL, dag IOL, list<dag> pattern>:
451 RI16Form<0b100000110, OOL, IOL, "iohl\t$rT, $val",
453 RegConstraint<"$rS = $rT">,
456 class IOHLVecInst<ValueType vectype, Operand immtype /* , PatLeaf xform */>:
457 IOHLInst<(outs VECREG:$rT), (ins VECREG:$rS, immtype:$val),
460 class IOHLRegInst<RegisterClass rclass, Operand immtype /* , PatLeaf xform */>:
461 IOHLInst<(outs rclass:$rT), (ins rclass:$rS, immtype:$val),
464 multiclass ImmOrHalfwordLower
466 def v2i64: IOHLVecInst<v2i64, u16imm_i64>;
467 def v4i32: IOHLVecInst<v4i32, u16imm_i32>;
469 def r32: IOHLRegInst<R32C, i32imm>;
470 def f32: IOHLRegInst<R32FP, f32imm>;
472 def lo: IOHLRegInst<R32C, symbolLo>;
475 defm IOHL: ImmOrHalfwordLower;
477 // Form select mask for bytes using immediate, used in conjunction with the
480 class FSMBIVec<ValueType vectype>:
481 RI16Form<0b101001100, (outs VECREG:$rT), (ins u16imm:$val),
484 [(set (vectype VECREG:$rT), (SPUselmask (i16 immU16:$val)))]>;
486 multiclass FormSelectMaskBytesImm
488 def v16i8: FSMBIVec<v16i8>;
489 def v8i16: FSMBIVec<v8i16>;
490 def v4i32: FSMBIVec<v4i32>;
491 def v2i64: FSMBIVec<v2i64>;
494 defm FSMBI : FormSelectMaskBytesImm;
496 // fsmb: Form select mask for bytes. N.B. Input operand, $rA, is 16-bits
497 class FSMBInst<dag OOL, dag IOL, list<dag> pattern>:
498 RRForm_1<0b01101101100, OOL, IOL, "fsmb\t$rT, $rA", SelectOp,
501 class FSMBRegInst<RegisterClass rclass, ValueType vectype>:
502 FSMBInst<(outs VECREG:$rT), (ins rclass:$rA),
503 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
505 class FSMBVecInst<ValueType vectype>:
506 FSMBInst<(outs VECREG:$rT), (ins VECREG:$rA),
507 [(set (vectype VECREG:$rT),
508 (SPUselmask (vectype VECREG:$rA)))]>;
510 multiclass FormSelectMaskBits {
511 def v16i8_r16: FSMBRegInst<R16C, v16i8>;
512 def v16i8: FSMBVecInst<v16i8>;
515 defm FSMB: FormSelectMaskBits;
517 // fsmh: Form select mask for halfwords. N.B., Input operand, $rA, is
518 // only 8-bits wide (even though it's input as 16-bits here)
520 class FSMHInst<dag OOL, dag IOL, list<dag> pattern>:
521 RRForm_1<0b10101101100, OOL, IOL, "fsmh\t$rT, $rA", SelectOp,
524 class FSMHRegInst<RegisterClass rclass, ValueType vectype>:
525 FSMHInst<(outs VECREG:$rT), (ins rclass:$rA),
526 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
528 class FSMHVecInst<ValueType vectype>:
529 FSMHInst<(outs VECREG:$rT), (ins VECREG:$rA),
530 [(set (vectype VECREG:$rT),
531 (SPUselmask (vectype VECREG:$rA)))]>;
533 multiclass FormSelectMaskHalfword {
534 def v8i16_r16: FSMHRegInst<R16C, v8i16>;
535 def v8i16: FSMHVecInst<v8i16>;
538 defm FSMH: FormSelectMaskHalfword;
540 // fsm: Form select mask for words. Like the other fsm* instructions,
541 // only the lower 4 bits of $rA are significant.
543 class FSMInst<dag OOL, dag IOL, list<dag> pattern>:
544 RRForm_1<0b00101101100, OOL, IOL, "fsm\t$rT, $rA", SelectOp,
547 class FSMRegInst<ValueType vectype, RegisterClass rclass>:
548 FSMInst<(outs VECREG:$rT), (ins rclass:$rA),
549 [(set (vectype VECREG:$rT), (SPUselmask rclass:$rA))]>;
551 class FSMVecInst<ValueType vectype>:
552 FSMInst<(outs VECREG:$rT), (ins VECREG:$rA),
553 [(set (vectype VECREG:$rT), (SPUselmask (vectype VECREG:$rA)))]>;
555 multiclass FormSelectMaskWord {
556 def v4i32: FSMVecInst<v4i32>;
558 def r32 : FSMRegInst<v4i32, R32C>;
559 def r16 : FSMRegInst<v4i32, R16C>;
562 defm FSM : FormSelectMaskWord;
564 // Special case when used for i64 math operations
565 multiclass FormSelectMaskWord64 {
566 def r32 : FSMRegInst<v2i64, R32C>;
567 def r16 : FSMRegInst<v2i64, R16C>;
570 defm FSM64 : FormSelectMaskWord64;
572 //===----------------------------------------------------------------------===//
573 // Integer and Logical Operations:
574 //===----------------------------------------------------------------------===//
577 RRForm<0b00010011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
578 "ah\t$rT, $rA, $rB", IntegerOp,
579 [(set (v8i16 VECREG:$rT), (int_spu_si_ah VECREG:$rA, VECREG:$rB))]>;
581 def : Pat<(add (v8i16 VECREG:$rA), (v8i16 VECREG:$rB)),
582 (AHv8i16 VECREG:$rA, VECREG:$rB)>;
585 RRForm<0b00010011000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
586 "ah\t$rT, $rA, $rB", IntegerOp,
587 [(set R16C:$rT, (add R16C:$rA, R16C:$rB))]>;
590 RI10Form<0b10111000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
591 "ahi\t$rT, $rA, $val", IntegerOp,
592 [(set (v8i16 VECREG:$rT), (add (v8i16 VECREG:$rA),
593 v8i16SExt10Imm:$val))]>;
596 RI10Form<0b10111000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
597 "ahi\t$rT, $rA, $val", IntegerOp,
598 [(set R16C:$rT, (add R16C:$rA, i16ImmSExt10:$val))]>;
600 // v4i32, i32 add instruction:
602 class AInst<dag OOL, dag IOL, list<dag> pattern>:
603 RRForm<0b00000011000, OOL, IOL,
604 "a\t$rT, $rA, $rB", IntegerOp,
607 class AVecInst<ValueType vectype>:
608 AInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
609 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA),
610 (vectype VECREG:$rB)))]>;
612 class ARegInst<RegisterClass rclass>:
613 AInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
614 [(set rclass:$rT, (add rclass:$rA, rclass:$rB))]>;
616 multiclass AddInstruction {
617 def v4i32: AVecInst<v4i32>;
618 def v16i8: AVecInst<v16i8>;
620 def r32: ARegInst<R32C>;
623 defm A : AddInstruction;
625 class AIInst<dag OOL, dag IOL, list<dag> pattern>:
626 RI10Form<0b00111000, OOL, IOL,
627 "ai\t$rT, $rA, $val", IntegerOp,
630 class AIVecInst<ValueType vectype, PatLeaf immpred>:
631 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
632 [(set (vectype VECREG:$rT), (add (vectype VECREG:$rA), immpred:$val))]>;
634 class AIFPVecInst<ValueType vectype, PatLeaf immpred>:
635 AIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
638 class AIRegInst<RegisterClass rclass, PatLeaf immpred>:
639 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
640 [(set rclass:$rT, (add rclass:$rA, immpred:$val))]>;
642 // This is used to add epsilons to floating point numbers in the f32 fdiv code:
643 class AIFPInst<RegisterClass rclass, PatLeaf immpred>:
644 AIInst<(outs rclass:$rT), (ins rclass:$rA, s10imm_i32:$val),
647 multiclass AddImmediate {
648 def v4i32: AIVecInst<v4i32, v4i32SExt10Imm>;
650 def r32: AIRegInst<R32C, i32ImmSExt10>;
652 def v4f32: AIFPVecInst<v4f32, v4i32SExt10Imm>;
653 def f32: AIFPInst<R32FP, i32ImmSExt10>;
656 defm AI : AddImmediate;
659 RRForm<0b00010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
660 "sfh\t$rT, $rA, $rB", IntegerOp,
661 [(set (v8i16 VECREG:$rT), (sub (v8i16 VECREG:$rA),
662 (v8i16 VECREG:$rB)))]>;
665 RRForm<0b00010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
666 "sfh\t$rT, $rA, $rB", IntegerOp,
667 [(set R16C:$rT, (sub R16C:$rA, R16C:$rB))]>;
670 RI10Form<0b10110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
671 "sfhi\t$rT, $rA, $val", IntegerOp,
672 [(set (v8i16 VECREG:$rT), (sub v8i16SExt10Imm:$val,
673 (v8i16 VECREG:$rA)))]>;
675 def SFHIr16 : RI10Form<0b10110000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
676 "sfhi\t$rT, $rA, $val", IntegerOp,
677 [(set R16C:$rT, (sub i16ImmSExt10:$val, R16C:$rA))]>;
679 def SFvec : RRForm<0b00000010000, (outs VECREG:$rT),
680 (ins VECREG:$rA, VECREG:$rB),
681 "sf\t$rT, $rA, $rB", IntegerOp,
682 [(set (v4i32 VECREG:$rT), (sub (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
684 def SFr32 : RRForm<0b00000010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
685 "sf\t$rT, $rA, $rB", IntegerOp,
686 [(set R32C:$rT, (sub R32C:$rA, R32C:$rB))]>;
689 RI10Form<0b00110000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
690 "sfi\t$rT, $rA, $val", IntegerOp,
691 [(set (v4i32 VECREG:$rT), (sub v4i32SExt10Imm:$val,
692 (v4i32 VECREG:$rA)))]>;
694 def SFIr32 : RI10Form<0b00110000, (outs R32C:$rT),
695 (ins R32C:$rA, s10imm_i32:$val),
696 "sfi\t$rT, $rA, $val", IntegerOp,
697 [(set R32C:$rT, (sub i32ImmSExt10:$val, R32C:$rA))]>;
699 // ADDX: only available in vector form, doesn't match a pattern.
700 class ADDXInst<dag OOL, dag IOL, list<dag> pattern>:
701 RRForm<0b00000010110, OOL, IOL,
702 "addx\t$rT, $rA, $rB",
705 class ADDXVecInst<ValueType vectype>:
706 ADDXInst<(outs VECREG:$rT),
707 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
709 RegConstraint<"$rCarry = $rT">,
712 class ADDXRegInst<RegisterClass rclass>:
713 ADDXInst<(outs rclass:$rT),
714 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
716 RegConstraint<"$rCarry = $rT">,
719 multiclass AddExtended {
720 def v2i64 : ADDXVecInst<v2i64>;
721 def v4i32 : ADDXVecInst<v4i32>;
722 def r64 : ADDXRegInst<R64C>;
723 def r32 : ADDXRegInst<R32C>;
726 defm ADDX : AddExtended;
728 // CG: Generate carry for add
729 class CGInst<dag OOL, dag IOL, list<dag> pattern>:
730 RRForm<0b01000011000, OOL, IOL,
734 class CGVecInst<ValueType vectype>:
735 CGInst<(outs VECREG:$rT),
736 (ins VECREG:$rA, VECREG:$rB),
739 class CGRegInst<RegisterClass rclass>:
740 CGInst<(outs rclass:$rT),
741 (ins rclass:$rA, rclass:$rB),
744 multiclass CarryGenerate {
745 def v2i64 : CGVecInst<v2i64>;
746 def v4i32 : CGVecInst<v4i32>;
747 def r64 : CGRegInst<R64C>;
748 def r32 : CGRegInst<R32C>;
751 defm CG : CarryGenerate;
753 // SFX: Subract from, extended. This is used in conjunction with BG to subtract
754 // with carry (borrow, in this case)
755 class SFXInst<dag OOL, dag IOL, list<dag> pattern>:
756 RRForm<0b10000010110, OOL, IOL,
757 "sfx\t$rT, $rA, $rB",
760 class SFXVecInst<ValueType vectype>:
761 SFXInst<(outs VECREG:$rT),
762 (ins VECREG:$rA, VECREG:$rB, VECREG:$rCarry),
764 RegConstraint<"$rCarry = $rT">,
767 class SFXRegInst<RegisterClass rclass>:
768 SFXInst<(outs rclass:$rT),
769 (ins rclass:$rA, rclass:$rB, rclass:$rCarry),
771 RegConstraint<"$rCarry = $rT">,
774 multiclass SubtractExtended {
775 def v2i64 : SFXVecInst<v2i64>;
776 def v4i32 : SFXVecInst<v4i32>;
777 def r64 : SFXRegInst<R64C>;
778 def r32 : SFXRegInst<R32C>;
781 defm SFX : SubtractExtended;
783 // BG: only available in vector form, doesn't match a pattern.
784 class BGInst<dag OOL, dag IOL, list<dag> pattern>:
785 RRForm<0b01000010000, OOL, IOL,
789 class BGVecInst<ValueType vectype>:
790 BGInst<(outs VECREG:$rT),
791 (ins VECREG:$rA, VECREG:$rB),
794 class BGRegInst<RegisterClass rclass>:
795 BGInst<(outs rclass:$rT),
796 (ins rclass:$rA, rclass:$rB),
799 multiclass BorrowGenerate {
800 def v4i32 : BGVecInst<v4i32>;
801 def v2i64 : BGVecInst<v2i64>;
802 def r64 : BGRegInst<R64C>;
803 def r32 : BGRegInst<R32C>;
806 defm BG : BorrowGenerate;
808 // BGX: Borrow generate, extended.
810 RRForm<0b11000010110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB,
812 "bgx\t$rT, $rA, $rB", IntegerOp,
814 RegConstraint<"$rCarry = $rT">,
817 // Halfword multiply variants:
818 // N.B: These can be used to build up larger quantities (16x16 -> 32)
821 RRForm<0b00100011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
822 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
826 RRForm<0b00100011110, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
827 "mpy\t$rT, $rA, $rB", IntegerMulDiv,
828 [(set R16C:$rT, (mul R16C:$rA, R16C:$rB))]>;
830 // Unsigned 16-bit multiply:
832 class MPYUInst<dag OOL, dag IOL, list<dag> pattern>:
833 RRForm<0b00110011110, OOL, IOL,
834 "mpyu\t$rT, $rA, $rB", IntegerMulDiv,
838 MPYUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
842 MPYUInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB),
843 [(set R32C:$rT, (mul (zext R16C:$rA), (zext R16C:$rB)))]>;
846 MPYUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
849 // mpyi: multiply 16 x s10imm -> 32 result.
851 class MPYIInst<dag OOL, dag IOL, list<dag> pattern>:
852 RI10Form<0b00101110, OOL, IOL,
853 "mpyi\t$rT, $rA, $val", IntegerMulDiv,
857 MPYIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
858 [(set (v8i16 VECREG:$rT),
859 (mul (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
862 MPYIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
863 [(set R16C:$rT, (mul R16C:$rA, i16ImmSExt10:$val))]>;
865 // mpyui: same issues as other multiplies, plus, this doesn't match a
866 // pattern... but may be used during target DAG selection or lowering
868 class MPYUIInst<dag OOL, dag IOL, list<dag> pattern>:
869 RI10Form<0b10101110, OOL, IOL,
870 "mpyui\t$rT, $rA, $val", IntegerMulDiv,
874 MPYUIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
878 MPYUIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
881 // mpya: 16 x 16 + 16 -> 32 bit result
882 class MPYAInst<dag OOL, dag IOL, list<dag> pattern>:
883 RRRForm<0b0011, OOL, IOL,
884 "mpya\t$rT, $rA, $rB, $rC", IntegerMulDiv,
888 MPYAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
889 [(set (v4i32 VECREG:$rT),
890 (add (v4i32 (bitconvert (mul (v8i16 VECREG:$rA),
891 (v8i16 VECREG:$rB)))),
892 (v4i32 VECREG:$rC)))]>;
895 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
896 [(set R32C:$rT, (add (sext (mul R16C:$rA, R16C:$rB)),
900 MPYAInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB, R32C:$rC),
901 [(set R32C:$rT, (add (mul (sext R16C:$rA), (sext R16C:$rB)),
904 def MPYAr32_sextinreg:
905 MPYAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB, R32C:$rC),
906 [(set R32C:$rT, (add (mul (sext_inreg R32C:$rA, i16),
907 (sext_inreg R32C:$rB, i16)),
910 // mpyh: multiply high, used to synthesize 32-bit multiplies
911 class MPYHInst<dag OOL, dag IOL, list<dag> pattern>:
912 RRForm<0b10100011110, OOL, IOL,
913 "mpyh\t$rT, $rA, $rB", IntegerMulDiv,
917 MPYHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
921 MPYHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
924 // mpys: multiply high and shift right (returns the top half of
925 // a 16-bit multiply, sign extended to 32 bits.)
927 class MPYSInst<dag OOL, dag IOL>:
928 RRForm<0b11100011110, OOL, IOL,
929 "mpys\t$rT, $rA, $rB", IntegerMulDiv,
933 MPYSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
936 MPYSInst<(outs R32C:$rT), (ins R16C:$rA, R16C:$rB)>;
938 // mpyhh: multiply high-high (returns the 32-bit result from multiplying
939 // the top 16 bits of the $rA, $rB)
941 class MPYHHInst<dag OOL, dag IOL>:
942 RRForm<0b01100011110, OOL, IOL,
943 "mpyhh\t$rT, $rA, $rB", IntegerMulDiv,
947 MPYHHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
950 MPYHHInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
952 // mpyhha: Multiply high-high, add to $rT:
954 class MPYHHAInst<dag OOL, dag IOL>:
955 RRForm<0b01100010110, OOL, IOL,
956 "mpyhha\t$rT, $rA, $rB", IntegerMulDiv,
960 MPYHHAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
963 MPYHHAInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
965 // mpyhhu: Multiply high-high, unsigned, e.g.:
967 // +-------+-------+ +-------+-------+ +---------+
968 // | a0 . a1 | x | b0 . b1 | = | a0 x b0 |
969 // +-------+-------+ +-------+-------+ +---------+
971 // where a0, b0 are the upper 16 bits of the 32-bit word
973 class MPYHHUInst<dag OOL, dag IOL>:
974 RRForm<0b01110011110, OOL, IOL,
975 "mpyhhu\t$rT, $rA, $rB", IntegerMulDiv,
979 MPYHHUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
982 MPYHHUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
984 // mpyhhau: Multiply high-high, unsigned
986 class MPYHHAUInst<dag OOL, dag IOL>:
987 RRForm<0b01110010110, OOL, IOL,
988 "mpyhhau\t$rT, $rA, $rB", IntegerMulDiv,
992 MPYHHAUInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB)>;
995 MPYHHAUInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB)>;
997 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
998 // clz: Count leading zeroes
999 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1000 class CLZInst<dag OOL, dag IOL, list<dag> pattern>:
1001 RRForm_1<0b10100101010, OOL, IOL, "clz\t$rT, $rA",
1002 IntegerOp, pattern>;
1004 class CLZRegInst<RegisterClass rclass>:
1005 CLZInst<(outs rclass:$rT), (ins rclass:$rA),
1006 [(set rclass:$rT, (ctlz rclass:$rA))]>;
1008 class CLZVecInst<ValueType vectype>:
1009 CLZInst<(outs VECREG:$rT), (ins VECREG:$rA),
1010 [(set (vectype VECREG:$rT), (ctlz (vectype VECREG:$rA)))]>;
1012 multiclass CountLeadingZeroes {
1013 def v4i32 : CLZVecInst<v4i32>;
1014 def r32 : CLZRegInst<R32C>;
1017 defm CLZ : CountLeadingZeroes;
1019 // cntb: Count ones in bytes (aka "population count")
1021 // NOTE: This instruction is really a vector instruction, but the custom
1022 // lowering code uses it in unorthodox ways to support CTPOP for other
1026 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1027 "cntb\t$rT, $rA", IntegerOp,
1028 [(set (v16i8 VECREG:$rT), (SPUcntb (v16i8 VECREG:$rA)))]>;
1031 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1032 "cntb\t$rT, $rA", IntegerOp,
1033 [(set (v8i16 VECREG:$rT), (SPUcntb (v8i16 VECREG:$rA)))]>;
1036 RRForm_1<0b00101101010, (outs VECREG:$rT), (ins VECREG:$rA),
1037 "cntb\t$rT, $rA", IntegerOp,
1038 [(set (v4i32 VECREG:$rT), (SPUcntb (v4i32 VECREG:$rA)))]>;
1040 // gbb: Gather the low order bits from each byte in $rA into a single 16-bit
1041 // quantity stored into $rT's slot 0, upper 16 bits are zeroed, as are
1044 // Note: This instruction "pairs" with the fsmb instruction for all of the
1045 // various types defined here.
1047 // Note 2: The "VecInst" and "RegInst" forms refer to the result being either
1048 // a vector or register.
1050 class GBBInst<dag OOL, dag IOL, list<dag> pattern>:
1051 RRForm_1<0b01001101100, OOL, IOL, "gbb\t$rT, $rA", GatherOp, pattern>;
1053 class GBBRegInst<RegisterClass rclass, ValueType vectype>:
1054 GBBInst<(outs rclass:$rT), (ins VECREG:$rA),
1055 [/* no pattern */]>;
1057 class GBBVecInst<ValueType vectype>:
1058 GBBInst<(outs VECREG:$rT), (ins VECREG:$rA),
1059 [/* no pattern */]>;
1061 multiclass GatherBitsFromBytes {
1062 def v16i8_r32: GBBRegInst<R32C, v16i8>;
1063 def v16i8_r16: GBBRegInst<R16C, v16i8>;
1064 def v16i8: GBBVecInst<v16i8>;
1067 defm GBB: GatherBitsFromBytes;
1069 // gbh: Gather all low order bits from each halfword in $rA into a single
1070 // 8-bit quantity stored in $rT's slot 0, with the upper bits of $rT set to 0
1071 // and slots 1-3 also set to 0.
1073 // See notes for GBBInst, above.
1075 class GBHInst<dag OOL, dag IOL, list<dag> pattern>:
1076 RRForm_1<0b10001101100, OOL, IOL, "gbh\t$rT, $rA", GatherOp,
1079 class GBHRegInst<RegisterClass rclass, ValueType vectype>:
1080 GBHInst<(outs rclass:$rT), (ins VECREG:$rA),
1081 [/* no pattern */]>;
1083 class GBHVecInst<ValueType vectype>:
1084 GBHInst<(outs VECREG:$rT), (ins VECREG:$rA),
1085 [/* no pattern */]>;
1087 multiclass GatherBitsHalfword {
1088 def v8i16_r32: GBHRegInst<R32C, v8i16>;
1089 def v8i16_r16: GBHRegInst<R16C, v8i16>;
1090 def v8i16: GBHVecInst<v8i16>;
1093 defm GBH: GatherBitsHalfword;
1095 // gb: Gather all low order bits from each word in $rA into a single
1096 // 4-bit quantity stored in $rT's slot 0, upper bits in $rT set to 0,
1097 // as well as slots 1-3.
1099 // See notes for gbb, above.
1101 class GBInst<dag OOL, dag IOL, list<dag> pattern>:
1102 RRForm_1<0b00001101100, OOL, IOL, "gb\t$rT, $rA", GatherOp,
1105 class GBRegInst<RegisterClass rclass, ValueType vectype>:
1106 GBInst<(outs rclass:$rT), (ins VECREG:$rA),
1107 [/* no pattern */]>;
1109 class GBVecInst<ValueType vectype>:
1110 GBInst<(outs VECREG:$rT), (ins VECREG:$rA),
1111 [/* no pattern */]>;
1113 multiclass GatherBitsWord {
1114 def v4i32_r32: GBRegInst<R32C, v4i32>;
1115 def v4i32_r16: GBRegInst<R16C, v4i32>;
1116 def v4i32: GBVecInst<v4i32>;
1119 defm GB: GatherBitsWord;
1121 // avgb: average bytes
1123 RRForm<0b11001011000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1124 "avgb\t$rT, $rA, $rB", ByteOp,
1127 // absdb: absolute difference of bytes
1129 RRForm<0b11001010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1130 "absdb\t$rT, $rA, $rB", ByteOp,
1133 // sumb: sum bytes into halfwords
1135 RRForm<0b11001010010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1136 "sumb\t$rT, $rA, $rB", ByteOp,
1139 // Sign extension operations:
1140 class XSBHInst<dag OOL, dag IOL, list<dag> pattern>:
1141 RRForm_1<0b01101101010, OOL, IOL,
1142 "xsbh\t$rDst, $rSrc",
1143 IntegerOp, pattern>;
1145 class XSBHVecInst<ValueType vectype>:
1146 XSBHInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1147 [(set (v8i16 VECREG:$rDst), (sext (vectype VECREG:$rSrc)))]>;
1149 class XSBHInRegInst<RegisterClass rclass, list<dag> pattern>:
1150 XSBHInst<(outs rclass:$rDst), (ins rclass:$rSrc),
1153 multiclass ExtendByteHalfword {
1154 def v16i8: XSBHVecInst<v8i16>;
1155 def r8: XSBHInst<(outs R16C:$rDst), (ins R8C:$rSrc),
1156 [(set R16C:$rDst, (sext R8C:$rSrc))]>;
1157 def r16: XSBHInRegInst<R16C,
1158 [(set R16C:$rDst, (sext_inreg R16C:$rSrc, i8))]>;
1160 // 32-bit form for XSBH: used to sign extend 8-bit quantities to 16-bit
1161 // quantities to 32-bit quantities via a 32-bit register (see the sext 8->32
1162 // pattern below). Intentionally doesn't match a pattern because we want the
1163 // sext 8->32 pattern to do the work for us, namely because we need the extra
1165 def r32: XSBHInRegInst<R32C, [/* no pattern */]>;
1167 // Same as the 32-bit version, but for i64
1168 def r64: XSBHInRegInst<R64C, [/* no pattern */]>;
1171 defm XSBH : ExtendByteHalfword;
1173 // Sign extend halfwords to words:
1175 class XSHWInst<dag OOL, dag IOL, list<dag> pattern>:
1176 RRForm_1<0b01101101010, OOL, IOL, "xshw\t$rDest, $rSrc",
1177 IntegerOp, pattern>;
1179 class XSHWVecInst<ValueType in_vectype, ValueType out_vectype>:
1180 XSHWInst<(outs VECREG:$rDest), (ins VECREG:$rSrc),
1181 [(set (out_vectype VECREG:$rDest),
1182 (sext (in_vectype VECREG:$rSrc)))]>;
1184 class XSHWInRegInst<RegisterClass rclass, list<dag> pattern>:
1185 XSHWInst<(outs rclass:$rDest), (ins rclass:$rSrc),
1188 class XSHWRegInst<RegisterClass rclass>:
1189 XSHWInst<(outs rclass:$rDest), (ins R16C:$rSrc),
1190 [(set rclass:$rDest, (sext R16C:$rSrc))]>;
1192 multiclass ExtendHalfwordWord {
1193 def v4i32: XSHWVecInst<v4i32, v8i16>;
1195 def r16: XSHWRegInst<R32C>;
1197 def r32: XSHWInRegInst<R32C,
1198 [(set R32C:$rDest, (sext_inreg R32C:$rSrc, i16))]>;
1199 def r64: XSHWInRegInst<R64C, [/* no pattern */]>;
1202 defm XSHW : ExtendHalfwordWord;
1204 // Sign-extend words to doublewords (32->64 bits)
1206 class XSWDInst<dag OOL, dag IOL, list<dag> pattern>:
1207 RRForm_1<0b01100101010, OOL, IOL, "xswd\t$rDst, $rSrc",
1208 IntegerOp, pattern>;
1210 class XSWDVecInst<ValueType in_vectype, ValueType out_vectype>:
1211 XSWDInst<(outs VECREG:$rDst), (ins VECREG:$rSrc),
1212 [(set (out_vectype VECREG:$rDst),
1213 (sext (out_vectype VECREG:$rSrc)))]>;
1215 class XSWDRegInst<RegisterClass in_rclass, RegisterClass out_rclass>:
1216 XSWDInst<(outs out_rclass:$rDst), (ins in_rclass:$rSrc),
1217 [(set out_rclass:$rDst, (sext in_rclass:$rSrc))]>;
1219 multiclass ExtendWordToDoubleWord {
1220 def v2i64: XSWDVecInst<v4i32, v2i64>;
1221 def r64: XSWDRegInst<R32C, R64C>;
1223 def r64_inreg: XSWDInst<(outs R64C:$rDst), (ins R64C:$rSrc),
1224 [(set R64C:$rDst, (sext_inreg R64C:$rSrc, i32))]>;
1227 defm XSWD : ExtendWordToDoubleWord;
1231 class ANDInst<dag OOL, dag IOL, list<dag> pattern> :
1232 RRForm<0b10000011000, OOL, IOL, "and\t$rT, $rA, $rB",
1233 IntegerOp, pattern>;
1235 class ANDVecInst<ValueType vectype>:
1236 ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1237 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1238 (vectype VECREG:$rB)))]>;
1240 class ANDRegInst<RegisterClass rclass>:
1241 ANDInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1242 [(set rclass:$rT, (and rclass:$rA, rclass:$rB))]>;
1244 multiclass BitwiseAnd
1246 def v16i8: ANDVecInst<v16i8>;
1247 def v8i16: ANDVecInst<v8i16>;
1248 def v4i32: ANDVecInst<v4i32>;
1249 def v2i64: ANDVecInst<v2i64>;
1251 def r128: ANDRegInst<GPRC>;
1252 def r64: ANDRegInst<R64C>;
1253 def r32: ANDRegInst<R32C>;
1254 def r16: ANDRegInst<R16C>;
1255 def r8: ANDRegInst<R8C>;
1257 //===---------------------------------------------
1258 // Special instructions to perform the fabs instruction
1259 def fabs32: ANDInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1260 [/* Intentionally does not match a pattern */]>;
1262 def fabs64: ANDInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1263 [/* Intentionally does not match a pattern */]>;
1265 // Could use v4i32, but won't for clarity
1266 def fabsvec: ANDInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1267 [/* Intentionally does not match a pattern */]>;
1269 //===---------------------------------------------
1271 // Hacked form of AND to zero-extend 16-bit quantities to 32-bit
1272 // quantities -- see 16->32 zext pattern.
1274 // This pattern is somewhat artificial, since it might match some
1275 // compiler generated pattern but it is unlikely to do so.
1277 def i16i32: ANDInst<(outs R32C:$rT), (ins R16C:$rA, R32C:$rB),
1278 [(set R32C:$rT, (and (zext R16C:$rA), R32C:$rB))]>;
1281 defm AND : BitwiseAnd;
1283 // N.B.: vnot_conv is one of those special target selection pattern fragments,
1284 // in which we expect there to be a bit_convert on the constant. Bear in mind
1285 // that llvm translates "not <reg>" to "xor <reg>, -1" (or in this case, a
1286 // constant -1 vector.)
1288 class ANDCInst<dag OOL, dag IOL, list<dag> pattern>:
1289 RRForm<0b10000011010, OOL, IOL, "andc\t$rT, $rA, $rB",
1290 IntegerOp, pattern>;
1292 class ANDCVecInst<ValueType vectype>:
1293 ANDCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1294 [(set (vectype VECREG:$rT), (and (vectype VECREG:$rA),
1295 (vnot (vectype VECREG:$rB))))]>;
1297 class ANDCRegInst<RegisterClass rclass>:
1298 ANDCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1299 [(set rclass:$rT, (and rclass:$rA, (not rclass:$rB)))]>;
1301 multiclass AndComplement
1303 def v16i8: ANDCVecInst<v16i8>;
1304 def v8i16: ANDCVecInst<v8i16>;
1305 def v4i32: ANDCVecInst<v4i32>;
1306 def v2i64: ANDCVecInst<v2i64>;
1308 def r128: ANDCRegInst<GPRC>;
1309 def r64: ANDCRegInst<R64C>;
1310 def r32: ANDCRegInst<R32C>;
1311 def r16: ANDCRegInst<R16C>;
1312 def r8: ANDCRegInst<R8C>;
1315 defm ANDC : AndComplement;
1317 class ANDBIInst<dag OOL, dag IOL, list<dag> pattern>:
1318 RI10Form<0b01101000, OOL, IOL, "andbi\t$rT, $rA, $val",
1321 multiclass AndByteImm
1323 def v16i8: ANDBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1324 [(set (v16i8 VECREG:$rT),
1325 (and (v16i8 VECREG:$rA),
1326 (v16i8 v16i8U8Imm:$val)))]>;
1328 def r8: ANDBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1329 [(set R8C:$rT, (and R8C:$rA, immU8:$val))]>;
1332 defm ANDBI : AndByteImm;
1334 class ANDHIInst<dag OOL, dag IOL, list<dag> pattern> :
1335 RI10Form<0b10101000, OOL, IOL, "andhi\t$rT, $rA, $val",
1338 multiclass AndHalfwordImm
1340 def v8i16: ANDHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1341 [(set (v8i16 VECREG:$rT),
1342 (and (v8i16 VECREG:$rA), v8i16SExt10Imm:$val))]>;
1344 def r16: ANDHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1345 [(set R16C:$rT, (and R16C:$rA, i16ImmUns10:$val))]>;
1347 // Zero-extend i8 to i16:
1348 def i8i16: ANDHIInst<(outs R16C:$rT), (ins R8C:$rA, u10imm:$val),
1349 [(set R16C:$rT, (and (zext R8C:$rA), i16ImmUns10:$val))]>;
1352 defm ANDHI : AndHalfwordImm;
1354 class ANDIInst<dag OOL, dag IOL, list<dag> pattern> :
1355 RI10Form<0b00101000, OOL, IOL, "andi\t$rT, $rA, $val",
1356 IntegerOp, pattern>;
1358 multiclass AndWordImm
1360 def v4i32: ANDIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
1361 [(set (v4i32 VECREG:$rT),
1362 (and (v4i32 VECREG:$rA), v4i32SExt10Imm:$val))]>;
1364 def r32: ANDIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1365 [(set R32C:$rT, (and R32C:$rA, i32ImmSExt10:$val))]>;
1367 // Hacked form of ANDI to zero-extend i8 quantities to i32. See the zext 8->32
1369 def i8i32: ANDIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1371 (and (zext R8C:$rA), i32ImmSExt10:$val))]>;
1373 // Hacked form of ANDI to zero-extend i16 quantities to i32. See the
1374 // zext 16->32 pattern below.
1376 // Note that this pattern is somewhat artificial, since it might match
1377 // something the compiler generates but is unlikely to occur in practice.
1378 def i16i32: ANDIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1380 (and (zext R16C:$rA), i32ImmSExt10:$val))]>;
1383 defm ANDI : AndWordImm;
1385 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1386 // Bitwise OR group:
1387 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
1389 // Bitwise "or" (N.B.: These are also register-register copy instructions...)
1390 class ORInst<dag OOL, dag IOL, list<dag> pattern>:
1391 RRForm<0b10000010000, OOL, IOL, "or\t$rT, $rA, $rB",
1392 IntegerOp, pattern>;
1394 class ORVecInst<ValueType vectype>:
1395 ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1396 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1397 (vectype VECREG:$rB)))]>;
1399 class ORRegInst<RegisterClass rclass>:
1400 ORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1401 [(set rclass:$rT, (or rclass:$rA, rclass:$rB))]>;
1403 // ORCvtForm: OR conversion form
1405 // This is used to "convert" the preferred slot to its vector equivalent, as
1406 // well as convert a vector back to its preferred slot.
1408 // These are effectively no-ops, but need to exist for proper type conversion
1409 // and type coercion.
1411 class ORCvtForm<dag OOL, dag IOL>
1412 : SPUInstr<OOL, IOL, "or\t$rT, $rA, $rA", IntegerOp> {
1416 let Pattern = [/* no pattern */];
1418 let Inst{0-10} = 0b10000010000;
1419 let Inst{11-17} = RA;
1420 let Inst{18-24} = RA;
1421 let Inst{25-31} = RT;
1424 class ORPromoteScalar<RegisterClass rclass>:
1425 ORCvtForm<(outs VECREG:$rT), (ins rclass:$rA)>;
1427 class ORExtractElt<RegisterClass rclass>:
1428 ORCvtForm<(outs rclass:$rT), (ins VECREG:$rA)>;
1430 class ORCvtRegGPRC<RegisterClass rclass>:
1431 ORCvtForm<(outs GPRC:$rT), (ins rclass:$rA)>;
1434 ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>;
1436 class ORCvtGPRCReg<RegisterClass rclass>:
1437 ORCvtForm<(outs rclass:$rT), (ins GPRC:$rA)>;
1439 class ORCvtFormR32Reg<RegisterClass rclass>:
1440 ORCvtForm<(outs rclass:$rT), (ins R32C:$rA)>;
1442 class ORCvtFormRegR32<RegisterClass rclass>:
1443 ORCvtForm<(outs R32C:$rT), (ins rclass:$rA)>;
1445 class ORCvtFormR64Reg<RegisterClass rclass>:
1446 ORCvtForm<(outs rclass:$rT), (ins R64C:$rA)>;
1448 class ORCvtFormRegR64<RegisterClass rclass>:
1449 ORCvtForm<(outs R64C:$rT), (ins rclass:$rA)>;
1452 ORCvtForm<(outs VECREG:$rT), (ins GPRC:$rA)>;
1454 multiclass BitwiseOr
1456 def v16i8: ORVecInst<v16i8>;
1457 def v8i16: ORVecInst<v8i16>;
1458 def v4i32: ORVecInst<v4i32>;
1459 def v2i64: ORVecInst<v2i64>;
1461 def v4f32: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1462 [(set (v4f32 VECREG:$rT),
1463 (v4f32 (bitconvert (or (v4i32 VECREG:$rA),
1464 (v4i32 VECREG:$rB)))))]>;
1466 def v2f64: ORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1467 [(set (v2f64 VECREG:$rT),
1468 (v2f64 (bitconvert (or (v2i64 VECREG:$rA),
1469 (v2i64 VECREG:$rB)))))]>;
1471 def r64: ORRegInst<R64C>;
1472 def r32: ORRegInst<R32C>;
1473 def r16: ORRegInst<R16C>;
1474 def r8: ORRegInst<R8C>;
1476 // OR instructions used to copy f32 and f64 registers.
1477 def f32: ORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
1478 [/* no pattern */]>;
1480 def f64: ORInst<(outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
1481 [/* no pattern */]>;
1483 // scalar->vector promotion, prefslot2vec:
1484 def v16i8_i8: ORPromoteScalar<R8C>;
1485 def v8i16_i16: ORPromoteScalar<R16C>;
1486 def v4i32_i32: ORPromoteScalar<R32C>;
1487 def v2i64_i64: ORPromoteScalar<R64C>;
1488 def v4f32_f32: ORPromoteScalar<R32FP>;
1489 def v2f64_f64: ORPromoteScalar<R64FP>;
1491 // vector->scalar demotion, vec2prefslot:
1492 def i8_v16i8: ORExtractElt<R8C>;
1493 def i16_v8i16: ORExtractElt<R16C>;
1494 def i32_v4i32: ORExtractElt<R32C>;
1495 def i64_v2i64: ORExtractElt<R64C>;
1496 def f32_v4f32: ORExtractElt<R32FP>;
1497 def f64_v2f64: ORExtractElt<R64FP>;
1499 // Conversion from GPRC to register
1500 def i128_r64: ORCvtRegGPRC<R64C>;
1501 def i128_f64: ORCvtRegGPRC<R64FP>;
1502 def i128_r32: ORCvtRegGPRC<R32C>;
1503 def i128_f32: ORCvtRegGPRC<R32FP>;
1504 def i128_r16: ORCvtRegGPRC<R16C>;
1505 def i128_r8: ORCvtRegGPRC<R8C>;
1507 // Conversion from GPRC to vector
1508 def i128_vec: ORCvtVecGPRC;
1510 // Conversion from register to GPRC
1511 def r64_i128: ORCvtGPRCReg<R64C>;
1512 def f64_i128: ORCvtGPRCReg<R64FP>;
1513 def r32_i128: ORCvtGPRCReg<R32C>;
1514 def f32_i128: ORCvtGPRCReg<R32FP>;
1515 def r16_i128: ORCvtGPRCReg<R16C>;
1516 def r8_i128: ORCvtGPRCReg<R8C>;
1518 // Conversion from vector to GPRC
1519 def vec_i128: ORCvtGPRCVec;
1521 // Conversion from register to R32C:
1522 def r16_r32: ORCvtFormRegR32<R16C>;
1523 def r8_r32: ORCvtFormRegR32<R8C>;
1525 // Conversion from R32C to register
1526 def r32_r16: ORCvtFormR32Reg<R16C>;
1527 def r32_r8: ORCvtFormR32Reg<R8C>;
1529 // Conversion from register to R64C:
1530 def r32_r64: ORCvtFormR64Reg<R32C>;
1531 def r16_r64: ORCvtFormR64Reg<R16C>;
1532 def r8_r64: ORCvtFormR64Reg<R8C>;
1534 // Conversion from R64C to register
1535 def r64_r32: ORCvtFormRegR64<R32C>;
1536 def r64_r16: ORCvtFormRegR64<R16C>;
1537 def r64_r8: ORCvtFormRegR64<R8C>;
1540 defm OR : BitwiseOr;
1542 // scalar->vector promotion patterns (preferred slot to vector):
1543 def : Pat<(v16i8 (SPUprefslot2vec R8C:$rA)),
1544 (ORv16i8_i8 R8C:$rA)>;
1546 def : Pat<(v8i16 (SPUprefslot2vec R16C:$rA)),
1547 (ORv8i16_i16 R16C:$rA)>;
1549 def : Pat<(v4i32 (SPUprefslot2vec R32C:$rA)),
1550 (ORv4i32_i32 R32C:$rA)>;
1552 def : Pat<(v2i64 (SPUprefslot2vec R64C:$rA)),
1553 (ORv2i64_i64 R64C:$rA)>;
1555 def : Pat<(v4f32 (SPUprefslot2vec R32FP:$rA)),
1556 (ORv4f32_f32 R32FP:$rA)>;
1558 def : Pat<(v2f64 (SPUprefslot2vec R64FP:$rA)),
1559 (ORv2f64_f64 R64FP:$rA)>;
1561 // ORi*_v*: Used to extract vector element 0 (the preferred slot), otherwise
1562 // known as converting the vector back to its preferred slot
1564 def : Pat<(SPUvec2prefslot (v16i8 VECREG:$rA)),
1565 (ORi8_v16i8 VECREG:$rA)>;
1567 def : Pat<(SPUvec2prefslot (v8i16 VECREG:$rA)),
1568 (ORi16_v8i16 VECREG:$rA)>;
1570 def : Pat<(SPUvec2prefslot (v4i32 VECREG:$rA)),
1571 (ORi32_v4i32 VECREG:$rA)>;
1573 def : Pat<(SPUvec2prefslot (v2i64 VECREG:$rA)),
1574 (ORi64_v2i64 VECREG:$rA)>;
1576 def : Pat<(SPUvec2prefslot (v4f32 VECREG:$rA)),
1577 (ORf32_v4f32 VECREG:$rA)>;
1579 def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)),
1580 (ORf64_v2f64 VECREG:$rA)>;
1582 // Load Register: This is an assembler alias for a bitwise OR of a register
1583 // against itself. It's here because it brings some clarity to assembly
1586 let hasCtrlDep = 1 in {
1587 class LRInst<dag OOL, dag IOL>
1588 : SPUInstr<OOL, IOL, "lr\t$rT, $rA", IntegerOp> {
1592 let Pattern = [/*no pattern*/];
1594 let Inst{0-10} = 0b10000010000; /* It's an OR operation */
1595 let Inst{11-17} = RA;
1596 let Inst{18-24} = RA;
1597 let Inst{25-31} = RT;
1600 class LRVecInst<ValueType vectype>:
1601 LRInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
1603 class LRRegInst<RegisterClass rclass>:
1604 LRInst<(outs rclass:$rT), (ins rclass:$rA)>;
1606 multiclass LoadRegister {
1607 def v2i64: LRVecInst<v2i64>;
1608 def v2f64: LRVecInst<v2f64>;
1609 def v4i32: LRVecInst<v4i32>;
1610 def v4f32: LRVecInst<v4f32>;
1611 def v8i16: LRVecInst<v8i16>;
1612 def v16i8: LRVecInst<v16i8>;
1614 def r128: LRRegInst<GPRC>;
1615 def r64: LRRegInst<R64C>;
1616 def f64: LRRegInst<R64FP>;
1617 def r32: LRRegInst<R32C>;
1618 def f32: LRRegInst<R32FP>;
1619 def r16: LRRegInst<R16C>;
1620 def r8: LRRegInst<R8C>;
1623 defm LR: LoadRegister;
1626 // ORC: Bitwise "or" with complement (c = a | ~b)
1628 class ORCInst<dag OOL, dag IOL, list<dag> pattern>:
1629 RRForm<0b10010010000, OOL, IOL, "orc\t$rT, $rA, $rB",
1630 IntegerOp, pattern>;
1632 class ORCVecInst<ValueType vectype>:
1633 ORCInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1634 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1635 (vnot (vectype VECREG:$rB))))]>;
1637 class ORCRegInst<RegisterClass rclass>:
1638 ORCInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1639 [(set rclass:$rT, (or rclass:$rA, (not rclass:$rB)))]>;
1641 multiclass BitwiseOrComplement
1643 def v16i8: ORCVecInst<v16i8>;
1644 def v8i16: ORCVecInst<v8i16>;
1645 def v4i32: ORCVecInst<v4i32>;
1646 def v2i64: ORCVecInst<v2i64>;
1648 def r64: ORCRegInst<R64C>;
1649 def r32: ORCRegInst<R32C>;
1650 def r16: ORCRegInst<R16C>;
1651 def r8: ORCRegInst<R8C>;
1654 defm ORC : BitwiseOrComplement;
1656 // OR byte immediate
1657 class ORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1658 RI10Form<0b01100000, OOL, IOL, "orbi\t$rT, $rA, $val",
1659 IntegerOp, pattern>;
1661 class ORBIVecInst<ValueType vectype, PatLeaf immpred>:
1662 ORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1663 [(set (v16i8 VECREG:$rT), (or (vectype VECREG:$rA),
1664 (vectype immpred:$val)))]>;
1666 multiclass BitwiseOrByteImm
1668 def v16i8: ORBIVecInst<v16i8, v16i8U8Imm>;
1670 def r8: ORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1671 [(set R8C:$rT, (or R8C:$rA, immU8:$val))]>;
1674 defm ORBI : BitwiseOrByteImm;
1676 // OR halfword immediate
1677 class ORHIInst<dag OOL, dag IOL, list<dag> pattern>:
1678 RI10Form<0b10100000, OOL, IOL, "orhi\t$rT, $rA, $val",
1679 IntegerOp, pattern>;
1681 class ORHIVecInst<ValueType vectype, PatLeaf immpred>:
1682 ORHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1683 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1686 multiclass BitwiseOrHalfwordImm
1688 def v8i16: ORHIVecInst<v8i16, v8i16Uns10Imm>;
1690 def r16: ORHIInst<(outs R16C:$rT), (ins R16C:$rA, u10imm:$val),
1691 [(set R16C:$rT, (or R16C:$rA, i16ImmUns10:$val))]>;
1693 // Specialized ORHI form used to promote 8-bit registers to 16-bit
1694 def i8i16: ORHIInst<(outs R16C:$rT), (ins R8C:$rA, s10imm:$val),
1695 [(set R16C:$rT, (or (anyext R8C:$rA),
1696 i16ImmSExt10:$val))]>;
1699 defm ORHI : BitwiseOrHalfwordImm;
1701 class ORIInst<dag OOL, dag IOL, list<dag> pattern>:
1702 RI10Form<0b00100000, OOL, IOL, "ori\t$rT, $rA, $val",
1703 IntegerOp, pattern>;
1705 class ORIVecInst<ValueType vectype, PatLeaf immpred>:
1706 ORIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1707 [(set (vectype VECREG:$rT), (or (vectype VECREG:$rA),
1710 // Bitwise "or" with immediate
1711 multiclass BitwiseOrImm
1713 def v4i32: ORIVecInst<v4i32, v4i32Uns10Imm>;
1715 def r32: ORIInst<(outs R32C:$rT), (ins R32C:$rA, u10imm_i32:$val),
1716 [(set R32C:$rT, (or R32C:$rA, i32ImmUns10:$val))]>;
1718 // i16i32: hacked version of the ori instruction to extend 16-bit quantities
1719 // to 32-bit quantities. used exclusively to match "anyext" conversions (vide
1720 // infra "anyext 16->32" pattern.)
1721 def i16i32: ORIInst<(outs R32C:$rT), (ins R16C:$rA, s10imm_i32:$val),
1722 [(set R32C:$rT, (or (anyext R16C:$rA),
1723 i32ImmSExt10:$val))]>;
1725 // i8i32: Hacked version of the ORI instruction to extend 16-bit quantities
1726 // to 32-bit quantities. Used exclusively to match "anyext" conversions (vide
1727 // infra "anyext 16->32" pattern.)
1728 def i8i32: ORIInst<(outs R32C:$rT), (ins R8C:$rA, s10imm_i32:$val),
1729 [(set R32C:$rT, (or (anyext R8C:$rA),
1730 i32ImmSExt10:$val))]>;
1733 defm ORI : BitwiseOrImm;
1735 // ORX: "or" across the vector: or's $rA's word slots leaving the result in
1736 // $rT[0], slots 1-3 are zeroed.
1738 // FIXME: Needs to match an intrinsic pattern.
1740 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1741 "orx\t$rT, $rA, $rB", IntegerOp,
1746 class XORInst<dag OOL, dag IOL, list<dag> pattern> :
1747 RRForm<0b10010010000, OOL, IOL, "xor\t$rT, $rA, $rB",
1748 IntegerOp, pattern>;
1750 class XORVecInst<ValueType vectype>:
1751 XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1752 [(set (vectype VECREG:$rT), (xor (vectype VECREG:$rA),
1753 (vectype VECREG:$rB)))]>;
1755 class XORRegInst<RegisterClass rclass>:
1756 XORInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
1757 [(set rclass:$rT, (xor rclass:$rA, rclass:$rB))]>;
1759 multiclass BitwiseExclusiveOr
1761 def v16i8: XORVecInst<v16i8>;
1762 def v8i16: XORVecInst<v8i16>;
1763 def v4i32: XORVecInst<v4i32>;
1764 def v2i64: XORVecInst<v2i64>;
1766 def r128: XORRegInst<GPRC>;
1767 def r64: XORRegInst<R64C>;
1768 def r32: XORRegInst<R32C>;
1769 def r16: XORRegInst<R16C>;
1770 def r8: XORRegInst<R8C>;
1772 // Special forms for floating point instructions.
1773 // fneg and fabs require bitwise logical ops to manipulate the sign bit.
1775 def fneg32: XORInst<(outs R32FP:$rT), (ins R32FP:$rA, R32C:$rB),
1776 [/* no pattern */]>;
1778 def fneg64: XORInst<(outs R64FP:$rT), (ins R64FP:$rA, VECREG:$rB),
1779 [/* no pattern */]>;
1781 def fnegvec: XORInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1782 [/* no pattern, see fneg{32,64} */]>;
1785 defm XOR : BitwiseExclusiveOr;
1787 //==----------------------------------------------------------
1789 class XORBIInst<dag OOL, dag IOL, list<dag> pattern>:
1790 RI10Form<0b01100000, OOL, IOL, "xorbi\t$rT, $rA, $val",
1791 IntegerOp, pattern>;
1793 multiclass XorByteImm
1796 XORBIInst<(outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1797 [(set (v16i8 VECREG:$rT), (xor (v16i8 VECREG:$rA), v16i8U8Imm:$val))]>;
1800 XORBIInst<(outs R8C:$rT), (ins R8C:$rA, u10imm_i8:$val),
1801 [(set R8C:$rT, (xor R8C:$rA, immU8:$val))]>;
1804 defm XORBI : XorByteImm;
1807 RI10Form<0b10100000, (outs VECREG:$rT), (ins VECREG:$rA, u10imm:$val),
1808 "xorhi\t$rT, $rA, $val", IntegerOp,
1809 [(set (v8i16 VECREG:$rT), (xor (v8i16 VECREG:$rA),
1810 v8i16SExt10Imm:$val))]>;
1813 RI10Form<0b10100000, (outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
1814 "xorhi\t$rT, $rA, $val", IntegerOp,
1815 [(set R16C:$rT, (xor R16C:$rA, i16ImmSExt10:$val))]>;
1818 RI10Form<0b00100000, (outs VECREG:$rT), (ins VECREG:$rA, s10imm_i32:$val),
1819 "xori\t$rT, $rA, $val", IntegerOp,
1820 [(set (v4i32 VECREG:$rT), (xor (v4i32 VECREG:$rA),
1821 v4i32SExt10Imm:$val))]>;
1824 RI10Form<0b00100000, (outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
1825 "xori\t$rT, $rA, $val", IntegerOp,
1826 [(set R32C:$rT, (xor R32C:$rA, i32ImmSExt10:$val))]>;
1830 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1831 "nand\t$rT, $rA, $rB", IntegerOp,
1832 [(set (v16i8 VECREG:$rT), (vnot (and (v16i8 VECREG:$rA),
1833 (v16i8 VECREG:$rB))))]>;
1836 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1837 "nand\t$rT, $rA, $rB", IntegerOp,
1838 [(set (v8i16 VECREG:$rT), (vnot (and (v8i16 VECREG:$rA),
1839 (v8i16 VECREG:$rB))))]>;
1842 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1843 "nand\t$rT, $rA, $rB", IntegerOp,
1844 [(set (v4i32 VECREG:$rT), (vnot (and (v4i32 VECREG:$rA),
1845 (v4i32 VECREG:$rB))))]>;
1848 RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1849 "nand\t$rT, $rA, $rB", IntegerOp,
1850 [(set R32C:$rT, (not (and R32C:$rA, R32C:$rB)))]>;
1853 RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1854 "nand\t$rT, $rA, $rB", IntegerOp,
1855 [(set R16C:$rT, (not (and R16C:$rA, R16C:$rB)))]>;
1858 RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
1859 "nand\t$rT, $rA, $rB", IntegerOp,
1860 [(set R8C:$rT, (not (and R8C:$rA, R8C:$rB)))]>;
1864 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1865 "nor\t$rT, $rA, $rB", IntegerOp,
1866 [(set (v16i8 VECREG:$rT), (vnot (or (v16i8 VECREG:$rA),
1867 (v16i8 VECREG:$rB))))]>;
1870 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1871 "nor\t$rT, $rA, $rB", IntegerOp,
1872 [(set (v8i16 VECREG:$rT), (vnot (or (v8i16 VECREG:$rA),
1873 (v8i16 VECREG:$rB))))]>;
1876 RRForm<0b10010010000, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
1877 "nor\t$rT, $rA, $rB", IntegerOp,
1878 [(set (v4i32 VECREG:$rT), (vnot (or (v4i32 VECREG:$rA),
1879 (v4i32 VECREG:$rB))))]>;
1882 RRForm<0b10010010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
1883 "nor\t$rT, $rA, $rB", IntegerOp,
1884 [(set R32C:$rT, (not (or R32C:$rA, R32C:$rB)))]>;
1887 RRForm<0b10010010000, (outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
1888 "nor\t$rT, $rA, $rB", IntegerOp,
1889 [(set R16C:$rT, (not (or R16C:$rA, R16C:$rB)))]>;
1892 RRForm<0b10010010000, (outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
1893 "nor\t$rT, $rA, $rB", IntegerOp,
1894 [(set R8C:$rT, (not (or R8C:$rA, R8C:$rB)))]>;
1897 class SELBInst<dag OOL, dag IOL, list<dag> pattern>:
1898 RRRForm<0b1000, OOL, IOL, "selb\t$rT, $rA, $rB, $rC",
1899 IntegerOp, pattern>;
1901 class SELBVecInst<ValueType vectype>:
1902 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1903 [(set (vectype VECREG:$rT),
1904 (or (and (vectype VECREG:$rC), (vectype VECREG:$rB)),
1905 (and (vnot (vectype VECREG:$rC)),
1906 (vectype VECREG:$rA))))]>;
1908 class SELBVecVCondInst<ValueType vectype>:
1909 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1910 [(set (vectype VECREG:$rT),
1911 (select (vectype VECREG:$rC),
1912 (vectype VECREG:$rB),
1913 (vectype VECREG:$rA)))]>;
1915 class SELBVecCondInst<ValueType vectype>:
1916 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, R32C:$rC),
1917 [(set (vectype VECREG:$rT),
1919 (vectype VECREG:$rB),
1920 (vectype VECREG:$rA)))]>;
1922 class SELBRegInst<RegisterClass rclass>:
1923 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rclass:$rC),
1925 (or (and rclass:$rB, rclass:$rC),
1926 (and rclass:$rA, (not rclass:$rC))))]>;
1928 class SELBRegCondInst<RegisterClass rcond, RegisterClass rclass>:
1929 SELBInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB, rcond:$rC),
1931 (select rcond:$rC, rclass:$rB, rclass:$rA))]>;
1933 multiclass SelectBits
1935 def v16i8: SELBVecInst<v16i8>;
1936 def v8i16: SELBVecInst<v8i16>;
1937 def v4i32: SELBVecInst<v4i32>;
1938 def v2i64: SELBVecInst<v2i64>;
1940 def r128: SELBRegInst<GPRC>;
1941 def r64: SELBRegInst<R64C>;
1942 def r32: SELBRegInst<R32C>;
1943 def r16: SELBRegInst<R16C>;
1944 def r8: SELBRegInst<R8C>;
1946 def v16i8_cond: SELBVecCondInst<v16i8>;
1947 def v8i16_cond: SELBVecCondInst<v8i16>;
1948 def v4i32_cond: SELBVecCondInst<v4i32>;
1949 def v2i64_cond: SELBVecCondInst<v2i64>;
1951 def v16i8_vcond: SELBVecCondInst<v16i8>;
1952 def v8i16_vcond: SELBVecCondInst<v8i16>;
1953 def v4i32_vcond: SELBVecCondInst<v4i32>;
1954 def v2i64_vcond: SELBVecCondInst<v2i64>;
1957 SELBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
1958 [(set (v4f32 VECREG:$rT),
1959 (select (v4i32 VECREG:$rC),
1961 (v4f32 VECREG:$rA)))]>;
1963 // SELBr64_cond is defined further down, look for i64 comparisons
1964 def r32_cond: SELBRegCondInst<R32C, R32C>;
1965 def f32_cond: SELBRegCondInst<R32C, R32FP>;
1966 def r16_cond: SELBRegCondInst<R16C, R16C>;
1967 def r8_cond: SELBRegCondInst<R8C, R8C>;
1970 defm SELB : SelectBits;
1972 class SPUselbPatVec<ValueType vectype, SPUInstr inst>:
1973 Pat<(SPUselb (vectype VECREG:$rA), (vectype VECREG:$rB), (vectype VECREG:$rC)),
1974 (inst VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
1976 def : SPUselbPatVec<v16i8, SELBv16i8>;
1977 def : SPUselbPatVec<v8i16, SELBv8i16>;
1978 def : SPUselbPatVec<v4i32, SELBv4i32>;
1979 def : SPUselbPatVec<v2i64, SELBv2i64>;
1981 class SPUselbPatReg<RegisterClass rclass, SPUInstr inst>:
1982 Pat<(SPUselb rclass:$rA, rclass:$rB, rclass:$rC),
1983 (inst rclass:$rA, rclass:$rB, rclass:$rC)>;
1985 def : SPUselbPatReg<R8C, SELBr8>;
1986 def : SPUselbPatReg<R16C, SELBr16>;
1987 def : SPUselbPatReg<R32C, SELBr32>;
1988 def : SPUselbPatReg<R64C, SELBr64>;
1990 // EQV: Equivalence (1 for each same bit, otherwise 0)
1992 // Note: There are a lot of ways to match this bit operator and these patterns
1993 // attempt to be as exhaustive as possible.
1995 class EQVInst<dag OOL, dag IOL, list<dag> pattern>:
1996 RRForm<0b10010010000, OOL, IOL, "eqv\t$rT, $rA, $rB",
1997 IntegerOp, pattern>;
1999 class EQVVecInst<ValueType vectype>:
2000 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2001 [(set (vectype VECREG:$rT),
2002 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2003 (and (vnot (vectype VECREG:$rA)),
2004 (vnot (vectype VECREG:$rB)))))]>;
2006 class EQVRegInst<RegisterClass rclass>:
2007 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2008 [(set rclass:$rT, (or (and rclass:$rA, rclass:$rB),
2009 (and (not rclass:$rA), (not rclass:$rB))))]>;
2011 class EQVVecPattern1<ValueType vectype>:
2012 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2013 [(set (vectype VECREG:$rT),
2014 (xor (vectype VECREG:$rA), (vnot (vectype VECREG:$rB))))]>;
2016 class EQVRegPattern1<RegisterClass rclass>:
2017 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2018 [(set rclass:$rT, (xor rclass:$rA, (not rclass:$rB)))]>;
2020 class EQVVecPattern2<ValueType vectype>:
2021 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2022 [(set (vectype VECREG:$rT),
2023 (or (and (vectype VECREG:$rA), (vectype VECREG:$rB)),
2024 (vnot (or (vectype VECREG:$rA), (vectype VECREG:$rB)))))]>;
2026 class EQVRegPattern2<RegisterClass rclass>:
2027 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2029 (or (and rclass:$rA, rclass:$rB),
2030 (not (or rclass:$rA, rclass:$rB))))]>;
2032 class EQVVecPattern3<ValueType vectype>:
2033 EQVInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2034 [(set (vectype VECREG:$rT),
2035 (not (xor (vectype VECREG:$rA), (vectype VECREG:$rB))))]>;
2037 class EQVRegPattern3<RegisterClass rclass>:
2038 EQVInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2039 [(set rclass:$rT, (not (xor rclass:$rA, rclass:$rB)))]>;
2041 multiclass BitEquivalence
2043 def v16i8: EQVVecInst<v16i8>;
2044 def v8i16: EQVVecInst<v8i16>;
2045 def v4i32: EQVVecInst<v4i32>;
2046 def v2i64: EQVVecInst<v2i64>;
2048 def v16i8_1: EQVVecPattern1<v16i8>;
2049 def v8i16_1: EQVVecPattern1<v8i16>;
2050 def v4i32_1: EQVVecPattern1<v4i32>;
2051 def v2i64_1: EQVVecPattern1<v2i64>;
2053 def v16i8_2: EQVVecPattern2<v16i8>;
2054 def v8i16_2: EQVVecPattern2<v8i16>;
2055 def v4i32_2: EQVVecPattern2<v4i32>;
2056 def v2i64_2: EQVVecPattern2<v2i64>;
2058 def v16i8_3: EQVVecPattern3<v16i8>;
2059 def v8i16_3: EQVVecPattern3<v8i16>;
2060 def v4i32_3: EQVVecPattern3<v4i32>;
2061 def v2i64_3: EQVVecPattern3<v2i64>;
2063 def r128: EQVRegInst<GPRC>;
2064 def r64: EQVRegInst<R64C>;
2065 def r32: EQVRegInst<R32C>;
2066 def r16: EQVRegInst<R16C>;
2067 def r8: EQVRegInst<R8C>;
2069 def r128_1: EQVRegPattern1<GPRC>;
2070 def r64_1: EQVRegPattern1<R64C>;
2071 def r32_1: EQVRegPattern1<R32C>;
2072 def r16_1: EQVRegPattern1<R16C>;
2073 def r8_1: EQVRegPattern1<R8C>;
2075 def r128_2: EQVRegPattern2<GPRC>;
2076 def r64_2: EQVRegPattern2<R64C>;
2077 def r32_2: EQVRegPattern2<R32C>;
2078 def r16_2: EQVRegPattern2<R16C>;
2079 def r8_2: EQVRegPattern2<R8C>;
2081 def r128_3: EQVRegPattern3<GPRC>;
2082 def r64_3: EQVRegPattern3<R64C>;
2083 def r32_3: EQVRegPattern3<R32C>;
2084 def r16_3: EQVRegPattern3<R16C>;
2085 def r8_3: EQVRegPattern3<R8C>;
2088 defm EQV: BitEquivalence;
2090 //===----------------------------------------------------------------------===//
2091 // Vector shuffle...
2092 //===----------------------------------------------------------------------===//
2093 // SPUshuffle is generated in LowerVECTOR_SHUFFLE and gets replaced with SHUFB.
2094 // See the SPUshuffle SDNode operand above, which sets up the DAG pattern
2095 // matcher to emit something when the LowerVECTOR_SHUFFLE generates a node with
2096 // the SPUISD::SHUFB opcode.
2097 //===----------------------------------------------------------------------===//
2099 class SHUFBInst<dag OOL, dag IOL, list<dag> pattern>:
2100 RRRForm<0b1000, OOL, IOL, "shufb\t$rT, $rA, $rB, $rC",
2101 IntegerOp, pattern>;
2103 class SHUFBVecInst<ValueType resultvec, ValueType maskvec>:
2104 SHUFBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
2105 [(set (resultvec VECREG:$rT),
2106 (SPUshuffle (resultvec VECREG:$rA),
2107 (resultvec VECREG:$rB),
2108 (maskvec VECREG:$rC)))]>;
2110 class SHUFBGPRCInst:
2111 SHUFBInst<(outs VECREG:$rT), (ins GPRC:$rA, GPRC:$rB, VECREG:$rC),
2112 [/* no pattern */]>;
2114 multiclass ShuffleBytes
2116 def v16i8 : SHUFBVecInst<v16i8, v16i8>;
2117 def v16i8_m32 : SHUFBVecInst<v16i8, v4i32>;
2118 def v8i16 : SHUFBVecInst<v8i16, v16i8>;
2119 def v8i16_m32 : SHUFBVecInst<v8i16, v4i32>;
2120 def v4i32 : SHUFBVecInst<v4i32, v16i8>;
2121 def v4i32_m32 : SHUFBVecInst<v4i32, v4i32>;
2122 def v2i64 : SHUFBVecInst<v2i64, v16i8>;
2123 def v2i64_m32 : SHUFBVecInst<v2i64, v4i32>;
2125 def v4f32 : SHUFBVecInst<v4f32, v16i8>;
2126 def v4f32_m32 : SHUFBVecInst<v4f32, v4i32>;
2128 def v2f64 : SHUFBVecInst<v2f64, v16i8>;
2129 def v2f64_m32 : SHUFBVecInst<v2f64, v4i32>;
2131 def gprc : SHUFBGPRCInst;
2134 defm SHUFB : ShuffleBytes;
2136 //===----------------------------------------------------------------------===//
2137 // Shift and rotate group:
2138 //===----------------------------------------------------------------------===//
2140 class SHLHInst<dag OOL, dag IOL, list<dag> pattern>:
2141 RRForm<0b11111010000, OOL, IOL, "shlh\t$rT, $rA, $rB",
2142 RotateShift, pattern>;
2144 class SHLHVecInst<ValueType vectype>:
2145 SHLHInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2146 [(set (vectype VECREG:$rT),
2147 (SPUvec_shl (vectype VECREG:$rA), R16C:$rB))]>;
2149 // $rB gets promoted to 32-bit register type when confronted with
2150 // this llvm assembly code:
2152 // define i16 @shlh_i16_1(i16 %arg1, i16 %arg2) {
2153 // %A = shl i16 %arg1, %arg2
2157 multiclass ShiftLeftHalfword
2159 def v8i16: SHLHVecInst<v8i16>;
2160 def r16: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
2161 [(set R16C:$rT, (shl R16C:$rA, R16C:$rB))]>;
2162 def r16_r32: SHLHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2163 [(set R16C:$rT, (shl R16C:$rA, R32C:$rB))]>;
2166 defm SHLH : ShiftLeftHalfword;
2168 //===----------------------------------------------------------------------===//
2170 class SHLHIInst<dag OOL, dag IOL, list<dag> pattern>:
2171 RI7Form<0b11111010000, OOL, IOL, "shlhi\t$rT, $rA, $val",
2172 RotateShift, pattern>;
2174 class SHLHIVecInst<ValueType vectype>:
2175 SHLHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2176 [(set (vectype VECREG:$rT),
2177 (SPUvec_shl (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2179 multiclass ShiftLeftHalfwordImm
2181 def v8i16: SHLHIVecInst<v8i16>;
2182 def r16: SHLHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2183 [(set R16C:$rT, (shl R16C:$rA, (i16 uimm7:$val)))]>;
2186 defm SHLHI : ShiftLeftHalfwordImm;
2188 def : Pat<(SPUvec_shl (v8i16 VECREG:$rA), (i32 uimm7:$val)),
2189 (SHLHIv8i16 VECREG:$rA, uimm7:$val)>;
2191 def : Pat<(shl R16C:$rA, (i32 uimm7:$val)),
2192 (SHLHIr16 R16C:$rA, uimm7:$val)>;
2194 //===----------------------------------------------------------------------===//
2196 class SHLInst<dag OOL, dag IOL, list<dag> pattern>:
2197 RRForm<0b11111010000, OOL, IOL, "shl\t$rT, $rA, $rB",
2198 RotateShift, pattern>;
2200 multiclass ShiftLeftWord
2203 SHLInst<(outs VECREG:$rT), (ins VECREG:$rA, R16C:$rB),
2204 [(set (v4i32 VECREG:$rT),
2205 (SPUvec_shl (v4i32 VECREG:$rA), R16C:$rB))]>;
2207 SHLInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2208 [(set R32C:$rT, (shl R32C:$rA, R32C:$rB))]>;
2211 defm SHL: ShiftLeftWord;
2213 //===----------------------------------------------------------------------===//
2215 class SHLIInst<dag OOL, dag IOL, list<dag> pattern>:
2216 RI7Form<0b11111010000, OOL, IOL, "shli\t$rT, $rA, $val",
2217 RotateShift, pattern>;
2219 multiclass ShiftLeftWordImm
2222 SHLIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2223 [(set (v4i32 VECREG:$rT),
2224 (SPUvec_shl (v4i32 VECREG:$rA), (i32 uimm7:$val)))]>;
2227 SHLIInst<(outs R32C:$rT), (ins R32C:$rA, u7imm_i32:$val),
2228 [(set R32C:$rT, (shl R32C:$rA, (i32 uimm7:$val)))]>;
2231 defm SHLI : ShiftLeftWordImm;
2233 //===----------------------------------------------------------------------===//
2234 // SHLQBI vec form: Note that this will shift the entire vector (the 128-bit
2235 // register) to the left. Vector form is here to ensure type correctness.
2237 // The shift count is in the lowest 3 bits (29-31) of $rB, so only a bit shift
2238 // of 7 bits is actually possible.
2240 // Note also that SHLQBI/SHLQBII are used in conjunction with SHLQBY/SHLQBYI
2241 // to shift i64 and i128. SHLQBI is the residual left over after shifting by
2242 // bytes with SHLQBY.
2244 class SHLQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2245 RRForm<0b11011011100, OOL, IOL, "shlqbi\t$rT, $rA, $rB",
2246 RotateShift, pattern>;
2248 class SHLQBIVecInst<ValueType vectype>:
2249 SHLQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2250 [(set (vectype VECREG:$rT),
2251 (SPUshlquad_l_bits (vectype VECREG:$rA), R32C:$rB))]>;
2253 multiclass ShiftLeftQuadByBits
2255 def v16i8: SHLQBIVecInst<v16i8>;
2256 def v8i16: SHLQBIVecInst<v8i16>;
2257 def v4i32: SHLQBIVecInst<v4i32>;
2258 def v4f32: SHLQBIVecInst<v4f32>;
2259 def v2i64: SHLQBIVecInst<v2i64>;
2260 def v2f64: SHLQBIVecInst<v2f64>;
2263 defm SHLQBI : ShiftLeftQuadByBits;
2265 // See note above on SHLQBI. In this case, the predicate actually does then
2266 // enforcement, whereas with SHLQBI, we have to "take it on faith."
2267 class SHLQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2268 RI7Form<0b11011111100, OOL, IOL, "shlqbii\t$rT, $rA, $val",
2269 RotateShift, pattern>;
2271 class SHLQBIIVecInst<ValueType vectype>:
2272 SHLQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2273 [(set (vectype VECREG:$rT),
2274 (SPUshlquad_l_bits (vectype VECREG:$rA), (i32 bitshift:$val)))]>;
2276 multiclass ShiftLeftQuadByBitsImm
2278 def v16i8 : SHLQBIIVecInst<v16i8>;
2279 def v8i16 : SHLQBIIVecInst<v8i16>;
2280 def v4i32 : SHLQBIIVecInst<v4i32>;
2281 def v4f32 : SHLQBIIVecInst<v4f32>;
2282 def v2i64 : SHLQBIIVecInst<v2i64>;
2283 def v2f64 : SHLQBIIVecInst<v2f64>;
2286 defm SHLQBII : ShiftLeftQuadByBitsImm;
2288 // SHLQBY, SHLQBYI vector forms: Shift the entire vector to the left by bytes,
2289 // not by bits. See notes above on SHLQBI.
2291 class SHLQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2292 RI7Form<0b11111011100, OOL, IOL, "shlqby\t$rT, $rA, $rB",
2293 RotateShift, pattern>;
2295 class SHLQBYVecInst<ValueType vectype>:
2296 SHLQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2297 [(set (vectype VECREG:$rT),
2298 (SPUshlquad_l_bytes (vectype VECREG:$rA), R32C:$rB))]>;
2300 multiclass ShiftLeftQuadBytes
2302 def v16i8: SHLQBYVecInst<v16i8>;
2303 def v8i16: SHLQBYVecInst<v8i16>;
2304 def v4i32: SHLQBYVecInst<v4i32>;
2305 def v4f32: SHLQBYVecInst<v4f32>;
2306 def v2i64: SHLQBYVecInst<v2i64>;
2307 def v2f64: SHLQBYVecInst<v2f64>;
2308 def r128: SHLQBYInst<(outs GPRC:$rT), (ins GPRC:$rA, R32C:$rB),
2309 [(set GPRC:$rT, (SPUshlquad_l_bytes GPRC:$rA, R32C:$rB))]>;
2312 defm SHLQBY: ShiftLeftQuadBytes;
2314 class SHLQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2315 RI7Form<0b11111111100, OOL, IOL, "shlqbyi\t$rT, $rA, $val",
2316 RotateShift, pattern>;
2318 class SHLQBYIVecInst<ValueType vectype>:
2319 SHLQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm_i32:$val),
2320 [(set (vectype VECREG:$rT),
2321 (SPUshlquad_l_bytes (vectype VECREG:$rA), (i32 uimm7:$val)))]>;
2323 multiclass ShiftLeftQuadBytesImm
2325 def v16i8: SHLQBYIVecInst<v16i8>;
2326 def v8i16: SHLQBYIVecInst<v8i16>;
2327 def v4i32: SHLQBYIVecInst<v4i32>;
2328 def v4f32: SHLQBYIVecInst<v4f32>;
2329 def v2i64: SHLQBYIVecInst<v2i64>;
2330 def v2f64: SHLQBYIVecInst<v2f64>;
2331 def r128: SHLQBYIInst<(outs GPRC:$rT), (ins GPRC:$rA, u7imm_i32:$val),
2333 (SPUshlquad_l_bytes GPRC:$rA, (i32 uimm7:$val)))]>;
2336 defm SHLQBYI : ShiftLeftQuadBytesImm;
2338 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2340 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2341 class ROTHInst<dag OOL, dag IOL, list<dag> pattern>:
2342 RRForm<0b00111010000, OOL, IOL, "roth\t$rT, $rA, $rB",
2343 RotateShift, pattern>;
2345 class ROTHVecInst<ValueType vectype>:
2346 ROTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
2347 [(set (vectype VECREG:$rT),
2348 (SPUvec_rotl VECREG:$rA, VECREG:$rB))]>;
2350 class ROTHRegInst<RegisterClass rclass>:
2351 ROTHInst<(outs rclass:$rT), (ins rclass:$rA, rclass:$rB),
2352 [(set rclass:$rT, (rotl rclass:$rA, rclass:$rB))]>;
2354 multiclass RotateLeftHalfword
2356 def v8i16: ROTHVecInst<v8i16>;
2357 def r16: ROTHRegInst<R16C>;
2360 defm ROTH: RotateLeftHalfword;
2362 def ROTHr16_r32: ROTHInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2363 [(set R16C:$rT, (rotl R16C:$rA, R32C:$rB))]>;
2365 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2366 // Rotate halfword, immediate:
2367 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2368 class ROTHIInst<dag OOL, dag IOL, list<dag> pattern>:
2369 RI7Form<0b00111110000, OOL, IOL, "rothi\t$rT, $rA, $val",
2370 RotateShift, pattern>;
2372 class ROTHIVecInst<ValueType vectype>:
2373 ROTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2374 [(set (vectype VECREG:$rT),
2375 (SPUvec_rotl VECREG:$rA, (i16 uimm7:$val)))]>;
2377 multiclass RotateLeftHalfwordImm
2379 def v8i16: ROTHIVecInst<v8i16>;
2380 def r16: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm:$val),
2381 [(set R16C:$rT, (rotl R16C:$rA, (i16 uimm7:$val)))]>;
2382 def r16_r32: ROTHIInst<(outs R16C:$rT), (ins R16C:$rA, u7imm_i32:$val),
2383 [(set R16C:$rT, (rotl R16C:$rA, (i32 uimm7:$val)))]>;
2386 defm ROTHI: RotateLeftHalfwordImm;
2388 def : Pat<(SPUvec_rotl VECREG:$rA, (i32 uimm7:$val)),
2389 (ROTHIv8i16 VECREG:$rA, imm:$val)>;
2391 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2393 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2395 class ROTInst<dag OOL, dag IOL, list<dag> pattern>:
2396 RRForm<0b00011010000, OOL, IOL, "rot\t$rT, $rA, $rB",
2397 RotateShift, pattern>;
2399 class ROTVecInst<ValueType vectype>:
2400 ROTInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2401 [(set (vectype VECREG:$rT),
2402 (SPUvec_rotl (vectype VECREG:$rA), R32C:$rB))]>;
2404 class ROTRegInst<RegisterClass rclass>:
2405 ROTInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2407 (rotl rclass:$rA, R32C:$rB))]>;
2409 multiclass RotateLeftWord
2411 def v4i32: ROTVecInst<v4i32>;
2412 def r32: ROTRegInst<R32C>;
2415 defm ROT: RotateLeftWord;
2417 // The rotate amount is in the same bits whether we've got an 8-bit, 16-bit or
2419 def ROTr32_r16_anyext:
2420 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R16C:$rB),
2421 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R16C:$rB))))]>;
2423 def : Pat<(rotl R32C:$rA, (i32 (zext R16C:$rB))),
2424 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2426 def : Pat<(rotl R32C:$rA, (i32 (sext R16C:$rB))),
2427 (ROTr32_r16_anyext R32C:$rA, R16C:$rB)>;
2429 def ROTr32_r8_anyext:
2430 ROTInst<(outs R32C:$rT), (ins R32C:$rA, R8C:$rB),
2431 [(set R32C:$rT, (rotl R32C:$rA, (i32 (anyext R8C:$rB))))]>;
2433 def : Pat<(rotl R32C:$rA, (i32 (zext R8C:$rB))),
2434 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2436 def : Pat<(rotl R32C:$rA, (i32 (sext R8C:$rB))),
2437 (ROTr32_r8_anyext R32C:$rA, R8C:$rB)>;
2439 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2440 // Rotate word, immediate
2441 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2443 class ROTIInst<dag OOL, dag IOL, list<dag> pattern>:
2444 RI7Form<0b00011110000, OOL, IOL, "roti\t$rT, $rA, $val",
2445 RotateShift, pattern>;
2447 class ROTIVecInst<ValueType vectype, Operand optype, ValueType inttype, PatLeaf pred>:
2448 ROTIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2449 [(set (vectype VECREG:$rT),
2450 (SPUvec_rotl (vectype VECREG:$rA), (inttype pred:$val)))]>;
2452 class ROTIRegInst<RegisterClass rclass, Operand optype, ValueType inttype, PatLeaf pred>:
2453 ROTIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2454 [(set rclass:$rT, (rotl rclass:$rA, (inttype pred:$val)))]>;
2456 multiclass RotateLeftWordImm
2458 def v4i32: ROTIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2459 def v4i32_i16: ROTIVecInst<v4i32, u7imm, i16, uimm7>;
2460 def v4i32_i8: ROTIVecInst<v4i32, u7imm_i8, i8, uimm7>;
2462 def r32: ROTIRegInst<R32C, u7imm_i32, i32, uimm7>;
2463 def r32_i16: ROTIRegInst<R32C, u7imm, i16, uimm7>;
2464 def r32_i8: ROTIRegInst<R32C, u7imm_i8, i8, uimm7>;
2467 defm ROTI : RotateLeftWordImm;
2469 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2470 // Rotate quad by byte (count)
2471 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2473 class ROTQBYInst<dag OOL, dag IOL, list<dag> pattern>:
2474 RRForm<0b00111011100, OOL, IOL, "rotqby\t$rT, $rA, $rB",
2475 RotateShift, pattern>;
2477 class ROTQBYVecInst<ValueType vectype>:
2478 ROTQBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2479 [(set (vectype VECREG:$rT),
2480 (SPUrotbytes_left (vectype VECREG:$rA), R32C:$rB))]>;
2482 multiclass RotateQuadLeftByBytes
2484 def v16i8: ROTQBYVecInst<v16i8>;
2485 def v8i16: ROTQBYVecInst<v8i16>;
2486 def v4i32: ROTQBYVecInst<v4i32>;
2487 def v4f32: ROTQBYVecInst<v4f32>;
2488 def v2i64: ROTQBYVecInst<v2i64>;
2489 def v2f64: ROTQBYVecInst<v2f64>;
2492 defm ROTQBY: RotateQuadLeftByBytes;
2494 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2495 // Rotate quad by byte (count), immediate
2496 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2498 class ROTQBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2499 RI7Form<0b00111111100, OOL, IOL, "rotqbyi\t$rT, $rA, $val",
2500 RotateShift, pattern>;
2502 class ROTQBYIVecInst<ValueType vectype>:
2503 ROTQBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, u7imm:$val),
2504 [(set (vectype VECREG:$rT),
2505 (SPUrotbytes_left (vectype VECREG:$rA), (i16 uimm7:$val)))]>;
2507 multiclass RotateQuadByBytesImm
2509 def v16i8: ROTQBYIVecInst<v16i8>;
2510 def v8i16: ROTQBYIVecInst<v8i16>;
2511 def v4i32: ROTQBYIVecInst<v4i32>;
2512 def v4f32: ROTQBYIVecInst<v4f32>;
2513 def v2i64: ROTQBYIVecInst<v2i64>;
2514 def vfi64: ROTQBYIVecInst<v2f64>;
2517 defm ROTQBYI: RotateQuadByBytesImm;
2519 // See ROTQBY note above.
2520 class ROTQBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2521 RI7Form<0b00110011100, OOL, IOL,
2522 "rotqbybi\t$rT, $rA, $shift",
2523 RotateShift, pattern>;
2525 class ROTQBYBIVecInst<ValueType vectype, RegisterClass rclass>:
2526 ROTQBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, rclass:$shift),
2527 [(set (vectype VECREG:$rT),
2528 (SPUrotbytes_left_bits (vectype VECREG:$rA), rclass:$shift))]>;
2530 multiclass RotateQuadByBytesByBitshift {
2531 def v16i8_r32: ROTQBYBIVecInst<v16i8, R32C>;
2532 def v8i16_r32: ROTQBYBIVecInst<v8i16, R32C>;
2533 def v4i32_r32: ROTQBYBIVecInst<v4i32, R32C>;
2534 def v2i64_r32: ROTQBYBIVecInst<v2i64, R32C>;
2537 defm ROTQBYBI : RotateQuadByBytesByBitshift;
2539 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2540 // See ROTQBY note above.
2542 // Assume that the user of this instruction knows to shift the rotate count
2544 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2546 class ROTQBIInst<dag OOL, dag IOL, list<dag> pattern>:
2547 RRForm<0b00011011100, OOL, IOL, "rotqbi\t$rT, $rA, $rB",
2548 RotateShift, pattern>;
2550 class ROTQBIVecInst<ValueType vectype>:
2551 ROTQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2552 [/* no pattern yet */]>;
2554 class ROTQBIRegInst<RegisterClass rclass>:
2555 ROTQBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2556 [/* no pattern yet */]>;
2558 multiclass RotateQuadByBitCount
2560 def v16i8: ROTQBIVecInst<v16i8>;
2561 def v8i16: ROTQBIVecInst<v8i16>;
2562 def v4i32: ROTQBIVecInst<v4i32>;
2563 def v2i64: ROTQBIVecInst<v2i64>;
2565 def r128: ROTQBIRegInst<GPRC>;
2566 def r64: ROTQBIRegInst<R64C>;
2569 defm ROTQBI: RotateQuadByBitCount;
2571 class ROTQBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2572 RI7Form<0b00011111100, OOL, IOL, "rotqbii\t$rT, $rA, $val",
2573 RotateShift, pattern>;
2575 class ROTQBIIVecInst<ValueType vectype, Operand optype, ValueType inttype,
2577 ROTQBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, optype:$val),
2578 [/* no pattern yet */]>;
2580 class ROTQBIIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2582 ROTQBIIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2583 [/* no pattern yet */]>;
2585 multiclass RotateQuadByBitCountImm
2587 def v16i8: ROTQBIIVecInst<v16i8, u7imm_i32, i32, uimm7>;
2588 def v8i16: ROTQBIIVecInst<v8i16, u7imm_i32, i32, uimm7>;
2589 def v4i32: ROTQBIIVecInst<v4i32, u7imm_i32, i32, uimm7>;
2590 def v2i64: ROTQBIIVecInst<v2i64, u7imm_i32, i32, uimm7>;
2592 def r128: ROTQBIIRegInst<GPRC, u7imm_i32, i32, uimm7>;
2593 def r64: ROTQBIIRegInst<R64C, u7imm_i32, i32, uimm7>;
2596 defm ROTQBII : RotateQuadByBitCountImm;
2598 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2599 // ROTHM v8i16 form:
2600 // NOTE(1): No vector rotate is generated by the C/C++ frontend (today),
2601 // so this only matches a synthetically generated/lowered code
2603 // NOTE(2): $rB must be negated before the right rotate!
2604 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2606 class ROTHMInst<dag OOL, dag IOL, list<dag> pattern>:
2607 RRForm<0b10111010000, OOL, IOL, "rothm\t$rT, $rA, $rB",
2608 RotateShift, pattern>;
2611 ROTHMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2612 [/* see patterns below - $rB must be negated */]>;
2614 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R32C:$rB),
2615 (ROTHMv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2617 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R16C:$rB),
2618 (ROTHMv8i16 VECREG:$rA,
2619 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2621 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), R8C:$rB),
2622 (ROTHMv8i16 VECREG:$rA,
2623 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2625 // ROTHM r16 form: Rotate 16-bit quantity to right, zero fill at the left
2626 // Note: This instruction doesn't match a pattern because rB must be negated
2627 // for the instruction to work. Thus, the pattern below the instruction!
2630 ROTHMInst<(outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2631 [/* see patterns below - $rB must be negated! */]>;
2633 def : Pat<(srl R16C:$rA, R32C:$rB),
2634 (ROTHMr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2636 def : Pat<(srl R16C:$rA, R16C:$rB),
2638 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2640 def : Pat<(srl R16C:$rA, R8C:$rB),
2642 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB) ), 0))>;
2644 // ROTHMI v8i16 form: See the comment for ROTHM v8i16. The difference here is
2645 // that the immediate can be complemented, so that the user doesn't have to
2648 class ROTHMIInst<dag OOL, dag IOL, list<dag> pattern>:
2649 RI7Form<0b10111110000, OOL, IOL, "rothmi\t$rT, $rA, $val",
2650 RotateShift, pattern>;
2653 ROTHMIInst<(outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2654 [/* no pattern */]>;
2656 def : Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i32 imm:$val)),
2657 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2659 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i16 imm:$val)),
2660 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2662 def: Pat<(SPUvec_srl (v8i16 VECREG:$rA), (i8 imm:$val)),
2663 (ROTHMIv8i16 VECREG:$rA, imm:$val)>;
2666 ROTHMIInst<(outs R16C:$rT), (ins R16C:$rA, rothNeg7imm:$val),
2667 [/* no pattern */]>;
2669 def: Pat<(srl R16C:$rA, (i32 uimm7:$val)),
2670 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2672 def: Pat<(srl R16C:$rA, (i16 uimm7:$val)),
2673 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2675 def: Pat<(srl R16C:$rA, (i8 uimm7:$val)),
2676 (ROTHMIr16 R16C:$rA, uimm7:$val)>;
2678 // ROTM v4i32 form: See the ROTHM v8i16 comments.
2679 class ROTMInst<dag OOL, dag IOL, list<dag> pattern>:
2680 RRForm<0b10011010000, OOL, IOL, "rotm\t$rT, $rA, $rB",
2681 RotateShift, pattern>;
2684 ROTMInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2685 [/* see patterns below - $rB must be negated */]>;
2687 def : Pat<(SPUvec_srl VECREG:$rA, R32C:$rB),
2688 (ROTMv4i32 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2690 def : Pat<(SPUvec_srl VECREG:$rA, R16C:$rB),
2691 (ROTMv4i32 VECREG:$rA,
2692 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2694 def : Pat<(SPUvec_srl VECREG:$rA, R8C:$rB),
2695 (ROTMv4i32 VECREG:$rA,
2696 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2699 ROTMInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2700 [/* see patterns below - $rB must be negated */]>;
2702 def : Pat<(srl R32C:$rA, R32C:$rB),
2703 (ROTMr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2705 def : Pat<(srl R32C:$rA, R16C:$rB),
2707 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2709 def : Pat<(srl R32C:$rA, R8C:$rB),
2711 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2713 // ROTMI v4i32 form: See the comment for ROTHM v8i16.
2715 RI7Form<0b10011110000, (outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2716 "rotmi\t$rT, $rA, $val", RotateShift,
2717 [(set (v4i32 VECREG:$rT),
2718 (SPUvec_srl VECREG:$rA, (i32 uimm7:$val)))]>;
2720 def : Pat<(SPUvec_srl VECREG:$rA, (i16 uimm7:$val)),
2721 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2723 def : Pat<(SPUvec_srl VECREG:$rA, (i8 uimm7:$val)),
2724 (ROTMIv4i32 VECREG:$rA, uimm7:$val)>;
2726 // ROTMI r32 form: know how to complement the immediate value.
2728 RI7Form<0b10011110000, (outs R32C:$rT), (ins R32C:$rA, rotNeg7imm:$val),
2729 "rotmi\t$rT, $rA, $val", RotateShift,
2730 [(set R32C:$rT, (srl R32C:$rA, (i32 uimm7:$val)))]>;
2732 def : Pat<(srl R32C:$rA, (i16 imm:$val)),
2733 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2735 def : Pat<(srl R32C:$rA, (i8 imm:$val)),
2736 (ROTMIr32 R32C:$rA, uimm7:$val)>;
2738 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2739 // ROTQMBY: This is a vector form merely so that when used in an
2740 // instruction pattern, type checking will succeed. This instruction assumes
2741 // that the user knew to negate $rB.
2742 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2744 class ROTQMBYInst<dag OOL, dag IOL, list<dag> pattern>:
2745 RRForm<0b10111011100, OOL, IOL, "rotqmby\t$rT, $rA, $rB",
2746 RotateShift, pattern>;
2748 class ROTQMBYVecInst<ValueType vectype>:
2749 ROTQMBYInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2750 [/* no pattern, $rB must be negated */]>;
2752 class ROTQMBYRegInst<RegisterClass rclass>:
2753 ROTQMBYInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2754 [/* no pattern */]>;
2756 multiclass RotateQuadBytes
2758 def v16i8: ROTQMBYVecInst<v16i8>;
2759 def v8i16: ROTQMBYVecInst<v8i16>;
2760 def v4i32: ROTQMBYVecInst<v4i32>;
2761 def v2i64: ROTQMBYVecInst<v2i64>;
2763 def r128: ROTQMBYRegInst<GPRC>;
2764 def r64: ROTQMBYRegInst<R64C>;
2767 defm ROTQMBY : RotateQuadBytes;
2769 class ROTQMBYIInst<dag OOL, dag IOL, list<dag> pattern>:
2770 RI7Form<0b10111111100, OOL, IOL, "rotqmbyi\t$rT, $rA, $val",
2771 RotateShift, pattern>;
2773 class ROTQMBYIVecInst<ValueType vectype>:
2774 ROTQMBYIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2775 [/* no pattern */]>;
2777 class ROTQMBYIRegInst<RegisterClass rclass, Operand optype, ValueType inttype,
2779 ROTQMBYIInst<(outs rclass:$rT), (ins rclass:$rA, optype:$val),
2780 [/* no pattern */]>;
2782 // 128-bit zero extension form:
2783 class ROTQMBYIZExtInst<RegisterClass rclass, Operand optype, PatLeaf pred>:
2784 ROTQMBYIInst<(outs GPRC:$rT), (ins rclass:$rA, optype:$val),
2785 [/* no pattern */]>;
2787 multiclass RotateQuadBytesImm
2789 def v16i8: ROTQMBYIVecInst<v16i8>;
2790 def v8i16: ROTQMBYIVecInst<v8i16>;
2791 def v4i32: ROTQMBYIVecInst<v4i32>;
2792 def v2i64: ROTQMBYIVecInst<v2i64>;
2794 def r128: ROTQMBYIRegInst<GPRC, rotNeg7imm, i32, uimm7>;
2795 def r64: ROTQMBYIRegInst<R64C, rotNeg7imm, i32, uimm7>;
2797 def r128_zext_r8: ROTQMBYIZExtInst<R8C, rotNeg7imm, uimm7>;
2798 def r128_zext_r16: ROTQMBYIZExtInst<R16C, rotNeg7imm, uimm7>;
2799 def r128_zext_r32: ROTQMBYIZExtInst<R32C, rotNeg7imm, uimm7>;
2800 def r128_zext_r64: ROTQMBYIZExtInst<R64C, rotNeg7imm, uimm7>;
2803 defm ROTQMBYI : RotateQuadBytesImm;
2805 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2806 // Rotate right and mask by bit count
2807 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2809 class ROTQMBYBIInst<dag OOL, dag IOL, list<dag> pattern>:
2810 RRForm<0b10110011100, OOL, IOL, "rotqmbybi\t$rT, $rA, $rB",
2811 RotateShift, pattern>;
2813 class ROTQMBYBIVecInst<ValueType vectype>:
2814 ROTQMBYBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2815 [/* no pattern, */]>;
2817 multiclass RotateMaskQuadByBitCount
2819 def v16i8: ROTQMBYBIVecInst<v16i8>;
2820 def v8i16: ROTQMBYBIVecInst<v8i16>;
2821 def v4i32: ROTQMBYBIVecInst<v4i32>;
2822 def v2i64: ROTQMBYBIVecInst<v2i64>;
2825 defm ROTQMBYBI: RotateMaskQuadByBitCount;
2827 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2828 // Rotate quad and mask by bits
2829 // Note that the rotate amount has to be negated
2830 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2832 class ROTQMBIInst<dag OOL, dag IOL, list<dag> pattern>:
2833 RRForm<0b10011011100, OOL, IOL, "rotqmbi\t$rT, $rA, $rB",
2834 RotateShift, pattern>;
2836 class ROTQMBIVecInst<ValueType vectype>:
2837 ROTQMBIInst<(outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2838 [/* no pattern */]>;
2840 class ROTQMBIRegInst<RegisterClass rclass>:
2841 ROTQMBIInst<(outs rclass:$rT), (ins rclass:$rA, R32C:$rB),
2842 [/* no pattern */]>;
2844 multiclass RotateMaskQuadByBits
2846 def v16i8: ROTQMBIVecInst<v16i8>;
2847 def v8i16: ROTQMBIVecInst<v8i16>;
2848 def v4i32: ROTQMBIVecInst<v4i32>;
2849 def v2i64: ROTQMBIVecInst<v2i64>;
2851 def r128: ROTQMBIRegInst<GPRC>;
2852 def r64: ROTQMBIRegInst<R64C>;
2855 defm ROTQMBI: RotateMaskQuadByBits;
2857 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2858 // Rotate quad and mask by bits, immediate
2859 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2861 class ROTQMBIIInst<dag OOL, dag IOL, list<dag> pattern>:
2862 RI7Form<0b10011111100, OOL, IOL, "rotqmbii\t$rT, $rA, $val",
2863 RotateShift, pattern>;
2865 class ROTQMBIIVecInst<ValueType vectype>:
2866 ROTQMBIIInst<(outs VECREG:$rT), (ins VECREG:$rA, rotNeg7imm:$val),
2867 [/* no pattern */]>;
2869 class ROTQMBIIRegInst<RegisterClass rclass>:
2870 ROTQMBIIInst<(outs rclass:$rT), (ins rclass:$rA, rotNeg7imm:$val),
2871 [/* no pattern */]>;
2873 multiclass RotateMaskQuadByBitsImm
2875 def v16i8: ROTQMBIIVecInst<v16i8>;
2876 def v8i16: ROTQMBIIVecInst<v8i16>;
2877 def v4i32: ROTQMBIIVecInst<v4i32>;
2878 def v2i64: ROTQMBIIVecInst<v2i64>;
2880 def r128: ROTQMBIIRegInst<GPRC>;
2881 def r64: ROTQMBIIRegInst<R64C>;
2884 defm ROTQMBII: RotateMaskQuadByBitsImm;
2886 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2887 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
2890 RRForm<0b01111010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2891 "rotmah\t$rT, $rA, $rB", RotateShift,
2892 [/* see patterns below - $rB must be negated */]>;
2894 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2895 (ROTMAHv8i16 VECREG:$rA, (SFIr32 R32C:$rB, 0))>;
2897 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2898 (ROTMAHv8i16 VECREG:$rA,
2899 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2901 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2902 (ROTMAHv8i16 VECREG:$rA,
2903 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2906 RRForm<0b01111010000, (outs R16C:$rT), (ins R16C:$rA, R32C:$rB),
2907 "rotmah\t$rT, $rA, $rB", RotateShift,
2908 [/* see patterns below - $rB must be negated */]>;
2910 def : Pat<(sra R16C:$rA, R32C:$rB),
2911 (ROTMAHr16 R16C:$rA, (SFIr32 R32C:$rB, 0))>;
2913 def : Pat<(sra R16C:$rA, R16C:$rB),
2914 (ROTMAHr16 R16C:$rA,
2915 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2917 def : Pat<(sra R16C:$rA, R8C:$rB),
2918 (ROTMAHr16 R16C:$rA,
2919 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2922 RRForm<0b01111110000, (outs VECREG:$rT), (ins VECREG:$rA, rothNeg7imm:$val),
2923 "rotmahi\t$rT, $rA, $val", RotateShift,
2924 [(set (v8i16 VECREG:$rT),
2925 (SPUvec_sra (v8i16 VECREG:$rA), (i32 uimm7:$val)))]>;
2927 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i16 uimm7:$val)),
2928 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2930 def : Pat<(SPUvec_sra (v8i16 VECREG:$rA), (i8 uimm7:$val)),
2931 (ROTMAHIv8i16 (v8i16 VECREG:$rA), (i32 uimm7:$val))>;
2934 RRForm<0b01111110000, (outs R16C:$rT), (ins R16C:$rA, rothNeg7imm_i16:$val),
2935 "rotmahi\t$rT, $rA, $val", RotateShift,
2936 [(set R16C:$rT, (sra R16C:$rA, (i16 uimm7:$val)))]>;
2938 def : Pat<(sra R16C:$rA, (i32 imm:$val)),
2939 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2941 def : Pat<(sra R16C:$rA, (i8 imm:$val)),
2942 (ROTMAHIr16 R16C:$rA, uimm7:$val)>;
2945 RRForm<0b01011010000, (outs VECREG:$rT), (ins VECREG:$rA, R32C:$rB),
2946 "rotma\t$rT, $rA, $rB", RotateShift,
2947 [/* see patterns below - $rB must be negated */]>;
2949 def : Pat<(SPUvec_sra VECREG:$rA, R32C:$rB),
2950 (ROTMAv4i32 (v4i32 VECREG:$rA), (SFIr32 R32C:$rB, 0))>;
2952 def : Pat<(SPUvec_sra VECREG:$rA, R16C:$rB),
2953 (ROTMAv4i32 (v4i32 VECREG:$rA),
2954 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2956 def : Pat<(SPUvec_sra VECREG:$rA, R8C:$rB),
2957 (ROTMAv4i32 (v4i32 VECREG:$rA),
2958 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2961 RRForm<0b01011010000, (outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
2962 "rotma\t$rT, $rA, $rB", RotateShift,
2963 [/* see patterns below - $rB must be negated */]>;
2965 def : Pat<(sra R32C:$rA, R32C:$rB),
2966 (ROTMAr32 R32C:$rA, (SFIr32 R32C:$rB, 0))>;
2968 def : Pat<(sra R32C:$rA, R16C:$rB),
2970 (SFIr32 (XSHWr16 R16C:$rB), 0))>;
2972 def : Pat<(sra R32C:$rA, R8C:$rB),
2974 (SFIr32 (XSHWr16 (XSBHr8 R8C:$rB)), 0))>;
2976 class ROTMAIInst<dag OOL, dag IOL, list<dag> pattern>:
2977 RRForm<0b01011110000, OOL, IOL,
2978 "rotmai\t$rT, $rA, $val",
2979 RotateShift, pattern>;
2981 class ROTMAIVecInst<ValueType vectype, Operand intop, ValueType inttype>:
2982 ROTMAIInst<(outs VECREG:$rT), (ins VECREG:$rA, intop:$val),
2983 [(set (vectype VECREG:$rT),
2984 (SPUvec_sra VECREG:$rA, (inttype uimm7:$val)))]>;
2986 class ROTMAIRegInst<RegisterClass rclass, Operand intop, ValueType inttype>:
2987 ROTMAIInst<(outs rclass:$rT), (ins rclass:$rA, intop:$val),
2988 [(set rclass:$rT, (sra rclass:$rA, (inttype uimm7:$val)))]>;
2990 multiclass RotateMaskAlgebraicImm {
2991 def v2i64_i32 : ROTMAIVecInst<v2i64, rotNeg7imm, i32>;
2992 def v4i32_i32 : ROTMAIVecInst<v4i32, rotNeg7imm, i32>;
2993 def r64_i32 : ROTMAIRegInst<R64C, rotNeg7imm, i32>;
2994 def r32_i32 : ROTMAIRegInst<R32C, rotNeg7imm, i32>;
2997 defm ROTMAI : RotateMaskAlgebraicImm;
2999 //===----------------------------------------------------------------------===//
3000 // Branch and conditionals:
3001 //===----------------------------------------------------------------------===//
3003 let isTerminator = 1, isBarrier = 1 in {
3004 // Halt If Equal (r32 preferred slot only, no vector form)
3006 RRForm_3<0b00011011110, (outs), (ins R32C:$rA, R32C:$rB),
3007 "heq\t$rA, $rB", BranchResolv,
3008 [/* no pattern to match */]>;
3011 RI10Form_2<0b11111110, (outs), (ins R32C:$rA, s10imm:$val),
3012 "heqi\t$rA, $val", BranchResolv,
3013 [/* no pattern to match */]>;
3015 // HGT/HGTI: These instructions use signed arithmetic for the comparison,
3016 // contrasting with HLGT/HLGTI, which use unsigned comparison:
3018 RRForm_3<0b00011010010, (outs), (ins R32C:$rA, R32C:$rB),
3019 "hgt\t$rA, $rB", BranchResolv,
3020 [/* no pattern to match */]>;
3023 RI10Form_2<0b11110010, (outs), (ins R32C:$rA, s10imm:$val),
3024 "hgti\t$rA, $val", BranchResolv,
3025 [/* no pattern to match */]>;
3028 RRForm_3<0b00011011010, (outs), (ins R32C:$rA, R32C:$rB),
3029 "hlgt\t$rA, $rB", BranchResolv,
3030 [/* no pattern to match */]>;
3033 RI10Form_2<0b11111010, (outs), (ins R32C:$rA, s10imm:$val),
3034 "hlgti\t$rA, $val", BranchResolv,
3035 [/* no pattern to match */]>;
3038 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3039 // Comparison operators for i8, i16 and i32:
3040 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3042 class CEQBInst<dag OOL, dag IOL, list<dag> pattern> :
3043 RRForm<0b00001011110, OOL, IOL, "ceqb\t$rT, $rA, $rB",
3046 multiclass CmpEqualByte
3049 CEQBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3050 [(set (v16i8 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3051 (v8i16 VECREG:$rB)))]>;
3054 CEQBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3055 [(set R8C:$rT, (seteq R8C:$rA, R8C:$rB))]>;
3058 class CEQBIInst<dag OOL, dag IOL, list<dag> pattern> :
3059 RI10Form<0b01111110, OOL, IOL, "ceqbi\t$rT, $rA, $val",
3062 multiclass CmpEqualByteImm
3065 CEQBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3066 [(set (v16i8 VECREG:$rT), (seteq (v16i8 VECREG:$rA),
3067 v16i8SExt8Imm:$val))]>;
3069 CEQBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3070 [(set R8C:$rT, (seteq R8C:$rA, immSExt8:$val))]>;
3073 class CEQHInst<dag OOL, dag IOL, list<dag> pattern> :
3074 RRForm<0b00010011110, OOL, IOL, "ceqh\t$rT, $rA, $rB",
3077 multiclass CmpEqualHalfword
3079 def v8i16 : CEQHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3080 [(set (v8i16 VECREG:$rT), (seteq (v8i16 VECREG:$rA),
3081 (v8i16 VECREG:$rB)))]>;
3083 def r16 : CEQHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3084 [(set R16C:$rT, (seteq R16C:$rA, R16C:$rB))]>;
3087 class CEQHIInst<dag OOL, dag IOL, list<dag> pattern> :
3088 RI10Form<0b10111110, OOL, IOL, "ceqhi\t$rT, $rA, $val",
3091 multiclass CmpEqualHalfwordImm
3093 def v8i16 : CEQHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3094 [(set (v8i16 VECREG:$rT),
3095 (seteq (v8i16 VECREG:$rA),
3096 (v8i16 v8i16SExt10Imm:$val)))]>;
3097 def r16 : CEQHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3098 [(set R16C:$rT, (seteq R16C:$rA, i16ImmSExt10:$val))]>;
3101 class CEQInst<dag OOL, dag IOL, list<dag> pattern> :
3102 RRForm<0b00000011110, OOL, IOL, "ceq\t$rT, $rA, $rB",
3105 multiclass CmpEqualWord
3107 def v4i32 : CEQInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3108 [(set (v4i32 VECREG:$rT),
3109 (seteq (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3111 def r32 : CEQInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3112 [(set R32C:$rT, (seteq R32C:$rA, R32C:$rB))]>;
3115 class CEQIInst<dag OOL, dag IOL, list<dag> pattern> :
3116 RI10Form<0b00111110, OOL, IOL, "ceqi\t$rT, $rA, $val",
3119 multiclass CmpEqualWordImm
3121 def v4i32 : CEQIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3122 [(set (v4i32 VECREG:$rT),
3123 (seteq (v4i32 VECREG:$rA),
3124 (v4i32 v4i32SExt16Imm:$val)))]>;
3126 def r32: CEQIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3127 [(set R32C:$rT, (seteq R32C:$rA, i32ImmSExt10:$val))]>;
3130 class CGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3131 RRForm<0b00001010010, OOL, IOL, "cgtb\t$rT, $rA, $rB",
3134 multiclass CmpGtrByte
3137 CGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3138 [(set (v16i8 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3139 (v8i16 VECREG:$rB)))]>;
3142 CGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3143 [(set R8C:$rT, (setgt R8C:$rA, R8C:$rB))]>;
3146 class CGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3147 RI10Form<0b01110010, OOL, IOL, "cgtbi\t$rT, $rA, $val",
3150 multiclass CmpGtrByteImm
3153 CGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3154 [(set (v16i8 VECREG:$rT), (setgt (v16i8 VECREG:$rA),
3155 v16i8SExt8Imm:$val))]>;
3157 CGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3158 [(set R8C:$rT, (setgt R8C:$rA, immSExt8:$val))]>;
3161 class CGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3162 RRForm<0b00010010010, OOL, IOL, "cgth\t$rT, $rA, $rB",
3165 multiclass CmpGtrHalfword
3167 def v8i16 : CGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3168 [(set (v8i16 VECREG:$rT), (setgt (v8i16 VECREG:$rA),
3169 (v8i16 VECREG:$rB)))]>;
3171 def r16 : CGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3172 [(set R16C:$rT, (setgt R16C:$rA, R16C:$rB))]>;
3175 class CGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3176 RI10Form<0b10110010, OOL, IOL, "cgthi\t$rT, $rA, $val",
3179 multiclass CmpGtrHalfwordImm
3181 def v8i16 : CGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3182 [(set (v8i16 VECREG:$rT),
3183 (setgt (v8i16 VECREG:$rA),
3184 (v8i16 v8i16SExt10Imm:$val)))]>;
3185 def r16 : CGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3186 [(set R16C:$rT, (setgt R16C:$rA, i16ImmSExt10:$val))]>;
3189 class CGTInst<dag OOL, dag IOL, list<dag> pattern> :
3190 RRForm<0b00000010010, OOL, IOL, "cgt\t$rT, $rA, $rB",
3193 multiclass CmpGtrWord
3195 def v4i32 : CGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3196 [(set (v4i32 VECREG:$rT),
3197 (setgt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3199 def r32 : CGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3200 [(set R32C:$rT, (setgt R32C:$rA, R32C:$rB))]>;
3203 class CGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3204 RI10Form<0b00110010, OOL, IOL, "cgti\t$rT, $rA, $val",
3207 multiclass CmpGtrWordImm
3209 def v4i32 : CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3210 [(set (v4i32 VECREG:$rT),
3211 (setgt (v4i32 VECREG:$rA),
3212 (v4i32 v4i32SExt16Imm:$val)))]>;
3214 def r32: CGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3215 [(set R32C:$rT, (setgt R32C:$rA, i32ImmSExt10:$val))]>;
3217 // CGTIv4f32, CGTIf32: These are used in the f32 fdiv instruction sequence:
3218 def v4f32: CGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3219 [(set (v4i32 VECREG:$rT),
3220 (setgt (v4i32 (bitconvert (v4f32 VECREG:$rA))),
3221 (v4i32 v4i32SExt16Imm:$val)))]>;
3223 def f32: CGTIInst<(outs R32C:$rT), (ins R32FP:$rA, s10imm_i32:$val),
3224 [/* no pattern */]>;
3227 class CLGTBInst<dag OOL, dag IOL, list<dag> pattern> :
3228 RRForm<0b00001011010, OOL, IOL, "clgtb\t$rT, $rA, $rB",
3231 multiclass CmpLGtrByte
3234 CLGTBInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3235 [(set (v16i8 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3236 (v8i16 VECREG:$rB)))]>;
3239 CLGTBInst<(outs R8C:$rT), (ins R8C:$rA, R8C:$rB),
3240 [(set R8C:$rT, (setugt R8C:$rA, R8C:$rB))]>;
3243 class CLGTBIInst<dag OOL, dag IOL, list<dag> pattern> :
3244 RI10Form<0b01111010, OOL, IOL, "clgtbi\t$rT, $rA, $val",
3247 multiclass CmpLGtrByteImm
3250 CLGTBIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm_i8:$val),
3251 [(set (v16i8 VECREG:$rT), (setugt (v16i8 VECREG:$rA),
3252 v16i8SExt8Imm:$val))]>;
3254 CLGTBIInst<(outs R8C:$rT), (ins R8C:$rA, s10imm_i8:$val),
3255 [(set R8C:$rT, (setugt R8C:$rA, immSExt8:$val))]>;
3258 class CLGTHInst<dag OOL, dag IOL, list<dag> pattern> :
3259 RRForm<0b00010011010, OOL, IOL, "clgth\t$rT, $rA, $rB",
3262 multiclass CmpLGtrHalfword
3264 def v8i16 : CLGTHInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3265 [(set (v8i16 VECREG:$rT), (setugt (v8i16 VECREG:$rA),
3266 (v8i16 VECREG:$rB)))]>;
3268 def r16 : CLGTHInst<(outs R16C:$rT), (ins R16C:$rA, R16C:$rB),
3269 [(set R16C:$rT, (setugt R16C:$rA, R16C:$rB))]>;
3272 class CLGTHIInst<dag OOL, dag IOL, list<dag> pattern> :
3273 RI10Form<0b10111010, OOL, IOL, "clgthi\t$rT, $rA, $val",
3276 multiclass CmpLGtrHalfwordImm
3278 def v8i16 : CLGTHIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3279 [(set (v8i16 VECREG:$rT),
3280 (setugt (v8i16 VECREG:$rA),
3281 (v8i16 v8i16SExt10Imm:$val)))]>;
3282 def r16 : CLGTHIInst<(outs R16C:$rT), (ins R16C:$rA, s10imm:$val),
3283 [(set R16C:$rT, (setugt R16C:$rA, i16ImmSExt10:$val))]>;
3286 class CLGTInst<dag OOL, dag IOL, list<dag> pattern> :
3287 RRForm<0b00000011010, OOL, IOL, "clgt\t$rT, $rA, $rB",
3290 multiclass CmpLGtrWord
3292 def v4i32 : CLGTInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3293 [(set (v4i32 VECREG:$rT),
3294 (setugt (v4i32 VECREG:$rA), (v4i32 VECREG:$rB)))]>;
3296 def r32 : CLGTInst<(outs R32C:$rT), (ins R32C:$rA, R32C:$rB),
3297 [(set R32C:$rT, (setugt R32C:$rA, R32C:$rB))]>;
3300 class CLGTIInst<dag OOL, dag IOL, list<dag> pattern> :
3301 RI10Form<0b00111010, OOL, IOL, "clgti\t$rT, $rA, $val",
3304 multiclass CmpLGtrWordImm
3306 def v4i32 : CLGTIInst<(outs VECREG:$rT), (ins VECREG:$rA, s10imm:$val),
3307 [(set (v4i32 VECREG:$rT),
3308 (setugt (v4i32 VECREG:$rA),
3309 (v4i32 v4i32SExt16Imm:$val)))]>;
3311 def r32: CLGTIInst<(outs R32C:$rT), (ins R32C:$rA, s10imm_i32:$val),
3312 [(set R32C:$rT, (setugt R32C:$rA, i32ImmSExt10:$val))]>;
3315 defm CEQB : CmpEqualByte;
3316 defm CEQBI : CmpEqualByteImm;
3317 defm CEQH : CmpEqualHalfword;
3318 defm CEQHI : CmpEqualHalfwordImm;
3319 defm CEQ : CmpEqualWord;
3320 defm CEQI : CmpEqualWordImm;
3321 defm CGTB : CmpGtrByte;
3322 defm CGTBI : CmpGtrByteImm;
3323 defm CGTH : CmpGtrHalfword;
3324 defm CGTHI : CmpGtrHalfwordImm;
3325 defm CGT : CmpGtrWord;
3326 defm CGTI : CmpGtrWordImm;
3327 defm CLGTB : CmpLGtrByte;
3328 defm CLGTBI : CmpLGtrByteImm;
3329 defm CLGTH : CmpLGtrHalfword;
3330 defm CLGTHI : CmpLGtrHalfwordImm;
3331 defm CLGT : CmpLGtrWord;
3332 defm CLGTI : CmpLGtrWordImm;
3334 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3335 // For SETCC primitives not supported above (setlt, setle, setge, etc.)
3336 // define a pattern to generate the right code, as a binary operator
3337 // (in a manner of speaking.)
3340 // 1. This only matches the setcc set of conditionals. Special pattern
3341 // matching is used for select conditionals.
3343 // 2. The "DAG" versions of these classes is almost exclusively used for
3344 // i64 comparisons. See the tblgen fundamentals documentation for what
3345 // ".ResultInstrs[0]" means; see TargetSelectionDAG.td and the Pattern
3346 // class for where ResultInstrs originates.
3347 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3349 class SETCCNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3350 SPUInstr xorinst, SPUInstr cmpare>:
3351 Pat<(cond rclass:$rA, rclass:$rB),
3352 (xorinst (cmpare rclass:$rA, rclass:$rB), (inttype -1))>;
3354 class SETCCNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3355 PatLeaf immpred, SPUInstr xorinst, SPUInstr cmpare>:
3356 Pat<(cond rclass:$rA, (inttype immpred:$imm)),
3357 (xorinst (cmpare rclass:$rA, (inttype immpred:$imm)), (inttype -1))>;
3359 def : SETCCNegCondReg<setne, R8C, i8, XORBIr8, CEQBr8>;
3360 def : SETCCNegCondImm<setne, R8C, i8, immSExt8, XORBIr8, CEQBIr8>;
3362 def : SETCCNegCondReg<setne, R16C, i16, XORHIr16, CEQHr16>;
3363 def : SETCCNegCondImm<setne, R16C, i16, i16ImmSExt10, XORHIr16, CEQHIr16>;
3365 def : SETCCNegCondReg<setne, R32C, i32, XORIr32, CEQr32>;
3366 def : SETCCNegCondImm<setne, R32C, i32, i32ImmSExt10, XORIr32, CEQIr32>;
3368 class SETCCBinOpReg<PatFrag cond, RegisterClass rclass,
3369 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3370 Pat<(cond rclass:$rA, rclass:$rB),
3371 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3372 (cmpOp2 rclass:$rA, rclass:$rB))>;
3374 class SETCCBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3376 SPUInstr binop, SPUInstr cmpOp1, SPUInstr cmpOp2>:
3377 Pat<(cond rclass:$rA, (immtype immpred:$imm)),
3378 (binop (cmpOp1 rclass:$rA, (immtype immpred:$imm)),
3379 (cmpOp2 rclass:$rA, (immtype immpred:$imm)))>;
3381 def : SETCCBinOpReg<setge, R8C, ORr8, CGTBr8, CEQBr8>;
3382 def : SETCCBinOpImm<setge, R8C, immSExt8, i8, ORr8, CGTBIr8, CEQBIr8>;
3383 def : SETCCBinOpReg<setlt, R8C, NORr8, CGTBr8, CEQBr8>;
3384 def : SETCCBinOpImm<setlt, R8C, immSExt8, i8, NORr8, CGTBIr8, CEQBIr8>;
3385 def : Pat<(setle R8C:$rA, R8C:$rB),
3386 (XORBIr8 (CGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3387 def : Pat<(setle R8C:$rA, immU8:$imm),
3388 (XORBIr8 (CGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3390 def : SETCCBinOpReg<setge, R16C, ORr16, CGTHr16, CEQHr16>;
3391 def : SETCCBinOpImm<setge, R16C, i16ImmSExt10, i16,
3392 ORr16, CGTHIr16, CEQHIr16>;
3393 def : SETCCBinOpReg<setlt, R16C, NORr16, CGTHr16, CEQHr16>;
3394 def : SETCCBinOpImm<setlt, R16C, i16ImmSExt10, i16, NORr16, CGTHIr16, CEQHIr16>;
3395 def : Pat<(setle R16C:$rA, R16C:$rB),
3396 (XORHIr16 (CGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3397 def : Pat<(setle R16C:$rA, i16ImmSExt10:$imm),
3398 (XORHIr16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3400 def : SETCCBinOpReg<setge, R32C, ORr32, CGTr32, CEQr32>;
3401 def : SETCCBinOpImm<setge, R32C, i32ImmSExt10, i32,
3402 ORr32, CGTIr32, CEQIr32>;
3403 def : SETCCBinOpReg<setlt, R32C, NORr32, CGTr32, CEQr32>;
3404 def : SETCCBinOpImm<setlt, R32C, i32ImmSExt10, i32, NORr32, CGTIr32, CEQIr32>;
3405 def : Pat<(setle R32C:$rA, R32C:$rB),
3406 (XORIr32 (CGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3407 def : Pat<(setle R32C:$rA, i32ImmSExt10:$imm),
3408 (XORIr32 (CGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3410 def : SETCCBinOpReg<setuge, R8C, ORr8, CLGTBr8, CEQBr8>;
3411 def : SETCCBinOpImm<setuge, R8C, immSExt8, i8, ORr8, CLGTBIr8, CEQBIr8>;
3412 def : SETCCBinOpReg<setult, R8C, NORr8, CLGTBr8, CEQBr8>;
3413 def : SETCCBinOpImm<setult, R8C, immSExt8, i8, NORr8, CLGTBIr8, CEQBIr8>;
3414 def : Pat<(setule R8C:$rA, R8C:$rB),
3415 (XORBIr8 (CLGTBr8 R8C:$rA, R8C:$rB), 0xff)>;
3416 def : Pat<(setule R8C:$rA, immU8:$imm),
3417 (XORBIr8 (CLGTBIr8 R8C:$rA, immU8:$imm), 0xff)>;
3419 def : SETCCBinOpReg<setuge, R16C, ORr16, CLGTHr16, CEQHr16>;
3420 def : SETCCBinOpImm<setuge, R16C, i16ImmSExt10, i16,
3421 ORr16, CLGTHIr16, CEQHIr16>;
3422 def : SETCCBinOpReg<setult, R16C, NORr16, CLGTHr16, CEQHr16>;
3423 def : SETCCBinOpImm<setult, R16C, i16ImmSExt10, i16, NORr16,
3424 CLGTHIr16, CEQHIr16>;
3425 def : Pat<(setule R16C:$rA, R16C:$rB),
3426 (XORHIr16 (CLGTHr16 R16C:$rA, R16C:$rB), 0xffff)>;
3427 def : Pat<(setule R16C:$rA, i16ImmSExt10:$imm),
3428 (XORHIr16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$imm), 0xffff)>;
3430 def : SETCCBinOpReg<setuge, R32C, ORr32, CLGTr32, CEQr32>;
3431 def : SETCCBinOpImm<setuge, R32C, i32ImmSExt10, i32,
3432 ORr32, CLGTIr32, CEQIr32>;
3433 def : SETCCBinOpReg<setult, R32C, NORr32, CLGTr32, CEQr32>;
3434 def : SETCCBinOpImm<setult, R32C, i32ImmSExt10, i32, NORr32, CLGTIr32, CEQIr32>;
3435 def : Pat<(setule R32C:$rA, R32C:$rB),
3436 (XORIr32 (CLGTr32 R32C:$rA, R32C:$rB), 0xffffffff)>;
3437 def : Pat<(setule R32C:$rA, i32ImmSExt10:$imm),
3438 (XORIr32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$imm), 0xffffffff)>;
3440 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3441 // select conditional patterns:
3442 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3444 class SELECTNegCondReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3445 SPUInstr selinstr, SPUInstr cmpare>:
3446 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3447 rclass:$rTrue, rclass:$rFalse),
3448 (selinstr rclass:$rTrue, rclass:$rFalse,
3449 (cmpare rclass:$rA, rclass:$rB))>;
3451 class SELECTNegCondImm<PatFrag cond, RegisterClass rclass, ValueType inttype,
3452 PatLeaf immpred, SPUInstr selinstr, SPUInstr cmpare>:
3453 Pat<(select (inttype (cond rclass:$rA, immpred:$imm)),
3454 rclass:$rTrue, rclass:$rFalse),
3455 (selinstr rclass:$rTrue, rclass:$rFalse,
3456 (cmpare rclass:$rA, immpred:$imm))>;
3458 def : SELECTNegCondReg<setne, R8C, i8, SELBr8, CEQBr8>;
3459 def : SELECTNegCondImm<setne, R8C, i8, immSExt8, SELBr8, CEQBIr8>;
3460 def : SELECTNegCondReg<setle, R8C, i8, SELBr8, CGTBr8>;
3461 def : SELECTNegCondImm<setle, R8C, i8, immSExt8, SELBr8, CGTBr8>;
3462 def : SELECTNegCondReg<setule, R8C, i8, SELBr8, CLGTBr8>;
3463 def : SELECTNegCondImm<setule, R8C, i8, immU8, SELBr8, CLGTBIr8>;
3465 def : SELECTNegCondReg<setne, R16C, i16, SELBr16, CEQHr16>;
3466 def : SELECTNegCondImm<setne, R16C, i16, i16ImmSExt10, SELBr16, CEQHIr16>;
3467 def : SELECTNegCondReg<setle, R16C, i16, SELBr16, CGTHr16>;
3468 def : SELECTNegCondImm<setle, R16C, i16, i16ImmSExt10, SELBr16, CGTHIr16>;
3469 def : SELECTNegCondReg<setule, R16C, i16, SELBr16, CLGTHr16>;
3470 def : SELECTNegCondImm<setule, R16C, i16, i16ImmSExt10, SELBr16, CLGTHIr16>;
3472 def : SELECTNegCondReg<setne, R32C, i32, SELBr32, CEQr32>;
3473 def : SELECTNegCondImm<setne, R32C, i32, i32ImmSExt10, SELBr32, CEQIr32>;
3474 def : SELECTNegCondReg<setle, R32C, i32, SELBr32, CGTr32>;
3475 def : SELECTNegCondImm<setle, R32C, i32, i32ImmSExt10, SELBr32, CGTIr32>;
3476 def : SELECTNegCondReg<setule, R32C, i32, SELBr32, CLGTr32>;
3477 def : SELECTNegCondImm<setule, R32C, i32, i32ImmSExt10, SELBr32, CLGTIr32>;
3479 class SELECTBinOpReg<PatFrag cond, RegisterClass rclass, ValueType inttype,
3480 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3482 Pat<(select (inttype (cond rclass:$rA, rclass:$rB)),
3483 rclass:$rTrue, rclass:$rFalse),
3484 (selinstr rclass:$rFalse, rclass:$rTrue,
3485 (binop (cmpOp1 rclass:$rA, rclass:$rB),
3486 (cmpOp2 rclass:$rA, rclass:$rB)))>;
3488 class SELECTBinOpImm<PatFrag cond, RegisterClass rclass, PatLeaf immpred,
3490 SPUInstr selinstr, SPUInstr binop, SPUInstr cmpOp1,
3492 Pat<(select (inttype (cond rclass:$rA, (inttype immpred:$imm))),
3493 rclass:$rTrue, rclass:$rFalse),
3494 (selinstr rclass:$rFalse, rclass:$rTrue,
3495 (binop (cmpOp1 rclass:$rA, (inttype immpred:$imm)),
3496 (cmpOp2 rclass:$rA, (inttype immpred:$imm))))>;
3498 def : SELECTBinOpReg<setge, R8C, i8, SELBr8, ORr8, CGTBr8, CEQBr8>;
3499 def : SELECTBinOpImm<setge, R8C, immSExt8, i8,
3500 SELBr8, ORr8, CGTBIr8, CEQBIr8>;
3502 def : SELECTBinOpReg<setge, R16C, i16, SELBr16, ORr16, CGTHr16, CEQHr16>;
3503 def : SELECTBinOpImm<setge, R16C, i16ImmSExt10, i16,
3504 SELBr16, ORr16, CGTHIr16, CEQHIr16>;
3506 def : SELECTBinOpReg<setge, R32C, i32, SELBr32, ORr32, CGTr32, CEQr32>;
3507 def : SELECTBinOpImm<setge, R32C, i32ImmSExt10, i32,
3508 SELBr32, ORr32, CGTIr32, CEQIr32>;
3510 def : SELECTBinOpReg<setuge, R8C, i8, SELBr8, ORr8, CLGTBr8, CEQBr8>;
3511 def : SELECTBinOpImm<setuge, R8C, immSExt8, i8,
3512 SELBr8, ORr8, CLGTBIr8, CEQBIr8>;
3514 def : SELECTBinOpReg<setuge, R16C, i16, SELBr16, ORr16, CLGTHr16, CEQHr16>;
3515 def : SELECTBinOpImm<setuge, R16C, i16ImmUns10, i16,
3516 SELBr16, ORr16, CLGTHIr16, CEQHIr16>;
3518 def : SELECTBinOpReg<setuge, R32C, i32, SELBr32, ORr32, CLGTr32, CEQr32>;
3519 def : SELECTBinOpImm<setuge, R32C, i32ImmUns10, i32,
3520 SELBr32, ORr32, CLGTIr32, CEQIr32>;
3522 //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
3525 // All calls clobber the non-callee-saved registers:
3526 Defs = [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9,
3527 R10,R11,R12,R13,R14,R15,R16,R17,R18,R19,
3528 R20,R21,R22,R23,R24,R25,R26,R27,R28,R29,
3529 R30,R31,R32,R33,R34,R35,R36,R37,R38,R39,
3530 R40,R41,R42,R43,R44,R45,R46,R47,R48,R49,
3531 R50,R51,R52,R53,R54,R55,R56,R57,R58,R59,
3532 R60,R61,R62,R63,R64,R65,R66,R67,R68,R69,
3533 R70,R71,R72,R73,R74,R75,R76,R77,R78,R79],
3534 // All of these instructions use $lr (aka $0)
3536 // Branch relative and set link: Used if we actually know that the target
3537 // is within [-32768, 32767] bytes of the target
3539 BranchSetLink<0b011001100, (outs), (ins relcalltarget:$func, variable_ops),
3540 "brsl\t$$lr, $func",
3541 [(SPUcall (SPUpcrel tglobaladdr:$func, 0))]>;
3543 // Branch absolute and set link: Used if we actually know that the target
3544 // is an absolute address
3546 BranchSetLink<0b011001100, (outs), (ins calltarget:$func, variable_ops),
3547 "brasl\t$$lr, $func",
3548 [(SPUcall (SPUaform tglobaladdr:$func, 0))]>;
3550 // Branch indirect and set link if external data. These instructions are not
3551 // actually generated, matched by an intrinsic:
3552 def BISLED_00: BISLEDForm<0b11, "bisled\t$$lr, $func", [/* empty pattern */]>;
3553 def BISLED_E0: BISLEDForm<0b10, "bisled\t$$lr, $func", [/* empty pattern */]>;
3554 def BISLED_0D: BISLEDForm<0b01, "bisled\t$$lr, $func", [/* empty pattern */]>;
3555 def BISLED_ED: BISLEDForm<0b00, "bisled\t$$lr, $func", [/* empty pattern */]>;
3557 // Branch indirect and set link. This is the "X-form" address version of a
3560 BIForm<0b10010101100, "bisl\t$$lr, $func", [(SPUcall R32C:$func)]>;
3563 // Support calls to external symbols:
3564 def : Pat<(SPUcall (SPUpcrel texternalsym:$func, 0)),
3565 (BRSL texternalsym:$func)>;
3567 def : Pat<(SPUcall (SPUaform texternalsym:$func, 0)),
3568 (BRASL texternalsym:$func)>;
3570 // Unconditional branches:
3571 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, isBarrier = 1 in {
3573 UncondBranch<0b001001100, (outs), (ins brtarget:$dest),
3577 // Unconditional, absolute address branch
3579 UncondBranch<0b001100000, (outs), (ins brtarget:$dest),
3581 [/* no pattern */]>;
3585 BIForm<0b00010101100, "bi\t$func", [(brind R32C:$func)]>;
3587 // Conditional branches:
3588 class BRNZInst<dag IOL, list<dag> pattern>:
3589 RI16Form<0b010000100, (outs), IOL, "brnz\t$rCond,$dest",
3590 BranchResolv, pattern>;
3592 class BRNZRegInst<RegisterClass rclass>:
3593 BRNZInst<(ins rclass:$rCond, brtarget:$dest),
3594 [(brcond rclass:$rCond, bb:$dest)]>;
3596 class BRNZVecInst<ValueType vectype>:
3597 BRNZInst<(ins VECREG:$rCond, brtarget:$dest),
3598 [(brcond (vectype VECREG:$rCond), bb:$dest)]>;
3600 multiclass BranchNotZero {
3601 def v4i32 : BRNZVecInst<v4i32>;
3602 def r32 : BRNZRegInst<R32C>;
3605 defm BRNZ : BranchNotZero;
3607 class BRZInst<dag IOL, list<dag> pattern>:
3608 RI16Form<0b000000100, (outs), IOL, "brz\t$rT,$dest",
3609 BranchResolv, pattern>;
3611 class BRZRegInst<RegisterClass rclass>:
3612 BRZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3614 class BRZVecInst<ValueType vectype>:
3615 BRZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3617 multiclass BranchZero {
3618 def v4i32: BRZVecInst<v4i32>;
3619 def r32: BRZRegInst<R32C>;
3622 defm BRZ: BranchZero;
3624 // Note: LLVM doesn't do branch conditional, indirect. Otherwise these would
3627 class BINZInst<dag IOL, list<dag> pattern>:
3628 BICondForm<0b10010100100, (outs), IOL, "binz\t$rA, $dest", pattern>;
3630 class BINZRegInst<RegisterClass rclass>:
3631 BINZInst<(ins rclass:$rA, brtarget:$dest),
3632 [(brcond rclass:$rA, R32C:$dest)]>;
3634 class BINZVecInst<ValueType vectype>:
3635 BINZInst<(ins VECREG:$rA, R32C:$dest),
3636 [(brcond (vectype VECREG:$rA), R32C:$dest)]>;
3638 multiclass BranchNotZeroIndirect {
3639 def v4i32: BINZVecInst<v4i32>;
3640 def r32: BINZRegInst<R32C>;
3643 defm BINZ: BranchNotZeroIndirect;
3645 class BIZInst<dag IOL, list<dag> pattern>:
3646 BICondForm<0b00010100100, (outs), IOL, "biz\t$rA, $func", pattern>;
3648 class BIZRegInst<RegisterClass rclass>:
3649 BIZInst<(ins rclass:$rA, R32C:$func), [/* no pattern */]>;
3651 class BIZVecInst<ValueType vectype>:
3652 BIZInst<(ins VECREG:$rA, R32C:$func), [/* no pattern */]>;
3654 multiclass BranchZeroIndirect {
3655 def v4i32: BIZVecInst<v4i32>;
3656 def r32: BIZRegInst<R32C>;
3659 defm BIZ: BranchZeroIndirect;
3662 class BRHNZInst<dag IOL, list<dag> pattern>:
3663 RI16Form<0b011000100, (outs), IOL, "brhnz\t$rCond,$dest", BranchResolv,
3666 class BRHNZRegInst<RegisterClass rclass>:
3667 BRHNZInst<(ins rclass:$rCond, brtarget:$dest),
3668 [(brcond rclass:$rCond, bb:$dest)]>;
3670 class BRHNZVecInst<ValueType vectype>:
3671 BRHNZInst<(ins VECREG:$rCond, brtarget:$dest), [/* no pattern */]>;
3673 multiclass BranchNotZeroHalfword {
3674 def v8i16: BRHNZVecInst<v8i16>;
3675 def r16: BRHNZRegInst<R16C>;
3678 defm BRHNZ: BranchNotZeroHalfword;
3680 class BRHZInst<dag IOL, list<dag> pattern>:
3681 RI16Form<0b001000100, (outs), IOL, "brhz\t$rT,$dest", BranchResolv,
3684 class BRHZRegInst<RegisterClass rclass>:
3685 BRHZInst<(ins rclass:$rT, brtarget:$dest), [/* no pattern */]>;
3687 class BRHZVecInst<ValueType vectype>:
3688 BRHZInst<(ins VECREG:$rT, brtarget:$dest), [/* no pattern */]>;
3690 multiclass BranchZeroHalfword {
3691 def v8i16: BRHZVecInst<v8i16>;
3692 def r16: BRHZRegInst<R16C>;
3695 defm BRHZ: BranchZeroHalfword;
3698 //===----------------------------------------------------------------------===//
3699 // setcc and brcond patterns:
3700 //===----------------------------------------------------------------------===//
3702 def : Pat<(brcond (i16 (seteq R16C:$rA, 0)), bb:$dest),
3703 (BRHZr16 R16C:$rA, bb:$dest)>;
3704 def : Pat<(brcond (i16 (setne R16C:$rA, 0)), bb:$dest),
3705 (BRHNZr16 R16C:$rA, bb:$dest)>;
3707 def : Pat<(brcond (i32 (seteq R32C:$rA, 0)), bb:$dest),
3708 (BRZr32 R32C:$rA, bb:$dest)>;
3709 def : Pat<(brcond (i32 (setne R32C:$rA, 0)), bb:$dest),
3710 (BRNZr32 R32C:$rA, bb:$dest)>;
3712 multiclass BranchCondEQ<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3714 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3715 (brinst16 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3717 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3718 (brinst16 (CEQHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3720 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3721 (brinst32 (CEQIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3723 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3724 (brinst32 (CEQr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3727 defm BRCONDeq : BranchCondEQ<seteq, BRHNZr16, BRNZr32>;
3728 defm BRCONDne : BranchCondEQ<setne, BRHZr16, BRZr32>;
3730 multiclass BranchCondLGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3732 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3733 (brinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3735 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3736 (brinst16 (CLGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3738 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3739 (brinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3741 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3742 (brinst32 (CLGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3745 defm BRCONDugt : BranchCondLGT<setugt, BRHNZr16, BRNZr32>;
3746 defm BRCONDule : BranchCondLGT<setule, BRHZr16, BRZr32>;
3748 multiclass BranchCondLGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3749 SPUInstr orinst32, SPUInstr brinst32>
3751 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3752 (brinst16 (orinst16 (CLGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3753 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3756 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3757 (brinst16 (orinst16 (CLGTHr16 R16C:$rA, R16:$rB),
3758 (CEQHr16 R16C:$rA, R16:$rB)),
3761 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3762 (brinst32 (orinst32 (CLGTIr32 R32C:$rA, i32ImmSExt10:$val),
3763 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3766 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3767 (brinst32 (orinst32 (CLGTr32 R32C:$rA, R32C:$rB),
3768 (CEQr32 R32C:$rA, R32C:$rB)),
3772 defm BRCONDuge : BranchCondLGTEQ<setuge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3773 defm BRCONDult : BranchCondLGTEQ<setult, ORr16, BRHZr16, ORr32, BRZr32>;
3775 multiclass BranchCondGT<PatFrag cond, SPUInstr brinst16, SPUInstr brinst32>
3777 def r16imm : Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3778 (brinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val), bb:$dest)>;
3780 def r16 : Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3781 (brinst16 (CGTHr16 R16C:$rA, R16:$rB), bb:$dest)>;
3783 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3784 (brinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val), bb:$dest)>;
3786 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3787 (brinst32 (CGTr32 R32C:$rA, R32C:$rB), bb:$dest)>;
3790 defm BRCONDgt : BranchCondGT<setgt, BRHNZr16, BRNZr32>;
3791 defm BRCONDle : BranchCondGT<setle, BRHZr16, BRZr32>;
3793 multiclass BranchCondGTEQ<PatFrag cond, SPUInstr orinst16, SPUInstr brinst16,
3794 SPUInstr orinst32, SPUInstr brinst32>
3796 def r16imm: Pat<(brcond (i16 (cond R16C:$rA, i16ImmSExt10:$val)), bb:$dest),
3797 (brinst16 (orinst16 (CGTHIr16 R16C:$rA, i16ImmSExt10:$val),
3798 (CEQHIr16 R16C:$rA, i16ImmSExt10:$val)),
3801 def r16: Pat<(brcond (i16 (cond R16C:$rA, R16C:$rB)), bb:$dest),
3802 (brinst16 (orinst16 (CGTHr16 R16C:$rA, R16:$rB),
3803 (CEQHr16 R16C:$rA, R16:$rB)),
3806 def r32imm : Pat<(brcond (i32 (cond R32C:$rA, i32ImmSExt10:$val)), bb:$dest),
3807 (brinst32 (orinst32 (CGTIr32 R32C:$rA, i32ImmSExt10:$val),
3808 (CEQIr32 R32C:$rA, i32ImmSExt10:$val)),
3811 def r32 : Pat<(brcond (i32 (cond R32C:$rA, R32C:$rB)), bb:$dest),
3812 (brinst32 (orinst32 (CGTr32 R32C:$rA, R32C:$rB),
3813 (CEQr32 R32C:$rA, R32C:$rB)),
3817 defm BRCONDge : BranchCondGTEQ<setge, ORr16, BRHNZr16, ORr32, BRNZr32>;
3818 defm BRCONDlt : BranchCondGTEQ<setlt, ORr16, BRHZr16, ORr32, BRZr32>;
3820 let isTerminator = 1, isBarrier = 1 in {
3821 let isReturn = 1 in {
3823 RETForm<"bi\t$$lr", [(retflag)]>;
3827 //===----------------------------------------------------------------------===//
3828 // Single precision floating point instructions
3829 //===----------------------------------------------------------------------===//
3831 class FAInst<dag OOL, dag IOL, list<dag> pattern>:
3832 RRForm<0b01011000100, OOL, IOL, "fa\t$rT, $rA, $rB",
3835 class FAVecInst<ValueType vectype>:
3836 FAInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3837 [(set (vectype VECREG:$rT),
3838 (fadd (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
3842 def v4f32: FAVecInst<v4f32>;
3843 def f32: FAInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3844 [(set R32FP:$rT, (fadd R32FP:$rA, R32FP:$rB))]>;
3849 class FSInst<dag OOL, dag IOL, list<dag> pattern>:
3850 RRForm<0b01011000100, OOL, IOL, "fs\t$rT, $rA, $rB",
3853 class FSVecInst<ValueType vectype>:
3854 FSInst<(outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3855 [(set (vectype VECREG:$rT),
3856 (fsub (vectype VECREG:$rA), (vectype VECREG:$rB)))]>;
3860 def v4f32: FSVecInst<v4f32>;
3861 def f32: FSInst<(outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3862 [(set R32FP:$rT, (fsub R32FP:$rA, R32FP:$rB))]>;
3867 // Floating point reciprocal estimate
3869 class FRESTInst<dag OOL, dag IOL>:
3870 RRForm_1<0b00110111000, OOL, IOL,
3871 "frest\t$rT, $rA", SPrecFP,
3872 [/* no pattern */]>;
3875 FRESTInst<(outs VECREG:$rT), (ins VECREG:$rA)>;
3878 FRESTInst<(outs R32FP:$rT), (ins R32FP:$rA)>;
3880 // Floating point interpolate (used in conjunction with reciprocal estimate)
3882 RRForm<0b00101011110, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3883 "fi\t$rT, $rA, $rB", SPrecFP,
3884 [/* no pattern */]>;
3887 RRForm<0b00101011110, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
3888 "fi\t$rT, $rA, $rB", SPrecFP,
3889 [/* no pattern */]>;
3891 //--------------------------------------------------------------------------
3892 // Basic single precision floating point comparisons:
3894 // Note: There is no support on SPU for single precision NaN. Consequently,
3895 // ordered and unordered comparisons are the same.
3896 //--------------------------------------------------------------------------
3899 RRForm<0b01000011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3900 "fceq\t$rT, $rA, $rB", SPrecFP,
3901 [(set R32C:$rT, (setueq R32FP:$rA, R32FP:$rB))]>;
3903 def : Pat<(setoeq R32FP:$rA, R32FP:$rB),
3904 (FCEQf32 R32FP:$rA, R32FP:$rB)>;
3907 RRForm<0b01010011110, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3908 "fcmeq\t$rT, $rA, $rB", SPrecFP,
3909 [(set R32C:$rT, (setueq (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3911 def : Pat<(setoeq (fabs R32FP:$rA), (fabs R32FP:$rB)),
3912 (FCMEQf32 R32FP:$rA, R32FP:$rB)>;
3915 RRForm<0b01000011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3916 "fcgt\t$rT, $rA, $rB", SPrecFP,
3917 [(set R32C:$rT, (setugt R32FP:$rA, R32FP:$rB))]>;
3919 def : Pat<(setugt R32FP:$rA, R32FP:$rB),
3920 (FCGTf32 R32FP:$rA, R32FP:$rB)>;
3923 RRForm<0b01010011010, (outs R32C:$rT), (ins R32FP:$rA, R32FP:$rB),
3924 "fcmgt\t$rT, $rA, $rB", SPrecFP,
3925 [(set R32C:$rT, (setugt (fabs R32FP:$rA), (fabs R32FP:$rB)))]>;
3927 def : Pat<(setugt (fabs R32FP:$rA), (fabs R32FP:$rB)),
3928 (FCMGTf32 R32FP:$rA, R32FP:$rB)>;
3930 //--------------------------------------------------------------------------
3931 // Single precision floating point comparisons and SETCC equivalents:
3932 //--------------------------------------------------------------------------
3934 def : SETCCNegCondReg<setune, R32FP, i32, XORIr32, FCEQf32>;
3935 def : SETCCNegCondReg<setone, R32FP, i32, XORIr32, FCEQf32>;
3937 def : SETCCBinOpReg<setuge, R32FP, ORr32, FCGTf32, FCEQf32>;
3938 def : SETCCBinOpReg<setoge, R32FP, ORr32, FCGTf32, FCEQf32>;
3940 def : SETCCBinOpReg<setult, R32FP, NORr32, FCGTf32, FCEQf32>;
3941 def : SETCCBinOpReg<setolt, R32FP, NORr32, FCGTf32, FCEQf32>;
3943 def : Pat<(setule R32FP:$rA, R32FP:$rB),
3944 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3945 def : Pat<(setole R32FP:$rA, R32FP:$rB),
3946 (XORIr32 (FCGTf32 R32FP:$rA, R32FP:$rB), 0xffffffff)>;
3948 // FP Status and Control Register Write
3949 // Why isn't rT a don't care in the ISA?
3950 // Should we create a special RRForm_3 for this guy and zero out the rT?
3952 RRForm_1<0b01011101110, (outs R32FP:$rT), (ins R32FP:$rA),
3953 "fscrwr\t$rA", SPrecFP,
3954 [/* This instruction requires an intrinsic. Note: rT is unused. */]>;
3956 // FP Status and Control Register Read
3958 RRForm_2<0b01011101110, (outs R32FP:$rT), (ins),
3959 "fscrrd\t$rT", SPrecFP,
3960 [/* This instruction requires an intrinsic */]>;
3962 // llvm instruction space
3963 // How do these map onto cell instructions?
3965 // frest rC rB # c = 1/b (both lines)
3967 // fm rD rA rC # d = a * 1/b
3968 // fnms rB rD rB rA # b = - (d * b - a) --should == 0 in a perfect world
3969 // fma rB rB rC rD # b = b * c + d
3970 // = -(d *b -a) * c + d
3971 // = a * c - c ( a *b *c - a)
3976 // These llvm instructions will actually map to library calls.
3977 // All that's needed, then, is to check that the appropriate library is
3978 // imported and do a brsl to the proper function name.
3979 // frem # fmod(x, y): x - (x/y) * y
3980 // (Note: fmod(double, double), fmodf(float,float)
3984 // Unimplemented SPU instruction space
3985 // floating reciprocal absolute square root estimate (frsqest)
3987 // The following are probably just intrinsics
3988 // status and control register write
3989 // status and control register read
3991 //--------------------------------------
3992 // Floating point multiply instructions
3993 //--------------------------------------
3996 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
3997 "fm\t$rT, $rA, $rB", SPrecFP,
3998 [(set (v4f32 VECREG:$rT), (fmul (v4f32 VECREG:$rA),
3999 (v4f32 VECREG:$rB)))]>;
4002 RRForm<0b01100011010, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB),
4003 "fm\t$rT, $rA, $rB", SPrecFP,
4004 [(set R32FP:$rT, (fmul R32FP:$rA, R32FP:$rB))]>;
4006 // Floating point multiply and add
4007 // e.g. d = c + (a * b)
4009 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4010 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4011 [(set (v4f32 VECREG:$rT),
4012 (fadd (v4f32 VECREG:$rC),
4013 (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB))))]>;
4016 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4017 "fma\t$rT, $rA, $rB, $rC", SPrecFP,
4018 [(set R32FP:$rT, (fadd R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4020 // FP multiply and subtract
4021 // Subtracts value in rC from product
4024 RRRForm<0b0111, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4025 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4026 [(set (v4f32 VECREG:$rT),
4027 (fsub (fmul (v4f32 VECREG:$rA), (v4f32 VECREG:$rB)),
4028 (v4f32 VECREG:$rC)))]>;
4031 RRRForm<0b0111, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4032 "fms\t$rT, $rA, $rB, $rC", SPrecFP,
4034 (fsub (fmul R32FP:$rA, R32FP:$rB), R32FP:$rC))]>;
4036 // Floating Negative Mulitply and Subtract
4037 // Subtracts product from value in rC
4038 // res = fneg(fms a b c)
4041 // NOTE: subtraction order
4045 RRRForm<0b1101, (outs R32FP:$rT), (ins R32FP:$rA, R32FP:$rB, R32FP:$rC),
4046 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4047 [(set R32FP:$rT, (fsub R32FP:$rC, (fmul R32FP:$rA, R32FP:$rB)))]>;
4050 RRRForm<0b1101, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4051 "fnms\t$rT, $rA, $rB, $rC", SPrecFP,
4052 [(set (v4f32 VECREG:$rT),
4053 (fsub (v4f32 VECREG:$rC),
4054 (fmul (v4f32 VECREG:$rA),
4055 (v4f32 VECREG:$rB))))]>;
4057 //--------------------------------------
4058 // Floating Point Conversions
4059 // Signed conversions:
4061 CVTIntFPForm<0b0101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4062 "csflt\t$rT, $rA, 0", SPrecFP,
4063 [(set (v4f32 VECREG:$rT), (sint_to_fp (v4i32 VECREG:$rA)))]>;
4065 // Convert signed integer to floating point
4067 CVTIntFPForm<0b0101101110, (outs R32FP:$rT), (ins R32C:$rA),
4068 "csflt\t$rT, $rA, 0", SPrecFP,
4069 [(set R32FP:$rT, (sint_to_fp R32C:$rA))]>;
4071 // Convert unsigned into to float
4073 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4074 "cuflt\t$rT, $rA, 0", SPrecFP,
4075 [(set (v4f32 VECREG:$rT), (uint_to_fp (v4i32 VECREG:$rA)))]>;
4078 CVTIntFPForm<0b1101101110, (outs R32FP:$rT), (ins R32C:$rA),
4079 "cuflt\t$rT, $rA, 0", SPrecFP,
4080 [(set R32FP:$rT, (uint_to_fp R32C:$rA))]>;
4082 // Convert float to unsigned int
4083 // Assume that scale = 0
4086 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4087 "cfltu\t$rT, $rA, 0", SPrecFP,
4088 [(set (v4i32 VECREG:$rT), (fp_to_uint (v4f32 VECREG:$rA)))]>;
4091 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4092 "cfltu\t$rT, $rA, 0", SPrecFP,
4093 [(set R32C:$rT, (fp_to_uint R32FP:$rA))]>;
4095 // Convert float to signed int
4096 // Assume that scale = 0
4099 CVTIntFPForm<0b1101101110, (outs VECREG:$rT), (ins VECREG:$rA),
4100 "cflts\t$rT, $rA, 0", SPrecFP,
4101 [(set (v4i32 VECREG:$rT), (fp_to_sint (v4f32 VECREG:$rA)))]>;
4104 CVTIntFPForm<0b1101101110, (outs R32C:$rT), (ins R32FP:$rA),
4105 "cflts\t$rT, $rA, 0", SPrecFP,
4106 [(set R32C:$rT, (fp_to_sint R32FP:$rA))]>;
4108 //===----------------------------------------------------------------------==//
4109 // Single<->Double precision conversions
4110 //===----------------------------------------------------------------------==//
4112 // NOTE: We use "vec" name suffix here to avoid confusion (e.g. input is a
4113 // v4f32, output is v2f64--which goes in the name?)
4115 // Floating point extend single to double
4116 // NOTE: Not sure if passing in v4f32 to FESDvec is correct since it
4117 // operates on two double-word slots (i.e. 1st and 3rd fp numbers
4120 RRForm_1<0b00011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4121 "fesd\t$rT, $rA", SPrecFP,
4122 [(set (v2f64 VECREG:$rT), (fextend (v4f32 VECREG:$rA)))]>;
4125 RRForm_1<0b00011101110, (outs R64FP:$rT), (ins R32FP:$rA),
4126 "fesd\t$rT, $rA", SPrecFP,
4127 [(set R64FP:$rT, (fextend R32FP:$rA))]>;
4129 // Floating point round double to single
4131 // RRForm_1<0b10011101110, (outs VECREG:$rT), (ins VECREG:$rA),
4132 // "frds\t$rT, $rA,", SPrecFP,
4133 // [(set (v4f32 R32FP:$rT), (fround (v2f64 R64FP:$rA)))]>;
4136 RRForm_1<0b10011101110, (outs R32FP:$rT), (ins R64FP:$rA),
4137 "frds\t$rT, $rA", SPrecFP,
4138 [(set R32FP:$rT, (fround R64FP:$rA))]>;
4140 //ToDo include anyextend?
4142 //===----------------------------------------------------------------------==//
4143 // Double precision floating point instructions
4144 //===----------------------------------------------------------------------==//
4146 RRForm<0b00110011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4147 "dfa\t$rT, $rA, $rB", DPrecFP,
4148 [(set R64FP:$rT, (fadd R64FP:$rA, R64FP:$rB))]>;
4151 RRForm<0b00110011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4152 "dfa\t$rT, $rA, $rB", DPrecFP,
4153 [(set (v2f64 VECREG:$rT), (fadd (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4156 RRForm<0b10100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4157 "dfs\t$rT, $rA, $rB", DPrecFP,
4158 [(set R64FP:$rT, (fsub R64FP:$rA, R64FP:$rB))]>;
4161 RRForm<0b10100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4162 "dfs\t$rT, $rA, $rB", DPrecFP,
4163 [(set (v2f64 VECREG:$rT),
4164 (fsub (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4167 RRForm<0b01100011010, (outs R64FP:$rT), (ins R64FP:$rA, R64FP:$rB),
4168 "dfm\t$rT, $rA, $rB", DPrecFP,
4169 [(set R64FP:$rT, (fmul R64FP:$rA, R64FP:$rB))]>;
4172 RRForm<0b00100011010, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
4173 "dfm\t$rT, $rA, $rB", DPrecFP,
4174 [(set (v2f64 VECREG:$rT),
4175 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)))]>;
4178 RRForm<0b00111010110, (outs R64FP:$rT),
4179 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4180 "dfma\t$rT, $rA, $rB", DPrecFP,
4181 [(set R64FP:$rT, (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4182 RegConstraint<"$rC = $rT">,
4186 RRForm<0b00111010110, (outs VECREG:$rT),
4187 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4188 "dfma\t$rT, $rA, $rB", DPrecFP,
4189 [(set (v2f64 VECREG:$rT),
4190 (fadd (v2f64 VECREG:$rC),
4191 (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB))))]>,
4192 RegConstraint<"$rC = $rT">,
4196 RRForm<0b10111010110, (outs R64FP:$rT),
4197 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4198 "dfms\t$rT, $rA, $rB", DPrecFP,
4199 [(set R64FP:$rT, (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC))]>,
4200 RegConstraint<"$rC = $rT">,
4204 RRForm<0b10111010110, (outs VECREG:$rT),
4205 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4206 "dfms\t$rT, $rA, $rB", DPrecFP,
4207 [(set (v2f64 VECREG:$rT),
4208 (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4209 (v2f64 VECREG:$rC)))]>;
4211 // FNMS: - (a * b - c)
4212 // - (a * b) + c => c - (a * b)
4214 RRForm<0b01111010110, (outs R64FP:$rT),
4215 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4216 "dfnms\t$rT, $rA, $rB", DPrecFP,
4217 [(set R64FP:$rT, (fsub R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB)))]>,
4218 RegConstraint<"$rC = $rT">,
4221 def : Pat<(fneg (fsub (fmul R64FP:$rA, R64FP:$rB), R64FP:$rC)),
4222 (FNMSf64 R64FP:$rA, R64FP:$rB, R64FP:$rC)>;
4225 RRForm<0b01111010110, (outs VECREG:$rT),
4226 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4227 "dfnms\t$rT, $rA, $rB", DPrecFP,
4228 [(set (v2f64 VECREG:$rT),
4229 (fsub (v2f64 VECREG:$rC),
4230 (fmul (v2f64 VECREG:$rA),
4231 (v2f64 VECREG:$rB))))]>,
4232 RegConstraint<"$rC = $rT">,
4235 def : Pat<(fneg (fsub (fmul (v2f64 VECREG:$rA), (v2f64 VECREG:$rB)),
4236 (v2f64 VECREG:$rC))),
4237 (FNMSv2f64 VECREG:$rA, VECREG:$rB, VECREG:$rC)>;
4242 RRForm<0b11111010110, (outs R64FP:$rT),
4243 (ins R64FP:$rA, R64FP:$rB, R64FP:$rC),
4244 "dfnma\t$rT, $rA, $rB", DPrecFP,
4245 [(set R64FP:$rT, (fneg (fadd R64FP:$rC, (fmul R64FP:$rA, R64FP:$rB))))]>,
4246 RegConstraint<"$rC = $rT">,
4250 RRForm<0b11111010110, (outs VECREG:$rT),
4251 (ins VECREG:$rA, VECREG:$rB, VECREG:$rC),
4252 "dfnma\t$rT, $rA, $rB", DPrecFP,
4253 [(set (v2f64 VECREG:$rT),
4254 (fneg (fadd (v2f64 VECREG:$rC),
4255 (fmul (v2f64 VECREG:$rA),
4256 (v2f64 VECREG:$rB)))))]>,
4257 RegConstraint<"$rC = $rT">,
4260 //===----------------------------------------------------------------------==//
4261 // Floating point negation and absolute value
4262 //===----------------------------------------------------------------------==//
4264 def : Pat<(fneg (v4f32 VECREG:$rA)),
4265 (XORfnegvec (v4f32 VECREG:$rA),
4266 (v4f32 (ILHUv4i32 0x8000)))>;
4268 def : Pat<(fneg R32FP:$rA),
4269 (XORfneg32 R32FP:$rA, (ILHUr32 0x8000))>;
4271 def : Pat<(fneg (v2f64 VECREG:$rA)),
4272 (XORfnegvec (v2f64 VECREG:$rA),
4273 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80)))>;
4275 def : Pat<(fneg R64FP:$rA),
4276 (XORfneg64 R64FP:$rA,
4277 (ANDBIv16i8 (FSMBIv16i8 0x8080), 0x80))>;
4279 // Floating point absolute value
4281 def : Pat<(fabs R32FP:$rA),
4282 (ANDfabs32 R32FP:$rA, (IOHLr32 (ILHUr32 0x7fff), 0xffff))>;
4284 def : Pat<(fabs (v4f32 VECREG:$rA)),
4285 (ANDfabsvec (v4f32 VECREG:$rA),
4286 (v4f32 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
4288 def : Pat<(fabs R64FP:$rA),
4289 (ANDfabs64 R64FP:$rA, (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f))>;
4291 def : Pat<(fabs (v2f64 VECREG:$rA)),
4292 (ANDfabsvec (v2f64 VECREG:$rA),
4293 (v2f64 (ANDBIv16i8 (FSMBIv16i8 0xffff), 0x7f)))>;
4295 //===----------------------------------------------------------------------===//
4296 // Hint for branch instructions:
4297 //===----------------------------------------------------------------------===//
4299 /* def HBR : SPUInstr<(outs), (ins), "hbr\t" */
4301 //===----------------------------------------------------------------------===//
4302 // Execution, Load NOP (execute NOPs belong in even pipeline, load NOPs belong
4303 // in the odd pipeline)
4304 //===----------------------------------------------------------------------===//
4306 def ENOP : SPUInstr<(outs), (ins), "enop", ExecNOP> {
4309 let Inst{0-10} = 0b10000000010;
4310 let Inst{11-17} = 0;
4311 let Inst{18-24} = 0;
4312 let Inst{25-31} = 0;
4315 def LNOP : SPUInstr<(outs), (ins), "lnop", LoadNOP> {
4318 let Inst{0-10} = 0b10000000000;
4319 let Inst{11-17} = 0;
4320 let Inst{18-24} = 0;
4321 let Inst{25-31} = 0;
4324 //===----------------------------------------------------------------------===//
4325 // Bit conversions (type conversions between vector/packed types)
4326 // NOTE: Promotions are handled using the XS* instructions. Truncation
4328 //===----------------------------------------------------------------------===//
4329 def : Pat<(v16i8 (bitconvert (v8i16 VECREG:$src))), (v16i8 VECREG:$src)>;
4330 def : Pat<(v16i8 (bitconvert (v4i32 VECREG:$src))), (v16i8 VECREG:$src)>;
4331 def : Pat<(v16i8 (bitconvert (v2i64 VECREG:$src))), (v16i8 VECREG:$src)>;
4332 def : Pat<(v16i8 (bitconvert (v4f32 VECREG:$src))), (v16i8 VECREG:$src)>;
4333 def : Pat<(v16i8 (bitconvert (v2f64 VECREG:$src))), (v16i8 VECREG:$src)>;
4335 def : Pat<(v8i16 (bitconvert (v16i8 VECREG:$src))), (v8i16 VECREG:$src)>;
4336 def : Pat<(v8i16 (bitconvert (v4i32 VECREG:$src))), (v8i16 VECREG:$src)>;
4337 def : Pat<(v8i16 (bitconvert (v2i64 VECREG:$src))), (v8i16 VECREG:$src)>;
4338 def : Pat<(v8i16 (bitconvert (v4f32 VECREG:$src))), (v8i16 VECREG:$src)>;
4339 def : Pat<(v8i16 (bitconvert (v2f64 VECREG:$src))), (v8i16 VECREG:$src)>;
4341 def : Pat<(v4i32 (bitconvert (v16i8 VECREG:$src))), (v4i32 VECREG:$src)>;
4342 def : Pat<(v4i32 (bitconvert (v8i16 VECREG:$src))), (v4i32 VECREG:$src)>;
4343 def : Pat<(v4i32 (bitconvert (v2i64 VECREG:$src))), (v4i32 VECREG:$src)>;
4344 def : Pat<(v4i32 (bitconvert (v4f32 VECREG:$src))), (v4i32 VECREG:$src)>;
4345 def : Pat<(v4i32 (bitconvert (v2f64 VECREG:$src))), (v4i32 VECREG:$src)>;
4347 def : Pat<(v2i64 (bitconvert (v16i8 VECREG:$src))), (v2i64 VECREG:$src)>;
4348 def : Pat<(v2i64 (bitconvert (v8i16 VECREG:$src))), (v2i64 VECREG:$src)>;
4349 def : Pat<(v2i64 (bitconvert (v4i32 VECREG:$src))), (v2i64 VECREG:$src)>;
4350 def : Pat<(v2i64 (bitconvert (v4f32 VECREG:$src))), (v2i64 VECREG:$src)>;
4351 def : Pat<(v2i64 (bitconvert (v2f64 VECREG:$src))), (v2i64 VECREG:$src)>;
4353 def : Pat<(v4f32 (bitconvert (v16i8 VECREG:$src))), (v4f32 VECREG:$src)>;
4354 def : Pat<(v4f32 (bitconvert (v8i16 VECREG:$src))), (v4f32 VECREG:$src)>;
4355 def : Pat<(v4f32 (bitconvert (v2i64 VECREG:$src))), (v4f32 VECREG:$src)>;
4356 def : Pat<(v4f32 (bitconvert (v4i32 VECREG:$src))), (v4f32 VECREG:$src)>;
4357 def : Pat<(v4f32 (bitconvert (v2f64 VECREG:$src))), (v4f32 VECREG:$src)>;
4359 def : Pat<(v2f64 (bitconvert (v16i8 VECREG:$src))), (v2f64 VECREG:$src)>;
4360 def : Pat<(v2f64 (bitconvert (v8i16 VECREG:$src))), (v2f64 VECREG:$src)>;
4361 def : Pat<(v2f64 (bitconvert (v4i32 VECREG:$src))), (v2f64 VECREG:$src)>;
4362 def : Pat<(v2f64 (bitconvert (v2i64 VECREG:$src))), (v2f64 VECREG:$src)>;
4363 def : Pat<(v2f64 (bitconvert (v2f64 VECREG:$src))), (v2f64 VECREG:$src)>;
4365 def : Pat<(f32 (bitconvert (i32 R32C:$src))), (f32 R32FP:$src)>;
4366 def : Pat<(f64 (bitconvert (i64 R64C:$src))), (f64 R64FP:$src)>;
4368 //===----------------------------------------------------------------------===//
4369 // Instruction patterns:
4370 //===----------------------------------------------------------------------===//
4372 // General 32-bit constants:
4373 def : Pat<(i32 imm:$imm),
4374 (IOHLr32 (ILHUr32 (HI16 imm:$imm)), (LO16 imm:$imm))>;
4376 // Single precision float constants:
4377 def : Pat<(f32 fpimm:$imm),
4378 (IOHLf32 (ILHUf32 (HI16_f32 fpimm:$imm)), (LO16_f32 fpimm:$imm))>;
4380 // General constant 32-bit vectors
4381 def : Pat<(v4i32 v4i32Imm:$imm),
4382 (IOHLv4i32 (v4i32 (ILHUv4i32 (HI16_vec v4i32Imm:$imm))),
4383 (LO16_vec v4i32Imm:$imm))>;
4386 def : Pat<(i8 imm:$imm),
4389 //===----------------------------------------------------------------------===//
4390 // Call instruction patterns:
4391 //===----------------------------------------------------------------------===//
4396 //===----------------------------------------------------------------------===//
4397 // Zero/Any/Sign extensions
4398 //===----------------------------------------------------------------------===//
4400 // sext 8->32: Sign extend bytes to words
4401 def : Pat<(sext_inreg R32C:$rSrc, i8),
4402 (XSHWr32 (XSBHr32 R32C:$rSrc))>;
4404 def : Pat<(i32 (sext R8C:$rSrc)),
4405 (XSHWr16 (XSBHr8 R8C:$rSrc))>;
4407 // sext 8->64: Sign extend bytes to double word
4408 def : Pat<(sext_inreg R64C:$rSrc, i8),
4409 (XSWDr64_inreg (XSHWr64 (XSBHr64 R64C:$rSrc)))>;
4411 def : Pat<(i64 (sext R8C:$rSrc)),
4412 (XSWDr64 (XSHWr16 (XSBHr8 R8C:$rSrc)))>;
4414 // zext 8->16: Zero extend bytes to halfwords
4415 def : Pat<(i16 (zext R8C:$rSrc)),
4416 (ANDHIi8i16 R8C:$rSrc, 0xff)>;
4418 // zext 8->32: Zero extend bytes to words
4419 def : Pat<(i32 (zext R8C:$rSrc)),
4420 (ANDIi8i32 R8C:$rSrc, 0xff)>;
4422 // zext 8->64: Zero extend bytes to double words
4423 def : Pat<(i64 (zext R8C:$rSrc)),
4424 (ORi64_v2i64 (SELBv4i32 (ROTQMBYv4i32
4425 (ORv4i32_i32 (ANDIi8i32 R8C:$rSrc, 0xff)),
4428 (FSMBIv4i32 0x0f0f)))>;
4430 // anyext 8->16: Extend 8->16 bits, irrespective of sign, preserves high bits
4431 def : Pat<(i16 (anyext R8C:$rSrc)),
4432 (ORHIi8i16 R8C:$rSrc, 0)>;
4434 // anyext 8->32: Extend 8->32 bits, irrespective of sign, preserves high bits
4435 def : Pat<(i32 (anyext R8C:$rSrc)),
4436 (ORIi8i32 R8C:$rSrc, 0)>;
4438 // sext 16->64: Sign extend halfword to double word
4439 def : Pat<(sext_inreg R64C:$rSrc, i16),
4440 (XSWDr64_inreg (XSHWr64 R64C:$rSrc))>;
4442 def : Pat<(sext R16C:$rSrc),
4443 (XSWDr64 (XSHWr16 R16C:$rSrc))>;
4445 // zext 16->32: Zero extend halfwords to words
4446 def : Pat<(i32 (zext R16C:$rSrc)),
4447 (ANDi16i32 R16C:$rSrc, (ILAr32 0xffff))>;
4449 def : Pat<(i32 (zext (and R16C:$rSrc, 0xf))),
4450 (ANDIi16i32 R16C:$rSrc, 0xf)>;
4452 def : Pat<(i32 (zext (and R16C:$rSrc, 0xff))),
4453 (ANDIi16i32 R16C:$rSrc, 0xff)>;
4455 def : Pat<(i32 (zext (and R16C:$rSrc, 0xfff))),
4456 (ANDIi16i32 R16C:$rSrc, 0xfff)>;
4458 // anyext 16->32: Extend 16->32 bits, irrespective of sign
4459 def : Pat<(i32 (anyext R16C:$rSrc)),
4460 (ORIi16i32 R16C:$rSrc, 0)>;
4462 //===----------------------------------------------------------------------===//
4464 // These truncates are for the SPU's supported types (i8, i16, i32). i64 and
4465 // above are custom lowered.
4466 //===----------------------------------------------------------------------===//
4468 def : Pat<(i8 (trunc GPRC:$src)),
4470 (SHUFBgprc GPRC:$src, GPRC:$src,
4471 (IOHLv4i32 (ILHUv4i32 0x0f0f), 0x0f0f)))>;
4473 def : Pat<(i8 (trunc R64C:$src)),
4476 (ORv2i64_i64 R64C:$src),
4477 (ORv2i64_i64 R64C:$src),
4478 (IOHLv4i32 (ILHUv4i32 0x0707), 0x0707)))>;
4480 def : Pat<(i8 (trunc R32C:$src)),
4483 (ORv4i32_i32 R32C:$src),
4484 (ORv4i32_i32 R32C:$src),
4485 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4487 def : Pat<(i8 (trunc R16C:$src)),
4490 (ORv8i16_i16 R16C:$src),
4491 (ORv8i16_i16 R16C:$src),
4492 (IOHLv4i32 (ILHUv4i32 0x0303), 0x0303)))>;
4494 def : Pat<(i16 (trunc GPRC:$src)),
4496 (SHUFBgprc GPRC:$src, GPRC:$src,
4497 (IOHLv4i32 (ILHUv4i32 0x0e0f), 0x0e0f)))>;
4499 def : Pat<(i16 (trunc R64C:$src)),
4502 (ORv2i64_i64 R64C:$src),
4503 (ORv2i64_i64 R64C:$src),
4504 (IOHLv4i32 (ILHUv4i32 0x0607), 0x0607)))>;
4506 def : Pat<(i16 (trunc R32C:$src)),
4509 (ORv4i32_i32 R32C:$src),
4510 (ORv4i32_i32 R32C:$src),
4511 (IOHLv4i32 (ILHUv4i32 0x0203), 0x0203)))>;
4513 def : Pat<(i32 (trunc GPRC:$src)),
4515 (SHUFBgprc GPRC:$src, GPRC:$src,
4516 (IOHLv4i32 (ILHUv4i32 0x0c0d), 0x0e0f)))>;
4518 def : Pat<(i32 (trunc R64C:$src)),
4521 (ORv2i64_i64 R64C:$src),
4522 (ORv2i64_i64 R64C:$src),
4523 (IOHLv4i32 (ILHUv4i32 0x0405), 0x0607)))>;
4525 //===----------------------------------------------------------------------===//
4526 // Address generation: SPU, like PPC, has to split addresses into high and
4527 // low parts in order to load them into a register.
4528 //===----------------------------------------------------------------------===//
4530 def : Pat<(SPUaform tglobaladdr:$in, 0), (ILAlsa tglobaladdr:$in)>;
4531 def : Pat<(SPUaform texternalsym:$in, 0), (ILAlsa texternalsym:$in)>;
4532 def : Pat<(SPUaform tjumptable:$in, 0), (ILAlsa tjumptable:$in)>;
4533 def : Pat<(SPUaform tconstpool:$in, 0), (ILAlsa tconstpool:$in)>;
4535 def : Pat<(SPUindirect (SPUhi tglobaladdr:$in, 0),
4536 (SPUlo tglobaladdr:$in, 0)),
4537 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4539 def : Pat<(SPUindirect (SPUhi texternalsym:$in, 0),
4540 (SPUlo texternalsym:$in, 0)),
4541 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4543 def : Pat<(SPUindirect (SPUhi tjumptable:$in, 0),
4544 (SPUlo tjumptable:$in, 0)),
4545 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4547 def : Pat<(SPUindirect (SPUhi tconstpool:$in, 0),
4548 (SPUlo tconstpool:$in, 0)),
4549 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4551 def : Pat<(add (SPUhi tglobaladdr:$in, 0), (SPUlo tglobaladdr:$in, 0)),
4552 (IOHLlo (ILHUhi tglobaladdr:$in), tglobaladdr:$in)>;
4554 def : Pat<(add (SPUhi texternalsym:$in, 0), (SPUlo texternalsym:$in, 0)),
4555 (IOHLlo (ILHUhi texternalsym:$in), texternalsym:$in)>;
4557 def : Pat<(add (SPUhi tjumptable:$in, 0), (SPUlo tjumptable:$in, 0)),
4558 (IOHLlo (ILHUhi tjumptable:$in), tjumptable:$in)>;
4560 def : Pat<(add (SPUhi tconstpool:$in, 0), (SPUlo tconstpool:$in, 0)),
4561 (IOHLlo (ILHUhi tconstpool:$in), tconstpool:$in)>;
4564 include "CellSDKIntrinsics.td"
4565 // Various math operator instruction sequences
4566 include "SPUMathInstr.td"
4567 // 64-bit "instructions"/support
4568 include "SPU64InstrInfo.td"
4569 // 128-bit "instructions"/support
4570 include "SPU128InstrInfo.td"