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 //===----------------------------------------------------------------------===//
66 let hasSideEffects = 0, isCompare = 1, InputType = "imm", isExtendable = 1,
68 class T_CMP <string mnemonic, bits<2> MajOp, bit isNot, Operand ImmOp>
69 : ALU32Inst <(outs PredRegs:$dst),
70 (ins IntRegs:$src1, ImmOp:$src2),
71 "$dst = "#!if(isNot, "!","")#mnemonic#"($src1, #$src2)",
72 [], "",ALU32_2op_tc_2early_SLOT0123 >, ImmRegRel {
76 let CextOpcode = mnemonic;
77 let opExtentBits = !if(!eq(mnemonic, "cmp.gtu"), 9, 10);
78 let isExtentSigned = !if(!eq(mnemonic, "cmp.gtu"), 0, 1);
82 let Inst{27-24} = 0b0101;
83 let Inst{23-22} = MajOp;
84 let Inst{21} = !if(!eq(mnemonic, "cmp.gtu"), 0, src2{9});
85 let Inst{20-16} = src1;
86 let Inst{13-5} = src2{8-0};
92 def C2_cmpeqi : T_CMP <"cmp.eq", 0b00, 0, s10Ext>;
93 def C2_cmpgti : T_CMP <"cmp.gt", 0b01, 0, s10Ext>;
94 def C2_cmpgtui : T_CMP <"cmp.gtu", 0b10, 0, u9Ext>;
96 class T_CMP_pat <InstHexagon MI, PatFrag OpNode, PatLeaf ImmPred>
97 : Pat<(i1 (OpNode (i32 IntRegs:$src1), ImmPred:$src2)),
98 (MI IntRegs:$src1, ImmPred:$src2)>;
100 def : T_CMP_pat <C2_cmpeqi, seteq, s10ImmPred>;
101 def : T_CMP_pat <C2_cmpgti, setgt, s10ImmPred>;
102 def : T_CMP_pat <C2_cmpgtui, setugt, u9ImmPred>;
104 //===----------------------------------------------------------------------===//
106 //===----------------------------------------------------------------------===//
107 def SDTHexagonI64I32I32 : SDTypeProfile<1, 2,
108 [SDTCisVT<0, i64>, SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>;
110 def HexagonCOMBINE : SDNode<"HexagonISD::COMBINE", SDTHexagonI64I32I32>;
112 let hasSideEffects = 0, hasNewValue = 1, InputType = "reg" in
113 class T_ALU32_3op<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit OpsRev,
115 : ALU32_rr<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
116 "$Rd = "#mnemonic#"($Rs, $Rt)",
117 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredRel {
118 let isCommutable = IsComm;
119 let BaseOpcode = mnemonic#_rr;
120 let CextOpcode = mnemonic;
128 let Inst{26-24} = MajOp;
129 let Inst{23-21} = MinOp;
130 let Inst{20-16} = !if(OpsRev,Rt,Rs);
131 let Inst{12-8} = !if(OpsRev,Rs,Rt);
135 let hasSideEffects = 0, hasNewValue = 1 in
136 class T_ALU32_3op_pred<string mnemonic, bits<3> MajOp, bits<3> MinOp,
137 bit OpsRev, bit PredNot, bit PredNew>
138 : ALU32_rr<(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
139 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") "#
140 "$Rd = "#mnemonic#"($Rs, $Rt)",
141 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
142 let isPredicated = 1;
143 let isPredicatedFalse = PredNot;
144 let isPredicatedNew = PredNew;
145 let BaseOpcode = mnemonic#_rr;
146 let CextOpcode = mnemonic;
155 let Inst{26-24} = MajOp;
156 let Inst{23-21} = MinOp;
157 let Inst{20-16} = !if(OpsRev,Rt,Rs);
158 let Inst{13} = PredNew;
159 let Inst{12-8} = !if(OpsRev,Rs,Rt);
160 let Inst{7} = PredNot;
165 class T_ALU32_combineh<string Op1, string Op2, bits<3> MajOp, bits<3> MinOp,
167 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, 0> {
168 let AsmString = "$Rd = combine($Rs"#Op1#", $Rt"#Op2#")";
171 def A2_combine_hh : T_ALU32_combineh<".h", ".h", 0b011, 0b100, 1>;
172 def A2_combine_hl : T_ALU32_combineh<".h", ".l", 0b011, 0b101, 1>;
173 def A2_combine_lh : T_ALU32_combineh<".l", ".h", 0b011, 0b110, 1>;
174 def A2_combine_ll : T_ALU32_combineh<".l", ".l", 0b011, 0b111, 1>;
176 class T_ALU32_3op_sfx<string mnemonic, string suffix, bits<3> MajOp,
177 bits<3> MinOp, bit OpsRev, bit IsComm>
178 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, IsComm> {
179 let AsmString = "$Rd = "#mnemonic#"($Rs, $Rt)"#suffix;
182 def A2_svaddh : T_ALU32_3op<"vaddh", 0b110, 0b000, 0, 1>;
183 def A2_svsubh : T_ALU32_3op<"vsubh", 0b110, 0b100, 1, 0>;
185 let Defs = [USR_OVF], Itinerary = ALU32_3op_tc_2_SLOT0123 in {
186 def A2_svaddhs : T_ALU32_3op_sfx<"vaddh", ":sat", 0b110, 0b001, 0, 1>;
187 def A2_addsat : T_ALU32_3op_sfx<"add", ":sat", 0b110, 0b010, 0, 1>;
188 def A2_svadduhs : T_ALU32_3op_sfx<"vadduh", ":sat", 0b110, 0b011, 0, 1>;
189 def A2_svsubhs : T_ALU32_3op_sfx<"vsubh", ":sat", 0b110, 0b101, 1, 0>;
190 def A2_subsat : T_ALU32_3op_sfx<"sub", ":sat", 0b110, 0b110, 1, 0>;
191 def A2_svsubuhs : T_ALU32_3op_sfx<"vsubuh", ":sat", 0b110, 0b111, 1, 0>;
194 let Itinerary = ALU32_3op_tc_2_SLOT0123 in
195 def A2_svavghs : T_ALU32_3op_sfx<"vavgh", ":rnd", 0b111, 0b001, 0, 1>;
197 def A2_svavgh : T_ALU32_3op<"vavgh", 0b111, 0b000, 0, 1>;
198 def A2_svnavgh : T_ALU32_3op<"vnavgh", 0b111, 0b011, 1, 0>;
200 multiclass T_ALU32_3op_p<string mnemonic, bits<3> MajOp, bits<3> MinOp,
202 def t : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 0>;
203 def f : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 0>;
204 def tnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 1>;
205 def fnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 1>;
208 multiclass T_ALU32_3op_A2<string mnemonic, bits<3> MajOp, bits<3> MinOp,
209 bit OpsRev, bit IsComm> {
210 let isPredicable = 1 in
211 def A2_#NAME : T_ALU32_3op <mnemonic, MajOp, MinOp, OpsRev, IsComm>;
212 defm A2_p#NAME : T_ALU32_3op_p<mnemonic, MajOp, MinOp, OpsRev>;
215 defm add : T_ALU32_3op_A2<"add", 0b011, 0b000, 0, 1>;
216 defm and : T_ALU32_3op_A2<"and", 0b001, 0b000, 0, 1>;
217 defm or : T_ALU32_3op_A2<"or", 0b001, 0b001, 0, 1>;
218 defm sub : T_ALU32_3op_A2<"sub", 0b011, 0b001, 1, 0>;
219 defm xor : T_ALU32_3op_A2<"xor", 0b001, 0b011, 0, 1>;
221 // Pats for instruction selection.
222 class BinOp32_pat<SDNode Op, InstHexagon MI, ValueType ResT>
223 : Pat<(ResT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
224 (ResT (MI IntRegs:$Rs, IntRegs:$Rt))>;
226 def: BinOp32_pat<add, A2_add, i32>;
227 def: BinOp32_pat<and, A2_and, i32>;
228 def: BinOp32_pat<or, A2_or, i32>;
229 def: BinOp32_pat<sub, A2_sub, i32>;
230 def: BinOp32_pat<xor, A2_xor, i32>;
232 // A few special cases producing register pairs:
233 let OutOperandList = (outs DoubleRegs:$Rd), hasNewValue = 0 in {
234 def S2_packhl : T_ALU32_3op <"packhl", 0b101, 0b100, 0, 0>;
236 let isPredicable = 1 in
237 def A2_combinew : T_ALU32_3op <"combine", 0b101, 0b000, 0, 0>;
239 // Conditional combinew uses "newt/f" instead of "t/fnew".
240 def C2_ccombinewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 0>;
241 def C2_ccombinewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 0>;
242 def C2_ccombinewnewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 1>;
243 def C2_ccombinewnewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 1>;
246 let hasSideEffects = 0, hasNewValue = 1, isCompare = 1, InputType = "reg" in
247 class T_ALU32_3op_cmp<string mnemonic, bits<2> MinOp, bit IsNeg, bit IsComm>
248 : ALU32_rr<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
249 "$Pd = "#mnemonic#"($Rs, $Rt)",
250 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
251 let CextOpcode = mnemonic;
252 let isCommutable = IsComm;
258 let Inst{27-24} = 0b0010;
259 let Inst{22-21} = MinOp;
260 let Inst{20-16} = Rs;
263 let Inst{3-2} = 0b00;
267 let Itinerary = ALU32_3op_tc_2early_SLOT0123 in {
268 def C2_cmpeq : T_ALU32_3op_cmp< "cmp.eq", 0b00, 0, 1>;
269 def C2_cmpgt : T_ALU32_3op_cmp< "cmp.gt", 0b10, 0, 0>;
270 def C2_cmpgtu : T_ALU32_3op_cmp< "cmp.gtu", 0b11, 0, 0>;
273 // Patfrag to convert the usual comparison patfrags (e.g. setlt) to ones
274 // that reverse the order of the operands.
275 class RevCmp<PatFrag F> : PatFrag<(ops node:$rhs, node:$lhs), F.Fragment>;
277 // Pats for compares. They use PatFrags as operands, not SDNodes,
278 // since seteq/setgt/etc. are defined as ParFrags.
279 class T_cmp32_rr_pat<InstHexagon MI, PatFrag Op, ValueType VT>
280 : Pat<(VT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
281 (VT (MI IntRegs:$Rs, IntRegs:$Rt))>;
283 def: T_cmp32_rr_pat<C2_cmpeq, seteq, i1>;
284 def: T_cmp32_rr_pat<C2_cmpgt, setgt, i1>;
285 def: T_cmp32_rr_pat<C2_cmpgtu, setugt, i1>;
287 def: T_cmp32_rr_pat<C2_cmpgt, RevCmp<setlt>, i1>;
288 def: T_cmp32_rr_pat<C2_cmpgtu, RevCmp<setult>, i1>;
290 let CextOpcode = "MUX", InputType = "reg", hasNewValue = 1 in
291 def C2_mux: ALU32_rr<(outs IntRegs:$Rd),
292 (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
293 "$Rd = mux($Pu, $Rs, $Rt)", [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
299 let CextOpcode = "mux";
300 let InputType = "reg";
301 let hasSideEffects = 0;
304 let Inst{27-24} = 0b0100;
305 let Inst{20-16} = Rs;
311 def: Pat<(i32 (select (i1 PredRegs:$Pu), (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
312 (C2_mux PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt)>;
314 // Combines the two immediates into a double register.
315 // Increase complexity to make it greater than any complexity of a combine
316 // that involves a register.
318 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
319 isExtentSigned = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 1,
320 AddedComplexity = 75 in
321 def A2_combineii: ALU32Inst <(outs DoubleRegs:$Rdd), (ins s8Ext:$s8, s8Imm:$S8),
322 "$Rdd = combine(#$s8, #$S8)",
323 [(set (i64 DoubleRegs:$Rdd),
324 (i64 (HexagonCOMBINE(i32 s8ExtPred:$s8), (i32 s8ImmPred:$S8))))]> {
330 let Inst{27-23} = 0b11000;
331 let Inst{22-16} = S8{7-1};
332 let Inst{13} = S8{0};
337 //===----------------------------------------------------------------------===//
338 // Template class for predicated ADD of a reg and an Immediate value.
339 //===----------------------------------------------------------------------===//
340 let hasNewValue = 1, hasSideEffects = 0 in
341 class T_Addri_Pred <bit PredNot, bit PredNew>
342 : ALU32_ri <(outs IntRegs:$Rd),
343 (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
344 !if(PredNot, "if (!$Pu", "if ($Pu")#!if(PredNew,".new) $Rd = ",
345 ") $Rd = ")#"add($Rs, #$s8)"> {
351 let isPredicatedNew = PredNew;
354 let Inst{27-24} = 0b0100;
355 let Inst{23} = PredNot;
356 let Inst{22-21} = Pu;
357 let Inst{20-16} = Rs;
358 let Inst{13} = PredNew;
363 //===----------------------------------------------------------------------===//
364 // A2_addi: Add a signed immediate to a register.
365 //===----------------------------------------------------------------------===//
366 let hasNewValue = 1, hasSideEffects = 0 in
367 class T_Addri <Operand immOp>
368 : ALU32_ri <(outs IntRegs:$Rd),
369 (ins IntRegs:$Rs, immOp:$s16),
370 "$Rd = add($Rs, #$s16)", [], "", ALU32_ADDI_tc_1_SLOT0123> {
377 let Inst{27-21} = s16{15-9};
378 let Inst{20-16} = Rs;
379 let Inst{13-5} = s16{8-0};
383 //===----------------------------------------------------------------------===//
384 // Multiclass for ADD of a register and an immediate value.
385 //===----------------------------------------------------------------------===//
386 multiclass Addri_Pred<string mnemonic, bit PredNot> {
387 let isPredicatedFalse = PredNot in {
388 def NAME : T_Addri_Pred<PredNot, 0>;
390 def NAME#new : T_Addri_Pred<PredNot, 1>;
394 let isExtendable = 1, isExtentSigned = 1, InputType = "imm" in
395 multiclass Addri_base<string mnemonic, SDNode OpNode> {
396 let CextOpcode = mnemonic, BaseOpcode = mnemonic#_ri in {
397 let opExtendable = 2, opExtentBits = 16, isPredicable = 1 in
398 def A2_#NAME : T_Addri<s16Ext>;
400 let opExtendable = 3, opExtentBits = 8, isPredicated = 1 in {
401 defm A2_p#NAME#t : Addri_Pred<mnemonic, 0>;
402 defm A2_p#NAME#f : Addri_Pred<mnemonic, 1>;
407 defm addi : Addri_base<"add", add>, ImmRegRel, PredNewRel;
409 def: Pat<(i32 (add I32:$Rs, s16ExtPred:$s16)),
410 (i32 (A2_addi I32:$Rs, imm:$s16))>;
412 //===----------------------------------------------------------------------===//
413 // Template class used for the following ALU32 instructions.
416 //===----------------------------------------------------------------------===//
417 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 10,
418 InputType = "imm", hasNewValue = 1 in
419 class T_ALU32ri_logical <string mnemonic, SDNode OpNode, bits<2> MinOp>
420 : ALU32_ri <(outs IntRegs:$Rd),
421 (ins IntRegs:$Rs, s10Ext:$s10),
422 "$Rd = "#mnemonic#"($Rs, #$s10)" ,
423 [(set (i32 IntRegs:$Rd), (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10))]> {
427 let CextOpcode = mnemonic;
431 let Inst{27-24} = 0b0110;
432 let Inst{23-22} = MinOp;
433 let Inst{21} = s10{9};
434 let Inst{20-16} = Rs;
435 let Inst{13-5} = s10{8-0};
439 def A2_orir : T_ALU32ri_logical<"or", or, 0b10>, ImmRegRel;
440 def A2_andir : T_ALU32ri_logical<"and", and, 0b00>, ImmRegRel;
442 // Subtract register from immediate
443 // Rd32=sub(#s10,Rs32)
444 let isExtendable = 1, CextOpcode = "sub", opExtendable = 1, isExtentSigned = 1,
445 opExtentBits = 10, InputType = "imm", hasNewValue = 1, hasSideEffects = 0 in
446 def A2_subri: ALU32_ri <(outs IntRegs:$Rd), (ins s10Ext:$s10, IntRegs:$Rs),
447 "$Rd = sub(#$s10, $Rs)", []>, ImmRegRel {
454 let Inst{27-22} = 0b011001;
455 let Inst{21} = s10{9};
456 let Inst{20-16} = Rs;
457 let Inst{13-5} = s10{8-0};
462 let hasSideEffects = 0 in
463 def A2_nop: ALU32Inst <(outs), (ins), "nop" > {
465 let Inst{27-24} = 0b1111;
468 def: Pat<(sub s10ExtPred:$s10, IntRegs:$Rs),
469 (A2_subri imm:$s10, IntRegs:$Rs)>;
471 // Rd = not(Rs) gets mapped to Rd=sub(#-1, Rs).
472 def: Pat<(not (i32 IntRegs:$src1)),
473 (A2_subri -1, IntRegs:$src1)>;
475 let hasSideEffects = 0, hasNewValue = 1 in
476 class T_tfr16<bit isHi>
477 : ALU32Inst <(outs IntRegs:$Rx), (ins IntRegs:$src1, u16Imm:$u16),
478 "$Rx"#!if(isHi, ".h", ".l")#" = #$u16",
479 [], "$src1 = $Rx" > {
484 let Inst{27-26} = 0b00;
485 let Inst{25-24} = !if(isHi, 0b10, 0b01);
486 let Inst{23-22} = u16{15-14};
488 let Inst{20-16} = Rx;
489 let Inst{13-0} = u16{13-0};
492 def A2_tfril: T_tfr16<0>;
493 def A2_tfrih: T_tfr16<1>;
495 // Conditional transfer is an alias to conditional "Rd = add(Rs, #0)".
496 let isPredicated = 1, hasNewValue = 1, opNewValue = 0 in
497 class T_tfr_pred<bit isPredNot, bit isPredNew>
498 : ALU32Inst<(outs IntRegs:$dst),
499 (ins PredRegs:$src1, IntRegs:$src2),
500 "if ("#!if(isPredNot, "!", "")#
501 "$src1"#!if(isPredNew, ".new", "")#
507 let isPredicatedFalse = isPredNot;
508 let isPredicatedNew = isPredNew;
511 let Inst{27-24} = 0b0100;
512 let Inst{23} = isPredNot;
513 let Inst{13} = isPredNew;
516 let Inst{22-21} = src1;
517 let Inst{20-16} = src2;
520 let isPredicable = 1 in
521 class T_tfr : ALU32Inst<(outs IntRegs:$dst), (ins IntRegs:$src),
528 let Inst{27-21} = 0b0000011;
529 let Inst{20-16} = src;
534 let InputType = "reg", hasNewValue = 1, hasSideEffects = 0 in
535 multiclass tfr_base<string CextOp> {
536 let CextOpcode = CextOp, BaseOpcode = CextOp in {
540 def t : T_tfr_pred<0, 0>;
541 def f : T_tfr_pred<1, 0>;
543 def tnew : T_tfr_pred<0, 1>;
544 def fnew : T_tfr_pred<1, 1>;
548 // Assembler mapped to C2_ccombinew[t|f|newt|newf].
549 // Please don't add bits to this instruction as it'll be converted into
550 // 'combine' before object code emission.
551 let isPredicated = 1 in
552 class T_tfrp_pred<bit PredNot, bit PredNew>
553 : ALU32_rr <(outs DoubleRegs:$dst),
554 (ins PredRegs:$src1, DoubleRegs:$src2),
555 "if ("#!if(PredNot, "!", "")#"$src1"
556 #!if(PredNew, ".new", "")#") $dst = $src2" > {
557 let isPredicatedFalse = PredNot;
558 let isPredicatedNew = PredNew;
561 // Assembler mapped to A2_combinew.
562 // Please don't add bits to this instruction as it'll be converted into
563 // 'combine' before object code emission.
564 class T_tfrp : ALU32Inst <(outs DoubleRegs:$dst),
565 (ins DoubleRegs:$src),
568 let hasSideEffects = 0 in
569 multiclass TFR64_base<string BaseName> {
570 let BaseOpcode = BaseName in {
571 let isPredicable = 1 in
574 def t : T_tfrp_pred <0, 0>;
575 def f : T_tfrp_pred <1, 0>;
577 def tnew : T_tfrp_pred <0, 1>;
578 def fnew : T_tfrp_pred <1, 1>;
582 let InputType = "imm", isExtendable = 1, isExtentSigned = 1, opExtentBits = 12,
583 isMoveImm = 1, opExtendable = 2, BaseOpcode = "TFRI", CextOpcode = "TFR",
584 hasSideEffects = 0, isPredicated = 1, hasNewValue = 1 in
585 class T_TFRI_Pred<bit PredNot, bit PredNew>
586 : ALU32_ri<(outs IntRegs:$Rd), (ins PredRegs:$Pu, s12Ext:$s12),
587 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") $Rd = #$s12",
588 [], "", ALU32_2op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
589 let isPredicatedFalse = PredNot;
590 let isPredicatedNew = PredNew;
597 let Inst{27-24} = 0b1110;
598 let Inst{23} = PredNot;
599 let Inst{22-21} = Pu;
601 let Inst{19-16,12-5} = s12;
602 let Inst{13} = PredNew;
606 def C2_cmoveit : T_TFRI_Pred<0, 0>;
607 def C2_cmoveif : T_TFRI_Pred<1, 0>;
608 def C2_cmovenewit : T_TFRI_Pred<0, 1>;
609 def C2_cmovenewif : T_TFRI_Pred<1, 1>;
611 let InputType = "imm", isExtendable = 1, isExtentSigned = 1,
612 CextOpcode = "TFR", BaseOpcode = "TFRI", hasNewValue = 1, opNewValue = 0,
613 isAsCheapAsAMove = 1 , opExtendable = 1, opExtentBits = 16, isMoveImm = 1,
614 isPredicated = 0, isPredicable = 1, isReMaterializable = 1 in
615 def A2_tfrsi : ALU32Inst<(outs IntRegs:$Rd), (ins s16Ext:$s16), "$Rd = #$s16",
616 [(set (i32 IntRegs:$Rd), s16ExtPred:$s16)], "", ALU32_2op_tc_1_SLOT0123>,
622 let Inst{27-24} = 0b1000;
623 let Inst{23-22,20-16,13-5} = s16;
627 defm A2_tfr : tfr_base<"TFR">, ImmRegRel, PredNewRel;
628 let isAsmParserOnly = 1 in
629 defm A2_tfrp : TFR64_base<"TFR64">, PredNewRel;
632 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
633 isAsmParserOnly = 1 in
634 def A2_tfrpi : ALU64_rr<(outs DoubleRegs:$dst), (ins s8Imm64:$src1),
636 [(set (i64 DoubleRegs:$dst), s8Imm64Pred:$src1)]>;
638 // TODO: see if this instruction can be deleted..
639 let isExtendable = 1, opExtendable = 1, opExtentBits = 6,
640 isAsmParserOnly = 1 in
641 def TFRI64_V4 : ALU64_rr<(outs DoubleRegs:$dst), (ins u6Ext:$src1),
644 //===----------------------------------------------------------------------===//
646 //===----------------------------------------------------------------------===//
649 //===----------------------------------------------------------------------===//
651 //===----------------------------------------------------------------------===//
652 // Scalar mux register immediate.
653 let hasSideEffects = 0, isExtentSigned = 1, CextOpcode = "MUX",
654 InputType = "imm", hasNewValue = 1, isExtendable = 1, opExtentBits = 8 in
655 class T_MUX1 <bit MajOp, dag ins, string AsmStr>
656 : ALU32Inst <(outs IntRegs:$Rd), ins, AsmStr>, ImmRegRel {
663 let Inst{27-24} = 0b0011;
664 let Inst{23} = MajOp;
665 let Inst{22-21} = Pu;
666 let Inst{20-16} = Rs;
672 let opExtendable = 2 in
673 def C2_muxri : T_MUX1<0b1, (ins PredRegs:$Pu, s8Ext:$s8, IntRegs:$Rs),
674 "$Rd = mux($Pu, #$s8, $Rs)">;
676 let opExtendable = 3 in
677 def C2_muxir : T_MUX1<0b0, (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
678 "$Rd = mux($Pu, $Rs, #$s8)">;
680 def : Pat<(i32 (select I1:$Pu, s8ExtPred:$s8, I32:$Rs)),
681 (C2_muxri I1:$Pu, s8ExtPred:$s8, I32:$Rs)>;
683 def : Pat<(i32 (select I1:$Pu, I32:$Rs, s8ExtPred:$s8)),
684 (C2_muxir I1:$Pu, I32:$Rs, s8ExtPred:$s8)>;
686 // C2_muxii: Scalar mux immediates.
687 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1,
688 opExtentBits = 8, opExtendable = 2 in
689 def C2_muxii: ALU32Inst <(outs IntRegs:$Rd),
690 (ins PredRegs:$Pu, s8Ext:$s8, s8Imm:$S8),
691 "$Rd = mux($Pu, #$s8, #$S8)" ,
692 [(set (i32 IntRegs:$Rd),
693 (i32 (select I1:$Pu, s8ExtPred:$s8, s8ImmPred:$S8)))] > {
701 let Inst{27-25} = 0b101;
702 let Inst{24-23} = Pu;
703 let Inst{22-16} = S8{7-1};
704 let Inst{13} = S8{0};
709 //===----------------------------------------------------------------------===//
710 // template class for non-predicated alu32_2op instructions
711 // - aslh, asrh, sxtb, sxth, zxth
712 //===----------------------------------------------------------------------===//
713 let hasNewValue = 1, opNewValue = 0 in
714 class T_ALU32_2op <string mnemonic, bits<3> minOp> :
715 ALU32Inst <(outs IntRegs:$Rd), (ins IntRegs:$Rs),
716 "$Rd = "#mnemonic#"($Rs)", [] > {
722 let Inst{27-24} = 0b0000;
723 let Inst{23-21} = minOp;
726 let Inst{20-16} = Rs;
729 //===----------------------------------------------------------------------===//
730 // template class for predicated alu32_2op instructions
731 // - aslh, asrh, sxtb, sxth, zxtb, zxth
732 //===----------------------------------------------------------------------===//
733 let hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
734 class T_ALU32_2op_Pred <string mnemonic, bits<3> minOp, bit isPredNot,
736 ALU32Inst <(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs),
737 !if(isPredNot, "if (!$Pu", "if ($Pu")
738 #!if(isPredNew, ".new) ",") ")#"$Rd = "#mnemonic#"($Rs)"> {
745 let Inst{27-24} = 0b0000;
746 let Inst{23-21} = minOp;
748 let Inst{11} = isPredNot;
749 let Inst{10} = isPredNew;
752 let Inst{20-16} = Rs;
755 multiclass ALU32_2op_Pred<string mnemonic, bits<3> minOp, bit PredNot> {
756 let isPredicatedFalse = PredNot in {
757 def NAME : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 0>;
760 let isPredicatedNew = 1 in
761 def NAME#new : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 1>;
765 multiclass ALU32_2op_base<string mnemonic, bits<3> minOp> {
766 let BaseOpcode = mnemonic in {
767 let isPredicable = 1, hasSideEffects = 0 in
768 def A2_#NAME : T_ALU32_2op<mnemonic, minOp>;
770 let isPredicated = 1, hasSideEffects = 0 in {
771 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
772 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
777 defm aslh : ALU32_2op_base<"aslh", 0b000>, PredNewRel;
778 defm asrh : ALU32_2op_base<"asrh", 0b001>, PredNewRel;
779 defm sxtb : ALU32_2op_base<"sxtb", 0b101>, PredNewRel;
780 defm sxth : ALU32_2op_base<"sxth", 0b111>, PredNewRel;
781 defm zxth : ALU32_2op_base<"zxth", 0b110>, PredNewRel;
783 // Rd=zxtb(Rs): assembler mapped to Rd=and(Rs,#255).
784 // Compiler would want to generate 'zxtb' instead of 'and' becuase 'zxtb' has
785 // predicated forms while 'and' doesn't. Since integrated assembler can't
786 // handle 'mapped' instructions, we need to encode 'zxtb' same as 'and' where
787 // immediate operand is set to '255'.
789 let hasNewValue = 1, opNewValue = 0 in
790 class T_ZXTB: ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
791 "$Rd = zxtb($Rs)", [] > { // Rd = and(Rs,255)
798 let Inst{27-22} = 0b011000;
800 let Inst{20-16} = Rs;
801 let Inst{21} = s10{9};
802 let Inst{13-5} = s10{8-0};
805 //Rd=zxtb(Rs): assembler mapped to "Rd=and(Rs,#255)
806 multiclass ZXTB_base <string mnemonic, bits<3> minOp> {
807 let BaseOpcode = mnemonic in {
808 let isPredicable = 1, hasSideEffects = 0 in
809 def A2_#NAME : T_ZXTB;
811 let isPredicated = 1, hasSideEffects = 0 in {
812 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
813 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
818 defm zxtb : ZXTB_base<"zxtb",0b100>, PredNewRel;
820 def: Pat<(shl I32:$src1, (i32 16)), (A2_aslh I32:$src1)>;
821 def: Pat<(sra I32:$src1, (i32 16)), (A2_asrh I32:$src1)>;
822 def: Pat<(sext_inreg I32:$src1, i8), (A2_sxtb I32:$src1)>;
823 def: Pat<(sext_inreg I32:$src1, i16), (A2_sxth I32:$src1)>;
825 //===----------------------------------------------------------------------===//
826 // Template class for vector add and avg
827 //===----------------------------------------------------------------------===//
829 class T_VectALU_64 <string opc, bits<3> majOp, bits<3> minOp,
830 bit isSat, bit isRnd, bit isCrnd, bit SwapOps >
831 : ALU64_rr < (outs DoubleRegs:$Rdd),
832 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
833 "$Rdd = "#opc#"($Rss, $Rtt)"#!if(isRnd, ":rnd", "")
834 #!if(isCrnd,":crnd","")
835 #!if(isSat, ":sat", ""),
836 [], "", ALU64_tc_2_SLOT23 > {
843 let Inst{27-24} = 0b0011;
844 let Inst{23-21} = majOp;
845 let Inst{20-16} = !if (SwapOps, Rtt, Rss);
846 let Inst{12-8} = !if (SwapOps, Rss, Rtt);
847 let Inst{7-5} = minOp;
851 // ALU64 - Vector add
852 // Rdd=vadd[u][bhw](Rss,Rtt)
853 let Itinerary = ALU64_tc_1_SLOT23 in {
854 def A2_vaddub : T_VectALU_64 < "vaddub", 0b000, 0b000, 0, 0, 0, 0>;
855 def A2_vaddh : T_VectALU_64 < "vaddh", 0b000, 0b010, 0, 0, 0, 0>;
856 def A2_vaddw : T_VectALU_64 < "vaddw", 0b000, 0b101, 0, 0, 0, 0>;
859 // Rdd=vadd[u][bhw](Rss,Rtt):sat
860 let Defs = [USR_OVF] in {
861 def A2_vaddubs : T_VectALU_64 < "vaddub", 0b000, 0b001, 1, 0, 0, 0>;
862 def A2_vaddhs : T_VectALU_64 < "vaddh", 0b000, 0b011, 1, 0, 0, 0>;
863 def A2_vadduhs : T_VectALU_64 < "vadduh", 0b000, 0b100, 1, 0, 0, 0>;
864 def A2_vaddws : T_VectALU_64 < "vaddw", 0b000, 0b110, 1, 0, 0, 0>;
867 // ALU64 - Vector average
868 // Rdd=vavg[u][bhw](Rss,Rtt)
869 let Itinerary = ALU64_tc_1_SLOT23 in {
870 def A2_vavgub : T_VectALU_64 < "vavgub", 0b010, 0b000, 0, 0, 0, 0>;
871 def A2_vavgh : T_VectALU_64 < "vavgh", 0b010, 0b010, 0, 0, 0, 0>;
872 def A2_vavguh : T_VectALU_64 < "vavguh", 0b010, 0b101, 0, 0, 0, 0>;
873 def A2_vavgw : T_VectALU_64 < "vavgw", 0b011, 0b000, 0, 0, 0, 0>;
874 def A2_vavguw : T_VectALU_64 < "vavguw", 0b011, 0b011, 0, 0, 0, 0>;
877 // Rdd=vavg[u][bhw](Rss,Rtt)[:rnd|:crnd]
878 def A2_vavgubr : T_VectALU_64 < "vavgub", 0b010, 0b001, 0, 1, 0, 0>;
879 def A2_vavghr : T_VectALU_64 < "vavgh", 0b010, 0b011, 0, 1, 0, 0>;
880 def A2_vavghcr : T_VectALU_64 < "vavgh", 0b010, 0b100, 0, 0, 1, 0>;
881 def A2_vavguhr : T_VectALU_64 < "vavguh", 0b010, 0b110, 0, 1, 0, 0>;
883 def A2_vavgwr : T_VectALU_64 < "vavgw", 0b011, 0b001, 0, 1, 0, 0>;
884 def A2_vavgwcr : T_VectALU_64 < "vavgw", 0b011, 0b010, 0, 0, 1, 0>;
885 def A2_vavguwr : T_VectALU_64 < "vavguw", 0b011, 0b100, 0, 1, 0, 0>;
887 // Rdd=vnavg[bh](Rss,Rtt)
888 let Itinerary = ALU64_tc_1_SLOT23 in {
889 def A2_vnavgh : T_VectALU_64 < "vnavgh", 0b100, 0b000, 0, 0, 0, 1>;
890 def A2_vnavgw : T_VectALU_64 < "vnavgw", 0b100, 0b011, 0, 0, 0, 1>;
893 // Rdd=vnavg[bh](Rss,Rtt)[:rnd|:crnd]:sat
894 let Defs = [USR_OVF] in {
895 def A2_vnavghr : T_VectALU_64 < "vnavgh", 0b100, 0b001, 1, 1, 0, 1>;
896 def A2_vnavghcr : T_VectALU_64 < "vnavgh", 0b100, 0b010, 1, 0, 1, 1>;
897 def A2_vnavgwr : T_VectALU_64 < "vnavgw", 0b100, 0b100, 1, 1, 0, 1>;
898 def A2_vnavgwcr : T_VectALU_64 < "vnavgw", 0b100, 0b110, 1, 0, 1, 1>;
901 // Rdd=vsub[u][bh](Rss,Rtt)
902 let Itinerary = ALU64_tc_1_SLOT23 in {
903 def A2_vsubub : T_VectALU_64 < "vsubub", 0b001, 0b000, 0, 0, 0, 1>;
904 def A2_vsubh : T_VectALU_64 < "vsubh", 0b001, 0b010, 0, 0, 0, 1>;
905 def A2_vsubw : T_VectALU_64 < "vsubw", 0b001, 0b101, 0, 0, 0, 1>;
908 // Rdd=vsub[u][bh](Rss,Rtt):sat
909 let Defs = [USR_OVF] in {
910 def A2_vsububs : T_VectALU_64 < "vsubub", 0b001, 0b001, 1, 0, 0, 1>;
911 def A2_vsubhs : T_VectALU_64 < "vsubh", 0b001, 0b011, 1, 0, 0, 1>;
912 def A2_vsubuhs : T_VectALU_64 < "vsubuh", 0b001, 0b100, 1, 0, 0, 1>;
913 def A2_vsubws : T_VectALU_64 < "vsubw", 0b001, 0b110, 1, 0, 0, 1>;
916 // Rdd=vmax[u][bhw](Rss,Rtt)
917 def A2_vmaxb : T_VectALU_64 < "vmaxb", 0b110, 0b110, 0, 0, 0, 1>;
918 def A2_vmaxub : T_VectALU_64 < "vmaxub", 0b110, 0b000, 0, 0, 0, 1>;
919 def A2_vmaxh : T_VectALU_64 < "vmaxh", 0b110, 0b001, 0, 0, 0, 1>;
920 def A2_vmaxuh : T_VectALU_64 < "vmaxuh", 0b110, 0b010, 0, 0, 0, 1>;
921 def A2_vmaxw : T_VectALU_64 < "vmaxw", 0b110, 0b011, 0, 0, 0, 1>;
922 def A2_vmaxuw : T_VectALU_64 < "vmaxuw", 0b101, 0b101, 0, 0, 0, 1>;
924 // Rdd=vmin[u][bhw](Rss,Rtt)
925 def A2_vminb : T_VectALU_64 < "vminb", 0b110, 0b111, 0, 0, 0, 1>;
926 def A2_vminub : T_VectALU_64 < "vminub", 0b101, 0b000, 0, 0, 0, 1>;
927 def A2_vminh : T_VectALU_64 < "vminh", 0b101, 0b001, 0, 0, 0, 1>;
928 def A2_vminuh : T_VectALU_64 < "vminuh", 0b101, 0b010, 0, 0, 0, 1>;
929 def A2_vminw : T_VectALU_64 < "vminw", 0b101, 0b011, 0, 0, 0, 1>;
930 def A2_vminuw : T_VectALU_64 < "vminuw", 0b101, 0b100, 0, 0, 0, 1>;
932 //===----------------------------------------------------------------------===//
933 // Template class for vector compare
934 //===----------------------------------------------------------------------===//
935 let hasSideEffects = 0 in
936 class T_vcmp <string Str, bits<4> minOp>
937 : ALU64_rr <(outs PredRegs:$Pd),
938 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
939 "$Pd = "#Str#"($Rss, $Rtt)", [],
940 "", ALU64_tc_2early_SLOT23> {
947 let Inst{27-23} = 0b00100;
948 let Inst{13} = minOp{3};
949 let Inst{7-5} = minOp{2-0};
951 let Inst{20-16} = Rss;
952 let Inst{12-8} = Rtt;
955 class T_vcmp_pat<InstHexagon MI, PatFrag Op, ValueType T>
956 : Pat<(i1 (Op (T DoubleRegs:$Rss), (T DoubleRegs:$Rtt))),
957 (i1 (MI DoubleRegs:$Rss, DoubleRegs:$Rtt))>;
959 // Vector compare bytes
960 def A2_vcmpbeq : T_vcmp <"vcmpb.eq", 0b0110>;
961 def A2_vcmpbgtu : T_vcmp <"vcmpb.gtu", 0b0111>;
963 // Vector compare halfwords
964 def A2_vcmpheq : T_vcmp <"vcmph.eq", 0b0011>;
965 def A2_vcmphgt : T_vcmp <"vcmph.gt", 0b0100>;
966 def A2_vcmphgtu : T_vcmp <"vcmph.gtu", 0b0101>;
968 // Vector compare words
969 def A2_vcmpweq : T_vcmp <"vcmpw.eq", 0b0000>;
970 def A2_vcmpwgt : T_vcmp <"vcmpw.gt", 0b0001>;
971 def A2_vcmpwgtu : T_vcmp <"vcmpw.gtu", 0b0010>;
973 def: T_vcmp_pat<A2_vcmpbeq, seteq, v8i8>;
974 def: T_vcmp_pat<A2_vcmpbgtu, setugt, v8i8>;
975 def: T_vcmp_pat<A2_vcmpheq, seteq, v4i16>;
976 def: T_vcmp_pat<A2_vcmphgt, setgt, v4i16>;
977 def: T_vcmp_pat<A2_vcmphgtu, setugt, v4i16>;
978 def: T_vcmp_pat<A2_vcmpweq, seteq, v2i32>;
979 def: T_vcmp_pat<A2_vcmpwgt, setgt, v2i32>;
980 def: T_vcmp_pat<A2_vcmpwgtu, setugt, v2i32>;
982 //===----------------------------------------------------------------------===//
984 //===----------------------------------------------------------------------===//
987 //===----------------------------------------------------------------------===//
989 //===----------------------------------------------------------------------===//
991 //===----------------------------------------------------------------------===//
993 //===----------------------------------------------------------------------===//
996 //===----------------------------------------------------------------------===//
998 //===----------------------------------------------------------------------===//
1000 //===----------------------------------------------------------------------===//
1002 // Add/Subtract halfword
1003 // Rd=add(Rt.L,Rs.[HL])[:sat]
1004 // Rd=sub(Rt.L,Rs.[HL])[:sat]
1005 // Rd=add(Rt.[LH],Rs.[HL])[:sat][:<16]
1006 // Rd=sub(Rt.[LH],Rs.[HL])[:sat][:<16]
1007 //===----------------------------------------------------------------------===//
1009 let hasNewValue = 1, opNewValue = 0 in
1010 class T_XTYPE_ADD_SUB <bits<2> LHbits, bit isSat, bit hasShift, bit isSub>
1011 : ALU64Inst <(outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
1012 "$Rd = "#!if(isSub,"sub","add")#"($Rt."
1013 #!if(hasShift, !if(LHbits{1},"h","l"),"l") #", $Rs."
1014 #!if(hasShift, !if(LHbits{0},"h)","l)"), !if(LHbits{1},"h)","l)"))
1015 #!if(isSat,":sat","")
1016 #!if(hasShift,":<<16",""), [], "", ALU64_tc_1_SLOT23> {
1020 let IClass = 0b1101;
1022 let Inst{27-23} = 0b01010;
1023 let Inst{22} = hasShift;
1024 let Inst{21} = isSub;
1025 let Inst{7} = isSat;
1026 let Inst{6-5} = LHbits;
1028 let Inst{12-8} = Rt;
1029 let Inst{20-16} = Rs;
1032 //Rd=sub(Rt.L,Rs.[LH])
1033 def A2_subh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 1>;
1034 def A2_subh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 1>;
1036 //Rd=add(Rt.L,Rs.[LH])
1037 def A2_addh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 0>;
1038 def A2_addh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 0>;
1040 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF] in {
1041 //Rd=sub(Rt.L,Rs.[LH]):sat
1042 def A2_subh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 1>;
1043 def A2_subh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 1>;
1045 //Rd=add(Rt.L,Rs.[LH]):sat
1046 def A2_addh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 0>;
1047 def A2_addh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 0>;
1050 //Rd=sub(Rt.[LH],Rs.[LH]):<<16
1051 def A2_subh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 1>;
1052 def A2_subh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 1>;
1053 def A2_subh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 1>;
1054 def A2_subh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 1>;
1056 //Rd=add(Rt.[LH],Rs.[LH]):<<16
1057 def A2_addh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 0>;
1058 def A2_addh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 0>;
1059 def A2_addh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 0>;
1060 def A2_addh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 0>;
1062 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF] in {
1063 //Rd=sub(Rt.[LH],Rs.[LH]):sat:<<16
1064 def A2_subh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 1>;
1065 def A2_subh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 1>;
1066 def A2_subh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 1>;
1067 def A2_subh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 1>;
1069 //Rd=add(Rt.[LH],Rs.[LH]):sat:<<16
1070 def A2_addh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 0>;
1071 def A2_addh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 0>;
1072 def A2_addh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 0>;
1073 def A2_addh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 0>;
1077 def: Pat<(sext_inreg (add I32:$src1, I32:$src2), i16),
1078 (A2_addh_l16_ll I32:$src1, I32:$src2)>;
1080 def: Pat<(sra (add (shl I32:$src1, (i32 16)), I32:$src2), (i32 16)),
1081 (A2_addh_l16_hl I32:$src1, I32:$src2)>;
1083 def: Pat<(shl (add I32:$src1, I32:$src2), (i32 16)),
1084 (A2_addh_h16_ll I32:$src1, I32:$src2)>;
1086 // Subtract halfword.
1087 def: Pat<(sext_inreg (sub I32:$src1, I32:$src2), i16),
1088 (A2_subh_l16_ll I32:$src1, I32:$src2)>;
1090 def: Pat<(shl (sub I32:$src1, I32:$src2), (i32 16)),
1091 (A2_subh_h16_ll I32:$src1, I32:$src2)>;
1093 let hasSideEffects = 0, hasNewValue = 1 in
1094 def S2_parityp: ALU64Inst<(outs IntRegs:$Rd),
1095 (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1096 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1101 let IClass = 0b1101;
1102 let Inst{27-24} = 0b0000;
1103 let Inst{20-16} = Rs;
1104 let Inst{12-8} = Rt;
1108 let hasNewValue = 1, opNewValue = 0, hasSideEffects = 0 in
1109 class T_XTYPE_MIN_MAX < bit isMax, bit isUnsigned >
1110 : ALU64Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
1111 "$Rd = "#!if(isMax,"max","min")#!if(isUnsigned,"u","")
1112 #"($Rt, $Rs)", [], "", ALU64_tc_2_SLOT23> {
1117 let IClass = 0b1101;
1119 let Inst{27-23} = 0b01011;
1120 let Inst{22-21} = !if(isMax, 0b10, 0b01);
1121 let Inst{7} = isUnsigned;
1123 let Inst{12-8} = !if(isMax, Rs, Rt);
1124 let Inst{20-16} = !if(isMax, Rt, Rs);
1127 def A2_min : T_XTYPE_MIN_MAX < 0, 0 >;
1128 def A2_minu : T_XTYPE_MIN_MAX < 0, 1 >;
1129 def A2_max : T_XTYPE_MIN_MAX < 1, 0 >;
1130 def A2_maxu : T_XTYPE_MIN_MAX < 1, 1 >;
1132 // Here, depending on the operand being selected, we'll either generate a
1133 // min or max instruction.
1135 // (a>b)?a:b --> max(a,b) => Here check performed is '>' and the value selected
1136 // is the larger of two. So, the corresponding HexagonInst is passed in 'Inst'.
1137 // (a>b)?b:a --> min(a,b) => Here check performed is '>' but the smaller value
1138 // is selected and the corresponding HexagonInst is passed in 'SwapInst'.
1140 multiclass T_MinMax_pats <PatFrag Op, RegisterClass RC, ValueType VT,
1141 InstHexagon Inst, InstHexagon SwapInst> {
1142 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1143 (VT RC:$src1), (VT RC:$src2)),
1144 (Inst RC:$src1, RC:$src2)>;
1145 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1146 (VT RC:$src2), (VT RC:$src1)),
1147 (SwapInst RC:$src1, RC:$src2)>;
1151 multiclass MinMax_pats <PatFrag Op, InstHexagon Inst, InstHexagon SwapInst> {
1152 defm: T_MinMax_pats<Op, IntRegs, i32, Inst, SwapInst>;
1154 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1155 (i32 PositiveHalfWord:$src2))),
1156 (i32 PositiveHalfWord:$src1),
1157 (i32 PositiveHalfWord:$src2))), i16),
1158 (Inst IntRegs:$src1, IntRegs:$src2)>;
1160 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1161 (i32 PositiveHalfWord:$src2))),
1162 (i32 PositiveHalfWord:$src2),
1163 (i32 PositiveHalfWord:$src1))), i16),
1164 (SwapInst IntRegs:$src1, IntRegs:$src2)>;
1167 let AddedComplexity = 200 in {
1168 defm: MinMax_pats<setge, A2_max, A2_min>;
1169 defm: MinMax_pats<setgt, A2_max, A2_min>;
1170 defm: MinMax_pats<setle, A2_min, A2_max>;
1171 defm: MinMax_pats<setlt, A2_min, A2_max>;
1172 defm: MinMax_pats<setuge, A2_maxu, A2_minu>;
1173 defm: MinMax_pats<setugt, A2_maxu, A2_minu>;
1174 defm: MinMax_pats<setule, A2_minu, A2_maxu>;
1175 defm: MinMax_pats<setult, A2_minu, A2_maxu>;
1178 class T_cmp64_rr<string mnemonic, bits<3> MinOp, bit IsComm>
1179 : ALU64_rr<(outs PredRegs:$Pd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1180 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", ALU64_tc_2early_SLOT23> {
1182 let isCommutable = IsComm;
1183 let hasSideEffects = 0;
1189 let IClass = 0b1101;
1190 let Inst{27-21} = 0b0010100;
1191 let Inst{20-16} = Rs;
1192 let Inst{12-8} = Rt;
1193 let Inst{7-5} = MinOp;
1197 def C2_cmpeqp : T_cmp64_rr<"cmp.eq", 0b000, 1>;
1198 def C2_cmpgtp : T_cmp64_rr<"cmp.gt", 0b010, 0>;
1199 def C2_cmpgtup : T_cmp64_rr<"cmp.gtu", 0b100, 0>;
1201 class T_cmp64_rr_pat<InstHexagon MI, PatFrag CmpOp>
1202 : Pat<(i1 (CmpOp (i64 DoubleRegs:$Rs), (i64 DoubleRegs:$Rt))),
1203 (i1 (MI DoubleRegs:$Rs, DoubleRegs:$Rt))>;
1205 def: T_cmp64_rr_pat<C2_cmpeqp, seteq>;
1206 def: T_cmp64_rr_pat<C2_cmpgtp, setgt>;
1207 def: T_cmp64_rr_pat<C2_cmpgtup, setugt>;
1208 def: T_cmp64_rr_pat<C2_cmpgtp, RevCmp<setlt>>;
1209 def: T_cmp64_rr_pat<C2_cmpgtup, RevCmp<setult>>;
1211 def C2_vmux : ALU64_rr<(outs DoubleRegs:$Rd),
1212 (ins PredRegs:$Pu, DoubleRegs:$Rs, DoubleRegs:$Rt),
1213 "$Rd = vmux($Pu, $Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
1214 let hasSideEffects = 0;
1221 let IClass = 0b1101;
1222 let Inst{27-24} = 0b0001;
1223 let Inst{20-16} = Rs;
1224 let Inst{12-8} = Rt;
1229 class T_ALU64_rr<string mnemonic, string suffix, bits<4> RegType,
1230 bits<3> MajOp, bits<3> MinOp, bit OpsRev, bit IsComm,
1232 : ALU64_rr<(outs DoubleRegs:$Rd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1233 "$Rd = " #mnemonic# "($Rs, " #Op2Pfx# "$Rt)" #suffix, [],
1234 "", ALU64_tc_1_SLOT23> {
1235 let hasSideEffects = 0;
1236 let isCommutable = IsComm;
1242 let IClass = 0b1101;
1243 let Inst{27-24} = RegType;
1244 let Inst{23-21} = MajOp;
1245 let Inst{20-16} = !if (OpsRev,Rt,Rs);
1246 let Inst{12-8} = !if (OpsRev,Rs,Rt);
1247 let Inst{7-5} = MinOp;
1251 class T_ALU64_arith<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit IsSat,
1252 bit OpsRev, bit IsComm>
1253 : T_ALU64_rr<mnemonic, !if(IsSat,":sat",""), 0b0011, MajOp, MinOp, OpsRev,
1256 def A2_addp : T_ALU64_arith<"add", 0b000, 0b111, 0, 0, 1>;
1257 def A2_subp : T_ALU64_arith<"sub", 0b001, 0b111, 0, 1, 0>;
1259 def: Pat<(i64 (add I64:$Rs, I64:$Rt)), (A2_addp I64:$Rs, I64:$Rt)>;
1260 def: Pat<(i64 (sub I64:$Rs, I64:$Rt)), (A2_subp I64:$Rs, I64:$Rt)>;
1262 class T_ALU64_logical<string mnemonic, bits<3> MinOp, bit OpsRev, bit IsComm,
1264 : T_ALU64_rr<mnemonic, "", 0b0011, 0b111, MinOp, OpsRev, IsComm,
1267 def A2_andp : T_ALU64_logical<"and", 0b000, 0, 1, 0>;
1268 def A2_orp : T_ALU64_logical<"or", 0b010, 0, 1, 0>;
1269 def A2_xorp : T_ALU64_logical<"xor", 0b100, 0, 1, 0>;
1271 def: Pat<(i64 (and I64:$Rs, I64:$Rt)), (A2_andp I64:$Rs, I64:$Rt)>;
1272 def: Pat<(i64 (or I64:$Rs, I64:$Rt)), (A2_orp I64:$Rs, I64:$Rt)>;
1273 def: Pat<(i64 (xor I64:$Rs, I64:$Rt)), (A2_xorp I64:$Rs, I64:$Rt)>;
1275 //===----------------------------------------------------------------------===//
1277 //===----------------------------------------------------------------------===//
1279 //===----------------------------------------------------------------------===//
1281 //===----------------------------------------------------------------------===//
1283 //===----------------------------------------------------------------------===//
1285 //===----------------------------------------------------------------------===//
1287 //===----------------------------------------------------------------------===//
1289 //===----------------------------------------------------------------------===//
1291 //===----------------------------------------------------------------------===//
1293 //===----------------------------------------------------------------------===//
1295 //===----------------------------------------------------------------------===//
1297 //===----------------------------------------------------------------------===//
1298 // Logical reductions on predicates.
1300 // Looping instructions.
1302 // Pipelined looping instructions.
1304 // Logical operations on predicates.
1305 let hasSideEffects = 0 in
1306 class T_LOGICAL_1OP<string MnOp, bits<2> OpBits>
1307 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps),
1308 "$Pd = " # MnOp # "($Ps)", [], "", CR_tc_2early_SLOT23> {
1312 let IClass = 0b0110;
1313 let Inst{27-23} = 0b10111;
1314 let Inst{22-21} = OpBits;
1316 let Inst{17-16} = Ps;
1321 def C2_any8 : T_LOGICAL_1OP<"any8", 0b00>;
1322 def C2_all8 : T_LOGICAL_1OP<"all8", 0b01>;
1323 def C2_not : T_LOGICAL_1OP<"not", 0b10>;
1325 def: Pat<(i1 (not (i1 PredRegs:$Ps))),
1326 (C2_not PredRegs:$Ps)>;
1328 let hasSideEffects = 0 in
1329 class T_LOGICAL_2OP<string MnOp, bits<3> OpBits, bit IsNeg, bit Rev>
1330 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps, PredRegs:$Pt),
1331 "$Pd = " # MnOp # "($Ps, " # !if (IsNeg,"!","") # "$Pt)",
1332 [], "", CR_tc_2early_SLOT23> {
1337 let IClass = 0b0110;
1338 let Inst{27-24} = 0b1011;
1339 let Inst{23-21} = OpBits;
1341 let Inst{17-16} = !if(Rev,Pt,Ps); // Rs and Rt are reversed for some
1342 let Inst{13} = 0b0; // instructions.
1343 let Inst{9-8} = !if(Rev,Ps,Pt);
1347 def C2_and : T_LOGICAL_2OP<"and", 0b000, 0, 1>;
1348 def C2_or : T_LOGICAL_2OP<"or", 0b001, 0, 1>;
1349 def C2_xor : T_LOGICAL_2OP<"xor", 0b010, 0, 0>;
1350 def C2_andn : T_LOGICAL_2OP<"and", 0b011, 1, 1>;
1351 def C2_orn : T_LOGICAL_2OP<"or", 0b111, 1, 1>;
1353 def: Pat<(i1 (and I1:$Ps, I1:$Pt)), (C2_and I1:$Ps, I1:$Pt)>;
1354 def: Pat<(i1 (or I1:$Ps, I1:$Pt)), (C2_or I1:$Ps, I1:$Pt)>;
1355 def: Pat<(i1 (xor I1:$Ps, I1:$Pt)), (C2_xor I1:$Ps, I1:$Pt)>;
1356 def: Pat<(i1 (and I1:$Ps, (not I1:$Pt))), (C2_andn I1:$Ps, I1:$Pt)>;
1357 def: Pat<(i1 (or I1:$Ps, (not I1:$Pt))), (C2_orn I1:$Ps, I1:$Pt)>;
1359 let hasSideEffects = 0, hasNewValue = 1 in
1360 def C2_vitpack : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps, PredRegs:$Pt),
1361 "$Rd = vitpack($Ps, $Pt)", [], "", S_2op_tc_1_SLOT23> {
1366 let IClass = 0b1000;
1367 let Inst{27-24} = 0b1001;
1368 let Inst{22-21} = 0b00;
1369 let Inst{17-16} = Ps;
1374 let hasSideEffects = 0 in
1375 def C2_mask : SInst<(outs DoubleRegs:$Rd), (ins PredRegs:$Pt),
1376 "$Rd = mask($Pt)", [], "", S_2op_tc_1_SLOT23> {
1380 let IClass = 0b1000;
1381 let Inst{27-24} = 0b0110;
1386 // User control register transfer.
1387 //===----------------------------------------------------------------------===//
1389 //===----------------------------------------------------------------------===//
1391 //===----------------------------------------------------------------------===//
1393 //===----------------------------------------------------------------------===//
1395 def retflag : SDNode<"HexagonISD::RET_FLAG", SDTNone,
1396 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
1397 def eh_return: SDNode<"HexagonISD::EH_RETURN", SDTNone, [SDNPHasChain]>;
1399 def SDHexagonBR_JT: SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
1400 def HexagonBR_JT: SDNode<"HexagonISD::BR_JT", SDHexagonBR_JT, [SDNPHasChain]>;
1402 class CondStr<string CReg, bit True, bit New> {
1403 string S = "if (" # !if(True,"","!") # CReg # !if(New,".new","") # ") ";
1405 class JumpOpcStr<string Mnemonic, bit New, bit Taken> {
1406 string S = Mnemonic # !if(Taken, ":t", !if(New, ":nt", ""));
1409 let isBranch = 1, isBarrier = 1, Defs = [PC], hasSideEffects = 0,
1411 isExtendable = 1, opExtendable = 0, isExtentSigned = 1,
1412 opExtentBits = 24, opExtentAlign = 2, InputType = "imm" in
1413 class T_JMP<string ExtStr>
1414 : JInst<(outs), (ins brtarget:$dst),
1415 "jump " # ExtStr # "$dst",
1416 [], "", J_tc_2early_SLOT23> {
1418 let IClass = 0b0101;
1420 let Inst{27-25} = 0b100;
1421 let Inst{24-16} = dst{23-15};
1422 let Inst{13-1} = dst{14-2};
1425 let isBranch = 1, Defs = [PC], hasSideEffects = 0, isPredicated = 1,
1426 isExtendable = 1, opExtendable = 1, isExtentSigned = 1,
1427 opExtentBits = 17, opExtentAlign = 2, InputType = "imm" in
1428 class T_JMP_c<bit PredNot, bit isPredNew, bit isTak, string ExtStr>
1429 : JInst<(outs), (ins PredRegs:$src, brtarget:$dst),
1430 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1431 JumpOpcStr<"jump", isPredNew, isTak>.S # " " #
1433 [], "", J_tc_2early_SLOT23>, ImmRegRel {
1434 let isTaken = isTak;
1435 let isPredicatedFalse = PredNot;
1436 let isPredicatedNew = isPredNew;
1440 let IClass = 0b0101;
1442 let Inst{27-24} = 0b1100;
1443 let Inst{21} = PredNot;
1444 let Inst{12} = isTak;
1445 let Inst{11} = isPredNew;
1446 let Inst{9-8} = src;
1447 let Inst{23-22} = dst{16-15};
1448 let Inst{20-16} = dst{14-10};
1449 let Inst{13} = dst{9};
1450 let Inst{7-1} = dst{8-2};
1453 multiclass JMP_Pred<bit PredNot, string ExtStr> {
1454 def NAME : T_JMP_c<PredNot, 0, 0, ExtStr>; // not taken
1456 def NAME#newpt : T_JMP_c<PredNot, 1, 1, ExtStr>; // taken
1457 def NAME#new : T_JMP_c<PredNot, 1, 0, ExtStr>; // not taken
1460 multiclass JMP_base<string BaseOp, string ExtStr> {
1461 let BaseOpcode = BaseOp in {
1462 def NAME : T_JMP<ExtStr>;
1463 defm t : JMP_Pred<0, ExtStr>;
1464 defm f : JMP_Pred<1, ExtStr>;
1468 // Jumps to address stored in a register, JUMPR_MISC
1469 // if ([[!]P[.new]]) jumpr[:t/nt] Rs
1470 let isBranch = 1, isIndirectBranch = 1, isBarrier = 1, Defs = [PC],
1471 isPredicable = 1, hasSideEffects = 0, InputType = "reg" in
1473 : JRInst<(outs), (ins IntRegs:$dst),
1474 "jumpr $dst", [], "", J_tc_2early_SLOT2> {
1477 let IClass = 0b0101;
1478 let Inst{27-21} = 0b0010100;
1479 let Inst{20-16} = dst;
1482 let isBranch = 1, isIndirectBranch = 1, Defs = [PC], isPredicated = 1,
1483 hasSideEffects = 0, InputType = "reg" in
1484 class T_JMPr_c <bit PredNot, bit isPredNew, bit isTak>
1485 : JRInst <(outs), (ins PredRegs:$src, IntRegs:$dst),
1486 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1487 JumpOpcStr<"jumpr", isPredNew, isTak>.S # " $dst", [],
1488 "", J_tc_2early_SLOT2> {
1490 let isTaken = isTak;
1491 let isPredicatedFalse = PredNot;
1492 let isPredicatedNew = isPredNew;
1496 let IClass = 0b0101;
1498 let Inst{27-22} = 0b001101;
1499 let Inst{21} = PredNot;
1500 let Inst{20-16} = dst;
1501 let Inst{12} = isTak;
1502 let Inst{11} = isPredNew;
1503 let Inst{9-8} = src;
1506 multiclass JMPR_Pred<bit PredNot> {
1507 def NAME : T_JMPr_c<PredNot, 0, 0>; // not taken
1509 def NAME#newpt : T_JMPr_c<PredNot, 1, 1>; // taken
1510 def NAME#new : T_JMPr_c<PredNot, 1, 0>; // not taken
1513 multiclass JMPR_base<string BaseOp> {
1514 let BaseOpcode = BaseOp in {
1516 defm t : JMPR_Pred<0>;
1517 defm f : JMPR_Pred<1>;
1521 let isCall = 1, hasSideEffects = 1 in
1522 class JUMPR_MISC_CALLR<bit isPred, bit isPredNot,
1523 dag InputDag = (ins IntRegs:$Rs)>
1524 : JRInst<(outs), InputDag,
1525 !if(isPred, !if(isPredNot, "if (!$Pu) callr $Rs",
1526 "if ($Pu) callr $Rs"),
1528 [], "", J_tc_2early_SLOT2> {
1531 let isPredicated = isPred;
1532 let isPredicatedFalse = isPredNot;
1534 let IClass = 0b0101;
1535 let Inst{27-25} = 0b000;
1536 let Inst{24-23} = !if (isPred, 0b10, 0b01);
1538 let Inst{21} = isPredNot;
1539 let Inst{9-8} = !if (isPred, Pu, 0b00);
1540 let Inst{20-16} = Rs;
1544 let Defs = VolatileV3.Regs in {
1545 def J2_callrt : JUMPR_MISC_CALLR<1, 0, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1546 def J2_callrf : JUMPR_MISC_CALLR<1, 1, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1549 let isTerminator = 1, hasSideEffects = 0 in {
1550 defm J2_jump : JMP_base<"JMP", "">, PredNewRel;
1552 // Deal with explicit assembly
1553 // - never extened a jump #, always extend a jump ##
1554 let isAsmParserOnly = 1 in {
1555 defm J2_jump_ext : JMP_base<"JMP", "##">;
1556 defm J2_jump_noext : JMP_base<"JMP", "#">;
1559 defm J2_jumpr : JMPR_base<"JMPr">, PredNewRel;
1561 let isReturn = 1, isCodeGenOnly = 1 in
1562 defm JMPret : JMPR_base<"JMPret">, PredNewRel;
1565 def: Pat<(br bb:$dst),
1566 (J2_jump brtarget:$dst)>;
1568 (JMPret (i32 R31))>;
1569 def: Pat<(brcond (i1 PredRegs:$src1), bb:$offset),
1570 (J2_jumpt PredRegs:$src1, bb:$offset)>;
1572 // A return through builtin_eh_return.
1573 let isReturn = 1, isTerminator = 1, isBarrier = 1, hasSideEffects = 0,
1574 isCodeGenOnly = 1, Defs = [PC], Uses = [R28], isPredicable = 0 in
1575 def EH_RETURN_JMPR : T_JMPr;
1577 def: Pat<(eh_return),
1578 (EH_RETURN_JMPR (i32 R31))>;
1579 def: Pat<(HexagonBR_JT (i32 IntRegs:$dst)),
1580 (J2_jumpr IntRegs:$dst)>;
1581 def: Pat<(brind (i32 IntRegs:$dst)),
1582 (J2_jumpr IntRegs:$dst)>;
1584 //===----------------------------------------------------------------------===//
1586 //===----------------------------------------------------------------------===//
1588 //===----------------------------------------------------------------------===//
1590 //===----------------------------------------------------------------------===//
1592 // Load - Base with Immediate offset addressing mode
1593 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, AddedComplexity = 20 in
1594 class T_load_io <string mnemonic, RegisterClass RC, bits<4> MajOp,
1596 : LDInst<(outs RC:$dst), (ins IntRegs:$src1, ImmOp:$offset),
1597 "$dst = "#mnemonic#"($src1 + #$offset)", []>, AddrModeRel {
1602 bits<11> offsetBits;
1604 string ImmOpStr = !cast<string>(ImmOp);
1605 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), offset{13-3},
1606 !if (!eq(ImmOpStr, "s11_2Ext"), offset{12-2},
1607 !if (!eq(ImmOpStr, "s11_1Ext"), offset{11-1},
1608 /* s11_0Ext */ offset{10-0})));
1609 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
1610 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
1611 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
1612 /* s11_0Ext */ 11)));
1613 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
1615 let IClass = 0b1001;
1618 let Inst{26-25} = offsetBits{10-9};
1619 let Inst{24-21} = MajOp;
1620 let Inst{20-16} = src1;
1621 let Inst{13-5} = offsetBits{8-0};
1622 let Inst{4-0} = dst;
1625 let opExtendable = 3, isExtentSigned = 0, isPredicated = 1 in
1626 class T_pload_io <string mnemonic, RegisterClass RC, bits<4>MajOp,
1627 Operand ImmOp, bit isNot, bit isPredNew>
1628 : LDInst<(outs RC:$dst),
1629 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1630 "if ("#!if(isNot, "!$src1", "$src1")
1631 #!if(isPredNew, ".new", "")
1632 #") $dst = "#mnemonic#"($src2 + #$offset)",
1633 [],"", V2LDST_tc_ld_SLOT01> , AddrModeRel {
1639 string ImmOpStr = !cast<string>(ImmOp);
1641 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), offset{8-3},
1642 !if (!eq(ImmOpStr, "u6_2Ext"), offset{7-2},
1643 !if (!eq(ImmOpStr, "u6_1Ext"), offset{6-1},
1644 /* u6_0Ext */ offset{5-0})));
1645 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
1646 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
1647 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
1649 let hasNewValue = !if (!eq(ImmOpStr, "u6_3Ext"), 0, 1);
1650 let isPredicatedNew = isPredNew;
1651 let isPredicatedFalse = isNot;
1653 let IClass = 0b0100;
1657 let Inst{26} = isNot;
1658 let Inst{25} = isPredNew;
1659 let Inst{24-21} = MajOp;
1660 let Inst{20-16} = src2;
1662 let Inst{12-11} = src1;
1663 let Inst{10-5} = offsetBits;
1664 let Inst{4-0} = dst;
1667 let isExtendable = 1, hasSideEffects = 0, addrMode = BaseImmOffset in
1668 multiclass LD_Idxd<string mnemonic, string CextOp, RegisterClass RC,
1669 Operand ImmOp, Operand predImmOp, bits<4>MajOp> {
1670 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1671 let isPredicable = 1 in
1672 def L2_#NAME#_io : T_load_io <mnemonic, RC, MajOp, ImmOp>;
1675 def L2_p#NAME#t_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 0>;
1676 def L2_p#NAME#f_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 0>;
1679 def L2_p#NAME#tnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 1>;
1680 def L2_p#NAME#fnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 1>;
1684 let accessSize = ByteAccess in {
1685 defm loadrb: LD_Idxd <"memb", "LDrib", IntRegs, s11_0Ext, u6_0Ext, 0b1000>;
1686 defm loadrub: LD_Idxd <"memub", "LDriub", IntRegs, s11_0Ext, u6_0Ext, 0b1001>;
1689 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1690 defm loadrh: LD_Idxd <"memh", "LDrih", IntRegs, s11_1Ext, u6_1Ext, 0b1010>;
1691 defm loadruh: LD_Idxd <"memuh", "LDriuh", IntRegs, s11_1Ext, u6_1Ext, 0b1011>;
1694 let accessSize = WordAccess, opExtentAlign = 2 in
1695 defm loadri: LD_Idxd <"memw", "LDriw", IntRegs, s11_2Ext, u6_2Ext, 0b1100>;
1697 let accessSize = DoubleWordAccess, opExtentAlign = 3 in
1698 defm loadrd: LD_Idxd <"memd", "LDrid", DoubleRegs, s11_3Ext, u6_3Ext, 0b1110>;
1700 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1701 def L2_loadbsw2_io: T_load_io<"membh", IntRegs, 0b0001, s11_1Ext>;
1702 def L2_loadbzw2_io: T_load_io<"memubh", IntRegs, 0b0011, s11_1Ext>;
1705 let accessSize = WordAccess, opExtentAlign = 2 in {
1706 def L2_loadbzw4_io: T_load_io<"memubh", DoubleRegs, 0b0101, s11_2Ext>;
1707 def L2_loadbsw4_io: T_load_io<"membh", DoubleRegs, 0b0111, s11_2Ext>;
1710 let addrMode = BaseImmOffset, isExtendable = 1, hasSideEffects = 0,
1711 opExtendable = 3, isExtentSigned = 1 in
1712 class T_loadalign_io <string str, bits<4> MajOp, Operand ImmOp>
1713 : LDInst<(outs DoubleRegs:$dst),
1714 (ins DoubleRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1715 "$dst = "#str#"($src2 + #$offset)", [],
1716 "$src1 = $dst">, AddrModeRel {
1721 bits<11> offsetBits;
1723 let offsetBits = !if (!eq(!cast<string>(ImmOp), "s11_1Ext"), offset{11-1},
1724 /* s11_0Ext */ offset{10-0});
1725 let IClass = 0b1001;
1728 let Inst{26-25} = offsetBits{10-9};
1729 let Inst{24-21} = MajOp;
1730 let Inst{20-16} = src2;
1731 let Inst{13-5} = offsetBits{8-0};
1732 let Inst{4-0} = dst;
1735 let accessSize = HalfWordAccess, opExtentBits = 12, opExtentAlign = 1 in
1736 def L2_loadalignh_io: T_loadalign_io <"memh_fifo", 0b0010, s11_1Ext>;
1738 let accessSize = ByteAccess, opExtentBits = 11 in
1739 def L2_loadalignb_io: T_loadalign_io <"memb_fifo", 0b0100, s11_0Ext>;
1741 // Patterns to select load-indexed (i.e. load from base+offset).
1742 multiclass Loadx_pat<PatFrag Load, ValueType VT, PatLeaf ImmPred,
1744 def: Pat<(VT (Load AddrFI:$fi)), (VT (MI AddrFI:$fi, 0))>;
1745 def: Pat<(VT (Load (add (i32 IntRegs:$Rs), ImmPred:$Off))),
1746 (VT (MI IntRegs:$Rs, imm:$Off))>;
1747 def: Pat<(VT (Load (i32 IntRegs:$Rs))), (VT (MI IntRegs:$Rs, 0))>;
1750 let AddedComplexity = 20 in {
1751 defm: Loadx_pat<load, i32, s11_2ExtPred, L2_loadri_io>;
1752 defm: Loadx_pat<load, i64, s11_3ExtPred, L2_loadrd_io>;
1753 defm: Loadx_pat<atomic_load_8 , i32, s11_0ExtPred, L2_loadrub_io>;
1754 defm: Loadx_pat<atomic_load_16, i32, s11_1ExtPred, L2_loadruh_io>;
1755 defm: Loadx_pat<atomic_load_32, i32, s11_2ExtPred, L2_loadri_io>;
1756 defm: Loadx_pat<atomic_load_64, i64, s11_3ExtPred, L2_loadrd_io>;
1758 defm: Loadx_pat<extloadi1, i32, s11_0ExtPred, L2_loadrub_io>;
1759 defm: Loadx_pat<extloadi8, i32, s11_0ExtPred, L2_loadrub_io>;
1760 defm: Loadx_pat<extloadi16, i32, s11_1ExtPred, L2_loadruh_io>;
1761 defm: Loadx_pat<sextloadi8, i32, s11_0ExtPred, L2_loadrb_io>;
1762 defm: Loadx_pat<sextloadi16, i32, s11_1ExtPred, L2_loadrh_io>;
1763 defm: Loadx_pat<zextloadi1, i32, s11_0ExtPred, L2_loadrub_io>;
1764 defm: Loadx_pat<zextloadi8, i32, s11_0ExtPred, L2_loadrub_io>;
1765 defm: Loadx_pat<zextloadi16, i32, s11_1ExtPred, L2_loadruh_io>;
1769 // Sign-extending loads of i1 need to replicate the lowest bit throughout
1770 // the 32-bit value. Since the loaded value can only be 0 or 1, 0-v should
1772 let AddedComplexity = 20 in
1773 def: Pat<(i32 (sextloadi1 (i32 IntRegs:$Rs))),
1774 (A2_subri 0, (L2_loadrub_io IntRegs:$Rs, 0))>;
1776 //===----------------------------------------------------------------------===//
1777 // Post increment load
1778 //===----------------------------------------------------------------------===//
1779 //===----------------------------------------------------------------------===//
1780 // Template class for non-predicated post increment loads with immediate offset.
1781 //===----------------------------------------------------------------------===//
1782 let hasSideEffects = 0, addrMode = PostInc in
1783 class T_load_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
1785 : LDInstPI <(outs RC:$dst, IntRegs:$dst2),
1786 (ins IntRegs:$src1, ImmOp:$offset),
1787 "$dst = "#mnemonic#"($src1++#$offset)" ,
1796 string ImmOpStr = !cast<string>(ImmOp);
1797 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1798 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1799 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1800 /* s4_0Imm */ offset{3-0})));
1801 let hasNewValue = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
1803 let IClass = 0b1001;
1805 let Inst{27-25} = 0b101;
1806 let Inst{24-21} = MajOp;
1807 let Inst{20-16} = src1;
1808 let Inst{13-12} = 0b00;
1809 let Inst{8-5} = offsetBits;
1810 let Inst{4-0} = dst;
1813 //===----------------------------------------------------------------------===//
1814 // Template class for predicated post increment loads with immediate offset.
1815 //===----------------------------------------------------------------------===//
1816 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc in
1817 class T_pload_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
1818 bits<4> MajOp, bit isPredNot, bit isPredNew >
1819 : LDInst <(outs RC:$dst, IntRegs:$dst2),
1820 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1821 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1822 ") ")#"$dst = "#mnemonic#"($src2++#$offset)",
1832 let isPredicatedNew = isPredNew;
1833 let isPredicatedFalse = isPredNot;
1835 string ImmOpStr = !cast<string>(ImmOp);
1836 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1837 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1838 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1839 /* s4_0Imm */ offset{3-0})));
1840 let hasNewValue = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
1842 let IClass = 0b1001;
1844 let Inst{27-25} = 0b101;
1845 let Inst{24-21} = MajOp;
1846 let Inst{20-16} = src2;
1848 let Inst{12} = isPredNew;
1849 let Inst{11} = isPredNot;
1850 let Inst{10-9} = src1;
1851 let Inst{8-5} = offsetBits;
1852 let Inst{4-0} = dst;
1855 //===----------------------------------------------------------------------===//
1856 // Multiclass for post increment loads with immediate offset.
1857 //===----------------------------------------------------------------------===//
1859 multiclass LD_PostInc <string mnemonic, string BaseOp, RegisterClass RC,
1860 Operand ImmOp, bits<4> MajOp> {
1861 let BaseOpcode = "POST_"#BaseOp in {
1862 let isPredicable = 1 in
1863 def L2_#NAME#_pi : T_load_pi < mnemonic, RC, ImmOp, MajOp>;
1866 def L2_p#NAME#t_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 0, 0>;
1867 def L2_p#NAME#f_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 1, 0>;
1870 def L2_p#NAME#tnew_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 0, 1>;
1871 def L2_p#NAME#fnew_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 1, 1>;
1875 // post increment byte loads with immediate offset
1876 let accessSize = ByteAccess in {
1877 defm loadrb : LD_PostInc <"memb", "LDrib", IntRegs, s4_0Imm, 0b1000>;
1878 defm loadrub : LD_PostInc <"memub", "LDriub", IntRegs, s4_0Imm, 0b1001>;
1881 // post increment halfword loads with immediate offset
1882 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1883 defm loadrh : LD_PostInc <"memh", "LDrih", IntRegs, s4_1Imm, 0b1010>;
1884 defm loadruh : LD_PostInc <"memuh", "LDriuh", IntRegs, s4_1Imm, 0b1011>;
1887 // post increment word loads with immediate offset
1888 let accessSize = WordAccess, opExtentAlign = 2 in
1889 defm loadri : LD_PostInc <"memw", "LDriw", IntRegs, s4_2Imm, 0b1100>;
1891 // post increment doubleword loads with immediate offset
1892 let accessSize = DoubleWordAccess, opExtentAlign = 3 in
1893 defm loadrd : LD_PostInc <"memd", "LDrid", DoubleRegs, s4_3Imm, 0b1110>;
1895 // Rd=memb[u]h(Rx++#s4:1)
1896 // Rdd=memb[u]h(Rx++#s4:2)
1897 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1898 def L2_loadbsw2_pi : T_load_pi <"membh", IntRegs, s4_1Imm, 0b0001>;
1899 def L2_loadbzw2_pi : T_load_pi <"memubh", IntRegs, s4_1Imm, 0b0011>;
1901 let accessSize = WordAccess, opExtentAlign = 2, hasNewValue = 0 in {
1902 def L2_loadbsw4_pi : T_load_pi <"membh", DoubleRegs, s4_2Imm, 0b0111>;
1903 def L2_loadbzw4_pi : T_load_pi <"memubh", DoubleRegs, s4_2Imm, 0b0101>;
1906 //===----------------------------------------------------------------------===//
1907 // Template class for post increment fifo loads with immediate offset.
1908 //===----------------------------------------------------------------------===//
1909 let hasSideEffects = 0, addrMode = PostInc in
1910 class T_loadalign_pi <string mnemonic, Operand ImmOp, bits<4> MajOp >
1911 : LDInstPI <(outs DoubleRegs:$dst, IntRegs:$dst2),
1912 (ins DoubleRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1913 "$dst = "#mnemonic#"($src2++#$offset)" ,
1914 [], "$src2 = $dst2, $src1 = $dst" > ,
1921 let offsetBits = !if (!eq(!cast<string>(ImmOp), "s4_1Imm"), offset{4-1},
1922 /* s4_0Imm */ offset{3-0});
1923 let IClass = 0b1001;
1925 let Inst{27-25} = 0b101;
1926 let Inst{24-21} = MajOp;
1927 let Inst{20-16} = src2;
1928 let Inst{13-12} = 0b00;
1929 let Inst{8-5} = offsetBits;
1930 let Inst{4-0} = dst;
1933 // Ryy=memh_fifo(Rx++#s4:1)
1934 // Ryy=memb_fifo(Rx++#s4:0)
1935 let accessSize = ByteAccess in
1936 def L2_loadalignb_pi : T_loadalign_pi <"memb_fifo", s4_0Imm, 0b0100>;
1938 let accessSize = HalfWordAccess, opExtentAlign = 1 in
1939 def L2_loadalignh_pi : T_loadalign_pi <"memh_fifo", s4_1Imm, 0b0010>;
1941 //===----------------------------------------------------------------------===//
1942 // Template class for post increment loads with register offset.
1943 //===----------------------------------------------------------------------===//
1944 let hasSideEffects = 0, addrMode = PostInc in
1945 class T_load_pr <string mnemonic, RegisterClass RC, bits<4> MajOp,
1946 MemAccessSize AccessSz>
1947 : LDInstPI <(outs RC:$dst, IntRegs:$_dst_),
1948 (ins IntRegs:$src1, ModRegs:$src2),
1949 "$dst = "#mnemonic#"($src1++$src2)" ,
1950 [], "$src1 = $_dst_" > {
1955 let accessSize = AccessSz;
1956 let IClass = 0b1001;
1958 let Inst{27-25} = 0b110;
1959 let Inst{24-21} = MajOp;
1960 let Inst{20-16} = src1;
1961 let Inst{13} = src2;
1964 let Inst{4-0} = dst;
1967 let hasNewValue = 1 in {
1968 def L2_loadrb_pr : T_load_pr <"memb", IntRegs, 0b1000, ByteAccess>;
1969 def L2_loadrub_pr : T_load_pr <"memub", IntRegs, 0b1001, ByteAccess>;
1970 def L2_loadrh_pr : T_load_pr <"memh", IntRegs, 0b1010, HalfWordAccess>;
1971 def L2_loadruh_pr : T_load_pr <"memuh", IntRegs, 0b1011, HalfWordAccess>;
1972 def L2_loadri_pr : T_load_pr <"memw", IntRegs, 0b1100, WordAccess>;
1974 def L2_loadbzw2_pr : T_load_pr <"memubh", IntRegs, 0b0011, HalfWordAccess>;
1977 def L2_loadrd_pr : T_load_pr <"memd", DoubleRegs, 0b1110, DoubleWordAccess>;
1978 def L2_loadbzw4_pr : T_load_pr <"memubh", DoubleRegs, 0b0101, WordAccess>;
1981 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 13,
1982 isCodeGenOnly = 1, isPseudo = 1, hasSideEffects = 0 in
1983 def LDriw_pred : LDInst<(outs PredRegs:$dst),
1984 (ins IntRegs:$addr, s11_2Ext:$off),
1985 ".error \"should not emit\"", []>;
1987 let Defs = [R29, R30, R31], Uses = [R30], hasSideEffects = 0 in
1988 def L2_deallocframe : LDInst<(outs), (ins),
1991 let IClass = 0b1001;
1993 let Inst{27-16} = 0b000000011110;
1995 let Inst{4-0} = 0b11110;
1998 // Load / Post increment circular addressing mode.
1999 let Uses = [CS], hasSideEffects = 0 in
2000 class T_load_pcr<string mnemonic, RegisterClass RC, bits<4> MajOp>
2001 : LDInst <(outs RC:$dst, IntRegs:$_dst_),
2002 (ins IntRegs:$Rz, ModRegs:$Mu),
2003 "$dst = "#mnemonic#"($Rz ++ I:circ($Mu))", [],
2009 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
2010 let IClass = 0b1001;
2012 let Inst{27-25} = 0b100;
2013 let Inst{24-21} = MajOp;
2014 let Inst{20-16} = Rz;
2019 let Inst{4-0} = dst;
2022 let accessSize = ByteAccess in {
2023 def L2_loadrb_pcr : T_load_pcr <"memb", IntRegs, 0b1000>;
2024 def L2_loadrub_pcr : T_load_pcr <"memub", IntRegs, 0b1001>;
2027 let accessSize = HalfWordAccess in {
2028 def L2_loadrh_pcr : T_load_pcr <"memh", IntRegs, 0b1010>;
2029 def L2_loadruh_pcr : T_load_pcr <"memuh", IntRegs, 0b1011>;
2030 def L2_loadbsw2_pcr : T_load_pcr <"membh", IntRegs, 0b0001>;
2031 def L2_loadbzw2_pcr : T_load_pcr <"memubh", IntRegs, 0b0011>;
2034 let accessSize = WordAccess in {
2035 def L2_loadri_pcr : T_load_pcr <"memw", IntRegs, 0b1100>;
2036 let hasNewValue = 0 in {
2037 def L2_loadbzw4_pcr : T_load_pcr <"memubh", DoubleRegs, 0b0101>;
2038 def L2_loadbsw4_pcr : T_load_pcr <"membh", DoubleRegs, 0b0111>;
2042 let accessSize = DoubleWordAccess in
2043 def L2_loadrd_pcr : T_load_pcr <"memd", DoubleRegs, 0b1110>;
2045 // Load / Post increment circular addressing mode.
2046 let Uses = [CS], hasSideEffects = 0 in
2047 class T_loadalign_pcr<string mnemonic, bits<4> MajOp, MemAccessSize AccessSz >
2048 : LDInst <(outs DoubleRegs:$dst, IntRegs:$_dst_),
2049 (ins DoubleRegs:$_src_, IntRegs:$Rz, ModRegs:$Mu),
2050 "$dst = "#mnemonic#"($Rz ++ I:circ($Mu))", [],
2051 "$Rz = $_dst_, $dst = $_src_" > {
2056 let accessSize = AccessSz;
2057 let IClass = 0b1001;
2059 let Inst{27-25} = 0b100;
2060 let Inst{24-21} = MajOp;
2061 let Inst{20-16} = Rz;
2066 let Inst{4-0} = dst;
2069 def L2_loadalignb_pcr : T_loadalign_pcr <"memb_fifo", 0b0100, ByteAccess>;
2070 def L2_loadalignh_pcr : T_loadalign_pcr <"memh_fifo", 0b0010, HalfWordAccess>;
2072 //===----------------------------------------------------------------------===//
2073 // Circular loads with immediate offset.
2074 //===----------------------------------------------------------------------===//
2075 let Uses = [CS], mayLoad = 1, hasSideEffects = 0 in
2076 class T_load_pci <string mnemonic, RegisterClass RC,
2077 Operand ImmOp, bits<4> MajOp>
2078 : LDInstPI<(outs RC:$dst, IntRegs:$_dst_),
2079 (ins IntRegs:$Rz, ImmOp:$offset, ModRegs:$Mu),
2080 "$dst = "#mnemonic#"($Rz ++ #$offset:circ($Mu))", [],
2088 string ImmOpStr = !cast<string>(ImmOp);
2089 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
2090 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
2091 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
2092 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
2093 /* s4_0Imm */ offset{3-0})));
2094 let IClass = 0b1001;
2095 let Inst{27-25} = 0b100;
2096 let Inst{24-21} = MajOp;
2097 let Inst{20-16} = Rz;
2101 let Inst{8-5} = offsetBits;
2102 let Inst{4-0} = dst;
2105 // Byte variants of circ load
2106 let accessSize = ByteAccess in {
2107 def L2_loadrb_pci : T_load_pci <"memb", IntRegs, s4_0Imm, 0b1000>;
2108 def L2_loadrub_pci : T_load_pci <"memub", IntRegs, s4_0Imm, 0b1001>;
2111 // Half word variants of circ load
2112 let accessSize = HalfWordAccess in {
2113 def L2_loadrh_pci : T_load_pci <"memh", IntRegs, s4_1Imm, 0b1010>;
2114 def L2_loadruh_pci : T_load_pci <"memuh", IntRegs, s4_1Imm, 0b1011>;
2115 def L2_loadbzw2_pci : T_load_pci <"memubh", IntRegs, s4_1Imm, 0b0011>;
2116 def L2_loadbsw2_pci : T_load_pci <"membh", IntRegs, s4_1Imm, 0b0001>;
2119 // Word variants of circ load
2120 let accessSize = WordAccess in
2121 def L2_loadri_pci : T_load_pci <"memw", IntRegs, s4_2Imm, 0b1100>;
2123 let accessSize = WordAccess, hasNewValue = 0 in {
2124 def L2_loadbzw4_pci : T_load_pci <"memubh", DoubleRegs, s4_2Imm, 0b0101>;
2125 def L2_loadbsw4_pci : T_load_pci <"membh", DoubleRegs, s4_2Imm, 0b0111>;
2128 let accessSize = DoubleWordAccess, hasNewValue = 0 in
2129 def L2_loadrd_pci : T_load_pci <"memd", DoubleRegs, s4_3Imm, 0b1110>;
2131 //===----------------------------------------------------------------------===//
2132 // Circular loads - Pseudo
2134 // Please note that the input operand order in the pseudo instructions
2135 // doesn't match with the real instructions. Pseudo instructions operand
2136 // order should mimics the ordering in the intrinsics. Also, 'src2' doesn't
2137 // appear in the AsmString because it's same as 'dst'.
2138 //===----------------------------------------------------------------------===//
2139 let isCodeGenOnly = 1, mayLoad = 1, hasSideEffects = 0, isPseudo = 1 in
2140 class T_load_pci_pseudo <string opc, RegisterClass RC>
2141 : LDInstPI<(outs IntRegs:$_dst_, RC:$dst),
2142 (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3, s4Imm:$src4),
2143 ".error \"$dst = "#opc#"($src1++#$src4:circ($src3))\"",
2144 [], "$src1 = $_dst_">;
2146 def L2_loadrb_pci_pseudo : T_load_pci_pseudo <"memb", IntRegs>;
2147 def L2_loadrub_pci_pseudo : T_load_pci_pseudo <"memub", IntRegs>;
2148 def L2_loadrh_pci_pseudo : T_load_pci_pseudo <"memh", IntRegs>;
2149 def L2_loadruh_pci_pseudo : T_load_pci_pseudo <"memuh", IntRegs>;
2150 def L2_loadri_pci_pseudo : T_load_pci_pseudo <"memw", IntRegs>;
2151 def L2_loadrd_pci_pseudo : T_load_pci_pseudo <"memd", DoubleRegs>;
2154 // TODO: memb_fifo and memh_fifo must take destination register as input.
2155 // One-off circ loads - not enough in common to break into a class.
2156 let accessSize = ByteAccess in
2157 def L2_loadalignb_pci : T_load_pci <"memb_fifo", DoubleRegs, s4_0Imm, 0b0100>;
2159 let accessSize = HalfWordAccess, opExtentAlign = 1 in
2160 def L2_loadalignh_pci : T_load_pci <"memh_fifo", DoubleRegs, s4_1Imm, 0b0010>;
2162 // L[24]_load[wd]_locked: Load word/double with lock.
2164 class T_load_locked <string mnemonic, RegisterClass RC>
2165 : LD0Inst <(outs RC:$dst),
2167 "$dst = "#mnemonic#"($src)"> {
2170 let IClass = 0b1001;
2171 let Inst{27-21} = 0b0010000;
2172 let Inst{20-16} = src;
2173 let Inst{13-12} = !if (!eq(mnemonic, "memd_locked"), 0b01, 0b00);
2175 let Inst{4-0} = dst;
2177 let hasNewValue = 1, accessSize = WordAccess, opNewValue = 0 in
2178 def L2_loadw_locked : T_load_locked <"memw_locked", IntRegs>;
2179 let accessSize = DoubleWordAccess in
2180 def L4_loadd_locked : T_load_locked <"memd_locked", DoubleRegs>;
2182 // S[24]_store[wd]_locked: Store word/double conditionally.
2183 let isSoloAX = 1, isPredicateLate = 1 in
2184 class T_store_locked <string mnemonic, RegisterClass RC>
2185 : ST0Inst <(outs PredRegs:$Pd), (ins IntRegs:$Rs, RC:$Rt),
2186 mnemonic#"($Rs, $Pd) = $Rt"> {
2191 let IClass = 0b1010;
2192 let Inst{27-23} = 0b00001;
2193 let Inst{22} = !if (!eq(mnemonic, "memw_locked"), 0b0, 0b1);
2195 let Inst{20-16} = Rs;
2196 let Inst{12-8} = Rt;
2200 let accessSize = WordAccess in
2201 def S2_storew_locked : T_store_locked <"memw_locked", IntRegs>;
2203 let accessSize = DoubleWordAccess in
2204 def S4_stored_locked : T_store_locked <"memd_locked", DoubleRegs>;
2206 //===----------------------------------------------------------------------===//
2207 // Bit-reversed loads with auto-increment register
2208 //===----------------------------------------------------------------------===//
2209 let hasSideEffects = 0 in
2210 class T_load_pbr<string mnemonic, RegisterClass RC,
2211 MemAccessSize addrSize, bits<4> majOp>
2213 <(outs RC:$dst, IntRegs:$_dst_),
2214 (ins IntRegs:$Rz, ModRegs:$Mu),
2215 "$dst = "#mnemonic#"($Rz ++ $Mu:brev)" ,
2216 [] , "$Rz = $_dst_" > {
2218 let accessSize = addrSize;
2224 let IClass = 0b1001;
2226 let Inst{27-25} = 0b111;
2227 let Inst{24-21} = majOp;
2228 let Inst{20-16} = Rz;
2232 let Inst{4-0} = dst;
2235 let hasNewValue =1, opNewValue = 0 in {
2236 def L2_loadrb_pbr : T_load_pbr <"memb", IntRegs, ByteAccess, 0b1000>;
2237 def L2_loadrub_pbr : T_load_pbr <"memub", IntRegs, ByteAccess, 0b1001>;
2238 def L2_loadrh_pbr : T_load_pbr <"memh", IntRegs, HalfWordAccess, 0b1010>;
2239 def L2_loadruh_pbr : T_load_pbr <"memuh", IntRegs, HalfWordAccess, 0b1011>;
2240 def L2_loadbsw2_pbr : T_load_pbr <"membh", IntRegs, HalfWordAccess, 0b0001>;
2241 def L2_loadbzw2_pbr : T_load_pbr <"memubh", IntRegs, HalfWordAccess, 0b0011>;
2242 def L2_loadri_pbr : T_load_pbr <"memw", IntRegs, WordAccess, 0b1100>;
2245 def L2_loadbzw4_pbr : T_load_pbr <"memubh", DoubleRegs, WordAccess, 0b0101>;
2246 def L2_loadbsw4_pbr : T_load_pbr <"membh", DoubleRegs, WordAccess, 0b0111>;
2247 def L2_loadrd_pbr : T_load_pbr <"memd", DoubleRegs, DoubleWordAccess, 0b1110>;
2249 def L2_loadalignb_pbr :T_load_pbr <"memb_fifo", DoubleRegs, ByteAccess, 0b0100>;
2250 def L2_loadalignh_pbr :T_load_pbr <"memh_fifo", DoubleRegs,
2251 HalfWordAccess, 0b0010>;
2253 //===----------------------------------------------------------------------===//
2254 // Bit-reversed loads - Pseudo
2256 // Please note that 'src2' doesn't appear in the AsmString because
2257 // it's same as 'dst'.
2258 //===----------------------------------------------------------------------===//
2259 let isCodeGenOnly = 1, mayLoad = 1, hasSideEffects = 0, isPseudo = 1 in
2260 class T_load_pbr_pseudo <string opc, RegisterClass RC>
2261 : LDInstPI<(outs IntRegs:$_dst_, RC:$dst),
2262 (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3),
2263 ".error \"$dst = "#opc#"($src1++$src3:brev)\"",
2264 [], "$src1 = $_dst_">;
2266 def L2_loadrb_pbr_pseudo : T_load_pbr_pseudo <"memb", IntRegs>;
2267 def L2_loadrub_pbr_pseudo : T_load_pbr_pseudo <"memub", IntRegs>;
2268 def L2_loadrh_pbr_pseudo : T_load_pbr_pseudo <"memh", IntRegs>;
2269 def L2_loadruh_pbr_pseudo : T_load_pbr_pseudo <"memuh", IntRegs>;
2270 def L2_loadri_pbr_pseudo : T_load_pbr_pseudo <"memw", IntRegs>;
2271 def L2_loadrd_pbr_pseudo : T_load_pbr_pseudo <"memd", DoubleRegs>;
2273 //===----------------------------------------------------------------------===//
2275 //===----------------------------------------------------------------------===//
2277 //===----------------------------------------------------------------------===//
2279 //===----------------------------------------------------------------------===//
2280 //===----------------------------------------------------------------------===//
2282 //===----------------------------------------------------------------------===//
2284 //===----------------------------------------------------------------------===//
2286 //===----------------------------------------------------------------------===//
2287 //===----------------------------------------------------------------------===//
2289 //===----------------------------------------------------------------------===//
2291 //===----------------------------------------------------------------------===//
2293 //===----------------------------------------------------------------------===//
2295 //===----------------------------------------------------------------------===//
2297 // MPYS / Multipy signed/unsigned halfwords
2298 //Rd=mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
2299 //===----------------------------------------------------------------------===//
2301 let hasNewValue = 1, opNewValue = 0 in
2302 class T_M2_mpy < bits<2> LHbits, bit isSat, bit isRnd,
2303 bit hasShift, bit isUnsigned>
2304 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
2305 "$Rd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
2306 #", $Rt."#!if(LHbits{0},"h)","l)")
2307 #!if(hasShift,":<<1","")
2308 #!if(isRnd,":rnd","")
2309 #!if(isSat,":sat",""),
2310 [], "", M_tc_3x_SLOT23 > {
2315 let IClass = 0b1110;
2317 let Inst{27-24} = 0b1100;
2318 let Inst{23} = hasShift;
2319 let Inst{22} = isUnsigned;
2320 let Inst{21} = isRnd;
2321 let Inst{7} = isSat;
2322 let Inst{6-5} = LHbits;
2324 let Inst{20-16} = Rs;
2325 let Inst{12-8} = Rt;
2328 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2329 def M2_mpy_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 0>;
2330 def M2_mpy_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 0>;
2331 def M2_mpy_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 0>;
2332 def M2_mpy_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 0>;
2333 def M2_mpy_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 0>;
2334 def M2_mpy_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 0>;
2335 def M2_mpy_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 0>;
2336 def M2_mpy_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 0>;
2338 //Rd=mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2339 def M2_mpyu_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 1>;
2340 def M2_mpyu_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 1>;
2341 def M2_mpyu_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 1>;
2342 def M2_mpyu_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 1>;
2343 def M2_mpyu_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 1>;
2344 def M2_mpyu_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 1>;
2345 def M2_mpyu_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 1>;
2346 def M2_mpyu_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 1>;
2348 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]:rnd
2349 def M2_mpy_rnd_ll_s1: T_M2_mpy <0b00, 0, 1, 1, 0>;
2350 def M2_mpy_rnd_ll_s0: T_M2_mpy <0b00, 0, 1, 0, 0>;
2351 def M2_mpy_rnd_lh_s1: T_M2_mpy <0b01, 0, 1, 1, 0>;
2352 def M2_mpy_rnd_lh_s0: T_M2_mpy <0b01, 0, 1, 0, 0>;
2353 def M2_mpy_rnd_hl_s1: T_M2_mpy <0b10, 0, 1, 1, 0>;
2354 def M2_mpy_rnd_hl_s0: T_M2_mpy <0b10, 0, 1, 0, 0>;
2355 def M2_mpy_rnd_hh_s1: T_M2_mpy <0b11, 0, 1, 1, 0>;
2356 def M2_mpy_rnd_hh_s0: T_M2_mpy <0b11, 0, 1, 0, 0>;
2358 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2359 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
2360 let Defs = [USR_OVF] in {
2361 def M2_mpy_sat_ll_s1: T_M2_mpy <0b00, 1, 0, 1, 0>;
2362 def M2_mpy_sat_ll_s0: T_M2_mpy <0b00, 1, 0, 0, 0>;
2363 def M2_mpy_sat_lh_s1: T_M2_mpy <0b01, 1, 0, 1, 0>;
2364 def M2_mpy_sat_lh_s0: T_M2_mpy <0b01, 1, 0, 0, 0>;
2365 def M2_mpy_sat_hl_s1: T_M2_mpy <0b10, 1, 0, 1, 0>;
2366 def M2_mpy_sat_hl_s0: T_M2_mpy <0b10, 1, 0, 0, 0>;
2367 def M2_mpy_sat_hh_s1: T_M2_mpy <0b11, 1, 0, 1, 0>;
2368 def M2_mpy_sat_hh_s0: T_M2_mpy <0b11, 1, 0, 0, 0>;
2370 def M2_mpy_sat_rnd_ll_s1: T_M2_mpy <0b00, 1, 1, 1, 0>;
2371 def M2_mpy_sat_rnd_ll_s0: T_M2_mpy <0b00, 1, 1, 0, 0>;
2372 def M2_mpy_sat_rnd_lh_s1: T_M2_mpy <0b01, 1, 1, 1, 0>;
2373 def M2_mpy_sat_rnd_lh_s0: T_M2_mpy <0b01, 1, 1, 0, 0>;
2374 def M2_mpy_sat_rnd_hl_s1: T_M2_mpy <0b10, 1, 1, 1, 0>;
2375 def M2_mpy_sat_rnd_hl_s0: T_M2_mpy <0b10, 1, 1, 0, 0>;
2376 def M2_mpy_sat_rnd_hh_s1: T_M2_mpy <0b11, 1, 1, 1, 0>;
2377 def M2_mpy_sat_rnd_hh_s0: T_M2_mpy <0b11, 1, 1, 0, 0>;
2380 //===----------------------------------------------------------------------===//
2382 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
2383 // result from the accumulator.
2384 //Rx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2385 //===----------------------------------------------------------------------===//
2387 let hasNewValue = 1, opNewValue = 0 in
2388 class T_M2_mpy_acc < bits<2> LHbits, bit isSat, bit isNac,
2389 bit hasShift, bit isUnsigned >
2390 : MInst_acc<(outs IntRegs:$Rx), (ins IntRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2391 "$Rx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
2392 #"($Rs."#!if(LHbits{1},"h","l")
2393 #", $Rt."#!if(LHbits{0},"h)","l)")
2394 #!if(hasShift,":<<1","")
2395 #!if(isSat,":sat",""),
2396 [], "$dst2 = $Rx", M_tc_3x_SLOT23 > {
2401 let IClass = 0b1110;
2402 let Inst{27-24} = 0b1110;
2403 let Inst{23} = hasShift;
2404 let Inst{22} = isUnsigned;
2405 let Inst{21} = isNac;
2406 let Inst{7} = isSat;
2407 let Inst{6-5} = LHbits;
2409 let Inst{20-16} = Rs;
2410 let Inst{12-8} = Rt;
2413 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2414 def M2_mpy_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 0>;
2415 def M2_mpy_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 0>;
2416 def M2_mpy_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 0>;
2417 def M2_mpy_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 0>;
2418 def M2_mpy_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 0>;
2419 def M2_mpy_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 0>;
2420 def M2_mpy_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 0>;
2421 def M2_mpy_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 0>;
2423 //Rx += mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2424 def M2_mpyu_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 1>;
2425 def M2_mpyu_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 1>;
2426 def M2_mpyu_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 1>;
2427 def M2_mpyu_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 1>;
2428 def M2_mpyu_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 1>;
2429 def M2_mpyu_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 1>;
2430 def M2_mpyu_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 1>;
2431 def M2_mpyu_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 1>;
2433 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2434 def M2_mpy_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 0>;
2435 def M2_mpy_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 0>;
2436 def M2_mpy_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 0>;
2437 def M2_mpy_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 0>;
2438 def M2_mpy_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 0>;
2439 def M2_mpy_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 0>;
2440 def M2_mpy_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 0>;
2441 def M2_mpy_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 0>;
2443 //Rx -= mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2444 def M2_mpyu_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 1>;
2445 def M2_mpyu_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 1>;
2446 def M2_mpyu_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 1>;
2447 def M2_mpyu_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 1>;
2448 def M2_mpyu_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 1>;
2449 def M2_mpyu_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 1>;
2450 def M2_mpyu_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 1>;
2451 def M2_mpyu_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 1>;
2453 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
2454 def M2_mpy_acc_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 0, 1, 0>;
2455 def M2_mpy_acc_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 0, 0, 0>;
2456 def M2_mpy_acc_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 0, 1, 0>;
2457 def M2_mpy_acc_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 0, 0, 0>;
2458 def M2_mpy_acc_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 0, 1, 0>;
2459 def M2_mpy_acc_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 0, 0, 0>;
2460 def M2_mpy_acc_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 0, 1, 0>;
2461 def M2_mpy_acc_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 0, 0, 0>;
2463 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
2464 def M2_mpy_nac_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 1, 1, 0>;
2465 def M2_mpy_nac_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 1, 0, 0>;
2466 def M2_mpy_nac_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 1, 1, 0>;
2467 def M2_mpy_nac_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 1, 0, 0>;
2468 def M2_mpy_nac_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 1, 1, 0>;
2469 def M2_mpy_nac_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 1, 0, 0>;
2470 def M2_mpy_nac_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 1, 1, 0>;
2471 def M2_mpy_nac_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 1, 0, 0>;
2473 //===----------------------------------------------------------------------===//
2475 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
2476 // result from the 64-bit destination register.
2477 //Rxx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2478 //===----------------------------------------------------------------------===//
2480 class T_M2_mpyd_acc < bits<2> LHbits, bit isNac, bit hasShift, bit isUnsigned>
2481 : MInst_acc<(outs DoubleRegs:$Rxx),
2482 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2483 "$Rxx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
2484 #"($Rs."#!if(LHbits{1},"h","l")
2485 #", $Rt."#!if(LHbits{0},"h)","l)")
2486 #!if(hasShift,":<<1",""),
2487 [], "$dst2 = $Rxx", M_tc_3x_SLOT23 > {
2492 let IClass = 0b1110;
2494 let Inst{27-24} = 0b0110;
2495 let Inst{23} = hasShift;
2496 let Inst{22} = isUnsigned;
2497 let Inst{21} = isNac;
2499 let Inst{6-5} = LHbits;
2500 let Inst{4-0} = Rxx;
2501 let Inst{20-16} = Rs;
2502 let Inst{12-8} = Rt;
2505 def M2_mpyd_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 0>;
2506 def M2_mpyd_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 0>;
2507 def M2_mpyd_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 0>;
2508 def M2_mpyd_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 0>;
2510 def M2_mpyd_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 0>;
2511 def M2_mpyd_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 0>;
2512 def M2_mpyd_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 0>;
2513 def M2_mpyd_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 0>;
2515 def M2_mpyd_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 0>;
2516 def M2_mpyd_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 0>;
2517 def M2_mpyd_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 0>;
2518 def M2_mpyd_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 0>;
2520 def M2_mpyd_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 0>;
2521 def M2_mpyd_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 0>;
2522 def M2_mpyd_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 0>;
2523 def M2_mpyd_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 0>;
2525 def M2_mpyud_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 1>;
2526 def M2_mpyud_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 1>;
2527 def M2_mpyud_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 1>;
2528 def M2_mpyud_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 1>;
2530 def M2_mpyud_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 1>;
2531 def M2_mpyud_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 1>;
2532 def M2_mpyud_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 1>;
2533 def M2_mpyud_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 1>;
2535 def M2_mpyud_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 1>;
2536 def M2_mpyud_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 1>;
2537 def M2_mpyud_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 1>;
2538 def M2_mpyud_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 1>;
2540 def M2_mpyud_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 1>;
2541 def M2_mpyud_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 1>;
2542 def M2_mpyud_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 1>;
2543 def M2_mpyud_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 1>;
2545 //===----------------------------------------------------------------------===//
2546 // Template Class -- Vector Multipy
2547 // Used for complex multiply real or imaginary, dual multiply and even halfwords
2548 //===----------------------------------------------------------------------===//
2549 class T_M2_vmpy < string opc, bits<3> MajOp, bits<3> MinOp, bit hasShift,
2550 bit isRnd, bit isSat >
2551 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2552 "$Rdd = "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2553 #!if(isRnd,":rnd","")
2554 #!if(isSat,":sat",""),
2560 let IClass = 0b1110;
2562 let Inst{27-24} = 0b1000;
2563 let Inst{23-21} = MajOp;
2564 let Inst{7-5} = MinOp;
2565 let Inst{4-0} = Rdd;
2566 let Inst{20-16} = Rss;
2567 let Inst{12-8} = Rtt;
2570 // Vector complex multiply imaginary: Rdd=vcmpyi(Rss,Rtt)[:<<1]:sat
2571 let Defs = [USR_OVF] in {
2572 def M2_vcmpy_s1_sat_i: T_M2_vmpy <"vcmpyi", 0b110, 0b110, 1, 0, 1>;
2573 def M2_vcmpy_s0_sat_i: T_M2_vmpy <"vcmpyi", 0b010, 0b110, 0, 0, 1>;
2575 // Vector complex multiply real: Rdd=vcmpyr(Rss,Rtt)[:<<1]:sat
2576 def M2_vcmpy_s1_sat_r: T_M2_vmpy <"vcmpyr", 0b101, 0b110, 1, 0, 1>;
2577 def M2_vcmpy_s0_sat_r: T_M2_vmpy <"vcmpyr", 0b001, 0b110, 0, 0, 1>;
2579 // Vector dual multiply: Rdd=vdmpy(Rss,Rtt)[:<<1]:sat
2580 def M2_vdmpys_s1: T_M2_vmpy <"vdmpy", 0b100, 0b100, 1, 0, 1>;
2581 def M2_vdmpys_s0: T_M2_vmpy <"vdmpy", 0b000, 0b100, 0, 0, 1>;
2583 // Vector multiply even halfwords: Rdd=vmpyeh(Rss,Rtt)[:<<1]:sat
2584 def M2_vmpy2es_s1: T_M2_vmpy <"vmpyeh", 0b100, 0b110, 1, 0, 1>;
2585 def M2_vmpy2es_s0: T_M2_vmpy <"vmpyeh", 0b000, 0b110, 0, 0, 1>;
2587 //Rdd=vmpywoh(Rss,Rtt)[:<<1][:rnd]:sat
2588 def M2_mmpyh_s0: T_M2_vmpy <"vmpywoh", 0b000, 0b111, 0, 0, 1>;
2589 def M2_mmpyh_s1: T_M2_vmpy <"vmpywoh", 0b100, 0b111, 1, 0, 1>;
2590 def M2_mmpyh_rs0: T_M2_vmpy <"vmpywoh", 0b001, 0b111, 0, 1, 1>;
2591 def M2_mmpyh_rs1: T_M2_vmpy <"vmpywoh", 0b101, 0b111, 1, 1, 1>;
2593 //Rdd=vmpyweh(Rss,Rtt)[:<<1][:rnd]:sat
2594 def M2_mmpyl_s0: T_M2_vmpy <"vmpyweh", 0b000, 0b101, 0, 0, 1>;
2595 def M2_mmpyl_s1: T_M2_vmpy <"vmpyweh", 0b100, 0b101, 1, 0, 1>;
2596 def M2_mmpyl_rs0: T_M2_vmpy <"vmpyweh", 0b001, 0b101, 0, 1, 1>;
2597 def M2_mmpyl_rs1: T_M2_vmpy <"vmpyweh", 0b101, 0b101, 1, 1, 1>;
2599 //Rdd=vmpywouh(Rss,Rtt)[:<<1][:rnd]:sat
2600 def M2_mmpyuh_s0: T_M2_vmpy <"vmpywouh", 0b010, 0b111, 0, 0, 1>;
2601 def M2_mmpyuh_s1: T_M2_vmpy <"vmpywouh", 0b110, 0b111, 1, 0, 1>;
2602 def M2_mmpyuh_rs0: T_M2_vmpy <"vmpywouh", 0b011, 0b111, 0, 1, 1>;
2603 def M2_mmpyuh_rs1: T_M2_vmpy <"vmpywouh", 0b111, 0b111, 1, 1, 1>;
2605 //Rdd=vmpyweuh(Rss,Rtt)[:<<1][:rnd]:sat
2606 def M2_mmpyul_s0: T_M2_vmpy <"vmpyweuh", 0b010, 0b101, 0, 0, 1>;
2607 def M2_mmpyul_s1: T_M2_vmpy <"vmpyweuh", 0b110, 0b101, 1, 0, 1>;
2608 def M2_mmpyul_rs0: T_M2_vmpy <"vmpyweuh", 0b011, 0b101, 0, 1, 1>;
2609 def M2_mmpyul_rs1: T_M2_vmpy <"vmpyweuh", 0b111, 0b101, 1, 1, 1>;
2612 let hasNewValue = 1, opNewValue = 0 in
2613 class T_MType_mpy <string mnemonic, bits<4> RegTyBits, RegisterClass RC,
2614 bits<3> MajOp, bits<3> MinOp, bit isSat = 0, bit isRnd = 0,
2615 string op2Suffix = "", bit isRaw = 0, bit isHi = 0 >
2616 : MInst <(outs IntRegs:$dst), (ins RC:$src1, RC:$src2),
2618 #"($src1, $src2"#op2Suffix#")"
2619 #!if(MajOp{2}, ":<<1", "")
2620 #!if(isRnd, ":rnd", "")
2621 #!if(isSat, ":sat", "")
2622 #!if(isRaw, !if(isHi, ":raw:hi", ":raw:lo"), ""), [] > {
2627 let IClass = 0b1110;
2629 let Inst{27-24} = RegTyBits;
2630 let Inst{23-21} = MajOp;
2631 let Inst{20-16} = src1;
2633 let Inst{12-8} = src2;
2634 let Inst{7-5} = MinOp;
2635 let Inst{4-0} = dst;
2638 class T_MType_vrcmpy <string mnemonic, bits<3> MajOp, bits<3> MinOp, bit isHi>
2639 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, 1, 1, "", 1, isHi>;
2641 class T_MType_dd <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2642 bit isSat = 0, bit isRnd = 0 >
2643 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, isSat, isRnd>;
2645 class T_MType_rr1 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2646 bit isSat = 0, bit isRnd = 0 >
2647 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd>;
2649 class T_MType_rr2 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2650 bit isSat = 0, bit isRnd = 0, string op2str = "" >
2651 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd, op2str>;
2653 def M2_vradduh : T_MType_dd <"vradduh", 0b000, 0b001, 0, 0>;
2654 def M2_vdmpyrs_s0 : T_MType_dd <"vdmpy", 0b000, 0b000, 1, 1>;
2655 def M2_vdmpyrs_s1 : T_MType_dd <"vdmpy", 0b100, 0b000, 1, 1>;
2657 let CextOpcode = "mpyi", InputType = "reg" in
2658 def M2_mpyi : T_MType_rr1 <"mpyi", 0b000, 0b000>, ImmRegRel;
2660 def M2_mpy_up : T_MType_rr1 <"mpy", 0b000, 0b001>;
2661 def M2_mpyu_up : T_MType_rr1 <"mpyu", 0b010, 0b001>;
2663 def M2_dpmpyss_rnd_s0 : T_MType_rr1 <"mpy", 0b001, 0b001, 0, 1>;
2665 def M2_vmpy2s_s0pack : T_MType_rr1 <"vmpyh", 0b001, 0b111, 1, 1>;
2666 def M2_vmpy2s_s1pack : T_MType_rr1 <"vmpyh", 0b101, 0b111, 1, 1>;
2668 def M2_hmmpyh_rs1 : T_MType_rr2 <"mpy", 0b101, 0b100, 1, 1, ".h">;
2669 def M2_hmmpyl_rs1 : T_MType_rr2 <"mpy", 0b111, 0b100, 1, 1, ".l">;
2671 def M2_cmpyrs_s0 : T_MType_rr2 <"cmpy", 0b001, 0b110, 1, 1>;
2672 def M2_cmpyrs_s1 : T_MType_rr2 <"cmpy", 0b101, 0b110, 1, 1>;
2673 def M2_cmpyrsc_s0 : T_MType_rr2 <"cmpy", 0b011, 0b110, 1, 1, "*">;
2674 def M2_cmpyrsc_s1 : T_MType_rr2 <"cmpy", 0b111, 0b110, 1, 1, "*">;
2677 def M2_vraddh : T_MType_dd <"vraddh", 0b001, 0b111, 0>;
2678 def M2_mpysu_up : T_MType_rr1 <"mpysu", 0b011, 0b001, 0>;
2679 def M2_mpy_up_s1 : T_MType_rr1 <"mpy", 0b101, 0b010, 0>;
2680 def M2_mpy_up_s1_sat : T_MType_rr1 <"mpy", 0b111, 0b000, 1>;
2682 def M2_hmmpyh_s1 : T_MType_rr2 <"mpy", 0b101, 0b000, 1, 0, ".h">;
2683 def M2_hmmpyl_s1 : T_MType_rr2 <"mpy", 0b101, 0b001, 1, 0, ".l">;
2685 def: Pat<(i32 (mul I32:$src1, I32:$src2)), (M2_mpyi I32:$src1, I32:$src2)>;
2686 def: Pat<(i32 (mulhs I32:$src1, I32:$src2)), (M2_mpy_up I32:$src1, I32:$src2)>;
2687 def: Pat<(i32 (mulhu I32:$src1, I32:$src2)), (M2_mpyu_up I32:$src1, I32:$src2)>;
2689 let hasNewValue = 1, opNewValue = 0 in
2690 class T_MType_mpy_ri <bit isNeg, Operand ImmOp, list<dag> pattern>
2691 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, ImmOp:$u8),
2692 "$Rd ="#!if(isNeg, "- ", "+ ")#"mpyi($Rs, #$u8)" ,
2693 pattern, "", M_tc_3x_SLOT23> {
2698 let IClass = 0b1110;
2700 let Inst{27-24} = 0b0000;
2701 let Inst{23} = isNeg;
2704 let Inst{20-16} = Rs;
2705 let Inst{12-5} = u8;
2708 let isExtendable = 1, opExtentBits = 8, opExtendable = 2 in
2709 def M2_mpysip : T_MType_mpy_ri <0, u8Ext,
2710 [(set (i32 IntRegs:$Rd), (mul IntRegs:$Rs, u8ExtPred:$u8))]>;
2712 def M2_mpysin : T_MType_mpy_ri <1, u8Imm,
2713 [(set (i32 IntRegs:$Rd), (ineg (mul IntRegs:$Rs,
2716 // Assember mapped to M2_mpyi
2717 let isAsmParserOnly = 1 in
2718 def M2_mpyui : MInst<(outs IntRegs:$dst),
2719 (ins IntRegs:$src1, IntRegs:$src2),
2720 "$dst = mpyui($src1, $src2)">;
2723 // s9 is NOT the same as m9 - but it works.. so far.
2724 // Assembler maps to either Rd=+mpyi(Rs,#u8) or Rd=-mpyi(Rs,#u8)
2725 // depending on the value of m9. See Arch Spec.
2726 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 9,
2727 CextOpcode = "mpyi", InputType = "imm", hasNewValue = 1,
2728 isAsmParserOnly = 1 in
2729 def M2_mpysmi : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, s9Ext:$src2),
2730 "$dst = mpyi($src1, #$src2)",
2731 [(set (i32 IntRegs:$dst), (mul (i32 IntRegs:$src1),
2732 s9ExtPred:$src2))]>, ImmRegRel;
2734 let hasNewValue = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 3,
2735 InputType = "imm" in
2736 class T_MType_acc_ri <string mnemonic, bits<3> MajOp, Operand ImmOp,
2737 list<dag> pattern = []>
2738 : MInst < (outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, ImmOp:$src3),
2739 "$dst "#mnemonic#"($src2, #$src3)",
2740 pattern, "$src1 = $dst", M_tc_2_SLOT23> {
2745 let IClass = 0b1110;
2747 let Inst{27-26} = 0b00;
2748 let Inst{25-23} = MajOp;
2749 let Inst{20-16} = src2;
2751 let Inst{12-5} = src3;
2752 let Inst{4-0} = dst;
2755 let InputType = "reg", hasNewValue = 1 in
2756 class T_MType_acc_rr <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2757 bit isSwap = 0, list<dag> pattern = [], bit hasNot = 0,
2758 bit isSat = 0, bit isShift = 0>
2759 : MInst < (outs IntRegs:$dst),
2760 (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3),
2761 "$dst "#mnemonic#"($src2, "#!if(hasNot, "~$src3)","$src3)")
2762 #!if(isShift, ":<<1", "")
2763 #!if(isSat, ":sat", ""),
2764 pattern, "$src1 = $dst", M_tc_2_SLOT23 > {
2769 let IClass = 0b1110;
2771 let Inst{27-24} = 0b1111;
2772 let Inst{23-21} = MajOp;
2773 let Inst{20-16} = !if(isSwap, src3, src2);
2775 let Inst{12-8} = !if(isSwap, src2, src3);
2776 let Inst{7-5} = MinOp;
2777 let Inst{4-0} = dst;
2780 let CextOpcode = "MPYI_acc", Itinerary = M_tc_3x_SLOT23 in {
2781 def M2_macsip : T_MType_acc_ri <"+= mpyi", 0b010, u8Ext,
2782 [(set (i32 IntRegs:$dst),
2783 (add (mul IntRegs:$src2, u8ExtPred:$src3),
2784 IntRegs:$src1))]>, ImmRegRel;
2786 def M2_maci : T_MType_acc_rr <"+= mpyi", 0b000, 0b000, 0,
2787 [(set (i32 IntRegs:$dst),
2788 (add (mul IntRegs:$src2, IntRegs:$src3),
2789 IntRegs:$src1))]>, ImmRegRel;
2792 let CextOpcode = "ADD_acc" in {
2793 let isExtentSigned = 1 in
2794 def M2_accii : T_MType_acc_ri <"+= add", 0b100, s8Ext,
2795 [(set (i32 IntRegs:$dst),
2796 (add (add (i32 IntRegs:$src2), s8_16ExtPred:$src3),
2797 (i32 IntRegs:$src1)))]>, ImmRegRel;
2799 def M2_acci : T_MType_acc_rr <"+= add", 0b000, 0b001, 0,
2800 [(set (i32 IntRegs:$dst),
2801 (add (add (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2802 (i32 IntRegs:$src1)))]>, ImmRegRel;
2805 let CextOpcode = "SUB_acc" in {
2806 let isExtentSigned = 1 in
2807 def M2_naccii : T_MType_acc_ri <"-= add", 0b101, s8Ext>, ImmRegRel;
2809 def M2_nacci : T_MType_acc_rr <"-= add", 0b100, 0b001, 0>, ImmRegRel;
2812 let Itinerary = M_tc_3x_SLOT23 in
2813 def M2_macsin : T_MType_acc_ri <"-= mpyi", 0b011, u8Ext>;
2815 def M2_xor_xacc : T_MType_acc_rr < "^= xor", 0b100, 0b011, 0>;
2816 def M2_subacc : T_MType_acc_rr <"+= sub", 0b000, 0b011, 1>;
2818 class T_MType_acc_pat1 <InstHexagon MI, SDNode firstOp, SDNode secOp,
2820 : Pat <(secOp IntRegs:$src1, (firstOp IntRegs:$src2, ImmPred:$src3)),
2821 (MI IntRegs:$src1, IntRegs:$src2, ImmPred:$src3)>;
2823 class T_MType_acc_pat2 <InstHexagon MI, SDNode firstOp, SDNode secOp>
2824 : Pat <(i32 (secOp IntRegs:$src1, (firstOp IntRegs:$src2, IntRegs:$src3))),
2825 (MI IntRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2827 def : T_MType_acc_pat2 <M2_xor_xacc, xor, xor>;
2828 def : T_MType_acc_pat1 <M2_macsin, mul, sub, u8ExtPred>;
2830 def : T_MType_acc_pat1 <M2_naccii, add, sub, s8_16ExtPred>;
2831 def : T_MType_acc_pat2 <M2_nacci, add, sub>;
2833 //===----------------------------------------------------------------------===//
2834 // Template Class -- XType Vector Instructions
2835 //===----------------------------------------------------------------------===//
2836 class T_XTYPE_Vect < string opc, bits<3> MajOp, bits<3> MinOp, bit isConj >
2837 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2838 "$Rdd = "#opc#"($Rss, $Rtt"#!if(isConj,"*)",")"),
2844 let IClass = 0b1110;
2846 let Inst{27-24} = 0b1000;
2847 let Inst{23-21} = MajOp;
2848 let Inst{7-5} = MinOp;
2849 let Inst{4-0} = Rdd;
2850 let Inst{20-16} = Rss;
2851 let Inst{12-8} = Rtt;
2854 class T_XTYPE_Vect_acc < string opc, bits<3> MajOp, bits<3> MinOp, bit isConj >
2855 : MInst <(outs DoubleRegs:$Rdd),
2856 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2857 "$Rdd += "#opc#"($Rss, $Rtt"#!if(isConj,"*)",")"),
2858 [], "$dst2 = $Rdd",M_tc_3x_SLOT23 > {
2863 let IClass = 0b1110;
2865 let Inst{27-24} = 0b1010;
2866 let Inst{23-21} = MajOp;
2867 let Inst{7-5} = MinOp;
2868 let Inst{4-0} = Rdd;
2869 let Inst{20-16} = Rss;
2870 let Inst{12-8} = Rtt;
2873 class T_XTYPE_Vect_diff < bits<3> MajOp, string opc >
2874 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rtt, DoubleRegs:$Rss),
2875 "$Rdd = "#opc#"($Rtt, $Rss)",
2876 [], "",M_tc_2_SLOT23 > {
2881 let IClass = 0b1110;
2883 let Inst{27-24} = 0b1000;
2884 let Inst{23-21} = MajOp;
2885 let Inst{7-5} = 0b000;
2886 let Inst{4-0} = Rdd;
2887 let Inst{20-16} = Rss;
2888 let Inst{12-8} = Rtt;
2891 // Vector reduce add unsigned bytes: Rdd32=vrmpybu(Rss32,Rtt32)
2892 def A2_vraddub: T_XTYPE_Vect <"vraddub", 0b010, 0b001, 0>;
2893 def A2_vraddub_acc: T_XTYPE_Vect_acc <"vraddub", 0b010, 0b001, 0>;
2895 // Vector sum of absolute differences unsigned bytes: Rdd=vrsadub(Rss,Rtt)
2896 def A2_vrsadub: T_XTYPE_Vect <"vrsadub", 0b010, 0b010, 0>;
2897 def A2_vrsadub_acc: T_XTYPE_Vect_acc <"vrsadub", 0b010, 0b010, 0>;
2899 // Vector absolute difference: Rdd=vabsdiffh(Rtt,Rss)
2900 def M2_vabsdiffh: T_XTYPE_Vect_diff<0b011, "vabsdiffh">;
2902 // Vector absolute difference words: Rdd=vabsdiffw(Rtt,Rss)
2903 def M2_vabsdiffw: T_XTYPE_Vect_diff<0b001, "vabsdiffw">;
2905 // Vector reduce complex multiply real or imaginary:
2906 // Rdd[+]=vrcmpy[ir](Rss,Rtt[*])
2907 def M2_vrcmpyi_s0: T_XTYPE_Vect <"vrcmpyi", 0b000, 0b000, 0>;
2908 def M2_vrcmpyi_s0c: T_XTYPE_Vect <"vrcmpyi", 0b010, 0b000, 1>;
2909 def M2_vrcmaci_s0: T_XTYPE_Vect_acc <"vrcmpyi", 0b000, 0b000, 0>;
2910 def M2_vrcmaci_s0c: T_XTYPE_Vect_acc <"vrcmpyi", 0b010, 0b000, 1>;
2912 def M2_vrcmpyr_s0: T_XTYPE_Vect <"vrcmpyr", 0b000, 0b001, 0>;
2913 def M2_vrcmpyr_s0c: T_XTYPE_Vect <"vrcmpyr", 0b011, 0b001, 1>;
2914 def M2_vrcmacr_s0: T_XTYPE_Vect_acc <"vrcmpyr", 0b000, 0b001, 0>;
2915 def M2_vrcmacr_s0c: T_XTYPE_Vect_acc <"vrcmpyr", 0b011, 0b001, 1>;
2917 // Vector reduce halfwords:
2918 // Rdd[+]=vrmpyh(Rss,Rtt)
2919 def M2_vrmpy_s0: T_XTYPE_Vect <"vrmpyh", 0b000, 0b010, 0>;
2920 def M2_vrmac_s0: T_XTYPE_Vect_acc <"vrmpyh", 0b000, 0b010, 0>;
2922 //===----------------------------------------------------------------------===//
2923 // Template Class -- Vector Multipy with accumulation.
2924 // Used for complex multiply real or imaginary, dual multiply and even halfwords
2925 //===----------------------------------------------------------------------===//
2926 let Defs = [USR_OVF] in
2927 class T_M2_vmpy_acc_sat < string opc, bits<3> MajOp, bits<3> MinOp,
2928 bit hasShift, bit isRnd >
2929 : MInst <(outs DoubleRegs:$Rxx),
2930 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2931 "$Rxx += "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2932 #!if(isRnd,":rnd","")#":sat",
2933 [], "$dst2 = $Rxx",M_tc_3x_SLOT23 > {
2938 let IClass = 0b1110;
2940 let Inst{27-24} = 0b1010;
2941 let Inst{23-21} = MajOp;
2942 let Inst{7-5} = MinOp;
2943 let Inst{4-0} = Rxx;
2944 let Inst{20-16} = Rss;
2945 let Inst{12-8} = Rtt;
2948 class T_M2_vmpy_acc < string opc, bits<3> MajOp, bits<3> MinOp,
2949 bit hasShift, bit isRnd >
2950 : MInst <(outs DoubleRegs:$Rxx),
2951 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2952 "$Rxx += "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2953 #!if(isRnd,":rnd",""),
2954 [], "$dst2 = $Rxx",M_tc_3x_SLOT23 > {
2959 let IClass = 0b1110;
2961 let Inst{27-24} = 0b1010;
2962 let Inst{23-21} = MajOp;
2963 let Inst{7-5} = MinOp;
2964 let Inst{4-0} = Rxx;
2965 let Inst{20-16} = Rss;
2966 let Inst{12-8} = Rtt;
2969 // Vector multiply word by signed half with accumulation
2970 // Rxx+=vmpyw[eo]h(Rss,Rtt)[:<<1][:rnd]:sat
2971 def M2_mmacls_s1: T_M2_vmpy_acc_sat <"vmpyweh", 0b100, 0b101, 1, 0>;
2972 def M2_mmacls_s0: T_M2_vmpy_acc_sat <"vmpyweh", 0b000, 0b101, 0, 0>;
2973 def M2_mmacls_rs1: T_M2_vmpy_acc_sat <"vmpyweh", 0b101, 0b101, 1, 1>;
2974 def M2_mmacls_rs0: T_M2_vmpy_acc_sat <"vmpyweh", 0b001, 0b101, 0, 1>;
2976 def M2_mmachs_s1: T_M2_vmpy_acc_sat <"vmpywoh", 0b100, 0b111, 1, 0>;
2977 def M2_mmachs_s0: T_M2_vmpy_acc_sat <"vmpywoh", 0b000, 0b111, 0, 0>;
2978 def M2_mmachs_rs1: T_M2_vmpy_acc_sat <"vmpywoh", 0b101, 0b111, 1, 1>;
2979 def M2_mmachs_rs0: T_M2_vmpy_acc_sat <"vmpywoh", 0b001, 0b111, 0, 1>;
2981 // Vector multiply word by unsigned half with accumulation
2982 // Rxx+=vmpyw[eo]uh(Rss,Rtt)[:<<1][:rnd]:sat
2983 def M2_mmaculs_s1: T_M2_vmpy_acc_sat <"vmpyweuh", 0b110, 0b101, 1, 0>;
2984 def M2_mmaculs_s0: T_M2_vmpy_acc_sat <"vmpyweuh", 0b010, 0b101, 0, 0>;
2985 def M2_mmaculs_rs1: T_M2_vmpy_acc_sat <"vmpyweuh", 0b111, 0b101, 1, 1>;
2986 def M2_mmaculs_rs0: T_M2_vmpy_acc_sat <"vmpyweuh", 0b011, 0b101, 0, 1>;
2988 def M2_mmacuhs_s1: T_M2_vmpy_acc_sat <"vmpywouh", 0b110, 0b111, 1, 0>;
2989 def M2_mmacuhs_s0: T_M2_vmpy_acc_sat <"vmpywouh", 0b010, 0b111, 0, 0>;
2990 def M2_mmacuhs_rs1: T_M2_vmpy_acc_sat <"vmpywouh", 0b111, 0b111, 1, 1>;
2991 def M2_mmacuhs_rs0: T_M2_vmpy_acc_sat <"vmpywouh", 0b011, 0b111, 0, 1>;
2993 // Vector multiply even halfwords with accumulation
2994 // Rxx+=vmpyeh(Rss,Rtt)[:<<1][:sat]
2995 def M2_vmac2es: T_M2_vmpy_acc <"vmpyeh", 0b001, 0b010, 0, 0>;
2996 def M2_vmac2es_s1: T_M2_vmpy_acc_sat <"vmpyeh", 0b100, 0b110, 1, 0>;
2997 def M2_vmac2es_s0: T_M2_vmpy_acc_sat <"vmpyeh", 0b000, 0b110, 0, 0>;
2999 // Vector dual multiply with accumulation
3000 // Rxx+=vdmpy(Rss,Rtt)[:sat]
3001 def M2_vdmacs_s1: T_M2_vmpy_acc_sat <"vdmpy", 0b100, 0b100, 1, 0>;
3002 def M2_vdmacs_s0: T_M2_vmpy_acc_sat <"vdmpy", 0b000, 0b100, 0, 0>;
3004 // Vector complex multiply real or imaginary with accumulation
3005 // Rxx+=vcmpy[ir](Rss,Rtt):sat
3006 def M2_vcmac_s0_sat_r: T_M2_vmpy_acc_sat <"vcmpyr", 0b001, 0b100, 0, 0>;
3007 def M2_vcmac_s0_sat_i: T_M2_vmpy_acc_sat <"vcmpyi", 0b010, 0b100, 0, 0>;
3009 //===----------------------------------------------------------------------===//
3010 // Template Class -- Multiply signed/unsigned halfwords with and without
3011 // saturation and rounding
3012 //===----------------------------------------------------------------------===//
3013 class T_M2_mpyd < bits<2> LHbits, bit isRnd, bit hasShift, bit isUnsigned >
3014 : MInst < (outs DoubleRegs:$Rdd), (ins IntRegs:$Rs, IntRegs:$Rt),
3015 "$Rdd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
3016 #", $Rt."#!if(LHbits{0},"h)","l)")
3017 #!if(hasShift,":<<1","")
3018 #!if(isRnd,":rnd",""),
3024 let IClass = 0b1110;
3026 let Inst{27-24} = 0b0100;
3027 let Inst{23} = hasShift;
3028 let Inst{22} = isUnsigned;
3029 let Inst{21} = isRnd;
3030 let Inst{6-5} = LHbits;
3031 let Inst{4-0} = Rdd;
3032 let Inst{20-16} = Rs;
3033 let Inst{12-8} = Rt;
3036 def M2_mpyd_hh_s0: T_M2_mpyd<0b11, 0, 0, 0>;
3037 def M2_mpyd_hl_s0: T_M2_mpyd<0b10, 0, 0, 0>;
3038 def M2_mpyd_lh_s0: T_M2_mpyd<0b01, 0, 0, 0>;
3039 def M2_mpyd_ll_s0: T_M2_mpyd<0b00, 0, 0, 0>;
3041 def M2_mpyd_hh_s1: T_M2_mpyd<0b11, 0, 1, 0>;
3042 def M2_mpyd_hl_s1: T_M2_mpyd<0b10, 0, 1, 0>;
3043 def M2_mpyd_lh_s1: T_M2_mpyd<0b01, 0, 1, 0>;
3044 def M2_mpyd_ll_s1: T_M2_mpyd<0b00, 0, 1, 0>;
3046 def M2_mpyd_rnd_hh_s0: T_M2_mpyd<0b11, 1, 0, 0>;
3047 def M2_mpyd_rnd_hl_s0: T_M2_mpyd<0b10, 1, 0, 0>;
3048 def M2_mpyd_rnd_lh_s0: T_M2_mpyd<0b01, 1, 0, 0>;
3049 def M2_mpyd_rnd_ll_s0: T_M2_mpyd<0b00, 1, 0, 0>;
3051 def M2_mpyd_rnd_hh_s1: T_M2_mpyd<0b11, 1, 1, 0>;
3052 def M2_mpyd_rnd_hl_s1: T_M2_mpyd<0b10, 1, 1, 0>;
3053 def M2_mpyd_rnd_lh_s1: T_M2_mpyd<0b01, 1, 1, 0>;
3054 def M2_mpyd_rnd_ll_s1: T_M2_mpyd<0b00, 1, 1, 0>;
3056 //Rdd=mpyu(Rs.[HL],Rt.[HL])[:<<1]
3057 def M2_mpyud_hh_s0: T_M2_mpyd<0b11, 0, 0, 1>;
3058 def M2_mpyud_hl_s0: T_M2_mpyd<0b10, 0, 0, 1>;
3059 def M2_mpyud_lh_s0: T_M2_mpyd<0b01, 0, 0, 1>;
3060 def M2_mpyud_ll_s0: T_M2_mpyd<0b00, 0, 0, 1>;
3062 def M2_mpyud_hh_s1: T_M2_mpyd<0b11, 0, 1, 1>;
3063 def M2_mpyud_hl_s1: T_M2_mpyd<0b10, 0, 1, 1>;
3064 def M2_mpyud_lh_s1: T_M2_mpyd<0b01, 0, 1, 1>;
3065 def M2_mpyud_ll_s1: T_M2_mpyd<0b00, 0, 1, 1>;
3067 //===----------------------------------------------------------------------===//
3068 // Template Class for xtype mpy:
3071 // multiply 32X32 and use full result
3072 //===----------------------------------------------------------------------===//
3073 let hasSideEffects = 0 in
3074 class T_XTYPE_mpy64 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
3075 bit isSat, bit hasShift, bit isConj>
3076 : MInst <(outs DoubleRegs:$Rdd),
3077 (ins IntRegs:$Rs, IntRegs:$Rt),
3078 "$Rdd = "#mnemonic#"($Rs, $Rt"#!if(isConj,"*)",")")
3079 #!if(hasShift,":<<1","")
3080 #!if(isSat,":sat",""),
3086 let IClass = 0b1110;
3088 let Inst{27-24} = 0b0101;
3089 let Inst{23-21} = MajOp;
3090 let Inst{20-16} = Rs;
3091 let Inst{12-8} = Rt;
3092 let Inst{7-5} = MinOp;
3093 let Inst{4-0} = Rdd;
3096 //===----------------------------------------------------------------------===//
3097 // Template Class for xtype mpy with accumulation into 64-bit:
3100 // multiply 32X32 and use full result
3101 //===----------------------------------------------------------------------===//
3102 class T_XTYPE_mpy64_acc <string op1, string op2, bits<3> MajOp, bits<3> MinOp,
3103 bit isSat, bit hasShift, bit isConj>
3104 : MInst <(outs DoubleRegs:$Rxx),
3105 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
3106 "$Rxx "#op2#"= "#op1#"($Rs, $Rt"#!if(isConj,"*)",")")
3107 #!if(hasShift,":<<1","")
3108 #!if(isSat,":sat",""),
3110 [] , "$dst2 = $Rxx" > {
3115 let IClass = 0b1110;
3117 let Inst{27-24} = 0b0111;
3118 let Inst{23-21} = MajOp;
3119 let Inst{20-16} = Rs;
3120 let Inst{12-8} = Rt;
3121 let Inst{7-5} = MinOp;
3122 let Inst{4-0} = Rxx;
3125 // MPY - Multiply and use full result
3126 // Rdd = mpy[u](Rs,Rt)
3127 def M2_dpmpyss_s0 : T_XTYPE_mpy64 < "mpy", 0b000, 0b000, 0, 0, 0>;
3128 def M2_dpmpyuu_s0 : T_XTYPE_mpy64 < "mpyu", 0b010, 0b000, 0, 0, 0>;
3130 // Rxx[+-]= mpy[u](Rs,Rt)
3131 def M2_dpmpyss_acc_s0 : T_XTYPE_mpy64_acc < "mpy", "+", 0b000, 0b000, 0, 0, 0>;
3132 def M2_dpmpyss_nac_s0 : T_XTYPE_mpy64_acc < "mpy", "-", 0b001, 0b000, 0, 0, 0>;
3133 def M2_dpmpyuu_acc_s0 : T_XTYPE_mpy64_acc < "mpyu", "+", 0b010, 0b000, 0, 0, 0>;
3134 def M2_dpmpyuu_nac_s0 : T_XTYPE_mpy64_acc < "mpyu", "-", 0b011, 0b000, 0, 0, 0>;
3136 // Complex multiply real or imaginary
3137 // Rxx=cmpy[ir](Rs,Rt)
3138 def M2_cmpyi_s0 : T_XTYPE_mpy64 < "cmpyi", 0b000, 0b001, 0, 0, 0>;
3139 def M2_cmpyr_s0 : T_XTYPE_mpy64 < "cmpyr", 0b000, 0b010, 0, 0, 0>;
3141 // Rxx+=cmpy[ir](Rs,Rt)
3142 def M2_cmaci_s0 : T_XTYPE_mpy64_acc < "cmpyi", "+", 0b000, 0b001, 0, 0, 0>;
3143 def M2_cmacr_s0 : T_XTYPE_mpy64_acc < "cmpyr", "+", 0b000, 0b010, 0, 0, 0>;
3146 // Rdd=cmpy(Rs,Rt)[:<<]:sat
3147 def M2_cmpys_s0 : T_XTYPE_mpy64 < "cmpy", 0b000, 0b110, 1, 0, 0>;
3148 def M2_cmpys_s1 : T_XTYPE_mpy64 < "cmpy", 0b100, 0b110, 1, 1, 0>;
3150 // Rdd=cmpy(Rs,Rt*)[:<<]:sat
3151 def M2_cmpysc_s0 : T_XTYPE_mpy64 < "cmpy", 0b010, 0b110, 1, 0, 1>;
3152 def M2_cmpysc_s1 : T_XTYPE_mpy64 < "cmpy", 0b110, 0b110, 1, 1, 1>;
3154 // Rxx[-+]=cmpy(Rs,Rt)[:<<1]:sat
3155 def M2_cmacs_s0 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b000, 0b110, 1, 0, 0>;
3156 def M2_cnacs_s0 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b000, 0b111, 1, 0, 0>;
3157 def M2_cmacs_s1 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b100, 0b110, 1, 1, 0>;
3158 def M2_cnacs_s1 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b100, 0b111, 1, 1, 0>;
3160 // Rxx[-+]=cmpy(Rs,Rt*)[:<<1]:sat
3161 def M2_cmacsc_s0 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b010, 0b110, 1, 0, 1>;
3162 def M2_cnacsc_s0 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b010, 0b111, 1, 0, 1>;
3163 def M2_cmacsc_s1 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b110, 0b110, 1, 1, 1>;
3164 def M2_cnacsc_s1 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b110, 0b111, 1, 1, 1>;
3166 // Vector multiply halfwords
3167 // Rdd=vmpyh(Rs,Rt)[:<<]:sat
3168 //let Defs = [USR_OVF] in {
3169 def M2_vmpy2s_s1 : T_XTYPE_mpy64 < "vmpyh", 0b100, 0b101, 1, 1, 0>;
3170 def M2_vmpy2s_s0 : T_XTYPE_mpy64 < "vmpyh", 0b000, 0b101, 1, 0, 0>;
3173 // Rxx+=vmpyh(Rs,Rt)[:<<1][:sat]
3174 def M2_vmac2 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b001, 0b001, 0, 0, 0>;
3175 def M2_vmac2s_s1 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b100, 0b101, 1, 1, 0>;
3176 def M2_vmac2s_s0 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b000, 0b101, 1, 0, 0>;
3178 def: Pat<(i64 (mul (i64 (anyext (i32 IntRegs:$src1))),
3179 (i64 (anyext (i32 IntRegs:$src2))))),
3180 (M2_dpmpyuu_s0 IntRegs:$src1, IntRegs:$src2)>;
3182 def: Pat<(i64 (mul (i64 (sext (i32 IntRegs:$src1))),
3183 (i64 (sext (i32 IntRegs:$src2))))),
3184 (M2_dpmpyss_s0 IntRegs:$src1, IntRegs:$src2)>;
3186 def: Pat<(i64 (mul (is_sext_i32:$src1),
3187 (is_sext_i32:$src2))),
3188 (M2_dpmpyss_s0 (LoReg DoubleRegs:$src1), (LoReg DoubleRegs:$src2))>;
3190 // Multiply and accumulate, use full result.
3191 // Rxx[+-]=mpy(Rs,Rt)
3193 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3194 (mul (i64 (sext (i32 IntRegs:$src2))),
3195 (i64 (sext (i32 IntRegs:$src3)))))),
3196 (M2_dpmpyss_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3198 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3199 (mul (i64 (sext (i32 IntRegs:$src2))),
3200 (i64 (sext (i32 IntRegs:$src3)))))),
3201 (M2_dpmpyss_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3203 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3204 (mul (i64 (anyext (i32 IntRegs:$src2))),
3205 (i64 (anyext (i32 IntRegs:$src3)))))),
3206 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3208 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3209 (mul (i64 (zext (i32 IntRegs:$src2))),
3210 (i64 (zext (i32 IntRegs:$src3)))))),
3211 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3213 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3214 (mul (i64 (anyext (i32 IntRegs:$src2))),
3215 (i64 (anyext (i32 IntRegs:$src3)))))),
3216 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3218 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3219 (mul (i64 (zext (i32 IntRegs:$src2))),
3220 (i64 (zext (i32 IntRegs:$src3)))))),
3221 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3223 //===----------------------------------------------------------------------===//
3225 //===----------------------------------------------------------------------===//
3227 //===----------------------------------------------------------------------===//
3229 //===----------------------------------------------------------------------===//
3230 //===----------------------------------------------------------------------===//
3232 //===----------------------------------------------------------------------===//
3234 //===----------------------------------------------------------------------===//
3236 //===----------------------------------------------------------------------===//
3237 //===----------------------------------------------------------------------===//
3239 //===----------------------------------------------------------------------===//
3241 //===----------------------------------------------------------------------===//
3243 //===----------------------------------------------------------------------===//
3244 //===----------------------------------------------------------------------===//
3246 //===----------------------------------------------------------------------===//
3248 //===----------------------------------------------------------------------===//
3250 //===----------------------------------------------------------------------===//
3252 // Store doubleword.
3253 //===----------------------------------------------------------------------===//
3254 // Template class for non-predicated post increment stores with immediate offset
3255 //===----------------------------------------------------------------------===//
3256 let isPredicable = 1, hasSideEffects = 0, addrMode = PostInc in
3257 class T_store_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
3258 bits<4> MajOp, bit isHalf >
3259 : STInst <(outs IntRegs:$_dst_),
3260 (ins IntRegs:$src1, ImmOp:$offset, RC:$src2),
3261 mnemonic#"($src1++#$offset) = $src2"#!if(isHalf, ".h", ""),
3262 [], "$src1 = $_dst_" >,
3269 string ImmOpStr = !cast<string>(ImmOp);
3270 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
3271 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
3272 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
3273 /* s4_0Imm */ offset{3-0})));
3274 let isNVStorable = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
3276 let IClass = 0b1010;
3278 let Inst{27-25} = 0b101;
3279 let Inst{24-21} = MajOp;
3280 let Inst{20-16} = src1;
3282 let Inst{12-8} = src2;
3284 let Inst{6-3} = offsetBits;
3288 //===----------------------------------------------------------------------===//
3289 // Template class for predicated post increment stores with immediate offset
3290 //===----------------------------------------------------------------------===//
3291 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc in
3292 class T_pstore_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
3293 bits<4> MajOp, bit isHalf, bit isPredNot, bit isPredNew >
3294 : STInst <(outs IntRegs:$_dst_),
3295 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset, RC:$src3),
3296 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3297 ") ")#mnemonic#"($src2++#$offset) = $src3"#!if(isHalf, ".h", ""),
3298 [], "$src2 = $_dst_" >,
3306 string ImmOpStr = !cast<string>(ImmOp);
3307 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
3308 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
3309 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
3310 /* s4_0Imm */ offset{3-0})));
3312 let isNVStorable = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
3313 let isPredicatedNew = isPredNew;
3314 let isPredicatedFalse = isPredNot;
3316 let IClass = 0b1010;
3318 let Inst{27-25} = 0b101;
3319 let Inst{24-21} = MajOp;
3320 let Inst{20-16} = src2;
3322 let Inst{12-8} = src3;
3323 let Inst{7} = isPredNew;
3324 let Inst{6-3} = offsetBits;
3325 let Inst{2} = isPredNot;
3326 let Inst{1-0} = src1;
3329 multiclass ST_PostInc<string mnemonic, string BaseOp, RegisterClass RC,
3330 Operand ImmOp, bits<4> MajOp, bit isHalf = 0 > {
3332 let BaseOpcode = "POST_"#BaseOp in {
3333 def S2_#NAME#_pi : T_store_pi <mnemonic, RC, ImmOp, MajOp, isHalf>;
3336 def S2_p#NAME#t_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp, isHalf, 0, 0>;
3337 def S2_p#NAME#f_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp, isHalf, 1, 0>;
3340 def S2_p#NAME#tnew_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp,
3342 def S2_p#NAME#fnew_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp,
3347 let accessSize = ByteAccess in
3348 defm storerb: ST_PostInc <"memb", "STrib", IntRegs, s4_0Imm, 0b1000>;
3350 let accessSize = HalfWordAccess in
3351 defm storerh: ST_PostInc <"memh", "STrih", IntRegs, s4_1Imm, 0b1010>;
3353 let accessSize = WordAccess in
3354 defm storeri: ST_PostInc <"memw", "STriw", IntRegs, s4_2Imm, 0b1100>;
3356 let accessSize = DoubleWordAccess in
3357 defm storerd: ST_PostInc <"memd", "STrid", DoubleRegs, s4_3Imm, 0b1110>;
3359 let accessSize = HalfWordAccess, isNVStorable = 0 in
3360 defm storerf: ST_PostInc <"memh", "STrih_H", IntRegs, s4_1Imm, 0b1011, 1>;
3362 class Storepi_pat<PatFrag Store, PatFrag Value, PatFrag Offset,
3364 : Pat<(Store Value:$src1, I32:$src2, Offset:$offset),
3365 (MI I32:$src2, imm:$offset, Value:$src1)>;
3367 def: Storepi_pat<post_truncsti8, I32, s4_0ImmPred, S2_storerb_pi>;
3368 def: Storepi_pat<post_truncsti16, I32, s4_1ImmPred, S2_storerh_pi>;
3369 def: Storepi_pat<post_store, I32, s4_2ImmPred, S2_storeri_pi>;
3370 def: Storepi_pat<post_store, I64, s4_3ImmPred, S2_storerd_pi>;
3372 //===----------------------------------------------------------------------===//
3373 // Template class for post increment stores with register offset.
3374 //===----------------------------------------------------------------------===//
3375 let isNVStorable = 1 in
3376 class T_store_pr <string mnemonic, RegisterClass RC, bits<3> MajOp,
3377 MemAccessSize AccessSz, bit isHalf = 0>
3378 : STInst <(outs IntRegs:$_dst_),
3379 (ins IntRegs:$src1, ModRegs:$src2, RC:$src3),
3380 mnemonic#"($src1++$src2) = $src3"#!if(isHalf, ".h", ""),
3381 [], "$src1 = $_dst_" > {
3385 let accessSize = AccessSz;
3387 let IClass = 0b1010;
3389 let Inst{27-24} = 0b1101;
3390 let Inst{23-21} = MajOp;
3391 let Inst{20-16} = src1;
3392 let Inst{13} = src2;
3393 let Inst{12-8} = src3;
3397 def S2_storerb_pr : T_store_pr<"memb", IntRegs, 0b000, ByteAccess>;
3398 def S2_storerh_pr : T_store_pr<"memh", IntRegs, 0b010, HalfWordAccess>;
3399 def S2_storeri_pr : T_store_pr<"memw", IntRegs, 0b100, WordAccess>;
3400 def S2_storerd_pr : T_store_pr<"memd", DoubleRegs, 0b110, DoubleWordAccess>;
3402 def S2_storerf_pr : T_store_pr<"memh", IntRegs, 0b011, HalfWordAccess, 1>;
3404 let opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
3405 class T_store_io <string mnemonic, RegisterClass RC, Operand ImmOp,
3406 bits<3>MajOp, bit isH = 0>
3408 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
3409 mnemonic#"($src1+#$src2) = $src3"#!if(isH,".h","")>,
3410 AddrModeRel, ImmRegRel {
3412 bits<14> src2; // Actual address offset
3414 bits<11> offsetBits; // Represents offset encoding
3416 string ImmOpStr = !cast<string>(ImmOp);
3418 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
3419 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
3420 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
3421 /* s11_0Ext */ 11)));
3422 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), src2{13-3},
3423 !if (!eq(ImmOpStr, "s11_2Ext"), src2{12-2},
3424 !if (!eq(ImmOpStr, "s11_1Ext"), src2{11-1},
3425 /* s11_0Ext */ src2{10-0})));
3426 let IClass = 0b1010;
3429 let Inst{26-25} = offsetBits{10-9};
3431 let Inst{23-21} = MajOp;
3432 let Inst{20-16} = src1;
3433 let Inst{13} = offsetBits{8};
3434 let Inst{12-8} = src3;
3435 let Inst{7-0} = offsetBits{7-0};
3438 let opExtendable = 2, isPredicated = 1 in
3439 class T_pstore_io <string mnemonic, RegisterClass RC, Operand ImmOp,
3440 bits<3>MajOp, bit PredNot, bit isPredNew, bit isH = 0>
3442 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$src3, RC:$src4),
3443 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3444 ") ")#mnemonic#"($src2+#$src3) = $src4"#!if(isH,".h",""),
3445 [],"",V2LDST_tc_st_SLOT01 >,
3446 AddrModeRel, ImmRegRel {
3449 bits<9> src3; // Actual address offset
3451 bits<6> offsetBits; // Represents offset encoding
3453 let isPredicatedNew = isPredNew;
3454 let isPredicatedFalse = PredNot;
3456 string ImmOpStr = !cast<string>(ImmOp);
3457 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
3458 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
3459 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
3461 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), src3{8-3},
3462 !if (!eq(ImmOpStr, "u6_2Ext"), src3{7-2},
3463 !if (!eq(ImmOpStr, "u6_1Ext"), src3{6-1},
3464 /* u6_0Ext */ src3{5-0})));
3465 let IClass = 0b0100;
3468 let Inst{26} = PredNot;
3469 let Inst{25} = isPredNew;
3471 let Inst{23-21} = MajOp;
3472 let Inst{20-16} = src2;
3473 let Inst{13} = offsetBits{5};
3474 let Inst{12-8} = src4;
3475 let Inst{7-3} = offsetBits{4-0};
3476 let Inst{1-0} = src1;
3479 let isExtendable = 1, isNVStorable = 1, hasSideEffects = 0 in
3480 multiclass ST_Idxd<string mnemonic, string CextOp, RegisterClass RC,
3481 Operand ImmOp, Operand predImmOp, bits<3> MajOp, bit isH = 0> {
3482 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
3483 def S2_#NAME#_io : T_store_io <mnemonic, RC, ImmOp, MajOp, isH>;
3486 def S2_p#NAME#t_io : T_pstore_io<mnemonic, RC, predImmOp, MajOp, 0, 0, isH>;
3487 def S2_p#NAME#f_io : T_pstore_io<mnemonic, RC, predImmOp, MajOp, 1, 0, isH>;
3490 def S4_p#NAME#tnew_io : T_pstore_io <mnemonic, RC, predImmOp,
3492 def S4_p#NAME#fnew_io : T_pstore_io <mnemonic, RC, predImmOp,
3497 let addrMode = BaseImmOffset, InputType = "imm" in {
3498 let accessSize = ByteAccess in
3499 defm storerb: ST_Idxd < "memb", "STrib", IntRegs, s11_0Ext, u6_0Ext, 0b000>;
3501 let accessSize = HalfWordAccess, opExtentAlign = 1 in
3502 defm storerh: ST_Idxd < "memh", "STrih", IntRegs, s11_1Ext, u6_1Ext, 0b010>;
3504 let accessSize = WordAccess, opExtentAlign = 2 in
3505 defm storeri: ST_Idxd < "memw", "STriw", IntRegs, s11_2Ext, u6_2Ext, 0b100>;
3507 let accessSize = DoubleWordAccess, isNVStorable = 0, opExtentAlign = 3 in
3508 defm storerd: ST_Idxd < "memd", "STrid", DoubleRegs, s11_3Ext,
3511 let accessSize = HalfWordAccess, opExtentAlign = 1 in
3512 defm storerf: ST_Idxd < "memh", "STrif", IntRegs, s11_1Ext,
3516 // Patterns for generating stores, where the address takes different forms:
3519 // - simple (base address without offset).
3520 // These would usually be used together (via Storex_pat defined below), but
3521 // in some cases one may want to apply different properties (such as
3522 // AddedComplexity) to the individual patterns.
3523 class Storex_fi_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
3524 : Pat<(Store Value:$Rs, AddrFI:$fi), (MI AddrFI:$fi, 0, Value:$Rs)>;
3525 class Storex_add_pat<PatFrag Store, PatFrag Value, PatFrag ImmPred,
3527 : Pat<(Store Value:$Rt, (add (i32 IntRegs:$Rs), ImmPred:$Off)),
3528 (MI IntRegs:$Rs, imm:$Off, Value:$Rt)>;
3529 class Storex_simple_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
3530 : Pat<(Store Value:$Rt, (i32 IntRegs:$Rs)),
3531 (MI IntRegs:$Rs, 0, Value:$Rt)>;
3533 // Patterns for generating stores, where the address takes different forms,
3534 // and where the value being stored is transformed through the value modifier
3535 // ValueMod. The address forms are same as above.
3536 class Storexm_fi_pat<PatFrag Store, PatFrag Value, PatFrag ValueMod,
3538 : Pat<(Store Value:$Rs, AddrFI:$fi),
3539 (MI AddrFI:$fi, 0, (ValueMod Value:$Rs))>;
3540 class Storexm_add_pat<PatFrag Store, PatFrag Value, PatFrag ImmPred,
3541 PatFrag ValueMod, InstHexagon MI>
3542 : Pat<(Store Value:$Rt, (add (i32 IntRegs:$Rs), ImmPred:$Off)),
3543 (MI IntRegs:$Rs, imm:$Off, (ValueMod Value:$Rt))>;
3544 class Storexm_simple_pat<PatFrag Store, PatFrag Value, PatFrag ValueMod,
3546 : Pat<(Store Value:$Rt, (i32 IntRegs:$Rs)),
3547 (MI IntRegs:$Rs, 0, (ValueMod Value:$Rt))>;
3549 multiclass Storex_pat<PatFrag Store, PatFrag Value, PatLeaf ImmPred,
3551 def: Storex_fi_pat <Store, Value, MI>;
3552 def: Storex_add_pat <Store, Value, ImmPred, MI>;
3555 multiclass Storexm_pat<PatFrag Store, PatFrag Value, PatLeaf ImmPred,
3556 PatFrag ValueMod, InstHexagon MI> {
3557 def: Storexm_fi_pat <Store, Value, ValueMod, MI>;
3558 def: Storexm_add_pat <Store, Value, ImmPred, ValueMod, MI>;
3561 // Regular stores in the DAG have two operands: value and address.
3562 // Atomic stores also have two, but they are reversed: address, value.
3563 // To use atomic stores with the patterns, they need to have their operands
3564 // swapped. This relies on the knowledge that the F.Fragment uses names
3566 class SwapSt<PatFrag F>
3567 : PatFrag<(ops node:$val, node:$ptr), F.Fragment>;
3569 let AddedComplexity = 20 in {
3570 defm: Storex_pat<truncstorei8, I32, s11_0ExtPred, S2_storerb_io>;
3571 defm: Storex_pat<truncstorei16, I32, s11_1ExtPred, S2_storerh_io>;
3572 defm: Storex_pat<store, I32, s11_2ExtPred, S2_storeri_io>;
3573 defm: Storex_pat<store, I64, s11_3ExtPred, S2_storerd_io>;
3575 defm: Storex_pat<SwapSt<atomic_store_8>, I32, s11_0ExtPred, S2_storerb_io>;
3576 defm: Storex_pat<SwapSt<atomic_store_16>, I32, s11_1ExtPred, S2_storerh_io>;
3577 defm: Storex_pat<SwapSt<atomic_store_32>, I32, s11_2ExtPred, S2_storeri_io>;
3578 defm: Storex_pat<SwapSt<atomic_store_64>, I64, s11_3ExtPred, S2_storerd_io>;
3581 // Simple patterns should be tried with the least priority.
3582 def: Storex_simple_pat<truncstorei8, I32, S2_storerb_io>;
3583 def: Storex_simple_pat<truncstorei16, I32, S2_storerh_io>;
3584 def: Storex_simple_pat<store, I32, S2_storeri_io>;
3585 def: Storex_simple_pat<store, I64, S2_storerd_io>;
3587 def: Storex_simple_pat<SwapSt<atomic_store_8>, I32, S2_storerb_io>;
3588 def: Storex_simple_pat<SwapSt<atomic_store_16>, I32, S2_storerh_io>;
3589 def: Storex_simple_pat<SwapSt<atomic_store_32>, I32, S2_storeri_io>;
3590 def: Storex_simple_pat<SwapSt<atomic_store_64>, I64, S2_storerd_io>;
3592 let AddedComplexity = 20 in {
3593 defm: Storexm_pat<truncstorei8, I64, s11_0ExtPred, LoReg, S2_storerb_io>;
3594 defm: Storexm_pat<truncstorei16, I64, s11_1ExtPred, LoReg, S2_storerh_io>;
3595 defm: Storexm_pat<truncstorei32, I64, s11_2ExtPred, LoReg, S2_storeri_io>;
3598 def: Storexm_simple_pat<truncstorei8, I64, LoReg, S2_storerb_io>;
3599 def: Storexm_simple_pat<truncstorei16, I64, LoReg, S2_storerh_io>;
3600 def: Storexm_simple_pat<truncstorei32, I64, LoReg, S2_storeri_io>;
3603 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 13,
3604 isCodeGenOnly = 1, isPseudo = 1, hasSideEffects = 0 in
3605 def STriw_pred : STInst<(outs),
3606 (ins IntRegs:$addr, s11_2Ext:$off, PredRegs:$src1),
3607 ".error \"should not emit\"", []>;
3609 // S2_allocframe: Allocate stack frame.
3610 let Defs = [R29, R30], Uses = [R29, R31, R30],
3611 hasSideEffects = 0, accessSize = DoubleWordAccess in
3612 def S2_allocframe: ST0Inst <
3613 (outs), (ins u11_3Imm:$u11_3),
3614 "allocframe(#$u11_3)" > {
3617 let IClass = 0b1010;
3618 let Inst{27-16} = 0b000010011101;
3619 let Inst{13-11} = 0b000;
3620 let Inst{10-0} = u11_3{13-3};
3623 // S2_storer[bhwdf]_pci: Store byte/half/word/double.
3624 // S2_storer[bhwdf]_pci -> S2_storerbnew_pci
3625 let Uses = [CS], isNVStorable = 1 in
3626 class T_store_pci <string mnemonic, RegisterClass RC,
3627 Operand Imm, bits<4>MajOp,
3628 MemAccessSize AlignSize, string RegSrc = "Rt">
3629 : STInst <(outs IntRegs:$_dst_),
3630 (ins IntRegs:$Rz, Imm:$offset, ModRegs:$Mu, RC:$Rt),
3631 #mnemonic#"($Rz ++ #$offset:circ($Mu)) = $"#RegSrc#"",
3638 let accessSize = AlignSize;
3640 let IClass = 0b1010;
3641 let Inst{27-25} = 0b100;
3642 let Inst{24-21} = MajOp;
3643 let Inst{20-16} = Rz;
3645 let Inst{12-8} = Rt;
3648 !if (!eq(!cast<string>(AlignSize), "DoubleWordAccess"), offset{6-3},
3649 !if (!eq(!cast<string>(AlignSize), "WordAccess"), offset{5-2},
3650 !if (!eq(!cast<string>(AlignSize), "HalfWordAccess"), offset{4-1},
3651 /* ByteAccess */ offset{3-0})));
3655 def S2_storerb_pci : T_store_pci<"memb", IntRegs, s4_0Imm, 0b1000,
3657 def S2_storerh_pci : T_store_pci<"memh", IntRegs, s4_1Imm, 0b1010,
3659 def S2_storerf_pci : T_store_pci<"memh", IntRegs, s4_1Imm, 0b1011,
3660 HalfWordAccess, "Rt.h">;
3661 def S2_storeri_pci : T_store_pci<"memw", IntRegs, s4_2Imm, 0b1100,
3663 def S2_storerd_pci : T_store_pci<"memd", DoubleRegs, s4_3Imm, 0b1110,
3666 let Uses = [CS], isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 4 in
3667 class T_storenew_pci <string mnemonic, Operand Imm,
3668 bits<2>MajOp, MemAccessSize AlignSize>
3669 : NVInst < (outs IntRegs:$_dst_),
3670 (ins IntRegs:$Rz, Imm:$offset, ModRegs:$Mu, IntRegs:$Nt),
3671 #mnemonic#"($Rz ++ #$offset:circ($Mu)) = $Nt.new",
3679 let accessSize = AlignSize;
3681 let IClass = 0b1010;
3682 let Inst{27-21} = 0b1001101;
3683 let Inst{20-16} = Rz;
3685 let Inst{12-11} = MajOp;
3686 let Inst{10-8} = Nt;
3689 !if (!eq(!cast<string>(AlignSize), "WordAccess"), offset{5-2},
3690 !if (!eq(!cast<string>(AlignSize), "HalfWordAccess"), offset{4-1},
3691 /* ByteAccess */ offset{3-0}));
3695 def S2_storerbnew_pci : T_storenew_pci <"memb", s4_0Imm, 0b00, ByteAccess>;
3696 def S2_storerhnew_pci : T_storenew_pci <"memh", s4_1Imm, 0b01, HalfWordAccess>;
3697 def S2_storerinew_pci : T_storenew_pci <"memw", s4_2Imm, 0b10, WordAccess>;
3699 //===----------------------------------------------------------------------===//
3700 // Circular stores - Pseudo
3702 // Please note that the input operand order in the pseudo instructions
3703 // doesn't match with the real instructions. Pseudo instructions operand
3704 // order should mimics the ordering in the intrinsics.
3705 //===----------------------------------------------------------------------===//
3706 let isCodeGenOnly = 1, mayStore = 1, hasSideEffects = 0, isPseudo = 1 in
3707 class T_store_pci_pseudo <string opc, RegisterClass RC>
3708 : STInstPI<(outs IntRegs:$_dst_),
3709 (ins IntRegs:$src1, RC:$src2, IntRegs:$src3, s4Imm:$src4),
3710 ".error \""#opc#"($src1++#$src4:circ($src3)) = $src2\"",
3711 [], "$_dst_ = $src1">;
3713 def S2_storerb_pci_pseudo : T_store_pci_pseudo <"memb", IntRegs>;
3714 def S2_storerh_pci_pseudo : T_store_pci_pseudo <"memh", IntRegs>;
3715 def S2_storerf_pci_pseudo : T_store_pci_pseudo <"memh", IntRegs>;
3716 def S2_storeri_pci_pseudo : T_store_pci_pseudo <"memw", IntRegs>;
3717 def S2_storerd_pci_pseudo : T_store_pci_pseudo <"memd", DoubleRegs>;
3719 //===----------------------------------------------------------------------===//
3720 // Circular stores with auto-increment register
3721 //===----------------------------------------------------------------------===//
3722 let Uses = [CS], isNVStorable = 1 in
3723 class T_store_pcr <string mnemonic, RegisterClass RC, bits<4>MajOp,
3724 MemAccessSize AlignSize, string RegSrc = "Rt">
3725 : STInst <(outs IntRegs:$_dst_),
3726 (ins IntRegs:$Rz, ModRegs:$Mu, RC:$Rt),
3727 #mnemonic#"($Rz ++ I:circ($Mu)) = $"#RegSrc#"",
3734 let accessSize = AlignSize;
3736 let IClass = 0b1010;
3737 let Inst{27-25} = 0b100;
3738 let Inst{24-21} = MajOp;
3739 let Inst{20-16} = Rz;
3741 let Inst{12-8} = Rt;
3746 def S2_storerb_pcr : T_store_pcr<"memb", IntRegs, 0b1000, ByteAccess>;
3747 def S2_storerh_pcr : T_store_pcr<"memh", IntRegs, 0b1010, HalfWordAccess>;
3748 def S2_storeri_pcr : T_store_pcr<"memw", IntRegs, 0b1100, WordAccess>;
3749 def S2_storerd_pcr : T_store_pcr<"memd", DoubleRegs, 0b1110, DoubleWordAccess>;
3750 def S2_storerf_pcr : T_store_pcr<"memh", IntRegs, 0b1011,
3751 HalfWordAccess, "Rt.h">;
3753 //===----------------------------------------------------------------------===//
3754 // Circular .new stores with auto-increment register
3755 //===----------------------------------------------------------------------===//
3756 let Uses = [CS], isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
3757 class T_storenew_pcr <string mnemonic, bits<2>MajOp,
3758 MemAccessSize AlignSize>
3759 : NVInst <(outs IntRegs:$_dst_),
3760 (ins IntRegs:$Rz, ModRegs:$Mu, IntRegs:$Nt),
3761 #mnemonic#"($Rz ++ I:circ($Mu)) = $Nt.new" ,
3768 let accessSize = AlignSize;
3770 let IClass = 0b1010;
3771 let Inst{27-21} = 0b1001101;
3772 let Inst{20-16} = Rz;
3774 let Inst{12-11} = MajOp;
3775 let Inst{10-8} = Nt;
3780 def S2_storerbnew_pcr : T_storenew_pcr <"memb", 0b00, ByteAccess>;
3781 def S2_storerhnew_pcr : T_storenew_pcr <"memh", 0b01, HalfWordAccess>;
3782 def S2_storerinew_pcr : T_storenew_pcr <"memw", 0b10, WordAccess>;
3784 //===----------------------------------------------------------------------===//
3785 // Bit-reversed stores with auto-increment register
3786 //===----------------------------------------------------------------------===//
3787 let hasSideEffects = 0 in
3788 class T_store_pbr<string mnemonic, RegisterClass RC,
3789 MemAccessSize addrSize, bits<3> majOp,
3792 <(outs IntRegs:$_dst_),
3793 (ins IntRegs:$Rz, ModRegs:$Mu, RC:$src),
3794 #mnemonic#"($Rz ++ $Mu:brev) = $src"#!if (!eq(isHalf, 1), ".h", ""),
3795 [], "$Rz = $_dst_" > {
3797 let accessSize = addrSize;
3803 let IClass = 0b1010;
3805 let Inst{27-24} = 0b1111;
3806 let Inst{23-21} = majOp;
3808 let Inst{20-16} = Rz;
3810 let Inst{12-8} = src;
3813 let isNVStorable = 1 in {
3814 let BaseOpcode = "S2_storerb_pbr" in
3815 def S2_storerb_pbr : T_store_pbr<"memb", IntRegs, ByteAccess,
3816 0b000>, NewValueRel;
3817 let BaseOpcode = "S2_storerh_pbr" in
3818 def S2_storerh_pbr : T_store_pbr<"memh", IntRegs, HalfWordAccess,
3819 0b010>, NewValueRel;
3820 let BaseOpcode = "S2_storeri_pbr" in
3821 def S2_storeri_pbr : T_store_pbr<"memw", IntRegs, WordAccess,
3822 0b100>, NewValueRel;
3825 def S2_storerf_pbr : T_store_pbr<"memh", IntRegs, HalfWordAccess, 0b011, 1>;
3826 def S2_storerd_pbr : T_store_pbr<"memd", DoubleRegs, DoubleWordAccess, 0b110>;
3828 //===----------------------------------------------------------------------===//
3829 // Bit-reversed .new stores with auto-increment register
3830 //===----------------------------------------------------------------------===//
3831 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3,
3832 hasSideEffects = 0 in
3833 class T_storenew_pbr<string mnemonic, MemAccessSize addrSize, bits<2> majOp>
3834 : NVInst <(outs IntRegs:$_dst_),
3835 (ins IntRegs:$Rz, ModRegs:$Mu, IntRegs:$Nt),
3836 #mnemonic#"($Rz ++ $Mu:brev) = $Nt.new", [],
3837 "$Rz = $_dst_">, NewValueRel {
3838 let accessSize = addrSize;
3843 let IClass = 0b1010;
3845 let Inst{27-21} = 0b1111101;
3846 let Inst{12-11} = majOp;
3848 let Inst{20-16} = Rz;
3850 let Inst{10-8} = Nt;
3853 let BaseOpcode = "S2_storerb_pbr" in
3854 def S2_storerbnew_pbr : T_storenew_pbr<"memb", ByteAccess, 0b00>;
3856 let BaseOpcode = "S2_storerh_pbr" in
3857 def S2_storerhnew_pbr : T_storenew_pbr<"memh", HalfWordAccess, 0b01>;
3859 let BaseOpcode = "S2_storeri_pbr" in
3860 def S2_storerinew_pbr : T_storenew_pbr<"memw", WordAccess, 0b10>;
3862 //===----------------------------------------------------------------------===//
3863 // Bit-reversed stores - Pseudo
3865 // Please note that the input operand order in the pseudo instructions
3866 // doesn't match with the real instructions. Pseudo instructions operand
3867 // order should mimics the ordering in the intrinsics.
3868 //===----------------------------------------------------------------------===//
3869 let isCodeGenOnly = 1, mayStore = 1, hasSideEffects = 0, isPseudo = 1 in
3870 class T_store_pbr_pseudo <string opc, RegisterClass RC>
3871 : STInstPI<(outs IntRegs:$_dst_),
3872 (ins IntRegs:$src1, RC:$src2, IntRegs:$src3),
3873 ".error \""#opc#"($src1++$src3:brev) = $src2\"",
3874 [], "$_dst_ = $src1">;
3876 def S2_storerb_pbr_pseudo : T_store_pbr_pseudo <"memb", IntRegs>;
3877 def S2_storerh_pbr_pseudo : T_store_pbr_pseudo <"memh", IntRegs>;
3878 def S2_storeri_pbr_pseudo : T_store_pbr_pseudo <"memw", IntRegs>;
3879 def S2_storerf_pbr_pseudo : T_store_pbr_pseudo <"memh", IntRegs>;
3880 def S2_storerd_pbr_pseudo : T_store_pbr_pseudo <"memd", DoubleRegs>;
3882 //===----------------------------------------------------------------------===//
3884 //===----------------------------------------------------------------------===//
3886 //===----------------------------------------------------------------------===//
3887 // Template class for S_2op instructions.
3888 //===----------------------------------------------------------------------===//
3889 let hasSideEffects = 0 in
3890 class T_S2op_1 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
3891 RegisterClass RCIn, bits<2> MajOp, bits<3> MinOp, bit isSat>
3892 : SInst <(outs RCOut:$dst), (ins RCIn:$src),
3893 "$dst = "#mnemonic#"($src)"#!if(isSat, ":sat", ""),
3894 [], "", S_2op_tc_1_SLOT23 > {
3898 let IClass = 0b1000;
3900 let Inst{27-24} = RegTyBits;
3901 let Inst{23-22} = MajOp;
3903 let Inst{20-16} = src;
3904 let Inst{7-5} = MinOp;
3905 let Inst{4-0} = dst;
3908 class T_S2op_1_di <string mnemonic, bits<2> MajOp, bits<3> MinOp>
3909 : T_S2op_1 <mnemonic, 0b0100, DoubleRegs, IntRegs, MajOp, MinOp, 0>;
3911 let hasNewValue = 1 in
3912 class T_S2op_1_id <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
3913 : T_S2op_1 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, isSat>;
3915 let hasNewValue = 1 in
3916 class T_S2op_1_ii <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
3917 : T_S2op_1 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp, isSat>;
3919 // Vector sign/zero extend
3920 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3921 def S2_vsxtbh : T_S2op_1_di <"vsxtbh", 0b00, 0b000>;
3922 def S2_vsxthw : T_S2op_1_di <"vsxthw", 0b00, 0b100>;
3923 def S2_vzxtbh : T_S2op_1_di <"vzxtbh", 0b00, 0b010>;
3924 def S2_vzxthw : T_S2op_1_di <"vzxthw", 0b00, 0b110>;
3927 // Vector splat bytes/halfwords
3928 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3929 def S2_vsplatrb : T_S2op_1_ii <"vsplatb", 0b01, 0b111>;
3930 def S2_vsplatrh : T_S2op_1_di <"vsplath", 0b01, 0b010>;
3933 // Sign extend word to doubleword
3934 def A2_sxtw : T_S2op_1_di <"sxtw", 0b01, 0b000>;
3936 def: Pat <(i64 (sext I32:$src)), (A2_sxtw I32:$src)>;
3938 // Vector saturate and pack
3939 let Defs = [USR_OVF] in {
3940 def S2_svsathb : T_S2op_1_ii <"vsathb", 0b10, 0b000>;
3941 def S2_svsathub : T_S2op_1_ii <"vsathub", 0b10, 0b010>;
3942 def S2_vsathb : T_S2op_1_id <"vsathb", 0b00, 0b110>;
3943 def S2_vsathub : T_S2op_1_id <"vsathub", 0b00, 0b000>;
3944 def S2_vsatwh : T_S2op_1_id <"vsatwh", 0b00, 0b010>;
3945 def S2_vsatwuh : T_S2op_1_id <"vsatwuh", 0b00, 0b100>;
3949 def S2_vtrunohb : T_S2op_1_id <"vtrunohb", 0b10, 0b000>;
3950 def S2_vtrunehb : T_S2op_1_id <"vtrunehb", 0b10, 0b010>;
3952 // Swizzle the bytes of a word
3953 def A2_swiz : T_S2op_1_ii <"swiz", 0b10, 0b111>;
3956 let Defs = [USR_OVF] in {
3957 def A2_sat : T_S2op_1_id <"sat", 0b11, 0b000>;
3958 def A2_satb : T_S2op_1_ii <"satb", 0b11, 0b111>;
3959 def A2_satub : T_S2op_1_ii <"satub", 0b11, 0b110>;
3960 def A2_sath : T_S2op_1_ii <"sath", 0b11, 0b100>;
3961 def A2_satuh : T_S2op_1_ii <"satuh", 0b11, 0b101>;
3962 def A2_roundsat : T_S2op_1_id <"round", 0b11, 0b001, 0b1>;
3965 let Itinerary = S_2op_tc_2_SLOT23 in {
3966 // Vector round and pack
3967 def S2_vrndpackwh : T_S2op_1_id <"vrndwh", 0b10, 0b100>;
3969 let Defs = [USR_OVF] in
3970 def S2_vrndpackwhs : T_S2op_1_id <"vrndwh", 0b10, 0b110, 1>;
3973 def S2_brev : T_S2op_1_ii <"brev", 0b01, 0b110>;
3975 // Absolute value word
3976 def A2_abs : T_S2op_1_ii <"abs", 0b10, 0b100>;
3978 let Defs = [USR_OVF] in
3979 def A2_abssat : T_S2op_1_ii <"abs", 0b10, 0b101, 1>;
3981 // Negate with saturation
3982 let Defs = [USR_OVF] in
3983 def A2_negsat : T_S2op_1_ii <"neg", 0b10, 0b110, 1>;
3986 def: Pat<(i32 (select (i1 (setlt (i32 IntRegs:$src), 0)),
3987 (i32 (sub 0, (i32 IntRegs:$src))),
3988 (i32 IntRegs:$src))),
3989 (A2_abs IntRegs:$src)>;
3991 let AddedComplexity = 50 in
3992 def: Pat<(i32 (xor (add (sra (i32 IntRegs:$src), (i32 31)),
3993 (i32 IntRegs:$src)),
3994 (sra (i32 IntRegs:$src), (i32 31)))),
3995 (A2_abs IntRegs:$src)>;
3997 class T_S2op_2 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
3998 RegisterClass RCIn, bits<3> MajOp, bits<3> MinOp,
3999 bit isSat, bit isRnd, list<dag> pattern = []>
4000 : SInst <(outs RCOut:$dst),
4001 (ins RCIn:$src, u5Imm:$u5),
4002 "$dst = "#mnemonic#"($src, #$u5)"#!if(isSat, ":sat", "")
4003 #!if(isRnd, ":rnd", ""),
4004 pattern, "", S_2op_tc_2_SLOT23> {
4009 let IClass = 0b1000;
4011 let Inst{27-24} = RegTyBits;
4012 let Inst{23-21} = MajOp;
4013 let Inst{20-16} = src;
4015 let Inst{12-8} = u5;
4016 let Inst{7-5} = MinOp;
4017 let Inst{4-0} = dst;
4020 class T_S2op_2_di <string mnemonic, bits<3> MajOp, bits<3> MinOp>
4021 : T_S2op_2 <mnemonic, 0b1000, DoubleRegs, IntRegs, MajOp, MinOp, 0, 0>;
4023 let hasNewValue = 1 in
4024 class T_S2op_2_id <string mnemonic, bits<3> MajOp, bits<3> MinOp>
4025 : T_S2op_2 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, 0, 0>;
4027 let hasNewValue = 1 in
4028 class T_S2op_2_ii <string mnemonic, bits<3> MajOp, bits<3> MinOp,
4029 bit isSat = 0, bit isRnd = 0, list<dag> pattern = []>
4030 : T_S2op_2 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp,
4031 isSat, isRnd, pattern>;
4033 class T_S2op_shift <string mnemonic, bits<3> MajOp, bits<3> MinOp, SDNode OpNd>
4034 : T_S2op_2_ii <mnemonic, MajOp, MinOp, 0, 0,
4035 [(set (i32 IntRegs:$dst), (OpNd (i32 IntRegs:$src),
4036 (u5ImmPred:$u5)))]>;
4038 // Vector arithmetic shift right by immediate with truncate and pack
4039 def S2_asr_i_svw_trun : T_S2op_2_id <"vasrw", 0b110, 0b010>;
4041 // Arithmetic/logical shift right/left by immediate
4042 let Itinerary = S_2op_tc_1_SLOT23 in {
4043 def S2_asr_i_r : T_S2op_shift <"asr", 0b000, 0b000, sra>;
4044 def S2_lsr_i_r : T_S2op_shift <"lsr", 0b000, 0b001, srl>;
4045 def S2_asl_i_r : T_S2op_shift <"asl", 0b000, 0b010, shl>;
4048 // Shift left by immediate with saturation
4049 let Defs = [USR_OVF] in
4050 def S2_asl_i_r_sat : T_S2op_2_ii <"asl", 0b010, 0b010, 1>;
4052 // Shift right with round
4053 def S2_asr_i_r_rnd : T_S2op_2_ii <"asr", 0b010, 0b000, 0, 1>;
4055 let isAsmParserOnly = 1 in
4056 def S2_asr_i_r_rnd_goodsyntax
4057 : SInst <(outs IntRegs:$dst), (ins IntRegs:$src, u5Imm:$u5),
4058 "$dst = asrrnd($src, #$u5)",
4059 [], "", S_2op_tc_1_SLOT23>;
4061 let isAsmParserOnly = 1 in
4062 def A2_not: ALU32_rr<(outs IntRegs:$dst),(ins IntRegs:$src),
4063 "$dst = not($src)">;
4065 def: Pat<(i32 (sra (i32 (add (i32 (sra I32:$src1, u5ImmPred:$src2)),
4068 (S2_asr_i_r_rnd IntRegs:$src1, u5ImmPred:$src2)>;
4070 class T_S2op_3<string opc, bits<2>MajOp, bits<3>minOp, bits<1> sat = 0>
4071 : SInst<(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss),
4072 "$Rdd = "#opc#"($Rss)"#!if(!eq(sat, 1),":sat","")> {
4075 let IClass = 0b1000;
4076 let Inst{27-24} = 0;
4077 let Inst{23-22} = MajOp;
4078 let Inst{20-16} = Rss;
4079 let Inst{7-5} = minOp;
4080 let Inst{4-0} = Rdd;
4083 def A2_absp : T_S2op_3 <"abs", 0b10, 0b110>;
4084 def A2_negp : T_S2op_3 <"neg", 0b10, 0b101>;
4085 def A2_notp : T_S2op_3 <"not", 0b10, 0b100>;
4087 // Innterleave/deinterleave
4088 def S2_interleave : T_S2op_3 <"interleave", 0b11, 0b101>;
4089 def S2_deinterleave : T_S2op_3 <"deinterleave", 0b11, 0b100>;
4091 // Vector Complex conjugate
4092 def A2_vconj : T_S2op_3 <"vconj", 0b10, 0b111, 1>;
4094 // Vector saturate without pack
4095 def S2_vsathb_nopack : T_S2op_3 <"vsathb", 0b00, 0b111>;
4096 def S2_vsathub_nopack : T_S2op_3 <"vsathub", 0b00, 0b100>;
4097 def S2_vsatwh_nopack : T_S2op_3 <"vsatwh", 0b00, 0b110>;
4098 def S2_vsatwuh_nopack : T_S2op_3 <"vsatwuh", 0b00, 0b101>;
4100 // Vector absolute value halfwords with and without saturation
4101 // Rdd64=vabsh(Rss64)[:sat]
4102 def A2_vabsh : T_S2op_3 <"vabsh", 0b01, 0b100>;
4103 def A2_vabshsat : T_S2op_3 <"vabsh", 0b01, 0b101, 1>;
4105 // Vector absolute value words with and without saturation
4106 def A2_vabsw : T_S2op_3 <"vabsw", 0b01, 0b110>;
4107 def A2_vabswsat : T_S2op_3 <"vabsw", 0b01, 0b111, 1>;
4109 def : Pat<(not (i64 DoubleRegs:$src1)),
4110 (A2_notp DoubleRegs:$src1)>;
4112 //===----------------------------------------------------------------------===//
4114 //===----------------------------------------------------------------------===//
4117 let hasSideEffects = 0, hasNewValue = 1 in
4118 class T_COUNT_LEADING<string MnOp, bits<3> MajOp, bits<3> MinOp, bit Is32,
4120 : SInst<Out, Inp, "$Rd = "#MnOp#"($Rs)", [], "", S_2op_tc_1_SLOT23> {
4123 let IClass = 0b1000;
4125 let Inst{26} = Is32;
4126 let Inst{25-24} = 0b00;
4127 let Inst{23-21} = MajOp;
4128 let Inst{20-16} = Rs;
4129 let Inst{7-5} = MinOp;
4133 class T_COUNT_LEADING_32<string MnOp, bits<3> MajOp, bits<3> MinOp>
4134 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b1,
4135 (outs IntRegs:$Rd), (ins IntRegs:$Rs)>;
4137 class T_COUNT_LEADING_64<string MnOp, bits<3> MajOp, bits<3> MinOp>
4138 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b0,
4139 (outs IntRegs:$Rd), (ins DoubleRegs:$Rs)>;
4141 def S2_cl0 : T_COUNT_LEADING_32<"cl0", 0b000, 0b101>;
4142 def S2_cl1 : T_COUNT_LEADING_32<"cl1", 0b000, 0b110>;
4143 def S2_ct0 : T_COUNT_LEADING_32<"ct0", 0b010, 0b100>;
4144 def S2_ct1 : T_COUNT_LEADING_32<"ct1", 0b010, 0b101>;
4145 def S2_cl0p : T_COUNT_LEADING_64<"cl0", 0b010, 0b010>;
4146 def S2_cl1p : T_COUNT_LEADING_64<"cl1", 0b010, 0b100>;
4147 def S2_clb : T_COUNT_LEADING_32<"clb", 0b000, 0b100>;
4148 def S2_clbp : T_COUNT_LEADING_64<"clb", 0b010, 0b000>;
4149 def S2_clbnorm : T_COUNT_LEADING_32<"normamt", 0b000, 0b111>;
4151 def: Pat<(i32 (ctlz I32:$Rs)), (S2_cl0 I32:$Rs)>;
4152 def: Pat<(i32 (ctlz (not I32:$Rs))), (S2_cl1 I32:$Rs)>;
4153 def: Pat<(i32 (cttz I32:$Rs)), (S2_ct0 I32:$Rs)>;
4154 def: Pat<(i32 (cttz (not I32:$Rs))), (S2_ct1 I32:$Rs)>;
4155 def: Pat<(i32 (trunc (ctlz I64:$Rss))), (S2_cl0p I64:$Rss)>;
4156 def: Pat<(i32 (trunc (ctlz (not I64:$Rss)))), (S2_cl1p I64:$Rss)>;
4158 // Bit set/clear/toggle
4160 let hasSideEffects = 0, hasNewValue = 1 in
4161 class T_SCT_BIT_IMM<string MnOp, bits<3> MinOp>
4162 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, u5Imm:$u5),
4163 "$Rd = "#MnOp#"($Rs, #$u5)", [], "", S_2op_tc_1_SLOT23> {
4167 let IClass = 0b1000;
4168 let Inst{27-21} = 0b1100110;
4169 let Inst{20-16} = Rs;
4171 let Inst{12-8} = u5;
4172 let Inst{7-5} = MinOp;
4176 let hasSideEffects = 0, hasNewValue = 1 in
4177 class T_SCT_BIT_REG<string MnOp, bits<2> MinOp>
4178 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
4179 "$Rd = "#MnOp#"($Rs, $Rt)", [], "", S_3op_tc_1_SLOT23> {
4183 let IClass = 0b1100;
4184 let Inst{27-22} = 0b011010;
4185 let Inst{20-16} = Rs;
4186 let Inst{12-8} = Rt;
4187 let Inst{7-6} = MinOp;
4191 def S2_clrbit_i : T_SCT_BIT_IMM<"clrbit", 0b001>;
4192 def S2_setbit_i : T_SCT_BIT_IMM<"setbit", 0b000>;
4193 def S2_togglebit_i : T_SCT_BIT_IMM<"togglebit", 0b010>;
4194 def S2_clrbit_r : T_SCT_BIT_REG<"clrbit", 0b01>;
4195 def S2_setbit_r : T_SCT_BIT_REG<"setbit", 0b00>;
4196 def S2_togglebit_r : T_SCT_BIT_REG<"togglebit", 0b10>;
4198 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, u5ImmPred:$u5)))),
4199 (S2_clrbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4200 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
4201 (S2_setbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4202 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
4203 (S2_togglebit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4204 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, (i32 IntRegs:$Rt))))),
4205 (S2_clrbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4206 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
4207 (S2_setbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4208 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
4209 (S2_togglebit_r IntRegs:$Rs, IntRegs:$Rt)>;
4213 let hasSideEffects = 0 in
4214 class T_TEST_BIT_IMM<string MnOp, bits<3> MajOp>
4215 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u5Imm:$u5),
4216 "$Pd = "#MnOp#"($Rs, #$u5)",
4217 [], "", S_2op_tc_2early_SLOT23> {
4221 let IClass = 0b1000;
4222 let Inst{27-24} = 0b0101;
4223 let Inst{23-21} = MajOp;
4224 let Inst{20-16} = Rs;
4226 let Inst{12-8} = u5;
4230 let hasSideEffects = 0 in
4231 class T_TEST_BIT_REG<string MnOp, bit IsNeg>
4232 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
4233 "$Pd = "#MnOp#"($Rs, $Rt)",
4234 [], "", S_3op_tc_2early_SLOT23> {
4238 let IClass = 0b1100;
4239 let Inst{27-22} = 0b011100;
4240 let Inst{21} = IsNeg;
4241 let Inst{20-16} = Rs;
4242 let Inst{12-8} = Rt;
4246 def S2_tstbit_i : T_TEST_BIT_IMM<"tstbit", 0b000>;
4247 def S2_tstbit_r : T_TEST_BIT_REG<"tstbit", 0>;
4249 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
4250 def: Pat<(i1 (setne (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
4251 (S2_tstbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4252 def: Pat<(i1 (setne (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
4253 (S2_tstbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4254 def: Pat<(i1 (trunc (i32 IntRegs:$Rs))),
4255 (S2_tstbit_i IntRegs:$Rs, 0)>;
4256 def: Pat<(i1 (trunc (i64 DoubleRegs:$Rs))),
4257 (S2_tstbit_i (LoReg DoubleRegs:$Rs), 0)>;
4260 let hasSideEffects = 0 in
4261 class T_TEST_BITS_IMM<string MnOp, bits<2> MajOp, bit IsNeg>
4262 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u6Imm:$u6),
4263 "$Pd = "#MnOp#"($Rs, #$u6)",
4264 [], "", S_2op_tc_2early_SLOT23> {
4268 let IClass = 0b1000;
4269 let Inst{27-24} = 0b0101;
4270 let Inst{23-22} = MajOp;
4271 let Inst{21} = IsNeg;
4272 let Inst{20-16} = Rs;
4273 let Inst{13-8} = u6;
4277 let hasSideEffects = 0 in
4278 class T_TEST_BITS_REG<string MnOp, bits<2> MajOp, bit IsNeg>
4279 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
4280 "$Pd = "#MnOp#"($Rs, $Rt)",
4281 [], "", S_3op_tc_2early_SLOT23> {
4285 let IClass = 0b1100;
4286 let Inst{27-24} = 0b0111;
4287 let Inst{23-22} = MajOp;
4288 let Inst{21} = IsNeg;
4289 let Inst{20-16} = Rs;
4290 let Inst{12-8} = Rt;
4294 def C2_bitsclri : T_TEST_BITS_IMM<"bitsclr", 0b10, 0>;
4295 def C2_bitsclr : T_TEST_BITS_REG<"bitsclr", 0b10, 0>;
4296 def C2_bitsset : T_TEST_BITS_REG<"bitsset", 0b01, 0>;
4298 let AddedComplexity = 20 in { // Complexity greater than compare reg-imm.
4299 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), u6ImmPred:$u6), 0)),
4300 (C2_bitsclri IntRegs:$Rs, u6ImmPred:$u6)>;
4301 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), 0)),
4302 (C2_bitsclr IntRegs:$Rs, IntRegs:$Rt)>;
4305 let AddedComplexity = 10 in // Complexity greater than compare reg-reg.
4306 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), IntRegs:$Rt)),
4307 (C2_bitsset IntRegs:$Rs, IntRegs:$Rt)>;
4309 //===----------------------------------------------------------------------===//
4311 //===----------------------------------------------------------------------===//
4313 //===----------------------------------------------------------------------===//
4315 //===----------------------------------------------------------------------===//
4316 //===----------------------------------------------------------------------===//
4318 //===----------------------------------------------------------------------===//
4320 //===----------------------------------------------------------------------===//
4322 //===----------------------------------------------------------------------===//
4324 //===----------------------------------------------------------------------===//
4326 //===----------------------------------------------------------------------===//
4328 //===----------------------------------------------------------------------===//
4330 //===----------------------------------------------------------------------===//
4332 // Predicate transfer.
4333 let hasSideEffects = 0, hasNewValue = 1 in
4334 def C2_tfrpr : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps),
4335 "$Rd = $Ps", [], "", S_2op_tc_1_SLOT23> {
4339 let IClass = 0b1000;
4340 let Inst{27-24} = 0b1001;
4342 let Inst{17-16} = Ps;
4346 // Transfer general register to predicate.
4347 let hasSideEffects = 0 in
4348 def C2_tfrrp: SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs),
4349 "$Pd = $Rs", [], "", S_2op_tc_2early_SLOT23> {
4353 let IClass = 0b1000;
4354 let Inst{27-21} = 0b0101010;
4355 let Inst{20-16} = Rs;
4359 let hasSideEffects = 0, isCodeGenOnly = 1 in
4360 def C2_pxfer_map: SInst<(outs PredRegs:$dst), (ins PredRegs:$src),
4364 // Patterns for loads of i1:
4365 def: Pat<(i1 (load AddrFI:$fi)),
4366 (C2_tfrrp (L2_loadrub_io AddrFI:$fi, 0))>;
4367 def: Pat<(i1 (load (add (i32 IntRegs:$Rs), s11_0ExtPred:$Off))),
4368 (C2_tfrrp (L2_loadrub_io IntRegs:$Rs, imm:$Off))>;
4369 def: Pat<(i1 (load (i32 IntRegs:$Rs))),
4370 (C2_tfrrp (L2_loadrub_io IntRegs:$Rs, 0))>;
4372 def I1toI32: OutPatFrag<(ops node:$Rs),
4373 (C2_muxii (i1 $Rs), 1, 0)>;
4375 def I32toI1: OutPatFrag<(ops node:$Rs),
4376 (i1 (C2_tfrrp (i32 $Rs)))>;
4378 defm: Storexm_pat<store, I1, s11_0ExtPred, I1toI32, S2_storerb_io>;
4379 def: Storexm_simple_pat<store, I1, I1toI32, S2_storerb_io>;
4381 //===----------------------------------------------------------------------===//
4383 //===----------------------------------------------------------------------===//
4385 //===----------------------------------------------------------------------===//
4387 //===----------------------------------------------------------------------===//
4388 class S_2OpInstImm<string Mnemonic, bits<3>MajOp, bits<3>MinOp,
4389 Operand Imm, list<dag> pattern = [], bit isRnd = 0>
4390 : SInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, Imm:$src2),
4391 "$dst = "#Mnemonic#"($src1, #$src2)"#!if(isRnd, ":rnd", ""),
4395 let IClass = 0b1000;
4396 let Inst{27-24} = 0;
4397 let Inst{23-21} = MajOp;
4398 let Inst{20-16} = src1;
4399 let Inst{7-5} = MinOp;
4400 let Inst{4-0} = dst;
4403 class S_2OpInstImmI6<string Mnemonic, SDNode OpNode, bits<3>MinOp>
4404 : S_2OpInstImm<Mnemonic, 0b000, MinOp, u6Imm,
4405 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
4406 u6ImmPred:$src2))]> {
4408 let Inst{13-8} = src2;
4411 // Shift by immediate.
4412 def S2_asr_i_p : S_2OpInstImmI6<"asr", sra, 0b000>;
4413 def S2_asl_i_p : S_2OpInstImmI6<"asl", shl, 0b010>;
4414 def S2_lsr_i_p : S_2OpInstImmI6<"lsr", srl, 0b001>;
4416 // Shift left by small amount and add.
4417 let AddedComplexity = 100, hasNewValue = 1, hasSideEffects = 0 in
4418 def S2_addasl_rrri: SInst <(outs IntRegs:$Rd),
4419 (ins IntRegs:$Rt, IntRegs:$Rs, u3Imm:$u3),
4420 "$Rd = addasl($Rt, $Rs, #$u3)" ,
4421 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rt),
4422 (shl (i32 IntRegs:$Rs), u3ImmPred:$u3)))],
4423 "", S_3op_tc_2_SLOT23> {
4429 let IClass = 0b1100;
4431 let Inst{27-21} = 0b0100000;
4432 let Inst{20-16} = Rs;
4434 let Inst{12-8} = Rt;
4439 //===----------------------------------------------------------------------===//
4441 //===----------------------------------------------------------------------===//
4443 //===----------------------------------------------------------------------===//
4445 //===----------------------------------------------------------------------===//
4446 //===----------------------------------------------------------------------===//
4448 //===----------------------------------------------------------------------===//
4450 //===----------------------------------------------------------------------===//
4452 //===----------------------------------------------------------------------===//
4453 //===----------------------------------------------------------------------===//
4455 //===----------------------------------------------------------------------===//
4457 //===----------------------------------------------------------------------===//
4459 //===----------------------------------------------------------------------===//
4461 //===----------------------------------------------------------------------===//
4463 //===----------------------------------------------------------------------===//
4464 def HexagonBARRIER: SDNode<"HexagonISD::BARRIER", SDTNone, [SDNPHasChain]>;
4466 let hasSideEffects = 1, isSoloAX = 1 in
4467 def Y2_barrier : SYSInst<(outs), (ins),
4469 [(HexagonBARRIER)],"",ST_tc_st_SLOT0> {
4470 let Inst{31-28} = 0b1010;
4471 let Inst{27-21} = 0b1000000;
4474 //===----------------------------------------------------------------------===//
4476 //===----------------------------------------------------------------------===//
4477 //===----------------------------------------------------------------------===//
4479 //===----------------------------------------------------------------------===//
4481 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
4482 opExtendable = 0, hasSideEffects = 0 in
4483 class LOOP_iBase<string mnemonic, Operand brOp, bit mustExtend = 0>
4484 : CRInst<(outs), (ins brOp:$offset, u10Imm:$src2),
4485 #mnemonic#"($offset, #$src2)",
4486 [], "" , CR_tc_3x_SLOT3> {
4490 let IClass = 0b0110;
4492 let Inst{27-22} = 0b100100;
4493 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
4494 let Inst{20-16} = src2{9-5};
4495 let Inst{12-8} = offset{8-4};
4496 let Inst{7-5} = src2{4-2};
4497 let Inst{4-3} = offset{3-2};
4498 let Inst{1-0} = src2{1-0};
4501 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
4502 opExtendable = 0, hasSideEffects = 0 in
4503 class LOOP_rBase<string mnemonic, Operand brOp, bit mustExtend = 0>
4504 : CRInst<(outs), (ins brOp:$offset, IntRegs:$src2),
4505 #mnemonic#"($offset, $src2)",
4506 [], "" ,CR_tc_3x_SLOT3> {
4510 let IClass = 0b0110;
4512 let Inst{27-22} = 0b000000;
4513 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
4514 let Inst{20-16} = src2;
4515 let Inst{12-8} = offset{8-4};
4516 let Inst{4-3} = offset{3-2};
4519 multiclass LOOP_ri<string mnemonic> {
4520 def i : LOOP_iBase<mnemonic, brtarget>;
4521 def r : LOOP_rBase<mnemonic, brtarget>;
4525 let Defs = [SA0, LC0, USR] in
4526 defm J2_loop0 : LOOP_ri<"loop0">;
4528 // Interestingly only loop0's appear to set usr.lpcfg
4529 let Defs = [SA1, LC1] in
4530 defm J2_loop1 : LOOP_ri<"loop1">;
4532 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
4533 Defs = [PC, LC0], Uses = [SA0, LC0] in {
4534 def ENDLOOP0 : Endloop<(outs), (ins brtarget:$offset),
4539 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
4540 Defs = [PC, LC1], Uses = [SA1, LC1] in {
4541 def ENDLOOP1 : Endloop<(outs), (ins brtarget:$offset),
4546 // Pipelined loop instructions, sp[123]loop0
4547 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
4548 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
4549 opExtendable = 0, isPredicateLate = 1 in
4550 class SPLOOP_iBase<string SP, bits<2> op>
4551 : CRInst <(outs), (ins brtarget:$r7_2, u10Imm:$U10),
4552 "p3 = sp"#SP#"loop0($r7_2, #$U10)" > {
4556 let IClass = 0b0110;
4558 let Inst{22-21} = op;
4559 let Inst{27-23} = 0b10011;
4560 let Inst{20-16} = U10{9-5};
4561 let Inst{12-8} = r7_2{8-4};
4562 let Inst{7-5} = U10{4-2};
4563 let Inst{4-3} = r7_2{3-2};
4564 let Inst{1-0} = U10{1-0};
4567 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
4568 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
4569 opExtendable = 0, isPredicateLate = 1 in
4570 class SPLOOP_rBase<string SP, bits<2> op>
4571 : CRInst <(outs), (ins brtarget:$r7_2, IntRegs:$Rs),
4572 "p3 = sp"#SP#"loop0($r7_2, $Rs)" > {
4576 let IClass = 0b0110;
4578 let Inst{22-21} = op;
4579 let Inst{27-23} = 0b00001;
4580 let Inst{20-16} = Rs;
4581 let Inst{12-8} = r7_2{8-4};
4582 let Inst{4-3} = r7_2{3-2};
4585 multiclass SPLOOP_ri<string mnemonic, bits<2> op> {
4586 def i : SPLOOP_iBase<mnemonic, op>;
4587 def r : SPLOOP_rBase<mnemonic, op>;
4590 defm J2_ploop1s : SPLOOP_ri<"1", 0b01>;
4591 defm J2_ploop2s : SPLOOP_ri<"2", 0b10>;
4592 defm J2_ploop3s : SPLOOP_ri<"3", 0b11>;
4594 // if (Rs[!>=<]=#0) jump:[t/nt]
4595 let Defs = [PC], isPredicated = 1, isBranch = 1, hasSideEffects = 0,
4596 hasSideEffects = 0 in
4597 class J2_jump_0_Base<string compare, bit isTak, bits<2> op>
4598 : CRInst <(outs), (ins IntRegs:$Rs, brtarget:$r13_2),
4599 "if ($Rs"#compare#"#0) jump"#!if(isTak, ":t", ":nt")#" $r13_2" > {
4603 let IClass = 0b0110;
4605 let Inst{27-24} = 0b0001;
4606 let Inst{23-22} = op;
4607 let Inst{12} = isTak;
4608 let Inst{21} = r13_2{14};
4609 let Inst{20-16} = Rs;
4610 let Inst{11-1} = r13_2{12-2};
4611 let Inst{13} = r13_2{13};
4614 multiclass J2_jump_compare_0<string compare, bits<2> op> {
4615 def NAME : J2_jump_0_Base<compare, 0, op>;
4616 def NAME#pt : J2_jump_0_Base<compare, 1, op>;
4619 defm J2_jumprz : J2_jump_compare_0<"!=", 0b00>;
4620 defm J2_jumprgtez : J2_jump_compare_0<">=", 0b01>;
4621 defm J2_jumprnz : J2_jump_compare_0<"==", 0b10>;
4622 defm J2_jumprltez : J2_jump_compare_0<"<=", 0b11>;
4624 // Transfer to/from Control/GPR Guest/GPR
4625 let hasSideEffects = 0 in
4626 class TFR_CR_RS_base<RegisterClass CTRC, RegisterClass RC, bit isDouble>
4627 : CRInst <(outs CTRC:$dst), (ins RC:$src),
4628 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
4632 let IClass = 0b0110;
4634 let Inst{27-25} = 0b001;
4635 let Inst{24} = isDouble;
4636 let Inst{23-21} = 0b001;
4637 let Inst{20-16} = src;
4638 let Inst{4-0} = dst;
4641 def A2_tfrrcr : TFR_CR_RS_base<CtrRegs, IntRegs, 0b0>;
4642 def A4_tfrpcp : TFR_CR_RS_base<CtrRegs64, DoubleRegs, 0b1>;
4643 def : InstAlias<"m0 = $Rs", (A2_tfrrcr C6, IntRegs:$Rs)>;
4644 def : InstAlias<"m1 = $Rs", (A2_tfrrcr C7, IntRegs:$Rs)>;
4646 let hasSideEffects = 0 in
4647 class TFR_RD_CR_base<RegisterClass RC, RegisterClass CTRC, bit isSingle>
4648 : CRInst <(outs RC:$dst), (ins CTRC:$src),
4649 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
4653 let IClass = 0b0110;
4655 let Inst{27-26} = 0b10;
4656 let Inst{25} = isSingle;
4657 let Inst{24-21} = 0b0000;
4658 let Inst{20-16} = src;
4659 let Inst{4-0} = dst;
4662 let hasNewValue = 1, opNewValue = 0 in
4663 def A2_tfrcrr : TFR_RD_CR_base<IntRegs, CtrRegs, 1>;
4664 def A4_tfrcpp : TFR_RD_CR_base<DoubleRegs, CtrRegs64, 0>;
4665 def : InstAlias<"$Rd = m0", (A2_tfrcrr IntRegs:$Rd, C6)>;
4666 def : InstAlias<"$Rd = m1", (A2_tfrcrr IntRegs:$Rd, C7)>;
4668 // Y4_trace: Send value to etm trace.
4669 let isSoloAX = 1, hasSideEffects = 0 in
4670 def Y4_trace: CRInst <(outs), (ins IntRegs:$Rs),
4674 let IClass = 0b0110;
4675 let Inst{27-21} = 0b0010010;
4676 let Inst{20-16} = Rs;
4679 let AddedComplexity = 100, isPredicated = 1, isCodeGenOnly = 1 in
4680 def TFR_condset_ri : ALU32_rr<(outs IntRegs:$dst),
4681 (ins PredRegs:$src1, IntRegs:$src2, s12Imm:$src3),
4682 "Error; should not emit",
4683 [(set (i32 IntRegs:$dst),
4684 (i32 (select (i1 PredRegs:$src1), (i32 IntRegs:$src2),
4685 s12ImmPred:$src3)))]>;
4687 let AddedComplexity = 100, isPredicated = 1, isCodeGenOnly = 1 in
4688 def TFR_condset_ir : ALU32_rr<(outs IntRegs:$dst),
4689 (ins PredRegs:$src1, s12Imm:$src2, IntRegs:$src3),
4690 "Error; should not emit",
4691 [(set (i32 IntRegs:$dst),
4692 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
4693 (i32 IntRegs:$src3))))]>;
4695 let AddedComplexity = 100, isPredicated = 1, isCodeGenOnly = 1 in
4696 def TFR_condset_ii : ALU32_rr<(outs IntRegs:$dst),
4697 (ins PredRegs:$src1, s12Imm:$src2, s12Imm:$src3),
4698 "Error; should not emit",
4699 [(set (i32 IntRegs:$dst),
4700 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
4701 s12ImmPred:$src3)))]>;
4703 // Generate frameindex addresses.
4704 let isReMaterializable = 1, isCodeGenOnly = 1 in
4705 def TFR_FI : ALU32_ri<(outs IntRegs:$dst), (ins FrameIndex:$src1),
4706 "$dst = add($src1)",
4707 [(set (i32 IntRegs:$dst), ADDRri:$src1)]>;
4709 // Support for generating global address.
4710 // Taken from X86InstrInfo.td.
4711 def SDTHexagonCONST32 : SDTypeProfile<1, 1, [SDTCisVT<0, i32>,
4714 def HexagonCONST32 : SDNode<"HexagonISD::CONST32", SDTHexagonCONST32>;
4715 def HexagonCONST32_GP : SDNode<"HexagonISD::CONST32_GP", SDTHexagonCONST32>;
4717 // HI/LO Instructions
4718 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4719 hasNewValue = 1, opNewValue = 0 in
4720 class REG_IMMED<string RegHalf, string Op, bit Rs, bits<3> MajOp, bit MinOp>
4721 : ALU32_ri<(outs IntRegs:$dst),
4722 (ins i32imm:$imm_value),
4723 "$dst"#RegHalf#" = #"#Op#"($imm_value)", []> {
4726 let IClass = 0b0111;
4729 let Inst{26-24} = MajOp;
4730 let Inst{21} = MinOp;
4731 let Inst{20-16} = dst;
4732 let Inst{23-22} = !if (!eq(Op, "LO"), imm_value{15-14}, imm_value{31-30});
4733 let Inst{13-0} = !if (!eq(Op, "LO"), imm_value{13-0}, imm_value{29-16});
4736 let isAsmParserOnly = 1 in {
4737 def LO : REG_IMMED<".l", "LO", 0b0, 0b001, 0b1>;
4738 def LO_H : REG_IMMED<".l", "HI", 0b0, 0b001, 0b1>;
4739 def HI : REG_IMMED<".h", "HI", 0b0, 0b010, 0b1>;
4740 def HI_L : REG_IMMED<".h", "LO", 0b0, 0b010, 0b1>;
4743 let isMoveImm = 1, isCodeGenOnly = 1 in
4744 def LO_PIC : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
4745 "$dst.l = #LO($label@GOTREL)",
4748 let isMoveImm = 1, isCodeGenOnly = 1 in
4749 def HI_PIC : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
4750 "$dst.h = #HI($label@GOTREL)",
4753 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4754 isAsmParserOnly = 1 in
4755 def LOi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
4756 "$dst.l = #LO($imm_value)",
4760 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4761 isAsmParserOnly = 1 in
4762 def HIi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
4763 "$dst.h = #HI($imm_value)",
4766 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4767 isAsmParserOnly = 1 in
4768 def LO_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4769 "$dst.l = #LO($jt)",
4772 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4773 isAsmParserOnly = 1 in
4774 def HI_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4775 "$dst.h = #HI($jt)",
4778 // This pattern is incorrect. When we add small data, we should change
4779 // this pattern to use memw(#foo).
4780 // This is for sdata.
4781 let isMoveImm = 1, isAsmParserOnly = 1 in
4782 def CONST32 : CONSTLDInst<(outs IntRegs:$dst), (ins globaladdress:$global),
4783 "$dst = CONST32(#$global)",
4784 [(set (i32 IntRegs:$dst),
4785 (load (HexagonCONST32 tglobaltlsaddr:$global)))]>;
4787 let isReMaterializable = 1, isMoveImm = 1 in
4788 def CONST32_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
4789 "$dst = CONST32(#$global)",
4790 [(set (i32 IntRegs:$dst),
4791 (HexagonCONST32 tglobaladdr:$global))]>;
4793 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4794 def CONST32_set_jt : CONSTLDInst<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4795 "$dst = CONST32(#$jt)",
4796 [(set (i32 IntRegs:$dst),
4797 (HexagonCONST32 tjumptable:$jt))]>;
4799 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4800 def CONST32GP_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
4801 "$dst = CONST32(#$global)",
4802 [(set (i32 IntRegs:$dst),
4803 (HexagonCONST32_GP tglobaladdr:$global))]>;
4805 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4806 def CONST32_Int_Real : CONSTLDInst<(outs IntRegs:$dst), (ins i32imm:$global),
4807 "$dst = CONST32(#$global)",
4808 [(set (i32 IntRegs:$dst), imm:$global) ]>;
4810 // Map BlockAddress lowering to CONST32_Int_Real
4811 def : Pat<(HexagonCONST32_GP tblockaddress:$addr),
4812 (CONST32_Int_Real tblockaddress:$addr)>;
4814 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4815 def CONST32_Label : LDInst2<(outs IntRegs:$dst), (ins bblabel:$label),
4816 "$dst = CONST32($label)",
4817 [(set (i32 IntRegs:$dst), (HexagonCONST32 bbl:$label))]>;
4819 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4820 def CONST64_Int_Real : CONSTLDInst<(outs DoubleRegs:$dst), (ins i64imm:$global),
4821 "$dst = CONST64(#$global)",
4822 [(set (i64 DoubleRegs:$dst), imm:$global)]>;
4824 let hasSideEffects = 0, isReMaterializable = 1, isPseudo = 1,
4825 isCodeGenOnly = 1 in
4826 def TFR_PdTrue : SInst<(outs PredRegs:$dst), (ins), "",
4827 [(set (i1 PredRegs:$dst), 1)]>;
4829 let hasSideEffects = 0, isReMaterializable = 1, isPseudo = 1,
4830 isCodeGenOnly = 1 in
4831 def TFR_PdFalse : SInst<(outs PredRegs:$dst), (ins), "$dst = xor($dst, $dst)",
4832 [(set (i1 PredRegs:$dst), 0)]>;
4834 // Pseudo instructions.
4835 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
4836 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
4837 SDTCisVT<1, i32> ]>;
4839 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
4840 [SDNPHasChain, SDNPOutGlue]>;
4841 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
4842 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
4844 def SDT_SPCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
4846 // For tailcalls a HexagonTCRet SDNode has 3 SDNode Properties - a chain,
4847 // Optional Flag and Variable Arguments.
4848 // Its 1 Operand has pointer type.
4849 def HexagonTCRet : SDNode<"HexagonISD::TC_RETURN", SDT_SPCall,
4850 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
4852 let Defs = [R29, R30], Uses = [R31, R30, R29], isPseudo = 1 in
4853 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
4854 ".error \"should not emit\" ",
4855 [(callseq_start timm:$amt)]>;
4857 let Defs = [R29, R30, R31], Uses = [R29], isPseudo = 1 in
4858 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
4859 ".error \"should not emit\" ",
4860 [(callseq_end timm:$amt1, timm:$amt2)]>;
4862 // Call subroutine indirectly.
4863 let Defs = VolatileV3.Regs in
4864 def J2_callr : JUMPR_MISC_CALLR<0, 1>;
4866 // Indirect tail-call.
4867 let isPseudo = 1, isCall = 1, isReturn = 1, isBarrier = 1, isPredicable = 0,
4868 isTerminator = 1, isCodeGenOnly = 1 in
4869 def TCRETURNr : T_JMPr;
4871 // Direct tail-calls.
4872 let isCall = 1, isReturn = 1, isBarrier = 1, isPredicable = 0,
4873 isTerminator = 1, isCodeGenOnly = 1 in {
4874 def TCRETURNtg : JInst<(outs), (ins calltarget:$dst), "jump $dst",
4875 [], "", J_tc_2early_SLOT23>;
4876 def TCRETURNtext : JInst<(outs), (ins calltarget:$dst), "jump $dst",
4877 [], "", J_tc_2early_SLOT23>;
4881 def: Pat<(HexagonTCRet tglobaladdr:$dst),
4882 (TCRETURNtg tglobaladdr:$dst)>;
4883 def: Pat<(HexagonTCRet texternalsym:$dst),
4884 (TCRETURNtext texternalsym:$dst)>;
4885 def: Pat<(HexagonTCRet (i32 IntRegs:$dst)),
4886 (TCRETURNr (i32 IntRegs:$dst))>;
4888 // Map from r0 = and(r1, 65535) to r0 = zxth(r1)
4889 def: Pat<(and (i32 IntRegs:$src1), 65535),
4890 (A2_zxth IntRegs:$src1)>;
4892 // Map from r0 = and(r1, 255) to r0 = zxtb(r1).
4893 def: Pat<(and (i32 IntRegs:$src1), 255),
4894 (A2_zxtb IntRegs:$src1)>;
4896 // Map Add(p1, true) to p1 = not(p1).
4897 // Add(p1, false) should never be produced,
4898 // if it does, it got to be mapped to NOOP.
4899 def: Pat<(add (i1 PredRegs:$src1), -1),
4900 (C2_not PredRegs:$src1)>;
4902 // Map from p0 = pnot(p0); r0 = mux(p0, #i, #j) => r0 = mux(p0, #j, #i).
4903 def: Pat<(select (not (i1 PredRegs:$src1)), s8ImmPred:$src2, s8ExtPred:$src3),
4904 (C2_muxii PredRegs:$src1, s8ExtPred:$src3, s8ImmPred:$src2)>;
4906 // Map from p0 = pnot(p0); r0 = select(p0, #i, r1)
4907 // => r0 = C2_muxir(p0, r1, #i)
4908 def: Pat<(select (not (i1 PredRegs:$src1)), s8ExtPred:$src2,
4909 (i32 IntRegs:$src3)),
4910 (C2_muxir PredRegs:$src1, IntRegs:$src3, s8ExtPred:$src2)>;
4912 // Map from p0 = pnot(p0); r0 = mux(p0, r1, #i)
4913 // => r0 = C2_muxri (p0, #i, r1)
4914 def: Pat<(select (not (i1 PredRegs:$src1)), IntRegs:$src2, s8ExtPred:$src3),
4915 (C2_muxri PredRegs:$src1, s8ExtPred:$src3, IntRegs:$src2)>;
4917 // Map from p0 = pnot(p0); if (p0) jump => if (!p0) jump.
4918 def: Pat<(brcond (not (i1 PredRegs:$src1)), bb:$offset),
4919 (J2_jumpf PredRegs:$src1, bb:$offset)>;
4921 // Map from Rdd = sign_extend_inreg(Rss, i32) -> Rdd = A2_sxtw(Rss.lo).
4922 def: Pat<(i64 (sext_inreg (i64 DoubleRegs:$src1), i32)),
4923 (A2_sxtw (LoReg DoubleRegs:$src1))>;
4925 // Map from Rdd = sign_extend_inreg(Rss, i16) -> Rdd = A2_sxtw(A2_sxth(Rss.lo)).
4926 def: Pat<(i64 (sext_inreg (i64 DoubleRegs:$src1), i16)),
4927 (A2_sxtw (A2_sxth (LoReg DoubleRegs:$src1)))>;
4929 // Map from Rdd = sign_extend_inreg(Rss, i8) -> Rdd = A2_sxtw(A2_sxtb(Rss.lo)).
4930 def: Pat<(i64 (sext_inreg (i64 DoubleRegs:$src1), i8)),
4931 (A2_sxtw (A2_sxtb (LoReg DoubleRegs:$src1)))>;
4933 // We want to prevent emitting pnot's as much as possible.
4934 // Map brcond with an unsupported setcc to a J2_jumpf.
4935 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4937 (J2_jumpf (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
4940 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), s10ImmPred:$src2)),
4942 (J2_jumpf (C2_cmpeqi (i32 IntRegs:$src1), s10ImmPred:$src2), bb:$offset)>;
4944 def: Pat<(brcond (i1 (setne (i1 PredRegs:$src1), (i1 -1))), bb:$offset),
4945 (J2_jumpf PredRegs:$src1, bb:$offset)>;
4947 def: Pat<(brcond (i1 (setne (i1 PredRegs:$src1), (i1 0))), bb:$offset),
4948 (J2_jumpt PredRegs:$src1, bb:$offset)>;
4950 // cmp.lt(Rs, Imm) -> !cmp.ge(Rs, Imm) -> !cmp.gt(Rs, Imm-1)
4951 def: Pat<(brcond (i1 (setlt (i32 IntRegs:$src1), s8ImmPred:$src2)), bb:$offset),
4952 (J2_jumpf (C2_cmpgti IntRegs:$src1, (DEC_CONST_SIGNED s8ImmPred:$src2)),
4955 // cmp.lt(r0, r1) -> cmp.gt(r1, r0)
4956 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4958 (J2_jumpt (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)), bb:$offset)>;
4960 def : Pat <(brcond (i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4962 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)),
4965 def : Pat <(brcond (i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4967 (J2_jumpf (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
4970 def : Pat <(brcond (i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4972 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
4975 // Map from a 64-bit select to an emulated 64-bit mux.
4976 // Hexagon does not support 64-bit MUXes; so emulate with combines.
4977 def: Pat<(select (i1 PredRegs:$src1), (i64 DoubleRegs:$src2),
4978 (i64 DoubleRegs:$src3)),
4979 (A2_combinew (C2_mux PredRegs:$src1, (HiReg DoubleRegs:$src2),
4980 (HiReg DoubleRegs:$src3)),
4981 (C2_mux PredRegs:$src1, (LoReg DoubleRegs:$src2),
4982 (LoReg DoubleRegs:$src3)))>;
4984 // Map from a 1-bit select to logical ops.
4985 // From LegalizeDAG.cpp: (B1 ? B2 : B3) <=> (B1 & B2)|(!B1&B3).
4986 def: Pat<(select (i1 PredRegs:$src1), (i1 PredRegs:$src2), (i1 PredRegs:$src3)),
4987 (C2_or (C2_and PredRegs:$src1, PredRegs:$src2),
4988 (C2_and (C2_not PredRegs:$src1), PredRegs:$src3))>;
4990 // Map Pd = load(addr) -> Rs = load(addr); Pd = Rs.
4991 def : Pat<(i1 (load ADDRriS11_2:$addr)),
4992 (i1 (C2_tfrrp (i32 (L2_loadrb_io AddrFI:$addr, 0))))>;
4994 // Map for truncating from 64 immediates to 32 bit immediates.
4995 def: Pat<(i32 (trunc (i64 DoubleRegs:$src))),
4996 (LoReg DoubleRegs:$src)>;
4998 // Map for truncating from i64 immediates to i1 bit immediates.
4999 def: Pat<(i1 (trunc (i64 DoubleRegs:$src))),
5000 (C2_tfrrp (LoReg DoubleRegs:$src))>;
5002 // Map memb(Rs) = Rdd -> memb(Rs) = Rt.
5003 def : Pat<(truncstorei8 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
5004 (S2_storerb_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
5007 // Map memh(Rs) = Rdd -> memh(Rs) = Rt.
5008 def : Pat<(truncstorei16 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
5009 (S2_storerh_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
5011 // Map memw(Rs) = Rdd -> memw(Rs) = Rt
5012 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
5013 (S2_storeri_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
5016 // Map memw(Rs) = Rdd -> memw(Rs) = Rt.
5017 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
5018 (S2_storeri_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
5021 // Map from i1 = constant<-1>; memw(addr) = i1 -> r0 = 1; memw(addr) = r0.
5022 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
5023 (S2_storerb_io AddrFI:$addr, 0, (A2_tfrsi 1))>;
5026 // Map from i1 = constant<-1>; store i1 -> r0 = 1; store r0.
5027 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
5028 (S2_storerb_io AddrFI:$addr, 0, (A2_tfrsi 1))>;
5030 // Map from memb(Rs) = Pd -> Rt = mux(Pd, #0, #1); store Rt.
5031 def : Pat<(store (i1 PredRegs:$src1), ADDRriS11_2:$addr),
5032 (S2_storerb_io AddrFI:$addr, 0, (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0)) )>;
5034 // rs <= rt -> !(rs > rt).
5035 let AddedComplexity = 30 in
5036 def: Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
5037 (C2_not (C2_cmpgti IntRegs:$src1, s10ExtPred:$src2))>;
5039 // rs <= rt -> !(rs > rt).
5040 def : Pat<(i1 (setle (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5041 (i1 (C2_not (C2_cmpgt (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
5043 // Rss <= Rtt -> !(Rss > Rtt).
5044 def: Pat<(i1 (setle (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5045 (C2_not (C2_cmpgtp DoubleRegs:$src1, DoubleRegs:$src2))>;
5047 // Map cmpne -> cmpeq.
5048 // Hexagon_TODO: We should improve on this.
5049 // rs != rt -> !(rs == rt).
5050 let AddedComplexity = 30 in
5051 def: Pat<(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
5052 (C2_not (C2_cmpeqi IntRegs:$src1, s10ExtPred:$src2))>;
5054 // Map cmpne(Rs) -> !cmpeqe(Rs).
5055 // rs != rt -> !(rs == rt).
5056 def : Pat <(i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5057 (i1 (C2_not (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)))))>;
5059 // Convert setne back to xor for hexagon since we compute w/ pred registers.
5060 def: Pat<(i1 (setne (i1 PredRegs:$src1), (i1 PredRegs:$src2))),
5061 (C2_xor PredRegs:$src1, PredRegs:$src2)>;
5063 // Map cmpne(Rss) -> !cmpew(Rss).
5064 // rs != rt -> !(rs == rt).
5065 def: Pat<(i1 (setne (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5066 (C2_not (C2_cmpeqp DoubleRegs:$src1, DoubleRegs:$src2))>;
5068 // Map cmpge(Rs, Rt) -> !(cmpgt(Rs, Rt).
5069 // rs >= rt -> !(rt > rs).
5070 def : Pat <(i1 (setge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
5071 (i1 (C2_not (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))))>;
5073 // cmpge(Rs, Imm) -> cmpgt(Rs, Imm-1)
5074 let AddedComplexity = 30 in
5075 def: Pat<(i1 (setge (i32 IntRegs:$src1), s8ExtPred:$src2)),
5076 (C2_cmpgti IntRegs:$src1, (DEC_CONST_SIGNED s8ExtPred:$src2))>;
5078 // Map cmpge(Rss, Rtt) -> !cmpgt(Rtt, Rss).
5079 // rss >= rtt -> !(rtt > rss).
5080 def: Pat<(i1 (setge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5081 (C2_not (C2_cmpgtp DoubleRegs:$src2, DoubleRegs:$src1))>;
5083 // Map cmplt(Rs, Imm) -> !cmpge(Rs, Imm).
5084 // !cmpge(Rs, Imm) -> !cmpgt(Rs, Imm-1).
5085 // rs < rt -> !(rs >= rt).
5086 let AddedComplexity = 30 in
5087 def: Pat<(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
5088 (C2_not (C2_cmpgti IntRegs:$src1, (DEC_CONST_SIGNED s8ExtPred:$src2)))>;
5090 // Generate cmpgeu(Rs, #0) -> cmpeq(Rs, Rs)
5091 def: Pat<(i1 (setuge (i32 IntRegs:$src1), 0)),
5092 (C2_cmpeq IntRegs:$src1, IntRegs:$src1)>;
5094 // Generate cmpgeu(Rs, #u8) -> cmpgtu(Rs, #u8 -1)
5095 def: Pat<(i1 (setuge (i32 IntRegs:$src1), u8ExtPred:$src2)),
5096 (C2_cmpgtui IntRegs:$src1, (DEC_CONST_UNSIGNED u8ExtPred:$src2))>;
5098 // Generate cmpgtu(Rs, #u9)
5099 def: Pat<(i1 (setugt (i32 IntRegs:$src1), u9ExtPred:$src2)),
5100 (C2_cmpgtui IntRegs:$src1, u9ExtPred:$src2)>;
5102 // Map from Rs >= Rt -> !(Rt > Rs).
5103 // rs >= rt -> !(rt > rs).
5104 def: Pat<(i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5105 (C2_not (C2_cmpgtup DoubleRegs:$src2, DoubleRegs:$src1))>;
5107 // Map from cmpleu(Rss, Rtt) -> !cmpgtu(Rss, Rtt-1).
5108 // Map from (Rs <= Rt) -> !(Rs > Rt).
5109 def: Pat<(i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
5110 (C2_not (C2_cmpgtup DoubleRegs:$src1, DoubleRegs:$src2))>;
5114 def: Pat<(i32 (sext (i1 PredRegs:$src1))),
5115 (C2_muxii PredRegs:$src1, -1, 0)>;
5118 def: Pat<(i64 (sext (i1 PredRegs:$src1))),
5119 (A2_combinew (A2_tfrsi -1), (C2_muxii PredRegs:$src1, -1, 0))>;
5121 // Convert sign-extended load back to load and sign extend.
5123 def: Pat <(i64 (sextloadi32 ADDRriS11_2:$src1)),
5124 (i64 (A2_sxtw (L2_loadri_io AddrFI:$src1, 0)))>;
5128 def: Pat<(i32 (zext (i1 PredRegs:$src1))),
5129 (C2_muxii PredRegs:$src1, 1, 0)>;
5131 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
5132 def: Pat<(i32 (anyext (i1 PredRegs:$src1))),
5133 (C2_muxii PredRegs:$src1, 1, 0)>;
5135 // Map from Rss = Pd to Rdd = sxtw (mux(Pd, #1, #0))
5136 def: Pat<(i64 (anyext (i1 PredRegs:$src1))),
5137 (A2_sxtw (C2_muxii PredRegs:$src1, 1, 0))>;
5139 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5141 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
5142 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5143 (L2_loadri_io AddrFI:$srcLow, 0)))>;
5145 // Multiply 64-bit unsigned and use upper result.
5146 def : Pat <(mulhu (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
5152 (S2_lsr_i_p (M2_dpmpyuu_s0 (LoReg $src1), (LoReg $src2)), 32),
5155 (A2_combinew (A2_tfrsi 0),
5156 (LoReg (M2_dpmpyuu_s0 (LoReg $src1), (HiReg $src2))))),
5160 (S2_lsr_i_p (M2_dpmpyuu_s0 (LoReg $src1), (HiReg $src2)), 32)
5163 // Hexagon specific ISD nodes.
5164 def SDTHexagonADJDYNALLOC : SDTypeProfile<1, 2, [SDTCisVT<0, i32>,
5166 def SDTHexagonARGEXTEND : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
5168 def Hexagon_ADJDYNALLOC : SDNode<"HexagonISD::ADJDYNALLOC",
5169 SDTHexagonADJDYNALLOC>;
5170 def Hexagon_ARGEXTEND : SDNode<"HexagonISD::ARGEXTEND", SDTHexagonARGEXTEND>;
5172 // Needed to tag these instructions for stack layout.
5173 let isCodeGenOnly = 1, usesCustomInserter = 1 in
5174 def ADJDYNALLOC : T_Addri<s6Imm>;
5176 def: Pat<(Hexagon_ADJDYNALLOC I32:$Rs, s16ImmPred:$s16),
5177 (ADJDYNALLOC I32:$Rs, imm:$s16)>;
5179 let isCodeGenOnly = 1 in
5180 def ARGEXTEND : ALU32_rr <(outs IntRegs:$dst), (ins IntRegs:$src1),
5182 [(set (i32 IntRegs:$dst),
5183 (Hexagon_ARGEXTEND (i32 IntRegs:$src1)))]>;
5185 let AddedComplexity = 100 in
5186 def: Pat<(i32 (sext_inreg (Hexagon_ARGEXTEND (i32 IntRegs:$src1)), i16)),
5187 (i32 IntRegs:$src1)>;
5189 def HexagonWrapperJT: SDNode<"HexagonISD::WrapperJT", SDTIntUnaryOp>;
5191 def : Pat<(HexagonWrapperJT tjumptable:$dst),
5192 (i32 (CONST32_set_jt tjumptable:$dst))>;
5196 //===----------------------------------------------------------------------===//
5198 // Shift by immediate/register and accumulate/logical
5199 //===----------------------------------------------------------------------===//
5201 // Rx[+-&|]=asr(Rs,#u5)
5202 // Rx[+-&|^]=lsr(Rs,#u5)
5203 // Rx[+-&|^]=asl(Rs,#u5)
5205 let hasNewValue = 1, opNewValue = 0 in
5206 class T_shift_imm_acc_r <string opc1, string opc2, SDNode OpNode1,
5207 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5208 : SInst_acc<(outs IntRegs:$Rx),
5209 (ins IntRegs:$src1, IntRegs:$Rs, u5Imm:$u5),
5210 "$Rx "#opc2#opc1#"($Rs, #$u5)",
5211 [(set (i32 IntRegs:$Rx),
5212 (OpNode2 (i32 IntRegs:$src1),
5213 (OpNode1 (i32 IntRegs:$Rs), u5ImmPred:$u5)))],
5214 "$src1 = $Rx", S_2op_tc_2_SLOT23> {
5219 let IClass = 0b1000;
5221 let Inst{27-24} = 0b1110;
5222 let Inst{23-22} = majOp{2-1};
5224 let Inst{7} = majOp{0};
5225 let Inst{6-5} = minOp;
5227 let Inst{20-16} = Rs;
5228 let Inst{12-8} = u5;
5231 // Rx[+-&|]=asr(Rs,Rt)
5232 // Rx[+-&|^]=lsr(Rs,Rt)
5233 // Rx[+-&|^]=asl(Rs,Rt)
5235 let hasNewValue = 1, opNewValue = 0 in
5236 class T_shift_reg_acc_r <string opc1, string opc2, SDNode OpNode1,
5237 SDNode OpNode2, bits<2> majOp, bits<2> minOp>
5238 : SInst_acc<(outs IntRegs:$Rx),
5239 (ins IntRegs:$src1, IntRegs:$Rs, IntRegs:$Rt),
5240 "$Rx "#opc2#opc1#"($Rs, $Rt)",
5241 [(set (i32 IntRegs:$Rx),
5242 (OpNode2 (i32 IntRegs:$src1),
5243 (OpNode1 (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))],
5244 "$src1 = $Rx", S_3op_tc_2_SLOT23 > {
5249 let IClass = 0b1100;
5251 let Inst{27-24} = 0b1100;
5252 let Inst{23-22} = majOp;
5253 let Inst{7-6} = minOp;
5255 let Inst{20-16} = Rs;
5256 let Inst{12-8} = Rt;
5259 // Rxx[+-&|]=asr(Rss,#u6)
5260 // Rxx[+-&|^]=lsr(Rss,#u6)
5261 // Rxx[+-&|^]=asl(Rss,#u6)
5263 class T_shift_imm_acc_p <string opc1, string opc2, SDNode OpNode1,
5264 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5265 : SInst_acc<(outs DoubleRegs:$Rxx),
5266 (ins DoubleRegs:$src1, DoubleRegs:$Rss, u6Imm:$u6),
5267 "$Rxx "#opc2#opc1#"($Rss, #$u6)",
5268 [(set (i64 DoubleRegs:$Rxx),
5269 (OpNode2 (i64 DoubleRegs:$src1),
5270 (OpNode1 (i64 DoubleRegs:$Rss), u6ImmPred:$u6)))],
5271 "$src1 = $Rxx", S_2op_tc_2_SLOT23> {
5276 let IClass = 0b1000;
5278 let Inst{27-24} = 0b0010;
5279 let Inst{23-22} = majOp{2-1};
5280 let Inst{7} = majOp{0};
5281 let Inst{6-5} = minOp;
5282 let Inst{4-0} = Rxx;
5283 let Inst{20-16} = Rss;
5284 let Inst{13-8} = u6;
5288 // Rxx[+-&|]=asr(Rss,Rt)
5289 // Rxx[+-&|^]=lsr(Rss,Rt)
5290 // Rxx[+-&|^]=asl(Rss,Rt)
5291 // Rxx[+-&|^]=lsl(Rss,Rt)
5293 class T_shift_reg_acc_p <string opc1, string opc2, SDNode OpNode1,
5294 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5295 : SInst_acc<(outs DoubleRegs:$Rxx),
5296 (ins DoubleRegs:$src1, DoubleRegs:$Rss, IntRegs:$Rt),
5297 "$Rxx "#opc2#opc1#"($Rss, $Rt)",
5298 [(set (i64 DoubleRegs:$Rxx),
5299 (OpNode2 (i64 DoubleRegs:$src1),
5300 (OpNode1 (i64 DoubleRegs:$Rss), (i32 IntRegs:$Rt))))],
5301 "$src1 = $Rxx", S_3op_tc_2_SLOT23> {
5306 let IClass = 0b1100;
5308 let Inst{27-24} = 0b1011;
5309 let Inst{23-21} = majOp;
5310 let Inst{20-16} = Rss;
5311 let Inst{12-8} = Rt;
5312 let Inst{7-6} = minOp;
5313 let Inst{4-0} = Rxx;
5316 //===----------------------------------------------------------------------===//
5317 // Multi-class for the shift instructions with logical/arithmetic operators.
5318 //===----------------------------------------------------------------------===//
5320 multiclass xtype_imm_base<string OpcStr1, string OpcStr2, SDNode OpNode1,
5321 SDNode OpNode2, bits<3> majOp, bits<2> minOp > {
5322 def _i_r#NAME : T_shift_imm_acc_r< OpcStr1, OpcStr2, OpNode1,
5323 OpNode2, majOp, minOp >;
5324 def _i_p#NAME : T_shift_imm_acc_p< OpcStr1, OpcStr2, OpNode1,
5325 OpNode2, majOp, minOp >;
5328 multiclass xtype_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
5329 let AddedComplexity = 100 in
5330 defm _acc : xtype_imm_base< opc1, "+= ", OpNode, add, 0b001, minOp>;
5332 defm _nac : xtype_imm_base< opc1, "-= ", OpNode, sub, 0b000, minOp>;
5333 defm _and : xtype_imm_base< opc1, "&= ", OpNode, and, 0b010, minOp>;
5334 defm _or : xtype_imm_base< opc1, "|= ", OpNode, or, 0b011, minOp>;
5337 multiclass xtype_xor_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
5338 let AddedComplexity = 100 in
5339 defm _xacc : xtype_imm_base< opc1, "^= ", OpNode, xor, 0b100, minOp>;
5342 defm S2_asr : xtype_imm_acc<"asr", sra, 0b00>;
5344 defm S2_lsr : xtype_imm_acc<"lsr", srl, 0b01>,
5345 xtype_xor_imm_acc<"lsr", srl, 0b01>;
5347 defm S2_asl : xtype_imm_acc<"asl", shl, 0b10>,
5348 xtype_xor_imm_acc<"asl", shl, 0b10>;
5350 multiclass xtype_reg_acc_r<string opc1, SDNode OpNode, bits<2>minOp> {
5351 let AddedComplexity = 100 in
5352 def _acc : T_shift_reg_acc_r <opc1, "+= ", OpNode, add, 0b11, minOp>;
5354 def _nac : T_shift_reg_acc_r <opc1, "-= ", OpNode, sub, 0b10, minOp>;
5355 def _and : T_shift_reg_acc_r <opc1, "&= ", OpNode, and, 0b01, minOp>;
5356 def _or : T_shift_reg_acc_r <opc1, "|= ", OpNode, or, 0b00, minOp>;
5359 multiclass xtype_reg_acc_p<string opc1, SDNode OpNode, bits<2>minOp> {
5360 let AddedComplexity = 100 in
5361 def _acc : T_shift_reg_acc_p <opc1, "+= ", OpNode, add, 0b110, minOp>;
5363 def _nac : T_shift_reg_acc_p <opc1, "-= ", OpNode, sub, 0b100, minOp>;
5364 def _and : T_shift_reg_acc_p <opc1, "&= ", OpNode, and, 0b010, minOp>;
5365 def _or : T_shift_reg_acc_p <opc1, "|= ", OpNode, or, 0b000, minOp>;
5366 def _xor : T_shift_reg_acc_p <opc1, "^= ", OpNode, xor, 0b011, minOp>;
5369 multiclass xtype_reg_acc<string OpcStr, SDNode OpNode, bits<2> minOp > {
5370 defm _r_r : xtype_reg_acc_r <OpcStr, OpNode, minOp>;
5371 defm _r_p : xtype_reg_acc_p <OpcStr, OpNode, minOp>;
5374 defm S2_asl : xtype_reg_acc<"asl", shl, 0b10>;
5375 defm S2_asr : xtype_reg_acc<"asr", sra, 0b00>;
5376 defm S2_lsr : xtype_reg_acc<"lsr", srl, 0b01>;
5377 defm S2_lsl : xtype_reg_acc<"lsl", shl, 0b11>;
5379 //===----------------------------------------------------------------------===//
5380 let hasSideEffects = 0 in
5381 class T_S3op_1 <string mnemonic, RegisterClass RC, bits<2> MajOp, bits<3> MinOp,
5382 bit SwapOps, bit isSat = 0, bit isRnd = 0, bit hasShift = 0>
5383 : SInst <(outs RC:$dst),
5384 (ins DoubleRegs:$src1, DoubleRegs:$src2),
5385 "$dst = "#mnemonic#"($src1, $src2)"#!if(isRnd, ":rnd", "")
5386 #!if(hasShift,":>>1","")
5387 #!if(isSat, ":sat", ""),
5388 [], "", S_3op_tc_2_SLOT23 > {
5393 let IClass = 0b1100;
5395 let Inst{27-24} = 0b0001;
5396 let Inst{23-22} = MajOp;
5397 let Inst{20-16} = !if (SwapOps, src2, src1);
5398 let Inst{12-8} = !if (SwapOps, src1, src2);
5399 let Inst{7-5} = MinOp;
5400 let Inst{4-0} = dst;
5403 class T_S3op_64 <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit SwapOps,
5404 bit isSat = 0, bit isRnd = 0, bit hasShift = 0 >
5405 : T_S3op_1 <mnemonic, DoubleRegs, MajOp, MinOp, SwapOps,
5406 isSat, isRnd, hasShift>;
5408 let Itinerary = S_3op_tc_1_SLOT23 in {
5409 def S2_shuffeb : T_S3op_64 < "shuffeb", 0b00, 0b010, 0>;
5410 def S2_shuffeh : T_S3op_64 < "shuffeh", 0b00, 0b110, 0>;
5411 def S2_shuffob : T_S3op_64 < "shuffob", 0b00, 0b100, 1>;
5412 def S2_shuffoh : T_S3op_64 < "shuffoh", 0b10, 0b000, 1>;
5414 def S2_vtrunewh : T_S3op_64 < "vtrunewh", 0b10, 0b010, 0>;
5415 def S2_vtrunowh : T_S3op_64 < "vtrunowh", 0b10, 0b100, 0>;
5418 def S2_lfsp : T_S3op_64 < "lfs", 0b10, 0b110, 0>;
5420 let hasSideEffects = 0 in
5421 class T_S3op_2 <string mnemonic, bits<3> MajOp, bit SwapOps>
5422 : SInst < (outs DoubleRegs:$Rdd),
5423 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
5424 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu)",
5425 [], "", S_3op_tc_1_SLOT23 > {
5431 let IClass = 0b1100;
5433 let Inst{27-24} = 0b0010;
5434 let Inst{23-21} = MajOp;
5435 let Inst{20-16} = !if (SwapOps, Rtt, Rss);
5436 let Inst{12-8} = !if (SwapOps, Rss, Rtt);
5438 let Inst{4-0} = Rdd;
5441 def S2_valignrb : T_S3op_2 < "valignb", 0b000, 1>;
5442 def S2_vsplicerb : T_S3op_2 < "vspliceb", 0b100, 0>;
5444 //===----------------------------------------------------------------------===//
5445 // Template class used by vector shift, vector rotate, vector neg,
5446 // 32-bit shift, 64-bit shifts, etc.
5447 //===----------------------------------------------------------------------===//
5449 let hasSideEffects = 0 in
5450 class T_S3op_3 <string mnemonic, RegisterClass RC, bits<2> MajOp,
5451 bits<2> MinOp, bit isSat = 0, list<dag> pattern = [] >
5452 : SInst <(outs RC:$dst),
5453 (ins RC:$src1, IntRegs:$src2),
5454 "$dst = "#mnemonic#"($src1, $src2)"#!if(isSat, ":sat", ""),
5455 pattern, "", S_3op_tc_1_SLOT23> {
5460 let IClass = 0b1100;
5462 let Inst{27-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b0110, 0b0011);
5463 let Inst{23-22} = MajOp;
5464 let Inst{20-16} = src1;
5465 let Inst{12-8} = src2;
5466 let Inst{7-6} = MinOp;
5467 let Inst{4-0} = dst;
5470 let hasNewValue = 1 in
5471 class T_S3op_shift32 <string mnemonic, SDNode OpNode, bits<2> MinOp>
5472 : T_S3op_3 <mnemonic, IntRegs, 0b01, MinOp, 0,
5473 [(set (i32 IntRegs:$dst), (OpNode (i32 IntRegs:$src1),
5474 (i32 IntRegs:$src2)))]>;
5476 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in
5477 class T_S3op_shift32_Sat <string mnemonic, bits<2> MinOp>
5478 : T_S3op_3 <mnemonic, IntRegs, 0b00, MinOp, 1, []>;
5481 class T_S3op_shift64 <string mnemonic, SDNode OpNode, bits<2> MinOp>
5482 : T_S3op_3 <mnemonic, DoubleRegs, 0b10, MinOp, 0,
5483 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
5484 (i32 IntRegs:$src2)))]>;
5487 class T_S3op_shiftVect <string mnemonic, bits<2> MajOp, bits<2> MinOp>
5488 : T_S3op_3 <mnemonic, DoubleRegs, MajOp, MinOp, 0, []>;
5491 // Shift by register
5492 // Rdd=[asr|lsr|asl|lsl](Rss,Rt)
5494 def S2_asr_r_p : T_S3op_shift64 < "asr", sra, 0b00>;
5495 def S2_lsr_r_p : T_S3op_shift64 < "lsr", srl, 0b01>;
5496 def S2_asl_r_p : T_S3op_shift64 < "asl", shl, 0b10>;
5497 def S2_lsl_r_p : T_S3op_shift64 < "lsl", shl, 0b11>;
5499 // Rd=[asr|lsr|asl|lsl](Rs,Rt)
5501 def S2_asr_r_r : T_S3op_shift32<"asr", sra, 0b00>;
5502 def S2_lsr_r_r : T_S3op_shift32<"lsr", srl, 0b01>;
5503 def S2_asl_r_r : T_S3op_shift32<"asl", shl, 0b10>;
5504 def S2_lsl_r_r : T_S3op_shift32<"lsl", shl, 0b11>;
5506 // Shift by register with saturation
5507 // Rd=asr(Rs,Rt):sat
5508 // Rd=asl(Rs,Rt):sat
5510 let Defs = [USR_OVF] in {
5511 def S2_asr_r_r_sat : T_S3op_shift32_Sat<"asr", 0b00>;
5512 def S2_asl_r_r_sat : T_S3op_shift32_Sat<"asl", 0b10>;
5515 let hasNewValue = 1, hasSideEffects = 0 in
5516 class T_S3op_8 <string opc, bits<3> MinOp, bit isSat, bit isRnd, bit hasShift, bit hasSplat = 0>
5517 : SInst < (outs IntRegs:$Rd),
5518 (ins DoubleRegs:$Rss, IntRegs:$Rt),
5519 "$Rd = "#opc#"($Rss, $Rt"#!if(hasSplat, "*", "")#")"
5520 #!if(hasShift, ":<<1", "")
5521 #!if(isRnd, ":rnd", "")
5522 #!if(isSat, ":sat", ""),
5523 [], "", S_3op_tc_1_SLOT23 > {
5528 let IClass = 0b1100;
5530 let Inst{27-24} = 0b0101;
5531 let Inst{20-16} = Rss;
5532 let Inst{12-8} = Rt;
5533 let Inst{7-5} = MinOp;
5537 def S2_asr_r_svw_trun : T_S3op_8<"vasrw", 0b010, 0, 0, 0>;
5539 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
5540 def S2_vcrotate : T_S3op_shiftVect < "vcrotate", 0b11, 0b00>;
5542 let hasSideEffects = 0 in
5543 class T_S3op_7 <string mnemonic, bit MajOp >
5544 : SInst <(outs DoubleRegs:$Rdd),
5545 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, u3Imm:$u3),
5546 "$Rdd = "#mnemonic#"($Rss, $Rtt, #$u3)" ,
5547 [], "", S_3op_tc_1_SLOT23 > {
5553 let IClass = 0b1100;
5555 let Inst{27-24} = 0b0000;
5556 let Inst{23} = MajOp;
5557 let Inst{20-16} = !if(MajOp, Rss, Rtt);
5558 let Inst{12-8} = !if(MajOp, Rtt, Rss);
5560 let Inst{4-0} = Rdd;
5563 def S2_valignib : T_S3op_7 < "valignb", 0>;
5564 def S2_vspliceib : T_S3op_7 < "vspliceb", 1>;
5566 //===----------------------------------------------------------------------===//
5567 // Template class for 'insert bitfield' instructions
5568 //===----------------------------------------------------------------------===//
5569 let hasSideEffects = 0 in
5570 class T_S3op_insert <string mnemonic, RegisterClass RC>
5571 : SInst <(outs RC:$dst),
5572 (ins RC:$src1, RC:$src2, DoubleRegs:$src3),
5573 "$dst = "#mnemonic#"($src2, $src3)" ,
5574 [], "$src1 = $dst", S_3op_tc_1_SLOT23 > {
5579 let IClass = 0b1100;
5581 let Inst{27-26} = 0b10;
5582 let Inst{25-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b00, 0b10);
5584 let Inst{20-16} = src2;
5585 let Inst{12-8} = src3;
5586 let Inst{4-0} = dst;
5589 let hasSideEffects = 0 in
5590 class T_S2op_insert <bits<4> RegTyBits, RegisterClass RC, Operand ImmOp>
5591 : SInst <(outs RC:$dst), (ins RC:$dst2, RC:$src1, ImmOp:$src2, ImmOp:$src3),
5592 "$dst = insert($src1, #$src2, #$src3)",
5593 [], "$dst2 = $dst", S_2op_tc_2_SLOT23> {
5600 string ImmOpStr = !cast<string>(ImmOp);
5602 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5}, 0);
5603 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
5605 let IClass = 0b1000;
5607 let Inst{27-24} = RegTyBits;
5608 let Inst{23} = bit23;
5609 let Inst{22-21} = src3{4-3};
5610 let Inst{20-16} = src1;
5611 let Inst{13} = bit13;
5612 let Inst{12-8} = src2{4-0};
5613 let Inst{7-5} = src3{2-0};
5614 let Inst{4-0} = dst;
5617 // Rx=insert(Rs,Rtt)
5618 // Rx=insert(Rs,#u5,#U5)
5619 let hasNewValue = 1 in {
5620 def S2_insert_rp : T_S3op_insert <"insert", IntRegs>;
5621 def S2_insert : T_S2op_insert <0b1111, IntRegs, u5Imm>;
5624 // Rxx=insert(Rss,Rtt)
5625 // Rxx=insert(Rss,#u6,#U6)
5626 def S2_insertp_rp : T_S3op_insert<"insert", DoubleRegs>;
5627 def S2_insertp : T_S2op_insert <0b0011, DoubleRegs, u6Imm>;
5629 //===----------------------------------------------------------------------===//
5630 // Template class for 'extract bitfield' instructions
5631 //===----------------------------------------------------------------------===//
5632 let hasNewValue = 1, hasSideEffects = 0 in
5633 class T_S3op_extract <string mnemonic, bits<2> MinOp>
5634 : SInst <(outs IntRegs:$Rd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
5635 "$Rd = "#mnemonic#"($Rs, $Rtt)",
5636 [], "", S_3op_tc_2_SLOT23 > {
5641 let IClass = 0b1100;
5643 let Inst{27-22} = 0b100100;
5644 let Inst{20-16} = Rs;
5645 let Inst{12-8} = Rtt;
5646 let Inst{7-6} = MinOp;
5650 let hasSideEffects = 0 in
5651 class T_S2op_extract <string mnemonic, bits<4> RegTyBits,
5652 RegisterClass RC, Operand ImmOp>
5653 : SInst <(outs RC:$dst), (ins RC:$src1, ImmOp:$src2, ImmOp:$src3),
5654 "$dst = "#mnemonic#"($src1, #$src2, #$src3)",
5655 [], "", S_2op_tc_2_SLOT23> {
5662 string ImmOpStr = !cast<string>(ImmOp);
5664 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5},
5665 !if (!eq(mnemonic, "extractu"), 0, 1));
5667 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
5669 let IClass = 0b1000;
5671 let Inst{27-24} = RegTyBits;
5672 let Inst{23} = bit23;
5673 let Inst{22-21} = src3{4-3};
5674 let Inst{20-16} = src1;
5675 let Inst{13} = bit13;
5676 let Inst{12-8} = src2{4-0};
5677 let Inst{7-5} = src3{2-0};
5678 let Inst{4-0} = dst;
5683 // Rdd=extractu(Rss,Rtt)
5684 // Rdd=extractu(Rss,#u6,#U6)
5685 def S2_extractup_rp : T_S3op_64 < "extractu", 0b00, 0b000, 0>;
5686 def S2_extractup : T_S2op_extract <"extractu", 0b0001, DoubleRegs, u6Imm>;
5688 // Rd=extractu(Rs,Rtt)
5689 // Rd=extractu(Rs,#u5,#U5)
5690 let hasNewValue = 1 in {
5691 def S2_extractu_rp : T_S3op_extract<"extractu", 0b00>;
5692 def S2_extractu : T_S2op_extract <"extractu", 0b1101, IntRegs, u5Imm>;
5695 // Change the sign of the immediate for Rd=-mpyi(Rs,#u8)
5696 def: Pat<(mul (i32 IntRegs:$src1), (ineg n8ImmPred:$src2)),
5697 (M2_mpysin IntRegs:$src1, u8ImmPred:$src2)>;
5699 //===----------------------------------------------------------------------===//
5700 // :raw for of tableindx[bdhw] insns
5701 //===----------------------------------------------------------------------===//
5703 let hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
5704 class tableidxRaw<string OpStr, bits<2>MinOp>
5705 : SInst <(outs IntRegs:$Rx),
5706 (ins IntRegs:$_dst_, IntRegs:$Rs, u4Imm:$u4, s6Imm:$S6),
5707 "$Rx = "#OpStr#"($Rs, #$u4, #$S6):raw",
5708 [], "$Rx = $_dst_" > {
5714 let IClass = 0b1000;
5716 let Inst{27-24} = 0b0111;
5717 let Inst{23-22} = MinOp;
5718 let Inst{21} = u4{3};
5719 let Inst{20-16} = Rs;
5720 let Inst{13-8} = S6;
5721 let Inst{7-5} = u4{2-0};
5725 def S2_tableidxb : tableidxRaw<"tableidxb", 0b00>;
5726 def S2_tableidxh : tableidxRaw<"tableidxh", 0b01>;
5727 def S2_tableidxw : tableidxRaw<"tableidxw", 0b10>;
5728 def S2_tableidxd : tableidxRaw<"tableidxd", 0b11>;
5730 //===----------------------------------------------------------------------===//
5731 // V3 Instructions +
5732 //===----------------------------------------------------------------------===//
5734 include "HexagonInstrInfoV3.td"
5736 //===----------------------------------------------------------------------===//
5737 // V3 Instructions -
5738 //===----------------------------------------------------------------------===//
5740 //===----------------------------------------------------------------------===//
5741 // V4 Instructions +
5742 //===----------------------------------------------------------------------===//
5744 include "HexagonInstrInfoV4.td"
5746 //===----------------------------------------------------------------------===//
5747 // V4 Instructions -
5748 //===----------------------------------------------------------------------===//
5750 //===----------------------------------------------------------------------===//
5751 // V5 Instructions +
5752 //===----------------------------------------------------------------------===//
5754 include "HexagonInstrInfoV5.td"
5756 //===----------------------------------------------------------------------===//
5757 // V5 Instructions -
5758 //===----------------------------------------------------------------------===//
5760 //===----------------------------------------------------------------------===//
5761 // ALU32/64/Vector +
5762 //===----------------------------------------------------------------------===///
5764 include "HexagonInstrInfoVector.td"