1 //==- HexagonInstrInfo.td - Target Description for Hexagon -*- 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 //===----------------------------------------------------------------------===//
10 // This file describes the Hexagon instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 include "HexagonInstrFormats.td"
15 include "HexagonOperands.td"
17 // Pattern fragment that combines the value type and the register class
18 // into a single parameter.
19 // The pat frags in the definitions below need to have a named register,
20 // otherwise i32 will be assumed regardless of the register class. The
21 // name of the register does not matter.
22 def I1 : PatLeaf<(i1 PredRegs:$R)>;
23 def I32 : PatLeaf<(i32 IntRegs:$R)>;
24 def I64 : PatLeaf<(i64 DoubleRegs:$R)>;
25 def F32 : PatLeaf<(f32 IntRegs:$R)>;
26 def F64 : PatLeaf<(f64 DoubleRegs:$R)>;
28 // Pattern fragments to extract the low and high subregisters from a
30 def LoReg: OutPatFrag<(ops node:$Rs),
31 (EXTRACT_SUBREG (i64 $Rs), subreg_loreg)>;
33 //===----------------------------------------------------------------------===//
35 //===----------------------------------------------------------------------===//
37 //===----------------------------------------------------------------------===//
38 let hasSideEffects = 0, isCompare = 1, InputType = "imm", isExtendable = 1,
40 class T_CMP <string mnemonic, bits<2> MajOp, bit isNot, Operand ImmOp>
41 : ALU32Inst <(outs PredRegs:$dst),
42 (ins IntRegs:$src1, ImmOp:$src2),
43 "$dst = "#!if(isNot, "!","")#mnemonic#"($src1, #$src2)",
44 [], "",ALU32_2op_tc_2early_SLOT0123 >, ImmRegRel {
48 let CextOpcode = mnemonic;
49 let opExtentBits = !if(!eq(mnemonic, "cmp.gtu"), 9, 10);
50 let isExtentSigned = !if(!eq(mnemonic, "cmp.gtu"), 0, 1);
54 let Inst{27-24} = 0b0101;
55 let Inst{23-22} = MajOp;
56 let Inst{21} = !if(!eq(mnemonic, "cmp.gtu"), 0, src2{9});
57 let Inst{20-16} = src1;
58 let Inst{13-5} = src2{8-0};
64 def C2_cmpeqi : T_CMP <"cmp.eq", 0b00, 0, s10Ext>;
65 def C2_cmpgti : T_CMP <"cmp.gt", 0b01, 0, s10Ext>;
66 def C2_cmpgtui : T_CMP <"cmp.gtu", 0b10, 0, u9Ext>;
68 class T_CMP_pat <InstHexagon MI, PatFrag OpNode, PatLeaf ImmPred>
69 : Pat<(i1 (OpNode (i32 IntRegs:$src1), ImmPred:$src2)),
70 (MI IntRegs:$src1, ImmPred:$src2)>;
72 def : T_CMP_pat <C2_cmpeqi, seteq, s10ImmPred>;
73 def : T_CMP_pat <C2_cmpgti, setgt, s10ImmPred>;
74 def : T_CMP_pat <C2_cmpgtui, setugt, u9ImmPred>;
76 //===----------------------------------------------------------------------===//
78 //===----------------------------------------------------------------------===//
79 def SDTHexagonI64I32I32 : SDTypeProfile<1, 2,
80 [SDTCisVT<0, i64>, SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>;
82 def HexagonCOMBINE : SDNode<"HexagonISD::COMBINE", SDTHexagonI64I32I32>;
84 let hasSideEffects = 0, hasNewValue = 1, InputType = "reg" in
85 class T_ALU32_3op<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit OpsRev,
87 : ALU32_rr<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
88 "$Rd = "#mnemonic#"($Rs, $Rt)",
89 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredRel {
90 let isCommutable = IsComm;
91 let BaseOpcode = mnemonic#_rr;
92 let CextOpcode = mnemonic;
100 let Inst{26-24} = MajOp;
101 let Inst{23-21} = MinOp;
102 let Inst{20-16} = !if(OpsRev,Rt,Rs);
103 let Inst{12-8} = !if(OpsRev,Rs,Rt);
107 let hasSideEffects = 0, hasNewValue = 1 in
108 class T_ALU32_3op_pred<string mnemonic, bits<3> MajOp, bits<3> MinOp,
109 bit OpsRev, bit PredNot, bit PredNew>
110 : ALU32_rr<(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
111 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") "#
112 "$Rd = "#mnemonic#"($Rs, $Rt)",
113 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
114 let isPredicated = 1;
115 let isPredicatedFalse = PredNot;
116 let isPredicatedNew = PredNew;
117 let BaseOpcode = mnemonic#_rr;
118 let CextOpcode = mnemonic;
127 let Inst{26-24} = MajOp;
128 let Inst{23-21} = MinOp;
129 let Inst{20-16} = !if(OpsRev,Rt,Rs);
130 let Inst{13} = PredNew;
131 let Inst{12-8} = !if(OpsRev,Rs,Rt);
132 let Inst{7} = PredNot;
137 class T_ALU32_combineh<string Op1, string Op2, bits<3> MajOp, bits<3> MinOp,
139 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, 0> {
140 let AsmString = "$Rd = combine($Rs"#Op1#", $Rt"#Op2#")";
143 let isCodeGenOnly = 0 in {
144 def A2_combine_hh : T_ALU32_combineh<".h", ".h", 0b011, 0b100, 1>;
145 def A2_combine_hl : T_ALU32_combineh<".h", ".l", 0b011, 0b101, 1>;
146 def A2_combine_lh : T_ALU32_combineh<".l", ".h", 0b011, 0b110, 1>;
147 def A2_combine_ll : T_ALU32_combineh<".l", ".l", 0b011, 0b111, 1>;
150 class T_ALU32_3op_sfx<string mnemonic, string suffix, bits<3> MajOp,
151 bits<3> MinOp, bit OpsRev, bit IsComm>
152 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, IsComm> {
153 let AsmString = "$Rd = "#mnemonic#"($Rs, $Rt)"#suffix;
156 let Defs = [USR_OVF], Itinerary = ALU32_3op_tc_2_SLOT0123,
157 isCodeGenOnly = 0 in {
158 def A2_addsat : T_ALU32_3op_sfx<"add", ":sat", 0b110, 0b010, 0, 1>;
159 def A2_subsat : T_ALU32_3op_sfx<"sub", ":sat", 0b110, 0b110, 1, 0>;
162 multiclass T_ALU32_3op_p<string mnemonic, bits<3> MajOp, bits<3> MinOp,
164 def t : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 0>;
165 def f : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 0>;
166 def tnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 1>;
167 def fnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 1>;
170 multiclass T_ALU32_3op_A2<string mnemonic, bits<3> MajOp, bits<3> MinOp,
171 bit OpsRev, bit IsComm> {
172 let isPredicable = 1 in
173 def A2_#NAME : T_ALU32_3op <mnemonic, MajOp, MinOp, OpsRev, IsComm>;
174 defm A2_p#NAME : T_ALU32_3op_p<mnemonic, MajOp, MinOp, OpsRev>;
177 let isCodeGenOnly = 0 in {
178 defm add : T_ALU32_3op_A2<"add", 0b011, 0b000, 0, 1>;
179 defm and : T_ALU32_3op_A2<"and", 0b001, 0b000, 0, 1>;
180 defm or : T_ALU32_3op_A2<"or", 0b001, 0b001, 0, 1>;
181 defm sub : T_ALU32_3op_A2<"sub", 0b011, 0b001, 1, 0>;
182 defm xor : T_ALU32_3op_A2<"xor", 0b001, 0b011, 0, 1>;
185 // Pats for instruction selection.
186 class BinOp32_pat<SDNode Op, InstHexagon MI, ValueType ResT>
187 : Pat<(ResT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
188 (ResT (MI IntRegs:$Rs, IntRegs:$Rt))>;
190 def: BinOp32_pat<add, A2_add, i32>;
191 def: BinOp32_pat<and, A2_and, i32>;
192 def: BinOp32_pat<or, A2_or, i32>;
193 def: BinOp32_pat<sub, A2_sub, i32>;
194 def: BinOp32_pat<xor, A2_xor, i32>;
196 // A few special cases producing register pairs:
197 let OutOperandList = (outs DoubleRegs:$Rd), hasNewValue = 0,
198 isCodeGenOnly = 0 in {
199 def S2_packhl : T_ALU32_3op <"packhl", 0b101, 0b100, 0, 0>;
201 let isPredicable = 1 in
202 def A2_combinew : T_ALU32_3op <"combine", 0b101, 0b000, 0, 0>;
204 // Conditional combinew uses "newt/f" instead of "t/fnew".
205 def C2_ccombinewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 0>;
206 def C2_ccombinewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 0>;
207 def C2_ccombinewnewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 1>;
208 def C2_ccombinewnewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 1>;
211 let hasSideEffects = 0, hasNewValue = 1, isCompare = 1, InputType = "reg" in
212 class T_ALU32_3op_cmp<string mnemonic, bits<2> MinOp, bit IsNeg, bit IsComm>
213 : ALU32_rr<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
214 "$Pd = "#mnemonic#"($Rs, $Rt)",
215 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
216 let CextOpcode = mnemonic;
217 let isCommutable = IsComm;
223 let Inst{27-24} = 0b0010;
224 let Inst{22-21} = MinOp;
225 let Inst{20-16} = Rs;
228 let Inst{3-2} = 0b00;
232 let Itinerary = ALU32_3op_tc_2early_SLOT0123, isCodeGenOnly = 0 in {
233 def C2_cmpeq : T_ALU32_3op_cmp< "cmp.eq", 0b00, 0, 1>;
234 def C2_cmpgt : T_ALU32_3op_cmp< "cmp.gt", 0b10, 0, 0>;
235 def C2_cmpgtu : T_ALU32_3op_cmp< "cmp.gtu", 0b11, 0, 0>;
238 // Patfrag to convert the usual comparison patfrags (e.g. setlt) to ones
239 // that reverse the order of the operands.
240 class RevCmp<PatFrag F> : PatFrag<(ops node:$rhs, node:$lhs), F.Fragment>;
242 // Pats for compares. They use PatFrags as operands, not SDNodes,
243 // since seteq/setgt/etc. are defined as ParFrags.
244 class T_cmp32_rr_pat<InstHexagon MI, PatFrag Op, ValueType VT>
245 : Pat<(VT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
246 (VT (MI IntRegs:$Rs, IntRegs:$Rt))>;
248 def: T_cmp32_rr_pat<C2_cmpeq, seteq, i1>;
249 def: T_cmp32_rr_pat<C2_cmpgt, setgt, i1>;
250 def: T_cmp32_rr_pat<C2_cmpgtu, setugt, i1>;
252 def: T_cmp32_rr_pat<C2_cmpgt, RevCmp<setlt>, i1>;
253 def: T_cmp32_rr_pat<C2_cmpgtu, RevCmp<setult>, i1>;
255 let CextOpcode = "MUX", InputType = "reg", hasNewValue = 1,
257 def C2_mux: ALU32_rr<(outs IntRegs:$Rd),
258 (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
259 "$Rd = mux($Pu, $Rs, $Rt)", [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
265 let CextOpcode = "mux";
266 let InputType = "reg";
267 let hasSideEffects = 0;
270 let Inst{27-24} = 0b0100;
271 let Inst{20-16} = Rs;
277 def: Pat<(i32 (select (i1 PredRegs:$Pu), (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
278 (C2_mux PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt)>;
280 // Combines the two immediates into a double register.
281 // Increase complexity to make it greater than any complexity of a combine
282 // that involves a register.
284 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
285 isExtentSigned = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 1,
286 AddedComplexity = 75, isCodeGenOnly = 0 in
287 def A2_combineii: ALU32Inst <(outs DoubleRegs:$Rdd), (ins s8Ext:$s8, s8Imm:$S8),
288 "$Rdd = combine(#$s8, #$S8)",
289 [(set (i64 DoubleRegs:$Rdd),
290 (i64 (HexagonCOMBINE(i32 s8ExtPred:$s8), (i32 s8ImmPred:$S8))))]> {
296 let Inst{27-23} = 0b11000;
297 let Inst{22-16} = S8{7-1};
298 let Inst{13} = S8{0};
303 //===----------------------------------------------------------------------===//
304 // Template class for predicated ADD of a reg and an Immediate value.
305 //===----------------------------------------------------------------------===//
306 let hasNewValue = 1 in
307 class T_Addri_Pred <bit PredNot, bit PredNew>
308 : ALU32_ri <(outs IntRegs:$Rd),
309 (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
310 !if(PredNot, "if (!$Pu", "if ($Pu")#!if(PredNew,".new) $Rd = ",
311 ") $Rd = ")#"add($Rs, #$s8)"> {
317 let isPredicatedNew = PredNew;
320 let Inst{27-24} = 0b0100;
321 let Inst{23} = PredNot;
322 let Inst{22-21} = Pu;
323 let Inst{20-16} = Rs;
324 let Inst{13} = PredNew;
329 //===----------------------------------------------------------------------===//
330 // A2_addi: Add a signed immediate to a register.
331 //===----------------------------------------------------------------------===//
332 let hasNewValue = 1 in
333 class T_Addri <Operand immOp, list<dag> pattern = [] >
334 : ALU32_ri <(outs IntRegs:$Rd),
335 (ins IntRegs:$Rs, immOp:$s16),
336 "$Rd = add($Rs, #$s16)", pattern,
337 //[(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs), (s16ExtPred:$s16)))],
338 "", ALU32_ADDI_tc_1_SLOT0123> {
345 let Inst{27-21} = s16{15-9};
346 let Inst{20-16} = Rs;
347 let Inst{13-5} = s16{8-0};
351 //===----------------------------------------------------------------------===//
352 // Multiclass for ADD of a register and an immediate value.
353 //===----------------------------------------------------------------------===//
354 multiclass Addri_Pred<string mnemonic, bit PredNot> {
355 let isPredicatedFalse = PredNot in {
356 def _c#NAME : T_Addri_Pred<PredNot, 0>;
358 def _cdn#NAME : T_Addri_Pred<PredNot, 1>;
362 let isExtendable = 1, InputType = "imm" in
363 multiclass Addri_base<string mnemonic, SDNode OpNode> {
364 let CextOpcode = mnemonic, BaseOpcode = mnemonic#_ri in {
365 let opExtendable = 2, isExtentSigned = 1, opExtentBits = 16,
367 def NAME : T_Addri< s16Ext, // Rd=add(Rs,#s16)
368 [(set (i32 IntRegs:$Rd),
369 (add IntRegs:$Rs, s16ExtPred:$s16))]>;
371 let opExtendable = 3, isExtentSigned = 1, opExtentBits = 8,
372 hasSideEffects = 0, isPredicated = 1 in {
373 defm Pt : Addri_Pred<mnemonic, 0>;
374 defm NotPt : Addri_Pred<mnemonic, 1>;
379 let isCodeGenOnly = 0 in
380 defm ADD_ri : Addri_base<"add", add>, ImmRegRel, PredNewRel;
382 //===----------------------------------------------------------------------===//
383 // Template class used for the following ALU32 instructions.
386 //===----------------------------------------------------------------------===//
387 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 10,
388 InputType = "imm", hasNewValue = 1 in
389 class T_ALU32ri_logical <string mnemonic, SDNode OpNode, bits<2> MinOp>
390 : ALU32_ri <(outs IntRegs:$Rd),
391 (ins IntRegs:$Rs, s10Ext:$s10),
392 "$Rd = "#mnemonic#"($Rs, #$s10)" ,
393 [(set (i32 IntRegs:$Rd), (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10))]> {
397 let CextOpcode = mnemonic;
401 let Inst{27-24} = 0b0110;
402 let Inst{23-22} = MinOp;
403 let Inst{21} = s10{9};
404 let Inst{20-16} = Rs;
405 let Inst{13-5} = s10{8-0};
409 let isCodeGenOnly = 0 in {
410 def OR_ri : T_ALU32ri_logical<"or", or, 0b10>, ImmRegRel;
411 def AND_ri : T_ALU32ri_logical<"and", and, 0b00>, ImmRegRel;
414 // Subtract register from immediate
415 // Rd32=sub(#s10,Rs32)
416 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 10,
417 CextOpcode = "sub", InputType = "imm", hasNewValue = 1, isCodeGenOnly = 0 in
418 def SUB_ri: ALU32_ri <(outs IntRegs:$Rd), (ins s10Ext:$s10, IntRegs:$Rs),
419 "$Rd = sub(#$s10, $Rs)" ,
420 [(set IntRegs:$Rd, (sub s10ExtPred:$s10, IntRegs:$Rs))] > ,
428 let Inst{27-22} = 0b011001;
429 let Inst{21} = s10{9};
430 let Inst{20-16} = Rs;
431 let Inst{13-5} = s10{8-0};
436 let hasSideEffects = 0, isCodeGenOnly = 0 in
437 def A2_nop: ALU32Inst <(outs), (ins), "nop" > {
439 let Inst{27-24} = 0b1111;
441 // Rd = not(Rs) gets mapped to Rd=sub(#-1, Rs).
442 def : Pat<(not (i32 IntRegs:$src1)),
443 (SUB_ri -1, (i32 IntRegs:$src1))>;
445 let hasSideEffects = 0, hasNewValue = 1 in
446 class T_tfr16<bit isHi>
447 : ALU32Inst <(outs IntRegs:$Rx), (ins IntRegs:$src1, u16Imm:$u16),
448 "$Rx"#!if(isHi, ".h", ".l")#" = #$u16",
449 [], "$src1 = $Rx" > {
454 let Inst{27-26} = 0b00;
455 let Inst{25-24} = !if(isHi, 0b10, 0b01);
456 let Inst{23-22} = u16{15-14};
458 let Inst{20-16} = Rx;
459 let Inst{13-0} = u16{13-0};
462 let isCodeGenOnly = 0 in {
463 def A2_tfril: T_tfr16<0>;
464 def A2_tfrih: T_tfr16<1>;
467 // Conditional transfer is an alias to conditional "Rd = add(Rs, #0)".
468 let isPredicated = 1, hasNewValue = 1, opNewValue = 0 in
469 class T_tfr_pred<bit isPredNot, bit isPredNew>
470 : ALU32Inst<(outs IntRegs:$dst),
471 (ins PredRegs:$src1, IntRegs:$src2),
472 "if ("#!if(isPredNot, "!", "")#
473 "$src1"#!if(isPredNew, ".new", "")#
479 let isPredicatedFalse = isPredNot;
480 let isPredicatedNew = isPredNew;
483 let Inst{27-24} = 0b0100;
484 let Inst{23} = isPredNot;
485 let Inst{13} = isPredNew;
488 let Inst{22-21} = src1;
489 let Inst{20-16} = src2;
492 let isPredicable = 1 in
493 class T_tfr : ALU32Inst<(outs IntRegs:$dst), (ins IntRegs:$src),
500 let Inst{27-21} = 0b0000011;
501 let Inst{20-16} = src;
506 let InputType = "reg", hasNewValue = 1, hasSideEffects = 0 in
507 multiclass tfr_base<string CextOp> {
508 let CextOpcode = CextOp, BaseOpcode = CextOp in {
512 def t : T_tfr_pred<0, 0>;
513 def f : T_tfr_pred<1, 0>;
515 def tnew : T_tfr_pred<0, 1>;
516 def fnew : T_tfr_pred<1, 1>;
520 // Assembler mapped to C2_ccombinew[t|f|newt|newf].
521 // Please don't add bits to this instruction as it'll be converted into
522 // 'combine' before object code emission.
523 let isPredicated = 1 in
524 class T_tfrp_pred<bit PredNot, bit PredNew>
525 : ALU32_rr <(outs DoubleRegs:$dst),
526 (ins PredRegs:$src1, DoubleRegs:$src2),
527 "if ("#!if(PredNot, "!", "")#"$src1"
528 #!if(PredNew, ".new", "")#") $dst = $src2" > {
529 let isPredicatedFalse = PredNot;
530 let isPredicatedNew = PredNew;
533 // Assembler mapped to A2_combinew.
534 // Please don't add bits to this instruction as it'll be converted into
535 // 'combine' before object code emission.
536 class T_tfrp : ALU32Inst <(outs DoubleRegs:$dst),
537 (ins DoubleRegs:$src),
540 let hasSideEffects = 0 in
541 multiclass TFR64_base<string BaseName> {
542 let BaseOpcode = BaseName in {
543 let isPredicable = 1 in
546 def t : T_tfrp_pred <0, 0>;
547 def f : T_tfrp_pred <1, 0>;
549 def tnew : T_tfrp_pred <0, 1>;
550 def fnew : T_tfrp_pred <1, 1>;
554 let InputType = "imm", isExtendable = 1, isExtentSigned = 1, opExtentBits = 12,
555 isMoveImm = 1, opExtendable = 2, BaseOpcode = "TFRI", CextOpcode = "TFR",
556 hasSideEffects = 0, isPredicated = 1, hasNewValue = 1 in
557 class T_TFRI_Pred<bit PredNot, bit PredNew>
558 : ALU32_ri<(outs IntRegs:$Rd), (ins PredRegs:$Pu, s12Ext:$s12),
559 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") $Rd = #$s12",
560 [], "", ALU32_2op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
561 let isPredicatedFalse = PredNot;
562 let isPredicatedNew = PredNew;
569 let Inst{27-24} = 0b1110;
570 let Inst{23} = PredNot;
571 let Inst{22-21} = Pu;
573 let Inst{19-16,12-5} = s12;
574 let Inst{13} = PredNew;
578 let isCodeGenOnly = 0 in {
579 def C2_cmoveit : T_TFRI_Pred<0, 0>;
580 def C2_cmoveif : T_TFRI_Pred<1, 0>;
581 def C2_cmovenewit : T_TFRI_Pred<0, 1>;
582 def C2_cmovenewif : T_TFRI_Pred<1, 1>;
585 let InputType = "imm", isExtendable = 1, isExtentSigned = 1,
586 CextOpcode = "TFR", BaseOpcode = "TFRI", hasNewValue = 1, opNewValue = 0,
587 isAsCheapAsAMove = 1 , opExtendable = 1, opExtentBits = 16, isMoveImm = 1,
588 isPredicated = 0, isPredicable = 1, isReMaterializable = 1,
590 def A2_tfrsi : ALU32Inst<(outs IntRegs:$Rd), (ins s16Ext:$s16), "$Rd = #$s16",
591 [(set (i32 IntRegs:$Rd), s16ExtPred:$s16)], "", ALU32_2op_tc_1_SLOT0123>,
597 let Inst{27-24} = 0b1000;
598 let Inst{23-22,20-16,13-5} = s16;
602 let isCodeGenOnly = 0 in
603 defm A2_tfr : tfr_base<"TFR">, ImmRegRel, PredNewRel;
604 defm A2_tfrp : TFR64_base<"TFR64">, PredNewRel;
607 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1 in
608 def A2_tfrpi : ALU64_rr<(outs DoubleRegs:$dst), (ins s8Imm64:$src1),
610 [(set (i64 DoubleRegs:$dst), s8Imm64Pred:$src1)]>;
612 // TODO: see if this instruction can be deleted..
613 let isExtendable = 1, opExtendable = 1, opExtentBits = 6 in
614 def TFRI64_V4 : ALU64_rr<(outs DoubleRegs:$dst), (ins u6Ext:$src1),
617 //===----------------------------------------------------------------------===//
619 //===----------------------------------------------------------------------===//
622 //===----------------------------------------------------------------------===//
624 //===----------------------------------------------------------------------===//
625 // Scalar mux register immediate.
626 let hasSideEffects = 0, isExtentSigned = 1, CextOpcode = "MUX",
627 InputType = "imm", hasNewValue = 1, isExtendable = 1, opExtentBits = 8 in
628 class T_MUX1 <bit MajOp, dag ins, string AsmStr>
629 : ALU32Inst <(outs IntRegs:$Rd), ins, AsmStr>, ImmRegRel {
636 let Inst{27-24} = 0b0011;
637 let Inst{23} = MajOp;
638 let Inst{22-21} = Pu;
639 let Inst{20-16} = Rs;
645 let opExtendable = 2, isCodeGenOnly = 0 in
646 def C2_muxri : T_MUX1<0b1, (ins PredRegs:$Pu, s8Ext:$s8, IntRegs:$Rs),
647 "$Rd = mux($Pu, #$s8, $Rs)">;
649 let opExtendable = 3, isCodeGenOnly = 0 in
650 def C2_muxir : T_MUX1<0b0, (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
651 "$Rd = mux($Pu, $Rs, #$s8)">;
653 def : Pat<(i32 (select I1:$Pu, s8ExtPred:$s8, I32:$Rs)),
654 (C2_muxri I1:$Pu, s8ExtPred:$s8, I32:$Rs)>;
656 def : Pat<(i32 (select I1:$Pu, I32:$Rs, s8ExtPred:$s8)),
657 (C2_muxir I1:$Pu, I32:$Rs, s8ExtPred:$s8)>;
659 // C2_muxii: Scalar mux immediates.
660 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1,
661 opExtentBits = 8, opExtendable = 2, isCodeGenOnly = 0 in
662 def C2_muxii: ALU32Inst <(outs IntRegs:$Rd),
663 (ins PredRegs:$Pu, s8Ext:$s8, s8Imm:$S8),
664 "$Rd = mux($Pu, #$s8, #$S8)" ,
665 [(set (i32 IntRegs:$Rd),
666 (i32 (select I1:$Pu, s8ExtPred:$s8, s8ImmPred:$S8)))] > {
674 let Inst{27-25} = 0b101;
675 let Inst{24-23} = Pu;
676 let Inst{22-16} = S8{7-1};
677 let Inst{13} = S8{0};
682 //===----------------------------------------------------------------------===//
683 // template class for non-predicated alu32_2op instructions
684 // - aslh, asrh, sxtb, sxth, zxth
685 //===----------------------------------------------------------------------===//
686 let hasNewValue = 1, opNewValue = 0 in
687 class T_ALU32_2op <string mnemonic, bits<3> minOp> :
688 ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
689 "$Rd = "#mnemonic#"($Rs)", [] > {
695 let Inst{27-24} = 0b0000;
696 let Inst{23-21} = minOp;
699 let Inst{20-16} = Rs;
702 //===----------------------------------------------------------------------===//
703 // template class for predicated alu32_2op instructions
704 // - aslh, asrh, sxtb, sxth, zxtb, zxth
705 //===----------------------------------------------------------------------===//
706 let hasSideEffects = 0, validSubTargets = HasV4SubT,
707 hasNewValue = 1, opNewValue = 0 in
708 class T_ALU32_2op_Pred <string mnemonic, bits<3> minOp, bit isPredNot,
710 ALU32Inst <(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs),
711 !if(isPredNot, "if (!$Pu", "if ($Pu")
712 #!if(isPredNew, ".new) ",") ")#"$Rd = "#mnemonic#"($Rs)"> {
719 let Inst{27-24} = 0b0000;
720 let Inst{23-21} = minOp;
722 let Inst{11} = isPredNot;
723 let Inst{10} = isPredNew;
726 let Inst{20-16} = Rs;
729 multiclass ALU32_2op_Pred<string mnemonic, bits<3> minOp, bit PredNot> {
730 let isPredicatedFalse = PredNot in {
731 def NAME : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 0>;
734 let isPredicatedNew = 1 in
735 def NAME#new : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 1>;
739 multiclass ALU32_2op_base<string mnemonic, bits<3> minOp> {
740 let BaseOpcode = mnemonic in {
741 let isPredicable = 1, hasSideEffects = 0 in
742 def A2_#NAME : T_ALU32_2op<mnemonic, minOp>;
744 let validSubTargets = HasV4SubT, isPredicated = 1, hasSideEffects = 0 in {
745 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
746 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
751 let isCodeGenOnly = 0 in {
752 defm aslh : ALU32_2op_base<"aslh", 0b000>, PredNewRel;
753 defm asrh : ALU32_2op_base<"asrh", 0b001>, PredNewRel;
754 defm sxtb : ALU32_2op_base<"sxtb", 0b101>, PredNewRel;
755 defm sxth : ALU32_2op_base<"sxth", 0b111>, PredNewRel;
756 defm zxth : ALU32_2op_base<"zxth", 0b110>, PredNewRel;
759 // Rd=zxtb(Rs): assembler mapped to Rd=and(Rs,#255).
760 // Compiler would want to generate 'zxtb' instead of 'and' becuase 'zxtb' has
761 // predicated forms while 'and' doesn't. Since integrated assembler can't
762 // handle 'mapped' instructions, we need to encode 'zxtb' same as 'and' where
763 // immediate operand is set to '255'.
765 let hasNewValue = 1, opNewValue = 0 in
766 class T_ZXTB: ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
767 "$Rd = zxtb($Rs)", [] > { // Rd = and(Rs,255)
774 let Inst{27-22} = 0b011000;
776 let Inst{20-16} = Rs;
777 let Inst{21} = s10{9};
778 let Inst{13-5} = s10{8-0};
781 //Rd=zxtb(Rs): assembler mapped to "Rd=and(Rs,#255)
782 multiclass ZXTB_base <string mnemonic, bits<3> minOp> {
783 let BaseOpcode = mnemonic in {
784 let isPredicable = 1, hasSideEffects = 0 in
785 def A2_#NAME : T_ZXTB;
787 let validSubTargets = HasV4SubT, isPredicated = 1, hasSideEffects = 0 in {
788 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
789 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
794 let isCodeGenOnly=0 in
795 defm zxtb : ZXTB_base<"zxtb",0b100>, PredNewRel;
797 def: Pat<(shl I32:$src1, (i32 16)), (A2_aslh I32:$src1)>;
798 def: Pat<(sra I32:$src1, (i32 16)), (A2_asrh I32:$src1)>;
799 def: Pat<(sext_inreg I32:$src1, i8), (A2_sxtb I32:$src1)>;
800 def: Pat<(sext_inreg I32:$src1, i16), (A2_sxth I32:$src1)>;
803 def VMUX_prr64 : ALU64_rr<(outs DoubleRegs:$dst), (ins PredRegs:$src1,
806 "$dst = vmux($src1, $src2, $src3)",
810 //===----------------------------------------------------------------------===//
812 //===----------------------------------------------------------------------===//
815 //===----------------------------------------------------------------------===//
817 //===----------------------------------------------------------------------===//
819 // SDNode for converting immediate C to C-1.
820 def DEC_CONST_SIGNED : SDNodeXForm<imm, [{
821 // Return the byte immediate const-1 as an SDNode.
822 int32_t imm = N->getSExtValue();
823 return XformSToSM1Imm(imm);
826 // SDNode for converting immediate C to C-1.
827 def DEC_CONST_UNSIGNED : SDNodeXForm<imm, [{
828 // Return the byte immediate const-1 as an SDNode.
829 uint32_t imm = N->getZExtValue();
830 return XformUToUM1Imm(imm);
833 def CTLZ64_rr : SInst<(outs IntRegs:$dst), (ins DoubleRegs:$src1),
835 [(set (i32 IntRegs:$dst), (i32 (trunc (ctlz (i64 DoubleRegs:$src1)))))]>;
837 def CTTZ64_rr : SInst<(outs IntRegs:$dst), (ins DoubleRegs:$src1),
839 [(set (i32 IntRegs:$dst), (i32 (trunc (cttz (i64 DoubleRegs:$src1)))))]>;
841 //===----------------------------------------------------------------------===//
843 //===----------------------------------------------------------------------===//
846 //===----------------------------------------------------------------------===//
848 //===----------------------------------------------------------------------===//// Add.
849 //===----------------------------------------------------------------------===//
851 // Add/Subtract halfword
852 // Rd=add(Rt.L,Rs.[HL])[:sat]
853 // Rd=sub(Rt.L,Rs.[HL])[:sat]
854 // Rd=add(Rt.[LH],Rs.[HL])[:sat][:<16]
855 // Rd=sub(Rt.[LH],Rs.[HL])[:sat][:<16]
856 //===----------------------------------------------------------------------===//
858 let hasNewValue = 1, opNewValue = 0 in
859 class T_XTYPE_ADD_SUB <bits<2> LHbits, bit isSat, bit hasShift, bit isSub>
860 : ALU64Inst <(outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
861 "$Rd = "#!if(isSub,"sub","add")#"($Rt."
862 #!if(hasShift, !if(LHbits{1},"h","l"),"l") #", $Rs."
863 #!if(hasShift, !if(LHbits{0},"h)","l)"), !if(LHbits{1},"h)","l)"))
864 #!if(isSat,":sat","")
865 #!if(hasShift,":<<16",""), [], "", ALU64_tc_1_SLOT23> {
871 let Inst{27-23} = 0b01010;
872 let Inst{22} = hasShift;
873 let Inst{21} = isSub;
875 let Inst{6-5} = LHbits;
878 let Inst{20-16} = Rs;
881 //Rd=sub(Rt.L,Rs.[LH])
882 let isCodeGenOnly = 0 in {
883 def A2_subh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 1>;
884 def A2_subh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 1>;
887 let isCodeGenOnly = 0 in {
888 //Rd=add(Rt.L,Rs.[LH])
889 def A2_addh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 0>;
890 def A2_addh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 0>;
893 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF], isCodeGenOnly = 0 in {
894 //Rd=sub(Rt.L,Rs.[LH]):sat
895 def A2_subh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 1>;
896 def A2_subh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 1>;
898 //Rd=add(Rt.L,Rs.[LH]):sat
899 def A2_addh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 0>;
900 def A2_addh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 0>;
903 //Rd=sub(Rt.[LH],Rs.[LH]):<<16
904 let isCodeGenOnly = 0 in {
905 def A2_subh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 1>;
906 def A2_subh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 1>;
907 def A2_subh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 1>;
908 def A2_subh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 1>;
911 //Rd=add(Rt.[LH],Rs.[LH]):<<16
912 let isCodeGenOnly = 0 in {
913 def A2_addh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 0>;
914 def A2_addh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 0>;
915 def A2_addh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 0>;
916 def A2_addh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 0>;
919 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF], isCodeGenOnly = 0 in {
920 //Rd=sub(Rt.[LH],Rs.[LH]):sat:<<16
921 def A2_subh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 1>;
922 def A2_subh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 1>;
923 def A2_subh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 1>;
924 def A2_subh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 1>;
926 //Rd=add(Rt.[LH],Rs.[LH]):sat:<<16
927 def A2_addh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 0>;
928 def A2_addh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 0>;
929 def A2_addh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 0>;
930 def A2_addh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 0>;
934 def: Pat<(sext_inreg (add I32:$src1, I32:$src2), i16),
935 (A2_addh_l16_ll I32:$src1, I32:$src2)>;
937 def: Pat<(sra (add (shl I32:$src1, (i32 16)), I32:$src2), (i32 16)),
938 (A2_addh_l16_hl I32:$src1, I32:$src2)>;
940 def: Pat<(shl (add I32:$src1, I32:$src2), (i32 16)),
941 (A2_addh_h16_ll I32:$src1, I32:$src2)>;
943 // Subtract halfword.
944 def: Pat<(sext_inreg (sub I32:$src1, I32:$src2), i16),
945 (A2_subh_l16_ll I32:$src1, I32:$src2)>;
947 def: Pat<(shl (sub I32:$src1, I32:$src2), (i32 16)),
948 (A2_subh_h16_ll I32:$src1, I32:$src2)>;
950 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
951 def S2_parityp: ALU64Inst<(outs IntRegs:$Rd),
952 (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
953 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
959 let Inst{27-24} = 0b0000;
960 let Inst{20-16} = Rs;
965 let hasNewValue = 1, opNewValue = 0, hasSideEffects = 0 in
966 class T_XTYPE_MIN_MAX < bit isMax, bit isUnsigned >
967 : ALU64Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
968 "$Rd = "#!if(isMax,"max","min")#!if(isUnsigned,"u","")
969 #"($Rt, $Rs)", [], "", ALU64_tc_2_SLOT23> {
976 let Inst{27-23} = 0b01011;
977 let Inst{22-21} = !if(isMax, 0b10, 0b01);
978 let Inst{7} = isUnsigned;
980 let Inst{12-8} = !if(isMax, Rs, Rt);
981 let Inst{20-16} = !if(isMax, Rt, Rs);
984 let isCodeGenOnly = 0 in {
985 def A2_min : T_XTYPE_MIN_MAX < 0, 0 >;
986 def A2_minu : T_XTYPE_MIN_MAX < 0, 1 >;
987 def A2_max : T_XTYPE_MIN_MAX < 1, 0 >;
988 def A2_maxu : T_XTYPE_MIN_MAX < 1, 1 >;
991 // Here, depending on the operand being selected, we'll either generate a
992 // min or max instruction.
994 // (a>b)?a:b --> max(a,b) => Here check performed is '>' and the value selected
995 // is the larger of two. So, the corresponding HexagonInst is passed in 'Inst'.
996 // (a>b)?b:a --> min(a,b) => Here check performed is '>' but the smaller value
997 // is selected and the corresponding HexagonInst is passed in 'SwapInst'.
999 multiclass T_MinMax_pats <PatFrag Op, RegisterClass RC, ValueType VT,
1000 InstHexagon Inst, InstHexagon SwapInst> {
1001 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1002 (VT RC:$src1), (VT RC:$src2)),
1003 (Inst RC:$src1, RC:$src2)>;
1004 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1005 (VT RC:$src2), (VT RC:$src1)),
1006 (SwapInst RC:$src1, RC:$src2)>;
1010 multiclass MinMax_pats <PatFrag Op, InstHexagon Inst, InstHexagon SwapInst> {
1011 defm: T_MinMax_pats<Op, IntRegs, i32, Inst, SwapInst>;
1013 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1014 (i32 PositiveHalfWord:$src2))),
1015 (i32 PositiveHalfWord:$src1),
1016 (i32 PositiveHalfWord:$src2))), i16),
1017 (Inst IntRegs:$src1, IntRegs:$src2)>;
1019 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1020 (i32 PositiveHalfWord:$src2))),
1021 (i32 PositiveHalfWord:$src2),
1022 (i32 PositiveHalfWord:$src1))), i16),
1023 (SwapInst IntRegs:$src1, IntRegs:$src2)>;
1026 let AddedComplexity = 200 in {
1027 defm: MinMax_pats<setge, A2_max, A2_min>;
1028 defm: MinMax_pats<setgt, A2_max, A2_min>;
1029 defm: MinMax_pats<setle, A2_min, A2_max>;
1030 defm: MinMax_pats<setlt, A2_min, A2_max>;
1031 defm: MinMax_pats<setuge, A2_maxu, A2_minu>;
1032 defm: MinMax_pats<setugt, A2_maxu, A2_minu>;
1033 defm: MinMax_pats<setule, A2_minu, A2_maxu>;
1034 defm: MinMax_pats<setult, A2_minu, A2_maxu>;
1037 class T_cmp64_rr<string mnemonic, bits<3> MinOp, bit IsComm>
1038 : ALU64_rr<(outs PredRegs:$Pd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1039 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", ALU64_tc_2early_SLOT23> {
1041 let isCommutable = IsComm;
1042 let hasSideEffects = 0;
1048 let IClass = 0b1101;
1049 let Inst{27-21} = 0b0010100;
1050 let Inst{20-16} = Rs;
1051 let Inst{12-8} = Rt;
1052 let Inst{7-5} = MinOp;
1056 let isCodeGenOnly = 0 in {
1057 def C2_cmpeqp : T_cmp64_rr<"cmp.eq", 0b000, 1>;
1058 def C2_cmpgtp : T_cmp64_rr<"cmp.gt", 0b010, 0>;
1059 def C2_cmpgtup : T_cmp64_rr<"cmp.gtu", 0b100, 0>;
1062 class T_cmp64_rr_pat<InstHexagon MI, PatFrag CmpOp>
1063 : Pat<(i1 (CmpOp (i64 DoubleRegs:$Rs), (i64 DoubleRegs:$Rt))),
1064 (i1 (MI DoubleRegs:$Rs, DoubleRegs:$Rt))>;
1066 def: T_cmp64_rr_pat<C2_cmpeqp, seteq>;
1067 def: T_cmp64_rr_pat<C2_cmpgtp, setgt>;
1068 def: T_cmp64_rr_pat<C2_cmpgtup, setugt>;
1069 def: T_cmp64_rr_pat<C2_cmpgtp, RevCmp<setlt>>;
1070 def: T_cmp64_rr_pat<C2_cmpgtup, RevCmp<setult>>;
1072 class T_ALU64_rr<string mnemonic, string suffix, bits<4> RegType,
1073 bits<3> MajOp, bits<3> MinOp, bit OpsRev, bit IsComm,
1075 : ALU64_rr<(outs DoubleRegs:$Rd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1076 "$Rd = " #mnemonic# "($Rs, " #Op2Pfx# "$Rt)" #suffix, [],
1077 "", ALU64_tc_1_SLOT23> {
1078 let hasSideEffects = 0;
1079 let isCommutable = IsComm;
1085 let IClass = 0b1101;
1086 let Inst{27-24} = RegType;
1087 let Inst{23-21} = MajOp;
1088 let Inst{20-16} = !if (OpsRev,Rt,Rs);
1089 let Inst{12-8} = !if (OpsRev,Rs,Rt);
1090 let Inst{7-5} = MinOp;
1094 class T_ALU64_arith<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit IsSat,
1095 bit OpsRev, bit IsComm>
1096 : T_ALU64_rr<mnemonic, !if(IsSat,":sat",""), 0b0011, MajOp, MinOp, OpsRev,
1099 let isCodeGenOnly = 0 in {
1100 def A2_addp : T_ALU64_arith<"add", 0b000, 0b111, 0, 0, 1>;
1101 def A2_subp : T_ALU64_arith<"sub", 0b001, 0b111, 0, 1, 0>;
1104 def: Pat<(i64 (add I64:$Rs, I64:$Rt)), (A2_addp I64:$Rs, I64:$Rt)>;
1105 def: Pat<(i64 (sub I64:$Rs, I64:$Rt)), (A2_subp I64:$Rs, I64:$Rt)>;
1107 class T_ALU64_logical<string mnemonic, bits<3> MinOp, bit OpsRev, bit IsComm,
1109 : T_ALU64_rr<mnemonic, "", 0b0011, 0b111, MinOp, OpsRev, IsComm,
1112 let isCodeGenOnly = 0 in {
1113 def A2_andp : T_ALU64_logical<"and", 0b000, 0, 1, 0>;
1114 def A2_orp : T_ALU64_logical<"or", 0b010, 0, 1, 0>;
1115 def A2_xorp : T_ALU64_logical<"xor", 0b100, 0, 1, 0>;
1118 def: Pat<(i64 (and I64:$Rs, I64:$Rt)), (A2_andp I64:$Rs, I64:$Rt)>;
1119 def: Pat<(i64 (or I64:$Rs, I64:$Rt)), (A2_orp I64:$Rs, I64:$Rt)>;
1120 def: Pat<(i64 (xor I64:$Rs, I64:$Rt)), (A2_xorp I64:$Rs, I64:$Rt)>;
1122 //===----------------------------------------------------------------------===//
1124 //===----------------------------------------------------------------------===//
1126 //===----------------------------------------------------------------------===//
1128 //===----------------------------------------------------------------------===//
1130 //===----------------------------------------------------------------------===//
1132 //===----------------------------------------------------------------------===//
1134 //===----------------------------------------------------------------------===//
1136 //===----------------------------------------------------------------------===//
1138 //===----------------------------------------------------------------------===//
1140 //===----------------------------------------------------------------------===//
1142 //===----------------------------------------------------------------------===//
1144 //===----------------------------------------------------------------------===//
1145 // Logical reductions on predicates.
1147 // Looping instructions.
1149 // Pipelined looping instructions.
1151 // Logical operations on predicates.
1152 let hasSideEffects = 0 in
1153 class T_LOGICAL_1OP<string MnOp, bits<2> OpBits>
1154 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps),
1155 "$Pd = " # MnOp # "($Ps)", [], "", CR_tc_2early_SLOT23> {
1159 let IClass = 0b0110;
1160 let Inst{27-23} = 0b10111;
1161 let Inst{22-21} = OpBits;
1163 let Inst{17-16} = Ps;
1168 let isCodeGenOnly = 0 in {
1169 def C2_any8 : T_LOGICAL_1OP<"any8", 0b00>;
1170 def C2_all8 : T_LOGICAL_1OP<"all8", 0b01>;
1171 def C2_not : T_LOGICAL_1OP<"not", 0b10>;
1174 def: Pat<(i1 (not (i1 PredRegs:$Ps))),
1175 (C2_not PredRegs:$Ps)>;
1177 let hasSideEffects = 0 in
1178 class T_LOGICAL_2OP<string MnOp, bits<3> OpBits, bit IsNeg, bit Rev>
1179 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps, PredRegs:$Pt),
1180 "$Pd = " # MnOp # "($Ps, " # !if (IsNeg,"!","") # "$Pt)",
1181 [], "", CR_tc_2early_SLOT23> {
1186 let IClass = 0b0110;
1187 let Inst{27-24} = 0b1011;
1188 let Inst{23-21} = OpBits;
1190 let Inst{17-16} = !if(Rev,Pt,Ps); // Rs and Rt are reversed for some
1191 let Inst{13} = 0b0; // instructions.
1192 let Inst{9-8} = !if(Rev,Ps,Pt);
1196 let isCodeGenOnly = 0 in {
1197 def C2_and : T_LOGICAL_2OP<"and", 0b000, 0, 1>;
1198 def C2_or : T_LOGICAL_2OP<"or", 0b001, 0, 1>;
1199 def C2_xor : T_LOGICAL_2OP<"xor", 0b010, 0, 0>;
1200 def C2_andn : T_LOGICAL_2OP<"and", 0b011, 1, 1>;
1201 def C2_orn : T_LOGICAL_2OP<"or", 0b111, 1, 1>;
1204 def: Pat<(i1 (and I1:$Ps, I1:$Pt)), (C2_and I1:$Ps, I1:$Pt)>;
1205 def: Pat<(i1 (or I1:$Ps, I1:$Pt)), (C2_or I1:$Ps, I1:$Pt)>;
1206 def: Pat<(i1 (xor I1:$Ps, I1:$Pt)), (C2_xor I1:$Ps, I1:$Pt)>;
1207 def: Pat<(i1 (and I1:$Ps, (not I1:$Pt))), (C2_andn I1:$Ps, I1:$Pt)>;
1208 def: Pat<(i1 (or I1:$Ps, (not I1:$Pt))), (C2_orn I1:$Ps, I1:$Pt)>;
1210 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
1211 def C2_vitpack : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps, PredRegs:$Pt),
1212 "$Rd = vitpack($Ps, $Pt)", [], "", S_2op_tc_1_SLOT23> {
1217 let IClass = 0b1000;
1218 let Inst{27-24} = 0b1001;
1219 let Inst{22-21} = 0b00;
1220 let Inst{17-16} = Ps;
1225 let hasSideEffects = 0, isCodeGenOnly = 0 in
1226 def C2_mask : SInst<(outs DoubleRegs:$Rd), (ins PredRegs:$Pt),
1227 "$Rd = mask($Pt)", [], "", S_2op_tc_1_SLOT23> {
1231 let IClass = 0b1000;
1232 let Inst{27-24} = 0b0110;
1237 def VALIGN_rrp : SInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1,
1240 "$dst = valignb($src1, $src2, $src3)",
1243 def VSPLICE_rrp : SInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1,
1246 "$dst = vspliceb($src1, $src2, $src3)",
1249 // User control register transfer.
1250 //===----------------------------------------------------------------------===//
1252 //===----------------------------------------------------------------------===//
1254 //===----------------------------------------------------------------------===//
1256 //===----------------------------------------------------------------------===//
1258 def retflag : SDNode<"HexagonISD::RET_FLAG", SDTNone,
1259 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
1260 def eh_return: SDNode<"HexagonISD::EH_RETURN", SDTNone, [SDNPHasChain]>;
1262 def SDHexagonBR_JT: SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
1263 def HexagonBR_JT: SDNode<"HexagonISD::BR_JT", SDHexagonBR_JT, [SDNPHasChain]>;
1265 class CondStr<string CReg, bit True, bit New> {
1266 string S = "if (" # !if(True,"","!") # CReg # !if(New,".new","") # ") ";
1268 class JumpOpcStr<string Mnemonic, bit New, bit Taken> {
1269 string S = Mnemonic # !if(New, !if(Taken,":t",":nt"), "");
1272 let isBranch = 1, isBarrier = 1, Defs = [PC], hasSideEffects = 0,
1274 isExtendable = 1, opExtendable = 0, isExtentSigned = 1,
1275 opExtentBits = 24, opExtentAlign = 2, InputType = "imm" in
1276 class T_JMP<string ExtStr>
1277 : JInst<(outs), (ins brtarget:$dst),
1278 "jump " # ExtStr # "$dst",
1279 [], "", J_tc_2early_SLOT23> {
1281 let IClass = 0b0101;
1283 let Inst{27-25} = 0b100;
1284 let Inst{24-16} = dst{23-15};
1285 let Inst{13-1} = dst{14-2};
1288 let isBranch = 1, Defs = [PC], hasSideEffects = 0, isPredicated = 1,
1289 isExtendable = 1, opExtendable = 1, isExtentSigned = 1,
1290 opExtentBits = 17, opExtentAlign = 2, InputType = "imm" in
1291 class T_JMP_c<bit PredNot, bit isPredNew, bit isTak, string ExtStr>
1292 : JInst<(outs), (ins PredRegs:$src, brtarget:$dst),
1293 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1294 JumpOpcStr<"jump", isPredNew, isTak>.S # " " #
1296 [], "", J_tc_2early_SLOT23>, ImmRegRel {
1297 let isTaken = isTak;
1298 let isPredicatedFalse = PredNot;
1299 let isPredicatedNew = isPredNew;
1303 let IClass = 0b0101;
1305 let Inst{27-24} = 0b1100;
1306 let Inst{21} = PredNot;
1307 let Inst{12} = !if(isPredNew, isTak, zero);
1308 let Inst{11} = isPredNew;
1309 let Inst{9-8} = src;
1310 let Inst{23-22} = dst{16-15};
1311 let Inst{20-16} = dst{14-10};
1312 let Inst{13} = dst{9};
1313 let Inst{7-1} = dst{8-2};
1316 multiclass JMP_Pred<bit PredNot, string ExtStr> {
1317 def NAME : T_JMP_c<PredNot, 0, 0, ExtStr>;
1319 def NAME#newpt : T_JMP_c<PredNot, 1, 1, ExtStr>; // taken
1320 def NAME#new : T_JMP_c<PredNot, 1, 0, ExtStr>; // not taken
1323 multiclass JMP_base<string BaseOp, string ExtStr> {
1324 let BaseOpcode = BaseOp in {
1325 def NAME : T_JMP<ExtStr>;
1326 defm t : JMP_Pred<0, ExtStr>;
1327 defm f : JMP_Pred<1, ExtStr>;
1331 // Jumps to address stored in a register, JUMPR_MISC
1332 // if ([[!]P[.new]]) jumpr[:t/nt] Rs
1333 let isBranch = 1, isIndirectBranch = 1, isBarrier = 1, Defs = [PC],
1334 isPredicable = 1, hasSideEffects = 0, InputType = "reg" in
1336 : JRInst<(outs), (ins IntRegs:$dst),
1337 "jumpr $dst", [], "", J_tc_2early_SLOT2> {
1340 let IClass = 0b0101;
1341 let Inst{27-21} = 0b0010100;
1342 let Inst{20-16} = dst;
1345 let isBranch = 1, isIndirectBranch = 1, Defs = [PC], isPredicated = 1,
1346 hasSideEffects = 0, InputType = "reg" in
1347 class T_JMPr_c <bit PredNot, bit isPredNew, bit isTak>
1348 : JRInst <(outs), (ins PredRegs:$src, IntRegs:$dst),
1349 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1350 JumpOpcStr<"jumpr", isPredNew, isTak>.S # " $dst", [],
1351 "", J_tc_2early_SLOT2> {
1353 let isTaken = isTak;
1354 let isPredicatedFalse = PredNot;
1355 let isPredicatedNew = isPredNew;
1359 let IClass = 0b0101;
1361 let Inst{27-22} = 0b001101;
1362 let Inst{21} = PredNot;
1363 let Inst{20-16} = dst;
1364 let Inst{12} = !if(isPredNew, isTak, zero);
1365 let Inst{11} = isPredNew;
1366 let Inst{9-8} = src;
1369 multiclass JMPR_Pred<bit PredNot> {
1370 def NAME: T_JMPr_c<PredNot, 0, 0>;
1372 def NAME#newpt : T_JMPr_c<PredNot, 1, 1>; // taken
1373 def NAME#new : T_JMPr_c<PredNot, 1, 0>; // not taken
1376 multiclass JMPR_base<string BaseOp> {
1377 let BaseOpcode = BaseOp in {
1379 defm t : JMPR_Pred<0>;
1380 defm f : JMPR_Pred<1>;
1384 let isCall = 1, hasSideEffects = 1 in
1385 class JUMPR_MISC_CALLR<bit isPred, bit isPredNot,
1386 dag InputDag = (ins IntRegs:$Rs)>
1387 : JRInst<(outs), InputDag,
1388 !if(isPred, !if(isPredNot, "if (!$Pu) callr $Rs",
1389 "if ($Pu) callr $Rs"),
1391 [], "", J_tc_2early_SLOT2> {
1394 let isPredicated = isPred;
1395 let isPredicatedFalse = isPredNot;
1397 let IClass = 0b0101;
1398 let Inst{27-25} = 0b000;
1399 let Inst{24-23} = !if (isPred, 0b10, 0b01);
1401 let Inst{21} = isPredNot;
1402 let Inst{9-8} = !if (isPred, Pu, 0b00);
1403 let Inst{20-16} = Rs;
1407 let Defs = VolatileV3.Regs, isCodeGenOnly = 0 in {
1408 def J2_callrt : JUMPR_MISC_CALLR<1, 0, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1409 def J2_callrf : JUMPR_MISC_CALLR<1, 1, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1412 let isTerminator = 1, hasSideEffects = 0, isCodeGenOnly = 0 in {
1413 defm J2_jump : JMP_base<"JMP", "">, PredNewRel;
1415 // Deal with explicit assembly
1416 // - never extened a jump #, always extend a jump ##
1417 let isAsmParserOnly = 1 in {
1418 defm J2_jump_ext : JMP_base<"JMP", "##">;
1419 defm J2_jump_noext : JMP_base<"JMP", "#">;
1422 defm J2_jumpr : JMPR_base<"JMPr">, PredNewRel;
1424 let isReturn = 1, isCodeGenOnly = 1 in
1425 defm JMPret : JMPR_base<"JMPret">, PredNewRel;
1428 def: Pat<(br bb:$dst),
1429 (J2_jump brtarget:$dst)>;
1431 (JMPret (i32 R31))>;
1432 def: Pat<(brcond (i1 PredRegs:$src1), bb:$offset),
1433 (J2_jumpt PredRegs:$src1, bb:$offset)>;
1435 // A return through builtin_eh_return.
1436 let isReturn = 1, isTerminator = 1, isBarrier = 1, hasSideEffects = 0,
1437 isCodeGenOnly = 1, Defs = [PC], Uses = [R28], isPredicable = 0 in
1438 def EH_RETURN_JMPR : T_JMPr;
1440 def: Pat<(eh_return),
1441 (EH_RETURN_JMPR (i32 R31))>;
1442 def: Pat<(HexagonBR_JT (i32 IntRegs:$dst)),
1443 (J2_jumpr IntRegs:$dst)>;
1444 def: Pat<(brind (i32 IntRegs:$dst)),
1445 (J2_jumpr IntRegs:$dst)>;
1447 //===----------------------------------------------------------------------===//
1449 //===----------------------------------------------------------------------===//
1451 //===----------------------------------------------------------------------===//
1453 //===----------------------------------------------------------------------===//
1454 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, AddedComplexity = 20 in
1455 class T_load_io <string mnemonic, RegisterClass RC, bits<4> MajOp,
1457 : LDInst<(outs RC:$dst), (ins IntRegs:$src1, ImmOp:$offset),
1458 "$dst = "#mnemonic#"($src1 + #$offset)", []>, AddrModeRel {
1463 bits<11> offsetBits;
1465 string ImmOpStr = !cast<string>(ImmOp);
1466 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), offset{13-3},
1467 !if (!eq(ImmOpStr, "s11_2Ext"), offset{12-2},
1468 !if (!eq(ImmOpStr, "s11_1Ext"), offset{11-1},
1469 /* s11_0Ext */ offset{10-0})));
1470 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
1471 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
1472 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
1473 /* s11_0Ext */ 11)));
1474 let hasNewValue = !if (!eq(ImmOpStr, "s11_3Ext"), 0, 1);
1476 let IClass = 0b1001;
1479 let Inst{26-25} = offsetBits{10-9};
1480 let Inst{24-21} = MajOp;
1481 let Inst{20-16} = src1;
1482 let Inst{13-5} = offsetBits{8-0};
1483 let Inst{4-0} = dst;
1486 let opExtendable = 3, isExtentSigned = 0, isPredicated = 1 in
1487 class T_pload_io <string mnemonic, RegisterClass RC, bits<4>MajOp,
1488 Operand ImmOp, bit isNot, bit isPredNew>
1489 : LDInst<(outs RC:$dst),
1490 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1491 "if ("#!if(isNot, "!$src1", "$src1")
1492 #!if(isPredNew, ".new", "")
1493 #") $dst = "#mnemonic#"($src2 + #$offset)",
1494 [],"", V2LDST_tc_ld_SLOT01> , AddrModeRel {
1500 string ImmOpStr = !cast<string>(ImmOp);
1502 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), offset{8-3},
1503 !if (!eq(ImmOpStr, "u6_2Ext"), offset{7-2},
1504 !if (!eq(ImmOpStr, "u6_1Ext"), offset{6-1},
1505 /* u6_0Ext */ offset{5-0})));
1506 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
1507 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
1508 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
1510 let hasNewValue = !if (!eq(ImmOpStr, "u6_3Ext"), 0, 1);
1511 let isPredicatedNew = isPredNew;
1512 let isPredicatedFalse = isNot;
1514 let IClass = 0b0100;
1518 let Inst{26} = isNot;
1519 let Inst{25} = isPredNew;
1520 let Inst{24-21} = MajOp;
1521 let Inst{20-16} = src2;
1523 let Inst{12-11} = src1;
1524 let Inst{10-5} = offsetBits;
1525 let Inst{4-0} = dst;
1528 let isExtendable = 1, hasSideEffects = 0, addrMode = BaseImmOffset in
1529 multiclass LD_Idxd<string mnemonic, string CextOp, RegisterClass RC,
1530 Operand ImmOp, Operand predImmOp, bits<4>MajOp> {
1531 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1532 let isPredicable = 1 in
1533 def L2_#NAME#_io : T_load_io <mnemonic, RC, MajOp, ImmOp>;
1536 def L2_p#NAME#t_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 0>;
1537 def L2_p#NAME#f_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 0>;
1540 def L2_p#NAME#tnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 1>;
1541 def L2_p#NAME#fnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 1>;
1545 let accessSize = ByteAccess, isCodeGenOnly = 0 in {
1546 defm loadrb: LD_Idxd <"memb", "LDrib", IntRegs, s11_0Ext, u6_0Ext, 0b1000>;
1547 defm loadrub: LD_Idxd <"memub", "LDriub", IntRegs, s11_0Ext, u6_0Ext, 0b1001>;
1550 let accessSize = HalfWordAccess, opExtentAlign = 1, isCodeGenOnly = 0 in {
1551 defm loadrh: LD_Idxd <"memh", "LDrih", IntRegs, s11_1Ext, u6_1Ext, 0b1010>;
1552 defm loadruh: LD_Idxd <"memuh", "LDriuh", IntRegs, s11_1Ext, u6_1Ext, 0b1011>;
1555 let accessSize = WordAccess, opExtentAlign = 2, isCodeGenOnly = 0 in
1556 defm loadri: LD_Idxd <"memw", "LDriw", IntRegs, s11_2Ext, u6_2Ext, 0b1100>;
1558 let accessSize = DoubleWordAccess, opExtentAlign = 3, isCodeGenOnly = 0 in
1559 defm loadrd: LD_Idxd <"memd", "LDrid", DoubleRegs, s11_3Ext, u6_3Ext, 0b1110>;
1561 def : Pat < (i32 (sextloadi8 ADDRriS11_0:$addr)),
1562 (L2_loadrb_io AddrFI:$addr, 0) >;
1564 def : Pat < (i32 (zextloadi8 ADDRriS11_0:$addr)),
1565 (L2_loadrub_io AddrFI:$addr, 0) >;
1567 def : Pat < (i32 (sextloadi16 ADDRriS11_1:$addr)),
1568 (L2_loadrh_io AddrFI:$addr, 0) >;
1570 def : Pat < (i32 (zextloadi16 ADDRriS11_1:$addr)),
1571 (L2_loadruh_io AddrFI:$addr, 0) >;
1573 def : Pat < (i32 (load ADDRriS11_2:$addr)),
1574 (L2_loadri_io AddrFI:$addr, 0) >;
1576 def : Pat < (i64 (load ADDRriS11_3:$addr)),
1577 (L2_loadrd_io AddrFI:$addr, 0) >;
1579 let AddedComplexity = 20 in {
1580 def : Pat < (i32 (sextloadi8 (add IntRegs:$src1, s11_0ExtPred:$offset))),
1581 (L2_loadrb_io IntRegs:$src1, s11_0ExtPred:$offset) >;
1583 def : Pat < (i32 (zextloadi8 (add IntRegs:$src1, s11_0ExtPred:$offset))),
1584 (L2_loadrub_io IntRegs:$src1, s11_0ExtPred:$offset) >;
1586 def : Pat < (i32 (sextloadi16 (add IntRegs:$src1, s11_1ExtPred:$offset))),
1587 (L2_loadrh_io IntRegs:$src1, s11_1ExtPred:$offset) >;
1589 def : Pat < (i32 (zextloadi16 (add IntRegs:$src1, s11_1ExtPred:$offset))),
1590 (L2_loadruh_io IntRegs:$src1, s11_1ExtPred:$offset) >;
1592 def : Pat < (i32 (load (add IntRegs:$src1, s11_2ExtPred:$offset))),
1593 (L2_loadri_io IntRegs:$src1, s11_2ExtPred:$offset) >;
1595 def : Pat < (i64 (load (add IntRegs:$src1, s11_3ExtPred:$offset))),
1596 (L2_loadrd_io IntRegs:$src1, s11_3ExtPred:$offset) >;
1599 //===----------------------------------------------------------------------===//
1600 // Post increment load
1601 //===----------------------------------------------------------------------===//
1603 multiclass LD_PostInc_Pbase<string mnemonic, RegisterClass RC, Operand ImmOp,
1604 bit isNot, bit isPredNew> {
1605 let isPredicatedNew = isPredNew in
1606 def NAME : LDInst2PI<(outs RC:$dst, IntRegs:$dst2),
1607 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1608 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1609 ") ")#"$dst = "#mnemonic#"($src2++#$offset)",
1614 multiclass LD_PostInc_Pred<string mnemonic, RegisterClass RC,
1615 Operand ImmOp, bit PredNot> {
1616 let isPredicatedFalse = PredNot in {
1617 defm _c#NAME : LD_PostInc_Pbase<mnemonic, RC, ImmOp, PredNot, 0>;
1619 let Predicates = [HasV4T], validSubTargets = HasV4SubT in
1620 defm _cdn#NAME#_V4 : LD_PostInc_Pbase<mnemonic, RC, ImmOp, PredNot, 1>;
1624 multiclass LD_PostInc<string mnemonic, string BaseOp, RegisterClass RC,
1627 let BaseOpcode = "POST_"#BaseOp in {
1628 let isPredicable = 1 in
1629 def NAME : LDInst2PI<(outs RC:$dst, IntRegs:$dst2),
1630 (ins IntRegs:$src1, ImmOp:$offset),
1631 "$dst = "#mnemonic#"($src1++#$offset)",
1635 let isPredicated = 1 in {
1636 defm Pt : LD_PostInc_Pred<mnemonic, RC, ImmOp, 0 >;
1637 defm NotPt : LD_PostInc_Pred<mnemonic, RC, ImmOp, 1 >;
1642 let hasCtrlDep = 1, hasSideEffects = 0, addrMode = PostInc in {
1643 defm POST_LDrib : LD_PostInc<"memb", "LDrib", IntRegs, s4_0Imm>,
1645 defm POST_LDriub : LD_PostInc<"memub", "LDriub", IntRegs, s4_0Imm>,
1647 defm POST_LDrih : LD_PostInc<"memh", "LDrih", IntRegs, s4_1Imm>,
1649 defm POST_LDriuh : LD_PostInc<"memuh", "LDriuh", IntRegs, s4_1Imm>,
1651 defm POST_LDriw : LD_PostInc<"memw", "LDriw", IntRegs, s4_2Imm>,
1653 defm POST_LDrid : LD_PostInc<"memd", "LDrid", DoubleRegs, s4_3Imm>,
1657 def : Pat< (i32 (extloadi1 ADDRriS11_0:$addr)),
1658 (i32 (L2_loadrb_io AddrFI:$addr, 0)) >;
1660 // Load byte any-extend.
1661 def : Pat < (i32 (extloadi8 ADDRriS11_0:$addr)),
1662 (i32 (L2_loadrb_io AddrFI:$addr, 0)) >;
1664 // Indexed load byte any-extend.
1665 let AddedComplexity = 20 in
1666 def : Pat < (i32 (extloadi8 (add IntRegs:$src1, s11_0ImmPred:$offset))),
1667 (i32 (L2_loadrb_io IntRegs:$src1, s11_0ImmPred:$offset)) >;
1669 def : Pat < (i32 (extloadi16 ADDRriS11_1:$addr)),
1670 (i32 (L2_loadrh_io AddrFI:$addr, 0))>;
1672 let AddedComplexity = 20 in
1673 def : Pat < (i32 (extloadi16 (add IntRegs:$src1, s11_1ImmPred:$offset))),
1674 (i32 (L2_loadrh_io IntRegs:$src1, s11_1ImmPred:$offset)) >;
1676 let AddedComplexity = 10 in
1677 def : Pat < (i32 (zextloadi1 ADDRriS11_0:$addr)),
1678 (i32 (L2_loadrub_io AddrFI:$addr, 0))>;
1680 let AddedComplexity = 20 in
1681 def : Pat < (i32 (zextloadi1 (add IntRegs:$src1, s11_0ImmPred:$offset))),
1682 (i32 (L2_loadrub_io IntRegs:$src1, s11_0ImmPred:$offset))>;
1685 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 13,
1686 isPseudo = 1, Defs = [R10,R11,D5], hasSideEffects = 0 in
1687 def LDriw_pred : LDInst2<(outs PredRegs:$dst),
1689 "Error; should not emit",
1692 // Deallocate stack frame.
1693 let Defs = [R29, R30, R31], Uses = [R29], hasSideEffects = 0 in {
1694 def DEALLOCFRAME : LDInst2<(outs), (ins),
1699 // Load and unpack bytes to halfwords.
1700 //===----------------------------------------------------------------------===//
1702 //===----------------------------------------------------------------------===//
1704 //===----------------------------------------------------------------------===//
1706 //===----------------------------------------------------------------------===//
1707 //===----------------------------------------------------------------------===//
1709 //===----------------------------------------------------------------------===//
1711 //===----------------------------------------------------------------------===//
1713 //===----------------------------------------------------------------------===//
1714 //===----------------------------------------------------------------------===//
1716 //===----------------------------------------------------------------------===//
1718 //===----------------------------------------------------------------------===//
1720 //===----------------------------------------------------------------------===//
1722 //===----------------------------------------------------------------------===//
1724 // MPYS / Multipy signed/unsigned halfwords
1725 //Rd=mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
1726 //===----------------------------------------------------------------------===//
1728 let hasNewValue = 1, opNewValue = 0 in
1729 class T_M2_mpy < bits<2> LHbits, bit isSat, bit isRnd,
1730 bit hasShift, bit isUnsigned>
1731 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1732 "$Rd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
1733 #", $Rt."#!if(LHbits{0},"h)","l)")
1734 #!if(hasShift,":<<1","")
1735 #!if(isRnd,":rnd","")
1736 #!if(isSat,":sat",""),
1737 [], "", M_tc_3x_SLOT23 > {
1742 let IClass = 0b1110;
1744 let Inst{27-24} = 0b1100;
1745 let Inst{23} = hasShift;
1746 let Inst{22} = isUnsigned;
1747 let Inst{21} = isRnd;
1748 let Inst{7} = isSat;
1749 let Inst{6-5} = LHbits;
1751 let Inst{20-16} = Rs;
1752 let Inst{12-8} = Rt;
1755 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]
1756 let isCodeGenOnly = 0 in {
1757 def M2_mpy_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 0>;
1758 def M2_mpy_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 0>;
1759 def M2_mpy_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 0>;
1760 def M2_mpy_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 0>;
1761 def M2_mpy_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 0>;
1762 def M2_mpy_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 0>;
1763 def M2_mpy_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 0>;
1764 def M2_mpy_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 0>;
1767 //Rd=mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
1768 let isCodeGenOnly = 0 in {
1769 def M2_mpyu_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 1>;
1770 def M2_mpyu_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 1>;
1771 def M2_mpyu_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 1>;
1772 def M2_mpyu_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 1>;
1773 def M2_mpyu_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 1>;
1774 def M2_mpyu_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 1>;
1775 def M2_mpyu_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 1>;
1776 def M2_mpyu_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 1>;
1779 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]:rnd
1780 let isCodeGenOnly = 0 in {
1781 def M2_mpy_rnd_ll_s1: T_M2_mpy <0b00, 0, 1, 1, 0>;
1782 def M2_mpy_rnd_ll_s0: T_M2_mpy <0b00, 0, 1, 0, 0>;
1783 def M2_mpy_rnd_lh_s1: T_M2_mpy <0b01, 0, 1, 1, 0>;
1784 def M2_mpy_rnd_lh_s0: T_M2_mpy <0b01, 0, 1, 0, 0>;
1785 def M2_mpy_rnd_hl_s1: T_M2_mpy <0b10, 0, 1, 1, 0>;
1786 def M2_mpy_rnd_hl_s0: T_M2_mpy <0b10, 0, 1, 0, 0>;
1787 def M2_mpy_rnd_hh_s1: T_M2_mpy <0b11, 0, 1, 1, 0>;
1788 def M2_mpy_rnd_hh_s0: T_M2_mpy <0b11, 0, 1, 0, 0>;
1791 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:sat]
1792 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
1793 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
1794 def M2_mpy_sat_ll_s1: T_M2_mpy <0b00, 1, 0, 1, 0>;
1795 def M2_mpy_sat_ll_s0: T_M2_mpy <0b00, 1, 0, 0, 0>;
1796 def M2_mpy_sat_lh_s1: T_M2_mpy <0b01, 1, 0, 1, 0>;
1797 def M2_mpy_sat_lh_s0: T_M2_mpy <0b01, 1, 0, 0, 0>;
1798 def M2_mpy_sat_hl_s1: T_M2_mpy <0b10, 1, 0, 1, 0>;
1799 def M2_mpy_sat_hl_s0: T_M2_mpy <0b10, 1, 0, 0, 0>;
1800 def M2_mpy_sat_hh_s1: T_M2_mpy <0b11, 1, 0, 1, 0>;
1801 def M2_mpy_sat_hh_s0: T_M2_mpy <0b11, 1, 0, 0, 0>;
1803 def M2_mpy_sat_rnd_ll_s1: T_M2_mpy <0b00, 1, 1, 1, 0>;
1804 def M2_mpy_sat_rnd_ll_s0: T_M2_mpy <0b00, 1, 1, 0, 0>;
1805 def M2_mpy_sat_rnd_lh_s1: T_M2_mpy <0b01, 1, 1, 1, 0>;
1806 def M2_mpy_sat_rnd_lh_s0: T_M2_mpy <0b01, 1, 1, 0, 0>;
1807 def M2_mpy_sat_rnd_hl_s1: T_M2_mpy <0b10, 1, 1, 1, 0>;
1808 def M2_mpy_sat_rnd_hl_s0: T_M2_mpy <0b10, 1, 1, 0, 0>;
1809 def M2_mpy_sat_rnd_hh_s1: T_M2_mpy <0b11, 1, 1, 1, 0>;
1810 def M2_mpy_sat_rnd_hh_s0: T_M2_mpy <0b11, 1, 1, 0, 0>;
1813 //===----------------------------------------------------------------------===//
1815 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
1816 // result from the accumulator.
1817 //Rx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
1818 //===----------------------------------------------------------------------===//
1820 let hasNewValue = 1, opNewValue = 0 in
1821 class T_M2_mpy_acc < bits<2> LHbits, bit isSat, bit isNac,
1822 bit hasShift, bit isUnsigned >
1823 : MInst_acc<(outs IntRegs:$Rx), (ins IntRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
1824 "$Rx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
1825 #"($Rs."#!if(LHbits{1},"h","l")
1826 #", $Rt."#!if(LHbits{0},"h)","l)")
1827 #!if(hasShift,":<<1","")
1828 #!if(isSat,":sat",""),
1829 [], "$dst2 = $Rx", M_tc_3x_SLOT23 > {
1834 let IClass = 0b1110;
1835 let Inst{27-24} = 0b1110;
1836 let Inst{23} = hasShift;
1837 let Inst{22} = isUnsigned;
1838 let Inst{21} = isNac;
1839 let Inst{7} = isSat;
1840 let Inst{6-5} = LHbits;
1842 let Inst{20-16} = Rs;
1843 let Inst{12-8} = Rt;
1846 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]
1847 let isCodeGenOnly = 0 in {
1848 def M2_mpy_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 0>;
1849 def M2_mpy_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 0>;
1850 def M2_mpy_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 0>;
1851 def M2_mpy_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 0>;
1852 def M2_mpy_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 0>;
1853 def M2_mpy_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 0>;
1854 def M2_mpy_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 0>;
1855 def M2_mpy_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 0>;
1858 //Rx += mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
1859 let isCodeGenOnly = 0 in {
1860 def M2_mpyu_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 1>;
1861 def M2_mpyu_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 1>;
1862 def M2_mpyu_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 1>;
1863 def M2_mpyu_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 1>;
1864 def M2_mpyu_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 1>;
1865 def M2_mpyu_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 1>;
1866 def M2_mpyu_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 1>;
1867 def M2_mpyu_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 1>;
1870 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]
1871 let isCodeGenOnly = 0 in {
1872 def M2_mpy_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 0>;
1873 def M2_mpy_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 0>;
1874 def M2_mpy_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 0>;
1875 def M2_mpy_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 0>;
1876 def M2_mpy_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 0>;
1877 def M2_mpy_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 0>;
1878 def M2_mpy_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 0>;
1879 def M2_mpy_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 0>;
1882 //Rx -= mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
1883 let isCodeGenOnly = 0 in {
1884 def M2_mpyu_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 1>;
1885 def M2_mpyu_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 1>;
1886 def M2_mpyu_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 1>;
1887 def M2_mpyu_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 1>;
1888 def M2_mpyu_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 1>;
1889 def M2_mpyu_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 1>;
1890 def M2_mpyu_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 1>;
1891 def M2_mpyu_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 1>;
1894 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
1895 let isCodeGenOnly = 0 in {
1896 def M2_mpy_acc_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 0, 1, 0>;
1897 def M2_mpy_acc_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 0, 0, 0>;
1898 def M2_mpy_acc_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 0, 1, 0>;
1899 def M2_mpy_acc_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 0, 0, 0>;
1900 def M2_mpy_acc_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 0, 1, 0>;
1901 def M2_mpy_acc_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 0, 0, 0>;
1902 def M2_mpy_acc_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 0, 1, 0>;
1903 def M2_mpy_acc_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 0, 0, 0>;
1906 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
1907 let isCodeGenOnly = 0 in {
1908 def M2_mpy_nac_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 1, 1, 0>;
1909 def M2_mpy_nac_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 1, 0, 0>;
1910 def M2_mpy_nac_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 1, 1, 0>;
1911 def M2_mpy_nac_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 1, 0, 0>;
1912 def M2_mpy_nac_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 1, 1, 0>;
1913 def M2_mpy_nac_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 1, 0, 0>;
1914 def M2_mpy_nac_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 1, 1, 0>;
1915 def M2_mpy_nac_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 1, 0, 0>;
1918 //===----------------------------------------------------------------------===//
1920 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
1921 // result from the 64-bit destination register.
1922 //Rxx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
1923 //===----------------------------------------------------------------------===//
1925 class T_M2_mpyd_acc < bits<2> LHbits, bit isNac, bit hasShift, bit isUnsigned>
1926 : MInst_acc<(outs DoubleRegs:$Rxx),
1927 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
1928 "$Rxx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
1929 #"($Rs."#!if(LHbits{1},"h","l")
1930 #", $Rt."#!if(LHbits{0},"h)","l)")
1931 #!if(hasShift,":<<1",""),
1932 [], "$dst2 = $Rxx", M_tc_3x_SLOT23 > {
1937 let IClass = 0b1110;
1939 let Inst{27-24} = 0b0110;
1940 let Inst{23} = hasShift;
1941 let Inst{22} = isUnsigned;
1942 let Inst{21} = isNac;
1944 let Inst{6-5} = LHbits;
1945 let Inst{4-0} = Rxx;
1946 let Inst{20-16} = Rs;
1947 let Inst{12-8} = Rt;
1950 let isCodeGenOnly = 0 in {
1951 def M2_mpyd_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 0>;
1952 def M2_mpyd_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 0>;
1953 def M2_mpyd_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 0>;
1954 def M2_mpyd_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 0>;
1956 def M2_mpyd_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 0>;
1957 def M2_mpyd_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 0>;
1958 def M2_mpyd_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 0>;
1959 def M2_mpyd_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 0>;
1961 def M2_mpyd_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 0>;
1962 def M2_mpyd_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 0>;
1963 def M2_mpyd_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 0>;
1964 def M2_mpyd_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 0>;
1966 def M2_mpyd_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 0>;
1967 def M2_mpyd_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 0>;
1968 def M2_mpyd_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 0>;
1969 def M2_mpyd_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 0>;
1971 def M2_mpyud_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 1>;
1972 def M2_mpyud_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 1>;
1973 def M2_mpyud_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 1>;
1974 def M2_mpyud_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 1>;
1976 def M2_mpyud_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 1>;
1977 def M2_mpyud_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 1>;
1978 def M2_mpyud_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 1>;
1979 def M2_mpyud_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 1>;
1981 def M2_mpyud_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 1>;
1982 def M2_mpyud_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 1>;
1983 def M2_mpyud_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 1>;
1984 def M2_mpyud_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 1>;
1986 def M2_mpyud_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 1>;
1987 def M2_mpyud_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 1>;
1988 def M2_mpyud_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 1>;
1989 def M2_mpyud_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 1>;
1992 let hasNewValue = 1, opNewValue = 0 in
1993 class T_MType_mpy <string mnemonic, bits<4> RegTyBits, RegisterClass RC,
1994 bits<3> MajOp, bits<3> MinOp, bit isSat = 0, bit isRnd = 0,
1995 string op2Suffix = "", bit isRaw = 0, bit isHi = 0 >
1996 : MInst <(outs IntRegs:$dst), (ins RC:$src1, RC:$src2),
1998 #"($src1, $src2"#op2Suffix#")"
1999 #!if(MajOp{2}, ":<<1", "")
2000 #!if(isRnd, ":rnd", "")
2001 #!if(isSat, ":sat", "")
2002 #!if(isRaw, !if(isHi, ":raw:hi", ":raw:lo"), ""), [] > {
2007 let IClass = 0b1110;
2009 let Inst{27-24} = RegTyBits;
2010 let Inst{23-21} = MajOp;
2011 let Inst{20-16} = src1;
2013 let Inst{12-8} = src2;
2014 let Inst{7-5} = MinOp;
2015 let Inst{4-0} = dst;
2018 class T_MType_dd <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2019 bit isSat = 0, bit isRnd = 0 >
2020 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, isSat, isRnd>;
2022 class T_MType_rr1 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2023 bit isSat = 0, bit isRnd = 0 >
2024 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd>;
2026 class T_MType_rr2 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2027 bit isSat = 0, bit isRnd = 0, string op2str = "" >
2028 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd, op2str>;
2030 let CextOpcode = "mpyi", InputType = "reg", isCodeGenOnly = 0 in
2031 def M2_mpyi : T_MType_rr1 <"mpyi", 0b000, 0b000>, ImmRegRel;
2033 let isCodeGenOnly = 0 in {
2034 def M2_mpy_up : T_MType_rr1 <"mpy", 0b000, 0b001>;
2035 def M2_mpyu_up : T_MType_rr1 <"mpyu", 0b010, 0b001>;
2038 let isCodeGenOnly = 0 in
2039 def M2_dpmpyss_rnd_s0 : T_MType_rr1 <"mpy", 0b001, 0b001, 0, 1>;
2041 let isCodeGenOnly = 0 in {
2042 def M2_hmmpyh_rs1 : T_MType_rr2 <"mpy", 0b101, 0b100, 1, 1, ".h">;
2043 def M2_hmmpyl_rs1 : T_MType_rr2 <"mpy", 0b111, 0b100, 1, 1, ".l">;
2047 let isCodeGenOnly = 0 in {
2048 def M2_mpysu_up : T_MType_rr1 <"mpysu", 0b011, 0b001, 0>;
2049 def M2_mpy_up_s1_sat : T_MType_rr1 <"mpy", 0b111, 0b000, 1>;
2051 def M2_hmmpyh_s1 : T_MType_rr2 <"mpy", 0b101, 0b000, 1, 0, ".h">;
2052 def M2_hmmpyl_s1 : T_MType_rr2 <"mpy", 0b101, 0b001, 1, 0, ".l">;
2055 def: Pat<(i32 (mul I32:$src1, I32:$src2)), (M2_mpyi I32:$src1, I32:$src2)>;
2056 def: Pat<(i32 (mulhs I32:$src1, I32:$src2)), (M2_mpy_up I32:$src1, I32:$src2)>;
2057 def: Pat<(i32 (mulhu I32:$src1, I32:$src2)), (M2_mpyu_up I32:$src1, I32:$src2)>;
2059 let hasNewValue = 1, opNewValue = 0 in
2060 class T_MType_mpy_ri <bit isNeg, Operand ImmOp, list<dag> pattern>
2061 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, ImmOp:$u8),
2062 "$Rd ="#!if(isNeg, "- ", "+ ")#"mpyi($Rs, #$u8)" ,
2063 pattern, "", M_tc_3x_SLOT23> {
2068 let IClass = 0b1110;
2070 let Inst{27-24} = 0b0000;
2071 let Inst{23} = isNeg;
2074 let Inst{20-16} = Rs;
2075 let Inst{12-5} = u8;
2078 let isExtendable = 1, opExtentBits = 8, opExtendable = 2, isCodeGenOnly = 0 in
2079 def M2_mpysip : T_MType_mpy_ri <0, u8Ext,
2080 [(set (i32 IntRegs:$Rd), (mul IntRegs:$Rs, u8ExtPred:$u8))]>;
2082 let isCodeGenOnly = 0 in
2083 def M2_mpysin : T_MType_mpy_ri <1, u8Imm,
2084 [(set (i32 IntRegs:$Rd), (ineg (mul IntRegs:$Rs,
2087 // Assember mapped to M2_mpyi
2088 let isAsmParserOnly = 1 in
2089 def M2_mpyui : MInst<(outs IntRegs:$dst),
2090 (ins IntRegs:$src1, IntRegs:$src2),
2091 "$dst = mpyui($src1, $src2)">;
2094 // s9 is NOT the same as m9 - but it works.. so far.
2095 // Assembler maps to either Rd=+mpyi(Rs,#u8) or Rd=-mpyi(Rs,#u8)
2096 // depending on the value of m9. See Arch Spec.
2097 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 9,
2098 CextOpcode = "mpyi", InputType = "imm", hasNewValue = 1 in
2099 def M2_mpysmi : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, s9Ext:$src2),
2100 "$dst = mpyi($src1, #$src2)",
2101 [(set (i32 IntRegs:$dst), (mul (i32 IntRegs:$src1),
2102 s9ExtPred:$src2))]>, ImmRegRel;
2104 let hasNewValue = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 3,
2105 InputType = "imm" in
2106 class T_MType_acc_ri <string mnemonic, bits<3> MajOp, Operand ImmOp,
2107 list<dag> pattern = []>
2108 : MInst < (outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, ImmOp:$src3),
2109 "$dst "#mnemonic#"($src2, #$src3)",
2110 pattern, "$src1 = $dst", M_tc_2_SLOT23> {
2115 let IClass = 0b1110;
2117 let Inst{27-26} = 0b00;
2118 let Inst{25-23} = MajOp;
2119 let Inst{20-16} = src2;
2121 let Inst{12-5} = src3;
2122 let Inst{4-0} = dst;
2125 let InputType = "reg", hasNewValue = 1 in
2126 class T_MType_acc_rr <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2127 bit isSwap = 0, list<dag> pattern = [], bit hasNot = 0,
2128 bit isSat = 0, bit isShift = 0>
2129 : MInst < (outs IntRegs:$dst),
2130 (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3),
2131 "$dst "#mnemonic#"($src2, "#!if(hasNot, "~$src3)","$src3)")
2132 #!if(isShift, ":<<1", "")
2133 #!if(isSat, ":sat", ""),
2134 pattern, "$src1 = $dst", M_tc_2_SLOT23 > {
2139 let IClass = 0b1110;
2141 let Inst{27-24} = 0b1111;
2142 let Inst{23-21} = MajOp;
2143 let Inst{20-16} = !if(isSwap, src3, src2);
2145 let Inst{12-8} = !if(isSwap, src2, src3);
2146 let Inst{7-5} = MinOp;
2147 let Inst{4-0} = dst;
2150 let CextOpcode = "MPYI_acc", Itinerary = M_tc_3x_SLOT23, isCodeGenOnly = 0 in {
2151 def M2_macsip : T_MType_acc_ri <"+= mpyi", 0b010, u8Ext,
2152 [(set (i32 IntRegs:$dst),
2153 (add (mul IntRegs:$src2, u8ExtPred:$src3),
2154 IntRegs:$src1))]>, ImmRegRel;
2156 def M2_maci : T_MType_acc_rr <"+= mpyi", 0b000, 0b000, 0,
2157 [(set (i32 IntRegs:$dst),
2158 (add (mul IntRegs:$src2, IntRegs:$src3),
2159 IntRegs:$src1))]>, ImmRegRel;
2162 let CextOpcode = "ADD_acc", isCodeGenOnly = 0 in {
2163 let isExtentSigned = 1 in
2164 def M2_accii : T_MType_acc_ri <"+= add", 0b100, s8Ext,
2165 [(set (i32 IntRegs:$dst),
2166 (add (add (i32 IntRegs:$src2), s8_16ExtPred:$src3),
2167 (i32 IntRegs:$src1)))]>, ImmRegRel;
2169 def M2_acci : T_MType_acc_rr <"+= add", 0b000, 0b001, 0,
2170 [(set (i32 IntRegs:$dst),
2171 (add (add (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2172 (i32 IntRegs:$src1)))]>, ImmRegRel;
2175 let CextOpcode = "SUB_acc", isCodeGenOnly = 0 in {
2176 let isExtentSigned = 1 in
2177 def M2_naccii : T_MType_acc_ri <"-= add", 0b101, s8Ext>, ImmRegRel;
2179 def M2_nacci : T_MType_acc_rr <"-= add", 0b100, 0b001, 0>, ImmRegRel;
2182 let Itinerary = M_tc_3x_SLOT23, isCodeGenOnly = 0 in
2183 def M2_macsin : T_MType_acc_ri <"-= mpyi", 0b011, u8Ext>;
2185 let isCodeGenOnly = 0 in {
2186 def M2_xor_xacc : T_MType_acc_rr < "^= xor", 0b100, 0b011, 0>;
2187 def M2_subacc : T_MType_acc_rr <"+= sub", 0b000, 0b011, 1>;
2190 class T_MType_acc_pat1 <InstHexagon MI, SDNode firstOp, SDNode secOp,
2192 : Pat <(secOp IntRegs:$src1, (firstOp IntRegs:$src2, ImmPred:$src3)),
2193 (MI IntRegs:$src1, IntRegs:$src2, ImmPred:$src3)>;
2195 class T_MType_acc_pat2 <InstHexagon MI, SDNode firstOp, SDNode secOp>
2196 : Pat <(i32 (secOp IntRegs:$src1, (firstOp IntRegs:$src2, IntRegs:$src3))),
2197 (MI IntRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2199 def : T_MType_acc_pat2 <M2_xor_xacc, xor, xor>;
2200 def : T_MType_acc_pat1 <M2_macsin, mul, sub, u8ExtPred>;
2202 def : T_MType_acc_pat1 <M2_naccii, add, sub, s8_16ExtPred>;
2203 def : T_MType_acc_pat2 <M2_nacci, add, sub>;
2204 //===----------------------------------------------------------------------===//
2205 // Template Class -- Multiply signed/unsigned halfwords with and without
2206 // saturation and rounding
2207 //===----------------------------------------------------------------------===//
2208 class T_M2_mpyd < bits<2> LHbits, bit isRnd, bit hasShift, bit isUnsigned >
2209 : MInst < (outs DoubleRegs:$Rdd), (ins IntRegs:$Rs, IntRegs:$Rt),
2210 "$Rdd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
2211 #", $Rt."#!if(LHbits{0},"h)","l)")
2212 #!if(hasShift,":<<1","")
2213 #!if(isRnd,":rnd",""),
2219 let IClass = 0b1110;
2221 let Inst{27-24} = 0b0100;
2222 let Inst{23} = hasShift;
2223 let Inst{22} = isUnsigned;
2224 let Inst{21} = isRnd;
2225 let Inst{6-5} = LHbits;
2226 let Inst{4-0} = Rdd;
2227 let Inst{20-16} = Rs;
2228 let Inst{12-8} = Rt;
2231 let isCodeGenOnly = 0 in {
2232 def M2_mpyd_hh_s0: T_M2_mpyd<0b11, 0, 0, 0>;
2233 def M2_mpyd_hl_s0: T_M2_mpyd<0b10, 0, 0, 0>;
2234 def M2_mpyd_lh_s0: T_M2_mpyd<0b01, 0, 0, 0>;
2235 def M2_mpyd_ll_s0: T_M2_mpyd<0b00, 0, 0, 0>;
2237 def M2_mpyd_hh_s1: T_M2_mpyd<0b11, 0, 1, 0>;
2238 def M2_mpyd_hl_s1: T_M2_mpyd<0b10, 0, 1, 0>;
2239 def M2_mpyd_lh_s1: T_M2_mpyd<0b01, 0, 1, 0>;
2240 def M2_mpyd_ll_s1: T_M2_mpyd<0b00, 0, 1, 0>;
2242 def M2_mpyd_rnd_hh_s0: T_M2_mpyd<0b11, 1, 0, 0>;
2243 def M2_mpyd_rnd_hl_s0: T_M2_mpyd<0b10, 1, 0, 0>;
2244 def M2_mpyd_rnd_lh_s0: T_M2_mpyd<0b01, 1, 0, 0>;
2245 def M2_mpyd_rnd_ll_s0: T_M2_mpyd<0b00, 1, 0, 0>;
2247 def M2_mpyd_rnd_hh_s1: T_M2_mpyd<0b11, 1, 1, 0>;
2248 def M2_mpyd_rnd_hl_s1: T_M2_mpyd<0b10, 1, 1, 0>;
2249 def M2_mpyd_rnd_lh_s1: T_M2_mpyd<0b01, 1, 1, 0>;
2250 def M2_mpyd_rnd_ll_s1: T_M2_mpyd<0b00, 1, 1, 0>;
2252 //Rdd=mpyu(Rs.[HL],Rt.[HL])[:<<1]
2253 def M2_mpyud_hh_s0: T_M2_mpyd<0b11, 0, 0, 1>;
2254 def M2_mpyud_hl_s0: T_M2_mpyd<0b10, 0, 0, 1>;
2255 def M2_mpyud_lh_s0: T_M2_mpyd<0b01, 0, 0, 1>;
2256 def M2_mpyud_ll_s0: T_M2_mpyd<0b00, 0, 0, 1>;
2258 def M2_mpyud_hh_s1: T_M2_mpyd<0b11, 0, 1, 1>;
2259 def M2_mpyud_hl_s1: T_M2_mpyd<0b10, 0, 1, 1>;
2260 def M2_mpyud_lh_s1: T_M2_mpyd<0b01, 0, 1, 1>;
2261 def M2_mpyud_ll_s1: T_M2_mpyd<0b00, 0, 1, 1>;
2263 //===----------------------------------------------------------------------===//
2264 // Template Class for xtype mpy:
2267 // multiply 32X32 and use full result
2268 //===----------------------------------------------------------------------===//
2269 let hasSideEffects = 0 in
2270 class T_XTYPE_mpy64 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2271 bit isSat, bit hasShift, bit isConj>
2272 : MInst <(outs DoubleRegs:$Rdd),
2273 (ins IntRegs:$Rs, IntRegs:$Rt),
2274 "$Rdd = "#mnemonic#"($Rs, $Rt"#!if(isConj,"*)",")")
2275 #!if(hasShift,":<<1","")
2276 #!if(isSat,":sat",""),
2282 let IClass = 0b1110;
2284 let Inst{27-24} = 0b0101;
2285 let Inst{23-21} = MajOp;
2286 let Inst{20-16} = Rs;
2287 let Inst{12-8} = Rt;
2288 let Inst{7-5} = MinOp;
2289 let Inst{4-0} = Rdd;
2292 //===----------------------------------------------------------------------===//
2293 // Template Class for xtype mpy with accumulation into 64-bit:
2296 // multiply 32X32 and use full result
2297 //===----------------------------------------------------------------------===//
2298 class T_XTYPE_mpy64_acc <string op1, string op2, bits<3> MajOp, bits<3> MinOp,
2299 bit isSat, bit hasShift, bit isConj>
2300 : MInst <(outs DoubleRegs:$Rxx),
2301 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2302 "$Rxx "#op2#"= "#op1#"($Rs, $Rt"#!if(isConj,"*)",")")
2303 #!if(hasShift,":<<1","")
2304 #!if(isSat,":sat",""),
2306 [] , "$dst2 = $Rxx" > {
2311 let IClass = 0b1110;
2313 let Inst{27-24} = 0b0111;
2314 let Inst{23-21} = MajOp;
2315 let Inst{20-16} = Rs;
2316 let Inst{12-8} = Rt;
2317 let Inst{7-5} = MinOp;
2318 let Inst{4-0} = Rxx;
2321 // MPY - Multiply and use full result
2322 // Rdd = mpy[u](Rs,Rt)
2323 let isCodeGenOnly = 0 in {
2324 def M2_dpmpyss_s0 : T_XTYPE_mpy64 < "mpy", 0b000, 0b000, 0, 0, 0>;
2325 def M2_dpmpyuu_s0 : T_XTYPE_mpy64 < "mpyu", 0b010, 0b000, 0, 0, 0>;
2327 // Rxx[+-]= mpy[u](Rs,Rt)
2328 def M2_dpmpyss_acc_s0 : T_XTYPE_mpy64_acc < "mpy", "+", 0b000, 0b000, 0, 0, 0>;
2329 def M2_dpmpyss_nac_s0 : T_XTYPE_mpy64_acc < "mpy", "-", 0b001, 0b000, 0, 0, 0>;
2330 def M2_dpmpyuu_acc_s0 : T_XTYPE_mpy64_acc < "mpyu", "+", 0b010, 0b000, 0, 0, 0>;
2331 def M2_dpmpyuu_nac_s0 : T_XTYPE_mpy64_acc < "mpyu", "-", 0b011, 0b000, 0, 0, 0>;
2334 def: Pat<(i64 (mul (i64 (anyext (i32 IntRegs:$src1))),
2335 (i64 (anyext (i32 IntRegs:$src2))))),
2336 (M2_dpmpyuu_s0 IntRegs:$src1, IntRegs:$src2)>;
2338 def: Pat<(i64 (mul (i64 (sext (i32 IntRegs:$src1))),
2339 (i64 (sext (i32 IntRegs:$src2))))),
2340 (M2_dpmpyss_s0 IntRegs:$src1, IntRegs:$src2)>;
2342 def: Pat<(i64 (mul (is_sext_i32:$src1),
2343 (is_sext_i32:$src2))),
2344 (M2_dpmpyss_s0 (LoReg DoubleRegs:$src1), (LoReg DoubleRegs:$src2))>;
2346 // Multiply and accumulate, use full result.
2347 // Rxx[+-]=mpy(Rs,Rt)
2349 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
2350 (mul (i64 (sext (i32 IntRegs:$src2))),
2351 (i64 (sext (i32 IntRegs:$src3)))))),
2352 (M2_dpmpyss_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2354 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
2355 (mul (i64 (sext (i32 IntRegs:$src2))),
2356 (i64 (sext (i32 IntRegs:$src3)))))),
2357 (M2_dpmpyss_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2359 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
2360 (mul (i64 (anyext (i32 IntRegs:$src2))),
2361 (i64 (anyext (i32 IntRegs:$src3)))))),
2362 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2364 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
2365 (mul (i64 (zext (i32 IntRegs:$src2))),
2366 (i64 (zext (i32 IntRegs:$src3)))))),
2367 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2369 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
2370 (mul (i64 (anyext (i32 IntRegs:$src2))),
2371 (i64 (anyext (i32 IntRegs:$src3)))))),
2372 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2374 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
2375 (mul (i64 (zext (i32 IntRegs:$src2))),
2376 (i64 (zext (i32 IntRegs:$src3)))))),
2377 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2379 //===----------------------------------------------------------------------===//
2381 //===----------------------------------------------------------------------===//
2383 //===----------------------------------------------------------------------===//
2385 //===----------------------------------------------------------------------===//
2386 //===----------------------------------------------------------------------===//
2388 //===----------------------------------------------------------------------===//
2390 //===----------------------------------------------------------------------===//
2392 //===----------------------------------------------------------------------===//
2393 //===----------------------------------------------------------------------===//
2395 //===----------------------------------------------------------------------===//
2397 //===----------------------------------------------------------------------===//
2399 //===----------------------------------------------------------------------===//
2400 //===----------------------------------------------------------------------===//
2402 //===----------------------------------------------------------------------===//
2404 //===----------------------------------------------------------------------===//
2406 //===----------------------------------------------------------------------===//
2408 // Store doubleword.
2410 //===----------------------------------------------------------------------===//
2411 // Post increment store
2412 //===----------------------------------------------------------------------===//
2414 multiclass ST_PostInc_Pbase<string mnemonic, RegisterClass RC, Operand ImmOp,
2415 bit isNot, bit isPredNew> {
2416 let isPredicatedNew = isPredNew in
2417 def NAME : STInst2PI<(outs IntRegs:$dst),
2418 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset, RC:$src3),
2419 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
2420 ") ")#mnemonic#"($src2++#$offset) = $src3",
2425 multiclass ST_PostInc_Pred<string mnemonic, RegisterClass RC,
2426 Operand ImmOp, bit PredNot> {
2427 let isPredicatedFalse = PredNot in {
2428 defm _c#NAME : ST_PostInc_Pbase<mnemonic, RC, ImmOp, PredNot, 0>;
2430 let Predicates = [HasV4T], validSubTargets = HasV4SubT in
2431 defm _cdn#NAME#_V4 : ST_PostInc_Pbase<mnemonic, RC, ImmOp, PredNot, 1>;
2435 let hasCtrlDep = 1, isNVStorable = 1, hasSideEffects = 0 in
2436 multiclass ST_PostInc<string mnemonic, string BaseOp, RegisterClass RC,
2439 let hasCtrlDep = 1, BaseOpcode = "POST_"#BaseOp in {
2440 let isPredicable = 1 in
2441 def NAME : STInst2PI<(outs IntRegs:$dst),
2442 (ins IntRegs:$src1, ImmOp:$offset, RC:$src2),
2443 mnemonic#"($src1++#$offset) = $src2",
2447 let isPredicated = 1 in {
2448 defm Pt : ST_PostInc_Pred<mnemonic, RC, ImmOp, 0 >;
2449 defm NotPt : ST_PostInc_Pred<mnemonic, RC, ImmOp, 1 >;
2454 defm POST_STbri: ST_PostInc <"memb", "STrib", IntRegs, s4_0Imm>, AddrModeRel;
2455 defm POST_SThri: ST_PostInc <"memh", "STrih", IntRegs, s4_1Imm>, AddrModeRel;
2456 defm POST_STwri: ST_PostInc <"memw", "STriw", IntRegs, s4_2Imm>, AddrModeRel;
2458 let isNVStorable = 0 in
2459 defm POST_STdri: ST_PostInc <"memd", "STrid", DoubleRegs, s4_3Imm>, AddrModeRel;
2461 def : Pat<(post_truncsti8 (i32 IntRegs:$src1), IntRegs:$src2,
2462 s4_3ImmPred:$offset),
2463 (POST_STbri IntRegs:$src2, s4_0ImmPred:$offset, IntRegs:$src1)>;
2465 def : Pat<(post_truncsti16 (i32 IntRegs:$src1), IntRegs:$src2,
2466 s4_3ImmPred:$offset),
2467 (POST_SThri IntRegs:$src2, s4_1ImmPred:$offset, IntRegs:$src1)>;
2469 def : Pat<(post_store (i32 IntRegs:$src1), IntRegs:$src2, s4_2ImmPred:$offset),
2470 (POST_STwri IntRegs:$src2, s4_1ImmPred:$offset, IntRegs:$src1)>;
2472 def : Pat<(post_store (i64 DoubleRegs:$src1), IntRegs:$src2,
2473 s4_3ImmPred:$offset),
2474 (POST_STdri IntRegs:$src2, s4_3ImmPred:$offset, DoubleRegs:$src1)>;
2476 //===----------------------------------------------------------------------===//
2477 // multiclass for the store instructions with MEMri operand.
2478 //===----------------------------------------------------------------------===//
2479 multiclass ST_MEMri_Pbase<string mnemonic, RegisterClass RC, bit isNot,
2481 let isPredicatedNew = isPredNew in
2482 def NAME : STInst2<(outs),
2483 (ins PredRegs:$src1, MEMri:$addr, RC: $src2),
2484 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
2485 ") ")#mnemonic#"($addr) = $src2",
2489 multiclass ST_MEMri_Pred<string mnemonic, RegisterClass RC, bit PredNot> {
2490 let isPredicatedFalse = PredNot in {
2491 defm _c#NAME : ST_MEMri_Pbase<mnemonic, RC, PredNot, 0>;
2494 let validSubTargets = HasV4SubT, Predicates = [HasV4T] in
2495 defm _cdn#NAME#_V4 : ST_MEMri_Pbase<mnemonic, RC, PredNot, 1>;
2499 let isExtendable = 1, isNVStorable = 1, hasSideEffects = 0 in
2500 multiclass ST_MEMri<string mnemonic, string CextOp, RegisterClass RC,
2501 bits<5> ImmBits, bits<5> PredImmBits> {
2503 let CextOpcode = CextOp, BaseOpcode = CextOp in {
2504 let opExtendable = 1, isExtentSigned = 1, opExtentBits = ImmBits,
2506 def NAME : STInst2<(outs),
2507 (ins MEMri:$addr, RC:$src),
2508 mnemonic#"($addr) = $src",
2511 let opExtendable = 2, isExtentSigned = 0, opExtentBits = PredImmBits,
2512 isPredicated = 1 in {
2513 defm Pt : ST_MEMri_Pred<mnemonic, RC, 0>;
2514 defm NotPt : ST_MEMri_Pred<mnemonic, RC, 1>;
2519 let addrMode = BaseImmOffset, isMEMri = "true" in {
2520 let accessSize = ByteAccess in
2521 defm STrib: ST_MEMri < "memb", "STrib", IntRegs, 11, 6>, AddrModeRel;
2523 let accessSize = HalfWordAccess in
2524 defm STrih: ST_MEMri < "memh", "STrih", IntRegs, 12, 7>, AddrModeRel;
2526 let accessSize = WordAccess in
2527 defm STriw: ST_MEMri < "memw", "STriw", IntRegs, 13, 8>, AddrModeRel;
2529 let accessSize = DoubleWordAccess, isNVStorable = 0 in
2530 defm STrid: ST_MEMri < "memd", "STrid", DoubleRegs, 14, 9>, AddrModeRel;
2533 def : Pat<(truncstorei8 (i32 IntRegs:$src1), ADDRriS11_0:$addr),
2534 (STrib ADDRriS11_0:$addr, (i32 IntRegs:$src1))>;
2536 def : Pat<(truncstorei16 (i32 IntRegs:$src1), ADDRriS11_1:$addr),
2537 (STrih ADDRriS11_1:$addr, (i32 IntRegs:$src1))>;
2539 def : Pat<(store (i32 IntRegs:$src1), ADDRriS11_2:$addr),
2540 (STriw ADDRriS11_2:$addr, (i32 IntRegs:$src1))>;
2542 def : Pat<(store (i64 DoubleRegs:$src1), ADDRriS11_3:$addr),
2543 (STrid ADDRriS11_3:$addr, (i64 DoubleRegs:$src1))>;
2546 //===----------------------------------------------------------------------===//
2547 // multiclass for the store instructions with base+immediate offset
2549 //===----------------------------------------------------------------------===//
2550 multiclass ST_Idxd_Pbase<string mnemonic, RegisterClass RC, Operand predImmOp,
2551 bit isNot, bit isPredNew> {
2552 let isPredicatedNew = isPredNew in
2553 def NAME : STInst2<(outs),
2554 (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC: $src4),
2555 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
2556 ") ")#mnemonic#"($src2+#$src3) = $src4",
2560 multiclass ST_Idxd_Pred<string mnemonic, RegisterClass RC, Operand predImmOp,
2562 let isPredicatedFalse = PredNot, isPredicated = 1 in {
2563 defm _c#NAME : ST_Idxd_Pbase<mnemonic, RC, predImmOp, PredNot, 0>;
2566 let validSubTargets = HasV4SubT, Predicates = [HasV4T] in
2567 defm _cdn#NAME#_V4 : ST_Idxd_Pbase<mnemonic, RC, predImmOp, PredNot, 1>;
2571 let isExtendable = 1, isNVStorable = 1, hasSideEffects = 0 in
2572 multiclass ST_Idxd<string mnemonic, string CextOp, RegisterClass RC,
2573 Operand ImmOp, Operand predImmOp, bits<5> ImmBits,
2574 bits<5> PredImmBits> {
2576 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
2577 let opExtendable = 1, isExtentSigned = 1, opExtentBits = ImmBits,
2579 def NAME : STInst2<(outs),
2580 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
2581 mnemonic#"($src1+#$src2) = $src3",
2584 let opExtendable = 2, isExtentSigned = 0, opExtentBits = PredImmBits in {
2585 defm Pt : ST_Idxd_Pred<mnemonic, RC, predImmOp, 0>;
2586 defm NotPt : ST_Idxd_Pred<mnemonic, RC, predImmOp, 1>;
2591 let addrMode = BaseImmOffset, InputType = "reg" in {
2592 let accessSize = ByteAccess in
2593 defm STrib_indexed: ST_Idxd < "memb", "STrib", IntRegs, s11_0Ext,
2594 u6_0Ext, 11, 6>, AddrModeRel, ImmRegRel;
2596 let accessSize = HalfWordAccess in
2597 defm STrih_indexed: ST_Idxd < "memh", "STrih", IntRegs, s11_1Ext,
2598 u6_1Ext, 12, 7>, AddrModeRel, ImmRegRel;
2600 let accessSize = WordAccess in
2601 defm STriw_indexed: ST_Idxd < "memw", "STriw", IntRegs, s11_2Ext,
2602 u6_2Ext, 13, 8>, AddrModeRel, ImmRegRel;
2604 let accessSize = DoubleWordAccess, isNVStorable = 0 in
2605 defm STrid_indexed: ST_Idxd < "memd", "STrid", DoubleRegs, s11_3Ext,
2606 u6_3Ext, 14, 9>, AddrModeRel;
2609 let AddedComplexity = 10 in {
2610 def : Pat<(truncstorei8 (i32 IntRegs:$src1), (add IntRegs:$src2,
2611 s11_0ExtPred:$offset)),
2612 (STrib_indexed IntRegs:$src2, s11_0ImmPred:$offset,
2613 (i32 IntRegs:$src1))>;
2615 def : Pat<(truncstorei16 (i32 IntRegs:$src1), (add IntRegs:$src2,
2616 s11_1ExtPred:$offset)),
2617 (STrih_indexed IntRegs:$src2, s11_1ImmPred:$offset,
2618 (i32 IntRegs:$src1))>;
2620 def : Pat<(store (i32 IntRegs:$src1), (add IntRegs:$src2,
2621 s11_2ExtPred:$offset)),
2622 (STriw_indexed IntRegs:$src2, s11_2ImmPred:$offset,
2623 (i32 IntRegs:$src1))>;
2625 def : Pat<(store (i64 DoubleRegs:$src1), (add IntRegs:$src2,
2626 s11_3ExtPred:$offset)),
2627 (STrid_indexed IntRegs:$src2, s11_3ImmPred:$offset,
2628 (i64 DoubleRegs:$src1))>;
2631 // memh(Rx++#s4:1)=Rt.H
2635 let Defs = [R10,R11,D5], hasSideEffects = 0 in
2636 def STriw_pred : STInst2<(outs),
2637 (ins MEMri:$addr, PredRegs:$src1),
2638 "Error; should not emit",
2641 // Allocate stack frame.
2642 let Defs = [R29, R30], Uses = [R31, R30], hasSideEffects = 0 in {
2643 def ALLOCFRAME : STInst2<(outs),
2645 "allocframe(#$amt)",
2648 //===----------------------------------------------------------------------===//
2650 //===----------------------------------------------------------------------===//
2652 //===----------------------------------------------------------------------===//
2654 //===----------------------------------------------------------------------===//
2656 def NOT_rr64 : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1),
2657 "$dst = not($src1)",
2658 [(set (i64 DoubleRegs:$dst), (not (i64 DoubleRegs:$src1)))]>;
2661 //===----------------------------------------------------------------------===//
2663 //===----------------------------------------------------------------------===//
2665 let hasSideEffects = 0 in
2666 class T_S2op_1 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
2667 RegisterClass RCIn, bits<2> MajOp, bits<3> MinOp, bit isSat>
2668 : SInst <(outs RCOut:$dst), (ins RCIn:$src),
2669 "$dst = "#mnemonic#"($src)"#!if(isSat, ":sat", ""),
2670 [], "", S_2op_tc_1_SLOT23 > {
2674 let IClass = 0b1000;
2676 let Inst{27-24} = RegTyBits;
2677 let Inst{23-22} = MajOp;
2679 let Inst{20-16} = src;
2680 let Inst{7-5} = MinOp;
2681 let Inst{4-0} = dst;
2684 class T_S2op_1_di <string mnemonic, bits<2> MajOp, bits<3> MinOp>
2685 : T_S2op_1 <mnemonic, 0b0100, DoubleRegs, IntRegs, MajOp, MinOp, 0>;
2687 let hasNewValue = 1 in
2688 class T_S2op_1_id <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
2689 : T_S2op_1 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, isSat>;
2691 let hasNewValue = 1 in
2692 class T_S2op_1_ii <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
2693 : T_S2op_1 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp, isSat>;
2695 // Sign extend word to doubleword
2696 let isCodeGenOnly = 0 in
2697 def A2_sxtw : T_S2op_1_di <"sxtw", 0b01, 0b000>;
2699 def: Pat <(i64 (sext I32:$src)), (A2_sxtw I32:$src)>;
2701 // Swizzle the bytes of a word
2702 let isCodeGenOnly = 0 in
2703 def A2_swiz : T_S2op_1_ii <"swiz", 0b10, 0b111>;
2706 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
2707 def A2_sat : T_S2op_1_id <"sat", 0b11, 0b000>;
2708 def A2_satb : T_S2op_1_ii <"satb", 0b11, 0b111>;
2709 def A2_satub : T_S2op_1_ii <"satub", 0b11, 0b110>;
2710 def A2_sath : T_S2op_1_ii <"sath", 0b11, 0b100>;
2711 def A2_satuh : T_S2op_1_ii <"satuh", 0b11, 0b101>;
2714 let Itinerary = S_2op_tc_2_SLOT23, isCodeGenOnly = 0 in {
2715 // Absolute value word
2716 def A2_abs : T_S2op_1_ii <"abs", 0b10, 0b100>;
2718 let Defs = [USR_OVF] in
2719 def A2_abssat : T_S2op_1_ii <"abs", 0b10, 0b101, 1>;
2721 // Negate with saturation
2722 let Defs = [USR_OVF] in
2723 def A2_negsat : T_S2op_1_ii <"neg", 0b10, 0b110, 1>;
2726 def: Pat<(i32 (select (i1 (setlt (i32 IntRegs:$src), 0)),
2727 (i32 (sub 0, (i32 IntRegs:$src))),
2728 (i32 IntRegs:$src))),
2729 (A2_abs IntRegs:$src)>;
2731 let AddedComplexity = 50 in
2732 def: Pat<(i32 (xor (add (sra (i32 IntRegs:$src), (i32 31)),
2733 (i32 IntRegs:$src)),
2734 (sra (i32 IntRegs:$src), (i32 31)))),
2735 (A2_abs IntRegs:$src)>;
2737 class T_S2op_2 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
2738 RegisterClass RCIn, bits<3> MajOp, bits<3> MinOp,
2739 bit isSat, bit isRnd, list<dag> pattern = []>
2740 : SInst <(outs RCOut:$dst),
2741 (ins RCIn:$src, u5Imm:$u5),
2742 "$dst = "#mnemonic#"($src, #$u5)"#!if(isSat, ":sat", "")
2743 #!if(isRnd, ":rnd", ""),
2744 pattern, "", S_2op_tc_2_SLOT23> {
2749 let IClass = 0b1000;
2751 let Inst{27-24} = RegTyBits;
2752 let Inst{23-21} = MajOp;
2753 let Inst{20-16} = src;
2755 let Inst{12-8} = u5;
2756 let Inst{7-5} = MinOp;
2757 let Inst{4-0} = dst;
2760 let hasNewValue = 1 in
2761 class T_S2op_2_ii <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2762 bit isSat = 0, bit isRnd = 0, list<dag> pattern = []>
2763 : T_S2op_2 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp,
2764 isSat, isRnd, pattern>;
2766 class T_S2op_shift <string mnemonic, bits<3> MajOp, bits<3> MinOp, SDNode OpNd>
2767 : T_S2op_2_ii <mnemonic, MajOp, MinOp, 0, 0,
2768 [(set (i32 IntRegs:$dst), (OpNd (i32 IntRegs:$src),
2769 (u5ImmPred:$u5)))]>;
2771 // Arithmetic/logical shift right/left by immediate
2772 let Itinerary = S_2op_tc_1_SLOT23, isCodeGenOnly = 0 in {
2773 def S2_asr_i_r : T_S2op_shift <"asr", 0b000, 0b000, sra>;
2774 def S2_lsr_i_r : T_S2op_shift <"lsr", 0b000, 0b001, srl>;
2775 def S2_asl_i_r : T_S2op_shift <"asl", 0b000, 0b010, shl>;
2778 // Shift left by immediate with saturation
2779 let Defs = [USR_OVF], isCodeGenOnly = 0 in
2780 def S2_asl_i_r_sat : T_S2op_2_ii <"asl", 0b010, 0b010, 1>;
2782 // Shift right with round
2783 let isCodeGenOnly = 0 in
2784 def S2_asr_i_r_rnd : T_S2op_2_ii <"asr", 0b010, 0b000, 0, 1>;
2786 def: Pat<(i32 (sra (i32 (add (i32 (sra I32:$src1, u5ImmPred:$src2)),
2789 (S2_asr_i_r_rnd IntRegs:$src1, u5ImmPred:$src2)>;
2791 class T_S2op_3<string opc, bits<2>MajOp, bits<3>minOp, bits<1> sat = 0>
2792 : SInst<(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss),
2793 "$Rdd = "#opc#"($Rss)"#!if(!eq(sat, 1),":sat","")> {
2796 let IClass = 0b1000;
2797 let Inst{27-24} = 0;
2798 let Inst{23-22} = MajOp;
2799 let Inst{20-16} = Rss;
2800 let Inst{7-5} = minOp;
2801 let Inst{4-0} = Rdd;
2804 let isCodeGenOnly = 0 in {
2805 def A2_absp : T_S2op_3 <"abs", 0b10, 0b110>;
2806 def A2_negp : T_S2op_3 <"neg", 0b10, 0b101>;
2807 def A2_notp : T_S2op_3 <"not", 0b10, 0b100>;
2810 // Innterleave/deinterleave
2811 let isCodeGenOnly = 0 in {
2812 def S2_interleave : T_S2op_3 <"interleave", 0b11, 0b101>;
2813 def S2_deinterleave : T_S2op_3 <"deinterleave", 0b11, 0b100>;
2816 //===----------------------------------------------------------------------===//
2818 //===----------------------------------------------------------------------===//
2821 let hasSideEffects = 0, hasNewValue = 1 in
2822 class T_COUNT_LEADING<string MnOp, bits<3> MajOp, bits<3> MinOp, bit Is32,
2824 : SInst<Out, Inp, "$Rd = "#MnOp#"($Rs)", [], "", S_2op_tc_1_SLOT23> {
2827 let IClass = 0b1000;
2829 let Inst{26} = Is32;
2830 let Inst{25-24} = 0b00;
2831 let Inst{23-21} = MajOp;
2832 let Inst{20-16} = Rs;
2833 let Inst{7-5} = MinOp;
2837 class T_COUNT_LEADING_32<string MnOp, bits<3> MajOp, bits<3> MinOp>
2838 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b1,
2839 (outs IntRegs:$Rd), (ins IntRegs:$Rs)>;
2841 class T_COUNT_LEADING_64<string MnOp, bits<3> MajOp, bits<3> MinOp>
2842 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b0,
2843 (outs IntRegs:$Rd), (ins DoubleRegs:$Rs)>;
2845 let isCodeGenOnly = 0 in {
2846 def S2_cl0 : T_COUNT_LEADING_32<"cl0", 0b000, 0b101>;
2847 def S2_cl1 : T_COUNT_LEADING_32<"cl1", 0b000, 0b110>;
2848 def S2_ct0 : T_COUNT_LEADING_32<"ct0", 0b010, 0b100>;
2849 def S2_ct1 : T_COUNT_LEADING_32<"ct1", 0b010, 0b101>;
2850 def S2_cl0p : T_COUNT_LEADING_64<"cl0", 0b010, 0b010>;
2851 def S2_cl1p : T_COUNT_LEADING_64<"cl1", 0b010, 0b100>;
2852 def S2_clb : T_COUNT_LEADING_32<"clb", 0b000, 0b100>;
2853 def S2_clbp : T_COUNT_LEADING_64<"clb", 0b010, 0b000>;
2854 def S2_clbnorm : T_COUNT_LEADING_32<"normamt", 0b000, 0b111>;
2857 def: Pat<(i32 (ctlz I32:$Rs)), (S2_cl0 I32:$Rs)>;
2858 def: Pat<(i32 (ctlz (not I32:$Rs))), (S2_cl1 I32:$Rs)>;
2859 def: Pat<(i32 (cttz I32:$Rs)), (S2_ct0 I32:$Rs)>;
2860 def: Pat<(i32 (cttz (not I32:$Rs))), (S2_ct1 I32:$Rs)>;
2861 def: Pat<(i32 (trunc (ctlz I64:$Rss))), (S2_cl0p I64:$Rss)>;
2862 def: Pat<(i32 (trunc (ctlz (not I64:$Rss)))), (S2_cl1p I64:$Rss)>;
2864 // Bit set/clear/toggle
2866 let hasSideEffects = 0, hasNewValue = 1 in
2867 class T_SCT_BIT_IMM<string MnOp, bits<3> MinOp>
2868 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, u5Imm:$u5),
2869 "$Rd = "#MnOp#"($Rs, #$u5)", [], "", S_2op_tc_1_SLOT23> {
2873 let IClass = 0b1000;
2874 let Inst{27-21} = 0b1100110;
2875 let Inst{20-16} = Rs;
2877 let Inst{12-8} = u5;
2878 let Inst{7-5} = MinOp;
2882 let hasSideEffects = 0, hasNewValue = 1 in
2883 class T_SCT_BIT_REG<string MnOp, bits<2> MinOp>
2884 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
2885 "$Rd = "#MnOp#"($Rs, $Rt)", [], "", S_3op_tc_1_SLOT23> {
2889 let IClass = 0b1100;
2890 let Inst{27-22} = 0b011010;
2891 let Inst{20-16} = Rs;
2892 let Inst{12-8} = Rt;
2893 let Inst{7-6} = MinOp;
2897 let isCodeGenOnly = 0 in {
2898 def S2_clrbit_i : T_SCT_BIT_IMM<"clrbit", 0b001>;
2899 def S2_setbit_i : T_SCT_BIT_IMM<"setbit", 0b000>;
2900 def S2_togglebit_i : T_SCT_BIT_IMM<"togglebit", 0b010>;
2901 def S2_clrbit_r : T_SCT_BIT_REG<"clrbit", 0b01>;
2902 def S2_setbit_r : T_SCT_BIT_REG<"setbit", 0b00>;
2903 def S2_togglebit_r : T_SCT_BIT_REG<"togglebit", 0b10>;
2906 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, u5ImmPred:$u5)))),
2907 (S2_clrbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
2908 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
2909 (S2_setbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
2910 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
2911 (S2_togglebit_i IntRegs:$Rs, u5ImmPred:$u5)>;
2912 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, (i32 IntRegs:$Rt))))),
2913 (S2_clrbit_r IntRegs:$Rs, IntRegs:$Rt)>;
2914 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
2915 (S2_setbit_r IntRegs:$Rs, IntRegs:$Rt)>;
2916 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
2917 (S2_togglebit_r IntRegs:$Rs, IntRegs:$Rt)>;
2921 let hasSideEffects = 0 in
2922 class T_TEST_BIT_IMM<string MnOp, bits<3> MajOp>
2923 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u5Imm:$u5),
2924 "$Pd = "#MnOp#"($Rs, #$u5)",
2925 [], "", S_2op_tc_2early_SLOT23> {
2929 let IClass = 0b1000;
2930 let Inst{27-24} = 0b0101;
2931 let Inst{23-21} = MajOp;
2932 let Inst{20-16} = Rs;
2934 let Inst{12-8} = u5;
2938 let hasSideEffects = 0 in
2939 class T_TEST_BIT_REG<string MnOp, bit IsNeg>
2940 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
2941 "$Pd = "#MnOp#"($Rs, $Rt)",
2942 [], "", S_3op_tc_2early_SLOT23> {
2946 let IClass = 0b1100;
2947 let Inst{27-22} = 0b011100;
2948 let Inst{21} = IsNeg;
2949 let Inst{20-16} = Rs;
2950 let Inst{12-8} = Rt;
2954 let isCodeGenOnly = 0 in {
2955 def S2_tstbit_i : T_TEST_BIT_IMM<"tstbit", 0b000>;
2956 def S2_tstbit_r : T_TEST_BIT_REG<"tstbit", 0>;
2959 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
2960 def: Pat<(i1 (setne (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
2961 (S2_tstbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
2962 def: Pat<(i1 (setne (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
2963 (S2_tstbit_r IntRegs:$Rs, IntRegs:$Rt)>;
2964 def: Pat<(i1 (trunc (i32 IntRegs:$Rs))),
2965 (S2_tstbit_i IntRegs:$Rs, 0)>;
2966 def: Pat<(i1 (trunc (i64 DoubleRegs:$Rs))),
2967 (S2_tstbit_i (LoReg DoubleRegs:$Rs), 0)>;
2969 let hasSideEffects = 0 in
2970 class T_TEST_BITS_IMM<string MnOp, bits<2> MajOp, bit IsNeg>
2971 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u6Imm:$u6),
2972 "$Pd = "#MnOp#"($Rs, #$u6)",
2973 [], "", S_2op_tc_2early_SLOT23> {
2977 let IClass = 0b1000;
2978 let Inst{27-24} = 0b0101;
2979 let Inst{23-22} = MajOp;
2980 let Inst{21} = IsNeg;
2981 let Inst{20-16} = Rs;
2982 let Inst{13-8} = u6;
2986 let hasSideEffects = 0 in
2987 class T_TEST_BITS_REG<string MnOp, bits<2> MajOp, bit IsNeg>
2988 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
2989 "$Pd = "#MnOp#"($Rs, $Rt)",
2990 [], "", S_3op_tc_2early_SLOT23> {
2994 let IClass = 0b1100;
2995 let Inst{27-24} = 0b0111;
2996 let Inst{23-22} = MajOp;
2997 let Inst{21} = IsNeg;
2998 let Inst{20-16} = Rs;
2999 let Inst{12-8} = Rt;
3003 let isCodeGenOnly = 0 in {
3004 def C2_bitsclri : T_TEST_BITS_IMM<"bitsclr", 0b10, 0>;
3005 def C2_bitsclr : T_TEST_BITS_REG<"bitsclr", 0b10, 0>;
3006 def C2_bitsset : T_TEST_BITS_REG<"bitsset", 0b01, 0>;
3009 let AddedComplexity = 20 in { // Complexity greater than compare reg-imm.
3010 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), u6ImmPred:$u6), 0)),
3011 (C2_bitsclri IntRegs:$Rs, u6ImmPred:$u6)>;
3012 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), 0)),
3013 (C2_bitsclr IntRegs:$Rs, IntRegs:$Rt)>;
3016 let AddedComplexity = 10 in // Complexity greater than compare reg-reg.
3017 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), IntRegs:$Rt)),
3018 (C2_bitsset IntRegs:$Rs, IntRegs:$Rt)>;
3020 //===----------------------------------------------------------------------===//
3022 //===----------------------------------------------------------------------===//
3024 //===----------------------------------------------------------------------===//
3026 //===----------------------------------------------------------------------===//
3027 //===----------------------------------------------------------------------===//
3029 //===----------------------------------------------------------------------===//
3031 //===----------------------------------------------------------------------===//
3033 //===----------------------------------------------------------------------===//
3035 //===----------------------------------------------------------------------===//
3037 //===----------------------------------------------------------------------===//
3039 //===----------------------------------------------------------------------===//
3041 //===----------------------------------------------------------------------===//
3043 // Predicate transfer.
3044 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
3045 def C2_tfrpr : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps),
3046 "$Rd = $Ps", [], "", S_2op_tc_1_SLOT23> {
3050 let IClass = 0b1000;
3051 let Inst{27-24} = 0b1001;
3053 let Inst{17-16} = Ps;
3057 // Transfer general register to predicate.
3058 let hasSideEffects = 0, isCodeGenOnly = 0 in
3059 def C2_tfrrp: SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs),
3060 "$Pd = $Rs", [], "", S_2op_tc_2early_SLOT23> {
3064 let IClass = 0b1000;
3065 let Inst{27-21} = 0b0101010;
3066 let Inst{20-16} = Rs;
3071 //===----------------------------------------------------------------------===//
3073 //===----------------------------------------------------------------------===//
3075 //===----------------------------------------------------------------------===//
3077 //===----------------------------------------------------------------------===//
3078 class S_2OpInstImm<string Mnemonic, bits<3>MajOp, bits<3>MinOp,
3079 Operand Imm, list<dag> pattern = [], bit isRnd = 0>
3080 : SInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, Imm:$src2),
3081 "$dst = "#Mnemonic#"($src1, #$src2)"#!if(isRnd, ":rnd", ""),
3085 let IClass = 0b1000;
3086 let Inst{27-24} = 0;
3087 let Inst{23-21} = MajOp;
3088 let Inst{20-16} = src1;
3089 let Inst{7-5} = MinOp;
3090 let Inst{4-0} = dst;
3093 class S_2OpInstImmI6<string Mnemonic, SDNode OpNode, bits<3>MinOp>
3094 : S_2OpInstImm<Mnemonic, 0b000, MinOp, u6Imm,
3095 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
3096 u6ImmPred:$src2))]> {
3098 let Inst{13-8} = src2;
3101 // Shift by immediate.
3102 let isCodeGenOnly = 0 in {
3103 def S2_asr_i_p : S_2OpInstImmI6<"asr", sra, 0b000>;
3104 def S2_asl_i_p : S_2OpInstImmI6<"asl", shl, 0b010>;
3105 def S2_lsr_i_p : S_2OpInstImmI6<"lsr", srl, 0b001>;
3108 // Shift left by small amount and add.
3109 let AddedComplexity = 100, hasNewValue = 1, hasSideEffects = 0,
3110 isCodeGenOnly = 0 in
3111 def S2_addasl_rrri: SInst <(outs IntRegs:$Rd),
3112 (ins IntRegs:$Rt, IntRegs:$Rs, u3Imm:$u3),
3113 "$Rd = addasl($Rt, $Rs, #$u3)" ,
3114 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rt),
3115 (shl (i32 IntRegs:$Rs), u3ImmPred:$u3)))],
3116 "", S_3op_tc_2_SLOT23> {
3122 let IClass = 0b1100;
3124 let Inst{27-21} = 0b0100000;
3125 let Inst{20-16} = Rs;
3127 let Inst{12-8} = Rt;
3132 //===----------------------------------------------------------------------===//
3134 //===----------------------------------------------------------------------===//
3136 //===----------------------------------------------------------------------===//
3138 //===----------------------------------------------------------------------===//
3139 //===----------------------------------------------------------------------===//
3141 //===----------------------------------------------------------------------===//
3143 //===----------------------------------------------------------------------===//
3145 //===----------------------------------------------------------------------===//
3146 //===----------------------------------------------------------------------===//
3148 //===----------------------------------------------------------------------===//
3150 //===----------------------------------------------------------------------===//
3152 //===----------------------------------------------------------------------===//
3154 //===----------------------------------------------------------------------===//
3156 //===----------------------------------------------------------------------===//
3157 def HexagonBARRIER: SDNode<"HexagonISD::BARRIER", SDTNone, [SDNPHasChain]>;
3159 let hasSideEffects = 1, isSoloAX = 1, isCodeGenOnly = 0 in
3160 def BARRIER : SYSInst<(outs), (ins),
3162 [(HexagonBARRIER)],"",ST_tc_st_SLOT0> {
3163 let Inst{31-28} = 0b1010;
3164 let Inst{27-21} = 0b1000000;
3167 //===----------------------------------------------------------------------===//
3169 //===----------------------------------------------------------------------===//
3170 //===----------------------------------------------------------------------===//
3172 //===----------------------------------------------------------------------===//
3174 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
3175 opExtendable = 0, hasSideEffects = 0 in
3176 class LOOP_iBase<string mnemonic, Operand brOp, bit mustExtend = 0>
3177 : CRInst<(outs), (ins brOp:$offset, u10Imm:$src2),
3178 #mnemonic#"($offset, #$src2)",
3179 [], "" , CR_tc_3x_SLOT3> {
3183 let IClass = 0b0110;
3185 let Inst{27-22} = 0b100100;
3186 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
3187 let Inst{20-16} = src2{9-5};
3188 let Inst{12-8} = offset{8-4};
3189 let Inst{7-5} = src2{4-2};
3190 let Inst{4-3} = offset{3-2};
3191 let Inst{1-0} = src2{1-0};
3194 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
3195 opExtendable = 0, hasSideEffects = 0 in
3196 class LOOP_rBase<string mnemonic, Operand brOp, bit mustExtend = 0>
3197 : CRInst<(outs), (ins brOp:$offset, IntRegs:$src2),
3198 #mnemonic#"($offset, $src2)",
3199 [], "" ,CR_tc_3x_SLOT3> {
3203 let IClass = 0b0110;
3205 let Inst{27-22} = 0b000000;
3206 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
3207 let Inst{20-16} = src2;
3208 let Inst{12-8} = offset{8-4};
3209 let Inst{4-3} = offset{3-2};
3212 multiclass LOOP_ri<string mnemonic> {
3213 def i : LOOP_iBase<mnemonic, brtarget>;
3214 def r : LOOP_rBase<mnemonic, brtarget>;
3218 let Defs = [SA0, LC0, USR], isCodeGenOnly = 0 in
3219 defm J2_loop0 : LOOP_ri<"loop0">;
3221 // Interestingly only loop0's appear to set usr.lpcfg
3222 let Defs = [SA1, LC1], isCodeGenOnly = 0 in
3223 defm J2_loop1 : LOOP_ri<"loop1">;
3225 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
3226 Defs = [PC, LC0], Uses = [SA0, LC0] in {
3227 def ENDLOOP0 : Endloop<(outs), (ins brtarget:$offset),
3232 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
3233 Defs = [PC, LC1], Uses = [SA1, LC1] in {
3234 def ENDLOOP1 : Endloop<(outs), (ins brtarget:$offset),
3239 // Pipelined loop instructions, sp[123]loop0
3240 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
3241 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
3242 opExtendable = 0, isPredicateLate = 1 in
3243 class SPLOOP_iBase<string SP, bits<2> op>
3244 : CRInst <(outs), (ins brtarget:$r7_2, u10Imm:$U10),
3245 "p3 = sp"#SP#"loop0($r7_2, #$U10)" > {
3249 let IClass = 0b0110;
3251 let Inst{22-21} = op;
3252 let Inst{27-23} = 0b10011;
3253 let Inst{20-16} = U10{9-5};
3254 let Inst{12-8} = r7_2{8-4};
3255 let Inst{7-5} = U10{4-2};
3256 let Inst{4-3} = r7_2{3-2};
3257 let Inst{1-0} = U10{1-0};
3260 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
3261 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
3262 opExtendable = 0, isPredicateLate = 1 in
3263 class SPLOOP_rBase<string SP, bits<2> op>
3264 : CRInst <(outs), (ins brtarget:$r7_2, IntRegs:$Rs),
3265 "p3 = sp"#SP#"loop0($r7_2, $Rs)" > {
3269 let IClass = 0b0110;
3271 let Inst{22-21} = op;
3272 let Inst{27-23} = 0b00001;
3273 let Inst{20-16} = Rs;
3274 let Inst{12-8} = r7_2{8-4};
3275 let Inst{4-3} = r7_2{3-2};
3278 multiclass SPLOOP_ri<string mnemonic, bits<2> op> {
3279 def i : SPLOOP_iBase<mnemonic, op>;
3280 def r : SPLOOP_rBase<mnemonic, op>;
3283 let isCodeGenOnly = 0 in {
3284 defm J2_ploop1s : SPLOOP_ri<"1", 0b01>;
3285 defm J2_ploop2s : SPLOOP_ri<"2", 0b10>;
3286 defm J2_ploop3s : SPLOOP_ri<"3", 0b11>;
3289 // Transfer to/from Control/GPR Guest/GPR
3290 let hasSideEffects = 0 in
3291 class TFR_CR_RS_base<RegisterClass CTRC, RegisterClass RC, bit isDouble>
3292 : CRInst <(outs CTRC:$dst), (ins RC:$src),
3293 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
3297 let IClass = 0b0110;
3299 let Inst{27-25} = 0b001;
3300 let Inst{24} = isDouble;
3301 let Inst{23-21} = 0b001;
3302 let Inst{20-16} = src;
3303 let Inst{4-0} = dst;
3305 let isCodeGenOnly = 0 in
3306 def A2_tfrrcr : TFR_CR_RS_base<CtrRegs, IntRegs, 0b0>;
3307 def : InstAlias<"m0 = $Rs", (A2_tfrrcr C6, IntRegs:$Rs)>;
3308 def : InstAlias<"m1 = $Rs", (A2_tfrrcr C7, IntRegs:$Rs)>;
3310 let hasSideEffects = 0 in
3311 class TFR_RD_CR_base<RegisterClass RC, RegisterClass CTRC, bit isSingle>
3312 : CRInst <(outs RC:$dst), (ins CTRC:$src),
3313 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
3317 let IClass = 0b0110;
3319 let Inst{27-26} = 0b10;
3320 let Inst{25} = isSingle;
3321 let Inst{24-21} = 0b0000;
3322 let Inst{20-16} = src;
3323 let Inst{4-0} = dst;
3326 let hasNewValue = 1, opNewValue = 0, isCodeGenOnly = 0 in
3327 def A2_tfrcrr : TFR_RD_CR_base<IntRegs, CtrRegs, 1>;
3328 def : InstAlias<"$Rd = m0", (A2_tfrcrr IntRegs:$Rd, C6)>;
3329 def : InstAlias<"$Rd = m1", (A2_tfrcrr IntRegs:$Rd, C7)>;
3331 // Y4_trace: Send value to etm trace.
3332 let isSoloAX = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
3333 def Y4_trace: CRInst <(outs), (ins IntRegs:$Rs),
3337 let IClass = 0b0110;
3338 let Inst{27-21} = 0b0010010;
3339 let Inst{20-16} = Rs;
3342 let AddedComplexity = 100, isPredicated = 1 in
3343 def TFR_condset_ri : ALU32_rr<(outs IntRegs:$dst),
3344 (ins PredRegs:$src1, IntRegs:$src2, s12Imm:$src3),
3345 "Error; should not emit",
3346 [(set (i32 IntRegs:$dst),
3347 (i32 (select (i1 PredRegs:$src1), (i32 IntRegs:$src2),
3348 s12ImmPred:$src3)))]>;
3350 let AddedComplexity = 100, isPredicated = 1 in
3351 def TFR_condset_ir : ALU32_rr<(outs IntRegs:$dst),
3352 (ins PredRegs:$src1, s12Imm:$src2, IntRegs:$src3),
3353 "Error; should not emit",
3354 [(set (i32 IntRegs:$dst),
3355 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
3356 (i32 IntRegs:$src3))))]>;
3358 let AddedComplexity = 100, isPredicated = 1 in
3359 def TFR_condset_ii : ALU32_rr<(outs IntRegs:$dst),
3360 (ins PredRegs:$src1, s12Imm:$src2, s12Imm:$src3),
3361 "Error; should not emit",
3362 [(set (i32 IntRegs:$dst),
3363 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
3364 s12ImmPred:$src3)))]>;
3366 // Generate frameindex addresses.
3367 let isReMaterializable = 1 in
3368 def TFR_FI : ALU32_ri<(outs IntRegs:$dst), (ins FrameIndex:$src1),
3369 "$dst = add($src1)",
3370 [(set (i32 IntRegs:$dst), ADDRri:$src1)]>;
3372 // Support for generating global address.
3373 // Taken from X86InstrInfo.td.
3374 def SDTHexagonCONST32 : SDTypeProfile<1, 1, [
3378 def HexagonCONST32 : SDNode<"HexagonISD::CONST32", SDTHexagonCONST32>;
3379 def HexagonCONST32_GP : SDNode<"HexagonISD::CONST32_GP", SDTHexagonCONST32>;
3381 // HI/LO Instructions
3382 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3383 def LO : ALU32_ri<(outs IntRegs:$dst), (ins globaladdress:$global),
3384 "$dst.l = #LO($global)",
3387 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3388 def HI : ALU32_ri<(outs IntRegs:$dst), (ins globaladdress:$global),
3389 "$dst.h = #HI($global)",
3392 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3393 def LOi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
3394 "$dst.l = #LO($imm_value)",
3398 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3399 def HIi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
3400 "$dst.h = #HI($imm_value)",
3403 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3404 def LO_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
3405 "$dst.l = #LO($jt)",
3408 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3409 def HI_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
3410 "$dst.h = #HI($jt)",
3414 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
3415 def LO_label : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
3416 "$dst.l = #LO($label)",
3419 let isReMaterializable = 1, isMoveImm = 1 , hasSideEffects = 0 in
3420 def HI_label : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
3421 "$dst.h = #HI($label)",
3424 // This pattern is incorrect. When we add small data, we should change
3425 // this pattern to use memw(#foo).
3426 // This is for sdata.
3427 let isMoveImm = 1 in
3428 def CONST32 : LDInst<(outs IntRegs:$dst), (ins globaladdress:$global),
3429 "$dst = CONST32(#$global)",
3430 [(set (i32 IntRegs:$dst),
3431 (load (HexagonCONST32 tglobaltlsaddr:$global)))]>;
3433 // This is for non-sdata.
3434 let isReMaterializable = 1, isMoveImm = 1 in
3435 def CONST32_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
3436 "$dst = CONST32(#$global)",
3437 [(set (i32 IntRegs:$dst),
3438 (HexagonCONST32 tglobaladdr:$global))]>;
3440 let isReMaterializable = 1, isMoveImm = 1 in
3441 def CONST32_set_jt : LDInst2<(outs IntRegs:$dst), (ins jumptablebase:$jt),
3442 "$dst = CONST32(#$jt)",
3443 [(set (i32 IntRegs:$dst),
3444 (HexagonCONST32 tjumptable:$jt))]>;
3446 let isReMaterializable = 1, isMoveImm = 1 in
3447 def CONST32GP_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
3448 "$dst = CONST32(#$global)",
3449 [(set (i32 IntRegs:$dst),
3450 (HexagonCONST32_GP tglobaladdr:$global))]>;
3452 let isReMaterializable = 1, isMoveImm = 1 in
3453 def CONST32_Int_Real : LDInst2<(outs IntRegs:$dst), (ins i32imm:$global),
3454 "$dst = CONST32(#$global)",
3455 [(set (i32 IntRegs:$dst), imm:$global) ]>;
3457 // Map BlockAddress lowering to CONST32_Int_Real
3458 def : Pat<(HexagonCONST32_GP tblockaddress:$addr),
3459 (CONST32_Int_Real tblockaddress:$addr)>;
3461 let isReMaterializable = 1, isMoveImm = 1 in
3462 def CONST32_Label : LDInst2<(outs IntRegs:$dst), (ins bblabel:$label),
3463 "$dst = CONST32($label)",
3464 [(set (i32 IntRegs:$dst), (HexagonCONST32 bbl:$label))]>;
3466 let isReMaterializable = 1, isMoveImm = 1 in
3467 def CONST64_Int_Real : LDInst2<(outs DoubleRegs:$dst), (ins i64imm:$global),
3468 "$dst = CONST64(#$global)",
3469 [(set (i64 DoubleRegs:$dst), imm:$global) ]>;
3471 def TFR_PdFalse : SInst<(outs PredRegs:$dst), (ins),
3472 "$dst = xor($dst, $dst)",
3473 [(set (i1 PredRegs:$dst), 0)]>;
3475 def MPY_trsext : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2),
3476 "$dst = mpy($src1, $src2)",
3477 [(set (i32 IntRegs:$dst),
3478 (trunc (i64 (srl (i64 (mul (i64 (sext (i32 IntRegs:$src1))),
3479 (i64 (sext (i32 IntRegs:$src2))))),
3482 // Pseudo instructions.
3483 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
3485 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
3486 SDTCisVT<1, i32> ]>;
3488 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
3489 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
3491 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
3492 [SDNPHasChain, SDNPOutGlue]>;
3494 def SDT_SPCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
3496 def call : SDNode<"HexagonISD::CALL", SDT_SPCall,
3497 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, SDNPVariadic]>;
3499 // For tailcalls a HexagonTCRet SDNode has 3 SDNode Properties - a chain,
3500 // Optional Flag and Variable Arguments.
3501 // Its 1 Operand has pointer type.
3502 def HexagonTCRet : SDNode<"HexagonISD::TC_RETURN", SDT_SPCall,
3503 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
3505 let Defs = [R29, R30], Uses = [R31, R30, R29] in {
3506 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
3507 "Should never be emitted",
3508 [(callseq_start timm:$amt)]>;
3511 let Defs = [R29, R30, R31], Uses = [R29] in {
3512 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
3513 "Should never be emitted",
3514 [(callseq_end timm:$amt1, timm:$amt2)]>;
3517 let isCall = 1, hasSideEffects = 0,
3518 Defs = [D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10,
3519 R22, R23, R28, R31, P0, P1, P2, P3, LC0, LC1, SA0, SA1] in {
3520 def CALL : JInst<(outs), (ins calltarget:$dst),
3524 // Call subroutine indirectly.
3525 let Defs = VolatileV3.Regs, isCodeGenOnly = 0 in
3526 def J2_callr : JUMPR_MISC_CALLR<0, 1>;
3528 // Indirect tail-call.
3529 let isCodeGenOnly = 1, isCall = 1, isReturn = 1 in
3530 def TCRETURNR : T_JMPr;
3532 // Direct tail-calls.
3533 let isCall = 1, isReturn = 1, isBarrier = 1, isPredicable = 0,
3534 isTerminator = 1, isCodeGenOnly = 1 in {
3535 def TCRETURNtg : JInst<(outs), (ins calltarget:$dst), "jump $dst",
3536 [], "", J_tc_2early_SLOT23>;
3537 def TCRETURNtext : JInst<(outs), (ins calltarget:$dst), "jump $dst",
3538 [], "", J_tc_2early_SLOT23>;
3541 // Map call instruction.
3542 def : Pat<(call (i32 IntRegs:$dst)),
3543 (J2_callr (i32 IntRegs:$dst))>, Requires<[HasV2TOnly]>;
3544 def : Pat<(call tglobaladdr:$dst),
3545 (CALL tglobaladdr:$dst)>, Requires<[HasV2TOnly]>;
3546 def : Pat<(call texternalsym:$dst),
3547 (CALL texternalsym:$dst)>, Requires<[HasV2TOnly]>;
3549 def : Pat<(HexagonTCRet tglobaladdr:$dst),
3550 (TCRETURNtg tglobaladdr:$dst)>;
3551 def : Pat<(HexagonTCRet texternalsym:$dst),
3552 (TCRETURNtext texternalsym:$dst)>;
3553 def : Pat<(HexagonTCRet (i32 IntRegs:$dst)),
3554 (TCRETURNR (i32 IntRegs:$dst))>;
3556 // Atomic load and store support
3557 // 8 bit atomic load
3558 def : Pat<(atomic_load_8 ADDRriS11_0:$src1),
3559 (i32 (L2_loadrub_io AddrFI:$src1, 0))>;
3561 def : Pat<(atomic_load_8 (add (i32 IntRegs:$src1), s11_0ImmPred:$offset)),
3562 (i32 (L2_loadrub_io (i32 IntRegs:$src1), s11_0ImmPred:$offset))>;
3564 // 16 bit atomic load
3565 def : Pat<(atomic_load_16 ADDRriS11_1:$src1),
3566 (i32 (L2_loadruh_io AddrFI:$src1, 0))>;
3568 def : Pat<(atomic_load_16 (add (i32 IntRegs:$src1), s11_1ImmPred:$offset)),
3569 (i32 (L2_loadruh_io (i32 IntRegs:$src1), s11_1ImmPred:$offset))>;
3571 def : Pat<(atomic_load_32 ADDRriS11_2:$src1),
3572 (i32 (L2_loadri_io AddrFI:$src1, 0))>;
3574 def : Pat<(atomic_load_32 (add (i32 IntRegs:$src1), s11_2ImmPred:$offset)),
3575 (i32 (L2_loadri_io (i32 IntRegs:$src1), s11_2ImmPred:$offset))>;
3577 // 64 bit atomic load
3578 def : Pat<(atomic_load_64 ADDRriS11_3:$src1),
3579 (i64 (L2_loadrd_io AddrFI:$src1, 0))>;
3581 def : Pat<(atomic_load_64 (add (i32 IntRegs:$src1), s11_3ImmPred:$offset)),
3582 (i64 (L2_loadrd_io (i32 IntRegs:$src1), s11_3ImmPred:$offset))>;
3585 def : Pat<(atomic_store_8 ADDRriS11_0:$src2, (i32 IntRegs:$src1)),
3586 (STrib ADDRriS11_0:$src2, (i32 IntRegs:$src1))>;
3588 def : Pat<(atomic_store_8 (add (i32 IntRegs:$src2), s11_0ImmPred:$offset),
3589 (i32 IntRegs:$src1)),
3590 (STrib_indexed (i32 IntRegs:$src2), s11_0ImmPred:$offset,
3591 (i32 IntRegs:$src1))>;
3594 def : Pat<(atomic_store_16 ADDRriS11_1:$src2, (i32 IntRegs:$src1)),
3595 (STrih ADDRriS11_1:$src2, (i32 IntRegs:$src1))>;
3597 def : Pat<(atomic_store_16 (i32 IntRegs:$src1),
3598 (add (i32 IntRegs:$src2), s11_1ImmPred:$offset)),
3599 (STrih_indexed (i32 IntRegs:$src2), s11_1ImmPred:$offset,
3600 (i32 IntRegs:$src1))>;
3602 def : Pat<(atomic_store_32 ADDRriS11_2:$src2, (i32 IntRegs:$src1)),
3603 (STriw ADDRriS11_2:$src2, (i32 IntRegs:$src1))>;
3605 def : Pat<(atomic_store_32 (add (i32 IntRegs:$src2), s11_2ImmPred:$offset),
3606 (i32 IntRegs:$src1)),
3607 (STriw_indexed (i32 IntRegs:$src2), s11_2ImmPred:$offset,
3608 (i32 IntRegs:$src1))>;
3613 def : Pat<(atomic_store_64 ADDRriS11_3:$src2, (i64 DoubleRegs:$src1)),
3614 (STrid ADDRriS11_3:$src2, (i64 DoubleRegs:$src1))>;
3616 def : Pat<(atomic_store_64 (add (i32 IntRegs:$src2), s11_3ImmPred:$offset),
3617 (i64 DoubleRegs:$src1)),
3618 (STrid_indexed (i32 IntRegs:$src2), s11_3ImmPred:$offset,
3619 (i64 DoubleRegs:$src1))>;
3621 // Map from r0 = and(r1, 65535) to r0 = zxth(r1)
3622 def : Pat <(and (i32 IntRegs:$src1), 65535),
3623 (A2_zxth (i32 IntRegs:$src1))>;
3625 // Map from r0 = and(r1, 255) to r0 = zxtb(r1).
3626 def : Pat <(and (i32 IntRegs:$src1), 255),
3627 (A2_zxtb (i32 IntRegs:$src1))>;
3629 // Map Add(p1, true) to p1 = not(p1).
3630 // Add(p1, false) should never be produced,
3631 // if it does, it got to be mapped to NOOP.
3632 def : Pat <(add (i1 PredRegs:$src1), -1),
3633 (C2_not (i1 PredRegs:$src1))>;
3635 // Map from p0 = pnot(p0); r0 = mux(p0, #i, #j) => r0 = mux(p0, #j, #i).
3636 def : Pat <(select (not (i1 PredRegs:$src1)), s8ImmPred:$src2, s8ImmPred:$src3),
3637 (i32 (TFR_condset_ii (i1 PredRegs:$src1), s8ImmPred:$src3,
3640 // Map from p0 = pnot(p0); r0 = select(p0, #i, r1)
3641 // => r0 = TFR_condset_ri(p0, r1, #i)
3642 def : Pat <(select (not (i1 PredRegs:$src1)), s12ImmPred:$src2,
3643 (i32 IntRegs:$src3)),
3644 (i32 (TFR_condset_ri (i1 PredRegs:$src1), (i32 IntRegs:$src3),
3645 s12ImmPred:$src2))>;
3647 // Map from p0 = pnot(p0); r0 = mux(p0, r1, #i)
3648 // => r0 = TFR_condset_ir(p0, #i, r1)
3649 def : Pat <(select (not (i1 PredRegs:$src1)), IntRegs:$src2, s12ImmPred:$src3),
3650 (i32 (TFR_condset_ir (i1 PredRegs:$src1), s12ImmPred:$src3,
3651 (i32 IntRegs:$src2)))>;
3653 // Map from p0 = pnot(p0); if (p0) jump => if (!p0) jump.
3654 def : Pat <(brcond (not (i1 PredRegs:$src1)), bb:$offset),
3655 (J2_jumpf (i1 PredRegs:$src1), bb:$offset)>;
3657 // Map from p2 = pnot(p2); p1 = and(p0, p2) => p1 = and(p0, !p2).
3658 def : Pat <(and (i1 PredRegs:$src1), (not (i1 PredRegs:$src2))),
3659 (i1 (C2_andn (i1 PredRegs:$src1), (i1 PredRegs:$src2)))>;
3662 let AddedComplexity = 100 in
3663 def : Pat <(i64 (zextloadi1 (HexagonCONST32 tglobaladdr:$global))),
3664 (i64 (A2_combinew (A2_tfrsi 0),
3665 (L2_loadrub_io (CONST32_set tglobaladdr:$global), 0)))>,
3668 // Map from i1 loads to 32 bits. This assumes that the i1* is byte aligned.
3669 let AddedComplexity = 10 in
3670 def : Pat <(i32 (zextloadi1 ADDRriS11_0:$addr)),
3671 (i32 (A2_and (i32 (L2_loadrb_io AddrFI:$addr, 0)), (A2_tfrsi 0x1)))>;
3673 // Map from Rdd = sign_extend_inreg(Rss, i32) -> Rdd = A2_sxtw(Rss.lo).
3674 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i32)),
3675 (i64 (A2_sxtw (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg))))>;
3677 // Map from Rdd = sign_extend_inreg(Rss, i16) -> Rdd = A2_sxtw(SXTH(Rss.lo)).
3678 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i16)),
3679 (i64 (A2_sxtw (i32 (A2_sxth (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
3680 subreg_loreg))))))>;
3682 // Map from Rdd = sign_extend_inreg(Rss, i8) -> Rdd = A2_sxtw(SXTB(Rss.lo)).
3683 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i8)),
3684 (i64 (A2_sxtw (i32 (A2_sxtb (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
3685 subreg_loreg))))))>;
3687 // We want to prevent emitting pnot's as much as possible.
3688 // Map brcond with an unsupported setcc to a J2_jumpf.
3689 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3691 (J2_jumpf (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
3694 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), s10ImmPred:$src2)),
3696 (J2_jumpf (C2_cmpeqi (i32 IntRegs:$src1), s10ImmPred:$src2), bb:$offset)>;
3698 def : Pat <(brcond (i1 (setne (i1 PredRegs:$src1), (i1 -1))), bb:$offset),
3699 (J2_jumpf (i1 PredRegs:$src1), bb:$offset)>;
3701 def : Pat <(brcond (i1 (setne (i1 PredRegs:$src1), (i1 0))), bb:$offset),
3702 (J2_jumpt (i1 PredRegs:$src1), bb:$offset)>;
3704 // cmp.lt(Rs, Imm) -> !cmp.ge(Rs, Imm) -> !cmp.gt(Rs, Imm-1)
3705 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), s8ImmPred:$src2)),
3707 (J2_jumpf (C2_cmpgti (i32 IntRegs:$src1),
3708 (DEC_CONST_SIGNED s8ImmPred:$src2)), bb:$offset)>;
3710 // cmp.lt(r0, r1) -> cmp.gt(r1, r0)
3711 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3713 (J2_jumpt (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)), bb:$offset)>;
3715 def : Pat <(brcond (i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3717 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)),
3720 def : Pat <(brcond (i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3722 (J2_jumpf (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
3725 def : Pat <(brcond (i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3727 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
3730 // Map from a 64-bit select to an emulated 64-bit mux.
3731 // Hexagon does not support 64-bit MUXes; so emulate with combines.
3732 def : Pat <(select (i1 PredRegs:$src1), (i64 DoubleRegs:$src2),
3733 (i64 DoubleRegs:$src3)),
3734 (i64 (A2_combinew (i32 (C2_mux (i1 PredRegs:$src1),
3735 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
3737 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src3),
3739 (i32 (C2_mux (i1 PredRegs:$src1),
3740 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
3742 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src3),
3743 subreg_loreg))))))>;
3745 // Map from a 1-bit select to logical ops.
3746 // From LegalizeDAG.cpp: (B1 ? B2 : B3) <=> (B1 & B2)|(!B1&B3).
3747 def : Pat <(select (i1 PredRegs:$src1), (i1 PredRegs:$src2),
3748 (i1 PredRegs:$src3)),
3749 (C2_or (C2_and (i1 PredRegs:$src1), (i1 PredRegs:$src2)),
3750 (C2_and (C2_not (i1 PredRegs:$src1)), (i1 PredRegs:$src3)))>;
3752 // Map Pd = load(addr) -> Rs = load(addr); Pd = Rs.
3753 def : Pat<(i1 (load ADDRriS11_2:$addr)),
3754 (i1 (C2_tfrrp (i32 (L2_loadrb_io AddrFI:$addr, 0))))>;
3756 // Map for truncating from 64 immediates to 32 bit immediates.
3757 def : Pat<(i32 (trunc (i64 DoubleRegs:$src))),
3758 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src), subreg_loreg))>;
3760 // Map for truncating from i64 immediates to i1 bit immediates.
3761 def : Pat<(i1 (trunc (i64 DoubleRegs:$src))),
3762 (i1 (C2_tfrrp (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
3765 // Map memb(Rs) = Rdd -> memb(Rs) = Rt.
3766 def : Pat<(truncstorei8 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
3767 (STrib ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
3770 // Map memh(Rs) = Rdd -> memh(Rs) = Rt.
3771 def : Pat<(truncstorei16 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
3772 (STrih ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
3774 // Map memw(Rs) = Rdd -> memw(Rs) = Rt
3775 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
3776 (STriw ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
3779 // Map memw(Rs) = Rdd -> memw(Rs) = Rt.
3780 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
3781 (STriw ADDRriS11_0:$addr, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
3784 // Map from i1 = constant<-1>; memw(addr) = i1 -> r0 = 1; memw(addr) = r0.
3785 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
3786 (STrib ADDRriS11_2:$addr, (A2_tfrsi 1))>;
3789 // Map from i1 = constant<-1>; store i1 -> r0 = 1; store r0.
3790 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
3791 (STrib ADDRriS11_2:$addr, (A2_tfrsi 1))>;
3793 // Map from memb(Rs) = Pd -> Rt = mux(Pd, #0, #1); store Rt.
3794 def : Pat<(store (i1 PredRegs:$src1), ADDRriS11_2:$addr),
3795 (STrib ADDRriS11_2:$addr, (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0)) )>;
3797 // Map Rdd = anyext(Rs) -> Rdd = A2_sxtw(Rs).
3798 // Hexagon_TODO: We can probably use combine but that will cost 2 instructions.
3799 // Better way to do this?
3800 def : Pat<(i64 (anyext (i32 IntRegs:$src1))),
3801 (i64 (A2_sxtw (i32 IntRegs:$src1)))>;
3803 // Map cmple -> cmpgt.
3804 // rs <= rt -> !(rs > rt).
3805 def : Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
3806 (i1 (C2_not (C2_cmpgti (i32 IntRegs:$src1), s10ExtPred:$src2)))>;
3808 // rs <= rt -> !(rs > rt).
3809 def : Pat<(i1 (setle (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3810 (i1 (C2_not (C2_cmpgt (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
3812 // Rss <= Rtt -> !(Rss > Rtt).
3813 def : Pat<(i1 (setle (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3814 (i1 (C2_not (C2_cmpgtp (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))))>;
3816 // Map cmpne -> cmpeq.
3817 // Hexagon_TODO: We should improve on this.
3818 // rs != rt -> !(rs == rt).
3819 def : Pat <(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
3820 (i1 (C2_not(i1 (C2_cmpeqi (i32 IntRegs:$src1), s10ExtPred:$src2))))>;
3822 // Map cmpne(Rs) -> !cmpeqe(Rs).
3823 // rs != rt -> !(rs == rt).
3824 def : Pat <(i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3825 (i1 (C2_not (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)))))>;
3827 // Convert setne back to xor for hexagon since we compute w/ pred registers.
3828 def : Pat <(i1 (setne (i1 PredRegs:$src1), (i1 PredRegs:$src2))),
3829 (i1 (C2_xor (i1 PredRegs:$src1), (i1 PredRegs:$src2)))>;
3831 // Map cmpne(Rss) -> !cmpew(Rss).
3832 // rs != rt -> !(rs == rt).
3833 def : Pat <(i1 (setne (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3834 (i1 (C2_not (i1 (C2_cmpeqp (i64 DoubleRegs:$src1),
3835 (i64 DoubleRegs:$src2)))))>;
3837 // Map cmpge(Rs, Rt) -> !(cmpgt(Rs, Rt).
3838 // rs >= rt -> !(rt > rs).
3839 def : Pat <(i1 (setge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3840 (i1 (C2_not (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))))>;
3842 // cmpge(Rs, Imm) -> cmpgt(Rs, Imm-1)
3843 def : Pat <(i1 (setge (i32 IntRegs:$src1), s8ExtPred:$src2)),
3844 (i1 (C2_cmpgti (i32 IntRegs:$src1), (DEC_CONST_SIGNED s8ExtPred:$src2)))>;
3846 // Map cmpge(Rss, Rtt) -> !cmpgt(Rtt, Rss).
3847 // rss >= rtt -> !(rtt > rss).
3848 def : Pat <(i1 (setge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3849 (i1 (C2_not (i1 (C2_cmpgtp (i64 DoubleRegs:$src2),
3850 (i64 DoubleRegs:$src1)))))>;
3852 // Map cmplt(Rs, Imm) -> !cmpge(Rs, Imm).
3853 // !cmpge(Rs, Imm) -> !cmpgt(Rs, Imm-1).
3854 // rs < rt -> !(rs >= rt).
3855 def : Pat <(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
3856 (i1 (C2_not (C2_cmpgti (i32 IntRegs:$src1), (DEC_CONST_SIGNED s8ExtPred:$src2))))>;
3858 // Map cmplt(Rs, Rt) -> cmpgt(Rt, Rs).
3859 // rs < rt -> rt > rs.
3860 // We can let assembler map it, or we can do in the compiler itself.
3861 def : Pat <(i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3862 (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))>;
3864 // Map cmplt(Rss, Rtt) -> cmpgt(Rtt, Rss).
3865 // rss < rtt -> (rtt > rss).
3866 def : Pat <(i1 (setlt (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3867 (i1 (C2_cmpgtp (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)))>;
3869 // Map from cmpltu(Rs, Rd) -> cmpgtu(Rd, Rs)
3870 // rs < rt -> rt > rs.
3871 // We can let assembler map it, or we can do in the compiler itself.
3872 def : Pat <(i1 (setult (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3873 (i1 (C2_cmpgtu (i32 IntRegs:$src2), (i32 IntRegs:$src1)))>;
3875 // Map from cmpltu(Rss, Rdd) -> cmpgtu(Rdd, Rss).
3876 // rs < rt -> rt > rs.
3877 def : Pat <(i1 (setult (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3878 (i1 (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)))>;
3880 // Generate cmpgeu(Rs, #0) -> cmpeq(Rs, Rs)
3881 def : Pat <(i1 (setuge (i32 IntRegs:$src1), 0)),
3882 (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src1)))>;
3884 // Generate cmpgeu(Rs, #u8) -> cmpgtu(Rs, #u8 -1)
3885 def : Pat <(i1 (setuge (i32 IntRegs:$src1), u8ExtPred:$src2)),
3886 (i1 (C2_cmpgtui (i32 IntRegs:$src1), (DEC_CONST_UNSIGNED u8ExtPred:$src2)))>;
3888 // Generate cmpgtu(Rs, #u9)
3889 def : Pat <(i1 (setugt (i32 IntRegs:$src1), u9ExtPred:$src2)),
3890 (i1 (C2_cmpgtui (i32 IntRegs:$src1), u9ExtPred:$src2))>;
3892 // Map from Rs >= Rt -> !(Rt > Rs).
3893 // rs >= rt -> !(rt > rs).
3894 def : Pat <(i1 (setuge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3895 (i1 (C2_not (C2_cmpgtu (i32 IntRegs:$src2), (i32 IntRegs:$src1))))>;
3897 // Map from Rs >= Rt -> !(Rt > Rs).
3898 // rs >= rt -> !(rt > rs).
3899 def : Pat <(i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3900 (i1 (C2_not (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1))))>;
3902 // Map from cmpleu(Rs, Rt) -> !cmpgtu(Rs, Rt).
3903 // Map from (Rs <= Rt) -> !(Rs > Rt).
3904 def : Pat <(i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
3905 (i1 (C2_not (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
3907 // Map from cmpleu(Rss, Rtt) -> !cmpgtu(Rss, Rtt-1).
3908 // Map from (Rs <= Rt) -> !(Rs > Rt).
3909 def : Pat <(i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
3910 (i1 (C2_not (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))))>;
3914 def : Pat <(i32 (sext (i1 PredRegs:$src1))),
3915 (i32 (C2_muxii (i1 PredRegs:$src1), -1, 0))>;
3918 def : Pat <(i64 (sext (i1 PredRegs:$src1))),
3919 (i64 (A2_combinew (A2_tfrsi -1), (C2_muxii (i1 PredRegs:$src1), -1, 0)))>;
3921 // Convert sign-extended load back to load and sign extend.
3923 def: Pat <(i64 (sextloadi8 ADDRriS11_0:$src1)),
3924 (i64 (A2_sxtw (L2_loadrb_io AddrFI:$src1, 0)))>;
3926 // Convert any-extended load back to load and sign extend.
3928 def: Pat <(i64 (extloadi8 ADDRriS11_0:$src1)),
3929 (i64 (A2_sxtw (L2_loadrb_io AddrFI:$src1, 0)))>;
3931 // Convert sign-extended load back to load and sign extend.
3933 def: Pat <(i64 (sextloadi16 ADDRriS11_1:$src1)),
3934 (i64 (A2_sxtw (L2_loadrh_io AddrFI:$src1, 0)))>;
3936 // Convert sign-extended load back to load and sign extend.
3938 def: Pat <(i64 (sextloadi32 ADDRriS11_2:$src1)),
3939 (i64 (A2_sxtw (L2_loadri_io AddrFI:$src1, 0)))>;
3944 def : Pat <(i32 (zext (i1 PredRegs:$src1))),
3945 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
3948 def : Pat <(i64 (zext (i1 PredRegs:$src1))),
3949 (i64 (A2_combinew (A2_tfrsi 0), (C2_muxii (i1 PredRegs:$src1), 1, 0)))>,
3953 def : Pat <(i64 (zext (i32 IntRegs:$src1))),
3954 (i64 (A2_combinew (A2_tfrsi 0), (i32 IntRegs:$src1)))>,
3958 def: Pat <(i64 (zextloadi8 ADDRriS11_0:$src1)),
3959 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io AddrFI:$src1, 0)))>,
3962 let AddedComplexity = 20 in
3963 def: Pat <(i64 (zextloadi8 (add (i32 IntRegs:$src1),
3964 s11_0ExtPred:$offset))),
3965 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io IntRegs:$src1,
3966 s11_0ExtPred:$offset)))>,
3970 def: Pat <(i64 (zextloadi1 ADDRriS11_0:$src1)),
3971 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io AddrFI:$src1, 0)))>,
3974 let AddedComplexity = 20 in
3975 def: Pat <(i64 (zextloadi1 (add (i32 IntRegs:$src1),
3976 s11_0ExtPred:$offset))),
3977 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io IntRegs:$src1,
3978 s11_0ExtPred:$offset)))>,
3982 def: Pat <(i64 (zextloadi16 ADDRriS11_1:$src1)),
3983 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadruh_io AddrFI:$src1, 0)))>,
3986 let AddedComplexity = 20 in
3987 def: Pat <(i64 (zextloadi16 (add (i32 IntRegs:$src1),
3988 s11_1ExtPred:$offset))),
3989 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadruh_io IntRegs:$src1,
3990 s11_1ExtPred:$offset)))>,
3994 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)),
3995 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io AddrFI:$src1, 0)))>,
3998 let AddedComplexity = 100 in
3999 def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
4000 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io IntRegs:$src1,
4001 s11_2ExtPred:$offset)))>,
4004 let AddedComplexity = 10 in
4005 def: Pat <(i32 (zextloadi1 ADDRriS11_0:$src1)),
4006 (i32 (L2_loadri_io AddrFI:$src1, 0))>;
4008 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
4009 def : Pat <(i32 (zext (i1 PredRegs:$src1))),
4010 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
4012 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
4013 def : Pat <(i32 (anyext (i1 PredRegs:$src1))),
4014 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
4016 // Map from Rss = Pd to Rdd = A2_sxtw (mux(Pd, #1, #0))
4017 def : Pat <(i64 (anyext (i1 PredRegs:$src1))),
4018 (i64 (A2_sxtw (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))))>;
4021 let AddedComplexity = 100 in
4022 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
4024 (i64 (zextloadi32 (i32 (add IntRegs:$src2,
4025 s11_2ExtPred:$offset2)))))),
4026 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
4027 (L2_loadri_io IntRegs:$src2,
4028 s11_2ExtPred:$offset2)))>;
4030 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
4032 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
4033 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
4034 (L2_loadri_io AddrFI:$srcLow, 0)))>;
4036 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
4038 (i64 (zext (i32 IntRegs:$srcLow))))),
4039 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
4042 let AddedComplexity = 100 in
4043 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
4045 (i64 (zextloadi32 (i32 (add IntRegs:$src2,
4046 s11_2ExtPred:$offset2)))))),
4047 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
4048 (L2_loadri_io IntRegs:$src2,
4049 s11_2ExtPred:$offset2)))>;
4051 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
4053 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
4054 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
4055 (L2_loadri_io AddrFI:$srcLow, 0)))>;
4057 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
4059 (i64 (zext (i32 IntRegs:$srcLow))))),
4060 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
4063 // Any extended 64-bit load.
4064 // anyext i32 -> i64
4065 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)),
4066 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io AddrFI:$src1, 0)))>,
4069 // When there is an offset we should prefer the pattern below over the pattern above.
4070 // The complexity of the above is 13 (gleaned from HexagonGenDAGIsel.inc)
4071 // So this complexity below is comfortably higher to allow for choosing the below.
4072 // If this is not done then we generate addresses such as
4073 // ********************************************
4074 // r1 = add (r0, #4)
4075 // r1 = memw(r1 + #0)
4077 // r1 = memw(r0 + #4)
4078 // ********************************************
4079 let AddedComplexity = 100 in
4080 def: Pat <(i64 (extloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
4081 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io IntRegs:$src1,
4082 s11_2ExtPred:$offset)))>,
4085 // anyext i16 -> i64.
4086 def: Pat <(i64 (extloadi16 ADDRriS11_2:$src1)),
4087 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrh_io AddrFI:$src1, 0)))>,
4090 let AddedComplexity = 20 in
4091 def: Pat <(i64 (extloadi16 (add (i32 IntRegs:$src1),
4092 s11_1ExtPred:$offset))),
4093 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrh_io IntRegs:$src1,
4094 s11_1ExtPred:$offset)))>,
4097 // Map from Rdd = zxtw(Rs) -> Rdd = combine(0, Rs).
4098 def : Pat<(i64 (zext (i32 IntRegs:$src1))),
4099 (i64 (A2_combinew (A2_tfrsi 0), (i32 IntRegs:$src1)))>,
4102 // Multiply 64-bit unsigned and use upper result.
4103 def : Pat <(mulhu (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
4118 (A2_combinew (A2_tfrsi 0),
4125 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
4127 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
4128 subreg_loreg)))), 32)),
4130 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
4131 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_loreg)))),
4132 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg)),
4133 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg)))),
4134 32)), subreg_loreg)))),
4135 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
4136 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg))))>;
4138 // Multiply 64-bit signed and use upper result.
4139 def : Pat <(mulhs (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
4143 (A2_combinew (A2_tfrsi 0),
4153 (A2_combinew (A2_tfrsi 0),
4160 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
4162 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
4163 subreg_loreg)))), 32)),
4165 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
4166 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_loreg)))),
4167 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg)),
4168 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg)))),
4169 32)), subreg_loreg)))),
4170 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
4171 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg))))>;
4173 // Hexagon specific ISD nodes.
4174 //def SDTHexagonADJDYNALLOC : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>]>;
4175 def SDTHexagonADJDYNALLOC : SDTypeProfile<1, 2,
4176 [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
4177 def Hexagon_ADJDYNALLOC : SDNode<"HexagonISD::ADJDYNALLOC",
4178 SDTHexagonADJDYNALLOC>;
4179 // Needed to tag these instructions for stack layout.
4180 let usesCustomInserter = 1 in
4181 def ADJDYNALLOC : ALU32_ri<(outs IntRegs:$dst), (ins IntRegs:$src1,
4183 "$dst = add($src1, #$src2)",
4184 [(set (i32 IntRegs:$dst),
4185 (Hexagon_ADJDYNALLOC (i32 IntRegs:$src1),
4186 s16ImmPred:$src2))]>;
4188 def SDTHexagonARGEXTEND : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
4189 def Hexagon_ARGEXTEND : SDNode<"HexagonISD::ARGEXTEND", SDTHexagonARGEXTEND>;
4190 def ARGEXTEND : ALU32_rr <(outs IntRegs:$dst), (ins IntRegs:$src1),
4192 [(set (i32 IntRegs:$dst),
4193 (Hexagon_ARGEXTEND (i32 IntRegs:$src1)))]>;
4195 let AddedComplexity = 100 in
4196 def : Pat<(i32 (sext_inreg (Hexagon_ARGEXTEND (i32 IntRegs:$src1)), i16)),
4197 (COPY (i32 IntRegs:$src1))>;
4199 def HexagonWrapperJT: SDNode<"HexagonISD::WrapperJT", SDTIntUnaryOp>;
4201 def : Pat<(HexagonWrapperJT tjumptable:$dst),
4202 (i32 (CONST32_set_jt tjumptable:$dst))>;
4206 //===----------------------------------------------------------------------===//
4208 // Shift by immediate/register and accumulate/logical
4209 //===----------------------------------------------------------------------===//
4211 // Rx[+-&|]=asr(Rs,#u5)
4212 // Rx[+-&|^]=lsr(Rs,#u5)
4213 // Rx[+-&|^]=asl(Rs,#u5)
4215 let hasNewValue = 1, opNewValue = 0 in
4216 class T_shift_imm_acc_r <string opc1, string opc2, SDNode OpNode1,
4217 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
4218 : SInst_acc<(outs IntRegs:$Rx),
4219 (ins IntRegs:$src1, IntRegs:$Rs, u5Imm:$u5),
4220 "$Rx "#opc2#opc1#"($Rs, #$u5)",
4221 [(set (i32 IntRegs:$Rx),
4222 (OpNode2 (i32 IntRegs:$src1),
4223 (OpNode1 (i32 IntRegs:$Rs), u5ImmPred:$u5)))],
4224 "$src1 = $Rx", S_2op_tc_2_SLOT23> {
4229 let IClass = 0b1000;
4231 let Inst{27-24} = 0b1110;
4232 let Inst{23-22} = majOp{2-1};
4234 let Inst{7} = majOp{0};
4235 let Inst{6-5} = minOp;
4237 let Inst{20-16} = Rs;
4238 let Inst{12-8} = u5;
4241 // Rx[+-&|]=asr(Rs,Rt)
4242 // Rx[+-&|^]=lsr(Rs,Rt)
4243 // Rx[+-&|^]=asl(Rs,Rt)
4245 let hasNewValue = 1, opNewValue = 0 in
4246 class T_shift_reg_acc_r <string opc1, string opc2, SDNode OpNode1,
4247 SDNode OpNode2, bits<2> majOp, bits<2> minOp>
4248 : SInst_acc<(outs IntRegs:$Rx),
4249 (ins IntRegs:$src1, IntRegs:$Rs, IntRegs:$Rt),
4250 "$Rx "#opc2#opc1#"($Rs, $Rt)",
4251 [(set (i32 IntRegs:$Rx),
4252 (OpNode2 (i32 IntRegs:$src1),
4253 (OpNode1 (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))],
4254 "$src1 = $Rx", S_3op_tc_2_SLOT23 > {
4259 let IClass = 0b1100;
4261 let Inst{27-24} = 0b1100;
4262 let Inst{23-22} = majOp;
4263 let Inst{7-6} = minOp;
4265 let Inst{20-16} = Rs;
4266 let Inst{12-8} = Rt;
4269 // Rxx[+-&|]=asr(Rss,#u6)
4270 // Rxx[+-&|^]=lsr(Rss,#u6)
4271 // Rxx[+-&|^]=asl(Rss,#u6)
4273 class T_shift_imm_acc_p <string opc1, string opc2, SDNode OpNode1,
4274 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
4275 : SInst_acc<(outs DoubleRegs:$Rxx),
4276 (ins DoubleRegs:$src1, DoubleRegs:$Rss, u6Imm:$u6),
4277 "$Rxx "#opc2#opc1#"($Rss, #$u6)",
4278 [(set (i64 DoubleRegs:$Rxx),
4279 (OpNode2 (i64 DoubleRegs:$src1),
4280 (OpNode1 (i64 DoubleRegs:$Rss), u6ImmPred:$u6)))],
4281 "$src1 = $Rxx", S_2op_tc_2_SLOT23> {
4286 let IClass = 0b1000;
4288 let Inst{27-24} = 0b0010;
4289 let Inst{23-22} = majOp{2-1};
4290 let Inst{7} = majOp{0};
4291 let Inst{6-5} = minOp;
4292 let Inst{4-0} = Rxx;
4293 let Inst{20-16} = Rss;
4294 let Inst{13-8} = u6;
4298 // Rxx[+-&|]=asr(Rss,Rt)
4299 // Rxx[+-&|^]=lsr(Rss,Rt)
4300 // Rxx[+-&|^]=asl(Rss,Rt)
4301 // Rxx[+-&|^]=lsl(Rss,Rt)
4303 class T_shift_reg_acc_p <string opc1, string opc2, SDNode OpNode1,
4304 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
4305 : SInst_acc<(outs DoubleRegs:$Rxx),
4306 (ins DoubleRegs:$src1, DoubleRegs:$Rss, IntRegs:$Rt),
4307 "$Rxx "#opc2#opc1#"($Rss, $Rt)",
4308 [(set (i64 DoubleRegs:$Rxx),
4309 (OpNode2 (i64 DoubleRegs:$src1),
4310 (OpNode1 (i64 DoubleRegs:$Rss), (i32 IntRegs:$Rt))))],
4311 "$src1 = $Rxx", S_3op_tc_2_SLOT23> {
4316 let IClass = 0b1100;
4318 let Inst{27-24} = 0b1011;
4319 let Inst{23-21} = majOp;
4320 let Inst{20-16} = Rss;
4321 let Inst{12-8} = Rt;
4322 let Inst{7-6} = minOp;
4323 let Inst{4-0} = Rxx;
4326 //===----------------------------------------------------------------------===//
4327 // Multi-class for the shift instructions with logical/arithmetic operators.
4328 //===----------------------------------------------------------------------===//
4330 multiclass xtype_imm_base<string OpcStr1, string OpcStr2, SDNode OpNode1,
4331 SDNode OpNode2, bits<3> majOp, bits<2> minOp > {
4332 def _i_r#NAME : T_shift_imm_acc_r< OpcStr1, OpcStr2, OpNode1,
4333 OpNode2, majOp, minOp >;
4334 def _i_p#NAME : T_shift_imm_acc_p< OpcStr1, OpcStr2, OpNode1,
4335 OpNode2, majOp, minOp >;
4338 multiclass xtype_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
4339 let AddedComplexity = 100 in
4340 defm _acc : xtype_imm_base< opc1, "+= ", OpNode, add, 0b001, minOp>;
4342 defm _nac : xtype_imm_base< opc1, "-= ", OpNode, sub, 0b000, minOp>;
4343 defm _and : xtype_imm_base< opc1, "&= ", OpNode, and, 0b010, minOp>;
4344 defm _or : xtype_imm_base< opc1, "|= ", OpNode, or, 0b011, minOp>;
4347 multiclass xtype_xor_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
4348 let AddedComplexity = 100 in
4349 defm _xacc : xtype_imm_base< opc1, "^= ", OpNode, xor, 0b100, minOp>;
4352 let isCodeGenOnly = 0 in {
4353 defm S2_asr : xtype_imm_acc<"asr", sra, 0b00>;
4355 defm S2_lsr : xtype_imm_acc<"lsr", srl, 0b01>,
4356 xtype_xor_imm_acc<"lsr", srl, 0b01>;
4358 defm S2_asl : xtype_imm_acc<"asl", shl, 0b10>,
4359 xtype_xor_imm_acc<"asl", shl, 0b10>;
4362 multiclass xtype_reg_acc_r<string opc1, SDNode OpNode, bits<2>minOp> {
4363 let AddedComplexity = 100 in
4364 def _acc : T_shift_reg_acc_r <opc1, "+= ", OpNode, add, 0b11, minOp>;
4366 def _nac : T_shift_reg_acc_r <opc1, "-= ", OpNode, sub, 0b10, minOp>;
4367 def _and : T_shift_reg_acc_r <opc1, "&= ", OpNode, and, 0b01, minOp>;
4368 def _or : T_shift_reg_acc_r <opc1, "|= ", OpNode, or, 0b00, minOp>;
4371 multiclass xtype_reg_acc_p<string opc1, SDNode OpNode, bits<2>minOp> {
4372 let AddedComplexity = 100 in
4373 def _acc : T_shift_reg_acc_p <opc1, "+= ", OpNode, add, 0b110, minOp>;
4375 def _nac : T_shift_reg_acc_p <opc1, "-= ", OpNode, sub, 0b100, minOp>;
4376 def _and : T_shift_reg_acc_p <opc1, "&= ", OpNode, and, 0b010, minOp>;
4377 def _or : T_shift_reg_acc_p <opc1, "|= ", OpNode, or, 0b000, minOp>;
4378 def _xor : T_shift_reg_acc_p <opc1, "^= ", OpNode, xor, 0b011, minOp>;
4381 multiclass xtype_reg_acc<string OpcStr, SDNode OpNode, bits<2> minOp > {
4382 defm _r_r : xtype_reg_acc_r <OpcStr, OpNode, minOp>;
4383 defm _r_p : xtype_reg_acc_p <OpcStr, OpNode, minOp>;
4386 let isCodeGenOnly = 0 in {
4387 defm S2_asl : xtype_reg_acc<"asl", shl, 0b10>;
4388 defm S2_asr : xtype_reg_acc<"asr", sra, 0b00>;
4389 defm S2_lsr : xtype_reg_acc<"lsr", srl, 0b01>;
4390 defm S2_lsl : xtype_reg_acc<"lsl", shl, 0b11>;
4393 //===----------------------------------------------------------------------===//
4394 let hasSideEffects = 0 in
4395 class T_S3op_1 <string mnemonic, RegisterClass RC, bits<2> MajOp, bits<3> MinOp,
4396 bit SwapOps, bit isSat = 0, bit isRnd = 0, bit hasShift = 0>
4397 : SInst <(outs RC:$dst),
4398 (ins DoubleRegs:$src1, DoubleRegs:$src2),
4399 "$dst = "#mnemonic#"($src1, $src2)"#!if(isRnd, ":rnd", "")
4400 #!if(hasShift,":>>1","")
4401 #!if(isSat, ":sat", ""),
4402 [], "", S_3op_tc_2_SLOT23 > {
4407 let IClass = 0b1100;
4409 let Inst{27-24} = 0b0001;
4410 let Inst{23-22} = MajOp;
4411 let Inst{20-16} = !if (SwapOps, src2, src1);
4412 let Inst{12-8} = !if (SwapOps, src1, src2);
4413 let Inst{7-5} = MinOp;
4414 let Inst{4-0} = dst;
4417 class T_S3op_64 <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit SwapOps,
4418 bit isSat = 0, bit isRnd = 0, bit hasShift = 0 >
4419 : T_S3op_1 <mnemonic, DoubleRegs, MajOp, MinOp, SwapOps,
4420 isSat, isRnd, hasShift>;
4422 let isCodeGenOnly = 0 in
4423 def S2_lfsp : T_S3op_64 < "lfs", 0b10, 0b110, 0>;
4425 //===----------------------------------------------------------------------===//
4426 // Template class used by vector shift, vector rotate, vector neg,
4427 // 32-bit shift, 64-bit shifts, etc.
4428 //===----------------------------------------------------------------------===//
4430 let hasSideEffects = 0 in
4431 class T_S3op_3 <string mnemonic, RegisterClass RC, bits<2> MajOp,
4432 bits<2> MinOp, bit isSat = 0, list<dag> pattern = [] >
4433 : SInst <(outs RC:$dst),
4434 (ins RC:$src1, IntRegs:$src2),
4435 "$dst = "#mnemonic#"($src1, $src2)"#!if(isSat, ":sat", ""),
4436 pattern, "", S_3op_tc_1_SLOT23> {
4441 let IClass = 0b1100;
4443 let Inst{27-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b0110, 0b0011);
4444 let Inst{23-22} = MajOp;
4445 let Inst{20-16} = src1;
4446 let Inst{12-8} = src2;
4447 let Inst{7-6} = MinOp;
4448 let Inst{4-0} = dst;
4451 let hasNewValue = 1 in
4452 class T_S3op_shift32 <string mnemonic, SDNode OpNode, bits<2> MinOp>
4453 : T_S3op_3 <mnemonic, IntRegs, 0b01, MinOp, 0,
4454 [(set (i32 IntRegs:$dst), (OpNode (i32 IntRegs:$src1),
4455 (i32 IntRegs:$src2)))]>;
4457 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in
4458 class T_S3op_shift32_Sat <string mnemonic, bits<2> MinOp>
4459 : T_S3op_3 <mnemonic, IntRegs, 0b00, MinOp, 1, []>;
4462 class T_S3op_shift64 <string mnemonic, SDNode OpNode, bits<2> MinOp>
4463 : T_S3op_3 <mnemonic, DoubleRegs, 0b10, MinOp, 0,
4464 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
4465 (i32 IntRegs:$src2)))]>;
4468 class T_S3op_shiftVect <string mnemonic, bits<2> MajOp, bits<2> MinOp>
4469 : T_S3op_3 <mnemonic, DoubleRegs, MajOp, MinOp, 0, []>;
4472 // Shift by register
4473 // Rdd=[asr|lsr|asl|lsl](Rss,Rt)
4475 let isCodeGenOnly = 0 in {
4476 def S2_asr_r_p : T_S3op_shift64 < "asr", sra, 0b00>;
4477 def S2_lsr_r_p : T_S3op_shift64 < "lsr", srl, 0b01>;
4478 def S2_asl_r_p : T_S3op_shift64 < "asl", shl, 0b10>;
4479 def S2_lsl_r_p : T_S3op_shift64 < "lsl", shl, 0b11>;
4482 // Rd=[asr|lsr|asl|lsl](Rs,Rt)
4484 let isCodeGenOnly = 0 in {
4485 def S2_asr_r_r : T_S3op_shift32<"asr", sra, 0b00>;
4486 def S2_lsr_r_r : T_S3op_shift32<"lsr", srl, 0b01>;
4487 def S2_asl_r_r : T_S3op_shift32<"asl", shl, 0b10>;
4488 def S2_lsl_r_r : T_S3op_shift32<"lsl", shl, 0b11>;
4491 // Shift by register with saturation
4492 // Rd=asr(Rs,Rt):sat
4493 // Rd=asl(Rs,Rt):sat
4495 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
4496 def S2_asr_r_r_sat : T_S3op_shift32_Sat<"asr", 0b00>;
4497 def S2_asl_r_r_sat : T_S3op_shift32_Sat<"asl", 0b10>;
4500 //===----------------------------------------------------------------------===//
4501 // Template class for 'insert bitfield' instructions
4502 //===----------------------------------------------------------------------===//
4503 let hasSideEffects = 0 in
4504 class T_S3op_insert <string mnemonic, RegisterClass RC>
4505 : SInst <(outs RC:$dst),
4506 (ins RC:$src1, RC:$src2, DoubleRegs:$src3),
4507 "$dst = "#mnemonic#"($src2, $src3)" ,
4508 [], "$src1 = $dst", S_3op_tc_1_SLOT23 > {
4513 let IClass = 0b1100;
4515 let Inst{27-26} = 0b10;
4516 let Inst{25-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b00, 0b10);
4518 let Inst{20-16} = src2;
4519 let Inst{12-8} = src3;
4520 let Inst{4-0} = dst;
4523 let hasSideEffects = 0 in
4524 class T_S2op_insert <bits<4> RegTyBits, RegisterClass RC, Operand ImmOp>
4525 : SInst <(outs RC:$dst), (ins RC:$dst2, RC:$src1, ImmOp:$src2, ImmOp:$src3),
4526 "$dst = insert($src1, #$src2, #$src3)",
4527 [], "$dst2 = $dst", S_2op_tc_2_SLOT23> {
4534 string ImmOpStr = !cast<string>(ImmOp);
4536 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5}, 0);
4537 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
4539 let IClass = 0b1000;
4541 let Inst{27-24} = RegTyBits;
4542 let Inst{23} = bit23;
4543 let Inst{22-21} = src3{4-3};
4544 let Inst{20-16} = src1;
4545 let Inst{13} = bit13;
4546 let Inst{12-8} = src2{4-0};
4547 let Inst{7-5} = src3{2-0};
4548 let Inst{4-0} = dst;
4551 // Rx=insert(Rs,Rtt)
4552 // Rx=insert(Rs,#u5,#U5)
4553 let hasNewValue = 1, isCodeGenOnly = 0 in {
4554 def S2_insert_rp : T_S3op_insert <"insert", IntRegs>;
4555 def S2_insert : T_S2op_insert <0b1111, IntRegs, u5Imm>;
4558 // Rxx=insert(Rss,Rtt)
4559 // Rxx=insert(Rss,#u6,#U6)
4560 let isCodeGenOnly = 0 in {
4561 def S2_insertp_rp : T_S3op_insert<"insert", DoubleRegs>;
4562 def S2_insertp : T_S2op_insert <0b0011, DoubleRegs, u6Imm>;
4565 //===----------------------------------------------------------------------===//
4566 // Template class for 'extract bitfield' instructions
4567 //===----------------------------------------------------------------------===//
4568 let hasNewValue = 1, hasSideEffects = 0 in
4569 class T_S3op_extract <string mnemonic, bits<2> MinOp>
4570 : SInst <(outs IntRegs:$Rd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
4571 "$Rd = "#mnemonic#"($Rs, $Rtt)",
4572 [], "", S_3op_tc_2_SLOT23 > {
4577 let IClass = 0b1100;
4579 let Inst{27-22} = 0b100100;
4580 let Inst{20-16} = Rs;
4581 let Inst{12-8} = Rtt;
4582 let Inst{7-6} = MinOp;
4586 let hasSideEffects = 0 in
4587 class T_S2op_extract <string mnemonic, bits<4> RegTyBits,
4588 RegisterClass RC, Operand ImmOp>
4589 : SInst <(outs RC:$dst), (ins RC:$src1, ImmOp:$src2, ImmOp:$src3),
4590 "$dst = "#mnemonic#"($src1, #$src2, #$src3)",
4591 [], "", S_2op_tc_2_SLOT23> {
4598 string ImmOpStr = !cast<string>(ImmOp);
4600 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5},
4601 !if (!eq(mnemonic, "extractu"), 0, 1));
4603 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
4605 let IClass = 0b1000;
4607 let Inst{27-24} = RegTyBits;
4608 let Inst{23} = bit23;
4609 let Inst{22-21} = src3{4-3};
4610 let Inst{20-16} = src1;
4611 let Inst{13} = bit13;
4612 let Inst{12-8} = src2{4-0};
4613 let Inst{7-5} = src3{2-0};
4614 let Inst{4-0} = dst;
4619 // Rdd=extractu(Rss,Rtt)
4620 // Rdd=extractu(Rss,#u6,#U6)
4621 let isCodeGenOnly = 0 in {
4622 def S2_extractup_rp : T_S3op_64 < "extractu", 0b00, 0b000, 0>;
4623 def S2_extractup : T_S2op_extract <"extractu", 0b0001, DoubleRegs, u6Imm>;
4626 // Rd=extractu(Rs,Rtt)
4627 // Rd=extractu(Rs,#u5,#U5)
4628 let hasNewValue = 1, isCodeGenOnly = 0 in {
4629 def S2_extractu_rp : T_S3op_extract<"extractu", 0b00>;
4630 def S2_extractu : T_S2op_extract <"extractu", 0b1101, IntRegs, u5Imm>;
4633 //===----------------------------------------------------------------------===//
4634 // :raw for of tableindx[bdhw] insns
4635 //===----------------------------------------------------------------------===//
4637 let hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
4638 class tableidxRaw<string OpStr, bits<2>MinOp>
4639 : SInst <(outs IntRegs:$Rx),
4640 (ins IntRegs:$_dst_, IntRegs:$Rs, u4Imm:$u4, s6Imm:$S6),
4641 "$Rx = "#OpStr#"($Rs, #$u4, #$S6):raw",
4642 [], "$Rx = $_dst_" > {
4648 let IClass = 0b1000;
4650 let Inst{27-24} = 0b0111;
4651 let Inst{23-22} = MinOp;
4652 let Inst{21} = u4{3};
4653 let Inst{20-16} = Rs;
4654 let Inst{13-8} = S6;
4655 let Inst{7-5} = u4{2-0};
4659 let isCodeGenOnly = 0 in {
4660 def S2_tableidxb : tableidxRaw<"tableidxb", 0b00>;
4661 def S2_tableidxh : tableidxRaw<"tableidxh", 0b01>;
4662 def S2_tableidxw : tableidxRaw<"tableidxw", 0b10>;
4663 def S2_tableidxd : tableidxRaw<"tableidxd", 0b11>;
4666 // Change the sign of the immediate for Rd=-mpyi(Rs,#u8)
4667 def : Pat <(mul (i32 IntRegs:$src1), (ineg n8ImmPred:$src2)),
4668 (i32 (M2_mpysin (i32 IntRegs:$src1), u8ImmPred:$src2))>;
4670 //===----------------------------------------------------------------------===//
4671 // V3 Instructions +
4672 //===----------------------------------------------------------------------===//
4674 include "HexagonInstrInfoV3.td"
4676 //===----------------------------------------------------------------------===//
4677 // V3 Instructions -
4678 //===----------------------------------------------------------------------===//
4680 //===----------------------------------------------------------------------===//
4681 // V4 Instructions +
4682 //===----------------------------------------------------------------------===//
4684 include "HexagonInstrInfoV4.td"
4686 //===----------------------------------------------------------------------===//
4687 // V4 Instructions -
4688 //===----------------------------------------------------------------------===//
4690 //===----------------------------------------------------------------------===//
4691 // V5 Instructions +
4692 //===----------------------------------------------------------------------===//
4694 include "HexagonInstrInfoV5.td"
4696 //===----------------------------------------------------------------------===//
4697 // V5 Instructions -
4698 //===----------------------------------------------------------------------===//