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)>;
32 def HiReg: OutPatFrag<(ops node:$Rs),
33 (EXTRACT_SUBREG (i64 $Rs), subreg_hireg)>;
35 // SDNode for converting immediate C to C-1.
36 def DEC_CONST_SIGNED : SDNodeXForm<imm, [{
37 // Return the byte immediate const-1 as an SDNode.
38 int32_t imm = N->getSExtValue();
39 return XformSToSM1Imm(imm);
42 // SDNode for converting immediate C to C-2.
43 def DEC2_CONST_SIGNED : SDNodeXForm<imm, [{
44 // Return the byte immediate const-2 as an SDNode.
45 int32_t imm = N->getSExtValue();
46 return XformSToSM2Imm(imm);
49 // SDNode for converting immediate C to C-3.
50 def DEC3_CONST_SIGNED : SDNodeXForm<imm, [{
51 // Return the byte immediate const-3 as an SDNode.
52 int32_t imm = N->getSExtValue();
53 return XformSToSM3Imm(imm);
56 // SDNode for converting immediate C to C-1.
57 def DEC_CONST_UNSIGNED : SDNodeXForm<imm, [{
58 // Return the byte immediate const-1 as an SDNode.
59 uint32_t imm = N->getZExtValue();
60 return XformUToUM1Imm(imm);
63 //===----------------------------------------------------------------------===//
65 //===----------------------------------------------------------------------===//
67 //===----------------------------------------------------------------------===//
68 let hasSideEffects = 0, isCompare = 1, InputType = "imm", isExtendable = 1,
70 class T_CMP <string mnemonic, bits<2> MajOp, bit isNot, Operand ImmOp>
71 : ALU32Inst <(outs PredRegs:$dst),
72 (ins IntRegs:$src1, ImmOp:$src2),
73 "$dst = "#!if(isNot, "!","")#mnemonic#"($src1, #$src2)",
74 [], "",ALU32_2op_tc_2early_SLOT0123 >, ImmRegRel {
78 let CextOpcode = mnemonic;
79 let opExtentBits = !if(!eq(mnemonic, "cmp.gtu"), 9, 10);
80 let isExtentSigned = !if(!eq(mnemonic, "cmp.gtu"), 0, 1);
84 let Inst{27-24} = 0b0101;
85 let Inst{23-22} = MajOp;
86 let Inst{21} = !if(!eq(mnemonic, "cmp.gtu"), 0, src2{9});
87 let Inst{20-16} = src1;
88 let Inst{13-5} = src2{8-0};
94 let isCodeGenOnly = 0 in {
95 def C2_cmpeqi : T_CMP <"cmp.eq", 0b00, 0, s10Ext>;
96 def C2_cmpgti : T_CMP <"cmp.gt", 0b01, 0, s10Ext>;
97 def C2_cmpgtui : T_CMP <"cmp.gtu", 0b10, 0, u9Ext>;
100 class T_CMP_pat <InstHexagon MI, PatFrag OpNode, PatLeaf ImmPred>
101 : Pat<(i1 (OpNode (i32 IntRegs:$src1), ImmPred:$src2)),
102 (MI IntRegs:$src1, ImmPred:$src2)>;
104 def : T_CMP_pat <C2_cmpeqi, seteq, s10ImmPred>;
105 def : T_CMP_pat <C2_cmpgti, setgt, s10ImmPred>;
106 def : T_CMP_pat <C2_cmpgtui, setugt, u9ImmPred>;
108 //===----------------------------------------------------------------------===//
110 //===----------------------------------------------------------------------===//
111 def SDTHexagonI64I32I32 : SDTypeProfile<1, 2,
112 [SDTCisVT<0, i64>, SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>;
114 def HexagonCOMBINE : SDNode<"HexagonISD::COMBINE", SDTHexagonI64I32I32>;
116 let hasSideEffects = 0, hasNewValue = 1, InputType = "reg" in
117 class T_ALU32_3op<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit OpsRev,
119 : ALU32_rr<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
120 "$Rd = "#mnemonic#"($Rs, $Rt)",
121 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredRel {
122 let isCommutable = IsComm;
123 let BaseOpcode = mnemonic#_rr;
124 let CextOpcode = mnemonic;
132 let Inst{26-24} = MajOp;
133 let Inst{23-21} = MinOp;
134 let Inst{20-16} = !if(OpsRev,Rt,Rs);
135 let Inst{12-8} = !if(OpsRev,Rs,Rt);
139 let hasSideEffects = 0, hasNewValue = 1 in
140 class T_ALU32_3op_pred<string mnemonic, bits<3> MajOp, bits<3> MinOp,
141 bit OpsRev, bit PredNot, bit PredNew>
142 : ALU32_rr<(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
143 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") "#
144 "$Rd = "#mnemonic#"($Rs, $Rt)",
145 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
146 let isPredicated = 1;
147 let isPredicatedFalse = PredNot;
148 let isPredicatedNew = PredNew;
149 let BaseOpcode = mnemonic#_rr;
150 let CextOpcode = mnemonic;
159 let Inst{26-24} = MajOp;
160 let Inst{23-21} = MinOp;
161 let Inst{20-16} = !if(OpsRev,Rt,Rs);
162 let Inst{13} = PredNew;
163 let Inst{12-8} = !if(OpsRev,Rs,Rt);
164 let Inst{7} = PredNot;
169 class T_ALU32_combineh<string Op1, string Op2, bits<3> MajOp, bits<3> MinOp,
171 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, 0> {
172 let AsmString = "$Rd = combine($Rs"#Op1#", $Rt"#Op2#")";
175 let isCodeGenOnly = 0 in {
176 def A2_combine_hh : T_ALU32_combineh<".h", ".h", 0b011, 0b100, 1>;
177 def A2_combine_hl : T_ALU32_combineh<".h", ".l", 0b011, 0b101, 1>;
178 def A2_combine_lh : T_ALU32_combineh<".l", ".h", 0b011, 0b110, 1>;
179 def A2_combine_ll : T_ALU32_combineh<".l", ".l", 0b011, 0b111, 1>;
182 class T_ALU32_3op_sfx<string mnemonic, string suffix, bits<3> MajOp,
183 bits<3> MinOp, bit OpsRev, bit IsComm>
184 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, IsComm> {
185 let AsmString = "$Rd = "#mnemonic#"($Rs, $Rt)"#suffix;
188 let isCodeGenOnly = 0 in {
189 def A2_svaddh : T_ALU32_3op<"vaddh", 0b110, 0b000, 0, 1>;
190 def A2_svsubh : T_ALU32_3op<"vsubh", 0b110, 0b100, 1, 0>;
193 let Defs = [USR_OVF], Itinerary = ALU32_3op_tc_2_SLOT0123,
194 isCodeGenOnly = 0 in {
195 def A2_svaddhs : T_ALU32_3op_sfx<"vaddh", ":sat", 0b110, 0b001, 0, 1>;
196 def A2_addsat : T_ALU32_3op_sfx<"add", ":sat", 0b110, 0b010, 0, 1>;
197 def A2_svadduhs : T_ALU32_3op_sfx<"vadduh", ":sat", 0b110, 0b011, 0, 1>;
198 def A2_svsubhs : T_ALU32_3op_sfx<"vsubh", ":sat", 0b110, 0b101, 1, 0>;
199 def A2_subsat : T_ALU32_3op_sfx<"sub", ":sat", 0b110, 0b110, 1, 0>;
200 def A2_svsubuhs : T_ALU32_3op_sfx<"vsubuh", ":sat", 0b110, 0b111, 1, 0>;
203 let Itinerary = ALU32_3op_tc_2_SLOT0123, isCodeGenOnly = 0 in
204 def A2_svavghs : T_ALU32_3op_sfx<"vavgh", ":rnd", 0b111, 0b001, 0, 1>;
206 let isCodeGenOnly = 0 in {
207 def A2_svavgh : T_ALU32_3op<"vavgh", 0b111, 0b000, 0, 1>;
208 def A2_svnavgh : T_ALU32_3op<"vnavgh", 0b111, 0b011, 1, 0>;
211 multiclass T_ALU32_3op_p<string mnemonic, bits<3> MajOp, bits<3> MinOp,
213 def t : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 0>;
214 def f : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 0>;
215 def tnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 1>;
216 def fnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 1>;
219 multiclass T_ALU32_3op_A2<string mnemonic, bits<3> MajOp, bits<3> MinOp,
220 bit OpsRev, bit IsComm> {
221 let isPredicable = 1 in
222 def A2_#NAME : T_ALU32_3op <mnemonic, MajOp, MinOp, OpsRev, IsComm>;
223 defm A2_p#NAME : T_ALU32_3op_p<mnemonic, MajOp, MinOp, OpsRev>;
226 let isCodeGenOnly = 0 in {
227 defm add : T_ALU32_3op_A2<"add", 0b011, 0b000, 0, 1>;
228 defm and : T_ALU32_3op_A2<"and", 0b001, 0b000, 0, 1>;
229 defm or : T_ALU32_3op_A2<"or", 0b001, 0b001, 0, 1>;
230 defm sub : T_ALU32_3op_A2<"sub", 0b011, 0b001, 1, 0>;
231 defm xor : T_ALU32_3op_A2<"xor", 0b001, 0b011, 0, 1>;
234 // Pats for instruction selection.
235 class BinOp32_pat<SDNode Op, InstHexagon MI, ValueType ResT>
236 : Pat<(ResT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
237 (ResT (MI IntRegs:$Rs, IntRegs:$Rt))>;
239 def: BinOp32_pat<add, A2_add, i32>;
240 def: BinOp32_pat<and, A2_and, i32>;
241 def: BinOp32_pat<or, A2_or, i32>;
242 def: BinOp32_pat<sub, A2_sub, i32>;
243 def: BinOp32_pat<xor, A2_xor, i32>;
245 // A few special cases producing register pairs:
246 let OutOperandList = (outs DoubleRegs:$Rd), hasNewValue = 0,
247 isCodeGenOnly = 0 in {
248 def S2_packhl : T_ALU32_3op <"packhl", 0b101, 0b100, 0, 0>;
250 let isPredicable = 1 in
251 def A2_combinew : T_ALU32_3op <"combine", 0b101, 0b000, 0, 0>;
253 // Conditional combinew uses "newt/f" instead of "t/fnew".
254 def C2_ccombinewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 0>;
255 def C2_ccombinewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 0>;
256 def C2_ccombinewnewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 1>;
257 def C2_ccombinewnewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 1>;
260 let hasSideEffects = 0, hasNewValue = 1, isCompare = 1, InputType = "reg" in
261 class T_ALU32_3op_cmp<string mnemonic, bits<2> MinOp, bit IsNeg, bit IsComm>
262 : ALU32_rr<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
263 "$Pd = "#mnemonic#"($Rs, $Rt)",
264 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
265 let CextOpcode = mnemonic;
266 let isCommutable = IsComm;
272 let Inst{27-24} = 0b0010;
273 let Inst{22-21} = MinOp;
274 let Inst{20-16} = Rs;
277 let Inst{3-2} = 0b00;
281 let Itinerary = ALU32_3op_tc_2early_SLOT0123, isCodeGenOnly = 0 in {
282 def C2_cmpeq : T_ALU32_3op_cmp< "cmp.eq", 0b00, 0, 1>;
283 def C2_cmpgt : T_ALU32_3op_cmp< "cmp.gt", 0b10, 0, 0>;
284 def C2_cmpgtu : T_ALU32_3op_cmp< "cmp.gtu", 0b11, 0, 0>;
287 // Patfrag to convert the usual comparison patfrags (e.g. setlt) to ones
288 // that reverse the order of the operands.
289 class RevCmp<PatFrag F> : PatFrag<(ops node:$rhs, node:$lhs), F.Fragment>;
291 // Pats for compares. They use PatFrags as operands, not SDNodes,
292 // since seteq/setgt/etc. are defined as ParFrags.
293 class T_cmp32_rr_pat<InstHexagon MI, PatFrag Op, ValueType VT>
294 : Pat<(VT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
295 (VT (MI IntRegs:$Rs, IntRegs:$Rt))>;
297 def: T_cmp32_rr_pat<C2_cmpeq, seteq, i1>;
298 def: T_cmp32_rr_pat<C2_cmpgt, setgt, i1>;
299 def: T_cmp32_rr_pat<C2_cmpgtu, setugt, i1>;
301 def: T_cmp32_rr_pat<C2_cmpgt, RevCmp<setlt>, i1>;
302 def: T_cmp32_rr_pat<C2_cmpgtu, RevCmp<setult>, i1>;
304 let CextOpcode = "MUX", InputType = "reg", hasNewValue = 1,
306 def C2_mux: ALU32_rr<(outs IntRegs:$Rd),
307 (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
308 "$Rd = mux($Pu, $Rs, $Rt)", [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
314 let CextOpcode = "mux";
315 let InputType = "reg";
316 let hasSideEffects = 0;
319 let Inst{27-24} = 0b0100;
320 let Inst{20-16} = Rs;
326 def: Pat<(i32 (select (i1 PredRegs:$Pu), (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
327 (C2_mux PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt)>;
329 // Combines the two immediates into a double register.
330 // Increase complexity to make it greater than any complexity of a combine
331 // that involves a register.
333 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
334 isExtentSigned = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 1,
335 AddedComplexity = 75, isCodeGenOnly = 0 in
336 def A2_combineii: ALU32Inst <(outs DoubleRegs:$Rdd), (ins s8Ext:$s8, s8Imm:$S8),
337 "$Rdd = combine(#$s8, #$S8)",
338 [(set (i64 DoubleRegs:$Rdd),
339 (i64 (HexagonCOMBINE(i32 s8ExtPred:$s8), (i32 s8ImmPred:$S8))))]> {
345 let Inst{27-23} = 0b11000;
346 let Inst{22-16} = S8{7-1};
347 let Inst{13} = S8{0};
352 //===----------------------------------------------------------------------===//
353 // Template class for predicated ADD of a reg and an Immediate value.
354 //===----------------------------------------------------------------------===//
355 let hasNewValue = 1, hasSideEffects = 0 in
356 class T_Addri_Pred <bit PredNot, bit PredNew>
357 : ALU32_ri <(outs IntRegs:$Rd),
358 (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
359 !if(PredNot, "if (!$Pu", "if ($Pu")#!if(PredNew,".new) $Rd = ",
360 ") $Rd = ")#"add($Rs, #$s8)"> {
366 let isPredicatedNew = PredNew;
369 let Inst{27-24} = 0b0100;
370 let Inst{23} = PredNot;
371 let Inst{22-21} = Pu;
372 let Inst{20-16} = Rs;
373 let Inst{13} = PredNew;
378 //===----------------------------------------------------------------------===//
379 // A2_addi: Add a signed immediate to a register.
380 //===----------------------------------------------------------------------===//
381 let hasNewValue = 1, hasSideEffects = 0 in
382 class T_Addri <Operand immOp, list<dag> pattern = [] >
383 : ALU32_ri <(outs IntRegs:$Rd),
384 (ins IntRegs:$Rs, immOp:$s16),
385 "$Rd = add($Rs, #$s16)", pattern,
386 //[(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs), (s16ExtPred:$s16)))],
387 "", ALU32_ADDI_tc_1_SLOT0123> {
394 let Inst{27-21} = s16{15-9};
395 let Inst{20-16} = Rs;
396 let Inst{13-5} = s16{8-0};
400 //===----------------------------------------------------------------------===//
401 // Multiclass for ADD of a register and an immediate value.
402 //===----------------------------------------------------------------------===//
403 multiclass Addri_Pred<string mnemonic, bit PredNot> {
404 let isPredicatedFalse = PredNot in {
405 def _c#NAME : T_Addri_Pred<PredNot, 0>;
407 def _cdn#NAME : T_Addri_Pred<PredNot, 1>;
411 let isExtendable = 1, InputType = "imm" in
412 multiclass Addri_base<string mnemonic, SDNode OpNode> {
413 let CextOpcode = mnemonic, BaseOpcode = mnemonic#_ri in {
414 let opExtendable = 2, isExtentSigned = 1, opExtentBits = 16,
416 def NAME : T_Addri< s16Ext, // Rd=add(Rs,#s16)
417 [(set (i32 IntRegs:$Rd),
418 (add IntRegs:$Rs, s16ExtPred:$s16))]>;
420 let opExtendable = 3, isExtentSigned = 1, opExtentBits = 8,
421 hasSideEffects = 0, isPredicated = 1 in {
422 defm Pt : Addri_Pred<mnemonic, 0>;
423 defm NotPt : Addri_Pred<mnemonic, 1>;
428 let isCodeGenOnly = 0 in
429 defm ADD_ri : Addri_base<"add", add>, ImmRegRel, PredNewRel;
431 //===----------------------------------------------------------------------===//
432 // Template class used for the following ALU32 instructions.
435 //===----------------------------------------------------------------------===//
436 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 10,
437 InputType = "imm", hasNewValue = 1 in
438 class T_ALU32ri_logical <string mnemonic, SDNode OpNode, bits<2> MinOp>
439 : ALU32_ri <(outs IntRegs:$Rd),
440 (ins IntRegs:$Rs, s10Ext:$s10),
441 "$Rd = "#mnemonic#"($Rs, #$s10)" ,
442 [(set (i32 IntRegs:$Rd), (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10))]> {
446 let CextOpcode = mnemonic;
450 let Inst{27-24} = 0b0110;
451 let Inst{23-22} = MinOp;
452 let Inst{21} = s10{9};
453 let Inst{20-16} = Rs;
454 let Inst{13-5} = s10{8-0};
458 let isCodeGenOnly = 0 in {
459 def OR_ri : T_ALU32ri_logical<"or", or, 0b10>, ImmRegRel;
460 def AND_ri : T_ALU32ri_logical<"and", and, 0b00>, ImmRegRel;
463 // Subtract register from immediate
464 // Rd32=sub(#s10,Rs32)
465 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 10,
466 CextOpcode = "sub", InputType = "imm", hasNewValue = 1, isCodeGenOnly = 0 in
467 def SUB_ri: ALU32_ri <(outs IntRegs:$Rd), (ins s10Ext:$s10, IntRegs:$Rs),
468 "$Rd = sub(#$s10, $Rs)" ,
469 [(set IntRegs:$Rd, (sub s10ExtPred:$s10, IntRegs:$Rs))] > ,
477 let Inst{27-22} = 0b011001;
478 let Inst{21} = s10{9};
479 let Inst{20-16} = Rs;
480 let Inst{13-5} = s10{8-0};
485 let hasSideEffects = 0, isCodeGenOnly = 0 in
486 def A2_nop: ALU32Inst <(outs), (ins), "nop" > {
488 let Inst{27-24} = 0b1111;
490 // Rd = not(Rs) gets mapped to Rd=sub(#-1, Rs).
491 def : Pat<(not (i32 IntRegs:$src1)),
492 (SUB_ri -1, (i32 IntRegs:$src1))>;
494 let hasSideEffects = 0, hasNewValue = 1 in
495 class T_tfr16<bit isHi>
496 : ALU32Inst <(outs IntRegs:$Rx), (ins IntRegs:$src1, u16Imm:$u16),
497 "$Rx"#!if(isHi, ".h", ".l")#" = #$u16",
498 [], "$src1 = $Rx" > {
503 let Inst{27-26} = 0b00;
504 let Inst{25-24} = !if(isHi, 0b10, 0b01);
505 let Inst{23-22} = u16{15-14};
507 let Inst{20-16} = Rx;
508 let Inst{13-0} = u16{13-0};
511 let isCodeGenOnly = 0 in {
512 def A2_tfril: T_tfr16<0>;
513 def A2_tfrih: T_tfr16<1>;
516 // Conditional transfer is an alias to conditional "Rd = add(Rs, #0)".
517 let isPredicated = 1, hasNewValue = 1, opNewValue = 0 in
518 class T_tfr_pred<bit isPredNot, bit isPredNew>
519 : ALU32Inst<(outs IntRegs:$dst),
520 (ins PredRegs:$src1, IntRegs:$src2),
521 "if ("#!if(isPredNot, "!", "")#
522 "$src1"#!if(isPredNew, ".new", "")#
528 let isPredicatedFalse = isPredNot;
529 let isPredicatedNew = isPredNew;
532 let Inst{27-24} = 0b0100;
533 let Inst{23} = isPredNot;
534 let Inst{13} = isPredNew;
537 let Inst{22-21} = src1;
538 let Inst{20-16} = src2;
541 let isPredicable = 1 in
542 class T_tfr : ALU32Inst<(outs IntRegs:$dst), (ins IntRegs:$src),
549 let Inst{27-21} = 0b0000011;
550 let Inst{20-16} = src;
555 let InputType = "reg", hasNewValue = 1, hasSideEffects = 0 in
556 multiclass tfr_base<string CextOp> {
557 let CextOpcode = CextOp, BaseOpcode = CextOp in {
561 def t : T_tfr_pred<0, 0>;
562 def f : T_tfr_pred<1, 0>;
564 def tnew : T_tfr_pred<0, 1>;
565 def fnew : T_tfr_pred<1, 1>;
569 // Assembler mapped to C2_ccombinew[t|f|newt|newf].
570 // Please don't add bits to this instruction as it'll be converted into
571 // 'combine' before object code emission.
572 let isPredicated = 1 in
573 class T_tfrp_pred<bit PredNot, bit PredNew>
574 : ALU32_rr <(outs DoubleRegs:$dst),
575 (ins PredRegs:$src1, DoubleRegs:$src2),
576 "if ("#!if(PredNot, "!", "")#"$src1"
577 #!if(PredNew, ".new", "")#") $dst = $src2" > {
578 let isPredicatedFalse = PredNot;
579 let isPredicatedNew = PredNew;
582 // Assembler mapped to A2_combinew.
583 // Please don't add bits to this instruction as it'll be converted into
584 // 'combine' before object code emission.
585 class T_tfrp : ALU32Inst <(outs DoubleRegs:$dst),
586 (ins DoubleRegs:$src),
589 let hasSideEffects = 0 in
590 multiclass TFR64_base<string BaseName> {
591 let BaseOpcode = BaseName in {
592 let isPredicable = 1 in
595 def t : T_tfrp_pred <0, 0>;
596 def f : T_tfrp_pred <1, 0>;
598 def tnew : T_tfrp_pred <0, 1>;
599 def fnew : T_tfrp_pred <1, 1>;
603 let InputType = "imm", isExtendable = 1, isExtentSigned = 1, opExtentBits = 12,
604 isMoveImm = 1, opExtendable = 2, BaseOpcode = "TFRI", CextOpcode = "TFR",
605 hasSideEffects = 0, isPredicated = 1, hasNewValue = 1 in
606 class T_TFRI_Pred<bit PredNot, bit PredNew>
607 : ALU32_ri<(outs IntRegs:$Rd), (ins PredRegs:$Pu, s12Ext:$s12),
608 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") $Rd = #$s12",
609 [], "", ALU32_2op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
610 let isPredicatedFalse = PredNot;
611 let isPredicatedNew = PredNew;
618 let Inst{27-24} = 0b1110;
619 let Inst{23} = PredNot;
620 let Inst{22-21} = Pu;
622 let Inst{19-16,12-5} = s12;
623 let Inst{13} = PredNew;
627 let isCodeGenOnly = 0 in {
628 def C2_cmoveit : T_TFRI_Pred<0, 0>;
629 def C2_cmoveif : T_TFRI_Pred<1, 0>;
630 def C2_cmovenewit : T_TFRI_Pred<0, 1>;
631 def C2_cmovenewif : T_TFRI_Pred<1, 1>;
634 let InputType = "imm", isExtendable = 1, isExtentSigned = 1,
635 CextOpcode = "TFR", BaseOpcode = "TFRI", hasNewValue = 1, opNewValue = 0,
636 isAsCheapAsAMove = 1 , opExtendable = 1, opExtentBits = 16, isMoveImm = 1,
637 isPredicated = 0, isPredicable = 1, isReMaterializable = 1,
639 def A2_tfrsi : ALU32Inst<(outs IntRegs:$Rd), (ins s16Ext:$s16), "$Rd = #$s16",
640 [(set (i32 IntRegs:$Rd), s16ExtPred:$s16)], "", ALU32_2op_tc_1_SLOT0123>,
646 let Inst{27-24} = 0b1000;
647 let Inst{23-22,20-16,13-5} = s16;
651 let isCodeGenOnly = 0 in
652 defm A2_tfr : tfr_base<"TFR">, ImmRegRel, PredNewRel;
653 defm A2_tfrp : TFR64_base<"TFR64">, PredNewRel;
656 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1 in
657 def A2_tfrpi : ALU64_rr<(outs DoubleRegs:$dst), (ins s8Imm64:$src1),
659 [(set (i64 DoubleRegs:$dst), s8Imm64Pred:$src1)]>;
661 // TODO: see if this instruction can be deleted..
662 let isExtendable = 1, opExtendable = 1, opExtentBits = 6 in
663 def TFRI64_V4 : ALU64_rr<(outs DoubleRegs:$dst), (ins u6Ext:$src1),
666 //===----------------------------------------------------------------------===//
668 //===----------------------------------------------------------------------===//
671 //===----------------------------------------------------------------------===//
673 //===----------------------------------------------------------------------===//
674 // Scalar mux register immediate.
675 let hasSideEffects = 0, isExtentSigned = 1, CextOpcode = "MUX",
676 InputType = "imm", hasNewValue = 1, isExtendable = 1, opExtentBits = 8 in
677 class T_MUX1 <bit MajOp, dag ins, string AsmStr>
678 : ALU32Inst <(outs IntRegs:$Rd), ins, AsmStr>, ImmRegRel {
685 let Inst{27-24} = 0b0011;
686 let Inst{23} = MajOp;
687 let Inst{22-21} = Pu;
688 let Inst{20-16} = Rs;
694 let opExtendable = 2, isCodeGenOnly = 0 in
695 def C2_muxri : T_MUX1<0b1, (ins PredRegs:$Pu, s8Ext:$s8, IntRegs:$Rs),
696 "$Rd = mux($Pu, #$s8, $Rs)">;
698 let opExtendable = 3, isCodeGenOnly = 0 in
699 def C2_muxir : T_MUX1<0b0, (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
700 "$Rd = mux($Pu, $Rs, #$s8)">;
702 def : Pat<(i32 (select I1:$Pu, s8ExtPred:$s8, I32:$Rs)),
703 (C2_muxri I1:$Pu, s8ExtPred:$s8, I32:$Rs)>;
705 def : Pat<(i32 (select I1:$Pu, I32:$Rs, s8ExtPred:$s8)),
706 (C2_muxir I1:$Pu, I32:$Rs, s8ExtPred:$s8)>;
708 // C2_muxii: Scalar mux immediates.
709 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1,
710 opExtentBits = 8, opExtendable = 2, isCodeGenOnly = 0 in
711 def C2_muxii: ALU32Inst <(outs IntRegs:$Rd),
712 (ins PredRegs:$Pu, s8Ext:$s8, s8Imm:$S8),
713 "$Rd = mux($Pu, #$s8, #$S8)" ,
714 [(set (i32 IntRegs:$Rd),
715 (i32 (select I1:$Pu, s8ExtPred:$s8, s8ImmPred:$S8)))] > {
723 let Inst{27-25} = 0b101;
724 let Inst{24-23} = Pu;
725 let Inst{22-16} = S8{7-1};
726 let Inst{13} = S8{0};
731 //===----------------------------------------------------------------------===//
732 // template class for non-predicated alu32_2op instructions
733 // - aslh, asrh, sxtb, sxth, zxth
734 //===----------------------------------------------------------------------===//
735 let hasNewValue = 1, opNewValue = 0 in
736 class T_ALU32_2op <string mnemonic, bits<3> minOp> :
737 ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
738 "$Rd = "#mnemonic#"($Rs)", [] > {
744 let Inst{27-24} = 0b0000;
745 let Inst{23-21} = minOp;
748 let Inst{20-16} = Rs;
751 //===----------------------------------------------------------------------===//
752 // template class for predicated alu32_2op instructions
753 // - aslh, asrh, sxtb, sxth, zxtb, zxth
754 //===----------------------------------------------------------------------===//
755 let hasSideEffects = 0, validSubTargets = HasV4SubT,
756 hasNewValue = 1, opNewValue = 0 in
757 class T_ALU32_2op_Pred <string mnemonic, bits<3> minOp, bit isPredNot,
759 ALU32Inst <(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs),
760 !if(isPredNot, "if (!$Pu", "if ($Pu")
761 #!if(isPredNew, ".new) ",") ")#"$Rd = "#mnemonic#"($Rs)"> {
768 let Inst{27-24} = 0b0000;
769 let Inst{23-21} = minOp;
771 let Inst{11} = isPredNot;
772 let Inst{10} = isPredNew;
775 let Inst{20-16} = Rs;
778 multiclass ALU32_2op_Pred<string mnemonic, bits<3> minOp, bit PredNot> {
779 let isPredicatedFalse = PredNot in {
780 def NAME : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 0>;
783 let isPredicatedNew = 1 in
784 def NAME#new : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 1>;
788 multiclass ALU32_2op_base<string mnemonic, bits<3> minOp> {
789 let BaseOpcode = mnemonic in {
790 let isPredicable = 1, hasSideEffects = 0 in
791 def A2_#NAME : T_ALU32_2op<mnemonic, minOp>;
793 let validSubTargets = HasV4SubT, isPredicated = 1, hasSideEffects = 0 in {
794 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
795 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
800 let isCodeGenOnly = 0 in {
801 defm aslh : ALU32_2op_base<"aslh", 0b000>, PredNewRel;
802 defm asrh : ALU32_2op_base<"asrh", 0b001>, PredNewRel;
803 defm sxtb : ALU32_2op_base<"sxtb", 0b101>, PredNewRel;
804 defm sxth : ALU32_2op_base<"sxth", 0b111>, PredNewRel;
805 defm zxth : ALU32_2op_base<"zxth", 0b110>, PredNewRel;
808 // Rd=zxtb(Rs): assembler mapped to Rd=and(Rs,#255).
809 // Compiler would want to generate 'zxtb' instead of 'and' becuase 'zxtb' has
810 // predicated forms while 'and' doesn't. Since integrated assembler can't
811 // handle 'mapped' instructions, we need to encode 'zxtb' same as 'and' where
812 // immediate operand is set to '255'.
814 let hasNewValue = 1, opNewValue = 0 in
815 class T_ZXTB: ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
816 "$Rd = zxtb($Rs)", [] > { // Rd = and(Rs,255)
823 let Inst{27-22} = 0b011000;
825 let Inst{20-16} = Rs;
826 let Inst{21} = s10{9};
827 let Inst{13-5} = s10{8-0};
830 //Rd=zxtb(Rs): assembler mapped to "Rd=and(Rs,#255)
831 multiclass ZXTB_base <string mnemonic, bits<3> minOp> {
832 let BaseOpcode = mnemonic in {
833 let isPredicable = 1, hasSideEffects = 0 in
834 def A2_#NAME : T_ZXTB;
836 let validSubTargets = HasV4SubT, isPredicated = 1, hasSideEffects = 0 in {
837 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
838 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
843 let isCodeGenOnly=0 in
844 defm zxtb : ZXTB_base<"zxtb",0b100>, PredNewRel;
846 def: Pat<(shl I32:$src1, (i32 16)), (A2_aslh I32:$src1)>;
847 def: Pat<(sra I32:$src1, (i32 16)), (A2_asrh I32:$src1)>;
848 def: Pat<(sext_inreg I32:$src1, i8), (A2_sxtb I32:$src1)>;
849 def: Pat<(sext_inreg I32:$src1, i16), (A2_sxth I32:$src1)>;
851 //===----------------------------------------------------------------------===//
852 // Template class for vector add and avg
853 //===----------------------------------------------------------------------===//
855 class T_VectALU_64 <string opc, bits<3> majOp, bits<3> minOp,
856 bit isSat, bit isRnd, bit isCrnd, bit SwapOps >
857 : ALU64_rr < (outs DoubleRegs:$Rdd),
858 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
859 "$Rdd = "#opc#"($Rss, $Rtt)"#!if(isRnd, ":rnd", "")
860 #!if(isCrnd,":crnd","")
861 #!if(isSat, ":sat", ""),
862 [], "", ALU64_tc_2_SLOT23 > {
869 let Inst{27-24} = 0b0011;
870 let Inst{23-21} = majOp;
871 let Inst{20-16} = !if (SwapOps, Rtt, Rss);
872 let Inst{12-8} = !if (SwapOps, Rss, Rtt);
873 let Inst{7-5} = minOp;
877 // ALU64 - Vector add
878 // Rdd=vadd[u][bhw](Rss,Rtt)
879 let Itinerary = ALU64_tc_1_SLOT23, isCodeGenOnly = 0 in {
880 def A2_vaddub : T_VectALU_64 < "vaddub", 0b000, 0b000, 0, 0, 0, 0>;
881 def A2_vaddh : T_VectALU_64 < "vaddh", 0b000, 0b010, 0, 0, 0, 0>;
882 def A2_vaddw : T_VectALU_64 < "vaddw", 0b000, 0b101, 0, 0, 0, 0>;
885 // Rdd=vadd[u][bhw](Rss,Rtt):sat
886 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
887 def A2_vaddubs : T_VectALU_64 < "vaddub", 0b000, 0b001, 1, 0, 0, 0>;
888 def A2_vaddhs : T_VectALU_64 < "vaddh", 0b000, 0b011, 1, 0, 0, 0>;
889 def A2_vadduhs : T_VectALU_64 < "vadduh", 0b000, 0b100, 1, 0, 0, 0>;
890 def A2_vaddws : T_VectALU_64 < "vaddw", 0b000, 0b110, 1, 0, 0, 0>;
893 // ALU64 - Vector average
894 // Rdd=vavg[u][bhw](Rss,Rtt)
895 let Itinerary = ALU64_tc_1_SLOT23, isCodeGenOnly = 0 in {
896 def A2_vavgub : T_VectALU_64 < "vavgub", 0b010, 0b000, 0, 0, 0, 0>;
897 def A2_vavgh : T_VectALU_64 < "vavgh", 0b010, 0b010, 0, 0, 0, 0>;
898 def A2_vavguh : T_VectALU_64 < "vavguh", 0b010, 0b101, 0, 0, 0, 0>;
899 def A2_vavgw : T_VectALU_64 < "vavgw", 0b011, 0b000, 0, 0, 0, 0>;
900 def A2_vavguw : T_VectALU_64 < "vavguw", 0b011, 0b011, 0, 0, 0, 0>;
903 // Rdd=vavg[u][bhw](Rss,Rtt)[:rnd|:crnd]
904 let isCodeGenOnly = 0 in {
905 def A2_vavgubr : T_VectALU_64 < "vavgub", 0b010, 0b001, 0, 1, 0, 0>;
906 def A2_vavghr : T_VectALU_64 < "vavgh", 0b010, 0b011, 0, 1, 0, 0>;
907 def A2_vavghcr : T_VectALU_64 < "vavgh", 0b010, 0b100, 0, 0, 1, 0>;
908 def A2_vavguhr : T_VectALU_64 < "vavguh", 0b010, 0b110, 0, 1, 0, 0>;
911 let isCodeGenOnly = 0 in {
912 def A2_vavgwr : T_VectALU_64 < "vavgw", 0b011, 0b001, 0, 1, 0, 0>;
913 def A2_vavgwcr : T_VectALU_64 < "vavgw", 0b011, 0b010, 0, 0, 1, 0>;
914 def A2_vavguwr : T_VectALU_64 < "vavguw", 0b011, 0b100, 0, 1, 0, 0>;
917 // Rdd=vnavg[bh](Rss,Rtt)
918 let Itinerary = ALU64_tc_1_SLOT23, isCodeGenOnly = 0 in {
919 def A2_vnavgh : T_VectALU_64 < "vnavgh", 0b100, 0b000, 0, 0, 0, 1>;
920 def A2_vnavgw : T_VectALU_64 < "vnavgw", 0b100, 0b011, 0, 0, 0, 1>;
923 // Rdd=vnavg[bh](Rss,Rtt)[:rnd|:crnd]:sat
924 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
925 def A2_vnavghr : T_VectALU_64 < "vnavgh", 0b100, 0b001, 1, 1, 0, 1>;
926 def A2_vnavghcr : T_VectALU_64 < "vnavgh", 0b100, 0b010, 1, 0, 1, 1>;
927 def A2_vnavgwr : T_VectALU_64 < "vnavgw", 0b100, 0b100, 1, 1, 0, 1>;
928 def A2_vnavgwcr : T_VectALU_64 < "vnavgw", 0b100, 0b110, 1, 0, 1, 1>;
931 // Rdd=vsub[u][bh](Rss,Rtt)
932 let Itinerary = ALU64_tc_1_SLOT23, isCodeGenOnly = 0 in {
933 def A2_vsubub : T_VectALU_64 < "vsubub", 0b001, 0b000, 0, 0, 0, 1>;
934 def A2_vsubh : T_VectALU_64 < "vsubh", 0b001, 0b010, 0, 0, 0, 1>;
935 def A2_vsubw : T_VectALU_64 < "vsubw", 0b001, 0b101, 0, 0, 0, 1>;
938 // Rdd=vsub[u][bh](Rss,Rtt):sat
939 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
940 def A2_vsububs : T_VectALU_64 < "vsubub", 0b001, 0b001, 1, 0, 0, 1>;
941 def A2_vsubhs : T_VectALU_64 < "vsubh", 0b001, 0b011, 1, 0, 0, 1>;
942 def A2_vsubuhs : T_VectALU_64 < "vsubuh", 0b001, 0b100, 1, 0, 0, 1>;
943 def A2_vsubws : T_VectALU_64 < "vsubw", 0b001, 0b110, 1, 0, 0, 1>;
946 // Rdd=vmax[u][bhw](Rss,Rtt)
947 let isCodeGenOnly = 0 in {
948 def A2_vmaxb : T_VectALU_64 < "vmaxb", 0b110, 0b110, 0, 0, 0, 1>;
949 def A2_vmaxub : T_VectALU_64 < "vmaxub", 0b110, 0b000, 0, 0, 0, 1>;
950 def A2_vmaxh : T_VectALU_64 < "vmaxh", 0b110, 0b001, 0, 0, 0, 1>;
951 def A2_vmaxuh : T_VectALU_64 < "vmaxuh", 0b110, 0b010, 0, 0, 0, 1>;
952 def A2_vmaxw : T_VectALU_64 < "vmaxw", 0b110, 0b011, 0, 0, 0, 1>;
953 def A2_vmaxuw : T_VectALU_64 < "vmaxuw", 0b101, 0b101, 0, 0, 0, 1>;
956 // Rdd=vmin[u][bhw](Rss,Rtt)
957 let isCodeGenOnly = 0 in {
958 def A2_vminb : T_VectALU_64 < "vminb", 0b110, 0b111, 0, 0, 0, 1>;
959 def A2_vminub : T_VectALU_64 < "vminub", 0b101, 0b000, 0, 0, 0, 1>;
960 def A2_vminh : T_VectALU_64 < "vminh", 0b101, 0b001, 0, 0, 0, 1>;
961 def A2_vminuh : T_VectALU_64 < "vminuh", 0b101, 0b010, 0, 0, 0, 1>;
962 def A2_vminw : T_VectALU_64 < "vminw", 0b101, 0b011, 0, 0, 0, 1>;
963 def A2_vminuw : T_VectALU_64 < "vminuw", 0b101, 0b100, 0, 0, 0, 1>;
966 //===----------------------------------------------------------------------===//
967 // Template class for vector compare
968 //===----------------------------------------------------------------------===//
969 let hasSideEffects = 0 in
970 class T_vcmp <string Str, bits<4> minOp>
971 : ALU64_rr <(outs PredRegs:$Pd),
972 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
973 "$Pd = "#Str#"($Rss, $Rtt)", [],
974 "", ALU64_tc_2early_SLOT23> {
981 let Inst{27-23} = 0b00100;
982 let Inst{13} = minOp{3};
983 let Inst{7-5} = minOp{2-0};
985 let Inst{20-16} = Rss;
986 let Inst{12-8} = Rtt;
989 class T_vcmp_pat<InstHexagon MI, PatFrag Op, ValueType T>
990 : Pat<(i1 (Op (T DoubleRegs:$Rss), (T DoubleRegs:$Rtt))),
991 (i1 (MI DoubleRegs:$Rss, DoubleRegs:$Rtt))>;
993 // Vector compare bytes
994 let isCodeGenOnly = 0 in {
995 def A2_vcmpbeq : T_vcmp <"vcmpb.eq", 0b0110>;
996 def A2_vcmpbgtu : T_vcmp <"vcmpb.gtu", 0b0111>;
999 // Vector compare halfwords
1000 let isCodeGenOnly = 0 in {
1001 def A2_vcmpheq : T_vcmp <"vcmph.eq", 0b0011>;
1002 def A2_vcmphgt : T_vcmp <"vcmph.gt", 0b0100>;
1003 def A2_vcmphgtu : T_vcmp <"vcmph.gtu", 0b0101>;
1006 // Vector compare words
1007 let isCodeGenOnly = 0 in {
1008 def A2_vcmpweq : T_vcmp <"vcmpw.eq", 0b0000>;
1009 def A2_vcmpwgt : T_vcmp <"vcmpw.gt", 0b0001>;
1010 def A2_vcmpwgtu : T_vcmp <"vcmpw.gtu", 0b0010>;
1013 def: T_vcmp_pat<A2_vcmpbeq, seteq, v8i8>;
1014 def: T_vcmp_pat<A2_vcmpbgtu, setugt, v8i8>;
1015 def: T_vcmp_pat<A2_vcmpheq, seteq, v4i16>;
1016 def: T_vcmp_pat<A2_vcmphgt, setgt, v4i16>;
1017 def: T_vcmp_pat<A2_vcmphgtu, setugt, v4i16>;
1018 def: T_vcmp_pat<A2_vcmpweq, seteq, v2i32>;
1019 def: T_vcmp_pat<A2_vcmpwgt, setgt, v2i32>;
1020 def: T_vcmp_pat<A2_vcmpwgtu, setugt, v2i32>;
1022 //===----------------------------------------------------------------------===//
1024 //===----------------------------------------------------------------------===//
1027 //===----------------------------------------------------------------------===//
1029 //===----------------------------------------------------------------------===//
1031 //===----------------------------------------------------------------------===//
1033 //===----------------------------------------------------------------------===//
1036 //===----------------------------------------------------------------------===//
1038 //===----------------------------------------------------------------------===//// Add.
1039 //===----------------------------------------------------------------------===//
1041 // Add/Subtract halfword
1042 // Rd=add(Rt.L,Rs.[HL])[:sat]
1043 // Rd=sub(Rt.L,Rs.[HL])[:sat]
1044 // Rd=add(Rt.[LH],Rs.[HL])[:sat][:<16]
1045 // Rd=sub(Rt.[LH],Rs.[HL])[:sat][:<16]
1046 //===----------------------------------------------------------------------===//
1048 let hasNewValue = 1, opNewValue = 0 in
1049 class T_XTYPE_ADD_SUB <bits<2> LHbits, bit isSat, bit hasShift, bit isSub>
1050 : ALU64Inst <(outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
1051 "$Rd = "#!if(isSub,"sub","add")#"($Rt."
1052 #!if(hasShift, !if(LHbits{1},"h","l"),"l") #", $Rs."
1053 #!if(hasShift, !if(LHbits{0},"h)","l)"), !if(LHbits{1},"h)","l)"))
1054 #!if(isSat,":sat","")
1055 #!if(hasShift,":<<16",""), [], "", ALU64_tc_1_SLOT23> {
1059 let IClass = 0b1101;
1061 let Inst{27-23} = 0b01010;
1062 let Inst{22} = hasShift;
1063 let Inst{21} = isSub;
1064 let Inst{7} = isSat;
1065 let Inst{6-5} = LHbits;
1067 let Inst{12-8} = Rt;
1068 let Inst{20-16} = Rs;
1071 //Rd=sub(Rt.L,Rs.[LH])
1072 let isCodeGenOnly = 0 in {
1073 def A2_subh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 1>;
1074 def A2_subh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 1>;
1077 let isCodeGenOnly = 0 in {
1078 //Rd=add(Rt.L,Rs.[LH])
1079 def A2_addh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 0>;
1080 def A2_addh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 0>;
1083 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF], isCodeGenOnly = 0 in {
1084 //Rd=sub(Rt.L,Rs.[LH]):sat
1085 def A2_subh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 1>;
1086 def A2_subh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 1>;
1088 //Rd=add(Rt.L,Rs.[LH]):sat
1089 def A2_addh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 0>;
1090 def A2_addh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 0>;
1093 //Rd=sub(Rt.[LH],Rs.[LH]):<<16
1094 let isCodeGenOnly = 0 in {
1095 def A2_subh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 1>;
1096 def A2_subh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 1>;
1097 def A2_subh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 1>;
1098 def A2_subh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 1>;
1101 //Rd=add(Rt.[LH],Rs.[LH]):<<16
1102 let isCodeGenOnly = 0 in {
1103 def A2_addh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 0>;
1104 def A2_addh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 0>;
1105 def A2_addh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 0>;
1106 def A2_addh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 0>;
1109 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF], isCodeGenOnly = 0 in {
1110 //Rd=sub(Rt.[LH],Rs.[LH]):sat:<<16
1111 def A2_subh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 1>;
1112 def A2_subh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 1>;
1113 def A2_subh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 1>;
1114 def A2_subh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 1>;
1116 //Rd=add(Rt.[LH],Rs.[LH]):sat:<<16
1117 def A2_addh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 0>;
1118 def A2_addh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 0>;
1119 def A2_addh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 0>;
1120 def A2_addh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 0>;
1124 def: Pat<(sext_inreg (add I32:$src1, I32:$src2), i16),
1125 (A2_addh_l16_ll I32:$src1, I32:$src2)>;
1127 def: Pat<(sra (add (shl I32:$src1, (i32 16)), I32:$src2), (i32 16)),
1128 (A2_addh_l16_hl I32:$src1, I32:$src2)>;
1130 def: Pat<(shl (add I32:$src1, I32:$src2), (i32 16)),
1131 (A2_addh_h16_ll I32:$src1, I32:$src2)>;
1133 // Subtract halfword.
1134 def: Pat<(sext_inreg (sub I32:$src1, I32:$src2), i16),
1135 (A2_subh_l16_ll I32:$src1, I32:$src2)>;
1137 def: Pat<(shl (sub I32:$src1, I32:$src2), (i32 16)),
1138 (A2_subh_h16_ll I32:$src1, I32:$src2)>;
1140 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
1141 def S2_parityp: ALU64Inst<(outs IntRegs:$Rd),
1142 (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1143 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1148 let IClass = 0b1101;
1149 let Inst{27-24} = 0b0000;
1150 let Inst{20-16} = Rs;
1151 let Inst{12-8} = Rt;
1155 let hasNewValue = 1, opNewValue = 0, hasSideEffects = 0 in
1156 class T_XTYPE_MIN_MAX < bit isMax, bit isUnsigned >
1157 : ALU64Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
1158 "$Rd = "#!if(isMax,"max","min")#!if(isUnsigned,"u","")
1159 #"($Rt, $Rs)", [], "", ALU64_tc_2_SLOT23> {
1164 let IClass = 0b1101;
1166 let Inst{27-23} = 0b01011;
1167 let Inst{22-21} = !if(isMax, 0b10, 0b01);
1168 let Inst{7} = isUnsigned;
1170 let Inst{12-8} = !if(isMax, Rs, Rt);
1171 let Inst{20-16} = !if(isMax, Rt, Rs);
1174 let isCodeGenOnly = 0 in {
1175 def A2_min : T_XTYPE_MIN_MAX < 0, 0 >;
1176 def A2_minu : T_XTYPE_MIN_MAX < 0, 1 >;
1177 def A2_max : T_XTYPE_MIN_MAX < 1, 0 >;
1178 def A2_maxu : T_XTYPE_MIN_MAX < 1, 1 >;
1181 // Here, depending on the operand being selected, we'll either generate a
1182 // min or max instruction.
1184 // (a>b)?a:b --> max(a,b) => Here check performed is '>' and the value selected
1185 // is the larger of two. So, the corresponding HexagonInst is passed in 'Inst'.
1186 // (a>b)?b:a --> min(a,b) => Here check performed is '>' but the smaller value
1187 // is selected and the corresponding HexagonInst is passed in 'SwapInst'.
1189 multiclass T_MinMax_pats <PatFrag Op, RegisterClass RC, ValueType VT,
1190 InstHexagon Inst, InstHexagon SwapInst> {
1191 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1192 (VT RC:$src1), (VT RC:$src2)),
1193 (Inst RC:$src1, RC:$src2)>;
1194 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1195 (VT RC:$src2), (VT RC:$src1)),
1196 (SwapInst RC:$src1, RC:$src2)>;
1200 multiclass MinMax_pats <PatFrag Op, InstHexagon Inst, InstHexagon SwapInst> {
1201 defm: T_MinMax_pats<Op, IntRegs, i32, Inst, SwapInst>;
1203 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1204 (i32 PositiveHalfWord:$src2))),
1205 (i32 PositiveHalfWord:$src1),
1206 (i32 PositiveHalfWord:$src2))), i16),
1207 (Inst IntRegs:$src1, IntRegs:$src2)>;
1209 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1210 (i32 PositiveHalfWord:$src2))),
1211 (i32 PositiveHalfWord:$src2),
1212 (i32 PositiveHalfWord:$src1))), i16),
1213 (SwapInst IntRegs:$src1, IntRegs:$src2)>;
1216 let AddedComplexity = 200 in {
1217 defm: MinMax_pats<setge, A2_max, A2_min>;
1218 defm: MinMax_pats<setgt, A2_max, A2_min>;
1219 defm: MinMax_pats<setle, A2_min, A2_max>;
1220 defm: MinMax_pats<setlt, A2_min, A2_max>;
1221 defm: MinMax_pats<setuge, A2_maxu, A2_minu>;
1222 defm: MinMax_pats<setugt, A2_maxu, A2_minu>;
1223 defm: MinMax_pats<setule, A2_minu, A2_maxu>;
1224 defm: MinMax_pats<setult, A2_minu, A2_maxu>;
1227 class T_cmp64_rr<string mnemonic, bits<3> MinOp, bit IsComm>
1228 : ALU64_rr<(outs PredRegs:$Pd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1229 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", ALU64_tc_2early_SLOT23> {
1231 let isCommutable = IsComm;
1232 let hasSideEffects = 0;
1238 let IClass = 0b1101;
1239 let Inst{27-21} = 0b0010100;
1240 let Inst{20-16} = Rs;
1241 let Inst{12-8} = Rt;
1242 let Inst{7-5} = MinOp;
1246 let isCodeGenOnly = 0 in {
1247 def C2_cmpeqp : T_cmp64_rr<"cmp.eq", 0b000, 1>;
1248 def C2_cmpgtp : T_cmp64_rr<"cmp.gt", 0b010, 0>;
1249 def C2_cmpgtup : T_cmp64_rr<"cmp.gtu", 0b100, 0>;
1252 class T_cmp64_rr_pat<InstHexagon MI, PatFrag CmpOp>
1253 : Pat<(i1 (CmpOp (i64 DoubleRegs:$Rs), (i64 DoubleRegs:$Rt))),
1254 (i1 (MI DoubleRegs:$Rs, DoubleRegs:$Rt))>;
1256 def: T_cmp64_rr_pat<C2_cmpeqp, seteq>;
1257 def: T_cmp64_rr_pat<C2_cmpgtp, setgt>;
1258 def: T_cmp64_rr_pat<C2_cmpgtup, setugt>;
1259 def: T_cmp64_rr_pat<C2_cmpgtp, RevCmp<setlt>>;
1260 def: T_cmp64_rr_pat<C2_cmpgtup, RevCmp<setult>>;
1262 let isCodeGenOnly = 0 in
1263 def C2_vmux : ALU64_rr<(outs DoubleRegs:$Rd),
1264 (ins PredRegs:$Pu, DoubleRegs:$Rs, DoubleRegs:$Rt),
1265 "$Rd = vmux($Pu, $Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
1266 let hasSideEffects = 0;
1273 let IClass = 0b1101;
1274 let Inst{27-24} = 0b0001;
1275 let Inst{20-16} = Rs;
1276 let Inst{12-8} = Rt;
1281 class T_ALU64_rr<string mnemonic, string suffix, bits<4> RegType,
1282 bits<3> MajOp, bits<3> MinOp, bit OpsRev, bit IsComm,
1284 : ALU64_rr<(outs DoubleRegs:$Rd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1285 "$Rd = " #mnemonic# "($Rs, " #Op2Pfx# "$Rt)" #suffix, [],
1286 "", ALU64_tc_1_SLOT23> {
1287 let hasSideEffects = 0;
1288 let isCommutable = IsComm;
1294 let IClass = 0b1101;
1295 let Inst{27-24} = RegType;
1296 let Inst{23-21} = MajOp;
1297 let Inst{20-16} = !if (OpsRev,Rt,Rs);
1298 let Inst{12-8} = !if (OpsRev,Rs,Rt);
1299 let Inst{7-5} = MinOp;
1303 class T_ALU64_arith<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit IsSat,
1304 bit OpsRev, bit IsComm>
1305 : T_ALU64_rr<mnemonic, !if(IsSat,":sat",""), 0b0011, MajOp, MinOp, OpsRev,
1308 let isCodeGenOnly = 0 in {
1309 def A2_addp : T_ALU64_arith<"add", 0b000, 0b111, 0, 0, 1>;
1310 def A2_subp : T_ALU64_arith<"sub", 0b001, 0b111, 0, 1, 0>;
1313 def: Pat<(i64 (add I64:$Rs, I64:$Rt)), (A2_addp I64:$Rs, I64:$Rt)>;
1314 def: Pat<(i64 (sub I64:$Rs, I64:$Rt)), (A2_subp I64:$Rs, I64:$Rt)>;
1316 class T_ALU64_logical<string mnemonic, bits<3> MinOp, bit OpsRev, bit IsComm,
1318 : T_ALU64_rr<mnemonic, "", 0b0011, 0b111, MinOp, OpsRev, IsComm,
1321 let isCodeGenOnly = 0 in {
1322 def A2_andp : T_ALU64_logical<"and", 0b000, 0, 1, 0>;
1323 def A2_orp : T_ALU64_logical<"or", 0b010, 0, 1, 0>;
1324 def A2_xorp : T_ALU64_logical<"xor", 0b100, 0, 1, 0>;
1327 def: Pat<(i64 (and I64:$Rs, I64:$Rt)), (A2_andp I64:$Rs, I64:$Rt)>;
1328 def: Pat<(i64 (or I64:$Rs, I64:$Rt)), (A2_orp I64:$Rs, I64:$Rt)>;
1329 def: Pat<(i64 (xor I64:$Rs, I64:$Rt)), (A2_xorp I64:$Rs, I64:$Rt)>;
1331 //===----------------------------------------------------------------------===//
1333 //===----------------------------------------------------------------------===//
1335 //===----------------------------------------------------------------------===//
1337 //===----------------------------------------------------------------------===//
1339 //===----------------------------------------------------------------------===//
1341 //===----------------------------------------------------------------------===//
1343 //===----------------------------------------------------------------------===//
1345 //===----------------------------------------------------------------------===//
1347 //===----------------------------------------------------------------------===//
1349 //===----------------------------------------------------------------------===//
1351 //===----------------------------------------------------------------------===//
1353 //===----------------------------------------------------------------------===//
1354 // Logical reductions on predicates.
1356 // Looping instructions.
1358 // Pipelined looping instructions.
1360 // Logical operations on predicates.
1361 let hasSideEffects = 0 in
1362 class T_LOGICAL_1OP<string MnOp, bits<2> OpBits>
1363 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps),
1364 "$Pd = " # MnOp # "($Ps)", [], "", CR_tc_2early_SLOT23> {
1368 let IClass = 0b0110;
1369 let Inst{27-23} = 0b10111;
1370 let Inst{22-21} = OpBits;
1372 let Inst{17-16} = Ps;
1377 let isCodeGenOnly = 0 in {
1378 def C2_any8 : T_LOGICAL_1OP<"any8", 0b00>;
1379 def C2_all8 : T_LOGICAL_1OP<"all8", 0b01>;
1380 def C2_not : T_LOGICAL_1OP<"not", 0b10>;
1383 def: Pat<(i1 (not (i1 PredRegs:$Ps))),
1384 (C2_not PredRegs:$Ps)>;
1386 let hasSideEffects = 0 in
1387 class T_LOGICAL_2OP<string MnOp, bits<3> OpBits, bit IsNeg, bit Rev>
1388 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps, PredRegs:$Pt),
1389 "$Pd = " # MnOp # "($Ps, " # !if (IsNeg,"!","") # "$Pt)",
1390 [], "", CR_tc_2early_SLOT23> {
1395 let IClass = 0b0110;
1396 let Inst{27-24} = 0b1011;
1397 let Inst{23-21} = OpBits;
1399 let Inst{17-16} = !if(Rev,Pt,Ps); // Rs and Rt are reversed for some
1400 let Inst{13} = 0b0; // instructions.
1401 let Inst{9-8} = !if(Rev,Ps,Pt);
1405 let isCodeGenOnly = 0 in {
1406 def C2_and : T_LOGICAL_2OP<"and", 0b000, 0, 1>;
1407 def C2_or : T_LOGICAL_2OP<"or", 0b001, 0, 1>;
1408 def C2_xor : T_LOGICAL_2OP<"xor", 0b010, 0, 0>;
1409 def C2_andn : T_LOGICAL_2OP<"and", 0b011, 1, 1>;
1410 def C2_orn : T_LOGICAL_2OP<"or", 0b111, 1, 1>;
1413 def: Pat<(i1 (and I1:$Ps, I1:$Pt)), (C2_and I1:$Ps, I1:$Pt)>;
1414 def: Pat<(i1 (or I1:$Ps, I1:$Pt)), (C2_or I1:$Ps, I1:$Pt)>;
1415 def: Pat<(i1 (xor I1:$Ps, I1:$Pt)), (C2_xor I1:$Ps, I1:$Pt)>;
1416 def: Pat<(i1 (and I1:$Ps, (not I1:$Pt))), (C2_andn I1:$Ps, I1:$Pt)>;
1417 def: Pat<(i1 (or I1:$Ps, (not I1:$Pt))), (C2_orn I1:$Ps, I1:$Pt)>;
1419 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
1420 def C2_vitpack : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps, PredRegs:$Pt),
1421 "$Rd = vitpack($Ps, $Pt)", [], "", S_2op_tc_1_SLOT23> {
1426 let IClass = 0b1000;
1427 let Inst{27-24} = 0b1001;
1428 let Inst{22-21} = 0b00;
1429 let Inst{17-16} = Ps;
1434 let hasSideEffects = 0, isCodeGenOnly = 0 in
1435 def C2_mask : SInst<(outs DoubleRegs:$Rd), (ins PredRegs:$Pt),
1436 "$Rd = mask($Pt)", [], "", S_2op_tc_1_SLOT23> {
1440 let IClass = 0b1000;
1441 let Inst{27-24} = 0b0110;
1446 // User control register transfer.
1447 //===----------------------------------------------------------------------===//
1449 //===----------------------------------------------------------------------===//
1451 //===----------------------------------------------------------------------===//
1453 //===----------------------------------------------------------------------===//
1455 def retflag : SDNode<"HexagonISD::RET_FLAG", SDTNone,
1456 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
1457 def eh_return: SDNode<"HexagonISD::EH_RETURN", SDTNone, [SDNPHasChain]>;
1459 def SDHexagonBR_JT: SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
1460 def HexagonBR_JT: SDNode<"HexagonISD::BR_JT", SDHexagonBR_JT, [SDNPHasChain]>;
1462 class CondStr<string CReg, bit True, bit New> {
1463 string S = "if (" # !if(True,"","!") # CReg # !if(New,".new","") # ") ";
1465 class JumpOpcStr<string Mnemonic, bit New, bit Taken> {
1466 string S = Mnemonic # !if(New, !if(Taken,":t",":nt"), "");
1469 let isBranch = 1, isBarrier = 1, Defs = [PC], hasSideEffects = 0,
1471 isExtendable = 1, opExtendable = 0, isExtentSigned = 1,
1472 opExtentBits = 24, opExtentAlign = 2, InputType = "imm" in
1473 class T_JMP<string ExtStr>
1474 : JInst<(outs), (ins brtarget:$dst),
1475 "jump " # ExtStr # "$dst",
1476 [], "", J_tc_2early_SLOT23> {
1478 let IClass = 0b0101;
1480 let Inst{27-25} = 0b100;
1481 let Inst{24-16} = dst{23-15};
1482 let Inst{13-1} = dst{14-2};
1485 let isBranch = 1, Defs = [PC], hasSideEffects = 0, isPredicated = 1,
1486 isExtendable = 1, opExtendable = 1, isExtentSigned = 1,
1487 opExtentBits = 17, opExtentAlign = 2, InputType = "imm" in
1488 class T_JMP_c<bit PredNot, bit isPredNew, bit isTak, string ExtStr>
1489 : JInst<(outs), (ins PredRegs:$src, brtarget:$dst),
1490 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1491 JumpOpcStr<"jump", isPredNew, isTak>.S # " " #
1493 [], "", J_tc_2early_SLOT23>, ImmRegRel {
1494 let isTaken = isTak;
1495 let isPredicatedFalse = PredNot;
1496 let isPredicatedNew = isPredNew;
1500 let IClass = 0b0101;
1502 let Inst{27-24} = 0b1100;
1503 let Inst{21} = PredNot;
1504 let Inst{12} = !if(isPredNew, isTak, zero);
1505 let Inst{11} = isPredNew;
1506 let Inst{9-8} = src;
1507 let Inst{23-22} = dst{16-15};
1508 let Inst{20-16} = dst{14-10};
1509 let Inst{13} = dst{9};
1510 let Inst{7-1} = dst{8-2};
1513 multiclass JMP_Pred<bit PredNot, string ExtStr> {
1514 def NAME : T_JMP_c<PredNot, 0, 0, ExtStr>;
1516 def NAME#newpt : T_JMP_c<PredNot, 1, 1, ExtStr>; // taken
1517 def NAME#new : T_JMP_c<PredNot, 1, 0, ExtStr>; // not taken
1520 multiclass JMP_base<string BaseOp, string ExtStr> {
1521 let BaseOpcode = BaseOp in {
1522 def NAME : T_JMP<ExtStr>;
1523 defm t : JMP_Pred<0, ExtStr>;
1524 defm f : JMP_Pred<1, ExtStr>;
1528 // Jumps to address stored in a register, JUMPR_MISC
1529 // if ([[!]P[.new]]) jumpr[:t/nt] Rs
1530 let isBranch = 1, isIndirectBranch = 1, isBarrier = 1, Defs = [PC],
1531 isPredicable = 1, hasSideEffects = 0, InputType = "reg" in
1533 : JRInst<(outs), (ins IntRegs:$dst),
1534 "jumpr $dst", [], "", J_tc_2early_SLOT2> {
1537 let IClass = 0b0101;
1538 let Inst{27-21} = 0b0010100;
1539 let Inst{20-16} = dst;
1542 let isBranch = 1, isIndirectBranch = 1, Defs = [PC], isPredicated = 1,
1543 hasSideEffects = 0, InputType = "reg" in
1544 class T_JMPr_c <bit PredNot, bit isPredNew, bit isTak>
1545 : JRInst <(outs), (ins PredRegs:$src, IntRegs:$dst),
1546 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1547 JumpOpcStr<"jumpr", isPredNew, isTak>.S # " $dst", [],
1548 "", J_tc_2early_SLOT2> {
1550 let isTaken = isTak;
1551 let isPredicatedFalse = PredNot;
1552 let isPredicatedNew = isPredNew;
1556 let IClass = 0b0101;
1558 let Inst{27-22} = 0b001101;
1559 let Inst{21} = PredNot;
1560 let Inst{20-16} = dst;
1561 let Inst{12} = !if(isPredNew, isTak, zero);
1562 let Inst{11} = isPredNew;
1563 let Inst{9-8} = src;
1566 multiclass JMPR_Pred<bit PredNot> {
1567 def NAME: T_JMPr_c<PredNot, 0, 0>;
1569 def NAME#newpt : T_JMPr_c<PredNot, 1, 1>; // taken
1570 def NAME#new : T_JMPr_c<PredNot, 1, 0>; // not taken
1573 multiclass JMPR_base<string BaseOp> {
1574 let BaseOpcode = BaseOp in {
1576 defm t : JMPR_Pred<0>;
1577 defm f : JMPR_Pred<1>;
1581 let isCall = 1, hasSideEffects = 1 in
1582 class JUMPR_MISC_CALLR<bit isPred, bit isPredNot,
1583 dag InputDag = (ins IntRegs:$Rs)>
1584 : JRInst<(outs), InputDag,
1585 !if(isPred, !if(isPredNot, "if (!$Pu) callr $Rs",
1586 "if ($Pu) callr $Rs"),
1588 [], "", J_tc_2early_SLOT2> {
1591 let isPredicated = isPred;
1592 let isPredicatedFalse = isPredNot;
1594 let IClass = 0b0101;
1595 let Inst{27-25} = 0b000;
1596 let Inst{24-23} = !if (isPred, 0b10, 0b01);
1598 let Inst{21} = isPredNot;
1599 let Inst{9-8} = !if (isPred, Pu, 0b00);
1600 let Inst{20-16} = Rs;
1604 let Defs = VolatileV3.Regs, isCodeGenOnly = 0 in {
1605 def J2_callrt : JUMPR_MISC_CALLR<1, 0, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1606 def J2_callrf : JUMPR_MISC_CALLR<1, 1, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1609 let isTerminator = 1, hasSideEffects = 0, isCodeGenOnly = 0 in {
1610 defm J2_jump : JMP_base<"JMP", "">, PredNewRel;
1612 // Deal with explicit assembly
1613 // - never extened a jump #, always extend a jump ##
1614 let isAsmParserOnly = 1 in {
1615 defm J2_jump_ext : JMP_base<"JMP", "##">;
1616 defm J2_jump_noext : JMP_base<"JMP", "#">;
1619 defm J2_jumpr : JMPR_base<"JMPr">, PredNewRel;
1621 let isReturn = 1, isCodeGenOnly = 1 in
1622 defm JMPret : JMPR_base<"JMPret">, PredNewRel;
1625 def: Pat<(br bb:$dst),
1626 (J2_jump brtarget:$dst)>;
1628 (JMPret (i32 R31))>;
1629 def: Pat<(brcond (i1 PredRegs:$src1), bb:$offset),
1630 (J2_jumpt PredRegs:$src1, bb:$offset)>;
1632 // A return through builtin_eh_return.
1633 let isReturn = 1, isTerminator = 1, isBarrier = 1, hasSideEffects = 0,
1634 isCodeGenOnly = 1, Defs = [PC], Uses = [R28], isPredicable = 0 in
1635 def EH_RETURN_JMPR : T_JMPr;
1637 def: Pat<(eh_return),
1638 (EH_RETURN_JMPR (i32 R31))>;
1639 def: Pat<(HexagonBR_JT (i32 IntRegs:$dst)),
1640 (J2_jumpr IntRegs:$dst)>;
1641 def: Pat<(brind (i32 IntRegs:$dst)),
1642 (J2_jumpr IntRegs:$dst)>;
1644 //===----------------------------------------------------------------------===//
1646 //===----------------------------------------------------------------------===//
1648 //===----------------------------------------------------------------------===//
1650 //===----------------------------------------------------------------------===//
1651 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, AddedComplexity = 20 in
1652 class T_load_io <string mnemonic, RegisterClass RC, bits<4> MajOp,
1654 : LDInst<(outs RC:$dst), (ins IntRegs:$src1, ImmOp:$offset),
1655 "$dst = "#mnemonic#"($src1 + #$offset)", []>, AddrModeRel {
1660 bits<11> offsetBits;
1662 string ImmOpStr = !cast<string>(ImmOp);
1663 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), offset{13-3},
1664 !if (!eq(ImmOpStr, "s11_2Ext"), offset{12-2},
1665 !if (!eq(ImmOpStr, "s11_1Ext"), offset{11-1},
1666 /* s11_0Ext */ offset{10-0})));
1667 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
1668 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
1669 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
1670 /* s11_0Ext */ 11)));
1671 let hasNewValue = !if (!eq(ImmOpStr, "s11_3Ext"), 0, 1);
1673 let IClass = 0b1001;
1676 let Inst{26-25} = offsetBits{10-9};
1677 let Inst{24-21} = MajOp;
1678 let Inst{20-16} = src1;
1679 let Inst{13-5} = offsetBits{8-0};
1680 let Inst{4-0} = dst;
1683 let opExtendable = 3, isExtentSigned = 0, isPredicated = 1 in
1684 class T_pload_io <string mnemonic, RegisterClass RC, bits<4>MajOp,
1685 Operand ImmOp, bit isNot, bit isPredNew>
1686 : LDInst<(outs RC:$dst),
1687 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1688 "if ("#!if(isNot, "!$src1", "$src1")
1689 #!if(isPredNew, ".new", "")
1690 #") $dst = "#mnemonic#"($src2 + #$offset)",
1691 [],"", V2LDST_tc_ld_SLOT01> , AddrModeRel {
1697 string ImmOpStr = !cast<string>(ImmOp);
1699 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), offset{8-3},
1700 !if (!eq(ImmOpStr, "u6_2Ext"), offset{7-2},
1701 !if (!eq(ImmOpStr, "u6_1Ext"), offset{6-1},
1702 /* u6_0Ext */ offset{5-0})));
1703 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
1704 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
1705 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
1707 let hasNewValue = !if (!eq(ImmOpStr, "u6_3Ext"), 0, 1);
1708 let isPredicatedNew = isPredNew;
1709 let isPredicatedFalse = isNot;
1711 let IClass = 0b0100;
1715 let Inst{26} = isNot;
1716 let Inst{25} = isPredNew;
1717 let Inst{24-21} = MajOp;
1718 let Inst{20-16} = src2;
1720 let Inst{12-11} = src1;
1721 let Inst{10-5} = offsetBits;
1722 let Inst{4-0} = dst;
1725 let isExtendable = 1, hasSideEffects = 0, addrMode = BaseImmOffset in
1726 multiclass LD_Idxd<string mnemonic, string CextOp, RegisterClass RC,
1727 Operand ImmOp, Operand predImmOp, bits<4>MajOp> {
1728 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1729 let isPredicable = 1 in
1730 def L2_#NAME#_io : T_load_io <mnemonic, RC, MajOp, ImmOp>;
1733 def L2_p#NAME#t_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 0>;
1734 def L2_p#NAME#f_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 0>;
1737 def L2_p#NAME#tnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 1>;
1738 def L2_p#NAME#fnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 1>;
1742 let accessSize = ByteAccess, isCodeGenOnly = 0 in {
1743 defm loadrb: LD_Idxd <"memb", "LDrib", IntRegs, s11_0Ext, u6_0Ext, 0b1000>;
1744 defm loadrub: LD_Idxd <"memub", "LDriub", IntRegs, s11_0Ext, u6_0Ext, 0b1001>;
1747 let accessSize = HalfWordAccess, opExtentAlign = 1, isCodeGenOnly = 0 in {
1748 defm loadrh: LD_Idxd <"memh", "LDrih", IntRegs, s11_1Ext, u6_1Ext, 0b1010>;
1749 defm loadruh: LD_Idxd <"memuh", "LDriuh", IntRegs, s11_1Ext, u6_1Ext, 0b1011>;
1752 let accessSize = WordAccess, opExtentAlign = 2, isCodeGenOnly = 0 in
1753 defm loadri: LD_Idxd <"memw", "LDriw", IntRegs, s11_2Ext, u6_2Ext, 0b1100>;
1755 let accessSize = DoubleWordAccess, opExtentAlign = 3, isCodeGenOnly = 0 in
1756 defm loadrd: LD_Idxd <"memd", "LDrid", DoubleRegs, s11_3Ext, u6_3Ext, 0b1110>;
1758 let accessSize = HalfWordAccess, opExtentAlign = 1, isCodeGenOnly = 0 in {
1759 def L2_loadbsw2_io: T_load_io<"membh", IntRegs, 0b0001, s11_1Ext>;
1760 def L2_loadbzw2_io: T_load_io<"memubh", IntRegs, 0b0011, s11_1Ext>;
1763 let accessSize = WordAccess, opExtentAlign = 2, isCodeGenOnly = 0 in {
1764 def L2_loadbzw4_io: T_load_io<"memubh", DoubleRegs, 0b0101, s11_2Ext>;
1765 def L2_loadbsw4_io: T_load_io<"membh", DoubleRegs, 0b0111, s11_2Ext>;
1768 // Patterns to select load-indexed (i.e. load from base+offset).
1769 multiclass Loadx_pat<PatFrag Load, ValueType VT, PatLeaf ImmPred,
1771 def: Pat<(VT (Load AddrFI:$fi)), (VT (MI AddrFI:$fi, 0))>;
1772 def: Pat<(VT (Load (add (i32 IntRegs:$Rs), ImmPred:$Off))),
1773 (VT (MI IntRegs:$Rs, imm:$Off))>;
1774 def: Pat<(VT (Load (i32 IntRegs:$Rs))), (VT (MI IntRegs:$Rs, 0))>;
1777 let AddedComplexity = 20 in {
1778 defm: Loadx_pat<load, i32, s11_2ExtPred, L2_loadri_io>;
1779 defm: Loadx_pat<load, i64, s11_3ExtPred, L2_loadrd_io>;
1780 defm: Loadx_pat<atomic_load_8 , i32, s11_0ExtPred, L2_loadrub_io>;
1781 defm: Loadx_pat<atomic_load_16, i32, s11_1ExtPred, L2_loadruh_io>;
1782 defm: Loadx_pat<atomic_load_32, i32, s11_2ExtPred, L2_loadri_io>;
1783 defm: Loadx_pat<atomic_load_64, i64, s11_3ExtPred, L2_loadrd_io>;
1785 defm: Loadx_pat<extloadi1, i32, s11_0ExtPred, L2_loadrub_io>;
1786 defm: Loadx_pat<extloadi8, i32, s11_0ExtPred, L2_loadrub_io>;
1787 defm: Loadx_pat<extloadi16, i32, s11_1ExtPred, L2_loadruh_io>;
1788 defm: Loadx_pat<sextloadi8, i32, s11_0ExtPred, L2_loadrb_io>;
1789 defm: Loadx_pat<sextloadi16, i32, s11_1ExtPred, L2_loadrh_io>;
1790 defm: Loadx_pat<zextloadi1, i32, s11_0ExtPred, L2_loadrub_io>;
1791 defm: Loadx_pat<zextloadi8, i32, s11_0ExtPred, L2_loadrub_io>;
1792 defm: Loadx_pat<zextloadi16, i32, s11_1ExtPred, L2_loadruh_io>;
1796 // Sign-extending loads of i1 need to replicate the lowest bit throughout
1797 // the 32-bit value. Since the loaded value can only be 0 or 1, 0-v should
1799 let AddedComplexity = 20 in
1800 def: Pat<(i32 (sextloadi1 (i32 IntRegs:$Rs))),
1801 (SUB_ri 0, (L2_loadrub_io IntRegs:$Rs, 0))>;
1803 //===----------------------------------------------------------------------===//
1804 // Post increment load
1805 //===----------------------------------------------------------------------===//
1806 //===----------------------------------------------------------------------===//
1807 // Template class for non-predicated post increment loads with immediate offset.
1808 //===----------------------------------------------------------------------===//
1809 let hasSideEffects = 0, addrMode = PostInc in
1810 class T_load_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
1812 : LDInstPI <(outs RC:$dst, IntRegs:$dst2),
1813 (ins IntRegs:$src1, ImmOp:$offset),
1814 "$dst = "#mnemonic#"($src1++#$offset)" ,
1823 string ImmOpStr = !cast<string>(ImmOp);
1824 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1825 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1826 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1827 /* s4_0Imm */ offset{3-0})));
1828 let hasNewValue = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
1830 let IClass = 0b1001;
1832 let Inst{27-25} = 0b101;
1833 let Inst{24-21} = MajOp;
1834 let Inst{20-16} = src1;
1835 let Inst{13-12} = 0b00;
1836 let Inst{8-5} = offsetBits;
1837 let Inst{4-0} = dst;
1840 //===----------------------------------------------------------------------===//
1841 // Template class for predicated post increment loads with immediate offset.
1842 //===----------------------------------------------------------------------===//
1843 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc in
1844 class T_pload_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
1845 bits<4> MajOp, bit isPredNot, bit isPredNew >
1846 : LDInst <(outs RC:$dst, IntRegs:$dst2),
1847 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1848 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1849 ") ")#"$dst = "#mnemonic#"($src2++#$offset)",
1859 let isPredicatedNew = isPredNew;
1860 let isPredicatedFalse = isPredNot;
1862 string ImmOpStr = !cast<string>(ImmOp);
1863 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1864 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1865 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1866 /* s4_0Imm */ offset{3-0})));
1867 let hasNewValue = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
1869 let IClass = 0b1001;
1871 let Inst{27-25} = 0b101;
1872 let Inst{24-21} = MajOp;
1873 let Inst{20-16} = src2;
1875 let Inst{12} = isPredNew;
1876 let Inst{11} = isPredNot;
1877 let Inst{10-9} = src1;
1878 let Inst{8-5} = offsetBits;
1879 let Inst{4-0} = dst;
1882 //===----------------------------------------------------------------------===//
1883 // Multiclass for post increment loads with immediate offset.
1884 //===----------------------------------------------------------------------===//
1886 multiclass LD_PostInc <string mnemonic, string BaseOp, RegisterClass RC,
1887 Operand ImmOp, bits<4> MajOp> {
1888 let BaseOpcode = "POST_"#BaseOp in {
1889 let isPredicable = 1 in
1890 def L2_#NAME#_pi : T_load_pi < mnemonic, RC, ImmOp, MajOp>;
1893 def L2_p#NAME#t_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 0, 0>;
1894 def L2_p#NAME#f_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 1, 0>;
1897 def L2_p#NAME#tnew_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 0, 1>;
1898 def L2_p#NAME#fnew_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 1, 1>;
1902 // post increment byte loads with immediate offset
1903 let accessSize = ByteAccess, isCodeGenOnly = 0 in {
1904 defm loadrb : LD_PostInc <"memb", "LDrib", IntRegs, s4_0Imm, 0b1000>;
1905 defm loadrub : LD_PostInc <"memub", "LDriub", IntRegs, s4_0Imm, 0b1001>;
1908 // post increment halfword loads with immediate offset
1909 let accessSize = HalfWordAccess, opExtentAlign = 1, isCodeGenOnly = 0 in {
1910 defm loadrh : LD_PostInc <"memh", "LDrih", IntRegs, s4_1Imm, 0b1010>;
1911 defm loadruh : LD_PostInc <"memuh", "LDriuh", IntRegs, s4_1Imm, 0b1011>;
1914 // post increment word loads with immediate offset
1915 let accessSize = WordAccess, opExtentAlign = 2, isCodeGenOnly = 0 in
1916 defm loadri : LD_PostInc <"memw", "LDriw", IntRegs, s4_2Imm, 0b1100>;
1918 // post increment doubleword loads with immediate offset
1919 let accessSize = DoubleWordAccess, opExtentAlign = 3, isCodeGenOnly = 0 in
1920 defm loadrd : LD_PostInc <"memd", "LDrid", DoubleRegs, s4_3Imm, 0b1110>;
1922 // Rd=memb[u]h(Rx++#s4:1)
1923 // Rdd=memb[u]h(Rx++#s4:2)
1924 let accessSize = HalfWordAccess, opExtentAlign = 1, isCodeGenOnly = 0 in {
1925 def L2_loadbsw2_pi : T_load_pi <"membh", IntRegs, s4_1Imm, 0b0001>;
1926 def L2_loadbzw2_pi : T_load_pi <"memubh", IntRegs, s4_1Imm, 0b0011>;
1928 let accessSize = WordAccess, opExtentAlign = 2, hasNewValue = 0,
1929 isCodeGenOnly = 0 in {
1930 def L2_loadbsw4_pi : T_load_pi <"membh", DoubleRegs, s4_2Imm, 0b0111>;
1931 def L2_loadbzw4_pi : T_load_pi <"memubh", DoubleRegs, s4_2Imm, 0b0101>;
1934 //===----------------------------------------------------------------------===//
1935 // Template class for post increment loads with register offset.
1936 //===----------------------------------------------------------------------===//
1937 let hasSideEffects = 0, addrMode = PostInc in
1938 class T_load_pr <string mnemonic, RegisterClass RC, bits<4> MajOp,
1939 MemAccessSize AccessSz>
1940 : LDInstPI <(outs RC:$dst, IntRegs:$_dst_),
1941 (ins IntRegs:$src1, ModRegs:$src2),
1942 "$dst = "#mnemonic#"($src1++$src2)" ,
1943 [], "$src1 = $_dst_" > {
1948 let accessSize = AccessSz;
1949 let IClass = 0b1001;
1951 let Inst{27-25} = 0b110;
1952 let Inst{24-21} = MajOp;
1953 let Inst{20-16} = src1;
1954 let Inst{13} = src2;
1957 let Inst{4-0} = dst;
1960 let hasNewValue = 1, isCodeGenOnly = 0 in {
1961 def L2_loadrb_pr : T_load_pr <"memb", IntRegs, 0b1000, ByteAccess>;
1962 def L2_loadrub_pr : T_load_pr <"memub", IntRegs, 0b1001, ByteAccess>;
1963 def L2_loadrh_pr : T_load_pr <"memh", IntRegs, 0b1010, HalfWordAccess>;
1964 def L2_loadruh_pr : T_load_pr <"memuh", IntRegs, 0b1011, HalfWordAccess>;
1965 def L2_loadri_pr : T_load_pr <"memw", IntRegs, 0b1100, WordAccess>;
1967 def L2_loadbzw2_pr : T_load_pr <"memubh", IntRegs, 0b0011, HalfWordAccess>;
1970 let isCodeGenOnly = 0 in {
1971 def L2_loadrd_pr : T_load_pr <"memd", DoubleRegs, 0b1110, DoubleWordAccess>;
1972 def L2_loadbzw4_pr : T_load_pr <"memubh", DoubleRegs, 0b0101, WordAccess>;
1976 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 13,
1977 isPseudo = 1, Defs = [R10,R11,D5], hasSideEffects = 0 in
1978 def LDriw_pred : LDInst2<(outs PredRegs:$dst),
1980 "Error; should not emit",
1983 let Defs = [R29, R30, R31], Uses = [R30], hasSideEffects = 0, isCodeGenOnly = 0 in
1984 def L2_deallocframe : LDInst<(outs), (ins),
1987 let IClass = 0b1001;
1989 let Inst{27-16} = 0b000000011110;
1991 let Inst{4-0} = 0b11110;
1994 // Load / Post increment circular addressing mode.
1995 let Uses = [CS], hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
1996 class T_load_pcr<string mnemonic, RegisterClass RC, bits<4> MajOp>
1997 : LDInst <(outs RC:$dst, IntRegs:$_dst_),
1998 (ins IntRegs:$Rz, ModRegs:$Mu),
1999 "$dst = "#mnemonic#"($Rz ++ I:circ($Mu))", [],
2005 let IClass = 0b1001;
2007 let Inst{27-25} = 0b100;
2008 let Inst{24-21} = MajOp;
2009 let Inst{20-16} = Rz;
2014 let Inst{4-0} = dst;
2017 let accessSize = ByteAccess, isCodeGenOnly = 0 in {
2018 def L2_loadrb_pcr : T_load_pcr <"memb", IntRegs, 0b1000>;
2019 def L2_loadrub_pcr : T_load_pcr <"memub", IntRegs, 0b1001>;
2022 let accessSize = HalfWordAccess, isCodeGenOnly = 0 in {
2023 def L2_loadrh_pcr : T_load_pcr <"memh", IntRegs, 0b1010>;
2024 def L2_loadruh_pcr : T_load_pcr <"memuh", IntRegs, 0b1011>;
2025 def L2_loadbsw2_pcr : T_load_pcr <"membh", IntRegs, 0b0001>;
2026 def L2_loadbzw2_pcr : T_load_pcr <"memubh", IntRegs, 0b0011>;
2029 let accessSize = WordAccess, isCodeGenOnly = 0 in {
2030 def L2_loadri_pcr : T_load_pcr <"memw", IntRegs, 0b1100>;
2031 let hasNewValue = 0 in {
2032 def L2_loadbzw4_pcr : T_load_pcr <"memubh", DoubleRegs, 0b0101>;
2033 def L2_loadbsw4_pcr : T_load_pcr <"membh", DoubleRegs, 0b0111>;
2037 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
2038 def L2_loadrd_pcr : T_load_pcr <"memd", DoubleRegs, 0b1110>;
2040 //===----------------------------------------------------------------------===//
2041 // Circular loads with immediate offset.
2042 //===----------------------------------------------------------------------===//
2043 let Uses = [CS], mayLoad = 1, hasSideEffects = 0, hasNewValue = 1 in
2044 class T_load_pci <string mnemonic, RegisterClass RC,
2045 Operand ImmOp, bits<4> MajOp>
2046 : LDInstPI<(outs RC:$dst, IntRegs:$_dst_),
2047 (ins IntRegs:$Rz, ImmOp:$offset, ModRegs:$Mu),
2048 "$dst = "#mnemonic#"($Rz ++ #$offset:circ($Mu))", [],
2056 string ImmOpStr = !cast<string>(ImmOp);
2057 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
2058 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
2059 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
2060 /* s4_0Imm */ offset{3-0})));
2061 let IClass = 0b1001;
2062 let Inst{27-25} = 0b100;
2063 let Inst{24-21} = MajOp;
2064 let Inst{20-16} = Rz;
2068 let Inst{8-5} = offsetBits;
2069 let Inst{4-0} = dst;
2072 // Byte variants of circ load
2073 let accessSize = ByteAccess, isCodeGenOnly = 0 in {
2074 def L2_loadrb_pci : T_load_pci <"memb", IntRegs, s4_0Imm, 0b1000>;
2075 def L2_loadrub_pci : T_load_pci <"memub", IntRegs, s4_0Imm, 0b1001>;
2078 // Half word variants of circ load
2079 let accessSize = HalfWordAccess, isCodeGenOnly = 0 in {
2080 def L2_loadrh_pci : T_load_pci <"memh", IntRegs, s4_1Imm, 0b1010>;
2081 def L2_loadruh_pci : T_load_pci <"memuh", IntRegs, s4_1Imm, 0b1011>;
2082 def L2_loadbzw2_pci : T_load_pci <"memubh", IntRegs, s4_1Imm, 0b0011>;
2083 def L2_loadbsw2_pci : T_load_pci <"membh", IntRegs, s4_1Imm, 0b0001>;
2086 // Word variants of circ load
2087 let accessSize = WordAccess, isCodeGenOnly = 0 in
2088 def L2_loadri_pci : T_load_pci <"memw", IntRegs, s4_2Imm, 0b1100>;
2090 let accessSize = WordAccess, hasNewValue = 0, isCodeGenOnly = 0 in {
2091 def L2_loadbzw4_pci : T_load_pci <"memubh", DoubleRegs, s4_2Imm, 0b0101>;
2092 def L2_loadbsw4_pci : T_load_pci <"membh", DoubleRegs, s4_2Imm, 0b0111>;
2095 let accessSize = DoubleWordAccess, hasNewValue = 0, isCodeGenOnly = 0 in
2096 def L2_loadrd_pci : T_load_pci <"memd", DoubleRegs, s4_3Imm, 0b1110>;
2098 // L[24]_load[wd]_locked: Load word/double with lock.
2100 class T_load_locked <string mnemonic, RegisterClass RC>
2101 : LD0Inst <(outs RC:$dst),
2103 "$dst = "#mnemonic#"($src)"> {
2106 let IClass = 0b1001;
2107 let Inst{27-21} = 0b0010000;
2108 let Inst{20-16} = src;
2109 let Inst{13-12} = !if (!eq(mnemonic, "memd_locked"), 0b01, 0b00);
2110 let Inst{4-0} = dst;
2112 let hasNewValue = 1, accessSize = WordAccess, opNewValue = 0, isCodeGenOnly = 0 in
2113 def L2_loadw_locked : T_load_locked <"memw_locked", IntRegs>;
2114 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
2115 def L4_loadd_locked : T_load_locked <"memd_locked", DoubleRegs>;
2117 // S[24]_store[wd]_locked: Store word/double conditionally.
2118 let isSoloAX = 1, isPredicateLate = 1 in
2119 class T_store_locked <string mnemonic, RegisterClass RC>
2120 : ST0Inst <(outs PredRegs:$Pd), (ins IntRegs:$Rs, RC:$Rt),
2121 mnemonic#"($Rs, $Pd) = $Rt"> {
2126 let IClass = 0b1010;
2127 let Inst{27-23} = 0b00001;
2128 let Inst{22} = !if (!eq(mnemonic, "memw_locked"), 0b0, 0b1);
2130 let Inst{20-16} = Rs;
2131 let Inst{12-8} = Rt;
2135 let accessSize = WordAccess, isCodeGenOnly = 0 in
2136 def S2_storew_locked : T_store_locked <"memw_locked", IntRegs>;
2138 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
2139 def S4_stored_locked : T_store_locked <"memd_locked", DoubleRegs>;
2141 //===----------------------------------------------------------------------===//
2142 // Bit-reversed loads with auto-increment register
2143 //===----------------------------------------------------------------------===//
2144 let hasSideEffects = 0 in
2145 class T_load_pbr<string mnemonic, RegisterClass RC,
2146 MemAccessSize addrSize, bits<4> majOp>
2148 <(outs RC:$dst, IntRegs:$_dst_),
2149 (ins IntRegs:$Rz, ModRegs:$Mu),
2150 "$dst = "#mnemonic#"($Rz ++ $Mu:brev)" ,
2151 [] , "$Rz = $_dst_" > {
2153 let accessSize = addrSize;
2159 let IClass = 0b1001;
2161 let Inst{27-25} = 0b111;
2162 let Inst{24-21} = majOp;
2163 let Inst{20-16} = Rz;
2167 let Inst{4-0} = dst;
2170 let hasNewValue =1, opNewValue = 0, isCodeGenOnly = 0 in {
2171 def L2_loadrb_pbr : T_load_pbr <"memb", IntRegs, ByteAccess, 0b1000>;
2172 def L2_loadrub_pbr : T_load_pbr <"memub", IntRegs, ByteAccess, 0b1001>;
2173 def L2_loadrh_pbr : T_load_pbr <"memh", IntRegs, HalfWordAccess, 0b1010>;
2174 def L2_loadruh_pbr : T_load_pbr <"memuh", IntRegs, HalfWordAccess, 0b1011>;
2175 def L2_loadbsw2_pbr : T_load_pbr <"membh", IntRegs, HalfWordAccess, 0b0001>;
2176 def L2_loadbzw2_pbr : T_load_pbr <"memubh", IntRegs, HalfWordAccess, 0b0011>;
2177 def L2_loadri_pbr : T_load_pbr <"memw", IntRegs, WordAccess, 0b1100>;
2180 let isCodeGenOnly = 0 in {
2181 def L2_loadbzw4_pbr : T_load_pbr <"memubh", DoubleRegs, WordAccess, 0b0101>;
2182 def L2_loadbsw4_pbr : T_load_pbr <"membh", DoubleRegs, WordAccess, 0b0111>;
2183 def L2_loadrd_pbr : T_load_pbr <"memd", DoubleRegs, DoubleWordAccess, 0b1110>;
2186 //===----------------------------------------------------------------------===//
2188 //===----------------------------------------------------------------------===//
2190 //===----------------------------------------------------------------------===//
2192 //===----------------------------------------------------------------------===//
2193 //===----------------------------------------------------------------------===//
2195 //===----------------------------------------------------------------------===//
2197 //===----------------------------------------------------------------------===//
2199 //===----------------------------------------------------------------------===//
2200 //===----------------------------------------------------------------------===//
2202 //===----------------------------------------------------------------------===//
2204 //===----------------------------------------------------------------------===//
2206 //===----------------------------------------------------------------------===//
2208 //===----------------------------------------------------------------------===//
2210 // MPYS / Multipy signed/unsigned halfwords
2211 //Rd=mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
2212 //===----------------------------------------------------------------------===//
2214 let hasNewValue = 1, opNewValue = 0 in
2215 class T_M2_mpy < bits<2> LHbits, bit isSat, bit isRnd,
2216 bit hasShift, bit isUnsigned>
2217 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
2218 "$Rd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
2219 #", $Rt."#!if(LHbits{0},"h)","l)")
2220 #!if(hasShift,":<<1","")
2221 #!if(isRnd,":rnd","")
2222 #!if(isSat,":sat",""),
2223 [], "", M_tc_3x_SLOT23 > {
2228 let IClass = 0b1110;
2230 let Inst{27-24} = 0b1100;
2231 let Inst{23} = hasShift;
2232 let Inst{22} = isUnsigned;
2233 let Inst{21} = isRnd;
2234 let Inst{7} = isSat;
2235 let Inst{6-5} = LHbits;
2237 let Inst{20-16} = Rs;
2238 let Inst{12-8} = Rt;
2241 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2242 let isCodeGenOnly = 0 in {
2243 def M2_mpy_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 0>;
2244 def M2_mpy_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 0>;
2245 def M2_mpy_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 0>;
2246 def M2_mpy_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 0>;
2247 def M2_mpy_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 0>;
2248 def M2_mpy_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 0>;
2249 def M2_mpy_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 0>;
2250 def M2_mpy_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 0>;
2253 //Rd=mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2254 let isCodeGenOnly = 0 in {
2255 def M2_mpyu_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 1>;
2256 def M2_mpyu_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 1>;
2257 def M2_mpyu_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 1>;
2258 def M2_mpyu_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 1>;
2259 def M2_mpyu_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 1>;
2260 def M2_mpyu_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 1>;
2261 def M2_mpyu_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 1>;
2262 def M2_mpyu_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 1>;
2265 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]:rnd
2266 let isCodeGenOnly = 0 in {
2267 def M2_mpy_rnd_ll_s1: T_M2_mpy <0b00, 0, 1, 1, 0>;
2268 def M2_mpy_rnd_ll_s0: T_M2_mpy <0b00, 0, 1, 0, 0>;
2269 def M2_mpy_rnd_lh_s1: T_M2_mpy <0b01, 0, 1, 1, 0>;
2270 def M2_mpy_rnd_lh_s0: T_M2_mpy <0b01, 0, 1, 0, 0>;
2271 def M2_mpy_rnd_hl_s1: T_M2_mpy <0b10, 0, 1, 1, 0>;
2272 def M2_mpy_rnd_hl_s0: T_M2_mpy <0b10, 0, 1, 0, 0>;
2273 def M2_mpy_rnd_hh_s1: T_M2_mpy <0b11, 0, 1, 1, 0>;
2274 def M2_mpy_rnd_hh_s0: T_M2_mpy <0b11, 0, 1, 0, 0>;
2277 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2278 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
2279 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
2280 def M2_mpy_sat_ll_s1: T_M2_mpy <0b00, 1, 0, 1, 0>;
2281 def M2_mpy_sat_ll_s0: T_M2_mpy <0b00, 1, 0, 0, 0>;
2282 def M2_mpy_sat_lh_s1: T_M2_mpy <0b01, 1, 0, 1, 0>;
2283 def M2_mpy_sat_lh_s0: T_M2_mpy <0b01, 1, 0, 0, 0>;
2284 def M2_mpy_sat_hl_s1: T_M2_mpy <0b10, 1, 0, 1, 0>;
2285 def M2_mpy_sat_hl_s0: T_M2_mpy <0b10, 1, 0, 0, 0>;
2286 def M2_mpy_sat_hh_s1: T_M2_mpy <0b11, 1, 0, 1, 0>;
2287 def M2_mpy_sat_hh_s0: T_M2_mpy <0b11, 1, 0, 0, 0>;
2289 def M2_mpy_sat_rnd_ll_s1: T_M2_mpy <0b00, 1, 1, 1, 0>;
2290 def M2_mpy_sat_rnd_ll_s0: T_M2_mpy <0b00, 1, 1, 0, 0>;
2291 def M2_mpy_sat_rnd_lh_s1: T_M2_mpy <0b01, 1, 1, 1, 0>;
2292 def M2_mpy_sat_rnd_lh_s0: T_M2_mpy <0b01, 1, 1, 0, 0>;
2293 def M2_mpy_sat_rnd_hl_s1: T_M2_mpy <0b10, 1, 1, 1, 0>;
2294 def M2_mpy_sat_rnd_hl_s0: T_M2_mpy <0b10, 1, 1, 0, 0>;
2295 def M2_mpy_sat_rnd_hh_s1: T_M2_mpy <0b11, 1, 1, 1, 0>;
2296 def M2_mpy_sat_rnd_hh_s0: T_M2_mpy <0b11, 1, 1, 0, 0>;
2299 //===----------------------------------------------------------------------===//
2301 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
2302 // result from the accumulator.
2303 //Rx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2304 //===----------------------------------------------------------------------===//
2306 let hasNewValue = 1, opNewValue = 0 in
2307 class T_M2_mpy_acc < bits<2> LHbits, bit isSat, bit isNac,
2308 bit hasShift, bit isUnsigned >
2309 : MInst_acc<(outs IntRegs:$Rx), (ins IntRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2310 "$Rx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
2311 #"($Rs."#!if(LHbits{1},"h","l")
2312 #", $Rt."#!if(LHbits{0},"h)","l)")
2313 #!if(hasShift,":<<1","")
2314 #!if(isSat,":sat",""),
2315 [], "$dst2 = $Rx", M_tc_3x_SLOT23 > {
2320 let IClass = 0b1110;
2321 let Inst{27-24} = 0b1110;
2322 let Inst{23} = hasShift;
2323 let Inst{22} = isUnsigned;
2324 let Inst{21} = isNac;
2325 let Inst{7} = isSat;
2326 let Inst{6-5} = LHbits;
2328 let Inst{20-16} = Rs;
2329 let Inst{12-8} = Rt;
2332 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2333 let isCodeGenOnly = 0 in {
2334 def M2_mpy_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 0>;
2335 def M2_mpy_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 0>;
2336 def M2_mpy_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 0>;
2337 def M2_mpy_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 0>;
2338 def M2_mpy_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 0>;
2339 def M2_mpy_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 0>;
2340 def M2_mpy_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 0>;
2341 def M2_mpy_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 0>;
2344 //Rx += mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2345 let isCodeGenOnly = 0 in {
2346 def M2_mpyu_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 1>;
2347 def M2_mpyu_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 1>;
2348 def M2_mpyu_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 1>;
2349 def M2_mpyu_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 1>;
2350 def M2_mpyu_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 1>;
2351 def M2_mpyu_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 1>;
2352 def M2_mpyu_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 1>;
2353 def M2_mpyu_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 1>;
2356 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2357 let isCodeGenOnly = 0 in {
2358 def M2_mpy_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 0>;
2359 def M2_mpy_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 0>;
2360 def M2_mpy_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 0>;
2361 def M2_mpy_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 0>;
2362 def M2_mpy_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 0>;
2363 def M2_mpy_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 0>;
2364 def M2_mpy_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 0>;
2365 def M2_mpy_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 0>;
2368 //Rx -= mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2369 let isCodeGenOnly = 0 in {
2370 def M2_mpyu_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 1>;
2371 def M2_mpyu_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 1>;
2372 def M2_mpyu_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 1>;
2373 def M2_mpyu_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 1>;
2374 def M2_mpyu_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 1>;
2375 def M2_mpyu_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 1>;
2376 def M2_mpyu_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 1>;
2377 def M2_mpyu_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 1>;
2380 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
2381 let isCodeGenOnly = 0 in {
2382 def M2_mpy_acc_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 0, 1, 0>;
2383 def M2_mpy_acc_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 0, 0, 0>;
2384 def M2_mpy_acc_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 0, 1, 0>;
2385 def M2_mpy_acc_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 0, 0, 0>;
2386 def M2_mpy_acc_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 0, 1, 0>;
2387 def M2_mpy_acc_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 0, 0, 0>;
2388 def M2_mpy_acc_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 0, 1, 0>;
2389 def M2_mpy_acc_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 0, 0, 0>;
2392 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
2393 let isCodeGenOnly = 0 in {
2394 def M2_mpy_nac_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 1, 1, 0>;
2395 def M2_mpy_nac_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 1, 0, 0>;
2396 def M2_mpy_nac_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 1, 1, 0>;
2397 def M2_mpy_nac_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 1, 0, 0>;
2398 def M2_mpy_nac_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 1, 1, 0>;
2399 def M2_mpy_nac_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 1, 0, 0>;
2400 def M2_mpy_nac_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 1, 1, 0>;
2401 def M2_mpy_nac_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 1, 0, 0>;
2404 //===----------------------------------------------------------------------===//
2406 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
2407 // result from the 64-bit destination register.
2408 //Rxx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2409 //===----------------------------------------------------------------------===//
2411 class T_M2_mpyd_acc < bits<2> LHbits, bit isNac, bit hasShift, bit isUnsigned>
2412 : MInst_acc<(outs DoubleRegs:$Rxx),
2413 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2414 "$Rxx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
2415 #"($Rs."#!if(LHbits{1},"h","l")
2416 #", $Rt."#!if(LHbits{0},"h)","l)")
2417 #!if(hasShift,":<<1",""),
2418 [], "$dst2 = $Rxx", M_tc_3x_SLOT23 > {
2423 let IClass = 0b1110;
2425 let Inst{27-24} = 0b0110;
2426 let Inst{23} = hasShift;
2427 let Inst{22} = isUnsigned;
2428 let Inst{21} = isNac;
2430 let Inst{6-5} = LHbits;
2431 let Inst{4-0} = Rxx;
2432 let Inst{20-16} = Rs;
2433 let Inst{12-8} = Rt;
2436 let isCodeGenOnly = 0 in {
2437 def M2_mpyd_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 0>;
2438 def M2_mpyd_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 0>;
2439 def M2_mpyd_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 0>;
2440 def M2_mpyd_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 0>;
2442 def M2_mpyd_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 0>;
2443 def M2_mpyd_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 0>;
2444 def M2_mpyd_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 0>;
2445 def M2_mpyd_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 0>;
2447 def M2_mpyd_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 0>;
2448 def M2_mpyd_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 0>;
2449 def M2_mpyd_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 0>;
2450 def M2_mpyd_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 0>;
2452 def M2_mpyd_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 0>;
2453 def M2_mpyd_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 0>;
2454 def M2_mpyd_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 0>;
2455 def M2_mpyd_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 0>;
2457 def M2_mpyud_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 1>;
2458 def M2_mpyud_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 1>;
2459 def M2_mpyud_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 1>;
2460 def M2_mpyud_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 1>;
2462 def M2_mpyud_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 1>;
2463 def M2_mpyud_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 1>;
2464 def M2_mpyud_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 1>;
2465 def M2_mpyud_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 1>;
2467 def M2_mpyud_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 1>;
2468 def M2_mpyud_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 1>;
2469 def M2_mpyud_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 1>;
2470 def M2_mpyud_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 1>;
2472 def M2_mpyud_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 1>;
2473 def M2_mpyud_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 1>;
2474 def M2_mpyud_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 1>;
2475 def M2_mpyud_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 1>;
2478 //===----------------------------------------------------------------------===//
2479 // Template Class -- Vector Multipy
2480 // Used for complex multiply real or imaginary, dual multiply and even halfwords
2481 //===----------------------------------------------------------------------===//
2482 class T_M2_vmpy < string opc, bits<3> MajOp, bits<3> MinOp, bit hasShift,
2483 bit isRnd, bit isSat >
2484 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2485 "$Rdd = "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2486 #!if(isRnd,":rnd","")
2487 #!if(isSat,":sat",""),
2493 let IClass = 0b1110;
2495 let Inst{27-24} = 0b1000;
2496 let Inst{23-21} = MajOp;
2497 let Inst{7-5} = MinOp;
2498 let Inst{4-0} = Rdd;
2499 let Inst{20-16} = Rss;
2500 let Inst{12-8} = Rtt;
2503 // Vector complex multiply imaginary: Rdd=vcmpyi(Rss,Rtt)[:<<1]:sat
2504 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
2505 def M2_vcmpy_s1_sat_i: T_M2_vmpy <"vcmpyi", 0b110, 0b110, 1, 0, 1>;
2506 def M2_vcmpy_s0_sat_i: T_M2_vmpy <"vcmpyi", 0b010, 0b110, 0, 0, 1>;
2509 // Vector complex multiply real: Rdd=vcmpyr(Rss,Rtt)[:<<1]:sat
2510 let isCodeGenOnly = 0 in {
2511 def M2_vcmpy_s1_sat_r: T_M2_vmpy <"vcmpyr", 0b101, 0b110, 1, 0, 1>;
2512 def M2_vcmpy_s0_sat_r: T_M2_vmpy <"vcmpyr", 0b001, 0b110, 0, 0, 1>;
2515 // Vector dual multiply: Rdd=vdmpy(Rss,Rtt)[:<<1]:sat
2516 let isCodeGenOnly = 0 in {
2517 def M2_vdmpys_s1: T_M2_vmpy <"vdmpy", 0b100, 0b100, 1, 0, 1>;
2518 def M2_vdmpys_s0: T_M2_vmpy <"vdmpy", 0b000, 0b100, 0, 0, 1>;
2521 // Vector multiply even halfwords: Rdd=vmpyeh(Rss,Rtt)[:<<1]:sat
2522 let isCodeGenOnly = 0 in {
2523 def M2_vmpy2es_s1: T_M2_vmpy <"vmpyeh", 0b100, 0b110, 1, 0, 1>;
2524 def M2_vmpy2es_s0: T_M2_vmpy <"vmpyeh", 0b000, 0b110, 0, 0, 1>;
2527 //Rdd=vmpywoh(Rss,Rtt)[:<<1][:rnd]:sat
2528 let isCodeGenOnly = 0 in {
2529 def M2_mmpyh_s0: T_M2_vmpy <"vmpywoh", 0b000, 0b111, 0, 0, 1>;
2530 def M2_mmpyh_s1: T_M2_vmpy <"vmpywoh", 0b100, 0b111, 1, 0, 1>;
2531 def M2_mmpyh_rs0: T_M2_vmpy <"vmpywoh", 0b001, 0b111, 0, 1, 1>;
2532 def M2_mmpyh_rs1: T_M2_vmpy <"vmpywoh", 0b101, 0b111, 1, 1, 1>;
2535 //Rdd=vmpyweh(Rss,Rtt)[:<<1][:rnd]:sat
2536 let isCodeGenOnly = 0 in {
2537 def M2_mmpyl_s0: T_M2_vmpy <"vmpyweh", 0b000, 0b101, 0, 0, 1>;
2538 def M2_mmpyl_s1: T_M2_vmpy <"vmpyweh", 0b100, 0b101, 1, 0, 1>;
2539 def M2_mmpyl_rs0: T_M2_vmpy <"vmpyweh", 0b001, 0b101, 0, 1, 1>;
2540 def M2_mmpyl_rs1: T_M2_vmpy <"vmpyweh", 0b101, 0b101, 1, 1, 1>;
2543 //Rdd=vmpywouh(Rss,Rtt)[:<<1][:rnd]:sat
2544 let isCodeGenOnly = 0 in {
2545 def M2_mmpyuh_s0: T_M2_vmpy <"vmpywouh", 0b010, 0b111, 0, 0, 1>;
2546 def M2_mmpyuh_s1: T_M2_vmpy <"vmpywouh", 0b110, 0b111, 1, 0, 1>;
2547 def M2_mmpyuh_rs0: T_M2_vmpy <"vmpywouh", 0b011, 0b111, 0, 1, 1>;
2548 def M2_mmpyuh_rs1: T_M2_vmpy <"vmpywouh", 0b111, 0b111, 1, 1, 1>;
2551 //Rdd=vmpyweuh(Rss,Rtt)[:<<1][:rnd]:sat
2552 let isCodeGenOnly = 0 in {
2553 def M2_mmpyul_s0: T_M2_vmpy <"vmpyweuh", 0b010, 0b101, 0, 0, 1>;
2554 def M2_mmpyul_s1: T_M2_vmpy <"vmpyweuh", 0b110, 0b101, 1, 0, 1>;
2555 def M2_mmpyul_rs0: T_M2_vmpy <"vmpyweuh", 0b011, 0b101, 0, 1, 1>;
2556 def M2_mmpyul_rs1: T_M2_vmpy <"vmpyweuh", 0b111, 0b101, 1, 1, 1>;
2559 let hasNewValue = 1, opNewValue = 0 in
2560 class T_MType_mpy <string mnemonic, bits<4> RegTyBits, RegisterClass RC,
2561 bits<3> MajOp, bits<3> MinOp, bit isSat = 0, bit isRnd = 0,
2562 string op2Suffix = "", bit isRaw = 0, bit isHi = 0 >
2563 : MInst <(outs IntRegs:$dst), (ins RC:$src1, RC:$src2),
2565 #"($src1, $src2"#op2Suffix#")"
2566 #!if(MajOp{2}, ":<<1", "")
2567 #!if(isRnd, ":rnd", "")
2568 #!if(isSat, ":sat", "")
2569 #!if(isRaw, !if(isHi, ":raw:hi", ":raw:lo"), ""), [] > {
2574 let IClass = 0b1110;
2576 let Inst{27-24} = RegTyBits;
2577 let Inst{23-21} = MajOp;
2578 let Inst{20-16} = src1;
2580 let Inst{12-8} = src2;
2581 let Inst{7-5} = MinOp;
2582 let Inst{4-0} = dst;
2585 class T_MType_vrcmpy <string mnemonic, bits<3> MajOp, bits<3> MinOp, bit isHi>
2586 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, 1, 1, "", 1, isHi>;
2588 class T_MType_dd <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2589 bit isSat = 0, bit isRnd = 0 >
2590 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, isSat, isRnd>;
2592 class T_MType_rr1 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2593 bit isSat = 0, bit isRnd = 0 >
2594 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd>;
2596 class T_MType_rr2 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2597 bit isSat = 0, bit isRnd = 0, string op2str = "" >
2598 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd, op2str>;
2600 let isCodeGenOnly = 0 in {
2601 def M2_vradduh : T_MType_dd <"vradduh", 0b000, 0b001, 0, 0>;
2602 def M2_vdmpyrs_s0 : T_MType_dd <"vdmpy", 0b000, 0b000, 1, 1>;
2603 def M2_vdmpyrs_s1 : T_MType_dd <"vdmpy", 0b100, 0b000, 1, 1>;
2606 let CextOpcode = "mpyi", InputType = "reg", isCodeGenOnly = 0 in
2607 def M2_mpyi : T_MType_rr1 <"mpyi", 0b000, 0b000>, ImmRegRel;
2609 let isCodeGenOnly = 0 in {
2610 def M2_mpy_up : T_MType_rr1 <"mpy", 0b000, 0b001>;
2611 def M2_mpyu_up : T_MType_rr1 <"mpyu", 0b010, 0b001>;
2614 let isCodeGenOnly = 0 in
2615 def M2_dpmpyss_rnd_s0 : T_MType_rr1 <"mpy", 0b001, 0b001, 0, 1>;
2617 let isCodeGenOnly = 0 in {
2618 def M2_vmpy2s_s0pack : T_MType_rr1 <"vmpyh", 0b001, 0b111, 1, 1>;
2619 def M2_vmpy2s_s1pack : T_MType_rr1 <"vmpyh", 0b101, 0b111, 1, 1>;
2622 let isCodeGenOnly = 0 in {
2623 def M2_hmmpyh_rs1 : T_MType_rr2 <"mpy", 0b101, 0b100, 1, 1, ".h">;
2624 def M2_hmmpyl_rs1 : T_MType_rr2 <"mpy", 0b111, 0b100, 1, 1, ".l">;
2627 let isCodeGenOnly = 0 in {
2628 def M2_cmpyrs_s0 : T_MType_rr2 <"cmpy", 0b001, 0b110, 1, 1>;
2629 def M2_cmpyrs_s1 : T_MType_rr2 <"cmpy", 0b101, 0b110, 1, 1>;
2630 def M2_cmpyrsc_s0 : T_MType_rr2 <"cmpy", 0b011, 0b110, 1, 1, "*">;
2631 def M2_cmpyrsc_s1 : T_MType_rr2 <"cmpy", 0b111, 0b110, 1, 1, "*">;
2635 let isCodeGenOnly = 0 in {
2636 def M2_vraddh : T_MType_dd <"vraddh", 0b001, 0b111, 0>;
2637 def M2_mpysu_up : T_MType_rr1 <"mpysu", 0b011, 0b001, 0>;
2638 def M2_mpy_up_s1 : T_MType_rr1 <"mpy", 0b101, 0b010, 0>;
2639 def M2_mpy_up_s1_sat : T_MType_rr1 <"mpy", 0b111, 0b000, 1>;
2641 def M2_hmmpyh_s1 : T_MType_rr2 <"mpy", 0b101, 0b000, 1, 0, ".h">;
2642 def M2_hmmpyl_s1 : T_MType_rr2 <"mpy", 0b101, 0b001, 1, 0, ".l">;
2645 def: Pat<(i32 (mul I32:$src1, I32:$src2)), (M2_mpyi I32:$src1, I32:$src2)>;
2646 def: Pat<(i32 (mulhs I32:$src1, I32:$src2)), (M2_mpy_up I32:$src1, I32:$src2)>;
2647 def: Pat<(i32 (mulhu I32:$src1, I32:$src2)), (M2_mpyu_up I32:$src1, I32:$src2)>;
2649 let hasNewValue = 1, opNewValue = 0 in
2650 class T_MType_mpy_ri <bit isNeg, Operand ImmOp, list<dag> pattern>
2651 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, ImmOp:$u8),
2652 "$Rd ="#!if(isNeg, "- ", "+ ")#"mpyi($Rs, #$u8)" ,
2653 pattern, "", M_tc_3x_SLOT23> {
2658 let IClass = 0b1110;
2660 let Inst{27-24} = 0b0000;
2661 let Inst{23} = isNeg;
2664 let Inst{20-16} = Rs;
2665 let Inst{12-5} = u8;
2668 let isExtendable = 1, opExtentBits = 8, opExtendable = 2, isCodeGenOnly = 0 in
2669 def M2_mpysip : T_MType_mpy_ri <0, u8Ext,
2670 [(set (i32 IntRegs:$Rd), (mul IntRegs:$Rs, u8ExtPred:$u8))]>;
2672 let isCodeGenOnly = 0 in
2673 def M2_mpysin : T_MType_mpy_ri <1, u8Imm,
2674 [(set (i32 IntRegs:$Rd), (ineg (mul IntRegs:$Rs,
2677 // Assember mapped to M2_mpyi
2678 let isAsmParserOnly = 1 in
2679 def M2_mpyui : MInst<(outs IntRegs:$dst),
2680 (ins IntRegs:$src1, IntRegs:$src2),
2681 "$dst = mpyui($src1, $src2)">;
2684 // s9 is NOT the same as m9 - but it works.. so far.
2685 // Assembler maps to either Rd=+mpyi(Rs,#u8) or Rd=-mpyi(Rs,#u8)
2686 // depending on the value of m9. See Arch Spec.
2687 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 9,
2688 CextOpcode = "mpyi", InputType = "imm", hasNewValue = 1 in
2689 def M2_mpysmi : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, s9Ext:$src2),
2690 "$dst = mpyi($src1, #$src2)",
2691 [(set (i32 IntRegs:$dst), (mul (i32 IntRegs:$src1),
2692 s9ExtPred:$src2))]>, ImmRegRel;
2694 let hasNewValue = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 3,
2695 InputType = "imm" in
2696 class T_MType_acc_ri <string mnemonic, bits<3> MajOp, Operand ImmOp,
2697 list<dag> pattern = []>
2698 : MInst < (outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, ImmOp:$src3),
2699 "$dst "#mnemonic#"($src2, #$src3)",
2700 pattern, "$src1 = $dst", M_tc_2_SLOT23> {
2705 let IClass = 0b1110;
2707 let Inst{27-26} = 0b00;
2708 let Inst{25-23} = MajOp;
2709 let Inst{20-16} = src2;
2711 let Inst{12-5} = src3;
2712 let Inst{4-0} = dst;
2715 let InputType = "reg", hasNewValue = 1 in
2716 class T_MType_acc_rr <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2717 bit isSwap = 0, list<dag> pattern = [], bit hasNot = 0,
2718 bit isSat = 0, bit isShift = 0>
2719 : MInst < (outs IntRegs:$dst),
2720 (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3),
2721 "$dst "#mnemonic#"($src2, "#!if(hasNot, "~$src3)","$src3)")
2722 #!if(isShift, ":<<1", "")
2723 #!if(isSat, ":sat", ""),
2724 pattern, "$src1 = $dst", M_tc_2_SLOT23 > {
2729 let IClass = 0b1110;
2731 let Inst{27-24} = 0b1111;
2732 let Inst{23-21} = MajOp;
2733 let Inst{20-16} = !if(isSwap, src3, src2);
2735 let Inst{12-8} = !if(isSwap, src2, src3);
2736 let Inst{7-5} = MinOp;
2737 let Inst{4-0} = dst;
2740 let CextOpcode = "MPYI_acc", Itinerary = M_tc_3x_SLOT23, isCodeGenOnly = 0 in {
2741 def M2_macsip : T_MType_acc_ri <"+= mpyi", 0b010, u8Ext,
2742 [(set (i32 IntRegs:$dst),
2743 (add (mul IntRegs:$src2, u8ExtPred:$src3),
2744 IntRegs:$src1))]>, ImmRegRel;
2746 def M2_maci : T_MType_acc_rr <"+= mpyi", 0b000, 0b000, 0,
2747 [(set (i32 IntRegs:$dst),
2748 (add (mul IntRegs:$src2, IntRegs:$src3),
2749 IntRegs:$src1))]>, ImmRegRel;
2752 let CextOpcode = "ADD_acc", isCodeGenOnly = 0 in {
2753 let isExtentSigned = 1 in
2754 def M2_accii : T_MType_acc_ri <"+= add", 0b100, s8Ext,
2755 [(set (i32 IntRegs:$dst),
2756 (add (add (i32 IntRegs:$src2), s8_16ExtPred:$src3),
2757 (i32 IntRegs:$src1)))]>, ImmRegRel;
2759 def M2_acci : T_MType_acc_rr <"+= add", 0b000, 0b001, 0,
2760 [(set (i32 IntRegs:$dst),
2761 (add (add (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2762 (i32 IntRegs:$src1)))]>, ImmRegRel;
2765 let CextOpcode = "SUB_acc", isCodeGenOnly = 0 in {
2766 let isExtentSigned = 1 in
2767 def M2_naccii : T_MType_acc_ri <"-= add", 0b101, s8Ext>, ImmRegRel;
2769 def M2_nacci : T_MType_acc_rr <"-= add", 0b100, 0b001, 0>, ImmRegRel;
2772 let Itinerary = M_tc_3x_SLOT23, isCodeGenOnly = 0 in
2773 def M2_macsin : T_MType_acc_ri <"-= mpyi", 0b011, u8Ext>;
2775 let isCodeGenOnly = 0 in {
2776 def M2_xor_xacc : T_MType_acc_rr < "^= xor", 0b100, 0b011, 0>;
2777 def M2_subacc : T_MType_acc_rr <"+= sub", 0b000, 0b011, 1>;
2780 class T_MType_acc_pat1 <InstHexagon MI, SDNode firstOp, SDNode secOp,
2782 : Pat <(secOp IntRegs:$src1, (firstOp IntRegs:$src2, ImmPred:$src3)),
2783 (MI IntRegs:$src1, IntRegs:$src2, ImmPred:$src3)>;
2785 class T_MType_acc_pat2 <InstHexagon MI, SDNode firstOp, SDNode secOp>
2786 : Pat <(i32 (secOp IntRegs:$src1, (firstOp IntRegs:$src2, IntRegs:$src3))),
2787 (MI IntRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2789 def : T_MType_acc_pat2 <M2_xor_xacc, xor, xor>;
2790 def : T_MType_acc_pat1 <M2_macsin, mul, sub, u8ExtPred>;
2792 def : T_MType_acc_pat1 <M2_naccii, add, sub, s8_16ExtPred>;
2793 def : T_MType_acc_pat2 <M2_nacci, add, sub>;
2795 //===----------------------------------------------------------------------===//
2796 // Template Class -- XType Vector Instructions
2797 //===----------------------------------------------------------------------===//
2798 class T_XTYPE_Vect < string opc, bits<3> MajOp, bits<3> MinOp, bit isConj >
2799 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2800 "$Rdd = "#opc#"($Rss, $Rtt"#!if(isConj,"*)",")"),
2806 let IClass = 0b1110;
2808 let Inst{27-24} = 0b1000;
2809 let Inst{23-21} = MajOp;
2810 let Inst{7-5} = MinOp;
2811 let Inst{4-0} = Rdd;
2812 let Inst{20-16} = Rss;
2813 let Inst{12-8} = Rtt;
2816 class T_XTYPE_Vect_acc < string opc, bits<3> MajOp, bits<3> MinOp, bit isConj >
2817 : MInst <(outs DoubleRegs:$Rdd),
2818 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2819 "$Rdd += "#opc#"($Rss, $Rtt"#!if(isConj,"*)",")"),
2820 [], "$dst2 = $Rdd",M_tc_3x_SLOT23 > {
2825 let IClass = 0b1110;
2827 let Inst{27-24} = 0b1010;
2828 let Inst{23-21} = MajOp;
2829 let Inst{7-5} = MinOp;
2830 let Inst{4-0} = Rdd;
2831 let Inst{20-16} = Rss;
2832 let Inst{12-8} = Rtt;
2835 class T_XTYPE_Vect_diff < bits<3> MajOp, string opc >
2836 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rtt, DoubleRegs:$Rss),
2837 "$Rdd = "#opc#"($Rtt, $Rss)",
2838 [], "",M_tc_2_SLOT23 > {
2843 let IClass = 0b1110;
2845 let Inst{27-24} = 0b1000;
2846 let Inst{23-21} = MajOp;
2847 let Inst{7-5} = 0b000;
2848 let Inst{4-0} = Rdd;
2849 let Inst{20-16} = Rss;
2850 let Inst{12-8} = Rtt;
2853 // Vector reduce add unsigned bytes: Rdd32=vrmpybu(Rss32,Rtt32)
2854 let isCodeGenOnly = 0 in {
2855 def A2_vraddub: T_XTYPE_Vect <"vraddub", 0b010, 0b001, 0>;
2856 def A2_vraddub_acc: T_XTYPE_Vect_acc <"vraddub", 0b010, 0b001, 0>;
2859 // Vector sum of absolute differences unsigned bytes: Rdd=vrsadub(Rss,Rtt)
2860 let isCodeGenOnly = 0 in {
2861 def A2_vrsadub: T_XTYPE_Vect <"vrsadub", 0b010, 0b010, 0>;
2862 def A2_vrsadub_acc: T_XTYPE_Vect_acc <"vrsadub", 0b010, 0b010, 0>;
2865 // Vector absolute difference: Rdd=vabsdiffh(Rtt,Rss)
2866 let isCodeGenOnly = 0 in
2867 def M2_vabsdiffh: T_XTYPE_Vect_diff<0b011, "vabsdiffh">;
2869 // Vector reduce complex multiply real or imaginary:
2870 // Rdd[+]=vrcmpy[ir](Rss,Rtt[*])
2871 let isCodeGenOnly = 0 in {
2872 def M2_vrcmpyi_s0: T_XTYPE_Vect <"vrcmpyi", 0b000, 0b000, 0>;
2873 def M2_vrcmpyi_s0c: T_XTYPE_Vect <"vrcmpyi", 0b010, 0b000, 1>;
2874 def M2_vrcmaci_s0: T_XTYPE_Vect_acc <"vrcmpyi", 0b000, 0b000, 0>;
2875 def M2_vrcmaci_s0c: T_XTYPE_Vect_acc <"vrcmpyi", 0b010, 0b000, 1>;
2878 let isCodeGenOnly = 0 in {
2879 def M2_vrcmpyr_s0: T_XTYPE_Vect <"vrcmpyr", 0b000, 0b001, 0>;
2880 def M2_vrcmpyr_s0c: T_XTYPE_Vect <"vrcmpyr", 0b011, 0b001, 1>;
2881 def M2_vrcmacr_s0: T_XTYPE_Vect_acc <"vrcmpyr", 0b000, 0b001, 0>;
2882 def M2_vrcmacr_s0c: T_XTYPE_Vect_acc <"vrcmpyr", 0b011, 0b001, 1>;
2884 // Vector reduce halfwords:
2885 // Rdd[+]=vrmpyh(Rss,Rtt)
2886 let isCodeGenOnly = 0 in {
2887 def M2_vrmpy_s0: T_XTYPE_Vect <"vrmpyh", 0b000, 0b010, 0>;
2888 def M2_vrmac_s0: T_XTYPE_Vect_acc <"vrmpyh", 0b000, 0b010, 0>;
2891 //===----------------------------------------------------------------------===//
2892 // Template Class -- Vector Multipy with accumulation.
2893 // Used for complex multiply real or imaginary, dual multiply and even halfwords
2894 //===----------------------------------------------------------------------===//
2895 let Defs = [USR_OVF] in
2896 class T_M2_vmpy_acc_sat < string opc, bits<3> MajOp, bits<3> MinOp,
2897 bit hasShift, bit isRnd >
2898 : MInst <(outs DoubleRegs:$Rxx),
2899 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2900 "$Rxx += "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2901 #!if(isRnd,":rnd","")#":sat",
2902 [], "$dst2 = $Rxx",M_tc_3x_SLOT23 > {
2907 let IClass = 0b1110;
2909 let Inst{27-24} = 0b1010;
2910 let Inst{23-21} = MajOp;
2911 let Inst{7-5} = MinOp;
2912 let Inst{4-0} = Rxx;
2913 let Inst{20-16} = Rss;
2914 let Inst{12-8} = Rtt;
2917 class T_M2_vmpy_acc < string opc, bits<3> MajOp, bits<3> MinOp,
2918 bit hasShift, bit isRnd >
2919 : MInst <(outs DoubleRegs:$Rxx),
2920 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2921 "$Rxx += "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2922 #!if(isRnd,":rnd",""),
2923 [], "$dst2 = $Rxx",M_tc_3x_SLOT23 > {
2928 let IClass = 0b1110;
2930 let Inst{27-24} = 0b1010;
2931 let Inst{23-21} = MajOp;
2932 let Inst{7-5} = MinOp;
2933 let Inst{4-0} = Rxx;
2934 let Inst{20-16} = Rss;
2935 let Inst{12-8} = Rtt;
2938 // Vector multiply word by signed half with accumulation
2939 // Rxx+=vmpyw[eo]h(Rss,Rtt)[:<<1][:rnd]:sat
2940 let isCodeGenOnly = 0 in {
2941 def M2_mmacls_s1: T_M2_vmpy_acc_sat <"vmpyweh", 0b100, 0b101, 1, 0>;
2942 def M2_mmacls_s0: T_M2_vmpy_acc_sat <"vmpyweh", 0b000, 0b101, 0, 0>;
2943 def M2_mmacls_rs1: T_M2_vmpy_acc_sat <"vmpyweh", 0b101, 0b101, 1, 1>;
2944 def M2_mmacls_rs0: T_M2_vmpy_acc_sat <"vmpyweh", 0b001, 0b101, 0, 1>;
2947 let isCodeGenOnly = 0 in {
2948 def M2_mmachs_s1: T_M2_vmpy_acc_sat <"vmpywoh", 0b100, 0b111, 1, 0>;
2949 def M2_mmachs_s0: T_M2_vmpy_acc_sat <"vmpywoh", 0b000, 0b111, 0, 0>;
2950 def M2_mmachs_rs1: T_M2_vmpy_acc_sat <"vmpywoh", 0b101, 0b111, 1, 1>;
2951 def M2_mmachs_rs0: T_M2_vmpy_acc_sat <"vmpywoh", 0b001, 0b111, 0, 1>;
2954 // Vector multiply even halfwords with accumulation
2955 // Rxx+=vmpyeh(Rss,Rtt)[:<<1][:sat]
2956 let isCodeGenOnly = 0 in {
2957 def M2_vmac2es: T_M2_vmpy_acc <"vmpyeh", 0b001, 0b010, 0, 0>;
2958 def M2_vmac2es_s1: T_M2_vmpy_acc_sat <"vmpyeh", 0b100, 0b110, 1, 0>;
2959 def M2_vmac2es_s0: T_M2_vmpy_acc_sat <"vmpyeh", 0b000, 0b110, 0, 0>;
2962 // Vector dual multiply with accumulation
2963 // Rxx+=vdmpy(Rss,Rtt)[:sat]
2964 let isCodeGenOnly = 0 in {
2965 def M2_vdmacs_s1: T_M2_vmpy_acc_sat <"vdmpy", 0b100, 0b100, 1, 0>;
2966 def M2_vdmacs_s0: T_M2_vmpy_acc_sat <"vdmpy", 0b000, 0b100, 0, 0>;
2969 // Vector complex multiply real or imaginary with accumulation
2970 // Rxx+=vcmpy[ir](Rss,Rtt):sat
2971 let isCodeGenOnly = 0 in {
2972 def M2_vcmac_s0_sat_r: T_M2_vmpy_acc_sat <"vcmpyr", 0b001, 0b100, 0, 0>;
2973 def M2_vcmac_s0_sat_i: T_M2_vmpy_acc_sat <"vcmpyi", 0b010, 0b100, 0, 0>;
2976 //===----------------------------------------------------------------------===//
2977 // Template Class -- Multiply signed/unsigned halfwords with and without
2978 // saturation and rounding
2979 //===----------------------------------------------------------------------===//
2980 class T_M2_mpyd < bits<2> LHbits, bit isRnd, bit hasShift, bit isUnsigned >
2981 : MInst < (outs DoubleRegs:$Rdd), (ins IntRegs:$Rs, IntRegs:$Rt),
2982 "$Rdd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
2983 #", $Rt."#!if(LHbits{0},"h)","l)")
2984 #!if(hasShift,":<<1","")
2985 #!if(isRnd,":rnd",""),
2991 let IClass = 0b1110;
2993 let Inst{27-24} = 0b0100;
2994 let Inst{23} = hasShift;
2995 let Inst{22} = isUnsigned;
2996 let Inst{21} = isRnd;
2997 let Inst{6-5} = LHbits;
2998 let Inst{4-0} = Rdd;
2999 let Inst{20-16} = Rs;
3000 let Inst{12-8} = Rt;
3003 let isCodeGenOnly = 0 in {
3004 def M2_mpyd_hh_s0: T_M2_mpyd<0b11, 0, 0, 0>;
3005 def M2_mpyd_hl_s0: T_M2_mpyd<0b10, 0, 0, 0>;
3006 def M2_mpyd_lh_s0: T_M2_mpyd<0b01, 0, 0, 0>;
3007 def M2_mpyd_ll_s0: T_M2_mpyd<0b00, 0, 0, 0>;
3009 def M2_mpyd_hh_s1: T_M2_mpyd<0b11, 0, 1, 0>;
3010 def M2_mpyd_hl_s1: T_M2_mpyd<0b10, 0, 1, 0>;
3011 def M2_mpyd_lh_s1: T_M2_mpyd<0b01, 0, 1, 0>;
3012 def M2_mpyd_ll_s1: T_M2_mpyd<0b00, 0, 1, 0>;
3014 def M2_mpyd_rnd_hh_s0: T_M2_mpyd<0b11, 1, 0, 0>;
3015 def M2_mpyd_rnd_hl_s0: T_M2_mpyd<0b10, 1, 0, 0>;
3016 def M2_mpyd_rnd_lh_s0: T_M2_mpyd<0b01, 1, 0, 0>;
3017 def M2_mpyd_rnd_ll_s0: T_M2_mpyd<0b00, 1, 0, 0>;
3019 def M2_mpyd_rnd_hh_s1: T_M2_mpyd<0b11, 1, 1, 0>;
3020 def M2_mpyd_rnd_hl_s1: T_M2_mpyd<0b10, 1, 1, 0>;
3021 def M2_mpyd_rnd_lh_s1: T_M2_mpyd<0b01, 1, 1, 0>;
3022 def M2_mpyd_rnd_ll_s1: T_M2_mpyd<0b00, 1, 1, 0>;
3024 //Rdd=mpyu(Rs.[HL],Rt.[HL])[:<<1]
3025 def M2_mpyud_hh_s0: T_M2_mpyd<0b11, 0, 0, 1>;
3026 def M2_mpyud_hl_s0: T_M2_mpyd<0b10, 0, 0, 1>;
3027 def M2_mpyud_lh_s0: T_M2_mpyd<0b01, 0, 0, 1>;
3028 def M2_mpyud_ll_s0: T_M2_mpyd<0b00, 0, 0, 1>;
3030 def M2_mpyud_hh_s1: T_M2_mpyd<0b11, 0, 1, 1>;
3031 def M2_mpyud_hl_s1: T_M2_mpyd<0b10, 0, 1, 1>;
3032 def M2_mpyud_lh_s1: T_M2_mpyd<0b01, 0, 1, 1>;
3033 def M2_mpyud_ll_s1: T_M2_mpyd<0b00, 0, 1, 1>;
3035 //===----------------------------------------------------------------------===//
3036 // Template Class for xtype mpy:
3039 // multiply 32X32 and use full result
3040 //===----------------------------------------------------------------------===//
3041 let hasSideEffects = 0 in
3042 class T_XTYPE_mpy64 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
3043 bit isSat, bit hasShift, bit isConj>
3044 : MInst <(outs DoubleRegs:$Rdd),
3045 (ins IntRegs:$Rs, IntRegs:$Rt),
3046 "$Rdd = "#mnemonic#"($Rs, $Rt"#!if(isConj,"*)",")")
3047 #!if(hasShift,":<<1","")
3048 #!if(isSat,":sat",""),
3054 let IClass = 0b1110;
3056 let Inst{27-24} = 0b0101;
3057 let Inst{23-21} = MajOp;
3058 let Inst{20-16} = Rs;
3059 let Inst{12-8} = Rt;
3060 let Inst{7-5} = MinOp;
3061 let Inst{4-0} = Rdd;
3064 //===----------------------------------------------------------------------===//
3065 // Template Class for xtype mpy with accumulation into 64-bit:
3068 // multiply 32X32 and use full result
3069 //===----------------------------------------------------------------------===//
3070 class T_XTYPE_mpy64_acc <string op1, string op2, bits<3> MajOp, bits<3> MinOp,
3071 bit isSat, bit hasShift, bit isConj>
3072 : MInst <(outs DoubleRegs:$Rxx),
3073 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
3074 "$Rxx "#op2#"= "#op1#"($Rs, $Rt"#!if(isConj,"*)",")")
3075 #!if(hasShift,":<<1","")
3076 #!if(isSat,":sat",""),
3078 [] , "$dst2 = $Rxx" > {
3083 let IClass = 0b1110;
3085 let Inst{27-24} = 0b0111;
3086 let Inst{23-21} = MajOp;
3087 let Inst{20-16} = Rs;
3088 let Inst{12-8} = Rt;
3089 let Inst{7-5} = MinOp;
3090 let Inst{4-0} = Rxx;
3093 // MPY - Multiply and use full result
3094 // Rdd = mpy[u](Rs,Rt)
3095 let isCodeGenOnly = 0 in {
3096 def M2_dpmpyss_s0 : T_XTYPE_mpy64 < "mpy", 0b000, 0b000, 0, 0, 0>;
3097 def M2_dpmpyuu_s0 : T_XTYPE_mpy64 < "mpyu", 0b010, 0b000, 0, 0, 0>;
3099 // Rxx[+-]= mpy[u](Rs,Rt)
3100 def M2_dpmpyss_acc_s0 : T_XTYPE_mpy64_acc < "mpy", "+", 0b000, 0b000, 0, 0, 0>;
3101 def M2_dpmpyss_nac_s0 : T_XTYPE_mpy64_acc < "mpy", "-", 0b001, 0b000, 0, 0, 0>;
3102 def M2_dpmpyuu_acc_s0 : T_XTYPE_mpy64_acc < "mpyu", "+", 0b010, 0b000, 0, 0, 0>;
3103 def M2_dpmpyuu_nac_s0 : T_XTYPE_mpy64_acc < "mpyu", "-", 0b011, 0b000, 0, 0, 0>;
3105 // Complex multiply real or imaginary
3106 // Rxx=cmpy[ir](Rs,Rt)
3107 let isCodeGenOnly = 0 in {
3108 def M2_cmpyi_s0 : T_XTYPE_mpy64 < "cmpyi", 0b000, 0b001, 0, 0, 0>;
3109 def M2_cmpyr_s0 : T_XTYPE_mpy64 < "cmpyr", 0b000, 0b010, 0, 0, 0>;
3112 // Rxx+=cmpy[ir](Rs,Rt)
3113 let isCodeGenOnly = 0 in {
3114 def M2_cmaci_s0 : T_XTYPE_mpy64_acc < "cmpyi", "+", 0b000, 0b001, 0, 0, 0>;
3115 def M2_cmacr_s0 : T_XTYPE_mpy64_acc < "cmpyr", "+", 0b000, 0b010, 0, 0, 0>;
3119 // Rdd=cmpy(Rs,Rt)[:<<]:sat
3120 let isCodeGenOnly = 0 in {
3121 def M2_cmpys_s0 : T_XTYPE_mpy64 < "cmpy", 0b000, 0b110, 1, 0, 0>;
3122 def M2_cmpys_s1 : T_XTYPE_mpy64 < "cmpy", 0b100, 0b110, 1, 1, 0>;
3125 // Rdd=cmpy(Rs,Rt*)[:<<]:sat
3126 let isCodeGenOnly = 0 in {
3127 def M2_cmpysc_s0 : T_XTYPE_mpy64 < "cmpy", 0b010, 0b110, 1, 0, 1>;
3128 def M2_cmpysc_s1 : T_XTYPE_mpy64 < "cmpy", 0b110, 0b110, 1, 1, 1>;
3131 // Rxx[-+]=cmpy(Rs,Rt)[:<<1]:sat
3132 let isCodeGenOnly = 0 in {
3133 def M2_cmacs_s0 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b000, 0b110, 1, 0, 0>;
3134 def M2_cnacs_s0 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b000, 0b111, 1, 0, 0>;
3135 def M2_cmacs_s1 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b100, 0b110, 1, 1, 0>;
3136 def M2_cnacs_s1 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b100, 0b111, 1, 1, 0>;
3139 // Rxx[-+]=cmpy(Rs,Rt*)[:<<1]:sat
3140 let isCodeGenOnly = 0 in {
3141 def M2_cmacsc_s0 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b010, 0b110, 1, 0, 1>;
3142 def M2_cnacsc_s0 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b010, 0b111, 1, 0, 1>;
3143 def M2_cmacsc_s1 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b110, 0b110, 1, 1, 1>;
3144 def M2_cnacsc_s1 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b110, 0b111, 1, 1, 1>;
3146 // Vector multiply halfwords
3147 // Rdd=vmpyh(Rs,Rt)[:<<]:sat
3148 //let Defs = [USR_OVF] in {
3149 let isCodeGenOnly = 0 in {
3150 def M2_vmpy2s_s1 : T_XTYPE_mpy64 < "vmpyh", 0b100, 0b101, 1, 1, 0>;
3151 def M2_vmpy2s_s0 : T_XTYPE_mpy64 < "vmpyh", 0b000, 0b101, 1, 0, 0>;
3155 // Rxx+=vmpyh(Rs,Rt)[:<<1][:sat]
3156 let isCodeGenOnly = 0 in {
3157 def M2_vmac2 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b001, 0b001, 0, 0, 0>;
3158 def M2_vmac2s_s1 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b100, 0b101, 1, 1, 0>;
3159 def M2_vmac2s_s0 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b000, 0b101, 1, 0, 0>;
3162 def: Pat<(i64 (mul (i64 (anyext (i32 IntRegs:$src1))),
3163 (i64 (anyext (i32 IntRegs:$src2))))),
3164 (M2_dpmpyuu_s0 IntRegs:$src1, IntRegs:$src2)>;
3166 def: Pat<(i64 (mul (i64 (sext (i32 IntRegs:$src1))),
3167 (i64 (sext (i32 IntRegs:$src2))))),
3168 (M2_dpmpyss_s0 IntRegs:$src1, IntRegs:$src2)>;
3170 def: Pat<(i64 (mul (is_sext_i32:$src1),
3171 (is_sext_i32:$src2))),
3172 (M2_dpmpyss_s0 (LoReg DoubleRegs:$src1), (LoReg DoubleRegs:$src2))>;
3174 // Multiply and accumulate, use full result.
3175 // Rxx[+-]=mpy(Rs,Rt)
3177 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3178 (mul (i64 (sext (i32 IntRegs:$src2))),
3179 (i64 (sext (i32 IntRegs:$src3)))))),
3180 (M2_dpmpyss_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3182 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3183 (mul (i64 (sext (i32 IntRegs:$src2))),
3184 (i64 (sext (i32 IntRegs:$src3)))))),
3185 (M2_dpmpyss_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3187 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3188 (mul (i64 (anyext (i32 IntRegs:$src2))),
3189 (i64 (anyext (i32 IntRegs:$src3)))))),
3190 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3192 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3193 (mul (i64 (zext (i32 IntRegs:$src2))),
3194 (i64 (zext (i32 IntRegs:$src3)))))),
3195 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3197 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3198 (mul (i64 (anyext (i32 IntRegs:$src2))),
3199 (i64 (anyext (i32 IntRegs:$src3)))))),
3200 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3202 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3203 (mul (i64 (zext (i32 IntRegs:$src2))),
3204 (i64 (zext (i32 IntRegs:$src3)))))),
3205 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3207 //===----------------------------------------------------------------------===//
3209 //===----------------------------------------------------------------------===//
3211 //===----------------------------------------------------------------------===//
3213 //===----------------------------------------------------------------------===//
3214 //===----------------------------------------------------------------------===//
3216 //===----------------------------------------------------------------------===//
3218 //===----------------------------------------------------------------------===//
3220 //===----------------------------------------------------------------------===//
3221 //===----------------------------------------------------------------------===//
3223 //===----------------------------------------------------------------------===//
3225 //===----------------------------------------------------------------------===//
3227 //===----------------------------------------------------------------------===//
3228 //===----------------------------------------------------------------------===//
3230 //===----------------------------------------------------------------------===//
3232 //===----------------------------------------------------------------------===//
3234 //===----------------------------------------------------------------------===//
3236 // Store doubleword.
3237 //===----------------------------------------------------------------------===//
3238 // Template class for non-predicated post increment stores with immediate offset
3239 //===----------------------------------------------------------------------===//
3240 let isPredicable = 1, hasSideEffects = 0, addrMode = PostInc in
3241 class T_store_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
3242 bits<4> MajOp, bit isHalf >
3243 : STInst <(outs IntRegs:$_dst_),
3244 (ins IntRegs:$src1, ImmOp:$offset, RC:$src2),
3245 mnemonic#"($src1++#$offset) = $src2"#!if(isHalf, ".h", ""),
3246 [], "$src1 = $_dst_" >,
3253 string ImmOpStr = !cast<string>(ImmOp);
3254 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
3255 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
3256 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
3257 /* s4_0Imm */ offset{3-0})));
3258 let isNVStorable = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
3260 let IClass = 0b1010;
3262 let Inst{27-25} = 0b101;
3263 let Inst{24-21} = MajOp;
3264 let Inst{20-16} = src1;
3266 let Inst{12-8} = src2;
3268 let Inst{6-3} = offsetBits;
3272 //===----------------------------------------------------------------------===//
3273 // Template class for predicated post increment stores with immediate offset
3274 //===----------------------------------------------------------------------===//
3275 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc in
3276 class T_pstore_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
3277 bits<4> MajOp, bit isHalf, bit isPredNot, bit isPredNew >
3278 : STInst <(outs IntRegs:$_dst_),
3279 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset, RC:$src3),
3280 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3281 ") ")#mnemonic#"($src2++#$offset) = $src3"#!if(isHalf, ".h", ""),
3282 [], "$src2 = $_dst_" >,
3290 string ImmOpStr = !cast<string>(ImmOp);
3291 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
3292 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
3293 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
3294 /* s4_0Imm */ offset{3-0})));
3296 let isNVStorable = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
3297 let isPredicatedNew = isPredNew;
3298 let isPredicatedFalse = isPredNot;
3300 let IClass = 0b1010;
3302 let Inst{27-25} = 0b101;
3303 let Inst{24-21} = MajOp;
3304 let Inst{20-16} = src2;
3306 let Inst{12-8} = src3;
3307 let Inst{7} = isPredNew;
3308 let Inst{6-3} = offsetBits;
3309 let Inst{2} = isPredNot;
3310 let Inst{1-0} = src1;
3313 multiclass ST_PostInc<string mnemonic, string BaseOp, RegisterClass RC,
3314 Operand ImmOp, bits<4> MajOp, bit isHalf = 0 > {
3316 let BaseOpcode = "POST_"#BaseOp in {
3317 def S2_#NAME#_pi : T_store_pi <mnemonic, RC, ImmOp, MajOp, isHalf>;
3320 def S2_p#NAME#t_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp, isHalf, 0, 0>;
3321 def S2_p#NAME#f_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp, isHalf, 1, 0>;
3324 def S2_p#NAME#tnew_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp,
3326 def S2_p#NAME#fnew_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp,
3331 let accessSize = ByteAccess, isCodeGenOnly = 0 in
3332 defm storerb: ST_PostInc <"memb", "STrib", IntRegs, s4_0Imm, 0b1000>;
3334 let accessSize = HalfWordAccess, isCodeGenOnly = 0 in
3335 defm storerh: ST_PostInc <"memh", "STrih", IntRegs, s4_1Imm, 0b1010>;
3337 let accessSize = WordAccess, isCodeGenOnly = 0 in
3338 defm storeri: ST_PostInc <"memw", "STriw", IntRegs, s4_2Imm, 0b1100>;
3340 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
3341 defm storerd: ST_PostInc <"memd", "STrid", DoubleRegs, s4_3Imm, 0b1110>;
3343 let accessSize = HalfWordAccess, isNVStorable = 0, isCodeGenOnly = 0 in
3344 defm storerf: ST_PostInc <"memh", "STrih_H", IntRegs, s4_1Imm, 0b1011, 1>;
3346 // Patterns for generating stores, where the address takes different forms:
3349 // - simple (base address without offset).
3350 // These would usually be used together (via Storex_pat defined below), but
3351 // in some cases one may want to apply different properties (such as
3352 // AddedComplexity) to the individual patterns.
3353 class Storex_fi_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
3354 : Pat<(Store Value:$Rs, AddrFI:$fi), (MI AddrFI:$fi, 0, Value:$Rs)>;
3355 class Storex_add_pat<PatFrag Store, PatFrag Value, PatFrag ImmPred,
3357 : Pat<(Store Value:$Rt, (add (i32 IntRegs:$Rs), ImmPred:$Off)),
3358 (MI IntRegs:$Rs, imm:$Off, Value:$Rt)>;
3360 multiclass Storex_pat<PatFrag Store, PatFrag Value, PatLeaf ImmPred,
3362 def: Storex_fi_pat <Store, Value, MI>;
3363 def: Storex_add_pat <Store, Value, ImmPred, MI>;
3366 def : Pat<(post_truncsti8 (i32 IntRegs:$src1), IntRegs:$src2,
3367 s4_3ImmPred:$offset),
3368 (S2_storerb_pi IntRegs:$src2, s4_0ImmPred:$offset, IntRegs:$src1)>;
3370 def : Pat<(post_truncsti16 (i32 IntRegs:$src1), IntRegs:$src2,
3371 s4_3ImmPred:$offset),
3372 (S2_storerh_pi IntRegs:$src2, s4_1ImmPred:$offset, IntRegs:$src1)>;
3374 def : Pat<(post_store (i32 IntRegs:$src1), IntRegs:$src2, s4_2ImmPred:$offset),
3375 (S2_storeri_pi IntRegs:$src2, s4_1ImmPred:$offset, IntRegs:$src1)>;
3377 def : Pat<(post_store (i64 DoubleRegs:$src1), IntRegs:$src2,
3378 s4_3ImmPred:$offset),
3379 (S2_storerd_pi IntRegs:$src2, s4_3ImmPred:$offset, DoubleRegs:$src1)>;
3381 //===----------------------------------------------------------------------===//
3382 // Template class for post increment stores with register offset.
3383 //===----------------------------------------------------------------------===//
3384 let isNVStorable = 1 in
3385 class T_store_pr <string mnemonic, RegisterClass RC, bits<3> MajOp,
3386 MemAccessSize AccessSz, bit isHalf = 0>
3387 : STInst <(outs IntRegs:$_dst_),
3388 (ins IntRegs:$src1, ModRegs:$src2, RC:$src3),
3389 mnemonic#"($src1++$src2) = $src3"#!if(isHalf, ".h", ""),
3390 [], "$src1 = $_dst_" > {
3394 let accessSize = AccessSz;
3396 let IClass = 0b1010;
3398 let Inst{27-24} = 0b1101;
3399 let Inst{23-21} = MajOp;
3400 let Inst{20-16} = src1;
3401 let Inst{13} = src2;
3402 let Inst{12-8} = src3;
3406 let isCodeGenOnly = 0 in {
3407 def S2_storerb_pr : T_store_pr<"memb", IntRegs, 0b000, ByteAccess>;
3408 def S2_storerh_pr : T_store_pr<"memh", IntRegs, 0b010, HalfWordAccess>;
3409 def S2_storeri_pr : T_store_pr<"memw", IntRegs, 0b100, WordAccess>;
3410 def S2_storerd_pr : T_store_pr<"memd", DoubleRegs, 0b110, DoubleWordAccess>;
3412 def S2_storerf_pr : T_store_pr<"memh", IntRegs, 0b011, HalfWordAccess, 1>;
3414 let opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
3415 class T_store_io <string mnemonic, RegisterClass RC, Operand ImmOp,
3416 bits<3>MajOp, bit isH = 0>
3418 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
3419 mnemonic#"($src1+#$src2) = $src3"#!if(isH,".h","")>,
3420 AddrModeRel, ImmRegRel {
3422 bits<14> src2; // Actual address offset
3424 bits<11> offsetBits; // Represents offset encoding
3426 string ImmOpStr = !cast<string>(ImmOp);
3428 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
3429 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
3430 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
3431 /* s11_0Ext */ 11)));
3432 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), src2{13-3},
3433 !if (!eq(ImmOpStr, "s11_2Ext"), src2{12-2},
3434 !if (!eq(ImmOpStr, "s11_1Ext"), src2{11-1},
3435 /* s11_0Ext */ src2{10-0})));
3436 let IClass = 0b1010;
3439 let Inst{26-25} = offsetBits{10-9};
3441 let Inst{23-21} = MajOp;
3442 let Inst{20-16} = src1;
3443 let Inst{13} = offsetBits{8};
3444 let Inst{12-8} = src3;
3445 let Inst{7-0} = offsetBits{7-0};
3448 let opExtendable = 2, isPredicated = 1 in
3449 class T_pstore_io <string mnemonic, RegisterClass RC, Operand ImmOp,
3450 bits<3>MajOp, bit PredNot, bit isPredNew, bit isH = 0>
3452 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$src3, RC:$src4),
3453 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3454 ") ")#mnemonic#"($src2+#$src3) = $src4"#!if(isH,".h",""),
3455 [],"",V2LDST_tc_st_SLOT01 >,
3456 AddrModeRel, ImmRegRel {
3459 bits<9> src3; // Actual address offset
3461 bits<6> offsetBits; // Represents offset encoding
3463 let isPredicatedNew = isPredNew;
3464 let isPredicatedFalse = PredNot;
3466 string ImmOpStr = !cast<string>(ImmOp);
3467 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
3468 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
3469 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
3471 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), src3{8-3},
3472 !if (!eq(ImmOpStr, "u6_2Ext"), src3{7-2},
3473 !if (!eq(ImmOpStr, "u6_1Ext"), src3{6-1},
3474 /* u6_0Ext */ src3{5-0})));
3475 let IClass = 0b0100;
3478 let Inst{26} = PredNot;
3479 let Inst{25} = isPredNew;
3481 let Inst{23-21} = MajOp;
3482 let Inst{20-16} = src2;
3483 let Inst{13} = offsetBits{5};
3484 let Inst{12-8} = src4;
3485 let Inst{7-3} = offsetBits{4-0};
3486 let Inst{1-0} = src1;
3489 let isExtendable = 1, isNVStorable = 1, hasSideEffects = 0 in
3490 multiclass ST_Idxd<string mnemonic, string CextOp, RegisterClass RC,
3491 Operand ImmOp, Operand predImmOp, bits<3> MajOp, bit isH = 0> {
3492 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
3493 def S2_#NAME#_io : T_store_io <mnemonic, RC, ImmOp, MajOp, isH>;
3496 def S2_p#NAME#t_io : T_pstore_io<mnemonic, RC, predImmOp, MajOp, 0, 0, isH>;
3497 def S2_p#NAME#f_io : T_pstore_io<mnemonic, RC, predImmOp, MajOp, 1, 0, isH>;
3500 def S4_p#NAME#tnew_io : T_pstore_io <mnemonic, RC, predImmOp,
3502 def S4_p#NAME#fnew_io : T_pstore_io <mnemonic, RC, predImmOp,
3507 let addrMode = BaseImmOffset, InputType = "imm", isCodeGenOnly = 0 in {
3508 let accessSize = ByteAccess in
3509 defm storerb: ST_Idxd < "memb", "STrib", IntRegs, s11_0Ext, u6_0Ext, 0b000>;
3511 let accessSize = HalfWordAccess, opExtentAlign = 1 in
3512 defm storerh: ST_Idxd < "memh", "STrih", IntRegs, s11_1Ext, u6_1Ext, 0b010>;
3514 let accessSize = WordAccess, opExtentAlign = 2 in
3515 defm storeri: ST_Idxd < "memw", "STriw", IntRegs, s11_2Ext, u6_2Ext, 0b100>;
3517 let accessSize = DoubleWordAccess, isNVStorable = 0, opExtentAlign = 3 in
3518 defm storerd: ST_Idxd < "memd", "STrid", DoubleRegs, s11_3Ext,
3521 let accessSize = HalfWordAccess, opExtentAlign = 1 in
3522 defm storerf: ST_Idxd < "memh", "STrif", IntRegs, s11_1Ext,
3526 class Storex_simple_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
3527 : Pat<(Store Value:$Rt, (i32 IntRegs:$Rs)),
3528 (MI IntRegs:$Rs, 0, Value:$Rt)>;
3530 // Regular stores in the DAG have two operands: value and address.
3531 // Atomic stores also have two, but they are reversed: address, value.
3532 // To use atomic stores with the patterns, they need to have their operands
3533 // swapped. This relies on the knowledge that the F.Fragment uses names
3535 class SwapSt<PatFrag F>
3536 : PatFrag<(ops node:$val, node:$ptr), F.Fragment>;
3538 def: Storex_simple_pat<SwapSt<atomic_store_8>, I32, S2_storerb_io>;
3539 def: Storex_simple_pat<SwapSt<atomic_store_16>, I32, S2_storerh_io>;
3540 def: Storex_simple_pat<SwapSt<atomic_store_32>, I32, S2_storeri_io>;
3541 def: Storex_simple_pat<SwapSt<atomic_store_64>, I64, S2_storerd_io>;
3543 def : Pat<(truncstorei8 (i32 IntRegs:$src1), ADDRriS11_0:$addr),
3544 (S2_storerb_io AddrFI:$addr, 0, (i32 IntRegs:$src1))>;
3546 def : Pat<(truncstorei16 (i32 IntRegs:$src1), ADDRriS11_1:$addr),
3547 (S2_storerh_io AddrFI:$addr, 0, (i32 IntRegs:$src1))>;
3549 def : Pat<(store (i32 IntRegs:$src1), ADDRriS11_2:$addr),
3550 (S2_storeri_io AddrFI:$addr, 0, (i32 IntRegs:$src1))>;
3552 def : Pat<(store (i64 DoubleRegs:$src1), ADDRriS11_3:$addr),
3553 (S2_storerd_io AddrFI:$addr, 0, (i64 DoubleRegs:$src1))>;
3556 let AddedComplexity = 10 in {
3557 def : Pat<(truncstorei8 (i32 IntRegs:$src1), (add IntRegs:$src2,
3558 s11_0ExtPred:$offset)),
3559 (S2_storerb_io IntRegs:$src2, s11_0ImmPred:$offset,
3560 (i32 IntRegs:$src1))>;
3562 def : Pat<(truncstorei16 (i32 IntRegs:$src1), (add IntRegs:$src2,
3563 s11_1ExtPred:$offset)),
3564 (S2_storerh_io IntRegs:$src2, s11_1ImmPred:$offset,
3565 (i32 IntRegs:$src1))>;
3567 def : Pat<(store (i32 IntRegs:$src1), (add IntRegs:$src2,
3568 s11_2ExtPred:$offset)),
3569 (S2_storeri_io IntRegs:$src2, s11_2ImmPred:$offset,
3570 (i32 IntRegs:$src1))>;
3572 def : Pat<(store (i64 DoubleRegs:$src1), (add IntRegs:$src2,
3573 s11_3ExtPred:$offset)),
3574 (S2_storerd_io IntRegs:$src2, s11_3ImmPred:$offset,
3575 (i64 DoubleRegs:$src1))>;
3578 // memh(Rx++#s4:1)=Rt.H
3581 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 13,
3582 isCodeGenOnly = 1, isPseudo = 1, hasSideEffects = 0 in
3583 def STriw_pred : STInst<(outs),
3584 (ins IntRegs:$addr, s11_2Ext:$off, PredRegs:$src1),
3585 ".error \"should not emit\"", []>;
3587 // S2_allocframe: Allocate stack frame.
3588 let Defs = [R29, R30], Uses = [R29, R31, R30],
3589 hasSideEffects = 0, accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
3590 def S2_allocframe: ST0Inst <
3591 (outs), (ins u11_3Imm:$u11_3),
3592 "allocframe(#$u11_3)" > {
3595 let IClass = 0b1010;
3596 let Inst{27-16} = 0b000010011101;
3597 let Inst{13-11} = 0b000;
3598 let Inst{10-0} = u11_3{13-3};
3601 // S2_storer[bhwdf]_pci: Store byte/half/word/double.
3602 // S2_storer[bhwdf]_pci -> S2_storerbnew_pci
3603 let Uses = [CS], isNVStorable = 1 in
3604 class T_store_pci <string mnemonic, RegisterClass RC,
3605 Operand Imm, bits<4>MajOp,
3606 MemAccessSize AlignSize, string RegSrc = "Rt">
3607 : STInst <(outs IntRegs:$_dst_),
3608 (ins IntRegs:$Rz, Imm:$offset, ModRegs:$Mu, RC:$Rt),
3609 #mnemonic#"($Rz ++ #$offset:circ($Mu)) = $"#RegSrc#"",
3616 let accessSize = AlignSize;
3618 let IClass = 0b1010;
3619 let Inst{27-25} = 0b100;
3620 let Inst{24-21} = MajOp;
3621 let Inst{20-16} = Rz;
3623 let Inst{12-8} = Rt;
3626 !if (!eq(!cast<string>(AlignSize), "DoubleWordAccess"), offset{6-3},
3627 !if (!eq(!cast<string>(AlignSize), "WordAccess"), offset{5-2},
3628 !if (!eq(!cast<string>(AlignSize), "HalfWordAccess"), offset{4-1},
3629 /* ByteAccess */ offset{3-0})));
3633 let isCodeGenOnly = 0 in {
3634 def S2_storerb_pci : T_store_pci<"memb", IntRegs, s4_0Imm, 0b1000,
3636 def S2_storerh_pci : T_store_pci<"memh", IntRegs, s4_1Imm, 0b1010,
3638 def S2_storerf_pci : T_store_pci<"memh", IntRegs, s4_1Imm, 0b1011,
3639 HalfWordAccess, "Rt.h">;
3640 def S2_storeri_pci : T_store_pci<"memw", IntRegs, s4_2Imm, 0b1100,
3642 def S2_storerd_pci : T_store_pci<"memd", DoubleRegs, s4_3Imm, 0b1110,
3646 let Uses = [CS], isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 4 in
3647 class T_storenew_pci <string mnemonic, Operand Imm,
3648 bits<2>MajOp, MemAccessSize AlignSize>
3649 : NVInst < (outs IntRegs:$_dst_),
3650 (ins IntRegs:$Rz, Imm:$offset, ModRegs:$Mu, IntRegs:$Nt),
3651 #mnemonic#"($Rz ++ #$offset:circ($Mu)) = $Nt.new",
3659 let accessSize = AlignSize;
3661 let IClass = 0b1010;
3662 let Inst{27-21} = 0b1001101;
3663 let Inst{20-16} = Rz;
3665 let Inst{12-11} = MajOp;
3666 let Inst{10-8} = Nt;
3669 !if (!eq(!cast<string>(AlignSize), "WordAccess"), offset{5-2},
3670 !if (!eq(!cast<string>(AlignSize), "HalfWordAccess"), offset{4-1},
3671 /* ByteAccess */ offset{3-0}));
3674 let isCodeGenOnly = 0 in {
3675 def S2_storerbnew_pci : T_storenew_pci <"memb", s4_0Imm, 0b00, ByteAccess>;
3676 def S2_storerhnew_pci : T_storenew_pci <"memh", s4_1Imm, 0b01, HalfWordAccess>;
3677 def S2_storerinew_pci : T_storenew_pci <"memw", s4_2Imm, 0b10, WordAccess>;
3680 //===----------------------------------------------------------------------===//
3681 // Circular stores with auto-increment register
3682 //===----------------------------------------------------------------------===//
3683 let Uses = [CS], isNVStorable = 1, isCodeGenOnly = 0 in
3684 class T_store_pcr <string mnemonic, RegisterClass RC, bits<4>MajOp,
3685 MemAccessSize AlignSize, string RegSrc = "Rt">
3686 : STInst <(outs IntRegs:$_dst_),
3687 (ins IntRegs:$Rz, ModRegs:$Mu, RC:$Rt),
3688 #mnemonic#"($Rz ++ I:circ($Mu)) = $"#RegSrc#"",
3695 let accessSize = AlignSize;
3697 let IClass = 0b1010;
3698 let Inst{27-25} = 0b100;
3699 let Inst{24-21} = MajOp;
3700 let Inst{20-16} = Rz;
3702 let Inst{12-8} = Rt;
3707 let isCodeGenOnly = 0 in {
3708 def S2_storerb_pcr : T_store_pcr<"memb", IntRegs, 0b1000, ByteAccess>;
3709 def S2_storerh_pcr : T_store_pcr<"memh", IntRegs, 0b1010, HalfWordAccess>;
3710 def S2_storeri_pcr : T_store_pcr<"memw", IntRegs, 0b1100, WordAccess>;
3711 def S2_storerd_pcr : T_store_pcr<"memd", DoubleRegs, 0b1110, DoubleWordAccess>;
3712 def S2_storerf_pcr : T_store_pcr<"memh", IntRegs, 0b1011,
3713 HalfWordAccess, "Rt.h">;
3716 //===----------------------------------------------------------------------===//
3717 // Circular .new stores with auto-increment register
3718 //===----------------------------------------------------------------------===//
3719 let Uses = [CS], isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
3720 class T_storenew_pcr <string mnemonic, bits<2>MajOp,
3721 MemAccessSize AlignSize>
3722 : NVInst <(outs IntRegs:$_dst_),
3723 (ins IntRegs:$Rz, ModRegs:$Mu, IntRegs:$Nt),
3724 #mnemonic#"($Rz ++ I:circ($Mu)) = $Nt.new" ,
3731 let accessSize = AlignSize;
3733 let IClass = 0b1010;
3734 let Inst{27-21} = 0b1001101;
3735 let Inst{20-16} = Rz;
3737 let Inst{12-11} = MajOp;
3738 let Inst{10-8} = Nt;
3743 let isCodeGenOnly = 0 in {
3744 def S2_storerbnew_pcr : T_storenew_pcr <"memb", 0b00, ByteAccess>;
3745 def S2_storerhnew_pcr : T_storenew_pcr <"memh", 0b01, HalfWordAccess>;
3746 def S2_storerinew_pcr : T_storenew_pcr <"memw", 0b10, WordAccess>;
3749 //===----------------------------------------------------------------------===//
3750 // Bit-reversed stores with auto-increment register
3751 //===----------------------------------------------------------------------===//
3752 let hasSideEffects = 0 in
3753 class T_store_pbr<string mnemonic, RegisterClass RC,
3754 MemAccessSize addrSize, bits<3> majOp,
3757 <(outs IntRegs:$_dst_),
3758 (ins IntRegs:$Rz, ModRegs:$Mu, RC:$src),
3759 #mnemonic#"($Rz ++ $Mu:brev) = $src"#!if (!eq(isHalf, 1), ".h", ""),
3760 [], "$Rz = $_dst_" > {
3762 let accessSize = addrSize;
3768 let IClass = 0b1010;
3770 let Inst{27-24} = 0b1111;
3771 let Inst{23-21} = majOp;
3773 let Inst{20-16} = Rz;
3775 let Inst{12-8} = src;
3778 let isNVStorable = 1, isCodeGenOnly = 0 in {
3779 let BaseOpcode = "S2_storerb_pbr" in
3780 def S2_storerb_pbr : T_store_pbr<"memb", IntRegs, ByteAccess,
3781 0b000>, NewValueRel;
3782 let BaseOpcode = "S2_storerh_pbr" in
3783 def S2_storerh_pbr : T_store_pbr<"memh", IntRegs, HalfWordAccess,
3784 0b010>, NewValueRel;
3785 let BaseOpcode = "S2_storeri_pbr" in
3786 def S2_storeri_pbr : T_store_pbr<"memw", IntRegs, WordAccess,
3787 0b100>, NewValueRel;
3789 let isCodeGenOnly = 0 in {
3790 def S2_storerf_pbr : T_store_pbr<"memh", IntRegs, HalfWordAccess, 0b011, 1>;
3791 def S2_storerd_pbr : T_store_pbr<"memd", DoubleRegs, DoubleWordAccess, 0b110>;
3794 //===----------------------------------------------------------------------===//
3795 // Bit-reversed .new stores with auto-increment register
3796 //===----------------------------------------------------------------------===//
3797 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3,
3798 hasSideEffects = 0 in
3799 class T_storenew_pbr<string mnemonic, MemAccessSize addrSize, bits<2> majOp>
3800 : NVInst <(outs IntRegs:$_dst_),
3801 (ins IntRegs:$Rz, ModRegs:$Mu, IntRegs:$Nt),
3802 #mnemonic#"($Rz ++ $Mu:brev) = $Nt.new", [],
3803 "$Rz = $_dst_">, NewValueRel {
3804 let accessSize = addrSize;
3809 let IClass = 0b1010;
3811 let Inst{27-21} = 0b1111101;
3812 let Inst{12-11} = majOp;
3814 let Inst{20-16} = Rz;
3816 let Inst{10-8} = Nt;
3819 let BaseOpcode = "S2_storerb_pbr", isCodeGenOnly = 0 in
3820 def S2_storerbnew_pbr : T_storenew_pbr<"memb", ByteAccess, 0b00>;
3822 let BaseOpcode = "S2_storerh_pbr", isCodeGenOnly = 0 in
3823 def S2_storerhnew_pbr : T_storenew_pbr<"memh", HalfWordAccess, 0b01>;
3825 let BaseOpcode = "S2_storeri_pbr", isCodeGenOnly = 0 in
3826 def S2_storerinew_pbr : T_storenew_pbr<"memw", WordAccess, 0b10>;
3828 //===----------------------------------------------------------------------===//
3830 //===----------------------------------------------------------------------===//
3832 //===----------------------------------------------------------------------===//
3834 //===----------------------------------------------------------------------===//
3836 def NOT_rr64 : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1),
3837 "$dst = not($src1)",
3838 [(set (i64 DoubleRegs:$dst), (not (i64 DoubleRegs:$src1)))]>;
3841 //===----------------------------------------------------------------------===//
3843 //===----------------------------------------------------------------------===//
3845 let hasSideEffects = 0 in
3846 class T_S2op_1 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
3847 RegisterClass RCIn, bits<2> MajOp, bits<3> MinOp, bit isSat>
3848 : SInst <(outs RCOut:$dst), (ins RCIn:$src),
3849 "$dst = "#mnemonic#"($src)"#!if(isSat, ":sat", ""),
3850 [], "", S_2op_tc_1_SLOT23 > {
3854 let IClass = 0b1000;
3856 let Inst{27-24} = RegTyBits;
3857 let Inst{23-22} = MajOp;
3859 let Inst{20-16} = src;
3860 let Inst{7-5} = MinOp;
3861 let Inst{4-0} = dst;
3864 class T_S2op_1_di <string mnemonic, bits<2> MajOp, bits<3> MinOp>
3865 : T_S2op_1 <mnemonic, 0b0100, DoubleRegs, IntRegs, MajOp, MinOp, 0>;
3867 let hasNewValue = 1 in
3868 class T_S2op_1_id <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
3869 : T_S2op_1 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, isSat>;
3871 let hasNewValue = 1 in
3872 class T_S2op_1_ii <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
3873 : T_S2op_1 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp, isSat>;
3875 // Vector sign/zero extend
3876 let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 0 in {
3877 def S2_vsxtbh : T_S2op_1_di <"vsxtbh", 0b00, 0b000>;
3878 def S2_vsxthw : T_S2op_1_di <"vsxthw", 0b00, 0b100>;
3879 def S2_vzxtbh : T_S2op_1_di <"vzxtbh", 0b00, 0b010>;
3880 def S2_vzxthw : T_S2op_1_di <"vzxthw", 0b00, 0b110>;
3883 // Vector splat bytes/halfwords
3884 let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 0 in {
3885 def S2_vsplatrb : T_S2op_1_ii <"vsplatb", 0b01, 0b111>;
3886 def S2_vsplatrh : T_S2op_1_di <"vsplath", 0b01, 0b010>;
3889 // Sign extend word to doubleword
3890 let isCodeGenOnly = 0 in
3891 def A2_sxtw : T_S2op_1_di <"sxtw", 0b01, 0b000>;
3893 def: Pat <(i64 (sext I32:$src)), (A2_sxtw I32:$src)>;
3895 // Vector saturate and pack
3896 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
3897 def S2_svsathb : T_S2op_1_ii <"vsathb", 0b10, 0b000>;
3898 def S2_svsathub : T_S2op_1_ii <"vsathub", 0b10, 0b010>;
3899 def S2_vsathb : T_S2op_1_id <"vsathb", 0b00, 0b110>;
3900 def S2_vsathub : T_S2op_1_id <"vsathub", 0b00, 0b000>;
3901 def S2_vsatwh : T_S2op_1_id <"vsatwh", 0b00, 0b010>;
3902 def S2_vsatwuh : T_S2op_1_id <"vsatwuh", 0b00, 0b100>;
3906 let isCodeGenOnly = 0 in {
3907 def S2_vtrunohb : T_S2op_1_id <"vtrunohb", 0b10, 0b000>;
3908 def S2_vtrunehb : T_S2op_1_id <"vtrunehb", 0b10, 0b010>;
3911 // Swizzle the bytes of a word
3912 let isCodeGenOnly = 0 in
3913 def A2_swiz : T_S2op_1_ii <"swiz", 0b10, 0b111>;
3916 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
3917 def A2_sat : T_S2op_1_id <"sat", 0b11, 0b000>;
3918 def A2_satb : T_S2op_1_ii <"satb", 0b11, 0b111>;
3919 def A2_satub : T_S2op_1_ii <"satub", 0b11, 0b110>;
3920 def A2_sath : T_S2op_1_ii <"sath", 0b11, 0b100>;
3921 def A2_satuh : T_S2op_1_ii <"satuh", 0b11, 0b101>;
3922 def A2_roundsat : T_S2op_1_id <"round", 0b11, 0b001, 0b1>;
3925 let Itinerary = S_2op_tc_2_SLOT23, isCodeGenOnly = 0 in {
3926 // Vector round and pack
3927 def S2_vrndpackwh : T_S2op_1_id <"vrndwh", 0b10, 0b100>;
3929 let Defs = [USR_OVF] in
3930 def S2_vrndpackwhs : T_S2op_1_id <"vrndwh", 0b10, 0b110, 1>;
3933 def S2_brev : T_S2op_1_ii <"brev", 0b01, 0b110>;
3935 // Absolute value word
3936 def A2_abs : T_S2op_1_ii <"abs", 0b10, 0b100>;
3938 let Defs = [USR_OVF] in
3939 def A2_abssat : T_S2op_1_ii <"abs", 0b10, 0b101, 1>;
3941 // Negate with saturation
3942 let Defs = [USR_OVF] in
3943 def A2_negsat : T_S2op_1_ii <"neg", 0b10, 0b110, 1>;
3946 def: Pat<(i32 (select (i1 (setlt (i32 IntRegs:$src), 0)),
3947 (i32 (sub 0, (i32 IntRegs:$src))),
3948 (i32 IntRegs:$src))),
3949 (A2_abs IntRegs:$src)>;
3951 let AddedComplexity = 50 in
3952 def: Pat<(i32 (xor (add (sra (i32 IntRegs:$src), (i32 31)),
3953 (i32 IntRegs:$src)),
3954 (sra (i32 IntRegs:$src), (i32 31)))),
3955 (A2_abs IntRegs:$src)>;
3957 class T_S2op_2 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
3958 RegisterClass RCIn, bits<3> MajOp, bits<3> MinOp,
3959 bit isSat, bit isRnd, list<dag> pattern = []>
3960 : SInst <(outs RCOut:$dst),
3961 (ins RCIn:$src, u5Imm:$u5),
3962 "$dst = "#mnemonic#"($src, #$u5)"#!if(isSat, ":sat", "")
3963 #!if(isRnd, ":rnd", ""),
3964 pattern, "", S_2op_tc_2_SLOT23> {
3969 let IClass = 0b1000;
3971 let Inst{27-24} = RegTyBits;
3972 let Inst{23-21} = MajOp;
3973 let Inst{20-16} = src;
3975 let Inst{12-8} = u5;
3976 let Inst{7-5} = MinOp;
3977 let Inst{4-0} = dst;
3980 class T_S2op_2_di <string mnemonic, bits<3> MajOp, bits<3> MinOp>
3981 : T_S2op_2 <mnemonic, 0b1000, DoubleRegs, IntRegs, MajOp, MinOp, 0, 0>;
3983 let hasNewValue = 1 in
3984 class T_S2op_2_id <string mnemonic, bits<3> MajOp, bits<3> MinOp>
3985 : T_S2op_2 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, 0, 0>;
3987 let hasNewValue = 1 in
3988 class T_S2op_2_ii <string mnemonic, bits<3> MajOp, bits<3> MinOp,
3989 bit isSat = 0, bit isRnd = 0, list<dag> pattern = []>
3990 : T_S2op_2 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp,
3991 isSat, isRnd, pattern>;
3993 class T_S2op_shift <string mnemonic, bits<3> MajOp, bits<3> MinOp, SDNode OpNd>
3994 : T_S2op_2_ii <mnemonic, MajOp, MinOp, 0, 0,
3995 [(set (i32 IntRegs:$dst), (OpNd (i32 IntRegs:$src),
3996 (u5ImmPred:$u5)))]>;
3998 // Vector arithmetic shift right by immediate with truncate and pack
3999 let isCodeGenOnly = 0 in
4000 def S2_asr_i_svw_trun : T_S2op_2_id <"vasrw", 0b110, 0b010>;
4002 // Arithmetic/logical shift right/left by immediate
4003 let Itinerary = S_2op_tc_1_SLOT23, isCodeGenOnly = 0 in {
4004 def S2_asr_i_r : T_S2op_shift <"asr", 0b000, 0b000, sra>;
4005 def S2_lsr_i_r : T_S2op_shift <"lsr", 0b000, 0b001, srl>;
4006 def S2_asl_i_r : T_S2op_shift <"asl", 0b000, 0b010, shl>;
4009 // Shift left by immediate with saturation
4010 let Defs = [USR_OVF], isCodeGenOnly = 0 in
4011 def S2_asl_i_r_sat : T_S2op_2_ii <"asl", 0b010, 0b010, 1>;
4013 // Shift right with round
4014 let isCodeGenOnly = 0 in
4015 def S2_asr_i_r_rnd : T_S2op_2_ii <"asr", 0b010, 0b000, 0, 1>;
4017 def S2_asr_i_r_rnd_goodsyntax
4018 : SInst <(outs IntRegs:$dst), (ins IntRegs:$src, u5Imm:$u5),
4019 "$dst = asrrnd($src, #$u5)",
4020 [], "", S_2op_tc_1_SLOT23>;
4022 def: Pat<(i32 (sra (i32 (add (i32 (sra I32:$src1, u5ImmPred:$src2)),
4025 (S2_asr_i_r_rnd IntRegs:$src1, u5ImmPred:$src2)>;
4027 class T_S2op_3<string opc, bits<2>MajOp, bits<3>minOp, bits<1> sat = 0>
4028 : SInst<(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss),
4029 "$Rdd = "#opc#"($Rss)"#!if(!eq(sat, 1),":sat","")> {
4032 let IClass = 0b1000;
4033 let Inst{27-24} = 0;
4034 let Inst{23-22} = MajOp;
4035 let Inst{20-16} = Rss;
4036 let Inst{7-5} = minOp;
4037 let Inst{4-0} = Rdd;
4040 let isCodeGenOnly = 0 in {
4041 def A2_absp : T_S2op_3 <"abs", 0b10, 0b110>;
4042 def A2_negp : T_S2op_3 <"neg", 0b10, 0b101>;
4043 def A2_notp : T_S2op_3 <"not", 0b10, 0b100>;
4046 // Innterleave/deinterleave
4047 let isCodeGenOnly = 0 in {
4048 def S2_interleave : T_S2op_3 <"interleave", 0b11, 0b101>;
4049 def S2_deinterleave : T_S2op_3 <"deinterleave", 0b11, 0b100>;
4052 // Vector Complex conjugate
4053 let isCodeGenOnly = 0 in
4054 def A2_vconj : T_S2op_3 <"vconj", 0b10, 0b111, 1>;
4056 // Vector saturate without pack
4057 let isCodeGenOnly = 0 in {
4058 def S2_vsathb_nopack : T_S2op_3 <"vsathb", 0b00, 0b111>;
4059 def S2_vsathub_nopack : T_S2op_3 <"vsathub", 0b00, 0b100>;
4060 def S2_vsatwh_nopack : T_S2op_3 <"vsatwh", 0b00, 0b110>;
4061 def S2_vsatwuh_nopack : T_S2op_3 <"vsatwuh", 0b00, 0b101>;
4064 // Vector absolute value halfwords with and without saturation
4065 // Rdd64=vabsh(Rss64)[:sat]
4066 let isCodeGenOnly = 0 in {
4067 def A2_vabsh : T_S2op_3 <"vabsh", 0b01, 0b100>;
4068 def A2_vabshsat : T_S2op_3 <"vabsh", 0b01, 0b101, 1>;
4071 // Vector absolute value words with and without saturation
4072 let isCodeGenOnly = 0 in {
4073 def A2_vabsw : T_S2op_3 <"vabsw", 0b01, 0b110>;
4074 def A2_vabswsat : T_S2op_3 <"vabsw", 0b01, 0b111, 1>;
4077 //===----------------------------------------------------------------------===//
4079 //===----------------------------------------------------------------------===//
4082 let hasSideEffects = 0, hasNewValue = 1 in
4083 class T_COUNT_LEADING<string MnOp, bits<3> MajOp, bits<3> MinOp, bit Is32,
4085 : SInst<Out, Inp, "$Rd = "#MnOp#"($Rs)", [], "", S_2op_tc_1_SLOT23> {
4088 let IClass = 0b1000;
4090 let Inst{26} = Is32;
4091 let Inst{25-24} = 0b00;
4092 let Inst{23-21} = MajOp;
4093 let Inst{20-16} = Rs;
4094 let Inst{7-5} = MinOp;
4098 class T_COUNT_LEADING_32<string MnOp, bits<3> MajOp, bits<3> MinOp>
4099 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b1,
4100 (outs IntRegs:$Rd), (ins IntRegs:$Rs)>;
4102 class T_COUNT_LEADING_64<string MnOp, bits<3> MajOp, bits<3> MinOp>
4103 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b0,
4104 (outs IntRegs:$Rd), (ins DoubleRegs:$Rs)>;
4106 let isCodeGenOnly = 0 in {
4107 def S2_cl0 : T_COUNT_LEADING_32<"cl0", 0b000, 0b101>;
4108 def S2_cl1 : T_COUNT_LEADING_32<"cl1", 0b000, 0b110>;
4109 def S2_ct0 : T_COUNT_LEADING_32<"ct0", 0b010, 0b100>;
4110 def S2_ct1 : T_COUNT_LEADING_32<"ct1", 0b010, 0b101>;
4111 def S2_cl0p : T_COUNT_LEADING_64<"cl0", 0b010, 0b010>;
4112 def S2_cl1p : T_COUNT_LEADING_64<"cl1", 0b010, 0b100>;
4113 def S2_clb : T_COUNT_LEADING_32<"clb", 0b000, 0b100>;
4114 def S2_clbp : T_COUNT_LEADING_64<"clb", 0b010, 0b000>;
4115 def S2_clbnorm : T_COUNT_LEADING_32<"normamt", 0b000, 0b111>;
4118 def: Pat<(i32 (ctlz I32:$Rs)), (S2_cl0 I32:$Rs)>;
4119 def: Pat<(i32 (ctlz (not I32:$Rs))), (S2_cl1 I32:$Rs)>;
4120 def: Pat<(i32 (cttz I32:$Rs)), (S2_ct0 I32:$Rs)>;
4121 def: Pat<(i32 (cttz (not I32:$Rs))), (S2_ct1 I32:$Rs)>;
4122 def: Pat<(i32 (trunc (ctlz I64:$Rss))), (S2_cl0p I64:$Rss)>;
4123 def: Pat<(i32 (trunc (ctlz (not I64:$Rss)))), (S2_cl1p I64:$Rss)>;
4125 // Bit set/clear/toggle
4127 let hasSideEffects = 0, hasNewValue = 1 in
4128 class T_SCT_BIT_IMM<string MnOp, bits<3> MinOp>
4129 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, u5Imm:$u5),
4130 "$Rd = "#MnOp#"($Rs, #$u5)", [], "", S_2op_tc_1_SLOT23> {
4134 let IClass = 0b1000;
4135 let Inst{27-21} = 0b1100110;
4136 let Inst{20-16} = Rs;
4138 let Inst{12-8} = u5;
4139 let Inst{7-5} = MinOp;
4143 let hasSideEffects = 0, hasNewValue = 1 in
4144 class T_SCT_BIT_REG<string MnOp, bits<2> MinOp>
4145 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
4146 "$Rd = "#MnOp#"($Rs, $Rt)", [], "", S_3op_tc_1_SLOT23> {
4150 let IClass = 0b1100;
4151 let Inst{27-22} = 0b011010;
4152 let Inst{20-16} = Rs;
4153 let Inst{12-8} = Rt;
4154 let Inst{7-6} = MinOp;
4158 let isCodeGenOnly = 0 in {
4159 def S2_clrbit_i : T_SCT_BIT_IMM<"clrbit", 0b001>;
4160 def S2_setbit_i : T_SCT_BIT_IMM<"setbit", 0b000>;
4161 def S2_togglebit_i : T_SCT_BIT_IMM<"togglebit", 0b010>;
4162 def S2_clrbit_r : T_SCT_BIT_REG<"clrbit", 0b01>;
4163 def S2_setbit_r : T_SCT_BIT_REG<"setbit", 0b00>;
4164 def S2_togglebit_r : T_SCT_BIT_REG<"togglebit", 0b10>;
4167 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, u5ImmPred:$u5)))),
4168 (S2_clrbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4169 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
4170 (S2_setbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4171 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
4172 (S2_togglebit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4173 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, (i32 IntRegs:$Rt))))),
4174 (S2_clrbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4175 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
4176 (S2_setbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4177 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
4178 (S2_togglebit_r IntRegs:$Rs, IntRegs:$Rt)>;
4182 let hasSideEffects = 0 in
4183 class T_TEST_BIT_IMM<string MnOp, bits<3> MajOp>
4184 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u5Imm:$u5),
4185 "$Pd = "#MnOp#"($Rs, #$u5)",
4186 [], "", S_2op_tc_2early_SLOT23> {
4190 let IClass = 0b1000;
4191 let Inst{27-24} = 0b0101;
4192 let Inst{23-21} = MajOp;
4193 let Inst{20-16} = Rs;
4195 let Inst{12-8} = u5;
4199 let hasSideEffects = 0 in
4200 class T_TEST_BIT_REG<string MnOp, bit IsNeg>
4201 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
4202 "$Pd = "#MnOp#"($Rs, $Rt)",
4203 [], "", S_3op_tc_2early_SLOT23> {
4207 let IClass = 0b1100;
4208 let Inst{27-22} = 0b011100;
4209 let Inst{21} = IsNeg;
4210 let Inst{20-16} = Rs;
4211 let Inst{12-8} = Rt;
4215 let isCodeGenOnly = 0 in {
4216 def S2_tstbit_i : T_TEST_BIT_IMM<"tstbit", 0b000>;
4217 def S2_tstbit_r : T_TEST_BIT_REG<"tstbit", 0>;
4220 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
4221 def: Pat<(i1 (setne (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
4222 (S2_tstbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4223 def: Pat<(i1 (setne (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
4224 (S2_tstbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4225 def: Pat<(i1 (trunc (i32 IntRegs:$Rs))),
4226 (S2_tstbit_i IntRegs:$Rs, 0)>;
4227 def: Pat<(i1 (trunc (i64 DoubleRegs:$Rs))),
4228 (S2_tstbit_i (LoReg DoubleRegs:$Rs), 0)>;
4230 let hasSideEffects = 0 in
4231 class T_TEST_BITS_IMM<string MnOp, bits<2> MajOp, bit IsNeg>
4232 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u6Imm:$u6),
4233 "$Pd = "#MnOp#"($Rs, #$u6)",
4234 [], "", S_2op_tc_2early_SLOT23> {
4238 let IClass = 0b1000;
4239 let Inst{27-24} = 0b0101;
4240 let Inst{23-22} = MajOp;
4241 let Inst{21} = IsNeg;
4242 let Inst{20-16} = Rs;
4243 let Inst{13-8} = u6;
4247 let hasSideEffects = 0 in
4248 class T_TEST_BITS_REG<string MnOp, bits<2> MajOp, bit IsNeg>
4249 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
4250 "$Pd = "#MnOp#"($Rs, $Rt)",
4251 [], "", S_3op_tc_2early_SLOT23> {
4255 let IClass = 0b1100;
4256 let Inst{27-24} = 0b0111;
4257 let Inst{23-22} = MajOp;
4258 let Inst{21} = IsNeg;
4259 let Inst{20-16} = Rs;
4260 let Inst{12-8} = Rt;
4264 let isCodeGenOnly = 0 in {
4265 def C2_bitsclri : T_TEST_BITS_IMM<"bitsclr", 0b10, 0>;
4266 def C2_bitsclr : T_TEST_BITS_REG<"bitsclr", 0b10, 0>;
4267 def C2_bitsset : T_TEST_BITS_REG<"bitsset", 0b01, 0>;
4270 let AddedComplexity = 20 in { // Complexity greater than compare reg-imm.
4271 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), u6ImmPred:$u6), 0)),
4272 (C2_bitsclri IntRegs:$Rs, u6ImmPred:$u6)>;
4273 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), 0)),
4274 (C2_bitsclr IntRegs:$Rs, IntRegs:$Rt)>;
4277 let AddedComplexity = 10 in // Complexity greater than compare reg-reg.
4278 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), IntRegs:$Rt)),
4279 (C2_bitsset IntRegs:$Rs, IntRegs:$Rt)>;
4281 //===----------------------------------------------------------------------===//
4283 //===----------------------------------------------------------------------===//
4285 //===----------------------------------------------------------------------===//
4287 //===----------------------------------------------------------------------===//
4288 //===----------------------------------------------------------------------===//
4290 //===----------------------------------------------------------------------===//
4292 //===----------------------------------------------------------------------===//
4294 //===----------------------------------------------------------------------===//
4296 //===----------------------------------------------------------------------===//
4298 //===----------------------------------------------------------------------===//
4300 //===----------------------------------------------------------------------===//
4302 //===----------------------------------------------------------------------===//
4304 // Predicate transfer.
4305 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
4306 def C2_tfrpr : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps),
4307 "$Rd = $Ps", [], "", S_2op_tc_1_SLOT23> {
4311 let IClass = 0b1000;
4312 let Inst{27-24} = 0b1001;
4314 let Inst{17-16} = Ps;
4318 // Transfer general register to predicate.
4319 let hasSideEffects = 0, isCodeGenOnly = 0 in
4320 def C2_tfrrp: SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs),
4321 "$Pd = $Rs", [], "", S_2op_tc_2early_SLOT23> {
4325 let IClass = 0b1000;
4326 let Inst{27-21} = 0b0101010;
4327 let Inst{20-16} = Rs;
4332 //===----------------------------------------------------------------------===//
4334 //===----------------------------------------------------------------------===//
4336 //===----------------------------------------------------------------------===//
4338 //===----------------------------------------------------------------------===//
4339 class S_2OpInstImm<string Mnemonic, bits<3>MajOp, bits<3>MinOp,
4340 Operand Imm, list<dag> pattern = [], bit isRnd = 0>
4341 : SInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, Imm:$src2),
4342 "$dst = "#Mnemonic#"($src1, #$src2)"#!if(isRnd, ":rnd", ""),
4346 let IClass = 0b1000;
4347 let Inst{27-24} = 0;
4348 let Inst{23-21} = MajOp;
4349 let Inst{20-16} = src1;
4350 let Inst{7-5} = MinOp;
4351 let Inst{4-0} = dst;
4354 class S_2OpInstImmI6<string Mnemonic, SDNode OpNode, bits<3>MinOp>
4355 : S_2OpInstImm<Mnemonic, 0b000, MinOp, u6Imm,
4356 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
4357 u6ImmPred:$src2))]> {
4359 let Inst{13-8} = src2;
4362 // Shift by immediate.
4363 let isCodeGenOnly = 0 in {
4364 def S2_asr_i_p : S_2OpInstImmI6<"asr", sra, 0b000>;
4365 def S2_asl_i_p : S_2OpInstImmI6<"asl", shl, 0b010>;
4366 def S2_lsr_i_p : S_2OpInstImmI6<"lsr", srl, 0b001>;
4369 // Shift left by small amount and add.
4370 let AddedComplexity = 100, hasNewValue = 1, hasSideEffects = 0,
4371 isCodeGenOnly = 0 in
4372 def S2_addasl_rrri: SInst <(outs IntRegs:$Rd),
4373 (ins IntRegs:$Rt, IntRegs:$Rs, u3Imm:$u3),
4374 "$Rd = addasl($Rt, $Rs, #$u3)" ,
4375 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rt),
4376 (shl (i32 IntRegs:$Rs), u3ImmPred:$u3)))],
4377 "", S_3op_tc_2_SLOT23> {
4383 let IClass = 0b1100;
4385 let Inst{27-21} = 0b0100000;
4386 let Inst{20-16} = Rs;
4388 let Inst{12-8} = Rt;
4393 //===----------------------------------------------------------------------===//
4395 //===----------------------------------------------------------------------===//
4397 //===----------------------------------------------------------------------===//
4399 //===----------------------------------------------------------------------===//
4400 //===----------------------------------------------------------------------===//
4402 //===----------------------------------------------------------------------===//
4404 //===----------------------------------------------------------------------===//
4406 //===----------------------------------------------------------------------===//
4407 //===----------------------------------------------------------------------===//
4409 //===----------------------------------------------------------------------===//
4411 //===----------------------------------------------------------------------===//
4413 //===----------------------------------------------------------------------===//
4415 //===----------------------------------------------------------------------===//
4417 //===----------------------------------------------------------------------===//
4418 def HexagonBARRIER: SDNode<"HexagonISD::BARRIER", SDTNone, [SDNPHasChain]>;
4420 let hasSideEffects = 1, isSoloAX = 1, isCodeGenOnly = 0 in
4421 def BARRIER : SYSInst<(outs), (ins),
4423 [(HexagonBARRIER)],"",ST_tc_st_SLOT0> {
4424 let Inst{31-28} = 0b1010;
4425 let Inst{27-21} = 0b1000000;
4428 //===----------------------------------------------------------------------===//
4430 //===----------------------------------------------------------------------===//
4431 //===----------------------------------------------------------------------===//
4433 //===----------------------------------------------------------------------===//
4435 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
4436 opExtendable = 0, hasSideEffects = 0 in
4437 class LOOP_iBase<string mnemonic, Operand brOp, bit mustExtend = 0>
4438 : CRInst<(outs), (ins brOp:$offset, u10Imm:$src2),
4439 #mnemonic#"($offset, #$src2)",
4440 [], "" , CR_tc_3x_SLOT3> {
4444 let IClass = 0b0110;
4446 let Inst{27-22} = 0b100100;
4447 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
4448 let Inst{20-16} = src2{9-5};
4449 let Inst{12-8} = offset{8-4};
4450 let Inst{7-5} = src2{4-2};
4451 let Inst{4-3} = offset{3-2};
4452 let Inst{1-0} = src2{1-0};
4455 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
4456 opExtendable = 0, hasSideEffects = 0 in
4457 class LOOP_rBase<string mnemonic, Operand brOp, bit mustExtend = 0>
4458 : CRInst<(outs), (ins brOp:$offset, IntRegs:$src2),
4459 #mnemonic#"($offset, $src2)",
4460 [], "" ,CR_tc_3x_SLOT3> {
4464 let IClass = 0b0110;
4466 let Inst{27-22} = 0b000000;
4467 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
4468 let Inst{20-16} = src2;
4469 let Inst{12-8} = offset{8-4};
4470 let Inst{4-3} = offset{3-2};
4473 multiclass LOOP_ri<string mnemonic> {
4474 def i : LOOP_iBase<mnemonic, brtarget>;
4475 def r : LOOP_rBase<mnemonic, brtarget>;
4479 let Defs = [SA0, LC0, USR], isCodeGenOnly = 0 in
4480 defm J2_loop0 : LOOP_ri<"loop0">;
4482 // Interestingly only loop0's appear to set usr.lpcfg
4483 let Defs = [SA1, LC1], isCodeGenOnly = 0 in
4484 defm J2_loop1 : LOOP_ri<"loop1">;
4486 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
4487 Defs = [PC, LC0], Uses = [SA0, LC0] in {
4488 def ENDLOOP0 : Endloop<(outs), (ins brtarget:$offset),
4493 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
4494 Defs = [PC, LC1], Uses = [SA1, LC1] in {
4495 def ENDLOOP1 : Endloop<(outs), (ins brtarget:$offset),
4500 // Pipelined loop instructions, sp[123]loop0
4501 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
4502 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
4503 opExtendable = 0, isPredicateLate = 1 in
4504 class SPLOOP_iBase<string SP, bits<2> op>
4505 : CRInst <(outs), (ins brtarget:$r7_2, u10Imm:$U10),
4506 "p3 = sp"#SP#"loop0($r7_2, #$U10)" > {
4510 let IClass = 0b0110;
4512 let Inst{22-21} = op;
4513 let Inst{27-23} = 0b10011;
4514 let Inst{20-16} = U10{9-5};
4515 let Inst{12-8} = r7_2{8-4};
4516 let Inst{7-5} = U10{4-2};
4517 let Inst{4-3} = r7_2{3-2};
4518 let Inst{1-0} = U10{1-0};
4521 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
4522 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
4523 opExtendable = 0, isPredicateLate = 1 in
4524 class SPLOOP_rBase<string SP, bits<2> op>
4525 : CRInst <(outs), (ins brtarget:$r7_2, IntRegs:$Rs),
4526 "p3 = sp"#SP#"loop0($r7_2, $Rs)" > {
4530 let IClass = 0b0110;
4532 let Inst{22-21} = op;
4533 let Inst{27-23} = 0b00001;
4534 let Inst{20-16} = Rs;
4535 let Inst{12-8} = r7_2{8-4};
4536 let Inst{4-3} = r7_2{3-2};
4539 multiclass SPLOOP_ri<string mnemonic, bits<2> op> {
4540 def i : SPLOOP_iBase<mnemonic, op>;
4541 def r : SPLOOP_rBase<mnemonic, op>;
4544 let isCodeGenOnly = 0 in {
4545 defm J2_ploop1s : SPLOOP_ri<"1", 0b01>;
4546 defm J2_ploop2s : SPLOOP_ri<"2", 0b10>;
4547 defm J2_ploop3s : SPLOOP_ri<"3", 0b11>;
4551 // if (Rs[!>=<]=#0) jump:[t/nt]
4552 let Defs = [PC], isPredicated = 1, isBranch = 1, hasSideEffects = 0,
4553 hasSideEffects = 0 in
4554 class J2_jump_0_Base<string compare, bit isTak, bits<2> op>
4555 : CRInst <(outs), (ins IntRegs:$Rs, brtarget:$r13_2),
4556 "if ($Rs"#compare#"#0) jump"#!if(isTak, ":t", ":nt")#" $r13_2" > {
4560 let IClass = 0b0110;
4562 let Inst{27-24} = 0b0001;
4563 let Inst{23-22} = op;
4564 let Inst{12} = isTak;
4565 let Inst{21} = r13_2{14};
4566 let Inst{20-16} = Rs;
4567 let Inst{11-1} = r13_2{12-2};
4568 let Inst{13} = r13_2{13};
4571 multiclass J2_jump_compare_0<string compare, bits<2> op> {
4572 def NAME : J2_jump_0_Base<compare, 0, op>;
4573 def NAME#pt : J2_jump_0_Base<compare, 1, op>;
4575 let isCodeGenOnly = 0 in {
4576 defm J2_jumprz : J2_jump_compare_0<"!=", 0b00>;
4577 defm J2_jumprgtez : J2_jump_compare_0<">=", 0b01>;
4578 defm J2_jumprnz : J2_jump_compare_0<"==", 0b10>;
4579 defm J2_jumprltez : J2_jump_compare_0<"<=", 0b11>;
4582 // Transfer to/from Control/GPR Guest/GPR
4583 let hasSideEffects = 0 in
4584 class TFR_CR_RS_base<RegisterClass CTRC, RegisterClass RC, bit isDouble>
4585 : CRInst <(outs CTRC:$dst), (ins RC:$src),
4586 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
4590 let IClass = 0b0110;
4592 let Inst{27-25} = 0b001;
4593 let Inst{24} = isDouble;
4594 let Inst{23-21} = 0b001;
4595 let Inst{20-16} = src;
4596 let Inst{4-0} = dst;
4598 let isCodeGenOnly = 0 in
4599 def A2_tfrrcr : TFR_CR_RS_base<CtrRegs, IntRegs, 0b0>;
4600 def : InstAlias<"m0 = $Rs", (A2_tfrrcr C6, IntRegs:$Rs)>;
4601 def : InstAlias<"m1 = $Rs", (A2_tfrrcr C7, IntRegs:$Rs)>;
4603 let hasSideEffects = 0 in
4604 class TFR_RD_CR_base<RegisterClass RC, RegisterClass CTRC, bit isSingle>
4605 : CRInst <(outs RC:$dst), (ins CTRC:$src),
4606 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
4610 let IClass = 0b0110;
4612 let Inst{27-26} = 0b10;
4613 let Inst{25} = isSingle;
4614 let Inst{24-21} = 0b0000;
4615 let Inst{20-16} = src;
4616 let Inst{4-0} = dst;
4619 let hasNewValue = 1, opNewValue = 0, isCodeGenOnly = 0 in
4620 def A2_tfrcrr : TFR_RD_CR_base<IntRegs, CtrRegs, 1>;
4621 def : InstAlias<"$Rd = m0", (A2_tfrcrr IntRegs:$Rd, C6)>;
4622 def : InstAlias<"$Rd = m1", (A2_tfrcrr IntRegs:$Rd, C7)>;
4624 // Y4_trace: Send value to etm trace.
4625 let isSoloAX = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
4626 def Y4_trace: CRInst <(outs), (ins IntRegs:$Rs),
4630 let IClass = 0b0110;
4631 let Inst{27-21} = 0b0010010;
4632 let Inst{20-16} = Rs;
4635 let AddedComplexity = 100, isPredicated = 1 in
4636 def TFR_condset_ri : ALU32_rr<(outs IntRegs:$dst),
4637 (ins PredRegs:$src1, IntRegs:$src2, s12Imm:$src3),
4638 "Error; should not emit",
4639 [(set (i32 IntRegs:$dst),
4640 (i32 (select (i1 PredRegs:$src1), (i32 IntRegs:$src2),
4641 s12ImmPred:$src3)))]>;
4643 let AddedComplexity = 100, isPredicated = 1 in
4644 def TFR_condset_ir : ALU32_rr<(outs IntRegs:$dst),
4645 (ins PredRegs:$src1, s12Imm:$src2, IntRegs:$src3),
4646 "Error; should not emit",
4647 [(set (i32 IntRegs:$dst),
4648 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
4649 (i32 IntRegs:$src3))))]>;
4651 let AddedComplexity = 100, isPredicated = 1 in
4652 def TFR_condset_ii : ALU32_rr<(outs IntRegs:$dst),
4653 (ins PredRegs:$src1, s12Imm:$src2, s12Imm:$src3),
4654 "Error; should not emit",
4655 [(set (i32 IntRegs:$dst),
4656 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
4657 s12ImmPred:$src3)))]>;
4659 // Generate frameindex addresses.
4660 let isReMaterializable = 1 in
4661 def TFR_FI : ALU32_ri<(outs IntRegs:$dst), (ins FrameIndex:$src1),
4662 "$dst = add($src1)",
4663 [(set (i32 IntRegs:$dst), ADDRri:$src1)]>;
4665 // Support for generating global address.
4666 // Taken from X86InstrInfo.td.
4667 def SDTHexagonCONST32 : SDTypeProfile<1, 1, [SDTCisVT<0, i32>,
4670 def HexagonCONST32 : SDNode<"HexagonISD::CONST32", SDTHexagonCONST32>;
4671 def HexagonCONST32_GP : SDNode<"HexagonISD::CONST32_GP", SDTHexagonCONST32>;
4673 // HI/LO Instructions
4674 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4675 def LO : ALU32_ri<(outs IntRegs:$dst), (ins globaladdress:$global),
4676 "$dst.l = #LO($global)",
4679 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4680 def HI : ALU32_ri<(outs IntRegs:$dst), (ins globaladdress:$global),
4681 "$dst.h = #HI($global)",
4684 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4685 def LOi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
4686 "$dst.l = #LO($imm_value)",
4690 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4691 def HIi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
4692 "$dst.h = #HI($imm_value)",
4695 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4696 def LO_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4697 "$dst.l = #LO($jt)",
4700 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4701 def HI_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4702 "$dst.h = #HI($jt)",
4706 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0 in
4707 def LO_label : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
4708 "$dst.l = #LO($label)",
4711 let isReMaterializable = 1, isMoveImm = 1 , hasSideEffects = 0 in
4712 def HI_label : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
4713 "$dst.h = #HI($label)",
4716 // This pattern is incorrect. When we add small data, we should change
4717 // this pattern to use memw(#foo).
4718 // This is for sdata.
4719 let isMoveImm = 1 in
4720 def CONST32 : LDInst<(outs IntRegs:$dst), (ins globaladdress:$global),
4721 "$dst = CONST32(#$global)",
4722 [(set (i32 IntRegs:$dst),
4723 (load (HexagonCONST32 tglobaltlsaddr:$global)))]>;
4725 // This is for non-sdata.
4726 let isReMaterializable = 1, isMoveImm = 1 in
4727 def CONST32_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
4728 "$dst = CONST32(#$global)",
4729 [(set (i32 IntRegs:$dst),
4730 (HexagonCONST32 tglobaladdr:$global))]>;
4732 let isReMaterializable = 1, isMoveImm = 1 in
4733 def CONST32_set_jt : LDInst2<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4734 "$dst = CONST32(#$jt)",
4735 [(set (i32 IntRegs:$dst),
4736 (HexagonCONST32 tjumptable:$jt))]>;
4738 let isReMaterializable = 1, isMoveImm = 1 in
4739 def CONST32GP_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
4740 "$dst = CONST32(#$global)",
4741 [(set (i32 IntRegs:$dst),
4742 (HexagonCONST32_GP tglobaladdr:$global))]>;
4744 let isReMaterializable = 1, isMoveImm = 1 in
4745 def CONST32_Int_Real : LDInst2<(outs IntRegs:$dst), (ins i32imm:$global),
4746 "$dst = CONST32(#$global)",
4747 [(set (i32 IntRegs:$dst), imm:$global) ]>;
4749 // Map BlockAddress lowering to CONST32_Int_Real
4750 def : Pat<(HexagonCONST32_GP tblockaddress:$addr),
4751 (CONST32_Int_Real tblockaddress:$addr)>;
4753 let isReMaterializable = 1, isMoveImm = 1 in
4754 def CONST32_Label : LDInst2<(outs IntRegs:$dst), (ins bblabel:$label),
4755 "$dst = CONST32($label)",
4756 [(set (i32 IntRegs:$dst), (HexagonCONST32 bbl:$label))]>;
4758 let isReMaterializable = 1, isMoveImm = 1 in
4759 def CONST64_Int_Real : LDInst2<(outs DoubleRegs:$dst), (ins i64imm:$global),
4760 "$dst = CONST64(#$global)",
4761 [(set (i64 DoubleRegs:$dst), imm:$global) ]>;
4763 def TFR_PdFalse : SInst<(outs PredRegs:$dst), (ins),
4764 "$dst = xor($dst, $dst)",
4765 [(set (i1 PredRegs:$dst), 0)]>;
4767 // Pseudo instructions.
4768 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
4769 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
4770 SDTCisVT<1, i32> ]>;
4772 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
4773 [SDNPHasChain, SDNPOutGlue]>;
4774 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
4775 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
4777 def SDT_SPCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
4779 // For tailcalls a HexagonTCRet SDNode has 3 SDNode Properties - a chain,
4780 // Optional Flag and Variable Arguments.
4781 // Its 1 Operand has pointer type.
4782 def HexagonTCRet : SDNode<"HexagonISD::TC_RETURN", SDT_SPCall,
4783 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
4785 let Defs = [R29, R30], Uses = [R31, R30, R29] in {
4786 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
4787 "Should never be emitted",
4788 [(callseq_start timm:$amt)]>;
4791 let Defs = [R29, R30, R31], Uses = [R29] in {
4792 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
4793 "Should never be emitted",
4794 [(callseq_end timm:$amt1, timm:$amt2)]>;
4797 let isCall = 1, hasSideEffects = 0,
4798 Defs = [D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10,
4799 R22, R23, R28, R31, P0, P1, P2, P3, LC0, LC1, SA0, SA1] in {
4800 def CALL : JInst<(outs), (ins calltarget:$dst),
4804 // Call subroutine indirectly.
4805 let Defs = VolatileV3.Regs, isCodeGenOnly = 0 in
4806 def J2_callr : JUMPR_MISC_CALLR<0, 1>;
4808 // Indirect tail-call.
4809 let isCodeGenOnly = 1, isCall = 1, isReturn = 1 in
4810 def TCRETURNR : T_JMPr;
4812 // Direct tail-calls.
4813 let isCall = 1, isReturn = 1, isBarrier = 1, isPredicable = 0,
4814 isTerminator = 1, isCodeGenOnly = 1 in {
4815 def TCRETURNtg : JInst<(outs), (ins calltarget:$dst), "jump $dst",
4816 [], "", J_tc_2early_SLOT23>;
4817 def TCRETURNtext : JInst<(outs), (ins calltarget:$dst), "jump $dst",
4818 [], "", J_tc_2early_SLOT23>;
4822 def : Pat<(HexagonTCRet tglobaladdr:$dst),
4823 (TCRETURNtg tglobaladdr:$dst)>;
4824 def : Pat<(HexagonTCRet texternalsym:$dst),
4825 (TCRETURNtext texternalsym:$dst)>;
4826 def : Pat<(HexagonTCRet (i32 IntRegs:$dst)),
4827 (TCRETURNR (i32 IntRegs:$dst))>;
4829 // Map from r0 = and(r1, 65535) to r0 = zxth(r1)
4830 def : Pat <(and (i32 IntRegs:$src1), 65535),
4831 (A2_zxth (i32 IntRegs:$src1))>;
4833 // Map from r0 = and(r1, 255) to r0 = zxtb(r1).
4834 def : Pat <(and (i32 IntRegs:$src1), 255),
4835 (A2_zxtb (i32 IntRegs:$src1))>;
4837 // Map Add(p1, true) to p1 = not(p1).
4838 // Add(p1, false) should never be produced,
4839 // if it does, it got to be mapped to NOOP.
4840 def : Pat <(add (i1 PredRegs:$src1), -1),
4841 (C2_not (i1 PredRegs:$src1))>;
4843 // Map from p0 = pnot(p0); r0 = mux(p0, #i, #j) => r0 = mux(p0, #j, #i).
4844 def : Pat <(select (not (i1 PredRegs:$src1)), s8ImmPred:$src2, s8ImmPred:$src3),
4845 (i32 (TFR_condset_ii (i1 PredRegs:$src1), s8ImmPred:$src3,
4848 // Map from p0 = pnot(p0); r0 = select(p0, #i, r1)
4849 // => r0 = TFR_condset_ri(p0, r1, #i)
4850 def : Pat <(select (not (i1 PredRegs:$src1)), s12ImmPred:$src2,
4851 (i32 IntRegs:$src3)),
4852 (i32 (TFR_condset_ri (i1 PredRegs:$src1), (i32 IntRegs:$src3),
4853 s12ImmPred:$src2))>;
4855 // Map from p0 = pnot(p0); r0 = mux(p0, r1, #i)
4856 // => r0 = TFR_condset_ir(p0, #i, r1)
4857 def : Pat <(select (not (i1 PredRegs:$src1)), IntRegs:$src2, s12ImmPred:$src3),
4858 (i32 (TFR_condset_ir (i1 PredRegs:$src1), s12ImmPred:$src3,
4859 (i32 IntRegs:$src2)))>;
4861 // Map from p0 = pnot(p0); if (p0) jump => if (!p0) jump.
4862 def : Pat <(brcond (not (i1 PredRegs:$src1)), bb:$offset),
4863 (J2_jumpf (i1 PredRegs:$src1), bb:$offset)>;
4865 // Map from p2 = pnot(p2); p1 = and(p0, p2) => p1 = and(p0, !p2).
4866 def : Pat <(and (i1 PredRegs:$src1), (not (i1 PredRegs:$src2))),
4867 (i1 (C2_andn (i1 PredRegs:$src1), (i1 PredRegs:$src2)))>;
4870 let AddedComplexity = 100 in
4871 def : Pat <(i64 (zextloadi1 (HexagonCONST32 tglobaladdr:$global))),
4872 (i64 (A2_combinew (A2_tfrsi 0),
4873 (L2_loadrub_io (CONST32_set tglobaladdr:$global), 0)))>,
4876 // Map from i1 loads to 32 bits. This assumes that the i1* is byte aligned.
4877 let AddedComplexity = 10 in
4878 def : Pat <(i32 (zextloadi1 ADDRriS11_0:$addr)),
4879 (i32 (A2_and (i32 (L2_loadrb_io AddrFI:$addr, 0)), (A2_tfrsi 0x1)))>;
4881 // Map from Rdd = sign_extend_inreg(Rss, i32) -> Rdd = A2_sxtw(Rss.lo).
4882 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i32)),
4883 (i64 (A2_sxtw (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg))))>;
4885 // Map from Rdd = sign_extend_inreg(Rss, i16) -> Rdd = A2_sxtw(SXTH(Rss.lo)).
4886 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i16)),
4887 (i64 (A2_sxtw (i32 (A2_sxth (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
4888 subreg_loreg))))))>;
4890 // Map from Rdd = sign_extend_inreg(Rss, i8) -> Rdd = A2_sxtw(SXTB(Rss.lo)).
4891 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i8)),
4892 (i64 (A2_sxtw (i32 (A2_sxtb (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
4893 subreg_loreg))))))>;
4895 // We want to prevent emitting pnot's as much as possible.
4896 // Map brcond with an unsupported setcc to a J2_jumpf.
4897 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4899 (J2_jumpf (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
4902 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), s10ImmPred:$src2)),
4904 (J2_jumpf (C2_cmpeqi (i32 IntRegs:$src1), s10ImmPred:$src2), bb:$offset)>;
4906 def : Pat <(brcond (i1 (setne (i1 PredRegs:$src1), (i1 -1))), bb:$offset),
4907 (J2_jumpf (i1 PredRegs:$src1), bb:$offset)>;
4909 def : Pat <(brcond (i1 (setne (i1 PredRegs:$src1), (i1 0))), bb:$offset),
4910 (J2_jumpt (i1 PredRegs:$src1), bb:$offset)>;
4912 // cmp.lt(Rs, Imm) -> !cmp.ge(Rs, Imm) -> !cmp.gt(Rs, Imm-1)
4913 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), s8ImmPred:$src2)),
4915 (J2_jumpf (C2_cmpgti (i32 IntRegs:$src1),
4916 (DEC_CONST_SIGNED s8ImmPred:$src2)), bb:$offset)>;
4918 // cmp.lt(r0, r1) -> cmp.gt(r1, r0)
4919 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4921 (J2_jumpt (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)), bb:$offset)>;
4923 def : Pat <(brcond (i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4925 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)),
4928 def : Pat <(brcond (i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4930 (J2_jumpf (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
4933 def : Pat <(brcond (i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4935 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
4938 // Map from a 64-bit select to an emulated 64-bit mux.
4939 // Hexagon does not support 64-bit MUXes; so emulate with combines.
4940 def : Pat <(select (i1 PredRegs:$src1), (i64 DoubleRegs:$src2),
4941 (i64 DoubleRegs:$src3)),
4942 (i64 (A2_combinew (i32 (C2_mux (i1 PredRegs:$src1),
4943 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
4945 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src3),
4947 (i32 (C2_mux (i1 PredRegs:$src1),
4948 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
4950 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src3),
4951 subreg_loreg))))))>;
4953 // Map from a 1-bit select to logical ops.
4954 // From LegalizeDAG.cpp: (B1 ? B2 : B3) <=> (B1 & B2)|(!B1&B3).
4955 def : Pat <(select (i1 PredRegs:$src1), (i1 PredRegs:$src2),
4956 (i1 PredRegs:$src3)),
4957 (C2_or (C2_and (i1 PredRegs:$src1), (i1 PredRegs:$src2)),
4958 (C2_and (C2_not (i1 PredRegs:$src1)), (i1 PredRegs:$src3)))>;
4960 // Map Pd = load(addr) -> Rs = load(addr); Pd = Rs.
4961 def : Pat<(i1 (load ADDRriS11_2:$addr)),
4962 (i1 (C2_tfrrp (i32 (L2_loadrb_io AddrFI:$addr, 0))))>;
4964 // Map for truncating from 64 immediates to 32 bit immediates.
4965 def : Pat<(i32 (trunc (i64 DoubleRegs:$src))),
4966 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src), subreg_loreg))>;
4968 // Map for truncating from i64 immediates to i1 bit immediates.
4969 def : Pat<(i1 (trunc (i64 DoubleRegs:$src))),
4970 (i1 (C2_tfrrp (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4973 // Map memb(Rs) = Rdd -> memb(Rs) = Rt.
4974 def : Pat<(truncstorei8 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4975 (S2_storerb_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4978 // Map memh(Rs) = Rdd -> memh(Rs) = Rt.
4979 def : Pat<(truncstorei16 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4980 (S2_storerh_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4982 // Map memw(Rs) = Rdd -> memw(Rs) = Rt
4983 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4984 (S2_storeri_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4987 // Map memw(Rs) = Rdd -> memw(Rs) = Rt.
4988 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4989 (S2_storeri_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4992 // Map from i1 = constant<-1>; memw(addr) = i1 -> r0 = 1; memw(addr) = r0.
4993 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
4994 (S2_storerb_io AddrFI:$addr, 0, (A2_tfrsi 1))>;
4997 // Map from i1 = constant<-1>; store i1 -> r0 = 1; store r0.
4998 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
4999 (S2_storerb_io AddrFI:$addr, 0, (A2_tfrsi 1))>;
5001 // Map from memb(Rs) = Pd -> Rt = mux(Pd, #0, #1); store Rt.
5002 def : Pat<(store (i1 PredRegs:$src1), ADDRriS11_2:$addr),
5003 (S2_storerb_io AddrFI:$addr, 0, (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0)) )>;
5005 // Map Rdd = anyext(Rs) -> Rdd = A2_sxtw(Rs).
5006 // Hexagon_TODO: We can probably use combine but that will cost 2 instructions.
5007 // Better way to do this?
5008 def : Pat<(i64 (anyext (i32 IntRegs:$src1))),
5009 (i64 (A2_sxtw (i32 IntRegs:$src1)))>;
5011 // Map cmple -> cmpgt.
5012 // rs <= rt -> !(rs > rt).
5013 def : Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
5014 (i1 (C2_not (C2_cmpgti (i32 IntRegs:$src1), s10ExtPred:$src2)))>;
5016 // rs <= rt -> !(rs > rt).
5017 def : Pat<(i1 (setle (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5018 (i1 (C2_not (C2_cmpgt (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
5020 // Rss <= Rtt -> !(Rss > Rtt).
5021 def : Pat<(i1 (setle (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5022 (i1 (C2_not (C2_cmpgtp (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))))>;
5024 // Map cmpne -> cmpeq.
5025 // Hexagon_TODO: We should improve on this.
5026 // rs != rt -> !(rs == rt).
5027 def : Pat <(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
5028 (i1 (C2_not(i1 (C2_cmpeqi (i32 IntRegs:$src1), s10ExtPred:$src2))))>;
5030 // Map cmpne(Rs) -> !cmpeqe(Rs).
5031 // rs != rt -> !(rs == rt).
5032 def : Pat <(i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5033 (i1 (C2_not (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)))))>;
5035 // Convert setne back to xor for hexagon since we compute w/ pred registers.
5036 def : Pat <(i1 (setne (i1 PredRegs:$src1), (i1 PredRegs:$src2))),
5037 (i1 (C2_xor (i1 PredRegs:$src1), (i1 PredRegs:$src2)))>;
5039 // Map cmpne(Rss) -> !cmpew(Rss).
5040 // rs != rt -> !(rs == rt).
5041 def : Pat <(i1 (setne (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5042 (i1 (C2_not (i1 (C2_cmpeqp (i64 DoubleRegs:$src1),
5043 (i64 DoubleRegs:$src2)))))>;
5045 // Map cmpge(Rs, Rt) -> !(cmpgt(Rs, Rt).
5046 // rs >= rt -> !(rt > rs).
5047 def : Pat <(i1 (setge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5048 (i1 (C2_not (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))))>;
5050 // cmpge(Rs, Imm) -> cmpgt(Rs, Imm-1)
5051 def : Pat <(i1 (setge (i32 IntRegs:$src1), s8ExtPred:$src2)),
5052 (i1 (C2_cmpgti (i32 IntRegs:$src1), (DEC_CONST_SIGNED s8ExtPred:$src2)))>;
5054 // Map cmpge(Rss, Rtt) -> !cmpgt(Rtt, Rss).
5055 // rss >= rtt -> !(rtt > rss).
5056 def : Pat <(i1 (setge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5057 (i1 (C2_not (i1 (C2_cmpgtp (i64 DoubleRegs:$src2),
5058 (i64 DoubleRegs:$src1)))))>;
5060 // Map cmplt(Rs, Imm) -> !cmpge(Rs, Imm).
5061 // !cmpge(Rs, Imm) -> !cmpgt(Rs, Imm-1).
5062 // rs < rt -> !(rs >= rt).
5063 def : Pat <(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
5064 (i1 (C2_not (C2_cmpgti (i32 IntRegs:$src1), (DEC_CONST_SIGNED s8ExtPred:$src2))))>;
5066 // Map cmplt(Rs, Rt) -> cmpgt(Rt, Rs).
5067 // rs < rt -> rt > rs.
5068 // We can let assembler map it, or we can do in the compiler itself.
5069 def : Pat <(i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5070 (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))>;
5072 // Map cmplt(Rss, Rtt) -> cmpgt(Rtt, Rss).
5073 // rss < rtt -> (rtt > rss).
5074 def : Pat <(i1 (setlt (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5075 (i1 (C2_cmpgtp (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)))>;
5077 // Map from cmpltu(Rs, Rd) -> cmpgtu(Rd, Rs)
5078 // rs < rt -> rt > rs.
5079 // We can let assembler map it, or we can do in the compiler itself.
5080 def : Pat <(i1 (setult (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5081 (i1 (C2_cmpgtu (i32 IntRegs:$src2), (i32 IntRegs:$src1)))>;
5083 // Map from cmpltu(Rss, Rdd) -> cmpgtu(Rdd, Rss).
5084 // rs < rt -> rt > rs.
5085 def : Pat <(i1 (setult (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5086 (i1 (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)))>;
5088 // Generate cmpgeu(Rs, #0) -> cmpeq(Rs, Rs)
5089 def : Pat <(i1 (setuge (i32 IntRegs:$src1), 0)),
5090 (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src1)))>;
5092 // Generate cmpgeu(Rs, #u8) -> cmpgtu(Rs, #u8 -1)
5093 def : Pat <(i1 (setuge (i32 IntRegs:$src1), u8ExtPred:$src2)),
5094 (i1 (C2_cmpgtui (i32 IntRegs:$src1), (DEC_CONST_UNSIGNED u8ExtPred:$src2)))>;
5096 // Generate cmpgtu(Rs, #u9)
5097 def : Pat <(i1 (setugt (i32 IntRegs:$src1), u9ExtPred:$src2)),
5098 (i1 (C2_cmpgtui (i32 IntRegs:$src1), u9ExtPred:$src2))>;
5100 // Map from Rs >= Rt -> !(Rt > Rs).
5101 // rs >= rt -> !(rt > rs).
5102 def : Pat <(i1 (setuge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5103 (i1 (C2_not (C2_cmpgtu (i32 IntRegs:$src2), (i32 IntRegs:$src1))))>;
5105 // Map from Rs >= Rt -> !(Rt > Rs).
5106 // rs >= rt -> !(rt > rs).
5107 def : Pat <(i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5108 (i1 (C2_not (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1))))>;
5110 // Map from cmpleu(Rs, Rt) -> !cmpgtu(Rs, Rt).
5111 // Map from (Rs <= Rt) -> !(Rs > Rt).
5112 def : Pat <(i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5113 (i1 (C2_not (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
5115 // Map from cmpleu(Rss, Rtt) -> !cmpgtu(Rss, Rtt-1).
5116 // Map from (Rs <= Rt) -> !(Rs > Rt).
5117 def : Pat <(i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5118 (i1 (C2_not (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))))>;
5122 def : Pat <(i32 (sext (i1 PredRegs:$src1))),
5123 (i32 (C2_muxii (i1 PredRegs:$src1), -1, 0))>;
5126 def : Pat <(i64 (sext (i1 PredRegs:$src1))),
5127 (i64 (A2_combinew (A2_tfrsi -1), (C2_muxii (i1 PredRegs:$src1), -1, 0)))>;
5129 // Convert sign-extended load back to load and sign extend.
5131 def: Pat <(i64 (sextloadi8 ADDRriS11_0:$src1)),
5132 (i64 (A2_sxtw (L2_loadrb_io AddrFI:$src1, 0)))>;
5134 // Convert any-extended load back to load and sign extend.
5136 def: Pat <(i64 (extloadi8 ADDRriS11_0:$src1)),
5137 (i64 (A2_sxtw (L2_loadrb_io AddrFI:$src1, 0)))>;
5139 // Convert sign-extended load back to load and sign extend.
5141 def: Pat <(i64 (sextloadi16 ADDRriS11_1:$src1)),
5142 (i64 (A2_sxtw (L2_loadrh_io AddrFI:$src1, 0)))>;
5144 // Convert sign-extended load back to load and sign extend.
5146 def: Pat <(i64 (sextloadi32 ADDRriS11_2:$src1)),
5147 (i64 (A2_sxtw (L2_loadri_io AddrFI:$src1, 0)))>;
5152 def : Pat <(i32 (zext (i1 PredRegs:$src1))),
5153 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
5156 def : Pat <(i64 (zext (i1 PredRegs:$src1))),
5157 (i64 (A2_combinew (A2_tfrsi 0), (C2_muxii (i1 PredRegs:$src1), 1, 0)))>,
5161 def : Pat <(i64 (zext (i32 IntRegs:$src1))),
5162 (i64 (A2_combinew (A2_tfrsi 0), (i32 IntRegs:$src1)))>,
5166 def: Pat <(i64 (zextloadi8 ADDRriS11_0:$src1)),
5167 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io AddrFI:$src1, 0)))>,
5170 let AddedComplexity = 20 in
5171 def: Pat <(i64 (zextloadi8 (add (i32 IntRegs:$src1),
5172 s11_0ExtPred:$offset))),
5173 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io IntRegs:$src1,
5174 s11_0ExtPred:$offset)))>,
5178 def: Pat <(i64 (zextloadi1 ADDRriS11_0:$src1)),
5179 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io AddrFI:$src1, 0)))>,
5182 let AddedComplexity = 20 in
5183 def: Pat <(i64 (zextloadi1 (add (i32 IntRegs:$src1),
5184 s11_0ExtPred:$offset))),
5185 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io IntRegs:$src1,
5186 s11_0ExtPred:$offset)))>,
5190 def: Pat <(i64 (zextloadi16 ADDRriS11_1:$src1)),
5191 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadruh_io AddrFI:$src1, 0)))>,
5194 let AddedComplexity = 20 in
5195 def: Pat <(i64 (zextloadi16 (add (i32 IntRegs:$src1),
5196 s11_1ExtPred:$offset))),
5197 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadruh_io IntRegs:$src1,
5198 s11_1ExtPred:$offset)))>,
5202 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)),
5203 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io AddrFI:$src1, 0)))>,
5206 let AddedComplexity = 100 in
5207 def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
5208 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io IntRegs:$src1,
5209 s11_2ExtPred:$offset)))>,
5212 let AddedComplexity = 10 in
5213 def: Pat <(i32 (zextloadi1 ADDRriS11_0:$src1)),
5214 (i32 (L2_loadri_io AddrFI:$src1, 0))>;
5216 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
5217 def : Pat <(i32 (zext (i1 PredRegs:$src1))),
5218 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
5220 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
5221 def : Pat <(i32 (anyext (i1 PredRegs:$src1))),
5222 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
5224 // Map from Rss = Pd to Rdd = A2_sxtw (mux(Pd, #1, #0))
5225 def : Pat <(i64 (anyext (i1 PredRegs:$src1))),
5226 (i64 (A2_sxtw (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))))>;
5229 let AddedComplexity = 100 in
5230 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5232 (i64 (zextloadi32 (i32 (add IntRegs:$src2,
5233 s11_2ExtPred:$offset2)))))),
5234 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5235 (L2_loadri_io IntRegs:$src2,
5236 s11_2ExtPred:$offset2)))>;
5238 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5240 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
5241 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5242 (L2_loadri_io AddrFI:$srcLow, 0)))>;
5244 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5246 (i64 (zext (i32 IntRegs:$srcLow))))),
5247 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5250 let AddedComplexity = 100 in
5251 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5253 (i64 (zextloadi32 (i32 (add IntRegs:$src2,
5254 s11_2ExtPred:$offset2)))))),
5255 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5256 (L2_loadri_io IntRegs:$src2,
5257 s11_2ExtPred:$offset2)))>;
5259 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5261 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
5262 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5263 (L2_loadri_io AddrFI:$srcLow, 0)))>;
5265 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5267 (i64 (zext (i32 IntRegs:$srcLow))))),
5268 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5271 // Any extended 64-bit load.
5272 // anyext i32 -> i64
5273 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)),
5274 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io AddrFI:$src1, 0)))>,
5277 // When there is an offset we should prefer the pattern below over the pattern above.
5278 // The complexity of the above is 13 (gleaned from HexagonGenDAGIsel.inc)
5279 // So this complexity below is comfortably higher to allow for choosing the below.
5280 // If this is not done then we generate addresses such as
5281 // ********************************************
5282 // r1 = add (r0, #4)
5283 // r1 = memw(r1 + #0)
5285 // r1 = memw(r0 + #4)
5286 // ********************************************
5287 let AddedComplexity = 100 in
5288 def: Pat <(i64 (extloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
5289 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io IntRegs:$src1,
5290 s11_2ExtPred:$offset)))>,
5293 // anyext i16 -> i64.
5294 def: Pat <(i64 (extloadi16 ADDRriS11_2:$src1)),
5295 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrh_io AddrFI:$src1, 0)))>,
5298 let AddedComplexity = 20 in
5299 def: Pat <(i64 (extloadi16 (add (i32 IntRegs:$src1),
5300 s11_1ExtPred:$offset))),
5301 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrh_io IntRegs:$src1,
5302 s11_1ExtPred:$offset)))>,
5305 // Map from Rdd = zxtw(Rs) -> Rdd = combine(0, Rs).
5306 def : Pat<(i64 (zext (i32 IntRegs:$src1))),
5307 (i64 (A2_combinew (A2_tfrsi 0), (i32 IntRegs:$src1)))>,
5310 // Multiply 64-bit unsigned and use upper result.
5311 def : Pat <(mulhu (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
5326 (A2_combinew (A2_tfrsi 0),
5333 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
5335 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
5336 subreg_loreg)))), 32)),
5338 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5339 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_loreg)))),
5340 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg)),
5341 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg)))),
5342 32)), subreg_loreg)))),
5343 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5344 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg))))>;
5346 // Multiply 64-bit signed and use upper result.
5347 def : Pat <(mulhs (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
5351 (A2_combinew (A2_tfrsi 0),
5361 (A2_combinew (A2_tfrsi 0),
5368 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
5370 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
5371 subreg_loreg)))), 32)),
5373 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5374 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_loreg)))),
5375 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg)),
5376 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg)))),
5377 32)), subreg_loreg)))),
5378 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5379 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg))))>;
5381 // Hexagon specific ISD nodes.
5382 //def SDTHexagonADJDYNALLOC : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>]>;
5383 def SDTHexagonADJDYNALLOC : SDTypeProfile<1, 2,
5384 [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
5385 def Hexagon_ADJDYNALLOC : SDNode<"HexagonISD::ADJDYNALLOC",
5386 SDTHexagonADJDYNALLOC>;
5387 // Needed to tag these instructions for stack layout.
5388 let usesCustomInserter = 1 in
5389 def ADJDYNALLOC : ALU32_ri<(outs IntRegs:$dst), (ins IntRegs:$src1,
5391 "$dst = add($src1, #$src2)",
5392 [(set (i32 IntRegs:$dst),
5393 (Hexagon_ADJDYNALLOC (i32 IntRegs:$src1),
5394 s16ImmPred:$src2))]>;
5396 def SDTHexagonARGEXTEND : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
5397 def Hexagon_ARGEXTEND : SDNode<"HexagonISD::ARGEXTEND", SDTHexagonARGEXTEND>;
5398 def ARGEXTEND : ALU32_rr <(outs IntRegs:$dst), (ins IntRegs:$src1),
5400 [(set (i32 IntRegs:$dst),
5401 (Hexagon_ARGEXTEND (i32 IntRegs:$src1)))]>;
5403 let AddedComplexity = 100 in
5404 def : Pat<(i32 (sext_inreg (Hexagon_ARGEXTEND (i32 IntRegs:$src1)), i16)),
5405 (COPY (i32 IntRegs:$src1))>;
5407 def HexagonWrapperJT: SDNode<"HexagonISD::WrapperJT", SDTIntUnaryOp>;
5409 def : Pat<(HexagonWrapperJT tjumptable:$dst),
5410 (i32 (CONST32_set_jt tjumptable:$dst))>;
5414 //===----------------------------------------------------------------------===//
5416 // Shift by immediate/register and accumulate/logical
5417 //===----------------------------------------------------------------------===//
5419 // Rx[+-&|]=asr(Rs,#u5)
5420 // Rx[+-&|^]=lsr(Rs,#u5)
5421 // Rx[+-&|^]=asl(Rs,#u5)
5423 let hasNewValue = 1, opNewValue = 0 in
5424 class T_shift_imm_acc_r <string opc1, string opc2, SDNode OpNode1,
5425 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5426 : SInst_acc<(outs IntRegs:$Rx),
5427 (ins IntRegs:$src1, IntRegs:$Rs, u5Imm:$u5),
5428 "$Rx "#opc2#opc1#"($Rs, #$u5)",
5429 [(set (i32 IntRegs:$Rx),
5430 (OpNode2 (i32 IntRegs:$src1),
5431 (OpNode1 (i32 IntRegs:$Rs), u5ImmPred:$u5)))],
5432 "$src1 = $Rx", S_2op_tc_2_SLOT23> {
5437 let IClass = 0b1000;
5439 let Inst{27-24} = 0b1110;
5440 let Inst{23-22} = majOp{2-1};
5442 let Inst{7} = majOp{0};
5443 let Inst{6-5} = minOp;
5445 let Inst{20-16} = Rs;
5446 let Inst{12-8} = u5;
5449 // Rx[+-&|]=asr(Rs,Rt)
5450 // Rx[+-&|^]=lsr(Rs,Rt)
5451 // Rx[+-&|^]=asl(Rs,Rt)
5453 let hasNewValue = 1, opNewValue = 0 in
5454 class T_shift_reg_acc_r <string opc1, string opc2, SDNode OpNode1,
5455 SDNode OpNode2, bits<2> majOp, bits<2> minOp>
5456 : SInst_acc<(outs IntRegs:$Rx),
5457 (ins IntRegs:$src1, IntRegs:$Rs, IntRegs:$Rt),
5458 "$Rx "#opc2#opc1#"($Rs, $Rt)",
5459 [(set (i32 IntRegs:$Rx),
5460 (OpNode2 (i32 IntRegs:$src1),
5461 (OpNode1 (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))],
5462 "$src1 = $Rx", S_3op_tc_2_SLOT23 > {
5467 let IClass = 0b1100;
5469 let Inst{27-24} = 0b1100;
5470 let Inst{23-22} = majOp;
5471 let Inst{7-6} = minOp;
5473 let Inst{20-16} = Rs;
5474 let Inst{12-8} = Rt;
5477 // Rxx[+-&|]=asr(Rss,#u6)
5478 // Rxx[+-&|^]=lsr(Rss,#u6)
5479 // Rxx[+-&|^]=asl(Rss,#u6)
5481 class T_shift_imm_acc_p <string opc1, string opc2, SDNode OpNode1,
5482 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5483 : SInst_acc<(outs DoubleRegs:$Rxx),
5484 (ins DoubleRegs:$src1, DoubleRegs:$Rss, u6Imm:$u6),
5485 "$Rxx "#opc2#opc1#"($Rss, #$u6)",
5486 [(set (i64 DoubleRegs:$Rxx),
5487 (OpNode2 (i64 DoubleRegs:$src1),
5488 (OpNode1 (i64 DoubleRegs:$Rss), u6ImmPred:$u6)))],
5489 "$src1 = $Rxx", S_2op_tc_2_SLOT23> {
5494 let IClass = 0b1000;
5496 let Inst{27-24} = 0b0010;
5497 let Inst{23-22} = majOp{2-1};
5498 let Inst{7} = majOp{0};
5499 let Inst{6-5} = minOp;
5500 let Inst{4-0} = Rxx;
5501 let Inst{20-16} = Rss;
5502 let Inst{13-8} = u6;
5506 // Rxx[+-&|]=asr(Rss,Rt)
5507 // Rxx[+-&|^]=lsr(Rss,Rt)
5508 // Rxx[+-&|^]=asl(Rss,Rt)
5509 // Rxx[+-&|^]=lsl(Rss,Rt)
5511 class T_shift_reg_acc_p <string opc1, string opc2, SDNode OpNode1,
5512 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5513 : SInst_acc<(outs DoubleRegs:$Rxx),
5514 (ins DoubleRegs:$src1, DoubleRegs:$Rss, IntRegs:$Rt),
5515 "$Rxx "#opc2#opc1#"($Rss, $Rt)",
5516 [(set (i64 DoubleRegs:$Rxx),
5517 (OpNode2 (i64 DoubleRegs:$src1),
5518 (OpNode1 (i64 DoubleRegs:$Rss), (i32 IntRegs:$Rt))))],
5519 "$src1 = $Rxx", S_3op_tc_2_SLOT23> {
5524 let IClass = 0b1100;
5526 let Inst{27-24} = 0b1011;
5527 let Inst{23-21} = majOp;
5528 let Inst{20-16} = Rss;
5529 let Inst{12-8} = Rt;
5530 let Inst{7-6} = minOp;
5531 let Inst{4-0} = Rxx;
5534 //===----------------------------------------------------------------------===//
5535 // Multi-class for the shift instructions with logical/arithmetic operators.
5536 //===----------------------------------------------------------------------===//
5538 multiclass xtype_imm_base<string OpcStr1, string OpcStr2, SDNode OpNode1,
5539 SDNode OpNode2, bits<3> majOp, bits<2> minOp > {
5540 def _i_r#NAME : T_shift_imm_acc_r< OpcStr1, OpcStr2, OpNode1,
5541 OpNode2, majOp, minOp >;
5542 def _i_p#NAME : T_shift_imm_acc_p< OpcStr1, OpcStr2, OpNode1,
5543 OpNode2, majOp, minOp >;
5546 multiclass xtype_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
5547 let AddedComplexity = 100 in
5548 defm _acc : xtype_imm_base< opc1, "+= ", OpNode, add, 0b001, minOp>;
5550 defm _nac : xtype_imm_base< opc1, "-= ", OpNode, sub, 0b000, minOp>;
5551 defm _and : xtype_imm_base< opc1, "&= ", OpNode, and, 0b010, minOp>;
5552 defm _or : xtype_imm_base< opc1, "|= ", OpNode, or, 0b011, minOp>;
5555 multiclass xtype_xor_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
5556 let AddedComplexity = 100 in
5557 defm _xacc : xtype_imm_base< opc1, "^= ", OpNode, xor, 0b100, minOp>;
5560 let isCodeGenOnly = 0 in {
5561 defm S2_asr : xtype_imm_acc<"asr", sra, 0b00>;
5563 defm S2_lsr : xtype_imm_acc<"lsr", srl, 0b01>,
5564 xtype_xor_imm_acc<"lsr", srl, 0b01>;
5566 defm S2_asl : xtype_imm_acc<"asl", shl, 0b10>,
5567 xtype_xor_imm_acc<"asl", shl, 0b10>;
5570 multiclass xtype_reg_acc_r<string opc1, SDNode OpNode, bits<2>minOp> {
5571 let AddedComplexity = 100 in
5572 def _acc : T_shift_reg_acc_r <opc1, "+= ", OpNode, add, 0b11, minOp>;
5574 def _nac : T_shift_reg_acc_r <opc1, "-= ", OpNode, sub, 0b10, minOp>;
5575 def _and : T_shift_reg_acc_r <opc1, "&= ", OpNode, and, 0b01, minOp>;
5576 def _or : T_shift_reg_acc_r <opc1, "|= ", OpNode, or, 0b00, minOp>;
5579 multiclass xtype_reg_acc_p<string opc1, SDNode OpNode, bits<2>minOp> {
5580 let AddedComplexity = 100 in
5581 def _acc : T_shift_reg_acc_p <opc1, "+= ", OpNode, add, 0b110, minOp>;
5583 def _nac : T_shift_reg_acc_p <opc1, "-= ", OpNode, sub, 0b100, minOp>;
5584 def _and : T_shift_reg_acc_p <opc1, "&= ", OpNode, and, 0b010, minOp>;
5585 def _or : T_shift_reg_acc_p <opc1, "|= ", OpNode, or, 0b000, minOp>;
5586 def _xor : T_shift_reg_acc_p <opc1, "^= ", OpNode, xor, 0b011, minOp>;
5589 multiclass xtype_reg_acc<string OpcStr, SDNode OpNode, bits<2> minOp > {
5590 defm _r_r : xtype_reg_acc_r <OpcStr, OpNode, minOp>;
5591 defm _r_p : xtype_reg_acc_p <OpcStr, OpNode, minOp>;
5594 let isCodeGenOnly = 0 in {
5595 defm S2_asl : xtype_reg_acc<"asl", shl, 0b10>;
5596 defm S2_asr : xtype_reg_acc<"asr", sra, 0b00>;
5597 defm S2_lsr : xtype_reg_acc<"lsr", srl, 0b01>;
5598 defm S2_lsl : xtype_reg_acc<"lsl", shl, 0b11>;
5601 //===----------------------------------------------------------------------===//
5602 let hasSideEffects = 0 in
5603 class T_S3op_1 <string mnemonic, RegisterClass RC, bits<2> MajOp, bits<3> MinOp,
5604 bit SwapOps, bit isSat = 0, bit isRnd = 0, bit hasShift = 0>
5605 : SInst <(outs RC:$dst),
5606 (ins DoubleRegs:$src1, DoubleRegs:$src2),
5607 "$dst = "#mnemonic#"($src1, $src2)"#!if(isRnd, ":rnd", "")
5608 #!if(hasShift,":>>1","")
5609 #!if(isSat, ":sat", ""),
5610 [], "", S_3op_tc_2_SLOT23 > {
5615 let IClass = 0b1100;
5617 let Inst{27-24} = 0b0001;
5618 let Inst{23-22} = MajOp;
5619 let Inst{20-16} = !if (SwapOps, src2, src1);
5620 let Inst{12-8} = !if (SwapOps, src1, src2);
5621 let Inst{7-5} = MinOp;
5622 let Inst{4-0} = dst;
5625 class T_S3op_64 <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit SwapOps,
5626 bit isSat = 0, bit isRnd = 0, bit hasShift = 0 >
5627 : T_S3op_1 <mnemonic, DoubleRegs, MajOp, MinOp, SwapOps,
5628 isSat, isRnd, hasShift>;
5630 let Itinerary = S_3op_tc_1_SLOT23, isCodeGenOnly = 0 in {
5631 def S2_shuffeb : T_S3op_64 < "shuffeb", 0b00, 0b010, 0>;
5632 def S2_shuffeh : T_S3op_64 < "shuffeh", 0b00, 0b110, 0>;
5633 def S2_shuffob : T_S3op_64 < "shuffob", 0b00, 0b100, 1>;
5634 def S2_shuffoh : T_S3op_64 < "shuffoh", 0b10, 0b000, 1>;
5636 def S2_vtrunewh : T_S3op_64 < "vtrunewh", 0b10, 0b010, 0>;
5637 def S2_vtrunowh : T_S3op_64 < "vtrunowh", 0b10, 0b100, 0>;
5640 let isCodeGenOnly = 0 in
5641 def S2_lfsp : T_S3op_64 < "lfs", 0b10, 0b110, 0>;
5643 let hasSideEffects = 0 in
5644 class T_S3op_2 <string mnemonic, bits<3> MajOp, bit SwapOps>
5645 : SInst < (outs DoubleRegs:$Rdd),
5646 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
5647 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu)",
5648 [], "", S_3op_tc_1_SLOT23 > {
5654 let IClass = 0b1100;
5656 let Inst{27-24} = 0b0010;
5657 let Inst{23-21} = MajOp;
5658 let Inst{20-16} = !if (SwapOps, Rtt, Rss);
5659 let Inst{12-8} = !if (SwapOps, Rss, Rtt);
5661 let Inst{4-0} = Rdd;
5664 let isCodeGenOnly = 0 in {
5665 def S2_valignrb : T_S3op_2 < "valignb", 0b000, 1>;
5666 def S2_vsplicerb : T_S3op_2 < "vspliceb", 0b100, 0>;
5669 //===----------------------------------------------------------------------===//
5670 // Template class used by vector shift, vector rotate, vector neg,
5671 // 32-bit shift, 64-bit shifts, etc.
5672 //===----------------------------------------------------------------------===//
5674 let hasSideEffects = 0 in
5675 class T_S3op_3 <string mnemonic, RegisterClass RC, bits<2> MajOp,
5676 bits<2> MinOp, bit isSat = 0, list<dag> pattern = [] >
5677 : SInst <(outs RC:$dst),
5678 (ins RC:$src1, IntRegs:$src2),
5679 "$dst = "#mnemonic#"($src1, $src2)"#!if(isSat, ":sat", ""),
5680 pattern, "", S_3op_tc_1_SLOT23> {
5685 let IClass = 0b1100;
5687 let Inst{27-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b0110, 0b0011);
5688 let Inst{23-22} = MajOp;
5689 let Inst{20-16} = src1;
5690 let Inst{12-8} = src2;
5691 let Inst{7-6} = MinOp;
5692 let Inst{4-0} = dst;
5695 let hasNewValue = 1 in
5696 class T_S3op_shift32 <string mnemonic, SDNode OpNode, bits<2> MinOp>
5697 : T_S3op_3 <mnemonic, IntRegs, 0b01, MinOp, 0,
5698 [(set (i32 IntRegs:$dst), (OpNode (i32 IntRegs:$src1),
5699 (i32 IntRegs:$src2)))]>;
5701 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in
5702 class T_S3op_shift32_Sat <string mnemonic, bits<2> MinOp>
5703 : T_S3op_3 <mnemonic, IntRegs, 0b00, MinOp, 1, []>;
5706 class T_S3op_shift64 <string mnemonic, SDNode OpNode, bits<2> MinOp>
5707 : T_S3op_3 <mnemonic, DoubleRegs, 0b10, MinOp, 0,
5708 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
5709 (i32 IntRegs:$src2)))]>;
5712 class T_S3op_shiftVect <string mnemonic, bits<2> MajOp, bits<2> MinOp>
5713 : T_S3op_3 <mnemonic, DoubleRegs, MajOp, MinOp, 0, []>;
5716 // Shift by register
5717 // Rdd=[asr|lsr|asl|lsl](Rss,Rt)
5719 let isCodeGenOnly = 0 in {
5720 def S2_asr_r_p : T_S3op_shift64 < "asr", sra, 0b00>;
5721 def S2_lsr_r_p : T_S3op_shift64 < "lsr", srl, 0b01>;
5722 def S2_asl_r_p : T_S3op_shift64 < "asl", shl, 0b10>;
5723 def S2_lsl_r_p : T_S3op_shift64 < "lsl", shl, 0b11>;
5726 // Rd=[asr|lsr|asl|lsl](Rs,Rt)
5728 let isCodeGenOnly = 0 in {
5729 def S2_asr_r_r : T_S3op_shift32<"asr", sra, 0b00>;
5730 def S2_lsr_r_r : T_S3op_shift32<"lsr", srl, 0b01>;
5731 def S2_asl_r_r : T_S3op_shift32<"asl", shl, 0b10>;
5732 def S2_lsl_r_r : T_S3op_shift32<"lsl", shl, 0b11>;
5735 // Shift by register with saturation
5736 // Rd=asr(Rs,Rt):sat
5737 // Rd=asl(Rs,Rt):sat
5739 let Defs = [USR_OVF], isCodeGenOnly = 0 in {
5740 def S2_asr_r_r_sat : T_S3op_shift32_Sat<"asr", 0b00>;
5741 def S2_asl_r_r_sat : T_S3op_shift32_Sat<"asl", 0b10>;
5744 let hasNewValue = 1, hasSideEffects = 0 in
5745 class T_S3op_8 <string opc, bits<3> MinOp, bit isSat, bit isRnd, bit hasShift, bit hasSplat = 0>
5746 : SInst < (outs IntRegs:$Rd),
5747 (ins DoubleRegs:$Rss, IntRegs:$Rt),
5748 "$Rd = "#opc#"($Rss, $Rt"#!if(hasSplat, "*", "")#")"
5749 #!if(hasShift, ":<<1", "")
5750 #!if(isRnd, ":rnd", "")
5751 #!if(isSat, ":sat", ""),
5752 [], "", S_3op_tc_1_SLOT23 > {
5757 let IClass = 0b1100;
5759 let Inst{27-24} = 0b0101;
5760 let Inst{20-16} = Rss;
5761 let Inst{12-8} = Rt;
5762 let Inst{7-5} = MinOp;
5766 let isCodeGenOnly = 0 in
5767 def S2_asr_r_svw_trun : T_S3op_8<"vasrw", 0b010, 0, 0, 0>;
5769 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23, isCodeGenOnly = 0 in
5770 def S2_vcrotate : T_S3op_shiftVect < "vcrotate", 0b11, 0b00>;
5772 let hasSideEffects = 0 in
5773 class T_S3op_7 <string mnemonic, bit MajOp >
5774 : SInst <(outs DoubleRegs:$Rdd),
5775 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, u3Imm:$u3),
5776 "$Rdd = "#mnemonic#"($Rss, $Rtt, #$u3)" ,
5777 [], "", S_3op_tc_1_SLOT23 > {
5783 let IClass = 0b1100;
5785 let Inst{27-24} = 0b0000;
5786 let Inst{23} = MajOp;
5787 let Inst{20-16} = !if(MajOp, Rss, Rtt);
5788 let Inst{12-8} = !if(MajOp, Rtt, Rss);
5790 let Inst{4-0} = Rdd;
5793 let isCodeGenOnly = 0 in {
5794 def S2_valignib : T_S3op_7 < "valignb", 0>;
5795 def S2_vspliceib : T_S3op_7 < "vspliceb", 1>;
5798 //===----------------------------------------------------------------------===//
5799 // Template class for 'insert bitfield' instructions
5800 //===----------------------------------------------------------------------===//
5801 let hasSideEffects = 0 in
5802 class T_S3op_insert <string mnemonic, RegisterClass RC>
5803 : SInst <(outs RC:$dst),
5804 (ins RC:$src1, RC:$src2, DoubleRegs:$src3),
5805 "$dst = "#mnemonic#"($src2, $src3)" ,
5806 [], "$src1 = $dst", S_3op_tc_1_SLOT23 > {
5811 let IClass = 0b1100;
5813 let Inst{27-26} = 0b10;
5814 let Inst{25-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b00, 0b10);
5816 let Inst{20-16} = src2;
5817 let Inst{12-8} = src3;
5818 let Inst{4-0} = dst;
5821 let hasSideEffects = 0 in
5822 class T_S2op_insert <bits<4> RegTyBits, RegisterClass RC, Operand ImmOp>
5823 : SInst <(outs RC:$dst), (ins RC:$dst2, RC:$src1, ImmOp:$src2, ImmOp:$src3),
5824 "$dst = insert($src1, #$src2, #$src3)",
5825 [], "$dst2 = $dst", S_2op_tc_2_SLOT23> {
5832 string ImmOpStr = !cast<string>(ImmOp);
5834 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5}, 0);
5835 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
5837 let IClass = 0b1000;
5839 let Inst{27-24} = RegTyBits;
5840 let Inst{23} = bit23;
5841 let Inst{22-21} = src3{4-3};
5842 let Inst{20-16} = src1;
5843 let Inst{13} = bit13;
5844 let Inst{12-8} = src2{4-0};
5845 let Inst{7-5} = src3{2-0};
5846 let Inst{4-0} = dst;
5849 // Rx=insert(Rs,Rtt)
5850 // Rx=insert(Rs,#u5,#U5)
5851 let hasNewValue = 1, isCodeGenOnly = 0 in {
5852 def S2_insert_rp : T_S3op_insert <"insert", IntRegs>;
5853 def S2_insert : T_S2op_insert <0b1111, IntRegs, u5Imm>;
5856 // Rxx=insert(Rss,Rtt)
5857 // Rxx=insert(Rss,#u6,#U6)
5858 let isCodeGenOnly = 0 in {
5859 def S2_insertp_rp : T_S3op_insert<"insert", DoubleRegs>;
5860 def S2_insertp : T_S2op_insert <0b0011, DoubleRegs, u6Imm>;
5863 //===----------------------------------------------------------------------===//
5864 // Template class for 'extract bitfield' instructions
5865 //===----------------------------------------------------------------------===//
5866 let hasNewValue = 1, hasSideEffects = 0 in
5867 class T_S3op_extract <string mnemonic, bits<2> MinOp>
5868 : SInst <(outs IntRegs:$Rd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
5869 "$Rd = "#mnemonic#"($Rs, $Rtt)",
5870 [], "", S_3op_tc_2_SLOT23 > {
5875 let IClass = 0b1100;
5877 let Inst{27-22} = 0b100100;
5878 let Inst{20-16} = Rs;
5879 let Inst{12-8} = Rtt;
5880 let Inst{7-6} = MinOp;
5884 let hasSideEffects = 0 in
5885 class T_S2op_extract <string mnemonic, bits<4> RegTyBits,
5886 RegisterClass RC, Operand ImmOp>
5887 : SInst <(outs RC:$dst), (ins RC:$src1, ImmOp:$src2, ImmOp:$src3),
5888 "$dst = "#mnemonic#"($src1, #$src2, #$src3)",
5889 [], "", S_2op_tc_2_SLOT23> {
5896 string ImmOpStr = !cast<string>(ImmOp);
5898 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5},
5899 !if (!eq(mnemonic, "extractu"), 0, 1));
5901 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
5903 let IClass = 0b1000;
5905 let Inst{27-24} = RegTyBits;
5906 let Inst{23} = bit23;
5907 let Inst{22-21} = src3{4-3};
5908 let Inst{20-16} = src1;
5909 let Inst{13} = bit13;
5910 let Inst{12-8} = src2{4-0};
5911 let Inst{7-5} = src3{2-0};
5912 let Inst{4-0} = dst;
5917 // Rdd=extractu(Rss,Rtt)
5918 // Rdd=extractu(Rss,#u6,#U6)
5919 let isCodeGenOnly = 0 in {
5920 def S2_extractup_rp : T_S3op_64 < "extractu", 0b00, 0b000, 0>;
5921 def S2_extractup : T_S2op_extract <"extractu", 0b0001, DoubleRegs, u6Imm>;
5924 // Rd=extractu(Rs,Rtt)
5925 // Rd=extractu(Rs,#u5,#U5)
5926 let hasNewValue = 1, isCodeGenOnly = 0 in {
5927 def S2_extractu_rp : T_S3op_extract<"extractu", 0b00>;
5928 def S2_extractu : T_S2op_extract <"extractu", 0b1101, IntRegs, u5Imm>;
5931 //===----------------------------------------------------------------------===//
5932 // :raw for of tableindx[bdhw] insns
5933 //===----------------------------------------------------------------------===//
5935 let hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
5936 class tableidxRaw<string OpStr, bits<2>MinOp>
5937 : SInst <(outs IntRegs:$Rx),
5938 (ins IntRegs:$_dst_, IntRegs:$Rs, u4Imm:$u4, s6Imm:$S6),
5939 "$Rx = "#OpStr#"($Rs, #$u4, #$S6):raw",
5940 [], "$Rx = $_dst_" > {
5946 let IClass = 0b1000;
5948 let Inst{27-24} = 0b0111;
5949 let Inst{23-22} = MinOp;
5950 let Inst{21} = u4{3};
5951 let Inst{20-16} = Rs;
5952 let Inst{13-8} = S6;
5953 let Inst{7-5} = u4{2-0};
5957 let isCodeGenOnly = 0 in {
5958 def S2_tableidxb : tableidxRaw<"tableidxb", 0b00>;
5959 def S2_tableidxh : tableidxRaw<"tableidxh", 0b01>;
5960 def S2_tableidxw : tableidxRaw<"tableidxw", 0b10>;
5961 def S2_tableidxd : tableidxRaw<"tableidxd", 0b11>;
5964 // Change the sign of the immediate for Rd=-mpyi(Rs,#u8)
5965 def : Pat <(mul (i32 IntRegs:$src1), (ineg n8ImmPred:$src2)),
5966 (i32 (M2_mpysin (i32 IntRegs:$src1), u8ImmPred:$src2))>;
5968 //===----------------------------------------------------------------------===//
5969 // V3 Instructions +
5970 //===----------------------------------------------------------------------===//
5972 include "HexagonInstrInfoV3.td"
5974 //===----------------------------------------------------------------------===//
5975 // V3 Instructions -
5976 //===----------------------------------------------------------------------===//
5978 //===----------------------------------------------------------------------===//
5979 // V4 Instructions +
5980 //===----------------------------------------------------------------------===//
5982 include "HexagonInstrInfoV4.td"
5984 //===----------------------------------------------------------------------===//
5985 // V4 Instructions -
5986 //===----------------------------------------------------------------------===//
5988 //===----------------------------------------------------------------------===//
5989 // V5 Instructions +
5990 //===----------------------------------------------------------------------===//
5992 include "HexagonInstrInfoV5.td"
5994 //===----------------------------------------------------------------------===//
5995 // V5 Instructions -
5996 //===----------------------------------------------------------------------===//
5998 //===----------------------------------------------------------------------===//
5999 // ALU32/64/Vector +
6000 //===----------------------------------------------------------------------===///
6002 include "HexagonInstrInfoVector.td"