1 //==- HexagonInstrInfo.td - Target Description for Hexagon -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the Hexagon instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 include "HexagonInstrFormats.td"
15 include "HexagonOperands.td"
17 // Pattern fragment that combines the value type and the register class
18 // into a single parameter.
19 // The pat frags in the definitions below need to have a named register,
20 // otherwise i32 will be assumed regardless of the register class. The
21 // name of the register does not matter.
22 def I1 : PatLeaf<(i1 PredRegs:$R)>;
23 def I32 : PatLeaf<(i32 IntRegs:$R)>;
24 def I64 : PatLeaf<(i64 DoubleRegs:$R)>;
25 def F32 : PatLeaf<(f32 IntRegs:$R)>;
26 def F64 : PatLeaf<(f64 DoubleRegs:$R)>;
28 // Pattern fragments to extract the low and high subregisters from a
30 def LoReg: OutPatFrag<(ops node:$Rs),
31 (EXTRACT_SUBREG (i64 $Rs), subreg_loreg)>;
32 def HiReg: OutPatFrag<(ops node:$Rs),
33 (EXTRACT_SUBREG (i64 $Rs), subreg_hireg)>;
35 // SDNode for converting immediate C to C-1.
36 def DEC_CONST_SIGNED : SDNodeXForm<imm, [{
37 // Return the byte immediate const-1 as an SDNode.
38 int32_t imm = N->getSExtValue();
39 return XformSToSM1Imm(imm);
42 // SDNode for converting immediate C to C-2.
43 def DEC2_CONST_SIGNED : SDNodeXForm<imm, [{
44 // Return the byte immediate const-2 as an SDNode.
45 int32_t imm = N->getSExtValue();
46 return XformSToSM2Imm(imm);
49 // SDNode for converting immediate C to C-3.
50 def DEC3_CONST_SIGNED : SDNodeXForm<imm, [{
51 // Return the byte immediate const-3 as an SDNode.
52 int32_t imm = N->getSExtValue();
53 return XformSToSM3Imm(imm);
56 // SDNode for converting immediate C to C-1.
57 def DEC_CONST_UNSIGNED : SDNodeXForm<imm, [{
58 // Return the byte immediate const-1 as an SDNode.
59 uint32_t imm = N->getZExtValue();
60 return XformUToUM1Imm(imm);
63 //===----------------------------------------------------------------------===//
65 //===----------------------------------------------------------------------===//
67 //===----------------------------------------------------------------------===//
68 let hasSideEffects = 0, isCompare = 1, InputType = "imm", isExtendable = 1,
70 class T_CMP <string mnemonic, bits<2> MajOp, bit isNot, Operand ImmOp>
71 : ALU32Inst <(outs PredRegs:$dst),
72 (ins IntRegs:$src1, ImmOp:$src2),
73 "$dst = "#!if(isNot, "!","")#mnemonic#"($src1, #$src2)",
74 [], "",ALU32_2op_tc_2early_SLOT0123 >, ImmRegRel {
78 let CextOpcode = mnemonic;
79 let opExtentBits = !if(!eq(mnemonic, "cmp.gtu"), 9, 10);
80 let isExtentSigned = !if(!eq(mnemonic, "cmp.gtu"), 0, 1);
84 let Inst{27-24} = 0b0101;
85 let Inst{23-22} = MajOp;
86 let Inst{21} = !if(!eq(mnemonic, "cmp.gtu"), 0, src2{9});
87 let Inst{20-16} = src1;
88 let Inst{13-5} = src2{8-0};
94 def C2_cmpeqi : T_CMP <"cmp.eq", 0b00, 0, s10Ext>;
95 def C2_cmpgti : T_CMP <"cmp.gt", 0b01, 0, s10Ext>;
96 def C2_cmpgtui : T_CMP <"cmp.gtu", 0b10, 0, u9Ext>;
98 class T_CMP_pat <InstHexagon MI, PatFrag OpNode, PatLeaf ImmPred>
99 : Pat<(i1 (OpNode (i32 IntRegs:$src1), ImmPred:$src2)),
100 (MI IntRegs:$src1, ImmPred:$src2)>;
102 def : T_CMP_pat <C2_cmpeqi, seteq, s10ImmPred>;
103 def : T_CMP_pat <C2_cmpgti, setgt, s10ImmPred>;
104 def : T_CMP_pat <C2_cmpgtui, setugt, u9ImmPred>;
106 //===----------------------------------------------------------------------===//
108 //===----------------------------------------------------------------------===//
109 def SDTHexagonI64I32I32 : SDTypeProfile<1, 2,
110 [SDTCisVT<0, i64>, SDTCisVT<1, i32>, SDTCisSameAs<1, 2>]>;
112 def HexagonCOMBINE : SDNode<"HexagonISD::COMBINE", SDTHexagonI64I32I32>;
114 let hasSideEffects = 0, hasNewValue = 1, InputType = "reg" in
115 class T_ALU32_3op<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit OpsRev,
117 : ALU32_rr<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
118 "$Rd = "#mnemonic#"($Rs, $Rt)",
119 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredRel {
120 let isCommutable = IsComm;
121 let BaseOpcode = mnemonic#_rr;
122 let CextOpcode = mnemonic;
130 let Inst{26-24} = MajOp;
131 let Inst{23-21} = MinOp;
132 let Inst{20-16} = !if(OpsRev,Rt,Rs);
133 let Inst{12-8} = !if(OpsRev,Rs,Rt);
137 let hasSideEffects = 0, hasNewValue = 1 in
138 class T_ALU32_3op_pred<string mnemonic, bits<3> MajOp, bits<3> MinOp,
139 bit OpsRev, bit PredNot, bit PredNew>
140 : ALU32_rr<(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
141 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") "#
142 "$Rd = "#mnemonic#"($Rs, $Rt)",
143 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
144 let isPredicated = 1;
145 let isPredicatedFalse = PredNot;
146 let isPredicatedNew = PredNew;
147 let BaseOpcode = mnemonic#_rr;
148 let CextOpcode = mnemonic;
157 let Inst{26-24} = MajOp;
158 let Inst{23-21} = MinOp;
159 let Inst{20-16} = !if(OpsRev,Rt,Rs);
160 let Inst{13} = PredNew;
161 let Inst{12-8} = !if(OpsRev,Rs,Rt);
162 let Inst{7} = PredNot;
167 class T_ALU32_combineh<string Op1, string Op2, bits<3> MajOp, bits<3> MinOp,
169 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, 0> {
170 let AsmString = "$Rd = combine($Rs"#Op1#", $Rt"#Op2#")";
173 def A2_combine_hh : T_ALU32_combineh<".h", ".h", 0b011, 0b100, 1>;
174 def A2_combine_hl : T_ALU32_combineh<".h", ".l", 0b011, 0b101, 1>;
175 def A2_combine_lh : T_ALU32_combineh<".l", ".h", 0b011, 0b110, 1>;
176 def A2_combine_ll : T_ALU32_combineh<".l", ".l", 0b011, 0b111, 1>;
178 class T_ALU32_3op_sfx<string mnemonic, string suffix, bits<3> MajOp,
179 bits<3> MinOp, bit OpsRev, bit IsComm>
180 : T_ALU32_3op<"", MajOp, MinOp, OpsRev, IsComm> {
181 let AsmString = "$Rd = "#mnemonic#"($Rs, $Rt)"#suffix;
184 def A2_svaddh : T_ALU32_3op<"vaddh", 0b110, 0b000, 0, 1>;
185 def A2_svsubh : T_ALU32_3op<"vsubh", 0b110, 0b100, 1, 0>;
187 let Defs = [USR_OVF], Itinerary = ALU32_3op_tc_2_SLOT0123 in {
188 def A2_svaddhs : T_ALU32_3op_sfx<"vaddh", ":sat", 0b110, 0b001, 0, 1>;
189 def A2_addsat : T_ALU32_3op_sfx<"add", ":sat", 0b110, 0b010, 0, 1>;
190 def A2_svadduhs : T_ALU32_3op_sfx<"vadduh", ":sat", 0b110, 0b011, 0, 1>;
191 def A2_svsubhs : T_ALU32_3op_sfx<"vsubh", ":sat", 0b110, 0b101, 1, 0>;
192 def A2_subsat : T_ALU32_3op_sfx<"sub", ":sat", 0b110, 0b110, 1, 0>;
193 def A2_svsubuhs : T_ALU32_3op_sfx<"vsubuh", ":sat", 0b110, 0b111, 1, 0>;
196 let Itinerary = ALU32_3op_tc_2_SLOT0123 in
197 def A2_svavghs : T_ALU32_3op_sfx<"vavgh", ":rnd", 0b111, 0b001, 0, 1>;
199 def A2_svavgh : T_ALU32_3op<"vavgh", 0b111, 0b000, 0, 1>;
200 def A2_svnavgh : T_ALU32_3op<"vnavgh", 0b111, 0b011, 1, 0>;
202 multiclass T_ALU32_3op_p<string mnemonic, bits<3> MajOp, bits<3> MinOp,
204 def t : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 0>;
205 def f : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 0>;
206 def tnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 0, 1>;
207 def fnew : T_ALU32_3op_pred<mnemonic, MajOp, MinOp, OpsRev, 1, 1>;
210 multiclass T_ALU32_3op_A2<string mnemonic, bits<3> MajOp, bits<3> MinOp,
211 bit OpsRev, bit IsComm> {
212 let isPredicable = 1 in
213 def A2_#NAME : T_ALU32_3op <mnemonic, MajOp, MinOp, OpsRev, IsComm>;
214 defm A2_p#NAME : T_ALU32_3op_p<mnemonic, MajOp, MinOp, OpsRev>;
217 defm add : T_ALU32_3op_A2<"add", 0b011, 0b000, 0, 1>;
218 defm and : T_ALU32_3op_A2<"and", 0b001, 0b000, 0, 1>;
219 defm or : T_ALU32_3op_A2<"or", 0b001, 0b001, 0, 1>;
220 defm sub : T_ALU32_3op_A2<"sub", 0b011, 0b001, 1, 0>;
221 defm xor : T_ALU32_3op_A2<"xor", 0b001, 0b011, 0, 1>;
223 // Pats for instruction selection.
224 class BinOp32_pat<SDNode Op, InstHexagon MI, ValueType ResT>
225 : Pat<(ResT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
226 (ResT (MI IntRegs:$Rs, IntRegs:$Rt))>;
228 def: BinOp32_pat<add, A2_add, i32>;
229 def: BinOp32_pat<and, A2_and, i32>;
230 def: BinOp32_pat<or, A2_or, i32>;
231 def: BinOp32_pat<sub, A2_sub, i32>;
232 def: BinOp32_pat<xor, A2_xor, i32>;
234 // A few special cases producing register pairs:
235 let OutOperandList = (outs DoubleRegs:$Rd), hasNewValue = 0 in {
236 def S2_packhl : T_ALU32_3op <"packhl", 0b101, 0b100, 0, 0>;
238 let isPredicable = 1 in
239 def A2_combinew : T_ALU32_3op <"combine", 0b101, 0b000, 0, 0>;
241 // Conditional combinew uses "newt/f" instead of "t/fnew".
242 def C2_ccombinewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 0>;
243 def C2_ccombinewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 0>;
244 def C2_ccombinewnewt : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 0, 1>;
245 def C2_ccombinewnewf : T_ALU32_3op_pred<"combine", 0b101, 0b000, 0, 1, 1>;
248 let hasSideEffects = 0, hasNewValue = 1, isCompare = 1, InputType = "reg" in
249 class T_ALU32_3op_cmp<string mnemonic, bits<2> MinOp, bit IsNeg, bit IsComm>
250 : ALU32_rr<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
251 "$Pd = "#mnemonic#"($Rs, $Rt)",
252 [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
253 let CextOpcode = mnemonic;
254 let isCommutable = IsComm;
260 let Inst{27-24} = 0b0010;
261 let Inst{22-21} = MinOp;
262 let Inst{20-16} = Rs;
265 let Inst{3-2} = 0b00;
269 let Itinerary = ALU32_3op_tc_2early_SLOT0123 in {
270 def C2_cmpeq : T_ALU32_3op_cmp< "cmp.eq", 0b00, 0, 1>;
271 def C2_cmpgt : T_ALU32_3op_cmp< "cmp.gt", 0b10, 0, 0>;
272 def C2_cmpgtu : T_ALU32_3op_cmp< "cmp.gtu", 0b11, 0, 0>;
275 // Patfrag to convert the usual comparison patfrags (e.g. setlt) to ones
276 // that reverse the order of the operands.
277 class RevCmp<PatFrag F> : PatFrag<(ops node:$rhs, node:$lhs), F.Fragment>;
279 // Pats for compares. They use PatFrags as operands, not SDNodes,
280 // since seteq/setgt/etc. are defined as ParFrags.
281 class T_cmp32_rr_pat<InstHexagon MI, PatFrag Op, ValueType VT>
282 : Pat<(VT (Op (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
283 (VT (MI IntRegs:$Rs, IntRegs:$Rt))>;
285 def: T_cmp32_rr_pat<C2_cmpeq, seteq, i1>;
286 def: T_cmp32_rr_pat<C2_cmpgt, setgt, i1>;
287 def: T_cmp32_rr_pat<C2_cmpgtu, setugt, i1>;
289 def: T_cmp32_rr_pat<C2_cmpgt, RevCmp<setlt>, i1>;
290 def: T_cmp32_rr_pat<C2_cmpgtu, RevCmp<setult>, i1>;
292 let CextOpcode = "MUX", InputType = "reg", hasNewValue = 1 in
293 def C2_mux: ALU32_rr<(outs IntRegs:$Rd),
294 (ins PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt),
295 "$Rd = mux($Pu, $Rs, $Rt)", [], "", ALU32_3op_tc_1_SLOT0123>, ImmRegRel {
301 let CextOpcode = "mux";
302 let InputType = "reg";
303 let hasSideEffects = 0;
306 let Inst{27-24} = 0b0100;
307 let Inst{20-16} = Rs;
313 def: Pat<(i32 (select (i1 PredRegs:$Pu), (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))),
314 (C2_mux PredRegs:$Pu, IntRegs:$Rs, IntRegs:$Rt)>;
316 // Combines the two immediates into a double register.
317 // Increase complexity to make it greater than any complexity of a combine
318 // that involves a register.
320 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
321 isExtentSigned = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 1,
322 AddedComplexity = 75 in
323 def A2_combineii: ALU32Inst <(outs DoubleRegs:$Rdd), (ins s8Ext:$s8, s8Imm:$S8),
324 "$Rdd = combine(#$s8, #$S8)",
325 [(set (i64 DoubleRegs:$Rdd),
326 (i64 (HexagonCOMBINE(i32 s8ExtPred:$s8), (i32 s8ImmPred:$S8))))]> {
332 let Inst{27-23} = 0b11000;
333 let Inst{22-16} = S8{7-1};
334 let Inst{13} = S8{0};
339 //===----------------------------------------------------------------------===//
340 // Template class for predicated ADD of a reg and an Immediate value.
341 //===----------------------------------------------------------------------===//
342 let hasNewValue = 1, hasSideEffects = 0 in
343 class T_Addri_Pred <bit PredNot, bit PredNew>
344 : ALU32_ri <(outs IntRegs:$Rd),
345 (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
346 !if(PredNot, "if (!$Pu", "if ($Pu")#!if(PredNew,".new) $Rd = ",
347 ") $Rd = ")#"add($Rs, #$s8)"> {
353 let isPredicatedNew = PredNew;
356 let Inst{27-24} = 0b0100;
357 let Inst{23} = PredNot;
358 let Inst{22-21} = Pu;
359 let Inst{20-16} = Rs;
360 let Inst{13} = PredNew;
365 //===----------------------------------------------------------------------===//
366 // A2_addi: Add a signed immediate to a register.
367 //===----------------------------------------------------------------------===//
368 let hasNewValue = 1, hasSideEffects = 0 in
369 class T_Addri <Operand immOp, list<dag> pattern = [] >
370 : ALU32_ri <(outs IntRegs:$Rd),
371 (ins IntRegs:$Rs, immOp:$s16),
372 "$Rd = add($Rs, #$s16)", pattern,
373 //[(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs), (s16ExtPred:$s16)))],
374 "", ALU32_ADDI_tc_1_SLOT0123> {
381 let Inst{27-21} = s16{15-9};
382 let Inst{20-16} = Rs;
383 let Inst{13-5} = s16{8-0};
387 //===----------------------------------------------------------------------===//
388 // Multiclass for ADD of a register and an immediate value.
389 //===----------------------------------------------------------------------===//
390 multiclass Addri_Pred<string mnemonic, bit PredNot> {
391 let isPredicatedFalse = PredNot in {
392 def _c#NAME : T_Addri_Pred<PredNot, 0>;
394 def _cdn#NAME : T_Addri_Pred<PredNot, 1>;
398 let isExtendable = 1, InputType = "imm" in
399 multiclass Addri_base<string mnemonic, SDNode OpNode> {
400 let CextOpcode = mnemonic, BaseOpcode = mnemonic#_ri in {
401 let opExtendable = 2, isExtentSigned = 1, opExtentBits = 16,
403 def NAME : T_Addri< s16Ext, // Rd=add(Rs,#s16)
404 [(set (i32 IntRegs:$Rd),
405 (add IntRegs:$Rs, s16ExtPred:$s16))]>;
407 let opExtendable = 3, isExtentSigned = 1, opExtentBits = 8,
408 hasSideEffects = 0, isPredicated = 1 in {
409 defm Pt : Addri_Pred<mnemonic, 0>;
410 defm NotPt : Addri_Pred<mnemonic, 1>;
415 defm ADD_ri : Addri_base<"add", add>, ImmRegRel, PredNewRel;
417 //===----------------------------------------------------------------------===//
418 // Template class used for the following ALU32 instructions.
421 //===----------------------------------------------------------------------===//
422 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 10,
423 InputType = "imm", hasNewValue = 1 in
424 class T_ALU32ri_logical <string mnemonic, SDNode OpNode, bits<2> MinOp>
425 : ALU32_ri <(outs IntRegs:$Rd),
426 (ins IntRegs:$Rs, s10Ext:$s10),
427 "$Rd = "#mnemonic#"($Rs, #$s10)" ,
428 [(set (i32 IntRegs:$Rd), (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10))]> {
432 let CextOpcode = mnemonic;
436 let Inst{27-24} = 0b0110;
437 let Inst{23-22} = MinOp;
438 let Inst{21} = s10{9};
439 let Inst{20-16} = Rs;
440 let Inst{13-5} = s10{8-0};
444 def OR_ri : T_ALU32ri_logical<"or", or, 0b10>, ImmRegRel;
445 def AND_ri : T_ALU32ri_logical<"and", and, 0b00>, ImmRegRel;
447 // Subtract register from immediate
448 // Rd32=sub(#s10,Rs32)
449 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 10,
450 CextOpcode = "sub", InputType = "imm", hasNewValue = 1 in
451 def SUB_ri: ALU32_ri <(outs IntRegs:$Rd), (ins s10Ext:$s10, IntRegs:$Rs),
452 "$Rd = sub(#$s10, $Rs)" ,
453 [(set IntRegs:$Rd, (sub s10ExtPred:$s10, IntRegs:$Rs))] > ,
461 let Inst{27-22} = 0b011001;
462 let Inst{21} = s10{9};
463 let Inst{20-16} = Rs;
464 let Inst{13-5} = s10{8-0};
469 let hasSideEffects = 0 in
470 def A2_nop: ALU32Inst <(outs), (ins), "nop" > {
472 let Inst{27-24} = 0b1111;
474 // Rd = not(Rs) gets mapped to Rd=sub(#-1, Rs).
475 def : Pat<(not (i32 IntRegs:$src1)),
476 (SUB_ri -1, (i32 IntRegs:$src1))>;
478 let hasSideEffects = 0, hasNewValue = 1 in
479 class T_tfr16<bit isHi>
480 : ALU32Inst <(outs IntRegs:$Rx), (ins IntRegs:$src1, u16Imm:$u16),
481 "$Rx"#!if(isHi, ".h", ".l")#" = #$u16",
482 [], "$src1 = $Rx" > {
487 let Inst{27-26} = 0b00;
488 let Inst{25-24} = !if(isHi, 0b10, 0b01);
489 let Inst{23-22} = u16{15-14};
491 let Inst{20-16} = Rx;
492 let Inst{13-0} = u16{13-0};
495 def A2_tfril: T_tfr16<0>;
496 def A2_tfrih: T_tfr16<1>;
498 // Conditional transfer is an alias to conditional "Rd = add(Rs, #0)".
499 let isPredicated = 1, hasNewValue = 1, opNewValue = 0 in
500 class T_tfr_pred<bit isPredNot, bit isPredNew>
501 : ALU32Inst<(outs IntRegs:$dst),
502 (ins PredRegs:$src1, IntRegs:$src2),
503 "if ("#!if(isPredNot, "!", "")#
504 "$src1"#!if(isPredNew, ".new", "")#
510 let isPredicatedFalse = isPredNot;
511 let isPredicatedNew = isPredNew;
514 let Inst{27-24} = 0b0100;
515 let Inst{23} = isPredNot;
516 let Inst{13} = isPredNew;
519 let Inst{22-21} = src1;
520 let Inst{20-16} = src2;
523 let isPredicable = 1 in
524 class T_tfr : ALU32Inst<(outs IntRegs:$dst), (ins IntRegs:$src),
531 let Inst{27-21} = 0b0000011;
532 let Inst{20-16} = src;
537 let InputType = "reg", hasNewValue = 1, hasSideEffects = 0 in
538 multiclass tfr_base<string CextOp> {
539 let CextOpcode = CextOp, BaseOpcode = CextOp in {
543 def t : T_tfr_pred<0, 0>;
544 def f : T_tfr_pred<1, 0>;
546 def tnew : T_tfr_pred<0, 1>;
547 def fnew : T_tfr_pred<1, 1>;
551 // Assembler mapped to C2_ccombinew[t|f|newt|newf].
552 // Please don't add bits to this instruction as it'll be converted into
553 // 'combine' before object code emission.
554 let isPredicated = 1 in
555 class T_tfrp_pred<bit PredNot, bit PredNew>
556 : ALU32_rr <(outs DoubleRegs:$dst),
557 (ins PredRegs:$src1, DoubleRegs:$src2),
558 "if ("#!if(PredNot, "!", "")#"$src1"
559 #!if(PredNew, ".new", "")#") $dst = $src2" > {
560 let isPredicatedFalse = PredNot;
561 let isPredicatedNew = PredNew;
564 // Assembler mapped to A2_combinew.
565 // Please don't add bits to this instruction as it'll be converted into
566 // 'combine' before object code emission.
567 class T_tfrp : ALU32Inst <(outs DoubleRegs:$dst),
568 (ins DoubleRegs:$src),
571 let hasSideEffects = 0 in
572 multiclass TFR64_base<string BaseName> {
573 let BaseOpcode = BaseName in {
574 let isPredicable = 1 in
577 def t : T_tfrp_pred <0, 0>;
578 def f : T_tfrp_pred <1, 0>;
580 def tnew : T_tfrp_pred <0, 1>;
581 def fnew : T_tfrp_pred <1, 1>;
585 let InputType = "imm", isExtendable = 1, isExtentSigned = 1, opExtentBits = 12,
586 isMoveImm = 1, opExtendable = 2, BaseOpcode = "TFRI", CextOpcode = "TFR",
587 hasSideEffects = 0, isPredicated = 1, hasNewValue = 1 in
588 class T_TFRI_Pred<bit PredNot, bit PredNew>
589 : ALU32_ri<(outs IntRegs:$Rd), (ins PredRegs:$Pu, s12Ext:$s12),
590 "if ("#!if(PredNot,"!","")#"$Pu"#!if(PredNew,".new","")#") $Rd = #$s12",
591 [], "", ALU32_2op_tc_1_SLOT0123>, ImmRegRel, PredNewRel {
592 let isPredicatedFalse = PredNot;
593 let isPredicatedNew = PredNew;
600 let Inst{27-24} = 0b1110;
601 let Inst{23} = PredNot;
602 let Inst{22-21} = Pu;
604 let Inst{19-16,12-5} = s12;
605 let Inst{13} = PredNew;
609 def C2_cmoveit : T_TFRI_Pred<0, 0>;
610 def C2_cmoveif : T_TFRI_Pred<1, 0>;
611 def C2_cmovenewit : T_TFRI_Pred<0, 1>;
612 def C2_cmovenewif : T_TFRI_Pred<1, 1>;
614 let InputType = "imm", isExtendable = 1, isExtentSigned = 1,
615 CextOpcode = "TFR", BaseOpcode = "TFRI", hasNewValue = 1, opNewValue = 0,
616 isAsCheapAsAMove = 1 , opExtendable = 1, opExtentBits = 16, isMoveImm = 1,
617 isPredicated = 0, isPredicable = 1, isReMaterializable = 1 in
618 def A2_tfrsi : ALU32Inst<(outs IntRegs:$Rd), (ins s16Ext:$s16), "$Rd = #$s16",
619 [(set (i32 IntRegs:$Rd), s16ExtPred:$s16)], "", ALU32_2op_tc_1_SLOT0123>,
625 let Inst{27-24} = 0b1000;
626 let Inst{23-22,20-16,13-5} = s16;
630 defm A2_tfr : tfr_base<"TFR">, ImmRegRel, PredNewRel;
631 let isAsmParserOnly = 1 in
632 defm A2_tfrp : TFR64_base<"TFR64">, PredNewRel;
635 let isReMaterializable = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
636 isAsmParserOnly = 1 in
637 def A2_tfrpi : ALU64_rr<(outs DoubleRegs:$dst), (ins s8Imm64:$src1),
639 [(set (i64 DoubleRegs:$dst), s8Imm64Pred:$src1)]>;
641 // TODO: see if this instruction can be deleted..
642 let isExtendable = 1, opExtendable = 1, opExtentBits = 6,
643 isAsmParserOnly = 1 in
644 def TFRI64_V4 : ALU64_rr<(outs DoubleRegs:$dst), (ins u6Ext:$src1),
647 //===----------------------------------------------------------------------===//
649 //===----------------------------------------------------------------------===//
652 //===----------------------------------------------------------------------===//
654 //===----------------------------------------------------------------------===//
655 // Scalar mux register immediate.
656 let hasSideEffects = 0, isExtentSigned = 1, CextOpcode = "MUX",
657 InputType = "imm", hasNewValue = 1, isExtendable = 1, opExtentBits = 8 in
658 class T_MUX1 <bit MajOp, dag ins, string AsmStr>
659 : ALU32Inst <(outs IntRegs:$Rd), ins, AsmStr>, ImmRegRel {
666 let Inst{27-24} = 0b0011;
667 let Inst{23} = MajOp;
668 let Inst{22-21} = Pu;
669 let Inst{20-16} = Rs;
675 let opExtendable = 2 in
676 def C2_muxri : T_MUX1<0b1, (ins PredRegs:$Pu, s8Ext:$s8, IntRegs:$Rs),
677 "$Rd = mux($Pu, #$s8, $Rs)">;
679 let opExtendable = 3 in
680 def C2_muxir : T_MUX1<0b0, (ins PredRegs:$Pu, IntRegs:$Rs, s8Ext:$s8),
681 "$Rd = mux($Pu, $Rs, #$s8)">;
683 def : Pat<(i32 (select I1:$Pu, s8ExtPred:$s8, I32:$Rs)),
684 (C2_muxri I1:$Pu, s8ExtPred:$s8, I32:$Rs)>;
686 def : Pat<(i32 (select I1:$Pu, I32:$Rs, s8ExtPred:$s8)),
687 (C2_muxir I1:$Pu, I32:$Rs, s8ExtPred:$s8)>;
689 // C2_muxii: Scalar mux immediates.
690 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1,
691 opExtentBits = 8, opExtendable = 2 in
692 def C2_muxii: ALU32Inst <(outs IntRegs:$Rd),
693 (ins PredRegs:$Pu, s8Ext:$s8, s8Imm:$S8),
694 "$Rd = mux($Pu, #$s8, #$S8)" ,
695 [(set (i32 IntRegs:$Rd),
696 (i32 (select I1:$Pu, s8ExtPred:$s8, s8ImmPred:$S8)))] > {
704 let Inst{27-25} = 0b101;
705 let Inst{24-23} = Pu;
706 let Inst{22-16} = S8{7-1};
707 let Inst{13} = S8{0};
712 //===----------------------------------------------------------------------===//
713 // template class for non-predicated alu32_2op instructions
714 // - aslh, asrh, sxtb, sxth, zxth
715 //===----------------------------------------------------------------------===//
716 let hasNewValue = 1, opNewValue = 0 in
717 class T_ALU32_2op <string mnemonic, bits<3> minOp> :
718 ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
719 "$Rd = "#mnemonic#"($Rs)", [] > {
725 let Inst{27-24} = 0b0000;
726 let Inst{23-21} = minOp;
729 let Inst{20-16} = Rs;
732 //===----------------------------------------------------------------------===//
733 // template class for predicated alu32_2op instructions
734 // - aslh, asrh, sxtb, sxth, zxtb, zxth
735 //===----------------------------------------------------------------------===//
736 let hasSideEffects = 0, validSubTargets = HasV4SubT,
737 hasNewValue = 1, opNewValue = 0 in
738 class T_ALU32_2op_Pred <string mnemonic, bits<3> minOp, bit isPredNot,
740 ALU32Inst <(outs IntRegs:$Rd), (ins PredRegs:$Pu, IntRegs:$Rs),
741 !if(isPredNot, "if (!$Pu", "if ($Pu")
742 #!if(isPredNew, ".new) ",") ")#"$Rd = "#mnemonic#"($Rs)"> {
749 let Inst{27-24} = 0b0000;
750 let Inst{23-21} = minOp;
752 let Inst{11} = isPredNot;
753 let Inst{10} = isPredNew;
756 let Inst{20-16} = Rs;
759 multiclass ALU32_2op_Pred<string mnemonic, bits<3> minOp, bit PredNot> {
760 let isPredicatedFalse = PredNot in {
761 def NAME : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 0>;
764 let isPredicatedNew = 1 in
765 def NAME#new : T_ALU32_2op_Pred<mnemonic, minOp, PredNot, 1>;
769 multiclass ALU32_2op_base<string mnemonic, bits<3> minOp> {
770 let BaseOpcode = mnemonic in {
771 let isPredicable = 1, hasSideEffects = 0 in
772 def A2_#NAME : T_ALU32_2op<mnemonic, minOp>;
774 let validSubTargets = HasV4SubT, isPredicated = 1, hasSideEffects = 0 in {
775 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
776 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
781 defm aslh : ALU32_2op_base<"aslh", 0b000>, PredNewRel;
782 defm asrh : ALU32_2op_base<"asrh", 0b001>, PredNewRel;
783 defm sxtb : ALU32_2op_base<"sxtb", 0b101>, PredNewRel;
784 defm sxth : ALU32_2op_base<"sxth", 0b111>, PredNewRel;
785 defm zxth : ALU32_2op_base<"zxth", 0b110>, PredNewRel;
787 // Rd=zxtb(Rs): assembler mapped to Rd=and(Rs,#255).
788 // Compiler would want to generate 'zxtb' instead of 'and' becuase 'zxtb' has
789 // predicated forms while 'and' doesn't. Since integrated assembler can't
790 // handle 'mapped' instructions, we need to encode 'zxtb' same as 'and' where
791 // immediate operand is set to '255'.
793 let hasNewValue = 1, opNewValue = 0 in
794 class T_ZXTB: ALU32Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rs),
795 "$Rd = zxtb($Rs)", [] > { // Rd = and(Rs,255)
802 let Inst{27-22} = 0b011000;
804 let Inst{20-16} = Rs;
805 let Inst{21} = s10{9};
806 let Inst{13-5} = s10{8-0};
809 //Rd=zxtb(Rs): assembler mapped to "Rd=and(Rs,#255)
810 multiclass ZXTB_base <string mnemonic, bits<3> minOp> {
811 let BaseOpcode = mnemonic in {
812 let isPredicable = 1, hasSideEffects = 0 in
813 def A2_#NAME : T_ZXTB;
815 let validSubTargets = HasV4SubT, isPredicated = 1, hasSideEffects = 0 in {
816 defm A4_p#NAME#t : ALU32_2op_Pred<mnemonic, minOp, 0>;
817 defm A4_p#NAME#f : ALU32_2op_Pred<mnemonic, minOp, 1>;
822 let isCodeGenOnly=0 in
823 defm zxtb : ZXTB_base<"zxtb",0b100>, PredNewRel;
825 def: Pat<(shl I32:$src1, (i32 16)), (A2_aslh I32:$src1)>;
826 def: Pat<(sra I32:$src1, (i32 16)), (A2_asrh I32:$src1)>;
827 def: Pat<(sext_inreg I32:$src1, i8), (A2_sxtb I32:$src1)>;
828 def: Pat<(sext_inreg I32:$src1, i16), (A2_sxth I32:$src1)>;
830 //===----------------------------------------------------------------------===//
831 // Template class for vector add and avg
832 //===----------------------------------------------------------------------===//
834 class T_VectALU_64 <string opc, bits<3> majOp, bits<3> minOp,
835 bit isSat, bit isRnd, bit isCrnd, bit SwapOps >
836 : ALU64_rr < (outs DoubleRegs:$Rdd),
837 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
838 "$Rdd = "#opc#"($Rss, $Rtt)"#!if(isRnd, ":rnd", "")
839 #!if(isCrnd,":crnd","")
840 #!if(isSat, ":sat", ""),
841 [], "", ALU64_tc_2_SLOT23 > {
848 let Inst{27-24} = 0b0011;
849 let Inst{23-21} = majOp;
850 let Inst{20-16} = !if (SwapOps, Rtt, Rss);
851 let Inst{12-8} = !if (SwapOps, Rss, Rtt);
852 let Inst{7-5} = minOp;
856 // ALU64 - Vector add
857 // Rdd=vadd[u][bhw](Rss,Rtt)
858 let Itinerary = ALU64_tc_1_SLOT23 in {
859 def A2_vaddub : T_VectALU_64 < "vaddub", 0b000, 0b000, 0, 0, 0, 0>;
860 def A2_vaddh : T_VectALU_64 < "vaddh", 0b000, 0b010, 0, 0, 0, 0>;
861 def A2_vaddw : T_VectALU_64 < "vaddw", 0b000, 0b101, 0, 0, 0, 0>;
864 // Rdd=vadd[u][bhw](Rss,Rtt):sat
865 let Defs = [USR_OVF] in {
866 def A2_vaddubs : T_VectALU_64 < "vaddub", 0b000, 0b001, 1, 0, 0, 0>;
867 def A2_vaddhs : T_VectALU_64 < "vaddh", 0b000, 0b011, 1, 0, 0, 0>;
868 def A2_vadduhs : T_VectALU_64 < "vadduh", 0b000, 0b100, 1, 0, 0, 0>;
869 def A2_vaddws : T_VectALU_64 < "vaddw", 0b000, 0b110, 1, 0, 0, 0>;
872 // ALU64 - Vector average
873 // Rdd=vavg[u][bhw](Rss,Rtt)
874 let Itinerary = ALU64_tc_1_SLOT23 in {
875 def A2_vavgub : T_VectALU_64 < "vavgub", 0b010, 0b000, 0, 0, 0, 0>;
876 def A2_vavgh : T_VectALU_64 < "vavgh", 0b010, 0b010, 0, 0, 0, 0>;
877 def A2_vavguh : T_VectALU_64 < "vavguh", 0b010, 0b101, 0, 0, 0, 0>;
878 def A2_vavgw : T_VectALU_64 < "vavgw", 0b011, 0b000, 0, 0, 0, 0>;
879 def A2_vavguw : T_VectALU_64 < "vavguw", 0b011, 0b011, 0, 0, 0, 0>;
882 // Rdd=vavg[u][bhw](Rss,Rtt)[:rnd|:crnd]
883 def A2_vavgubr : T_VectALU_64 < "vavgub", 0b010, 0b001, 0, 1, 0, 0>;
884 def A2_vavghr : T_VectALU_64 < "vavgh", 0b010, 0b011, 0, 1, 0, 0>;
885 def A2_vavghcr : T_VectALU_64 < "vavgh", 0b010, 0b100, 0, 0, 1, 0>;
886 def A2_vavguhr : T_VectALU_64 < "vavguh", 0b010, 0b110, 0, 1, 0, 0>;
888 def A2_vavgwr : T_VectALU_64 < "vavgw", 0b011, 0b001, 0, 1, 0, 0>;
889 def A2_vavgwcr : T_VectALU_64 < "vavgw", 0b011, 0b010, 0, 0, 1, 0>;
890 def A2_vavguwr : T_VectALU_64 < "vavguw", 0b011, 0b100, 0, 1, 0, 0>;
892 // Rdd=vnavg[bh](Rss,Rtt)
893 let Itinerary = ALU64_tc_1_SLOT23 in {
894 def A2_vnavgh : T_VectALU_64 < "vnavgh", 0b100, 0b000, 0, 0, 0, 1>;
895 def A2_vnavgw : T_VectALU_64 < "vnavgw", 0b100, 0b011, 0, 0, 0, 1>;
898 // Rdd=vnavg[bh](Rss,Rtt)[:rnd|:crnd]:sat
899 let Defs = [USR_OVF] in {
900 def A2_vnavghr : T_VectALU_64 < "vnavgh", 0b100, 0b001, 1, 1, 0, 1>;
901 def A2_vnavghcr : T_VectALU_64 < "vnavgh", 0b100, 0b010, 1, 0, 1, 1>;
902 def A2_vnavgwr : T_VectALU_64 < "vnavgw", 0b100, 0b100, 1, 1, 0, 1>;
903 def A2_vnavgwcr : T_VectALU_64 < "vnavgw", 0b100, 0b110, 1, 0, 1, 1>;
906 // Rdd=vsub[u][bh](Rss,Rtt)
907 let Itinerary = ALU64_tc_1_SLOT23 in {
908 def A2_vsubub : T_VectALU_64 < "vsubub", 0b001, 0b000, 0, 0, 0, 1>;
909 def A2_vsubh : T_VectALU_64 < "vsubh", 0b001, 0b010, 0, 0, 0, 1>;
910 def A2_vsubw : T_VectALU_64 < "vsubw", 0b001, 0b101, 0, 0, 0, 1>;
913 // Rdd=vsub[u][bh](Rss,Rtt):sat
914 let Defs = [USR_OVF] in {
915 def A2_vsububs : T_VectALU_64 < "vsubub", 0b001, 0b001, 1, 0, 0, 1>;
916 def A2_vsubhs : T_VectALU_64 < "vsubh", 0b001, 0b011, 1, 0, 0, 1>;
917 def A2_vsubuhs : T_VectALU_64 < "vsubuh", 0b001, 0b100, 1, 0, 0, 1>;
918 def A2_vsubws : T_VectALU_64 < "vsubw", 0b001, 0b110, 1, 0, 0, 1>;
921 // Rdd=vmax[u][bhw](Rss,Rtt)
922 def A2_vmaxb : T_VectALU_64 < "vmaxb", 0b110, 0b110, 0, 0, 0, 1>;
923 def A2_vmaxub : T_VectALU_64 < "vmaxub", 0b110, 0b000, 0, 0, 0, 1>;
924 def A2_vmaxh : T_VectALU_64 < "vmaxh", 0b110, 0b001, 0, 0, 0, 1>;
925 def A2_vmaxuh : T_VectALU_64 < "vmaxuh", 0b110, 0b010, 0, 0, 0, 1>;
926 def A2_vmaxw : T_VectALU_64 < "vmaxw", 0b110, 0b011, 0, 0, 0, 1>;
927 def A2_vmaxuw : T_VectALU_64 < "vmaxuw", 0b101, 0b101, 0, 0, 0, 1>;
929 // Rdd=vmin[u][bhw](Rss,Rtt)
930 def A2_vminb : T_VectALU_64 < "vminb", 0b110, 0b111, 0, 0, 0, 1>;
931 def A2_vminub : T_VectALU_64 < "vminub", 0b101, 0b000, 0, 0, 0, 1>;
932 def A2_vminh : T_VectALU_64 < "vminh", 0b101, 0b001, 0, 0, 0, 1>;
933 def A2_vminuh : T_VectALU_64 < "vminuh", 0b101, 0b010, 0, 0, 0, 1>;
934 def A2_vminw : T_VectALU_64 < "vminw", 0b101, 0b011, 0, 0, 0, 1>;
935 def A2_vminuw : T_VectALU_64 < "vminuw", 0b101, 0b100, 0, 0, 0, 1>;
937 //===----------------------------------------------------------------------===//
938 // Template class for vector compare
939 //===----------------------------------------------------------------------===//
940 let hasSideEffects = 0 in
941 class T_vcmp <string Str, bits<4> minOp>
942 : ALU64_rr <(outs PredRegs:$Pd),
943 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
944 "$Pd = "#Str#"($Rss, $Rtt)", [],
945 "", ALU64_tc_2early_SLOT23> {
952 let Inst{27-23} = 0b00100;
953 let Inst{13} = minOp{3};
954 let Inst{7-5} = minOp{2-0};
956 let Inst{20-16} = Rss;
957 let Inst{12-8} = Rtt;
960 class T_vcmp_pat<InstHexagon MI, PatFrag Op, ValueType T>
961 : Pat<(i1 (Op (T DoubleRegs:$Rss), (T DoubleRegs:$Rtt))),
962 (i1 (MI DoubleRegs:$Rss, DoubleRegs:$Rtt))>;
964 // Vector compare bytes
965 def A2_vcmpbeq : T_vcmp <"vcmpb.eq", 0b0110>;
966 def A2_vcmpbgtu : T_vcmp <"vcmpb.gtu", 0b0111>;
968 // Vector compare halfwords
969 def A2_vcmpheq : T_vcmp <"vcmph.eq", 0b0011>;
970 def A2_vcmphgt : T_vcmp <"vcmph.gt", 0b0100>;
971 def A2_vcmphgtu : T_vcmp <"vcmph.gtu", 0b0101>;
973 // Vector compare words
974 def A2_vcmpweq : T_vcmp <"vcmpw.eq", 0b0000>;
975 def A2_vcmpwgt : T_vcmp <"vcmpw.gt", 0b0001>;
976 def A2_vcmpwgtu : T_vcmp <"vcmpw.gtu", 0b0010>;
978 def: T_vcmp_pat<A2_vcmpbeq, seteq, v8i8>;
979 def: T_vcmp_pat<A2_vcmpbgtu, setugt, v8i8>;
980 def: T_vcmp_pat<A2_vcmpheq, seteq, v4i16>;
981 def: T_vcmp_pat<A2_vcmphgt, setgt, v4i16>;
982 def: T_vcmp_pat<A2_vcmphgtu, setugt, v4i16>;
983 def: T_vcmp_pat<A2_vcmpweq, seteq, v2i32>;
984 def: T_vcmp_pat<A2_vcmpwgt, setgt, v2i32>;
985 def: T_vcmp_pat<A2_vcmpwgtu, setugt, v2i32>;
987 //===----------------------------------------------------------------------===//
989 //===----------------------------------------------------------------------===//
992 //===----------------------------------------------------------------------===//
994 //===----------------------------------------------------------------------===//
996 //===----------------------------------------------------------------------===//
998 //===----------------------------------------------------------------------===//
1001 //===----------------------------------------------------------------------===//
1003 //===----------------------------------------------------------------------===//// Add.
1004 //===----------------------------------------------------------------------===//
1006 // Add/Subtract halfword
1007 // Rd=add(Rt.L,Rs.[HL])[:sat]
1008 // Rd=sub(Rt.L,Rs.[HL])[:sat]
1009 // Rd=add(Rt.[LH],Rs.[HL])[:sat][:<16]
1010 // Rd=sub(Rt.[LH],Rs.[HL])[:sat][:<16]
1011 //===----------------------------------------------------------------------===//
1013 let hasNewValue = 1, opNewValue = 0 in
1014 class T_XTYPE_ADD_SUB <bits<2> LHbits, bit isSat, bit hasShift, bit isSub>
1015 : ALU64Inst <(outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
1016 "$Rd = "#!if(isSub,"sub","add")#"($Rt."
1017 #!if(hasShift, !if(LHbits{1},"h","l"),"l") #", $Rs."
1018 #!if(hasShift, !if(LHbits{0},"h)","l)"), !if(LHbits{1},"h)","l)"))
1019 #!if(isSat,":sat","")
1020 #!if(hasShift,":<<16",""), [], "", ALU64_tc_1_SLOT23> {
1024 let IClass = 0b1101;
1026 let Inst{27-23} = 0b01010;
1027 let Inst{22} = hasShift;
1028 let Inst{21} = isSub;
1029 let Inst{7} = isSat;
1030 let Inst{6-5} = LHbits;
1032 let Inst{12-8} = Rt;
1033 let Inst{20-16} = Rs;
1036 //Rd=sub(Rt.L,Rs.[LH])
1037 def A2_subh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 1>;
1038 def A2_subh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 1>;
1040 //Rd=add(Rt.L,Rs.[LH])
1041 def A2_addh_l16_ll : T_XTYPE_ADD_SUB <0b00, 0, 0, 0>;
1042 def A2_addh_l16_hl : T_XTYPE_ADD_SUB <0b10, 0, 0, 0>;
1044 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF] in {
1045 //Rd=sub(Rt.L,Rs.[LH]):sat
1046 def A2_subh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 1>;
1047 def A2_subh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 1>;
1049 //Rd=add(Rt.L,Rs.[LH]):sat
1050 def A2_addh_l16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 0, 0>;
1051 def A2_addh_l16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 0, 0>;
1054 //Rd=sub(Rt.[LH],Rs.[LH]):<<16
1055 def A2_subh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 1>;
1056 def A2_subh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 1>;
1057 def A2_subh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 1>;
1058 def A2_subh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 1>;
1060 //Rd=add(Rt.[LH],Rs.[LH]):<<16
1061 def A2_addh_h16_ll : T_XTYPE_ADD_SUB <0b00, 0, 1, 0>;
1062 def A2_addh_h16_lh : T_XTYPE_ADD_SUB <0b01, 0, 1, 0>;
1063 def A2_addh_h16_hl : T_XTYPE_ADD_SUB <0b10, 0, 1, 0>;
1064 def A2_addh_h16_hh : T_XTYPE_ADD_SUB <0b11, 0, 1, 0>;
1066 let Itinerary = ALU64_tc_2_SLOT23, Defs = [USR_OVF] in {
1067 //Rd=sub(Rt.[LH],Rs.[LH]):sat:<<16
1068 def A2_subh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 1>;
1069 def A2_subh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 1>;
1070 def A2_subh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 1>;
1071 def A2_subh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 1>;
1073 //Rd=add(Rt.[LH],Rs.[LH]):sat:<<16
1074 def A2_addh_h16_sat_ll : T_XTYPE_ADD_SUB <0b00, 1, 1, 0>;
1075 def A2_addh_h16_sat_lh : T_XTYPE_ADD_SUB <0b01, 1, 1, 0>;
1076 def A2_addh_h16_sat_hl : T_XTYPE_ADD_SUB <0b10, 1, 1, 0>;
1077 def A2_addh_h16_sat_hh : T_XTYPE_ADD_SUB <0b11, 1, 1, 0>;
1081 def: Pat<(sext_inreg (add I32:$src1, I32:$src2), i16),
1082 (A2_addh_l16_ll I32:$src1, I32:$src2)>;
1084 def: Pat<(sra (add (shl I32:$src1, (i32 16)), I32:$src2), (i32 16)),
1085 (A2_addh_l16_hl I32:$src1, I32:$src2)>;
1087 def: Pat<(shl (add I32:$src1, I32:$src2), (i32 16)),
1088 (A2_addh_h16_ll I32:$src1, I32:$src2)>;
1090 // Subtract halfword.
1091 def: Pat<(sext_inreg (sub I32:$src1, I32:$src2), i16),
1092 (A2_subh_l16_ll I32:$src1, I32:$src2)>;
1094 def: Pat<(shl (sub I32:$src1, I32:$src2), (i32 16)),
1095 (A2_subh_h16_ll I32:$src1, I32:$src2)>;
1097 let hasSideEffects = 0, hasNewValue = 1 in
1098 def S2_parityp: ALU64Inst<(outs IntRegs:$Rd),
1099 (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1100 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1105 let IClass = 0b1101;
1106 let Inst{27-24} = 0b0000;
1107 let Inst{20-16} = Rs;
1108 let Inst{12-8} = Rt;
1112 let hasNewValue = 1, opNewValue = 0, hasSideEffects = 0 in
1113 class T_XTYPE_MIN_MAX < bit isMax, bit isUnsigned >
1114 : ALU64Inst < (outs IntRegs:$Rd), (ins IntRegs:$Rt, IntRegs:$Rs),
1115 "$Rd = "#!if(isMax,"max","min")#!if(isUnsigned,"u","")
1116 #"($Rt, $Rs)", [], "", ALU64_tc_2_SLOT23> {
1121 let IClass = 0b1101;
1123 let Inst{27-23} = 0b01011;
1124 let Inst{22-21} = !if(isMax, 0b10, 0b01);
1125 let Inst{7} = isUnsigned;
1127 let Inst{12-8} = !if(isMax, Rs, Rt);
1128 let Inst{20-16} = !if(isMax, Rt, Rs);
1131 def A2_min : T_XTYPE_MIN_MAX < 0, 0 >;
1132 def A2_minu : T_XTYPE_MIN_MAX < 0, 1 >;
1133 def A2_max : T_XTYPE_MIN_MAX < 1, 0 >;
1134 def A2_maxu : T_XTYPE_MIN_MAX < 1, 1 >;
1136 // Here, depending on the operand being selected, we'll either generate a
1137 // min or max instruction.
1139 // (a>b)?a:b --> max(a,b) => Here check performed is '>' and the value selected
1140 // is the larger of two. So, the corresponding HexagonInst is passed in 'Inst'.
1141 // (a>b)?b:a --> min(a,b) => Here check performed is '>' but the smaller value
1142 // is selected and the corresponding HexagonInst is passed in 'SwapInst'.
1144 multiclass T_MinMax_pats <PatFrag Op, RegisterClass RC, ValueType VT,
1145 InstHexagon Inst, InstHexagon SwapInst> {
1146 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1147 (VT RC:$src1), (VT RC:$src2)),
1148 (Inst RC:$src1, RC:$src2)>;
1149 def: Pat<(select (i1 (Op (VT RC:$src1), (VT RC:$src2))),
1150 (VT RC:$src2), (VT RC:$src1)),
1151 (SwapInst RC:$src1, RC:$src2)>;
1155 multiclass MinMax_pats <PatFrag Op, InstHexagon Inst, InstHexagon SwapInst> {
1156 defm: T_MinMax_pats<Op, IntRegs, i32, Inst, SwapInst>;
1158 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1159 (i32 PositiveHalfWord:$src2))),
1160 (i32 PositiveHalfWord:$src1),
1161 (i32 PositiveHalfWord:$src2))), i16),
1162 (Inst IntRegs:$src1, IntRegs:$src2)>;
1164 def: Pat<(sext_inreg (i32 (select (i1 (Op (i32 PositiveHalfWord:$src1),
1165 (i32 PositiveHalfWord:$src2))),
1166 (i32 PositiveHalfWord:$src2),
1167 (i32 PositiveHalfWord:$src1))), i16),
1168 (SwapInst IntRegs:$src1, IntRegs:$src2)>;
1171 let AddedComplexity = 200 in {
1172 defm: MinMax_pats<setge, A2_max, A2_min>;
1173 defm: MinMax_pats<setgt, A2_max, A2_min>;
1174 defm: MinMax_pats<setle, A2_min, A2_max>;
1175 defm: MinMax_pats<setlt, A2_min, A2_max>;
1176 defm: MinMax_pats<setuge, A2_maxu, A2_minu>;
1177 defm: MinMax_pats<setugt, A2_maxu, A2_minu>;
1178 defm: MinMax_pats<setule, A2_minu, A2_maxu>;
1179 defm: MinMax_pats<setult, A2_minu, A2_maxu>;
1182 class T_cmp64_rr<string mnemonic, bits<3> MinOp, bit IsComm>
1183 : ALU64_rr<(outs PredRegs:$Pd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1184 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", ALU64_tc_2early_SLOT23> {
1186 let isCommutable = IsComm;
1187 let hasSideEffects = 0;
1193 let IClass = 0b1101;
1194 let Inst{27-21} = 0b0010100;
1195 let Inst{20-16} = Rs;
1196 let Inst{12-8} = Rt;
1197 let Inst{7-5} = MinOp;
1201 def C2_cmpeqp : T_cmp64_rr<"cmp.eq", 0b000, 1>;
1202 def C2_cmpgtp : T_cmp64_rr<"cmp.gt", 0b010, 0>;
1203 def C2_cmpgtup : T_cmp64_rr<"cmp.gtu", 0b100, 0>;
1205 class T_cmp64_rr_pat<InstHexagon MI, PatFrag CmpOp>
1206 : Pat<(i1 (CmpOp (i64 DoubleRegs:$Rs), (i64 DoubleRegs:$Rt))),
1207 (i1 (MI DoubleRegs:$Rs, DoubleRegs:$Rt))>;
1209 def: T_cmp64_rr_pat<C2_cmpeqp, seteq>;
1210 def: T_cmp64_rr_pat<C2_cmpgtp, setgt>;
1211 def: T_cmp64_rr_pat<C2_cmpgtup, setugt>;
1212 def: T_cmp64_rr_pat<C2_cmpgtp, RevCmp<setlt>>;
1213 def: T_cmp64_rr_pat<C2_cmpgtup, RevCmp<setult>>;
1215 def C2_vmux : ALU64_rr<(outs DoubleRegs:$Rd),
1216 (ins PredRegs:$Pu, DoubleRegs:$Rs, DoubleRegs:$Rt),
1217 "$Rd = vmux($Pu, $Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
1218 let hasSideEffects = 0;
1225 let IClass = 0b1101;
1226 let Inst{27-24} = 0b0001;
1227 let Inst{20-16} = Rs;
1228 let Inst{12-8} = Rt;
1233 class T_ALU64_rr<string mnemonic, string suffix, bits<4> RegType,
1234 bits<3> MajOp, bits<3> MinOp, bit OpsRev, bit IsComm,
1236 : ALU64_rr<(outs DoubleRegs:$Rd), (ins DoubleRegs:$Rs, DoubleRegs:$Rt),
1237 "$Rd = " #mnemonic# "($Rs, " #Op2Pfx# "$Rt)" #suffix, [],
1238 "", ALU64_tc_1_SLOT23> {
1239 let hasSideEffects = 0;
1240 let isCommutable = IsComm;
1246 let IClass = 0b1101;
1247 let Inst{27-24} = RegType;
1248 let Inst{23-21} = MajOp;
1249 let Inst{20-16} = !if (OpsRev,Rt,Rs);
1250 let Inst{12-8} = !if (OpsRev,Rs,Rt);
1251 let Inst{7-5} = MinOp;
1255 class T_ALU64_arith<string mnemonic, bits<3> MajOp, bits<3> MinOp, bit IsSat,
1256 bit OpsRev, bit IsComm>
1257 : T_ALU64_rr<mnemonic, !if(IsSat,":sat",""), 0b0011, MajOp, MinOp, OpsRev,
1260 def A2_addp : T_ALU64_arith<"add", 0b000, 0b111, 0, 0, 1>;
1261 def A2_subp : T_ALU64_arith<"sub", 0b001, 0b111, 0, 1, 0>;
1263 def: Pat<(i64 (add I64:$Rs, I64:$Rt)), (A2_addp I64:$Rs, I64:$Rt)>;
1264 def: Pat<(i64 (sub I64:$Rs, I64:$Rt)), (A2_subp I64:$Rs, I64:$Rt)>;
1266 class T_ALU64_logical<string mnemonic, bits<3> MinOp, bit OpsRev, bit IsComm,
1268 : T_ALU64_rr<mnemonic, "", 0b0011, 0b111, MinOp, OpsRev, IsComm,
1271 def A2_andp : T_ALU64_logical<"and", 0b000, 0, 1, 0>;
1272 def A2_orp : T_ALU64_logical<"or", 0b010, 0, 1, 0>;
1273 def A2_xorp : T_ALU64_logical<"xor", 0b100, 0, 1, 0>;
1275 def: Pat<(i64 (and I64:$Rs, I64:$Rt)), (A2_andp I64:$Rs, I64:$Rt)>;
1276 def: Pat<(i64 (or I64:$Rs, I64:$Rt)), (A2_orp I64:$Rs, I64:$Rt)>;
1277 def: Pat<(i64 (xor I64:$Rs, I64:$Rt)), (A2_xorp I64:$Rs, I64:$Rt)>;
1279 //===----------------------------------------------------------------------===//
1281 //===----------------------------------------------------------------------===//
1283 //===----------------------------------------------------------------------===//
1285 //===----------------------------------------------------------------------===//
1287 //===----------------------------------------------------------------------===//
1289 //===----------------------------------------------------------------------===//
1291 //===----------------------------------------------------------------------===//
1293 //===----------------------------------------------------------------------===//
1295 //===----------------------------------------------------------------------===//
1297 //===----------------------------------------------------------------------===//
1299 //===----------------------------------------------------------------------===//
1301 //===----------------------------------------------------------------------===//
1302 // Logical reductions on predicates.
1304 // Looping instructions.
1306 // Pipelined looping instructions.
1308 // Logical operations on predicates.
1309 let hasSideEffects = 0 in
1310 class T_LOGICAL_1OP<string MnOp, bits<2> OpBits>
1311 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps),
1312 "$Pd = " # MnOp # "($Ps)", [], "", CR_tc_2early_SLOT23> {
1316 let IClass = 0b0110;
1317 let Inst{27-23} = 0b10111;
1318 let Inst{22-21} = OpBits;
1320 let Inst{17-16} = Ps;
1325 def C2_any8 : T_LOGICAL_1OP<"any8", 0b00>;
1326 def C2_all8 : T_LOGICAL_1OP<"all8", 0b01>;
1327 def C2_not : T_LOGICAL_1OP<"not", 0b10>;
1329 def: Pat<(i1 (not (i1 PredRegs:$Ps))),
1330 (C2_not PredRegs:$Ps)>;
1332 let hasSideEffects = 0 in
1333 class T_LOGICAL_2OP<string MnOp, bits<3> OpBits, bit IsNeg, bit Rev>
1334 : CRInst<(outs PredRegs:$Pd), (ins PredRegs:$Ps, PredRegs:$Pt),
1335 "$Pd = " # MnOp # "($Ps, " # !if (IsNeg,"!","") # "$Pt)",
1336 [], "", CR_tc_2early_SLOT23> {
1341 let IClass = 0b0110;
1342 let Inst{27-24} = 0b1011;
1343 let Inst{23-21} = OpBits;
1345 let Inst{17-16} = !if(Rev,Pt,Ps); // Rs and Rt are reversed for some
1346 let Inst{13} = 0b0; // instructions.
1347 let Inst{9-8} = !if(Rev,Ps,Pt);
1351 def C2_and : T_LOGICAL_2OP<"and", 0b000, 0, 1>;
1352 def C2_or : T_LOGICAL_2OP<"or", 0b001, 0, 1>;
1353 def C2_xor : T_LOGICAL_2OP<"xor", 0b010, 0, 0>;
1354 def C2_andn : T_LOGICAL_2OP<"and", 0b011, 1, 1>;
1355 def C2_orn : T_LOGICAL_2OP<"or", 0b111, 1, 1>;
1357 def: Pat<(i1 (and I1:$Ps, I1:$Pt)), (C2_and I1:$Ps, I1:$Pt)>;
1358 def: Pat<(i1 (or I1:$Ps, I1:$Pt)), (C2_or I1:$Ps, I1:$Pt)>;
1359 def: Pat<(i1 (xor I1:$Ps, I1:$Pt)), (C2_xor I1:$Ps, I1:$Pt)>;
1360 def: Pat<(i1 (and I1:$Ps, (not I1:$Pt))), (C2_andn I1:$Ps, I1:$Pt)>;
1361 def: Pat<(i1 (or I1:$Ps, (not I1:$Pt))), (C2_orn I1:$Ps, I1:$Pt)>;
1363 let hasSideEffects = 0, hasNewValue = 1 in
1364 def C2_vitpack : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps, PredRegs:$Pt),
1365 "$Rd = vitpack($Ps, $Pt)", [], "", S_2op_tc_1_SLOT23> {
1370 let IClass = 0b1000;
1371 let Inst{27-24} = 0b1001;
1372 let Inst{22-21} = 0b00;
1373 let Inst{17-16} = Ps;
1378 let hasSideEffects = 0 in
1379 def C2_mask : SInst<(outs DoubleRegs:$Rd), (ins PredRegs:$Pt),
1380 "$Rd = mask($Pt)", [], "", S_2op_tc_1_SLOT23> {
1384 let IClass = 0b1000;
1385 let Inst{27-24} = 0b0110;
1390 // User control register transfer.
1391 //===----------------------------------------------------------------------===//
1393 //===----------------------------------------------------------------------===//
1395 //===----------------------------------------------------------------------===//
1397 //===----------------------------------------------------------------------===//
1399 def retflag : SDNode<"HexagonISD::RET_FLAG", SDTNone,
1400 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
1401 def eh_return: SDNode<"HexagonISD::EH_RETURN", SDTNone, [SDNPHasChain]>;
1403 def SDHexagonBR_JT: SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
1404 def HexagonBR_JT: SDNode<"HexagonISD::BR_JT", SDHexagonBR_JT, [SDNPHasChain]>;
1406 class CondStr<string CReg, bit True, bit New> {
1407 string S = "if (" # !if(True,"","!") # CReg # !if(New,".new","") # ") ";
1409 class JumpOpcStr<string Mnemonic, bit New, bit Taken> {
1410 string S = Mnemonic # !if(New, !if(Taken,":t",":nt"), "");
1413 let isBranch = 1, isBarrier = 1, Defs = [PC], hasSideEffects = 0,
1415 isExtendable = 1, opExtendable = 0, isExtentSigned = 1,
1416 opExtentBits = 24, opExtentAlign = 2, InputType = "imm" in
1417 class T_JMP<string ExtStr>
1418 : JInst<(outs), (ins brtarget:$dst),
1419 "jump " # ExtStr # "$dst",
1420 [], "", J_tc_2early_SLOT23> {
1422 let IClass = 0b0101;
1424 let Inst{27-25} = 0b100;
1425 let Inst{24-16} = dst{23-15};
1426 let Inst{13-1} = dst{14-2};
1429 let isBranch = 1, Defs = [PC], hasSideEffects = 0, isPredicated = 1,
1430 isExtendable = 1, opExtendable = 1, isExtentSigned = 1,
1431 opExtentBits = 17, opExtentAlign = 2, InputType = "imm" in
1432 class T_JMP_c<bit PredNot, bit isPredNew, bit isTak, string ExtStr>
1433 : JInst<(outs), (ins PredRegs:$src, brtarget:$dst),
1434 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1435 JumpOpcStr<"jump", isPredNew, isTak>.S # " " #
1437 [], "", J_tc_2early_SLOT23>, ImmRegRel {
1438 let isTaken = isTak;
1439 let isPredicatedFalse = PredNot;
1440 let isPredicatedNew = isPredNew;
1444 let IClass = 0b0101;
1446 let Inst{27-24} = 0b1100;
1447 let Inst{21} = PredNot;
1448 let Inst{12} = !if(isPredNew, isTak, zero);
1449 let Inst{11} = isPredNew;
1450 let Inst{9-8} = src;
1451 let Inst{23-22} = dst{16-15};
1452 let Inst{20-16} = dst{14-10};
1453 let Inst{13} = dst{9};
1454 let Inst{7-1} = dst{8-2};
1457 multiclass JMP_Pred<bit PredNot, string ExtStr> {
1458 def NAME : T_JMP_c<PredNot, 0, 0, ExtStr>;
1460 def NAME#newpt : T_JMP_c<PredNot, 1, 1, ExtStr>; // taken
1461 def NAME#new : T_JMP_c<PredNot, 1, 0, ExtStr>; // not taken
1464 multiclass JMP_base<string BaseOp, string ExtStr> {
1465 let BaseOpcode = BaseOp in {
1466 def NAME : T_JMP<ExtStr>;
1467 defm t : JMP_Pred<0, ExtStr>;
1468 defm f : JMP_Pred<1, ExtStr>;
1472 // Jumps to address stored in a register, JUMPR_MISC
1473 // if ([[!]P[.new]]) jumpr[:t/nt] Rs
1474 let isBranch = 1, isIndirectBranch = 1, isBarrier = 1, Defs = [PC],
1475 isPredicable = 1, hasSideEffects = 0, InputType = "reg" in
1477 : JRInst<(outs), (ins IntRegs:$dst),
1478 "jumpr $dst", [], "", J_tc_2early_SLOT2> {
1481 let IClass = 0b0101;
1482 let Inst{27-21} = 0b0010100;
1483 let Inst{20-16} = dst;
1486 let isBranch = 1, isIndirectBranch = 1, Defs = [PC], isPredicated = 1,
1487 hasSideEffects = 0, InputType = "reg" in
1488 class T_JMPr_c <bit PredNot, bit isPredNew, bit isTak>
1489 : JRInst <(outs), (ins PredRegs:$src, IntRegs:$dst),
1490 CondStr<"$src", !if(PredNot,0,1), isPredNew>.S #
1491 JumpOpcStr<"jumpr", isPredNew, isTak>.S # " $dst", [],
1492 "", J_tc_2early_SLOT2> {
1494 let isTaken = isTak;
1495 let isPredicatedFalse = PredNot;
1496 let isPredicatedNew = isPredNew;
1500 let IClass = 0b0101;
1502 let Inst{27-22} = 0b001101;
1503 let Inst{21} = PredNot;
1504 let Inst{20-16} = dst;
1505 let Inst{12} = !if(isPredNew, isTak, zero);
1506 let Inst{11} = isPredNew;
1507 let Inst{9-8} = src;
1510 multiclass JMPR_Pred<bit PredNot> {
1511 def NAME: T_JMPr_c<PredNot, 0, 0>;
1513 def NAME#newpt : T_JMPr_c<PredNot, 1, 1>; // taken
1514 def NAME#new : T_JMPr_c<PredNot, 1, 0>; // not taken
1517 multiclass JMPR_base<string BaseOp> {
1518 let BaseOpcode = BaseOp in {
1520 defm t : JMPR_Pred<0>;
1521 defm f : JMPR_Pred<1>;
1525 let isCall = 1, hasSideEffects = 1 in
1526 class JUMPR_MISC_CALLR<bit isPred, bit isPredNot,
1527 dag InputDag = (ins IntRegs:$Rs)>
1528 : JRInst<(outs), InputDag,
1529 !if(isPred, !if(isPredNot, "if (!$Pu) callr $Rs",
1530 "if ($Pu) callr $Rs"),
1532 [], "", J_tc_2early_SLOT2> {
1535 let isPredicated = isPred;
1536 let isPredicatedFalse = isPredNot;
1538 let IClass = 0b0101;
1539 let Inst{27-25} = 0b000;
1540 let Inst{24-23} = !if (isPred, 0b10, 0b01);
1542 let Inst{21} = isPredNot;
1543 let Inst{9-8} = !if (isPred, Pu, 0b00);
1544 let Inst{20-16} = Rs;
1548 let Defs = VolatileV3.Regs in {
1549 def J2_callrt : JUMPR_MISC_CALLR<1, 0, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1550 def J2_callrf : JUMPR_MISC_CALLR<1, 1, (ins PredRegs:$Pu, IntRegs:$Rs)>;
1553 let isTerminator = 1, hasSideEffects = 0 in {
1554 defm J2_jump : JMP_base<"JMP", "">, PredNewRel;
1556 // Deal with explicit assembly
1557 // - never extened a jump #, always extend a jump ##
1558 let isAsmParserOnly = 1 in {
1559 defm J2_jump_ext : JMP_base<"JMP", "##">;
1560 defm J2_jump_noext : JMP_base<"JMP", "#">;
1563 defm J2_jumpr : JMPR_base<"JMPr">, PredNewRel;
1565 let isReturn = 1, isCodeGenOnly = 1 in
1566 defm JMPret : JMPR_base<"JMPret">, PredNewRel;
1569 def: Pat<(br bb:$dst),
1570 (J2_jump brtarget:$dst)>;
1572 (JMPret (i32 R31))>;
1573 def: Pat<(brcond (i1 PredRegs:$src1), bb:$offset),
1574 (J2_jumpt PredRegs:$src1, bb:$offset)>;
1576 // A return through builtin_eh_return.
1577 let isReturn = 1, isTerminator = 1, isBarrier = 1, hasSideEffects = 0,
1578 isCodeGenOnly = 1, Defs = [PC], Uses = [R28], isPredicable = 0 in
1579 def EH_RETURN_JMPR : T_JMPr;
1581 def: Pat<(eh_return),
1582 (EH_RETURN_JMPR (i32 R31))>;
1583 def: Pat<(HexagonBR_JT (i32 IntRegs:$dst)),
1584 (J2_jumpr IntRegs:$dst)>;
1585 def: Pat<(brind (i32 IntRegs:$dst)),
1586 (J2_jumpr IntRegs:$dst)>;
1588 //===----------------------------------------------------------------------===//
1590 //===----------------------------------------------------------------------===//
1592 //===----------------------------------------------------------------------===//
1594 //===----------------------------------------------------------------------===//
1595 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, AddedComplexity = 20 in
1596 class T_load_io <string mnemonic, RegisterClass RC, bits<4> MajOp,
1598 : LDInst<(outs RC:$dst), (ins IntRegs:$src1, ImmOp:$offset),
1599 "$dst = "#mnemonic#"($src1 + #$offset)", []>, AddrModeRel {
1604 bits<11> offsetBits;
1606 string ImmOpStr = !cast<string>(ImmOp);
1607 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), offset{13-3},
1608 !if (!eq(ImmOpStr, "s11_2Ext"), offset{12-2},
1609 !if (!eq(ImmOpStr, "s11_1Ext"), offset{11-1},
1610 /* s11_0Ext */ offset{10-0})));
1611 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
1612 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
1613 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
1614 /* s11_0Ext */ 11)));
1615 let hasNewValue = !if (!eq(ImmOpStr, "s11_3Ext"), 0, 1);
1617 let IClass = 0b1001;
1620 let Inst{26-25} = offsetBits{10-9};
1621 let Inst{24-21} = MajOp;
1622 let Inst{20-16} = src1;
1623 let Inst{13-5} = offsetBits{8-0};
1624 let Inst{4-0} = dst;
1627 let opExtendable = 3, isExtentSigned = 0, isPredicated = 1 in
1628 class T_pload_io <string mnemonic, RegisterClass RC, bits<4>MajOp,
1629 Operand ImmOp, bit isNot, bit isPredNew>
1630 : LDInst<(outs RC:$dst),
1631 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1632 "if ("#!if(isNot, "!$src1", "$src1")
1633 #!if(isPredNew, ".new", "")
1634 #") $dst = "#mnemonic#"($src2 + #$offset)",
1635 [],"", V2LDST_tc_ld_SLOT01> , AddrModeRel {
1641 string ImmOpStr = !cast<string>(ImmOp);
1643 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), offset{8-3},
1644 !if (!eq(ImmOpStr, "u6_2Ext"), offset{7-2},
1645 !if (!eq(ImmOpStr, "u6_1Ext"), offset{6-1},
1646 /* u6_0Ext */ offset{5-0})));
1647 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
1648 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
1649 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
1651 let hasNewValue = !if (!eq(ImmOpStr, "u6_3Ext"), 0, 1);
1652 let isPredicatedNew = isPredNew;
1653 let isPredicatedFalse = isNot;
1655 let IClass = 0b0100;
1659 let Inst{26} = isNot;
1660 let Inst{25} = isPredNew;
1661 let Inst{24-21} = MajOp;
1662 let Inst{20-16} = src2;
1664 let Inst{12-11} = src1;
1665 let Inst{10-5} = offsetBits;
1666 let Inst{4-0} = dst;
1669 let isExtendable = 1, hasSideEffects = 0, addrMode = BaseImmOffset in
1670 multiclass LD_Idxd<string mnemonic, string CextOp, RegisterClass RC,
1671 Operand ImmOp, Operand predImmOp, bits<4>MajOp> {
1672 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1673 let isPredicable = 1 in
1674 def L2_#NAME#_io : T_load_io <mnemonic, RC, MajOp, ImmOp>;
1677 def L2_p#NAME#t_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 0>;
1678 def L2_p#NAME#f_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 0>;
1681 def L2_p#NAME#tnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 0, 1>;
1682 def L2_p#NAME#fnew_io : T_pload_io <mnemonic, RC, MajOp, predImmOp, 1, 1>;
1686 let accessSize = ByteAccess in {
1687 defm loadrb: LD_Idxd <"memb", "LDrib", IntRegs, s11_0Ext, u6_0Ext, 0b1000>;
1688 defm loadrub: LD_Idxd <"memub", "LDriub", IntRegs, s11_0Ext, u6_0Ext, 0b1001>;
1691 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1692 defm loadrh: LD_Idxd <"memh", "LDrih", IntRegs, s11_1Ext, u6_1Ext, 0b1010>;
1693 defm loadruh: LD_Idxd <"memuh", "LDriuh", IntRegs, s11_1Ext, u6_1Ext, 0b1011>;
1696 let accessSize = WordAccess, opExtentAlign = 2 in
1697 defm loadri: LD_Idxd <"memw", "LDriw", IntRegs, s11_2Ext, u6_2Ext, 0b1100>;
1699 let accessSize = DoubleWordAccess, opExtentAlign = 3 in
1700 defm loadrd: LD_Idxd <"memd", "LDrid", DoubleRegs, s11_3Ext, u6_3Ext, 0b1110>;
1702 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1703 def L2_loadbsw2_io: T_load_io<"membh", IntRegs, 0b0001, s11_1Ext>;
1704 def L2_loadbzw2_io: T_load_io<"memubh", IntRegs, 0b0011, s11_1Ext>;
1707 let accessSize = WordAccess, opExtentAlign = 2 in {
1708 def L2_loadbzw4_io: T_load_io<"memubh", DoubleRegs, 0b0101, s11_2Ext>;
1709 def L2_loadbsw4_io: T_load_io<"membh", DoubleRegs, 0b0111, s11_2Ext>;
1712 // Patterns to select load-indexed (i.e. load from base+offset).
1713 multiclass Loadx_pat<PatFrag Load, ValueType VT, PatLeaf ImmPred,
1715 def: Pat<(VT (Load AddrFI:$fi)), (VT (MI AddrFI:$fi, 0))>;
1716 def: Pat<(VT (Load (add (i32 IntRegs:$Rs), ImmPred:$Off))),
1717 (VT (MI IntRegs:$Rs, imm:$Off))>;
1718 def: Pat<(VT (Load (i32 IntRegs:$Rs))), (VT (MI IntRegs:$Rs, 0))>;
1721 let AddedComplexity = 20 in {
1722 defm: Loadx_pat<load, i32, s11_2ExtPred, L2_loadri_io>;
1723 defm: Loadx_pat<load, i64, s11_3ExtPred, L2_loadrd_io>;
1724 defm: Loadx_pat<atomic_load_8 , i32, s11_0ExtPred, L2_loadrub_io>;
1725 defm: Loadx_pat<atomic_load_16, i32, s11_1ExtPred, L2_loadruh_io>;
1726 defm: Loadx_pat<atomic_load_32, i32, s11_2ExtPred, L2_loadri_io>;
1727 defm: Loadx_pat<atomic_load_64, i64, s11_3ExtPred, L2_loadrd_io>;
1729 defm: Loadx_pat<extloadi1, i32, s11_0ExtPred, L2_loadrub_io>;
1730 defm: Loadx_pat<extloadi8, i32, s11_0ExtPred, L2_loadrub_io>;
1731 defm: Loadx_pat<extloadi16, i32, s11_1ExtPred, L2_loadruh_io>;
1732 defm: Loadx_pat<sextloadi8, i32, s11_0ExtPred, L2_loadrb_io>;
1733 defm: Loadx_pat<sextloadi16, i32, s11_1ExtPred, L2_loadrh_io>;
1734 defm: Loadx_pat<zextloadi1, i32, s11_0ExtPred, L2_loadrub_io>;
1735 defm: Loadx_pat<zextloadi8, i32, s11_0ExtPred, L2_loadrub_io>;
1736 defm: Loadx_pat<zextloadi16, i32, s11_1ExtPred, L2_loadruh_io>;
1740 // Sign-extending loads of i1 need to replicate the lowest bit throughout
1741 // the 32-bit value. Since the loaded value can only be 0 or 1, 0-v should
1743 let AddedComplexity = 20 in
1744 def: Pat<(i32 (sextloadi1 (i32 IntRegs:$Rs))),
1745 (SUB_ri 0, (L2_loadrub_io IntRegs:$Rs, 0))>;
1747 //===----------------------------------------------------------------------===//
1748 // Post increment load
1749 //===----------------------------------------------------------------------===//
1750 //===----------------------------------------------------------------------===//
1751 // Template class for non-predicated post increment loads with immediate offset.
1752 //===----------------------------------------------------------------------===//
1753 let hasSideEffects = 0, addrMode = PostInc in
1754 class T_load_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
1756 : LDInstPI <(outs RC:$dst, IntRegs:$dst2),
1757 (ins IntRegs:$src1, ImmOp:$offset),
1758 "$dst = "#mnemonic#"($src1++#$offset)" ,
1767 string ImmOpStr = !cast<string>(ImmOp);
1768 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1769 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1770 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1771 /* s4_0Imm */ offset{3-0})));
1772 let hasNewValue = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
1774 let IClass = 0b1001;
1776 let Inst{27-25} = 0b101;
1777 let Inst{24-21} = MajOp;
1778 let Inst{20-16} = src1;
1779 let Inst{13-12} = 0b00;
1780 let Inst{8-5} = offsetBits;
1781 let Inst{4-0} = dst;
1784 //===----------------------------------------------------------------------===//
1785 // Template class for predicated post increment loads with immediate offset.
1786 //===----------------------------------------------------------------------===//
1787 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc in
1788 class T_pload_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
1789 bits<4> MajOp, bit isPredNot, bit isPredNew >
1790 : LDInst <(outs RC:$dst, IntRegs:$dst2),
1791 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset),
1792 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1793 ") ")#"$dst = "#mnemonic#"($src2++#$offset)",
1803 let isPredicatedNew = isPredNew;
1804 let isPredicatedFalse = isPredNot;
1806 string ImmOpStr = !cast<string>(ImmOp);
1807 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1808 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1809 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1810 /* s4_0Imm */ offset{3-0})));
1811 let hasNewValue = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
1813 let IClass = 0b1001;
1815 let Inst{27-25} = 0b101;
1816 let Inst{24-21} = MajOp;
1817 let Inst{20-16} = src2;
1819 let Inst{12} = isPredNew;
1820 let Inst{11} = isPredNot;
1821 let Inst{10-9} = src1;
1822 let Inst{8-5} = offsetBits;
1823 let Inst{4-0} = dst;
1826 //===----------------------------------------------------------------------===//
1827 // Multiclass for post increment loads with immediate offset.
1828 //===----------------------------------------------------------------------===//
1830 multiclass LD_PostInc <string mnemonic, string BaseOp, RegisterClass RC,
1831 Operand ImmOp, bits<4> MajOp> {
1832 let BaseOpcode = "POST_"#BaseOp in {
1833 let isPredicable = 1 in
1834 def L2_#NAME#_pi : T_load_pi < mnemonic, RC, ImmOp, MajOp>;
1837 def L2_p#NAME#t_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 0, 0>;
1838 def L2_p#NAME#f_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 1, 0>;
1841 def L2_p#NAME#tnew_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 0, 1>;
1842 def L2_p#NAME#fnew_pi : T_pload_pi < mnemonic, RC, ImmOp, MajOp, 1, 1>;
1846 // post increment byte loads with immediate offset
1847 let accessSize = ByteAccess in {
1848 defm loadrb : LD_PostInc <"memb", "LDrib", IntRegs, s4_0Imm, 0b1000>;
1849 defm loadrub : LD_PostInc <"memub", "LDriub", IntRegs, s4_0Imm, 0b1001>;
1852 // post increment halfword loads with immediate offset
1853 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1854 defm loadrh : LD_PostInc <"memh", "LDrih", IntRegs, s4_1Imm, 0b1010>;
1855 defm loadruh : LD_PostInc <"memuh", "LDriuh", IntRegs, s4_1Imm, 0b1011>;
1858 // post increment word loads with immediate offset
1859 let accessSize = WordAccess, opExtentAlign = 2 in
1860 defm loadri : LD_PostInc <"memw", "LDriw", IntRegs, s4_2Imm, 0b1100>;
1862 // post increment doubleword loads with immediate offset
1863 let accessSize = DoubleWordAccess, opExtentAlign = 3 in
1864 defm loadrd : LD_PostInc <"memd", "LDrid", DoubleRegs, s4_3Imm, 0b1110>;
1866 // Rd=memb[u]h(Rx++#s4:1)
1867 // Rdd=memb[u]h(Rx++#s4:2)
1868 let accessSize = HalfWordAccess, opExtentAlign = 1 in {
1869 def L2_loadbsw2_pi : T_load_pi <"membh", IntRegs, s4_1Imm, 0b0001>;
1870 def L2_loadbzw2_pi : T_load_pi <"memubh", IntRegs, s4_1Imm, 0b0011>;
1872 let accessSize = WordAccess, opExtentAlign = 2, hasNewValue = 0 in {
1873 def L2_loadbsw4_pi : T_load_pi <"membh", DoubleRegs, s4_2Imm, 0b0111>;
1874 def L2_loadbzw4_pi : T_load_pi <"memubh", DoubleRegs, s4_2Imm, 0b0101>;
1877 //===----------------------------------------------------------------------===//
1878 // Template class for post increment loads with register offset.
1879 //===----------------------------------------------------------------------===//
1880 let hasSideEffects = 0, addrMode = PostInc in
1881 class T_load_pr <string mnemonic, RegisterClass RC, bits<4> MajOp,
1882 MemAccessSize AccessSz>
1883 : LDInstPI <(outs RC:$dst, IntRegs:$_dst_),
1884 (ins IntRegs:$src1, ModRegs:$src2),
1885 "$dst = "#mnemonic#"($src1++$src2)" ,
1886 [], "$src1 = $_dst_" > {
1891 let accessSize = AccessSz;
1892 let IClass = 0b1001;
1894 let Inst{27-25} = 0b110;
1895 let Inst{24-21} = MajOp;
1896 let Inst{20-16} = src1;
1897 let Inst{13} = src2;
1900 let Inst{4-0} = dst;
1903 let hasNewValue = 1 in {
1904 def L2_loadrb_pr : T_load_pr <"memb", IntRegs, 0b1000, ByteAccess>;
1905 def L2_loadrub_pr : T_load_pr <"memub", IntRegs, 0b1001, ByteAccess>;
1906 def L2_loadrh_pr : T_load_pr <"memh", IntRegs, 0b1010, HalfWordAccess>;
1907 def L2_loadruh_pr : T_load_pr <"memuh", IntRegs, 0b1011, HalfWordAccess>;
1908 def L2_loadri_pr : T_load_pr <"memw", IntRegs, 0b1100, WordAccess>;
1910 def L2_loadbzw2_pr : T_load_pr <"memubh", IntRegs, 0b0011, HalfWordAccess>;
1913 def L2_loadrd_pr : T_load_pr <"memd", DoubleRegs, 0b1110, DoubleWordAccess>;
1914 def L2_loadbzw4_pr : T_load_pr <"memubh", DoubleRegs, 0b0101, WordAccess>;
1917 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 13,
1918 isPseudo = 1, Defs = [R10,R11,D5], hasSideEffects = 0 in
1919 def LDriw_pred : LDInst2<(outs PredRegs:$dst),
1921 "Error; should not emit",
1924 let Defs = [R29, R30, R31], Uses = [R30], hasSideEffects = 0 in
1925 def L2_deallocframe : LDInst<(outs), (ins),
1928 let IClass = 0b1001;
1930 let Inst{27-16} = 0b000000011110;
1932 let Inst{4-0} = 0b11110;
1935 // Load / Post increment circular addressing mode.
1936 let Uses = [CS], hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
1937 class T_load_pcr<string mnemonic, RegisterClass RC, bits<4> MajOp>
1938 : LDInst <(outs RC:$dst, IntRegs:$_dst_),
1939 (ins IntRegs:$Rz, ModRegs:$Mu),
1940 "$dst = "#mnemonic#"($Rz ++ I:circ($Mu))", [],
1946 let IClass = 0b1001;
1948 let Inst{27-25} = 0b100;
1949 let Inst{24-21} = MajOp;
1950 let Inst{20-16} = Rz;
1955 let Inst{4-0} = dst;
1958 let accessSize = ByteAccess in {
1959 def L2_loadrb_pcr : T_load_pcr <"memb", IntRegs, 0b1000>;
1960 def L2_loadrub_pcr : T_load_pcr <"memub", IntRegs, 0b1001>;
1963 let accessSize = HalfWordAccess in {
1964 def L2_loadrh_pcr : T_load_pcr <"memh", IntRegs, 0b1010>;
1965 def L2_loadruh_pcr : T_load_pcr <"memuh", IntRegs, 0b1011>;
1966 def L2_loadbsw2_pcr : T_load_pcr <"membh", IntRegs, 0b0001>;
1967 def L2_loadbzw2_pcr : T_load_pcr <"memubh", IntRegs, 0b0011>;
1970 let accessSize = WordAccess in {
1971 def L2_loadri_pcr : T_load_pcr <"memw", IntRegs, 0b1100>;
1972 let hasNewValue = 0 in {
1973 def L2_loadbzw4_pcr : T_load_pcr <"memubh", DoubleRegs, 0b0101>;
1974 def L2_loadbsw4_pcr : T_load_pcr <"membh", DoubleRegs, 0b0111>;
1978 let accessSize = DoubleWordAccess in
1979 def L2_loadrd_pcr : T_load_pcr <"memd", DoubleRegs, 0b1110>;
1981 //===----------------------------------------------------------------------===//
1982 // Circular loads with immediate offset.
1983 //===----------------------------------------------------------------------===//
1984 let Uses = [CS], mayLoad = 1, hasSideEffects = 0, hasNewValue = 1 in
1985 class T_load_pci <string mnemonic, RegisterClass RC,
1986 Operand ImmOp, bits<4> MajOp>
1987 : LDInstPI<(outs RC:$dst, IntRegs:$_dst_),
1988 (ins IntRegs:$Rz, ImmOp:$offset, ModRegs:$Mu),
1989 "$dst = "#mnemonic#"($Rz ++ #$offset:circ($Mu))", [],
1997 string ImmOpStr = !cast<string>(ImmOp);
1998 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
1999 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
2000 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
2001 /* s4_0Imm */ offset{3-0})));
2002 let IClass = 0b1001;
2003 let Inst{27-25} = 0b100;
2004 let Inst{24-21} = MajOp;
2005 let Inst{20-16} = Rz;
2009 let Inst{8-5} = offsetBits;
2010 let Inst{4-0} = dst;
2013 // Byte variants of circ load
2014 let accessSize = ByteAccess in {
2015 def L2_loadrb_pci : T_load_pci <"memb", IntRegs, s4_0Imm, 0b1000>;
2016 def L2_loadrub_pci : T_load_pci <"memub", IntRegs, s4_0Imm, 0b1001>;
2019 // Half word variants of circ load
2020 let accessSize = HalfWordAccess in {
2021 def L2_loadrh_pci : T_load_pci <"memh", IntRegs, s4_1Imm, 0b1010>;
2022 def L2_loadruh_pci : T_load_pci <"memuh", IntRegs, s4_1Imm, 0b1011>;
2023 def L2_loadbzw2_pci : T_load_pci <"memubh", IntRegs, s4_1Imm, 0b0011>;
2024 def L2_loadbsw2_pci : T_load_pci <"membh", IntRegs, s4_1Imm, 0b0001>;
2027 // Word variants of circ load
2028 let accessSize = WordAccess in
2029 def L2_loadri_pci : T_load_pci <"memw", IntRegs, s4_2Imm, 0b1100>;
2031 let accessSize = WordAccess, hasNewValue = 0 in {
2032 def L2_loadbzw4_pci : T_load_pci <"memubh", DoubleRegs, s4_2Imm, 0b0101>;
2033 def L2_loadbsw4_pci : T_load_pci <"membh", DoubleRegs, s4_2Imm, 0b0111>;
2036 let accessSize = DoubleWordAccess, hasNewValue = 0 in
2037 def L2_loadrd_pci : T_load_pci <"memd", DoubleRegs, s4_3Imm, 0b1110>;
2039 // L[24]_load[wd]_locked: Load word/double with lock.
2041 class T_load_locked <string mnemonic, RegisterClass RC>
2042 : LD0Inst <(outs RC:$dst),
2044 "$dst = "#mnemonic#"($src)"> {
2047 let IClass = 0b1001;
2048 let Inst{27-21} = 0b0010000;
2049 let Inst{20-16} = src;
2050 let Inst{13-12} = !if (!eq(mnemonic, "memd_locked"), 0b01, 0b00);
2051 let Inst{4-0} = dst;
2053 let hasNewValue = 1, accessSize = WordAccess, opNewValue = 0 in
2054 def L2_loadw_locked : T_load_locked <"memw_locked", IntRegs>;
2055 let accessSize = DoubleWordAccess in
2056 def L4_loadd_locked : T_load_locked <"memd_locked", DoubleRegs>;
2058 // S[24]_store[wd]_locked: Store word/double conditionally.
2059 let isSoloAX = 1, isPredicateLate = 1 in
2060 class T_store_locked <string mnemonic, RegisterClass RC>
2061 : ST0Inst <(outs PredRegs:$Pd), (ins IntRegs:$Rs, RC:$Rt),
2062 mnemonic#"($Rs, $Pd) = $Rt"> {
2067 let IClass = 0b1010;
2068 let Inst{27-23} = 0b00001;
2069 let Inst{22} = !if (!eq(mnemonic, "memw_locked"), 0b0, 0b1);
2071 let Inst{20-16} = Rs;
2072 let Inst{12-8} = Rt;
2076 let accessSize = WordAccess in
2077 def S2_storew_locked : T_store_locked <"memw_locked", IntRegs>;
2079 let accessSize = DoubleWordAccess in
2080 def S4_stored_locked : T_store_locked <"memd_locked", DoubleRegs>;
2082 //===----------------------------------------------------------------------===//
2083 // Bit-reversed loads with auto-increment register
2084 //===----------------------------------------------------------------------===//
2085 let hasSideEffects = 0 in
2086 class T_load_pbr<string mnemonic, RegisterClass RC,
2087 MemAccessSize addrSize, bits<4> majOp>
2089 <(outs RC:$dst, IntRegs:$_dst_),
2090 (ins IntRegs:$Rz, ModRegs:$Mu),
2091 "$dst = "#mnemonic#"($Rz ++ $Mu:brev)" ,
2092 [] , "$Rz = $_dst_" > {
2094 let accessSize = addrSize;
2100 let IClass = 0b1001;
2102 let Inst{27-25} = 0b111;
2103 let Inst{24-21} = majOp;
2104 let Inst{20-16} = Rz;
2108 let Inst{4-0} = dst;
2111 let hasNewValue =1, opNewValue = 0 in {
2112 def L2_loadrb_pbr : T_load_pbr <"memb", IntRegs, ByteAccess, 0b1000>;
2113 def L2_loadrub_pbr : T_load_pbr <"memub", IntRegs, ByteAccess, 0b1001>;
2114 def L2_loadrh_pbr : T_load_pbr <"memh", IntRegs, HalfWordAccess, 0b1010>;
2115 def L2_loadruh_pbr : T_load_pbr <"memuh", IntRegs, HalfWordAccess, 0b1011>;
2116 def L2_loadbsw2_pbr : T_load_pbr <"membh", IntRegs, HalfWordAccess, 0b0001>;
2117 def L2_loadbzw2_pbr : T_load_pbr <"memubh", IntRegs, HalfWordAccess, 0b0011>;
2118 def L2_loadri_pbr : T_load_pbr <"memw", IntRegs, WordAccess, 0b1100>;
2121 def L2_loadbzw4_pbr : T_load_pbr <"memubh", DoubleRegs, WordAccess, 0b0101>;
2122 def L2_loadbsw4_pbr : T_load_pbr <"membh", DoubleRegs, WordAccess, 0b0111>;
2123 def L2_loadrd_pbr : T_load_pbr <"memd", DoubleRegs, DoubleWordAccess, 0b1110>;
2125 //===----------------------------------------------------------------------===//
2127 //===----------------------------------------------------------------------===//
2129 //===----------------------------------------------------------------------===//
2131 //===----------------------------------------------------------------------===//
2132 //===----------------------------------------------------------------------===//
2134 //===----------------------------------------------------------------------===//
2136 //===----------------------------------------------------------------------===//
2138 //===----------------------------------------------------------------------===//
2139 //===----------------------------------------------------------------------===//
2141 //===----------------------------------------------------------------------===//
2143 //===----------------------------------------------------------------------===//
2145 //===----------------------------------------------------------------------===//
2147 //===----------------------------------------------------------------------===//
2149 // MPYS / Multipy signed/unsigned halfwords
2150 //Rd=mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
2151 //===----------------------------------------------------------------------===//
2153 let hasNewValue = 1, opNewValue = 0 in
2154 class T_M2_mpy < bits<2> LHbits, bit isSat, bit isRnd,
2155 bit hasShift, bit isUnsigned>
2156 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
2157 "$Rd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
2158 #", $Rt."#!if(LHbits{0},"h)","l)")
2159 #!if(hasShift,":<<1","")
2160 #!if(isRnd,":rnd","")
2161 #!if(isSat,":sat",""),
2162 [], "", M_tc_3x_SLOT23 > {
2167 let IClass = 0b1110;
2169 let Inst{27-24} = 0b1100;
2170 let Inst{23} = hasShift;
2171 let Inst{22} = isUnsigned;
2172 let Inst{21} = isRnd;
2173 let Inst{7} = isSat;
2174 let Inst{6-5} = LHbits;
2176 let Inst{20-16} = Rs;
2177 let Inst{12-8} = Rt;
2180 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2181 def M2_mpy_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 0>;
2182 def M2_mpy_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 0>;
2183 def M2_mpy_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 0>;
2184 def M2_mpy_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 0>;
2185 def M2_mpy_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 0>;
2186 def M2_mpy_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 0>;
2187 def M2_mpy_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 0>;
2188 def M2_mpy_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 0>;
2190 //Rd=mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2191 def M2_mpyu_ll_s1: T_M2_mpy<0b00, 0, 0, 1, 1>;
2192 def M2_mpyu_ll_s0: T_M2_mpy<0b00, 0, 0, 0, 1>;
2193 def M2_mpyu_lh_s1: T_M2_mpy<0b01, 0, 0, 1, 1>;
2194 def M2_mpyu_lh_s0: T_M2_mpy<0b01, 0, 0, 0, 1>;
2195 def M2_mpyu_hl_s1: T_M2_mpy<0b10, 0, 0, 1, 1>;
2196 def M2_mpyu_hl_s0: T_M2_mpy<0b10, 0, 0, 0, 1>;
2197 def M2_mpyu_hh_s1: T_M2_mpy<0b11, 0, 0, 1, 1>;
2198 def M2_mpyu_hh_s0: T_M2_mpy<0b11, 0, 0, 0, 1>;
2200 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1]:rnd
2201 def M2_mpy_rnd_ll_s1: T_M2_mpy <0b00, 0, 1, 1, 0>;
2202 def M2_mpy_rnd_ll_s0: T_M2_mpy <0b00, 0, 1, 0, 0>;
2203 def M2_mpy_rnd_lh_s1: T_M2_mpy <0b01, 0, 1, 1, 0>;
2204 def M2_mpy_rnd_lh_s0: T_M2_mpy <0b01, 0, 1, 0, 0>;
2205 def M2_mpy_rnd_hl_s1: T_M2_mpy <0b10, 0, 1, 1, 0>;
2206 def M2_mpy_rnd_hl_s0: T_M2_mpy <0b10, 0, 1, 0, 0>;
2207 def M2_mpy_rnd_hh_s1: T_M2_mpy <0b11, 0, 1, 1, 0>;
2208 def M2_mpy_rnd_hh_s0: T_M2_mpy <0b11, 0, 1, 0, 0>;
2210 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2211 //Rd=mpy(Rs.[H|L],Rt.[H|L])[:<<1][:rnd][:sat]
2212 let Defs = [USR_OVF] in {
2213 def M2_mpy_sat_ll_s1: T_M2_mpy <0b00, 1, 0, 1, 0>;
2214 def M2_mpy_sat_ll_s0: T_M2_mpy <0b00, 1, 0, 0, 0>;
2215 def M2_mpy_sat_lh_s1: T_M2_mpy <0b01, 1, 0, 1, 0>;
2216 def M2_mpy_sat_lh_s0: T_M2_mpy <0b01, 1, 0, 0, 0>;
2217 def M2_mpy_sat_hl_s1: T_M2_mpy <0b10, 1, 0, 1, 0>;
2218 def M2_mpy_sat_hl_s0: T_M2_mpy <0b10, 1, 0, 0, 0>;
2219 def M2_mpy_sat_hh_s1: T_M2_mpy <0b11, 1, 0, 1, 0>;
2220 def M2_mpy_sat_hh_s0: T_M2_mpy <0b11, 1, 0, 0, 0>;
2222 def M2_mpy_sat_rnd_ll_s1: T_M2_mpy <0b00, 1, 1, 1, 0>;
2223 def M2_mpy_sat_rnd_ll_s0: T_M2_mpy <0b00, 1, 1, 0, 0>;
2224 def M2_mpy_sat_rnd_lh_s1: T_M2_mpy <0b01, 1, 1, 1, 0>;
2225 def M2_mpy_sat_rnd_lh_s0: T_M2_mpy <0b01, 1, 1, 0, 0>;
2226 def M2_mpy_sat_rnd_hl_s1: T_M2_mpy <0b10, 1, 1, 1, 0>;
2227 def M2_mpy_sat_rnd_hl_s0: T_M2_mpy <0b10, 1, 1, 0, 0>;
2228 def M2_mpy_sat_rnd_hh_s1: T_M2_mpy <0b11, 1, 1, 1, 0>;
2229 def M2_mpy_sat_rnd_hh_s0: T_M2_mpy <0b11, 1, 1, 0, 0>;
2232 //===----------------------------------------------------------------------===//
2234 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
2235 // result from the accumulator.
2236 //Rx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2237 //===----------------------------------------------------------------------===//
2239 let hasNewValue = 1, opNewValue = 0 in
2240 class T_M2_mpy_acc < bits<2> LHbits, bit isSat, bit isNac,
2241 bit hasShift, bit isUnsigned >
2242 : MInst_acc<(outs IntRegs:$Rx), (ins IntRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2243 "$Rx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
2244 #"($Rs."#!if(LHbits{1},"h","l")
2245 #", $Rt."#!if(LHbits{0},"h)","l)")
2246 #!if(hasShift,":<<1","")
2247 #!if(isSat,":sat",""),
2248 [], "$dst2 = $Rx", M_tc_3x_SLOT23 > {
2253 let IClass = 0b1110;
2254 let Inst{27-24} = 0b1110;
2255 let Inst{23} = hasShift;
2256 let Inst{22} = isUnsigned;
2257 let Inst{21} = isNac;
2258 let Inst{7} = isSat;
2259 let Inst{6-5} = LHbits;
2261 let Inst{20-16} = Rs;
2262 let Inst{12-8} = Rt;
2265 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2266 def M2_mpy_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 0>;
2267 def M2_mpy_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 0>;
2268 def M2_mpy_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 0>;
2269 def M2_mpy_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 0>;
2270 def M2_mpy_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 0>;
2271 def M2_mpy_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 0>;
2272 def M2_mpy_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 0>;
2273 def M2_mpy_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 0>;
2275 //Rx += mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2276 def M2_mpyu_acc_ll_s1: T_M2_mpy_acc <0b00, 0, 0, 1, 1>;
2277 def M2_mpyu_acc_ll_s0: T_M2_mpy_acc <0b00, 0, 0, 0, 1>;
2278 def M2_mpyu_acc_lh_s1: T_M2_mpy_acc <0b01, 0, 0, 1, 1>;
2279 def M2_mpyu_acc_lh_s0: T_M2_mpy_acc <0b01, 0, 0, 0, 1>;
2280 def M2_mpyu_acc_hl_s1: T_M2_mpy_acc <0b10, 0, 0, 1, 1>;
2281 def M2_mpyu_acc_hl_s0: T_M2_mpy_acc <0b10, 0, 0, 0, 1>;
2282 def M2_mpyu_acc_hh_s1: T_M2_mpy_acc <0b11, 0, 0, 1, 1>;
2283 def M2_mpyu_acc_hh_s0: T_M2_mpy_acc <0b11, 0, 0, 0, 1>;
2285 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]
2286 def M2_mpy_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 0>;
2287 def M2_mpy_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 0>;
2288 def M2_mpy_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 0>;
2289 def M2_mpy_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 0>;
2290 def M2_mpy_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 0>;
2291 def M2_mpy_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 0>;
2292 def M2_mpy_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 0>;
2293 def M2_mpy_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 0>;
2295 //Rx -= mpyu(Rs.[H|L],Rt.[H|L])[:<<1]
2296 def M2_mpyu_nac_ll_s1: T_M2_mpy_acc <0b00, 0, 1, 1, 1>;
2297 def M2_mpyu_nac_ll_s0: T_M2_mpy_acc <0b00, 0, 1, 0, 1>;
2298 def M2_mpyu_nac_lh_s1: T_M2_mpy_acc <0b01, 0, 1, 1, 1>;
2299 def M2_mpyu_nac_lh_s0: T_M2_mpy_acc <0b01, 0, 1, 0, 1>;
2300 def M2_mpyu_nac_hl_s1: T_M2_mpy_acc <0b10, 0, 1, 1, 1>;
2301 def M2_mpyu_nac_hl_s0: T_M2_mpy_acc <0b10, 0, 1, 0, 1>;
2302 def M2_mpyu_nac_hh_s1: T_M2_mpy_acc <0b11, 0, 1, 1, 1>;
2303 def M2_mpyu_nac_hh_s0: T_M2_mpy_acc <0b11, 0, 1, 0, 1>;
2305 //Rx += mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
2306 def M2_mpy_acc_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 0, 1, 0>;
2307 def M2_mpy_acc_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 0, 0, 0>;
2308 def M2_mpy_acc_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 0, 1, 0>;
2309 def M2_mpy_acc_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 0, 0, 0>;
2310 def M2_mpy_acc_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 0, 1, 0>;
2311 def M2_mpy_acc_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 0, 0, 0>;
2312 def M2_mpy_acc_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 0, 1, 0>;
2313 def M2_mpy_acc_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 0, 0, 0>;
2315 //Rx -= mpy(Rs.[H|L],Rt.[H|L])[:<<1]:sat
2316 def M2_mpy_nac_sat_ll_s1: T_M2_mpy_acc <0b00, 1, 1, 1, 0>;
2317 def M2_mpy_nac_sat_ll_s0: T_M2_mpy_acc <0b00, 1, 1, 0, 0>;
2318 def M2_mpy_nac_sat_lh_s1: T_M2_mpy_acc <0b01, 1, 1, 1, 0>;
2319 def M2_mpy_nac_sat_lh_s0: T_M2_mpy_acc <0b01, 1, 1, 0, 0>;
2320 def M2_mpy_nac_sat_hl_s1: T_M2_mpy_acc <0b10, 1, 1, 1, 0>;
2321 def M2_mpy_nac_sat_hl_s0: T_M2_mpy_acc <0b10, 1, 1, 0, 0>;
2322 def M2_mpy_nac_sat_hh_s1: T_M2_mpy_acc <0b11, 1, 1, 1, 0>;
2323 def M2_mpy_nac_sat_hh_s0: T_M2_mpy_acc <0b11, 1, 1, 0, 0>;
2325 //===----------------------------------------------------------------------===//
2327 // MPYS / Multipy signed/unsigned halfwords and add/subtract the
2328 // result from the 64-bit destination register.
2329 //Rxx [-+]= mpy[u](Rs.[H|L],Rt.[H|L])[:<<1][:sat]
2330 //===----------------------------------------------------------------------===//
2332 class T_M2_mpyd_acc < bits<2> LHbits, bit isNac, bit hasShift, bit isUnsigned>
2333 : MInst_acc<(outs DoubleRegs:$Rxx),
2334 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2335 "$Rxx "#!if(isNac,"-= ","+= ")#!if(isUnsigned,"mpyu","mpy")
2336 #"($Rs."#!if(LHbits{1},"h","l")
2337 #", $Rt."#!if(LHbits{0},"h)","l)")
2338 #!if(hasShift,":<<1",""),
2339 [], "$dst2 = $Rxx", M_tc_3x_SLOT23 > {
2344 let IClass = 0b1110;
2346 let Inst{27-24} = 0b0110;
2347 let Inst{23} = hasShift;
2348 let Inst{22} = isUnsigned;
2349 let Inst{21} = isNac;
2351 let Inst{6-5} = LHbits;
2352 let Inst{4-0} = Rxx;
2353 let Inst{20-16} = Rs;
2354 let Inst{12-8} = Rt;
2357 def M2_mpyd_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 0>;
2358 def M2_mpyd_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 0>;
2359 def M2_mpyd_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 0>;
2360 def M2_mpyd_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 0>;
2362 def M2_mpyd_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 0>;
2363 def M2_mpyd_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 0>;
2364 def M2_mpyd_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 0>;
2365 def M2_mpyd_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 0>;
2367 def M2_mpyd_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 0>;
2368 def M2_mpyd_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 0>;
2369 def M2_mpyd_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 0>;
2370 def M2_mpyd_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 0>;
2372 def M2_mpyd_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 0>;
2373 def M2_mpyd_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 0>;
2374 def M2_mpyd_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 0>;
2375 def M2_mpyd_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 0>;
2377 def M2_mpyud_acc_hh_s0: T_M2_mpyd_acc <0b11, 0, 0, 1>;
2378 def M2_mpyud_acc_hl_s0: T_M2_mpyd_acc <0b10, 0, 0, 1>;
2379 def M2_mpyud_acc_lh_s0: T_M2_mpyd_acc <0b01, 0, 0, 1>;
2380 def M2_mpyud_acc_ll_s0: T_M2_mpyd_acc <0b00, 0, 0, 1>;
2382 def M2_mpyud_acc_hh_s1: T_M2_mpyd_acc <0b11, 0, 1, 1>;
2383 def M2_mpyud_acc_hl_s1: T_M2_mpyd_acc <0b10, 0, 1, 1>;
2384 def M2_mpyud_acc_lh_s1: T_M2_mpyd_acc <0b01, 0, 1, 1>;
2385 def M2_mpyud_acc_ll_s1: T_M2_mpyd_acc <0b00, 0, 1, 1>;
2387 def M2_mpyud_nac_hh_s0: T_M2_mpyd_acc <0b11, 1, 0, 1>;
2388 def M2_mpyud_nac_hl_s0: T_M2_mpyd_acc <0b10, 1, 0, 1>;
2389 def M2_mpyud_nac_lh_s0: T_M2_mpyd_acc <0b01, 1, 0, 1>;
2390 def M2_mpyud_nac_ll_s0: T_M2_mpyd_acc <0b00, 1, 0, 1>;
2392 def M2_mpyud_nac_hh_s1: T_M2_mpyd_acc <0b11, 1, 1, 1>;
2393 def M2_mpyud_nac_hl_s1: T_M2_mpyd_acc <0b10, 1, 1, 1>;
2394 def M2_mpyud_nac_lh_s1: T_M2_mpyd_acc <0b01, 1, 1, 1>;
2395 def M2_mpyud_nac_ll_s1: T_M2_mpyd_acc <0b00, 1, 1, 1>;
2397 //===----------------------------------------------------------------------===//
2398 // Template Class -- Vector Multipy
2399 // Used for complex multiply real or imaginary, dual multiply and even halfwords
2400 //===----------------------------------------------------------------------===//
2401 class T_M2_vmpy < string opc, bits<3> MajOp, bits<3> MinOp, bit hasShift,
2402 bit isRnd, bit isSat >
2403 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2404 "$Rdd = "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2405 #!if(isRnd,":rnd","")
2406 #!if(isSat,":sat",""),
2412 let IClass = 0b1110;
2414 let Inst{27-24} = 0b1000;
2415 let Inst{23-21} = MajOp;
2416 let Inst{7-5} = MinOp;
2417 let Inst{4-0} = Rdd;
2418 let Inst{20-16} = Rss;
2419 let Inst{12-8} = Rtt;
2422 // Vector complex multiply imaginary: Rdd=vcmpyi(Rss,Rtt)[:<<1]:sat
2423 let Defs = [USR_OVF] in {
2424 def M2_vcmpy_s1_sat_i: T_M2_vmpy <"vcmpyi", 0b110, 0b110, 1, 0, 1>;
2425 def M2_vcmpy_s0_sat_i: T_M2_vmpy <"vcmpyi", 0b010, 0b110, 0, 0, 1>;
2428 // Vector complex multiply real: Rdd=vcmpyr(Rss,Rtt)[:<<1]:sat
2429 def M2_vcmpy_s1_sat_r: T_M2_vmpy <"vcmpyr", 0b101, 0b110, 1, 0, 1>;
2430 def M2_vcmpy_s0_sat_r: T_M2_vmpy <"vcmpyr", 0b001, 0b110, 0, 0, 1>;
2432 // Vector dual multiply: Rdd=vdmpy(Rss,Rtt)[:<<1]:sat
2433 def M2_vdmpys_s1: T_M2_vmpy <"vdmpy", 0b100, 0b100, 1, 0, 1>;
2434 def M2_vdmpys_s0: T_M2_vmpy <"vdmpy", 0b000, 0b100, 0, 0, 1>;
2436 // Vector multiply even halfwords: Rdd=vmpyeh(Rss,Rtt)[:<<1]:sat
2437 def M2_vmpy2es_s1: T_M2_vmpy <"vmpyeh", 0b100, 0b110, 1, 0, 1>;
2438 def M2_vmpy2es_s0: T_M2_vmpy <"vmpyeh", 0b000, 0b110, 0, 0, 1>;
2440 //Rdd=vmpywoh(Rss,Rtt)[:<<1][:rnd]:sat
2441 def M2_mmpyh_s0: T_M2_vmpy <"vmpywoh", 0b000, 0b111, 0, 0, 1>;
2442 def M2_mmpyh_s1: T_M2_vmpy <"vmpywoh", 0b100, 0b111, 1, 0, 1>;
2443 def M2_mmpyh_rs0: T_M2_vmpy <"vmpywoh", 0b001, 0b111, 0, 1, 1>;
2444 def M2_mmpyh_rs1: T_M2_vmpy <"vmpywoh", 0b101, 0b111, 1, 1, 1>;
2446 //Rdd=vmpyweh(Rss,Rtt)[:<<1][:rnd]:sat
2447 def M2_mmpyl_s0: T_M2_vmpy <"vmpyweh", 0b000, 0b101, 0, 0, 1>;
2448 def M2_mmpyl_s1: T_M2_vmpy <"vmpyweh", 0b100, 0b101, 1, 0, 1>;
2449 def M2_mmpyl_rs0: T_M2_vmpy <"vmpyweh", 0b001, 0b101, 0, 1, 1>;
2450 def M2_mmpyl_rs1: T_M2_vmpy <"vmpyweh", 0b101, 0b101, 1, 1, 1>;
2452 //Rdd=vmpywouh(Rss,Rtt)[:<<1][:rnd]:sat
2453 def M2_mmpyuh_s0: T_M2_vmpy <"vmpywouh", 0b010, 0b111, 0, 0, 1>;
2454 def M2_mmpyuh_s1: T_M2_vmpy <"vmpywouh", 0b110, 0b111, 1, 0, 1>;
2455 def M2_mmpyuh_rs0: T_M2_vmpy <"vmpywouh", 0b011, 0b111, 0, 1, 1>;
2456 def M2_mmpyuh_rs1: T_M2_vmpy <"vmpywouh", 0b111, 0b111, 1, 1, 1>;
2458 //Rdd=vmpyweuh(Rss,Rtt)[:<<1][:rnd]:sat
2459 def M2_mmpyul_s0: T_M2_vmpy <"vmpyweuh", 0b010, 0b101, 0, 0, 1>;
2460 def M2_mmpyul_s1: T_M2_vmpy <"vmpyweuh", 0b110, 0b101, 1, 0, 1>;
2461 def M2_mmpyul_rs0: T_M2_vmpy <"vmpyweuh", 0b011, 0b101, 0, 1, 1>;
2462 def M2_mmpyul_rs1: T_M2_vmpy <"vmpyweuh", 0b111, 0b101, 1, 1, 1>;
2464 let hasNewValue = 1, opNewValue = 0 in
2465 class T_MType_mpy <string mnemonic, bits<4> RegTyBits, RegisterClass RC,
2466 bits<3> MajOp, bits<3> MinOp, bit isSat = 0, bit isRnd = 0,
2467 string op2Suffix = "", bit isRaw = 0, bit isHi = 0 >
2468 : MInst <(outs IntRegs:$dst), (ins RC:$src1, RC:$src2),
2470 #"($src1, $src2"#op2Suffix#")"
2471 #!if(MajOp{2}, ":<<1", "")
2472 #!if(isRnd, ":rnd", "")
2473 #!if(isSat, ":sat", "")
2474 #!if(isRaw, !if(isHi, ":raw:hi", ":raw:lo"), ""), [] > {
2479 let IClass = 0b1110;
2481 let Inst{27-24} = RegTyBits;
2482 let Inst{23-21} = MajOp;
2483 let Inst{20-16} = src1;
2485 let Inst{12-8} = src2;
2486 let Inst{7-5} = MinOp;
2487 let Inst{4-0} = dst;
2490 class T_MType_vrcmpy <string mnemonic, bits<3> MajOp, bits<3> MinOp, bit isHi>
2491 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, 1, 1, "", 1, isHi>;
2493 class T_MType_dd <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2494 bit isSat = 0, bit isRnd = 0 >
2495 : T_MType_mpy <mnemonic, 0b1001, DoubleRegs, MajOp, MinOp, isSat, isRnd>;
2497 class T_MType_rr1 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2498 bit isSat = 0, bit isRnd = 0 >
2499 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd>;
2501 class T_MType_rr2 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2502 bit isSat = 0, bit isRnd = 0, string op2str = "" >
2503 : T_MType_mpy<mnemonic, 0b1101, IntRegs, MajOp, MinOp, isSat, isRnd, op2str>;
2505 def M2_vradduh : T_MType_dd <"vradduh", 0b000, 0b001, 0, 0>;
2506 def M2_vdmpyrs_s0 : T_MType_dd <"vdmpy", 0b000, 0b000, 1, 1>;
2507 def M2_vdmpyrs_s1 : T_MType_dd <"vdmpy", 0b100, 0b000, 1, 1>;
2509 let CextOpcode = "mpyi", InputType = "reg" in
2510 def M2_mpyi : T_MType_rr1 <"mpyi", 0b000, 0b000>, ImmRegRel;
2512 def M2_mpy_up : T_MType_rr1 <"mpy", 0b000, 0b001>;
2513 def M2_mpyu_up : T_MType_rr1 <"mpyu", 0b010, 0b001>;
2515 def M2_dpmpyss_rnd_s0 : T_MType_rr1 <"mpy", 0b001, 0b001, 0, 1>;
2517 def M2_vmpy2s_s0pack : T_MType_rr1 <"vmpyh", 0b001, 0b111, 1, 1>;
2518 def M2_vmpy2s_s1pack : T_MType_rr1 <"vmpyh", 0b101, 0b111, 1, 1>;
2520 def M2_hmmpyh_rs1 : T_MType_rr2 <"mpy", 0b101, 0b100, 1, 1, ".h">;
2521 def M2_hmmpyl_rs1 : T_MType_rr2 <"mpy", 0b111, 0b100, 1, 1, ".l">;
2523 def M2_cmpyrs_s0 : T_MType_rr2 <"cmpy", 0b001, 0b110, 1, 1>;
2524 def M2_cmpyrs_s1 : T_MType_rr2 <"cmpy", 0b101, 0b110, 1, 1>;
2525 def M2_cmpyrsc_s0 : T_MType_rr2 <"cmpy", 0b011, 0b110, 1, 1, "*">;
2526 def M2_cmpyrsc_s1 : T_MType_rr2 <"cmpy", 0b111, 0b110, 1, 1, "*">;
2529 def M2_vraddh : T_MType_dd <"vraddh", 0b001, 0b111, 0>;
2530 def M2_mpysu_up : T_MType_rr1 <"mpysu", 0b011, 0b001, 0>;
2531 def M2_mpy_up_s1 : T_MType_rr1 <"mpy", 0b101, 0b010, 0>;
2532 def M2_mpy_up_s1_sat : T_MType_rr1 <"mpy", 0b111, 0b000, 1>;
2534 def M2_hmmpyh_s1 : T_MType_rr2 <"mpy", 0b101, 0b000, 1, 0, ".h">;
2535 def M2_hmmpyl_s1 : T_MType_rr2 <"mpy", 0b101, 0b001, 1, 0, ".l">;
2537 def: Pat<(i32 (mul I32:$src1, I32:$src2)), (M2_mpyi I32:$src1, I32:$src2)>;
2538 def: Pat<(i32 (mulhs I32:$src1, I32:$src2)), (M2_mpy_up I32:$src1, I32:$src2)>;
2539 def: Pat<(i32 (mulhu I32:$src1, I32:$src2)), (M2_mpyu_up I32:$src1, I32:$src2)>;
2541 let hasNewValue = 1, opNewValue = 0 in
2542 class T_MType_mpy_ri <bit isNeg, Operand ImmOp, list<dag> pattern>
2543 : MInst < (outs IntRegs:$Rd), (ins IntRegs:$Rs, ImmOp:$u8),
2544 "$Rd ="#!if(isNeg, "- ", "+ ")#"mpyi($Rs, #$u8)" ,
2545 pattern, "", M_tc_3x_SLOT23> {
2550 let IClass = 0b1110;
2552 let Inst{27-24} = 0b0000;
2553 let Inst{23} = isNeg;
2556 let Inst{20-16} = Rs;
2557 let Inst{12-5} = u8;
2560 let isExtendable = 1, opExtentBits = 8, opExtendable = 2 in
2561 def M2_mpysip : T_MType_mpy_ri <0, u8Ext,
2562 [(set (i32 IntRegs:$Rd), (mul IntRegs:$Rs, u8ExtPred:$u8))]>;
2564 def M2_mpysin : T_MType_mpy_ri <1, u8Imm,
2565 [(set (i32 IntRegs:$Rd), (ineg (mul IntRegs:$Rs,
2568 // Assember mapped to M2_mpyi
2569 let isAsmParserOnly = 1 in
2570 def M2_mpyui : MInst<(outs IntRegs:$dst),
2571 (ins IntRegs:$src1, IntRegs:$src2),
2572 "$dst = mpyui($src1, $src2)">;
2575 // s9 is NOT the same as m9 - but it works.. so far.
2576 // Assembler maps to either Rd=+mpyi(Rs,#u8) or Rd=-mpyi(Rs,#u8)
2577 // depending on the value of m9. See Arch Spec.
2578 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 9,
2579 CextOpcode = "mpyi", InputType = "imm", hasNewValue = 1,
2580 isAsmParserOnly = 1 in
2581 def M2_mpysmi : MInst<(outs IntRegs:$dst), (ins IntRegs:$src1, s9Ext:$src2),
2582 "$dst = mpyi($src1, #$src2)",
2583 [(set (i32 IntRegs:$dst), (mul (i32 IntRegs:$src1),
2584 s9ExtPred:$src2))]>, ImmRegRel;
2586 let hasNewValue = 1, isExtendable = 1, opExtentBits = 8, opExtendable = 3,
2587 InputType = "imm" in
2588 class T_MType_acc_ri <string mnemonic, bits<3> MajOp, Operand ImmOp,
2589 list<dag> pattern = []>
2590 : MInst < (outs IntRegs:$dst), (ins IntRegs:$src1, IntRegs:$src2, ImmOp:$src3),
2591 "$dst "#mnemonic#"($src2, #$src3)",
2592 pattern, "$src1 = $dst", M_tc_2_SLOT23> {
2597 let IClass = 0b1110;
2599 let Inst{27-26} = 0b00;
2600 let Inst{25-23} = MajOp;
2601 let Inst{20-16} = src2;
2603 let Inst{12-5} = src3;
2604 let Inst{4-0} = dst;
2607 let InputType = "reg", hasNewValue = 1 in
2608 class T_MType_acc_rr <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2609 bit isSwap = 0, list<dag> pattern = [], bit hasNot = 0,
2610 bit isSat = 0, bit isShift = 0>
2611 : MInst < (outs IntRegs:$dst),
2612 (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3),
2613 "$dst "#mnemonic#"($src2, "#!if(hasNot, "~$src3)","$src3)")
2614 #!if(isShift, ":<<1", "")
2615 #!if(isSat, ":sat", ""),
2616 pattern, "$src1 = $dst", M_tc_2_SLOT23 > {
2621 let IClass = 0b1110;
2623 let Inst{27-24} = 0b1111;
2624 let Inst{23-21} = MajOp;
2625 let Inst{20-16} = !if(isSwap, src3, src2);
2627 let Inst{12-8} = !if(isSwap, src2, src3);
2628 let Inst{7-5} = MinOp;
2629 let Inst{4-0} = dst;
2632 let CextOpcode = "MPYI_acc", Itinerary = M_tc_3x_SLOT23 in {
2633 def M2_macsip : T_MType_acc_ri <"+= mpyi", 0b010, u8Ext,
2634 [(set (i32 IntRegs:$dst),
2635 (add (mul IntRegs:$src2, u8ExtPred:$src3),
2636 IntRegs:$src1))]>, ImmRegRel;
2638 def M2_maci : T_MType_acc_rr <"+= mpyi", 0b000, 0b000, 0,
2639 [(set (i32 IntRegs:$dst),
2640 (add (mul IntRegs:$src2, IntRegs:$src3),
2641 IntRegs:$src1))]>, ImmRegRel;
2644 let CextOpcode = "ADD_acc" in {
2645 let isExtentSigned = 1 in
2646 def M2_accii : T_MType_acc_ri <"+= add", 0b100, s8Ext,
2647 [(set (i32 IntRegs:$dst),
2648 (add (add (i32 IntRegs:$src2), s8_16ExtPred:$src3),
2649 (i32 IntRegs:$src1)))]>, ImmRegRel;
2651 def M2_acci : T_MType_acc_rr <"+= add", 0b000, 0b001, 0,
2652 [(set (i32 IntRegs:$dst),
2653 (add (add (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2654 (i32 IntRegs:$src1)))]>, ImmRegRel;
2657 let CextOpcode = "SUB_acc" in {
2658 let isExtentSigned = 1 in
2659 def M2_naccii : T_MType_acc_ri <"-= add", 0b101, s8Ext>, ImmRegRel;
2661 def M2_nacci : T_MType_acc_rr <"-= add", 0b100, 0b001, 0>, ImmRegRel;
2664 let Itinerary = M_tc_3x_SLOT23 in
2665 def M2_macsin : T_MType_acc_ri <"-= mpyi", 0b011, u8Ext>;
2667 def M2_xor_xacc : T_MType_acc_rr < "^= xor", 0b100, 0b011, 0>;
2668 def M2_subacc : T_MType_acc_rr <"+= sub", 0b000, 0b011, 1>;
2670 class T_MType_acc_pat1 <InstHexagon MI, SDNode firstOp, SDNode secOp,
2672 : Pat <(secOp IntRegs:$src1, (firstOp IntRegs:$src2, ImmPred:$src3)),
2673 (MI IntRegs:$src1, IntRegs:$src2, ImmPred:$src3)>;
2675 class T_MType_acc_pat2 <InstHexagon MI, SDNode firstOp, SDNode secOp>
2676 : Pat <(i32 (secOp IntRegs:$src1, (firstOp IntRegs:$src2, IntRegs:$src3))),
2677 (MI IntRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
2679 def : T_MType_acc_pat2 <M2_xor_xacc, xor, xor>;
2680 def : T_MType_acc_pat1 <M2_macsin, mul, sub, u8ExtPred>;
2682 def : T_MType_acc_pat1 <M2_naccii, add, sub, s8_16ExtPred>;
2683 def : T_MType_acc_pat2 <M2_nacci, add, sub>;
2685 //===----------------------------------------------------------------------===//
2686 // Template Class -- XType Vector Instructions
2687 //===----------------------------------------------------------------------===//
2688 class T_XTYPE_Vect < string opc, bits<3> MajOp, bits<3> MinOp, bit isConj >
2689 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2690 "$Rdd = "#opc#"($Rss, $Rtt"#!if(isConj,"*)",")"),
2696 let IClass = 0b1110;
2698 let Inst{27-24} = 0b1000;
2699 let Inst{23-21} = MajOp;
2700 let Inst{7-5} = MinOp;
2701 let Inst{4-0} = Rdd;
2702 let Inst{20-16} = Rss;
2703 let Inst{12-8} = Rtt;
2706 class T_XTYPE_Vect_acc < string opc, bits<3> MajOp, bits<3> MinOp, bit isConj >
2707 : MInst <(outs DoubleRegs:$Rdd),
2708 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2709 "$Rdd += "#opc#"($Rss, $Rtt"#!if(isConj,"*)",")"),
2710 [], "$dst2 = $Rdd",M_tc_3x_SLOT23 > {
2715 let IClass = 0b1110;
2717 let Inst{27-24} = 0b1010;
2718 let Inst{23-21} = MajOp;
2719 let Inst{7-5} = MinOp;
2720 let Inst{4-0} = Rdd;
2721 let Inst{20-16} = Rss;
2722 let Inst{12-8} = Rtt;
2725 class T_XTYPE_Vect_diff < bits<3> MajOp, string opc >
2726 : MInst <(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rtt, DoubleRegs:$Rss),
2727 "$Rdd = "#opc#"($Rtt, $Rss)",
2728 [], "",M_tc_2_SLOT23 > {
2733 let IClass = 0b1110;
2735 let Inst{27-24} = 0b1000;
2736 let Inst{23-21} = MajOp;
2737 let Inst{7-5} = 0b000;
2738 let Inst{4-0} = Rdd;
2739 let Inst{20-16} = Rss;
2740 let Inst{12-8} = Rtt;
2743 // Vector reduce add unsigned bytes: Rdd32=vrmpybu(Rss32,Rtt32)
2744 def A2_vraddub: T_XTYPE_Vect <"vraddub", 0b010, 0b001, 0>;
2745 def A2_vraddub_acc: T_XTYPE_Vect_acc <"vraddub", 0b010, 0b001, 0>;
2747 // Vector sum of absolute differences unsigned bytes: Rdd=vrsadub(Rss,Rtt)
2748 def A2_vrsadub: T_XTYPE_Vect <"vrsadub", 0b010, 0b010, 0>;
2749 def A2_vrsadub_acc: T_XTYPE_Vect_acc <"vrsadub", 0b010, 0b010, 0>;
2751 // Vector absolute difference words: Rdd=vabsdiffw(Rtt,Rss)
2752 def M2_vabsdiffw: T_XTYPE_Vect_diff<0b001, "vabsdiffw">;
2754 // Vector absolute difference: Rdd=vabsdiffh(Rtt,Rss)
2755 def M2_vabsdiffh: T_XTYPE_Vect_diff<0b011, "vabsdiffh">;
2757 // Vector reduce complex multiply real or imaginary:
2758 // Rdd[+]=vrcmpy[ir](Rss,Rtt[*])
2759 def M2_vrcmpyi_s0: T_XTYPE_Vect <"vrcmpyi", 0b000, 0b000, 0>;
2760 def M2_vrcmpyi_s0c: T_XTYPE_Vect <"vrcmpyi", 0b010, 0b000, 1>;
2761 def M2_vrcmaci_s0: T_XTYPE_Vect_acc <"vrcmpyi", 0b000, 0b000, 0>;
2762 def M2_vrcmaci_s0c: T_XTYPE_Vect_acc <"vrcmpyi", 0b010, 0b000, 1>;
2764 def M2_vrcmpyr_s0: T_XTYPE_Vect <"vrcmpyr", 0b000, 0b001, 0>;
2765 def M2_vrcmpyr_s0c: T_XTYPE_Vect <"vrcmpyr", 0b011, 0b001, 1>;
2766 def M2_vrcmacr_s0: T_XTYPE_Vect_acc <"vrcmpyr", 0b000, 0b001, 0>;
2767 def M2_vrcmacr_s0c: T_XTYPE_Vect_acc <"vrcmpyr", 0b011, 0b001, 1>;
2769 // Vector reduce halfwords:
2770 // Rdd[+]=vrmpyh(Rss,Rtt)
2771 def M2_vrmpy_s0: T_XTYPE_Vect <"vrmpyh", 0b000, 0b010, 0>;
2772 def M2_vrmac_s0: T_XTYPE_Vect_acc <"vrmpyh", 0b000, 0b010, 0>;
2774 //===----------------------------------------------------------------------===//
2775 // Template Class -- Vector Multipy with accumulation.
2776 // Used for complex multiply real or imaginary, dual multiply and even halfwords
2777 //===----------------------------------------------------------------------===//
2778 let Defs = [USR_OVF] in
2779 class T_M2_vmpy_acc_sat < string opc, bits<3> MajOp, bits<3> MinOp,
2780 bit hasShift, bit isRnd >
2781 : MInst <(outs DoubleRegs:$Rxx),
2782 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2783 "$Rxx += "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2784 #!if(isRnd,":rnd","")#":sat",
2785 [], "$dst2 = $Rxx",M_tc_3x_SLOT23 > {
2790 let IClass = 0b1110;
2792 let Inst{27-24} = 0b1010;
2793 let Inst{23-21} = MajOp;
2794 let Inst{7-5} = MinOp;
2795 let Inst{4-0} = Rxx;
2796 let Inst{20-16} = Rss;
2797 let Inst{12-8} = Rtt;
2800 class T_M2_vmpy_acc < string opc, bits<3> MajOp, bits<3> MinOp,
2801 bit hasShift, bit isRnd >
2802 : MInst <(outs DoubleRegs:$Rxx),
2803 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
2804 "$Rxx += "#opc#"($Rss, $Rtt)"#!if(hasShift,":<<1","")
2805 #!if(isRnd,":rnd",""),
2806 [], "$dst2 = $Rxx",M_tc_3x_SLOT23 > {
2811 let IClass = 0b1110;
2813 let Inst{27-24} = 0b1010;
2814 let Inst{23-21} = MajOp;
2815 let Inst{7-5} = MinOp;
2816 let Inst{4-0} = Rxx;
2817 let Inst{20-16} = Rss;
2818 let Inst{12-8} = Rtt;
2821 // Vector multiply word by signed half with accumulation
2822 // Rxx+=vmpyw[eo]h(Rss,Rtt)[:<<1][:rnd]:sat
2823 def M2_mmacls_s1: T_M2_vmpy_acc_sat <"vmpyweh", 0b100, 0b101, 1, 0>;
2824 def M2_mmacls_s0: T_M2_vmpy_acc_sat <"vmpyweh", 0b000, 0b101, 0, 0>;
2825 def M2_mmacls_rs1: T_M2_vmpy_acc_sat <"vmpyweh", 0b101, 0b101, 1, 1>;
2826 def M2_mmacls_rs0: T_M2_vmpy_acc_sat <"vmpyweh", 0b001, 0b101, 0, 1>;
2828 def M2_mmachs_s1: T_M2_vmpy_acc_sat <"vmpywoh", 0b100, 0b111, 1, 0>;
2829 def M2_mmachs_s0: T_M2_vmpy_acc_sat <"vmpywoh", 0b000, 0b111, 0, 0>;
2830 def M2_mmachs_rs1: T_M2_vmpy_acc_sat <"vmpywoh", 0b101, 0b111, 1, 1>;
2831 def M2_mmachs_rs0: T_M2_vmpy_acc_sat <"vmpywoh", 0b001, 0b111, 0, 1>;
2833 // Vector multiply word by unsigned half with accumulation
2834 // Rxx+=vmpyw[eo]uh(Rss,Rtt)[:<<1][:rnd]:sat
2835 def M2_mmaculs_s1: T_M2_vmpy_acc_sat <"vmpyweuh", 0b110, 0b101, 1, 0>;
2836 def M2_mmaculs_s0: T_M2_vmpy_acc_sat <"vmpyweuh", 0b010, 0b101, 0, 0>;
2837 def M2_mmaculs_rs1: T_M2_vmpy_acc_sat <"vmpyweuh", 0b111, 0b101, 1, 1>;
2838 def M2_mmaculs_rs0: T_M2_vmpy_acc_sat <"vmpyweuh", 0b011, 0b101, 0, 1>;
2840 def M2_mmacuhs_s1: T_M2_vmpy_acc_sat <"vmpywouh", 0b110, 0b111, 1, 0>;
2841 def M2_mmacuhs_s0: T_M2_vmpy_acc_sat <"vmpywouh", 0b010, 0b111, 0, 0>;
2842 def M2_mmacuhs_rs1: T_M2_vmpy_acc_sat <"vmpywouh", 0b111, 0b111, 1, 1>;
2843 def M2_mmacuhs_rs0: T_M2_vmpy_acc_sat <"vmpywouh", 0b011, 0b111, 0, 1>;
2845 // Vector multiply even halfwords with accumulation
2846 // Rxx+=vmpyeh(Rss,Rtt)[:<<1][:sat]
2847 def M2_vmac2es: T_M2_vmpy_acc <"vmpyeh", 0b001, 0b010, 0, 0>;
2848 def M2_vmac2es_s1: T_M2_vmpy_acc_sat <"vmpyeh", 0b100, 0b110, 1, 0>;
2849 def M2_vmac2es_s0: T_M2_vmpy_acc_sat <"vmpyeh", 0b000, 0b110, 0, 0>;
2851 // Vector dual multiply with accumulation
2852 // Rxx+=vdmpy(Rss,Rtt)[:sat]
2853 def M2_vdmacs_s1: T_M2_vmpy_acc_sat <"vdmpy", 0b100, 0b100, 1, 0>;
2854 def M2_vdmacs_s0: T_M2_vmpy_acc_sat <"vdmpy", 0b000, 0b100, 0, 0>;
2856 // Vector complex multiply real or imaginary with accumulation
2857 // Rxx+=vcmpy[ir](Rss,Rtt):sat
2858 def M2_vcmac_s0_sat_r: T_M2_vmpy_acc_sat <"vcmpyr", 0b001, 0b100, 0, 0>;
2859 def M2_vcmac_s0_sat_i: T_M2_vmpy_acc_sat <"vcmpyi", 0b010, 0b100, 0, 0>;
2861 //===----------------------------------------------------------------------===//
2862 // Template Class -- Multiply signed/unsigned halfwords with and without
2863 // saturation and rounding
2864 //===----------------------------------------------------------------------===//
2865 class T_M2_mpyd < bits<2> LHbits, bit isRnd, bit hasShift, bit isUnsigned >
2866 : MInst < (outs DoubleRegs:$Rdd), (ins IntRegs:$Rs, IntRegs:$Rt),
2867 "$Rdd = "#!if(isUnsigned,"mpyu","mpy")#"($Rs."#!if(LHbits{1},"h","l")
2868 #", $Rt."#!if(LHbits{0},"h)","l)")
2869 #!if(hasShift,":<<1","")
2870 #!if(isRnd,":rnd",""),
2876 let IClass = 0b1110;
2878 let Inst{27-24} = 0b0100;
2879 let Inst{23} = hasShift;
2880 let Inst{22} = isUnsigned;
2881 let Inst{21} = isRnd;
2882 let Inst{6-5} = LHbits;
2883 let Inst{4-0} = Rdd;
2884 let Inst{20-16} = Rs;
2885 let Inst{12-8} = Rt;
2888 def M2_mpyd_hh_s0: T_M2_mpyd<0b11, 0, 0, 0>;
2889 def M2_mpyd_hl_s0: T_M2_mpyd<0b10, 0, 0, 0>;
2890 def M2_mpyd_lh_s0: T_M2_mpyd<0b01, 0, 0, 0>;
2891 def M2_mpyd_ll_s0: T_M2_mpyd<0b00, 0, 0, 0>;
2893 def M2_mpyd_hh_s1: T_M2_mpyd<0b11, 0, 1, 0>;
2894 def M2_mpyd_hl_s1: T_M2_mpyd<0b10, 0, 1, 0>;
2895 def M2_mpyd_lh_s1: T_M2_mpyd<0b01, 0, 1, 0>;
2896 def M2_mpyd_ll_s1: T_M2_mpyd<0b00, 0, 1, 0>;
2898 def M2_mpyd_rnd_hh_s0: T_M2_mpyd<0b11, 1, 0, 0>;
2899 def M2_mpyd_rnd_hl_s0: T_M2_mpyd<0b10, 1, 0, 0>;
2900 def M2_mpyd_rnd_lh_s0: T_M2_mpyd<0b01, 1, 0, 0>;
2901 def M2_mpyd_rnd_ll_s0: T_M2_mpyd<0b00, 1, 0, 0>;
2903 def M2_mpyd_rnd_hh_s1: T_M2_mpyd<0b11, 1, 1, 0>;
2904 def M2_mpyd_rnd_hl_s1: T_M2_mpyd<0b10, 1, 1, 0>;
2905 def M2_mpyd_rnd_lh_s1: T_M2_mpyd<0b01, 1, 1, 0>;
2906 def M2_mpyd_rnd_ll_s1: T_M2_mpyd<0b00, 1, 1, 0>;
2908 //Rdd=mpyu(Rs.[HL],Rt.[HL])[:<<1]
2909 def M2_mpyud_hh_s0: T_M2_mpyd<0b11, 0, 0, 1>;
2910 def M2_mpyud_hl_s0: T_M2_mpyd<0b10, 0, 0, 1>;
2911 def M2_mpyud_lh_s0: T_M2_mpyd<0b01, 0, 0, 1>;
2912 def M2_mpyud_ll_s0: T_M2_mpyd<0b00, 0, 0, 1>;
2914 def M2_mpyud_hh_s1: T_M2_mpyd<0b11, 0, 1, 1>;
2915 def M2_mpyud_hl_s1: T_M2_mpyd<0b10, 0, 1, 1>;
2916 def M2_mpyud_lh_s1: T_M2_mpyd<0b01, 0, 1, 1>;
2917 def M2_mpyud_ll_s1: T_M2_mpyd<0b00, 0, 1, 1>;
2919 //===----------------------------------------------------------------------===//
2920 // Template Class for xtype mpy:
2923 // multiply 32X32 and use full result
2924 //===----------------------------------------------------------------------===//
2925 let hasSideEffects = 0 in
2926 class T_XTYPE_mpy64 <string mnemonic, bits<3> MajOp, bits<3> MinOp,
2927 bit isSat, bit hasShift, bit isConj>
2928 : MInst <(outs DoubleRegs:$Rdd),
2929 (ins IntRegs:$Rs, IntRegs:$Rt),
2930 "$Rdd = "#mnemonic#"($Rs, $Rt"#!if(isConj,"*)",")")
2931 #!if(hasShift,":<<1","")
2932 #!if(isSat,":sat",""),
2938 let IClass = 0b1110;
2940 let Inst{27-24} = 0b0101;
2941 let Inst{23-21} = MajOp;
2942 let Inst{20-16} = Rs;
2943 let Inst{12-8} = Rt;
2944 let Inst{7-5} = MinOp;
2945 let Inst{4-0} = Rdd;
2948 //===----------------------------------------------------------------------===//
2949 // Template Class for xtype mpy with accumulation into 64-bit:
2952 // multiply 32X32 and use full result
2953 //===----------------------------------------------------------------------===//
2954 class T_XTYPE_mpy64_acc <string op1, string op2, bits<3> MajOp, bits<3> MinOp,
2955 bit isSat, bit hasShift, bit isConj>
2956 : MInst <(outs DoubleRegs:$Rxx),
2957 (ins DoubleRegs:$dst2, IntRegs:$Rs, IntRegs:$Rt),
2958 "$Rxx "#op2#"= "#op1#"($Rs, $Rt"#!if(isConj,"*)",")")
2959 #!if(hasShift,":<<1","")
2960 #!if(isSat,":sat",""),
2962 [] , "$dst2 = $Rxx" > {
2967 let IClass = 0b1110;
2969 let Inst{27-24} = 0b0111;
2970 let Inst{23-21} = MajOp;
2971 let Inst{20-16} = Rs;
2972 let Inst{12-8} = Rt;
2973 let Inst{7-5} = MinOp;
2974 let Inst{4-0} = Rxx;
2977 // MPY - Multiply and use full result
2978 // Rdd = mpy[u](Rs,Rt)
2979 def M2_dpmpyss_s0 : T_XTYPE_mpy64 < "mpy", 0b000, 0b000, 0, 0, 0>;
2980 def M2_dpmpyuu_s0 : T_XTYPE_mpy64 < "mpyu", 0b010, 0b000, 0, 0, 0>;
2982 // Rxx[+-]= mpy[u](Rs,Rt)
2983 def M2_dpmpyss_acc_s0 : T_XTYPE_mpy64_acc < "mpy", "+", 0b000, 0b000, 0, 0, 0>;
2984 def M2_dpmpyss_nac_s0 : T_XTYPE_mpy64_acc < "mpy", "-", 0b001, 0b000, 0, 0, 0>;
2985 def M2_dpmpyuu_acc_s0 : T_XTYPE_mpy64_acc < "mpyu", "+", 0b010, 0b000, 0, 0, 0>;
2986 def M2_dpmpyuu_nac_s0 : T_XTYPE_mpy64_acc < "mpyu", "-", 0b011, 0b000, 0, 0, 0>;
2988 // Complex multiply real or imaginary
2989 // Rxx=cmpy[ir](Rs,Rt)
2990 def M2_cmpyi_s0 : T_XTYPE_mpy64 < "cmpyi", 0b000, 0b001, 0, 0, 0>;
2991 def M2_cmpyr_s0 : T_XTYPE_mpy64 < "cmpyr", 0b000, 0b010, 0, 0, 0>;
2993 // Rxx+=cmpy[ir](Rs,Rt)
2994 def M2_cmaci_s0 : T_XTYPE_mpy64_acc < "cmpyi", "+", 0b000, 0b001, 0, 0, 0>;
2995 def M2_cmacr_s0 : T_XTYPE_mpy64_acc < "cmpyr", "+", 0b000, 0b010, 0, 0, 0>;
2998 // Rdd=cmpy(Rs,Rt)[:<<]:sat
2999 def M2_cmpys_s0 : T_XTYPE_mpy64 < "cmpy", 0b000, 0b110, 1, 0, 0>;
3000 def M2_cmpys_s1 : T_XTYPE_mpy64 < "cmpy", 0b100, 0b110, 1, 1, 0>;
3002 // Rdd=cmpy(Rs,Rt*)[:<<]:sat
3003 def M2_cmpysc_s0 : T_XTYPE_mpy64 < "cmpy", 0b010, 0b110, 1, 0, 1>;
3004 def M2_cmpysc_s1 : T_XTYPE_mpy64 < "cmpy", 0b110, 0b110, 1, 1, 1>;
3006 // Rxx[-+]=cmpy(Rs,Rt)[:<<1]:sat
3007 def M2_cmacs_s0 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b000, 0b110, 1, 0, 0>;
3008 def M2_cnacs_s0 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b000, 0b111, 1, 0, 0>;
3009 def M2_cmacs_s1 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b100, 0b110, 1, 1, 0>;
3010 def M2_cnacs_s1 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b100, 0b111, 1, 1, 0>;
3012 // Rxx[-+]=cmpy(Rs,Rt*)[:<<1]:sat
3013 def M2_cmacsc_s0 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b010, 0b110, 1, 0, 1>;
3014 def M2_cnacsc_s0 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b010, 0b111, 1, 0, 1>;
3015 def M2_cmacsc_s1 : T_XTYPE_mpy64_acc < "cmpy", "+", 0b110, 0b110, 1, 1, 1>;
3016 def M2_cnacsc_s1 : T_XTYPE_mpy64_acc < "cmpy", "-", 0b110, 0b111, 1, 1, 1>;
3018 // Vector multiply halfwords
3019 // Rdd=vmpyh(Rs,Rt)[:<<]:sat
3020 //let Defs = [USR_OVF] in {
3021 def M2_vmpy2s_s1 : T_XTYPE_mpy64 < "vmpyh", 0b100, 0b101, 1, 1, 0>;
3022 def M2_vmpy2s_s0 : T_XTYPE_mpy64 < "vmpyh", 0b000, 0b101, 1, 0, 0>;
3025 // Rxx+=vmpyh(Rs,Rt)[:<<1][:sat]
3026 def M2_vmac2 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b001, 0b001, 0, 0, 0>;
3027 def M2_vmac2s_s1 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b100, 0b101, 1, 1, 0>;
3028 def M2_vmac2s_s0 : T_XTYPE_mpy64_acc < "vmpyh", "+", 0b000, 0b101, 1, 0, 0>;
3030 def: Pat<(i64 (mul (i64 (anyext (i32 IntRegs:$src1))),
3031 (i64 (anyext (i32 IntRegs:$src2))))),
3032 (M2_dpmpyuu_s0 IntRegs:$src1, IntRegs:$src2)>;
3034 def: Pat<(i64 (mul (i64 (sext (i32 IntRegs:$src1))),
3035 (i64 (sext (i32 IntRegs:$src2))))),
3036 (M2_dpmpyss_s0 IntRegs:$src1, IntRegs:$src2)>;
3038 def: Pat<(i64 (mul (is_sext_i32:$src1),
3039 (is_sext_i32:$src2))),
3040 (M2_dpmpyss_s0 (LoReg DoubleRegs:$src1), (LoReg DoubleRegs:$src2))>;
3042 // Multiply and accumulate, use full result.
3043 // Rxx[+-]=mpy(Rs,Rt)
3045 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3046 (mul (i64 (sext (i32 IntRegs:$src2))),
3047 (i64 (sext (i32 IntRegs:$src3)))))),
3048 (M2_dpmpyss_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3050 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3051 (mul (i64 (sext (i32 IntRegs:$src2))),
3052 (i64 (sext (i32 IntRegs:$src3)))))),
3053 (M2_dpmpyss_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3055 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3056 (mul (i64 (anyext (i32 IntRegs:$src2))),
3057 (i64 (anyext (i32 IntRegs:$src3)))))),
3058 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3060 def: Pat<(i64 (add (i64 DoubleRegs:$src1),
3061 (mul (i64 (zext (i32 IntRegs:$src2))),
3062 (i64 (zext (i32 IntRegs:$src3)))))),
3063 (M2_dpmpyuu_acc_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3065 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3066 (mul (i64 (anyext (i32 IntRegs:$src2))),
3067 (i64 (anyext (i32 IntRegs:$src3)))))),
3068 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3070 def: Pat<(i64 (sub (i64 DoubleRegs:$src1),
3071 (mul (i64 (zext (i32 IntRegs:$src2))),
3072 (i64 (zext (i32 IntRegs:$src3)))))),
3073 (M2_dpmpyuu_nac_s0 DoubleRegs:$src1, IntRegs:$src2, IntRegs:$src3)>;
3075 //===----------------------------------------------------------------------===//
3077 //===----------------------------------------------------------------------===//
3079 //===----------------------------------------------------------------------===//
3081 //===----------------------------------------------------------------------===//
3082 //===----------------------------------------------------------------------===//
3084 //===----------------------------------------------------------------------===//
3086 //===----------------------------------------------------------------------===//
3088 //===----------------------------------------------------------------------===//
3089 //===----------------------------------------------------------------------===//
3091 //===----------------------------------------------------------------------===//
3093 //===----------------------------------------------------------------------===//
3095 //===----------------------------------------------------------------------===//
3096 //===----------------------------------------------------------------------===//
3098 //===----------------------------------------------------------------------===//
3100 //===----------------------------------------------------------------------===//
3102 //===----------------------------------------------------------------------===//
3104 // Store doubleword.
3105 //===----------------------------------------------------------------------===//
3106 // Template class for non-predicated post increment stores with immediate offset
3107 //===----------------------------------------------------------------------===//
3108 let isPredicable = 1, hasSideEffects = 0, addrMode = PostInc in
3109 class T_store_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
3110 bits<4> MajOp, bit isHalf >
3111 : STInst <(outs IntRegs:$_dst_),
3112 (ins IntRegs:$src1, ImmOp:$offset, RC:$src2),
3113 mnemonic#"($src1++#$offset) = $src2"#!if(isHalf, ".h", ""),
3114 [], "$src1 = $_dst_" >,
3121 string ImmOpStr = !cast<string>(ImmOp);
3122 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
3123 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
3124 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
3125 /* s4_0Imm */ offset{3-0})));
3126 let isNVStorable = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
3128 let IClass = 0b1010;
3130 let Inst{27-25} = 0b101;
3131 let Inst{24-21} = MajOp;
3132 let Inst{20-16} = src1;
3134 let Inst{12-8} = src2;
3136 let Inst{6-3} = offsetBits;
3140 //===----------------------------------------------------------------------===//
3141 // Template class for predicated post increment stores with immediate offset
3142 //===----------------------------------------------------------------------===//
3143 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc in
3144 class T_pstore_pi <string mnemonic, RegisterClass RC, Operand ImmOp,
3145 bits<4> MajOp, bit isHalf, bit isPredNot, bit isPredNew >
3146 : STInst <(outs IntRegs:$_dst_),
3147 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$offset, RC:$src3),
3148 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3149 ") ")#mnemonic#"($src2++#$offset) = $src3"#!if(isHalf, ".h", ""),
3150 [], "$src2 = $_dst_" >,
3158 string ImmOpStr = !cast<string>(ImmOp);
3159 let offsetBits = !if (!eq(ImmOpStr, "s4_3Imm"), offset{6-3},
3160 !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
3161 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
3162 /* s4_0Imm */ offset{3-0})));
3164 let isNVStorable = !if (!eq(ImmOpStr, "s4_3Imm"), 0, 1);
3165 let isPredicatedNew = isPredNew;
3166 let isPredicatedFalse = isPredNot;
3168 let IClass = 0b1010;
3170 let Inst{27-25} = 0b101;
3171 let Inst{24-21} = MajOp;
3172 let Inst{20-16} = src2;
3174 let Inst{12-8} = src3;
3175 let Inst{7} = isPredNew;
3176 let Inst{6-3} = offsetBits;
3177 let Inst{2} = isPredNot;
3178 let Inst{1-0} = src1;
3181 multiclass ST_PostInc<string mnemonic, string BaseOp, RegisterClass RC,
3182 Operand ImmOp, bits<4> MajOp, bit isHalf = 0 > {
3184 let BaseOpcode = "POST_"#BaseOp in {
3185 def S2_#NAME#_pi : T_store_pi <mnemonic, RC, ImmOp, MajOp, isHalf>;
3188 def S2_p#NAME#t_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp, isHalf, 0, 0>;
3189 def S2_p#NAME#f_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp, isHalf, 1, 0>;
3192 def S2_p#NAME#tnew_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp,
3194 def S2_p#NAME#fnew_pi : T_pstore_pi <mnemonic, RC, ImmOp, MajOp,
3199 let accessSize = ByteAccess in
3200 defm storerb: ST_PostInc <"memb", "STrib", IntRegs, s4_0Imm, 0b1000>;
3202 let accessSize = HalfWordAccess in
3203 defm storerh: ST_PostInc <"memh", "STrih", IntRegs, s4_1Imm, 0b1010>;
3205 let accessSize = WordAccess in
3206 defm storeri: ST_PostInc <"memw", "STriw", IntRegs, s4_2Imm, 0b1100>;
3208 let accessSize = DoubleWordAccess in
3209 defm storerd: ST_PostInc <"memd", "STrid", DoubleRegs, s4_3Imm, 0b1110>;
3211 let accessSize = HalfWordAccess, isNVStorable = 0 in
3212 defm storerf: ST_PostInc <"memh", "STrih_H", IntRegs, s4_1Imm, 0b1011, 1>;
3214 // Patterns for generating stores, where the address takes different forms:
3217 // - simple (base address without offset).
3218 // These would usually be used together (via Storex_pat defined below), but
3219 // in some cases one may want to apply different properties (such as
3220 // AddedComplexity) to the individual patterns.
3221 class Storex_fi_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
3222 : Pat<(Store Value:$Rs, AddrFI:$fi), (MI AddrFI:$fi, 0, Value:$Rs)>;
3223 class Storex_add_pat<PatFrag Store, PatFrag Value, PatFrag ImmPred,
3225 : Pat<(Store Value:$Rt, (add (i32 IntRegs:$Rs), ImmPred:$Off)),
3226 (MI IntRegs:$Rs, imm:$Off, Value:$Rt)>;
3228 multiclass Storex_pat<PatFrag Store, PatFrag Value, PatLeaf ImmPred,
3230 def: Storex_fi_pat <Store, Value, MI>;
3231 def: Storex_add_pat <Store, Value, ImmPred, MI>;
3234 def : Pat<(post_truncsti8 (i32 IntRegs:$src1), IntRegs:$src2,
3235 s4_3ImmPred:$offset),
3236 (S2_storerb_pi IntRegs:$src2, s4_0ImmPred:$offset, IntRegs:$src1)>;
3238 def : Pat<(post_truncsti16 (i32 IntRegs:$src1), IntRegs:$src2,
3239 s4_3ImmPred:$offset),
3240 (S2_storerh_pi IntRegs:$src2, s4_1ImmPred:$offset, IntRegs:$src1)>;
3242 def : Pat<(post_store (i32 IntRegs:$src1), IntRegs:$src2, s4_2ImmPred:$offset),
3243 (S2_storeri_pi IntRegs:$src2, s4_1ImmPred:$offset, IntRegs:$src1)>;
3245 def : Pat<(post_store (i64 DoubleRegs:$src1), IntRegs:$src2,
3246 s4_3ImmPred:$offset),
3247 (S2_storerd_pi IntRegs:$src2, s4_3ImmPred:$offset, DoubleRegs:$src1)>;
3249 //===----------------------------------------------------------------------===//
3250 // Template class for post increment stores with register offset.
3251 //===----------------------------------------------------------------------===//
3252 let isNVStorable = 1 in
3253 class T_store_pr <string mnemonic, RegisterClass RC, bits<3> MajOp,
3254 MemAccessSize AccessSz, bit isHalf = 0>
3255 : STInst <(outs IntRegs:$_dst_),
3256 (ins IntRegs:$src1, ModRegs:$src2, RC:$src3),
3257 mnemonic#"($src1++$src2) = $src3"#!if(isHalf, ".h", ""),
3258 [], "$src1 = $_dst_" > {
3262 let accessSize = AccessSz;
3264 let IClass = 0b1010;
3266 let Inst{27-24} = 0b1101;
3267 let Inst{23-21} = MajOp;
3268 let Inst{20-16} = src1;
3269 let Inst{13} = src2;
3270 let Inst{12-8} = src3;
3274 def S2_storerb_pr : T_store_pr<"memb", IntRegs, 0b000, ByteAccess>;
3275 def S2_storerh_pr : T_store_pr<"memh", IntRegs, 0b010, HalfWordAccess>;
3276 def S2_storeri_pr : T_store_pr<"memw", IntRegs, 0b100, WordAccess>;
3277 def S2_storerd_pr : T_store_pr<"memd", DoubleRegs, 0b110, DoubleWordAccess>;
3279 def S2_storerf_pr : T_store_pr<"memh", IntRegs, 0b011, HalfWordAccess, 1>;
3281 let opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
3282 class T_store_io <string mnemonic, RegisterClass RC, Operand ImmOp,
3283 bits<3>MajOp, bit isH = 0>
3285 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
3286 mnemonic#"($src1+#$src2) = $src3"#!if(isH,".h","")>,
3287 AddrModeRel, ImmRegRel {
3289 bits<14> src2; // Actual address offset
3291 bits<11> offsetBits; // Represents offset encoding
3293 string ImmOpStr = !cast<string>(ImmOp);
3295 let opExtentBits = !if (!eq(ImmOpStr, "s11_3Ext"), 14,
3296 !if (!eq(ImmOpStr, "s11_2Ext"), 13,
3297 !if (!eq(ImmOpStr, "s11_1Ext"), 12,
3298 /* s11_0Ext */ 11)));
3299 let offsetBits = !if (!eq(ImmOpStr, "s11_3Ext"), src2{13-3},
3300 !if (!eq(ImmOpStr, "s11_2Ext"), src2{12-2},
3301 !if (!eq(ImmOpStr, "s11_1Ext"), src2{11-1},
3302 /* s11_0Ext */ src2{10-0})));
3303 let IClass = 0b1010;
3306 let Inst{26-25} = offsetBits{10-9};
3308 let Inst{23-21} = MajOp;
3309 let Inst{20-16} = src1;
3310 let Inst{13} = offsetBits{8};
3311 let Inst{12-8} = src3;
3312 let Inst{7-0} = offsetBits{7-0};
3315 let opExtendable = 2, isPredicated = 1 in
3316 class T_pstore_io <string mnemonic, RegisterClass RC, Operand ImmOp,
3317 bits<3>MajOp, bit PredNot, bit isPredNew, bit isH = 0>
3319 (ins PredRegs:$src1, IntRegs:$src2, ImmOp:$src3, RC:$src4),
3320 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3321 ") ")#mnemonic#"($src2+#$src3) = $src4"#!if(isH,".h",""),
3322 [],"",V2LDST_tc_st_SLOT01 >,
3323 AddrModeRel, ImmRegRel {
3326 bits<9> src3; // Actual address offset
3328 bits<6> offsetBits; // Represents offset encoding
3330 let isPredicatedNew = isPredNew;
3331 let isPredicatedFalse = PredNot;
3333 string ImmOpStr = !cast<string>(ImmOp);
3334 let opExtentBits = !if (!eq(ImmOpStr, "u6_3Ext"), 9,
3335 !if (!eq(ImmOpStr, "u6_2Ext"), 8,
3336 !if (!eq(ImmOpStr, "u6_1Ext"), 7,
3338 let offsetBits = !if (!eq(ImmOpStr, "u6_3Ext"), src3{8-3},
3339 !if (!eq(ImmOpStr, "u6_2Ext"), src3{7-2},
3340 !if (!eq(ImmOpStr, "u6_1Ext"), src3{6-1},
3341 /* u6_0Ext */ src3{5-0})));
3342 let IClass = 0b0100;
3345 let Inst{26} = PredNot;
3346 let Inst{25} = isPredNew;
3348 let Inst{23-21} = MajOp;
3349 let Inst{20-16} = src2;
3350 let Inst{13} = offsetBits{5};
3351 let Inst{12-8} = src4;
3352 let Inst{7-3} = offsetBits{4-0};
3353 let Inst{1-0} = src1;
3356 let isExtendable = 1, isNVStorable = 1, hasSideEffects = 0 in
3357 multiclass ST_Idxd<string mnemonic, string CextOp, RegisterClass RC,
3358 Operand ImmOp, Operand predImmOp, bits<3> MajOp, bit isH = 0> {
3359 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
3360 def S2_#NAME#_io : T_store_io <mnemonic, RC, ImmOp, MajOp, isH>;
3363 def S2_p#NAME#t_io : T_pstore_io<mnemonic, RC, predImmOp, MajOp, 0, 0, isH>;
3364 def S2_p#NAME#f_io : T_pstore_io<mnemonic, RC, predImmOp, MajOp, 1, 0, isH>;
3367 def S4_p#NAME#tnew_io : T_pstore_io <mnemonic, RC, predImmOp,
3369 def S4_p#NAME#fnew_io : T_pstore_io <mnemonic, RC, predImmOp,
3374 let addrMode = BaseImmOffset, InputType = "imm" in {
3375 let accessSize = ByteAccess in
3376 defm storerb: ST_Idxd < "memb", "STrib", IntRegs, s11_0Ext, u6_0Ext, 0b000>;
3378 let accessSize = HalfWordAccess, opExtentAlign = 1 in
3379 defm storerh: ST_Idxd < "memh", "STrih", IntRegs, s11_1Ext, u6_1Ext, 0b010>;
3381 let accessSize = WordAccess, opExtentAlign = 2 in
3382 defm storeri: ST_Idxd < "memw", "STriw", IntRegs, s11_2Ext, u6_2Ext, 0b100>;
3384 let accessSize = DoubleWordAccess, isNVStorable = 0, opExtentAlign = 3 in
3385 defm storerd: ST_Idxd < "memd", "STrid", DoubleRegs, s11_3Ext,
3388 let accessSize = HalfWordAccess, opExtentAlign = 1 in
3389 defm storerf: ST_Idxd < "memh", "STrif", IntRegs, s11_1Ext,
3393 class Storex_simple_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
3394 : Pat<(Store Value:$Rt, (i32 IntRegs:$Rs)),
3395 (MI IntRegs:$Rs, 0, Value:$Rt)>;
3397 // Regular stores in the DAG have two operands: value and address.
3398 // Atomic stores also have two, but they are reversed: address, value.
3399 // To use atomic stores with the patterns, they need to have their operands
3400 // swapped. This relies on the knowledge that the F.Fragment uses names
3402 class SwapSt<PatFrag F>
3403 : PatFrag<(ops node:$val, node:$ptr), F.Fragment>;
3405 def: Storex_simple_pat<SwapSt<atomic_store_8>, I32, S2_storerb_io>;
3406 def: Storex_simple_pat<SwapSt<atomic_store_16>, I32, S2_storerh_io>;
3407 def: Storex_simple_pat<SwapSt<atomic_store_32>, I32, S2_storeri_io>;
3408 def: Storex_simple_pat<SwapSt<atomic_store_64>, I64, S2_storerd_io>;
3410 def : Pat<(truncstorei8 (i32 IntRegs:$src1), ADDRriS11_0:$addr),
3411 (S2_storerb_io AddrFI:$addr, 0, (i32 IntRegs:$src1))>;
3413 def : Pat<(truncstorei16 (i32 IntRegs:$src1), ADDRriS11_1:$addr),
3414 (S2_storerh_io AddrFI:$addr, 0, (i32 IntRegs:$src1))>;
3416 def : Pat<(store (i32 IntRegs:$src1), ADDRriS11_2:$addr),
3417 (S2_storeri_io AddrFI:$addr, 0, (i32 IntRegs:$src1))>;
3419 def : Pat<(store (i64 DoubleRegs:$src1), ADDRriS11_3:$addr),
3420 (S2_storerd_io AddrFI:$addr, 0, (i64 DoubleRegs:$src1))>;
3423 let AddedComplexity = 10 in {
3424 def : Pat<(truncstorei8 (i32 IntRegs:$src1), (add IntRegs:$src2,
3425 s11_0ExtPred:$offset)),
3426 (S2_storerb_io IntRegs:$src2, s11_0ImmPred:$offset,
3427 (i32 IntRegs:$src1))>;
3429 def : Pat<(truncstorei16 (i32 IntRegs:$src1), (add IntRegs:$src2,
3430 s11_1ExtPred:$offset)),
3431 (S2_storerh_io IntRegs:$src2, s11_1ImmPred:$offset,
3432 (i32 IntRegs:$src1))>;
3434 def : Pat<(store (i32 IntRegs:$src1), (add IntRegs:$src2,
3435 s11_2ExtPred:$offset)),
3436 (S2_storeri_io IntRegs:$src2, s11_2ImmPred:$offset,
3437 (i32 IntRegs:$src1))>;
3439 def : Pat<(store (i64 DoubleRegs:$src1), (add IntRegs:$src2,
3440 s11_3ExtPred:$offset)),
3441 (S2_storerd_io IntRegs:$src2, s11_3ImmPred:$offset,
3442 (i64 DoubleRegs:$src1))>;
3445 // memh(Rx++#s4:1)=Rt.H
3448 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 13,
3449 isCodeGenOnly = 1, isPseudo = 1, hasSideEffects = 0 in
3450 def STriw_pred : STInst<(outs),
3451 (ins IntRegs:$addr, s11_2Ext:$off, PredRegs:$src1),
3452 ".error \"should not emit\"", []>;
3454 // S2_allocframe: Allocate stack frame.
3455 let Defs = [R29, R30], Uses = [R29, R31, R30],
3456 hasSideEffects = 0, accessSize = DoubleWordAccess in
3457 def S2_allocframe: ST0Inst <
3458 (outs), (ins u11_3Imm:$u11_3),
3459 "allocframe(#$u11_3)" > {
3462 let IClass = 0b1010;
3463 let Inst{27-16} = 0b000010011101;
3464 let Inst{13-11} = 0b000;
3465 let Inst{10-0} = u11_3{13-3};
3468 // S2_storer[bhwdf]_pci: Store byte/half/word/double.
3469 // S2_storer[bhwdf]_pci -> S2_storerbnew_pci
3470 let Uses = [CS], isNVStorable = 1 in
3471 class T_store_pci <string mnemonic, RegisterClass RC,
3472 Operand Imm, bits<4>MajOp,
3473 MemAccessSize AlignSize, string RegSrc = "Rt">
3474 : STInst <(outs IntRegs:$_dst_),
3475 (ins IntRegs:$Rz, Imm:$offset, ModRegs:$Mu, RC:$Rt),
3476 #mnemonic#"($Rz ++ #$offset:circ($Mu)) = $"#RegSrc#"",
3483 let accessSize = AlignSize;
3485 let IClass = 0b1010;
3486 let Inst{27-25} = 0b100;
3487 let Inst{24-21} = MajOp;
3488 let Inst{20-16} = Rz;
3490 let Inst{12-8} = Rt;
3493 !if (!eq(!cast<string>(AlignSize), "DoubleWordAccess"), offset{6-3},
3494 !if (!eq(!cast<string>(AlignSize), "WordAccess"), offset{5-2},
3495 !if (!eq(!cast<string>(AlignSize), "HalfWordAccess"), offset{4-1},
3496 /* ByteAccess */ offset{3-0})));
3500 def S2_storerb_pci : T_store_pci<"memb", IntRegs, s4_0Imm, 0b1000,
3502 def S2_storerh_pci : T_store_pci<"memh", IntRegs, s4_1Imm, 0b1010,
3504 def S2_storerf_pci : T_store_pci<"memh", IntRegs, s4_1Imm, 0b1011,
3505 HalfWordAccess, "Rt.h">;
3506 def S2_storeri_pci : T_store_pci<"memw", IntRegs, s4_2Imm, 0b1100,
3508 def S2_storerd_pci : T_store_pci<"memd", DoubleRegs, s4_3Imm, 0b1110,
3511 let Uses = [CS], isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 4 in
3512 class T_storenew_pci <string mnemonic, Operand Imm,
3513 bits<2>MajOp, MemAccessSize AlignSize>
3514 : NVInst < (outs IntRegs:$_dst_),
3515 (ins IntRegs:$Rz, Imm:$offset, ModRegs:$Mu, IntRegs:$Nt),
3516 #mnemonic#"($Rz ++ #$offset:circ($Mu)) = $Nt.new",
3524 let accessSize = AlignSize;
3526 let IClass = 0b1010;
3527 let Inst{27-21} = 0b1001101;
3528 let Inst{20-16} = Rz;
3530 let Inst{12-11} = MajOp;
3531 let Inst{10-8} = Nt;
3534 !if (!eq(!cast<string>(AlignSize), "WordAccess"), offset{5-2},
3535 !if (!eq(!cast<string>(AlignSize), "HalfWordAccess"), offset{4-1},
3536 /* ByteAccess */ offset{3-0}));
3540 def S2_storerbnew_pci : T_storenew_pci <"memb", s4_0Imm, 0b00, ByteAccess>;
3541 def S2_storerhnew_pci : T_storenew_pci <"memh", s4_1Imm, 0b01, HalfWordAccess>;
3542 def S2_storerinew_pci : T_storenew_pci <"memw", s4_2Imm, 0b10, WordAccess>;
3544 //===----------------------------------------------------------------------===//
3545 // Circular stores with auto-increment register
3546 //===----------------------------------------------------------------------===//
3547 let Uses = [CS], isNVStorable = 1 in
3548 class T_store_pcr <string mnemonic, RegisterClass RC, bits<4>MajOp,
3549 MemAccessSize AlignSize, string RegSrc = "Rt">
3550 : STInst <(outs IntRegs:$_dst_),
3551 (ins IntRegs:$Rz, ModRegs:$Mu, RC:$Rt),
3552 #mnemonic#"($Rz ++ I:circ($Mu)) = $"#RegSrc#"",
3559 let accessSize = AlignSize;
3561 let IClass = 0b1010;
3562 let Inst{27-25} = 0b100;
3563 let Inst{24-21} = MajOp;
3564 let Inst{20-16} = Rz;
3566 let Inst{12-8} = Rt;
3571 def S2_storerb_pcr : T_store_pcr<"memb", IntRegs, 0b1000, ByteAccess>;
3572 def S2_storerh_pcr : T_store_pcr<"memh", IntRegs, 0b1010, HalfWordAccess>;
3573 def S2_storeri_pcr : T_store_pcr<"memw", IntRegs, 0b1100, WordAccess>;
3574 def S2_storerd_pcr : T_store_pcr<"memd", DoubleRegs, 0b1110, DoubleWordAccess>;
3575 def S2_storerf_pcr : T_store_pcr<"memh", IntRegs, 0b1011,
3576 HalfWordAccess, "Rt.h">;
3578 //===----------------------------------------------------------------------===//
3579 // Circular .new stores with auto-increment register
3580 //===----------------------------------------------------------------------===//
3581 let Uses = [CS], isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
3582 class T_storenew_pcr <string mnemonic, bits<2>MajOp,
3583 MemAccessSize AlignSize>
3584 : NVInst <(outs IntRegs:$_dst_),
3585 (ins IntRegs:$Rz, ModRegs:$Mu, IntRegs:$Nt),
3586 #mnemonic#"($Rz ++ I:circ($Mu)) = $Nt.new" ,
3593 let accessSize = AlignSize;
3595 let IClass = 0b1010;
3596 let Inst{27-21} = 0b1001101;
3597 let Inst{20-16} = Rz;
3599 let Inst{12-11} = MajOp;
3600 let Inst{10-8} = Nt;
3605 def S2_storerbnew_pcr : T_storenew_pcr <"memb", 0b00, ByteAccess>;
3606 def S2_storerhnew_pcr : T_storenew_pcr <"memh", 0b01, HalfWordAccess>;
3607 def S2_storerinew_pcr : T_storenew_pcr <"memw", 0b10, WordAccess>;
3609 //===----------------------------------------------------------------------===//
3610 // Bit-reversed stores with auto-increment register
3611 //===----------------------------------------------------------------------===//
3612 let hasSideEffects = 0 in
3613 class T_store_pbr<string mnemonic, RegisterClass RC,
3614 MemAccessSize addrSize, bits<3> majOp,
3617 <(outs IntRegs:$_dst_),
3618 (ins IntRegs:$Rz, ModRegs:$Mu, RC:$src),
3619 #mnemonic#"($Rz ++ $Mu:brev) = $src"#!if (!eq(isHalf, 1), ".h", ""),
3620 [], "$Rz = $_dst_" > {
3622 let accessSize = addrSize;
3628 let IClass = 0b1010;
3630 let Inst{27-24} = 0b1111;
3631 let Inst{23-21} = majOp;
3633 let Inst{20-16} = Rz;
3635 let Inst{12-8} = src;
3638 let isNVStorable = 1 in {
3639 let BaseOpcode = "S2_storerb_pbr" in
3640 def S2_storerb_pbr : T_store_pbr<"memb", IntRegs, ByteAccess,
3641 0b000>, NewValueRel;
3642 let BaseOpcode = "S2_storerh_pbr" in
3643 def S2_storerh_pbr : T_store_pbr<"memh", IntRegs, HalfWordAccess,
3644 0b010>, NewValueRel;
3645 let BaseOpcode = "S2_storeri_pbr" in
3646 def S2_storeri_pbr : T_store_pbr<"memw", IntRegs, WordAccess,
3647 0b100>, NewValueRel;
3650 def S2_storerf_pbr : T_store_pbr<"memh", IntRegs, HalfWordAccess, 0b011, 1>;
3651 def S2_storerd_pbr : T_store_pbr<"memd", DoubleRegs, DoubleWordAccess, 0b110>;
3653 //===----------------------------------------------------------------------===//
3654 // Bit-reversed .new stores with auto-increment register
3655 //===----------------------------------------------------------------------===//
3656 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3,
3657 hasSideEffects = 0 in
3658 class T_storenew_pbr<string mnemonic, MemAccessSize addrSize, bits<2> majOp>
3659 : NVInst <(outs IntRegs:$_dst_),
3660 (ins IntRegs:$Rz, ModRegs:$Mu, IntRegs:$Nt),
3661 #mnemonic#"($Rz ++ $Mu:brev) = $Nt.new", [],
3662 "$Rz = $_dst_">, NewValueRel {
3663 let accessSize = addrSize;
3668 let IClass = 0b1010;
3670 let Inst{27-21} = 0b1111101;
3671 let Inst{12-11} = majOp;
3673 let Inst{20-16} = Rz;
3675 let Inst{10-8} = Nt;
3678 let BaseOpcode = "S2_storerb_pbr" in
3679 def S2_storerbnew_pbr : T_storenew_pbr<"memb", ByteAccess, 0b00>;
3681 let BaseOpcode = "S2_storerh_pbr" in
3682 def S2_storerhnew_pbr : T_storenew_pbr<"memh", HalfWordAccess, 0b01>;
3684 let BaseOpcode = "S2_storeri_pbr" in
3685 def S2_storerinew_pbr : T_storenew_pbr<"memw", WordAccess, 0b10>;
3687 //===----------------------------------------------------------------------===//
3689 //===----------------------------------------------------------------------===//
3691 let hasSideEffects = 0 in
3692 class T_S2op_1 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
3693 RegisterClass RCIn, bits<2> MajOp, bits<3> MinOp, bit isSat>
3694 : SInst <(outs RCOut:$dst), (ins RCIn:$src),
3695 "$dst = "#mnemonic#"($src)"#!if(isSat, ":sat", ""),
3696 [], "", S_2op_tc_1_SLOT23 > {
3700 let IClass = 0b1000;
3702 let Inst{27-24} = RegTyBits;
3703 let Inst{23-22} = MajOp;
3705 let Inst{20-16} = src;
3706 let Inst{7-5} = MinOp;
3707 let Inst{4-0} = dst;
3710 class T_S2op_1_di <string mnemonic, bits<2> MajOp, bits<3> MinOp>
3711 : T_S2op_1 <mnemonic, 0b0100, DoubleRegs, IntRegs, MajOp, MinOp, 0>;
3713 let hasNewValue = 1 in
3714 class T_S2op_1_id <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
3715 : T_S2op_1 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, isSat>;
3717 let hasNewValue = 1 in
3718 class T_S2op_1_ii <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit isSat = 0>
3719 : T_S2op_1 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp, isSat>;
3721 // Vector sign/zero extend
3722 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3723 def S2_vsxtbh : T_S2op_1_di <"vsxtbh", 0b00, 0b000>;
3724 def S2_vsxthw : T_S2op_1_di <"vsxthw", 0b00, 0b100>;
3725 def S2_vzxtbh : T_S2op_1_di <"vzxtbh", 0b00, 0b010>;
3726 def S2_vzxthw : T_S2op_1_di <"vzxthw", 0b00, 0b110>;
3729 // Vector splat bytes/halfwords
3730 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3731 def S2_vsplatrb : T_S2op_1_ii <"vsplatb", 0b01, 0b111>;
3732 def S2_vsplatrh : T_S2op_1_di <"vsplath", 0b01, 0b010>;
3735 // Sign extend word to doubleword
3736 def A2_sxtw : T_S2op_1_di <"sxtw", 0b01, 0b000>;
3738 def: Pat <(i64 (sext I32:$src)), (A2_sxtw I32:$src)>;
3740 // Vector saturate and pack
3741 let Defs = [USR_OVF] in {
3742 def S2_svsathb : T_S2op_1_ii <"vsathb", 0b10, 0b000>;
3743 def S2_svsathub : T_S2op_1_ii <"vsathub", 0b10, 0b010>;
3744 def S2_vsathb : T_S2op_1_id <"vsathb", 0b00, 0b110>;
3745 def S2_vsathub : T_S2op_1_id <"vsathub", 0b00, 0b000>;
3746 def S2_vsatwh : T_S2op_1_id <"vsatwh", 0b00, 0b010>;
3747 def S2_vsatwuh : T_S2op_1_id <"vsatwuh", 0b00, 0b100>;
3751 def S2_vtrunohb : T_S2op_1_id <"vtrunohb", 0b10, 0b000>;
3752 def S2_vtrunehb : T_S2op_1_id <"vtrunehb", 0b10, 0b010>;
3754 // Swizzle the bytes of a word
3755 def A2_swiz : T_S2op_1_ii <"swiz", 0b10, 0b111>;
3758 let Defs = [USR_OVF] in {
3759 def A2_sat : T_S2op_1_id <"sat", 0b11, 0b000>;
3760 def A2_satb : T_S2op_1_ii <"satb", 0b11, 0b111>;
3761 def A2_satub : T_S2op_1_ii <"satub", 0b11, 0b110>;
3762 def A2_sath : T_S2op_1_ii <"sath", 0b11, 0b100>;
3763 def A2_satuh : T_S2op_1_ii <"satuh", 0b11, 0b101>;
3764 def A2_roundsat : T_S2op_1_id <"round", 0b11, 0b001, 0b1>;
3767 let Itinerary = S_2op_tc_2_SLOT23 in {
3768 // Vector round and pack
3769 def S2_vrndpackwh : T_S2op_1_id <"vrndwh", 0b10, 0b100>;
3771 let Defs = [USR_OVF] in
3772 def S2_vrndpackwhs : T_S2op_1_id <"vrndwh", 0b10, 0b110, 1>;
3775 def S2_brev : T_S2op_1_ii <"brev", 0b01, 0b110>;
3777 // Absolute value word
3778 def A2_abs : T_S2op_1_ii <"abs", 0b10, 0b100>;
3780 let Defs = [USR_OVF] in
3781 def A2_abssat : T_S2op_1_ii <"abs", 0b10, 0b101, 1>;
3783 // Negate with saturation
3784 let Defs = [USR_OVF] in
3785 def A2_negsat : T_S2op_1_ii <"neg", 0b10, 0b110, 1>;
3788 def: Pat<(i32 (select (i1 (setlt (i32 IntRegs:$src), 0)),
3789 (i32 (sub 0, (i32 IntRegs:$src))),
3790 (i32 IntRegs:$src))),
3791 (A2_abs IntRegs:$src)>;
3793 let AddedComplexity = 50 in
3794 def: Pat<(i32 (xor (add (sra (i32 IntRegs:$src), (i32 31)),
3795 (i32 IntRegs:$src)),
3796 (sra (i32 IntRegs:$src), (i32 31)))),
3797 (A2_abs IntRegs:$src)>;
3799 class T_S2op_2 <string mnemonic, bits<4> RegTyBits, RegisterClass RCOut,
3800 RegisterClass RCIn, bits<3> MajOp, bits<3> MinOp,
3801 bit isSat, bit isRnd, list<dag> pattern = []>
3802 : SInst <(outs RCOut:$dst),
3803 (ins RCIn:$src, u5Imm:$u5),
3804 "$dst = "#mnemonic#"($src, #$u5)"#!if(isSat, ":sat", "")
3805 #!if(isRnd, ":rnd", ""),
3806 pattern, "", S_2op_tc_2_SLOT23> {
3811 let IClass = 0b1000;
3813 let Inst{27-24} = RegTyBits;
3814 let Inst{23-21} = MajOp;
3815 let Inst{20-16} = src;
3817 let Inst{12-8} = u5;
3818 let Inst{7-5} = MinOp;
3819 let Inst{4-0} = dst;
3822 class T_S2op_2_di <string mnemonic, bits<3> MajOp, bits<3> MinOp>
3823 : T_S2op_2 <mnemonic, 0b1000, DoubleRegs, IntRegs, MajOp, MinOp, 0, 0>;
3825 let hasNewValue = 1 in
3826 class T_S2op_2_id <string mnemonic, bits<3> MajOp, bits<3> MinOp>
3827 : T_S2op_2 <mnemonic, 0b1000, IntRegs, DoubleRegs, MajOp, MinOp, 0, 0>;
3829 let hasNewValue = 1 in
3830 class T_S2op_2_ii <string mnemonic, bits<3> MajOp, bits<3> MinOp,
3831 bit isSat = 0, bit isRnd = 0, list<dag> pattern = []>
3832 : T_S2op_2 <mnemonic, 0b1100, IntRegs, IntRegs, MajOp, MinOp,
3833 isSat, isRnd, pattern>;
3835 class T_S2op_shift <string mnemonic, bits<3> MajOp, bits<3> MinOp, SDNode OpNd>
3836 : T_S2op_2_ii <mnemonic, MajOp, MinOp, 0, 0,
3837 [(set (i32 IntRegs:$dst), (OpNd (i32 IntRegs:$src),
3838 (u5ImmPred:$u5)))]>;
3840 // Vector arithmetic shift right by immediate with truncate and pack
3841 def S2_asr_i_svw_trun : T_S2op_2_id <"vasrw", 0b110, 0b010>;
3843 // Arithmetic/logical shift right/left by immediate
3844 let Itinerary = S_2op_tc_1_SLOT23 in {
3845 def S2_asr_i_r : T_S2op_shift <"asr", 0b000, 0b000, sra>;
3846 def S2_lsr_i_r : T_S2op_shift <"lsr", 0b000, 0b001, srl>;
3847 def S2_asl_i_r : T_S2op_shift <"asl", 0b000, 0b010, shl>;
3850 // Shift left by immediate with saturation
3851 let Defs = [USR_OVF] in
3852 def S2_asl_i_r_sat : T_S2op_2_ii <"asl", 0b010, 0b010, 1>;
3854 // Shift right with round
3855 def S2_asr_i_r_rnd : T_S2op_2_ii <"asr", 0b010, 0b000, 0, 1>;
3857 let isAsmParserOnly = 1 in
3858 def S2_asr_i_r_rnd_goodsyntax
3859 : SInst <(outs IntRegs:$dst), (ins IntRegs:$src, u5Imm:$u5),
3860 "$dst = asrrnd($src, #$u5)",
3861 [], "", S_2op_tc_1_SLOT23>;
3863 def: Pat<(i32 (sra (i32 (add (i32 (sra I32:$src1, u5ImmPred:$src2)),
3866 (S2_asr_i_r_rnd IntRegs:$src1, u5ImmPred:$src2)>;
3868 class T_S2op_3<string opc, bits<2>MajOp, bits<3>minOp, bits<1> sat = 0>
3869 : SInst<(outs DoubleRegs:$Rdd), (ins DoubleRegs:$Rss),
3870 "$Rdd = "#opc#"($Rss)"#!if(!eq(sat, 1),":sat","")> {
3873 let IClass = 0b1000;
3874 let Inst{27-24} = 0;
3875 let Inst{23-22} = MajOp;
3876 let Inst{20-16} = Rss;
3877 let Inst{7-5} = minOp;
3878 let Inst{4-0} = Rdd;
3881 def A2_absp : T_S2op_3 <"abs", 0b10, 0b110>;
3882 def A2_negp : T_S2op_3 <"neg", 0b10, 0b101>;
3883 def A2_notp : T_S2op_3 <"not", 0b10, 0b100>;
3885 // Innterleave/deinterleave
3886 def S2_interleave : T_S2op_3 <"interleave", 0b11, 0b101>;
3887 def S2_deinterleave : T_S2op_3 <"deinterleave", 0b11, 0b100>;
3889 // Vector Complex conjugate
3890 def A2_vconj : T_S2op_3 <"vconj", 0b10, 0b111, 1>;
3892 // Vector saturate without pack
3893 def S2_vsathb_nopack : T_S2op_3 <"vsathb", 0b00, 0b111>;
3894 def S2_vsathub_nopack : T_S2op_3 <"vsathub", 0b00, 0b100>;
3895 def S2_vsatwh_nopack : T_S2op_3 <"vsatwh", 0b00, 0b110>;
3896 def S2_vsatwuh_nopack : T_S2op_3 <"vsatwuh", 0b00, 0b101>;
3898 // Vector absolute value halfwords with and without saturation
3899 // Rdd64=vabsh(Rss64)[:sat]
3900 def A2_vabsh : T_S2op_3 <"vabsh", 0b01, 0b100>;
3901 def A2_vabshsat : T_S2op_3 <"vabsh", 0b01, 0b101, 1>;
3903 // Vector absolute value words with and without saturation
3904 def A2_vabsw : T_S2op_3 <"vabsw", 0b01, 0b110>;
3905 def A2_vabswsat : T_S2op_3 <"vabsw", 0b01, 0b111, 1>;
3907 //===----------------------------------------------------------------------===//
3909 //===----------------------------------------------------------------------===//
3912 let hasSideEffects = 0, hasNewValue = 1 in
3913 class T_COUNT_LEADING<string MnOp, bits<3> MajOp, bits<3> MinOp, bit Is32,
3915 : SInst<Out, Inp, "$Rd = "#MnOp#"($Rs)", [], "", S_2op_tc_1_SLOT23> {
3918 let IClass = 0b1000;
3920 let Inst{26} = Is32;
3921 let Inst{25-24} = 0b00;
3922 let Inst{23-21} = MajOp;
3923 let Inst{20-16} = Rs;
3924 let Inst{7-5} = MinOp;
3928 class T_COUNT_LEADING_32<string MnOp, bits<3> MajOp, bits<3> MinOp>
3929 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b1,
3930 (outs IntRegs:$Rd), (ins IntRegs:$Rs)>;
3932 class T_COUNT_LEADING_64<string MnOp, bits<3> MajOp, bits<3> MinOp>
3933 : T_COUNT_LEADING<MnOp, MajOp, MinOp, 0b0,
3934 (outs IntRegs:$Rd), (ins DoubleRegs:$Rs)>;
3936 def S2_cl0 : T_COUNT_LEADING_32<"cl0", 0b000, 0b101>;
3937 def S2_cl1 : T_COUNT_LEADING_32<"cl1", 0b000, 0b110>;
3938 def S2_ct0 : T_COUNT_LEADING_32<"ct0", 0b010, 0b100>;
3939 def S2_ct1 : T_COUNT_LEADING_32<"ct1", 0b010, 0b101>;
3940 def S2_cl0p : T_COUNT_LEADING_64<"cl0", 0b010, 0b010>;
3941 def S2_cl1p : T_COUNT_LEADING_64<"cl1", 0b010, 0b100>;
3942 def S2_clb : T_COUNT_LEADING_32<"clb", 0b000, 0b100>;
3943 def S2_clbp : T_COUNT_LEADING_64<"clb", 0b010, 0b000>;
3944 def S2_clbnorm : T_COUNT_LEADING_32<"normamt", 0b000, 0b111>;
3946 def: Pat<(i32 (ctlz I32:$Rs)), (S2_cl0 I32:$Rs)>;
3947 def: Pat<(i32 (ctlz (not I32:$Rs))), (S2_cl1 I32:$Rs)>;
3948 def: Pat<(i32 (cttz I32:$Rs)), (S2_ct0 I32:$Rs)>;
3949 def: Pat<(i32 (cttz (not I32:$Rs))), (S2_ct1 I32:$Rs)>;
3950 def: Pat<(i32 (trunc (ctlz I64:$Rss))), (S2_cl0p I64:$Rss)>;
3951 def: Pat<(i32 (trunc (ctlz (not I64:$Rss)))), (S2_cl1p I64:$Rss)>;
3953 // Bit set/clear/toggle
3955 let hasSideEffects = 0, hasNewValue = 1 in
3956 class T_SCT_BIT_IMM<string MnOp, bits<3> MinOp>
3957 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, u5Imm:$u5),
3958 "$Rd = "#MnOp#"($Rs, #$u5)", [], "", S_2op_tc_1_SLOT23> {
3962 let IClass = 0b1000;
3963 let Inst{27-21} = 0b1100110;
3964 let Inst{20-16} = Rs;
3966 let Inst{12-8} = u5;
3967 let Inst{7-5} = MinOp;
3971 let hasSideEffects = 0, hasNewValue = 1 in
3972 class T_SCT_BIT_REG<string MnOp, bits<2> MinOp>
3973 : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
3974 "$Rd = "#MnOp#"($Rs, $Rt)", [], "", S_3op_tc_1_SLOT23> {
3978 let IClass = 0b1100;
3979 let Inst{27-22} = 0b011010;
3980 let Inst{20-16} = Rs;
3981 let Inst{12-8} = Rt;
3982 let Inst{7-6} = MinOp;
3986 def S2_clrbit_i : T_SCT_BIT_IMM<"clrbit", 0b001>;
3987 def S2_setbit_i : T_SCT_BIT_IMM<"setbit", 0b000>;
3988 def S2_togglebit_i : T_SCT_BIT_IMM<"togglebit", 0b010>;
3989 def S2_clrbit_r : T_SCT_BIT_REG<"clrbit", 0b01>;
3990 def S2_setbit_r : T_SCT_BIT_REG<"setbit", 0b00>;
3991 def S2_togglebit_r : T_SCT_BIT_REG<"togglebit", 0b10>;
3993 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, u5ImmPred:$u5)))),
3994 (S2_clrbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
3995 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
3996 (S2_setbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
3997 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, u5ImmPred:$u5))),
3998 (S2_togglebit_i IntRegs:$Rs, u5ImmPred:$u5)>;
3999 def: Pat<(i32 (and (i32 IntRegs:$Rs), (not (shl 1, (i32 IntRegs:$Rt))))),
4000 (S2_clrbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4001 def: Pat<(i32 (or (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
4002 (S2_setbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4003 def: Pat<(i32 (xor (i32 IntRegs:$Rs), (shl 1, (i32 IntRegs:$Rt)))),
4004 (S2_togglebit_r IntRegs:$Rs, IntRegs:$Rt)>;
4008 let hasSideEffects = 0 in
4009 class T_TEST_BIT_IMM<string MnOp, bits<3> MajOp>
4010 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u5Imm:$u5),
4011 "$Pd = "#MnOp#"($Rs, #$u5)",
4012 [], "", S_2op_tc_2early_SLOT23> {
4016 let IClass = 0b1000;
4017 let Inst{27-24} = 0b0101;
4018 let Inst{23-21} = MajOp;
4019 let Inst{20-16} = Rs;
4021 let Inst{12-8} = u5;
4025 let hasSideEffects = 0 in
4026 class T_TEST_BIT_REG<string MnOp, bit IsNeg>
4027 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
4028 "$Pd = "#MnOp#"($Rs, $Rt)",
4029 [], "", S_3op_tc_2early_SLOT23> {
4033 let IClass = 0b1100;
4034 let Inst{27-22} = 0b011100;
4035 let Inst{21} = IsNeg;
4036 let Inst{20-16} = Rs;
4037 let Inst{12-8} = Rt;
4041 def S2_tstbit_i : T_TEST_BIT_IMM<"tstbit", 0b000>;
4042 def S2_tstbit_r : T_TEST_BIT_REG<"tstbit", 0>;
4044 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
4045 def: Pat<(i1 (setne (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
4046 (S2_tstbit_i IntRegs:$Rs, u5ImmPred:$u5)>;
4047 def: Pat<(i1 (setne (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
4048 (S2_tstbit_r IntRegs:$Rs, IntRegs:$Rt)>;
4049 def: Pat<(i1 (trunc (i32 IntRegs:$Rs))),
4050 (S2_tstbit_i IntRegs:$Rs, 0)>;
4051 def: Pat<(i1 (trunc (i64 DoubleRegs:$Rs))),
4052 (S2_tstbit_i (LoReg DoubleRegs:$Rs), 0)>;
4054 let hasSideEffects = 0 in
4055 class T_TEST_BITS_IMM<string MnOp, bits<2> MajOp, bit IsNeg>
4056 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, u6Imm:$u6),
4057 "$Pd = "#MnOp#"($Rs, #$u6)",
4058 [], "", S_2op_tc_2early_SLOT23> {
4062 let IClass = 0b1000;
4063 let Inst{27-24} = 0b0101;
4064 let Inst{23-22} = MajOp;
4065 let Inst{21} = IsNeg;
4066 let Inst{20-16} = Rs;
4067 let Inst{13-8} = u6;
4071 let hasSideEffects = 0 in
4072 class T_TEST_BITS_REG<string MnOp, bits<2> MajOp, bit IsNeg>
4073 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
4074 "$Pd = "#MnOp#"($Rs, $Rt)",
4075 [], "", S_3op_tc_2early_SLOT23> {
4079 let IClass = 0b1100;
4080 let Inst{27-24} = 0b0111;
4081 let Inst{23-22} = MajOp;
4082 let Inst{21} = IsNeg;
4083 let Inst{20-16} = Rs;
4084 let Inst{12-8} = Rt;
4088 def C2_bitsclri : T_TEST_BITS_IMM<"bitsclr", 0b10, 0>;
4089 def C2_bitsclr : T_TEST_BITS_REG<"bitsclr", 0b10, 0>;
4090 def C2_bitsset : T_TEST_BITS_REG<"bitsset", 0b01, 0>;
4092 let AddedComplexity = 20 in { // Complexity greater than compare reg-imm.
4093 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), u6ImmPred:$u6), 0)),
4094 (C2_bitsclri IntRegs:$Rs, u6ImmPred:$u6)>;
4095 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), 0)),
4096 (C2_bitsclr IntRegs:$Rs, IntRegs:$Rt)>;
4099 let AddedComplexity = 10 in // Complexity greater than compare reg-reg.
4100 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), IntRegs:$Rt)),
4101 (C2_bitsset IntRegs:$Rs, IntRegs:$Rt)>;
4103 //===----------------------------------------------------------------------===//
4105 //===----------------------------------------------------------------------===//
4107 //===----------------------------------------------------------------------===//
4109 //===----------------------------------------------------------------------===//
4110 //===----------------------------------------------------------------------===//
4112 //===----------------------------------------------------------------------===//
4114 //===----------------------------------------------------------------------===//
4116 //===----------------------------------------------------------------------===//
4118 //===----------------------------------------------------------------------===//
4120 //===----------------------------------------------------------------------===//
4122 //===----------------------------------------------------------------------===//
4124 //===----------------------------------------------------------------------===//
4126 // Predicate transfer.
4127 let hasSideEffects = 0, hasNewValue = 1 in
4128 def C2_tfrpr : SInst<(outs IntRegs:$Rd), (ins PredRegs:$Ps),
4129 "$Rd = $Ps", [], "", S_2op_tc_1_SLOT23> {
4133 let IClass = 0b1000;
4134 let Inst{27-24} = 0b1001;
4136 let Inst{17-16} = Ps;
4140 // Transfer general register to predicate.
4141 let hasSideEffects = 0 in
4142 def C2_tfrrp: SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs),
4143 "$Pd = $Rs", [], "", S_2op_tc_2early_SLOT23> {
4147 let IClass = 0b1000;
4148 let Inst{27-21} = 0b0101010;
4149 let Inst{20-16} = Rs;
4154 //===----------------------------------------------------------------------===//
4156 //===----------------------------------------------------------------------===//
4158 //===----------------------------------------------------------------------===//
4160 //===----------------------------------------------------------------------===//
4161 class S_2OpInstImm<string Mnemonic, bits<3>MajOp, bits<3>MinOp,
4162 Operand Imm, list<dag> pattern = [], bit isRnd = 0>
4163 : SInst<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1, Imm:$src2),
4164 "$dst = "#Mnemonic#"($src1, #$src2)"#!if(isRnd, ":rnd", ""),
4168 let IClass = 0b1000;
4169 let Inst{27-24} = 0;
4170 let Inst{23-21} = MajOp;
4171 let Inst{20-16} = src1;
4172 let Inst{7-5} = MinOp;
4173 let Inst{4-0} = dst;
4176 class S_2OpInstImmI6<string Mnemonic, SDNode OpNode, bits<3>MinOp>
4177 : S_2OpInstImm<Mnemonic, 0b000, MinOp, u6Imm,
4178 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
4179 u6ImmPred:$src2))]> {
4181 let Inst{13-8} = src2;
4184 // Shift by immediate.
4185 def S2_asr_i_p : S_2OpInstImmI6<"asr", sra, 0b000>;
4186 def S2_asl_i_p : S_2OpInstImmI6<"asl", shl, 0b010>;
4187 def S2_lsr_i_p : S_2OpInstImmI6<"lsr", srl, 0b001>;
4189 // Shift left by small amount and add.
4190 let AddedComplexity = 100, hasNewValue = 1, hasSideEffects = 0 in
4191 def S2_addasl_rrri: SInst <(outs IntRegs:$Rd),
4192 (ins IntRegs:$Rt, IntRegs:$Rs, u3Imm:$u3),
4193 "$Rd = addasl($Rt, $Rs, #$u3)" ,
4194 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rt),
4195 (shl (i32 IntRegs:$Rs), u3ImmPred:$u3)))],
4196 "", S_3op_tc_2_SLOT23> {
4202 let IClass = 0b1100;
4204 let Inst{27-21} = 0b0100000;
4205 let Inst{20-16} = Rs;
4207 let Inst{12-8} = Rt;
4212 //===----------------------------------------------------------------------===//
4214 //===----------------------------------------------------------------------===//
4216 //===----------------------------------------------------------------------===//
4218 //===----------------------------------------------------------------------===//
4219 //===----------------------------------------------------------------------===//
4221 //===----------------------------------------------------------------------===//
4223 //===----------------------------------------------------------------------===//
4225 //===----------------------------------------------------------------------===//
4226 //===----------------------------------------------------------------------===//
4228 //===----------------------------------------------------------------------===//
4230 //===----------------------------------------------------------------------===//
4232 //===----------------------------------------------------------------------===//
4234 //===----------------------------------------------------------------------===//
4236 //===----------------------------------------------------------------------===//
4237 def HexagonBARRIER: SDNode<"HexagonISD::BARRIER", SDTNone, [SDNPHasChain]>;
4239 let hasSideEffects = 1, isSoloAX = 1 in
4240 def BARRIER : SYSInst<(outs), (ins),
4242 [(HexagonBARRIER)],"",ST_tc_st_SLOT0> {
4243 let Inst{31-28} = 0b1010;
4244 let Inst{27-21} = 0b1000000;
4247 //===----------------------------------------------------------------------===//
4249 //===----------------------------------------------------------------------===//
4250 //===----------------------------------------------------------------------===//
4252 //===----------------------------------------------------------------------===//
4254 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
4255 opExtendable = 0, hasSideEffects = 0 in
4256 class LOOP_iBase<string mnemonic, Operand brOp, bit mustExtend = 0>
4257 : CRInst<(outs), (ins brOp:$offset, u10Imm:$src2),
4258 #mnemonic#"($offset, #$src2)",
4259 [], "" , CR_tc_3x_SLOT3> {
4263 let IClass = 0b0110;
4265 let Inst{27-22} = 0b100100;
4266 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
4267 let Inst{20-16} = src2{9-5};
4268 let Inst{12-8} = offset{8-4};
4269 let Inst{7-5} = src2{4-2};
4270 let Inst{4-3} = offset{3-2};
4271 let Inst{1-0} = src2{1-0};
4274 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 9, opExtentAlign = 2,
4275 opExtendable = 0, hasSideEffects = 0 in
4276 class LOOP_rBase<string mnemonic, Operand brOp, bit mustExtend = 0>
4277 : CRInst<(outs), (ins brOp:$offset, IntRegs:$src2),
4278 #mnemonic#"($offset, $src2)",
4279 [], "" ,CR_tc_3x_SLOT3> {
4283 let IClass = 0b0110;
4285 let Inst{27-22} = 0b000000;
4286 let Inst{21} = !if (!eq(mnemonic, "loop0"), 0b0, 0b1);
4287 let Inst{20-16} = src2;
4288 let Inst{12-8} = offset{8-4};
4289 let Inst{4-3} = offset{3-2};
4292 multiclass LOOP_ri<string mnemonic> {
4293 def i : LOOP_iBase<mnemonic, brtarget>;
4294 def r : LOOP_rBase<mnemonic, brtarget>;
4298 let Defs = [SA0, LC0, USR] in
4299 defm J2_loop0 : LOOP_ri<"loop0">;
4301 // Interestingly only loop0's appear to set usr.lpcfg
4302 let Defs = [SA1, LC1] in
4303 defm J2_loop1 : LOOP_ri<"loop1">;
4305 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
4306 Defs = [PC, LC0], Uses = [SA0, LC0] in {
4307 def ENDLOOP0 : Endloop<(outs), (ins brtarget:$offset),
4312 let isBranch = 1, isTerminator = 1, hasSideEffects = 0,
4313 Defs = [PC, LC1], Uses = [SA1, LC1] in {
4314 def ENDLOOP1 : Endloop<(outs), (ins brtarget:$offset),
4319 // Pipelined loop instructions, sp[123]loop0
4320 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
4321 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
4322 opExtendable = 0, isPredicateLate = 1 in
4323 class SPLOOP_iBase<string SP, bits<2> op>
4324 : CRInst <(outs), (ins brtarget:$r7_2, u10Imm:$U10),
4325 "p3 = sp"#SP#"loop0($r7_2, #$U10)" > {
4329 let IClass = 0b0110;
4331 let Inst{22-21} = op;
4332 let Inst{27-23} = 0b10011;
4333 let Inst{20-16} = U10{9-5};
4334 let Inst{12-8} = r7_2{8-4};
4335 let Inst{7-5} = U10{4-2};
4336 let Inst{4-3} = r7_2{3-2};
4337 let Inst{1-0} = U10{1-0};
4340 let Defs = [LC0, SA0, P3, USR], hasSideEffects = 0,
4341 isExtentSigned = 1, isExtendable = 1, opExtentBits = 9, opExtentAlign = 2,
4342 opExtendable = 0, isPredicateLate = 1 in
4343 class SPLOOP_rBase<string SP, bits<2> op>
4344 : CRInst <(outs), (ins brtarget:$r7_2, IntRegs:$Rs),
4345 "p3 = sp"#SP#"loop0($r7_2, $Rs)" > {
4349 let IClass = 0b0110;
4351 let Inst{22-21} = op;
4352 let Inst{27-23} = 0b00001;
4353 let Inst{20-16} = Rs;
4354 let Inst{12-8} = r7_2{8-4};
4355 let Inst{4-3} = r7_2{3-2};
4358 multiclass SPLOOP_ri<string mnemonic, bits<2> op> {
4359 def i : SPLOOP_iBase<mnemonic, op>;
4360 def r : SPLOOP_rBase<mnemonic, op>;
4363 defm J2_ploop1s : SPLOOP_ri<"1", 0b01>;
4364 defm J2_ploop2s : SPLOOP_ri<"2", 0b10>;
4365 defm J2_ploop3s : SPLOOP_ri<"3", 0b11>;
4367 // if (Rs[!>=<]=#0) jump:[t/nt]
4368 let Defs = [PC], isPredicated = 1, isBranch = 1, hasSideEffects = 0,
4369 hasSideEffects = 0 in
4370 class J2_jump_0_Base<string compare, bit isTak, bits<2> op>
4371 : CRInst <(outs), (ins IntRegs:$Rs, brtarget:$r13_2),
4372 "if ($Rs"#compare#"#0) jump"#!if(isTak, ":t", ":nt")#" $r13_2" > {
4376 let IClass = 0b0110;
4378 let Inst{27-24} = 0b0001;
4379 let Inst{23-22} = op;
4380 let Inst{12} = isTak;
4381 let Inst{21} = r13_2{14};
4382 let Inst{20-16} = Rs;
4383 let Inst{11-1} = r13_2{12-2};
4384 let Inst{13} = r13_2{13};
4387 multiclass J2_jump_compare_0<string compare, bits<2> op> {
4388 def NAME : J2_jump_0_Base<compare, 0, op>;
4389 def NAME#pt : J2_jump_0_Base<compare, 1, op>;
4392 defm J2_jumprz : J2_jump_compare_0<"!=", 0b00>;
4393 defm J2_jumprgtez : J2_jump_compare_0<">=", 0b01>;
4394 defm J2_jumprnz : J2_jump_compare_0<"==", 0b10>;
4395 defm J2_jumprltez : J2_jump_compare_0<"<=", 0b11>;
4397 // Transfer to/from Control/GPR Guest/GPR
4398 let hasSideEffects = 0 in
4399 class TFR_CR_RS_base<RegisterClass CTRC, RegisterClass RC, bit isDouble>
4400 : CRInst <(outs CTRC:$dst), (ins RC:$src),
4401 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
4405 let IClass = 0b0110;
4407 let Inst{27-25} = 0b001;
4408 let Inst{24} = isDouble;
4409 let Inst{23-21} = 0b001;
4410 let Inst{20-16} = src;
4411 let Inst{4-0} = dst;
4414 def A2_tfrrcr : TFR_CR_RS_base<CtrRegs, IntRegs, 0b0>;
4415 def : InstAlias<"m0 = $Rs", (A2_tfrrcr C6, IntRegs:$Rs)>;
4416 def : InstAlias<"m1 = $Rs", (A2_tfrrcr C7, IntRegs:$Rs)>;
4418 let hasSideEffects = 0 in
4419 class TFR_RD_CR_base<RegisterClass RC, RegisterClass CTRC, bit isSingle>
4420 : CRInst <(outs RC:$dst), (ins CTRC:$src),
4421 "$dst = $src", [], "", CR_tc_3x_SLOT3> {
4425 let IClass = 0b0110;
4427 let Inst{27-26} = 0b10;
4428 let Inst{25} = isSingle;
4429 let Inst{24-21} = 0b0000;
4430 let Inst{20-16} = src;
4431 let Inst{4-0} = dst;
4434 let hasNewValue = 1, opNewValue = 0 in
4435 def A2_tfrcrr : TFR_RD_CR_base<IntRegs, CtrRegs, 1>;
4436 def : InstAlias<"$Rd = m0", (A2_tfrcrr IntRegs:$Rd, C6)>;
4437 def : InstAlias<"$Rd = m1", (A2_tfrcrr IntRegs:$Rd, C7)>;
4439 // Y4_trace: Send value to etm trace.
4440 let isSoloAX = 1, hasSideEffects = 0 in
4441 def Y4_trace: CRInst <(outs), (ins IntRegs:$Rs),
4445 let IClass = 0b0110;
4446 let Inst{27-21} = 0b0010010;
4447 let Inst{20-16} = Rs;
4450 let AddedComplexity = 100, isPredicated = 1, isCodeGenOnly = 1 in
4451 def TFR_condset_ri : ALU32_rr<(outs IntRegs:$dst),
4452 (ins PredRegs:$src1, IntRegs:$src2, s12Imm:$src3),
4453 "Error; should not emit",
4454 [(set (i32 IntRegs:$dst),
4455 (i32 (select (i1 PredRegs:$src1), (i32 IntRegs:$src2),
4456 s12ImmPred:$src3)))]>;
4458 let AddedComplexity = 100, isPredicated = 1, isCodeGenOnly = 1 in
4459 def TFR_condset_ir : ALU32_rr<(outs IntRegs:$dst),
4460 (ins PredRegs:$src1, s12Imm:$src2, IntRegs:$src3),
4461 "Error; should not emit",
4462 [(set (i32 IntRegs:$dst),
4463 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
4464 (i32 IntRegs:$src3))))]>;
4466 let AddedComplexity = 100, isPredicated = 1, isCodeGenOnly = 1 in
4467 def TFR_condset_ii : ALU32_rr<(outs IntRegs:$dst),
4468 (ins PredRegs:$src1, s12Imm:$src2, s12Imm:$src3),
4469 "Error; should not emit",
4470 [(set (i32 IntRegs:$dst),
4471 (i32 (select (i1 PredRegs:$src1), s12ImmPred:$src2,
4472 s12ImmPred:$src3)))]>;
4474 // Generate frameindex addresses.
4475 let isReMaterializable = 1, isCodeGenOnly = 1 in
4476 def TFR_FI : ALU32_ri<(outs IntRegs:$dst), (ins FrameIndex:$src1),
4477 "$dst = add($src1)",
4478 [(set (i32 IntRegs:$dst), ADDRri:$src1)]>;
4480 // Support for generating global address.
4481 // Taken from X86InstrInfo.td.
4482 def SDTHexagonCONST32 : SDTypeProfile<1, 1, [SDTCisVT<0, i32>,
4485 def HexagonCONST32 : SDNode<"HexagonISD::CONST32", SDTHexagonCONST32>;
4486 def HexagonCONST32_GP : SDNode<"HexagonISD::CONST32_GP", SDTHexagonCONST32>;
4488 // HI/LO Instructions
4489 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4490 isAsmParserOnly = 1 in
4491 def LO : ALU32_ri<(outs IntRegs:$dst), (ins globaladdress:$global),
4492 "$dst.l = #LO($global)",
4495 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4496 isAsmParserOnly = 1 in
4497 def HI : ALU32_ri<(outs IntRegs:$dst), (ins globaladdress:$global),
4498 "$dst.h = #HI($global)",
4501 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4502 isAsmParserOnly = 1 in
4503 def LOi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
4504 "$dst.l = #LO($imm_value)",
4508 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4509 isAsmParserOnly = 1 in
4510 def HIi : ALU32_ri<(outs IntRegs:$dst), (ins i32imm:$imm_value),
4511 "$dst.h = #HI($imm_value)",
4514 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4515 isAsmParserOnly = 1 in
4516 def LO_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4517 "$dst.l = #LO($jt)",
4520 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4521 isAsmParserOnly = 1 in
4522 def HI_jt : ALU32_ri<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4523 "$dst.h = #HI($jt)",
4527 let isReMaterializable = 1, isMoveImm = 1, hasSideEffects = 0,
4528 isAsmParserOnly = 1 in
4529 def LO_label : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
4530 "$dst.l = #LO($label)",
4533 let isReMaterializable = 1, isMoveImm = 1 , hasSideEffects = 0,
4534 isAsmParserOnly = 1 in
4535 def HI_label : ALU32_ri<(outs IntRegs:$dst), (ins bblabel:$label),
4536 "$dst.h = #HI($label)",
4539 // This pattern is incorrect. When we add small data, we should change
4540 // this pattern to use memw(#foo).
4541 // This is for sdata.
4542 let isMoveImm = 1, isAsmParserOnly = 1 in
4543 def CONST32 : LDInst<(outs IntRegs:$dst), (ins globaladdress:$global),
4544 "$dst = CONST32(#$global)",
4545 [(set (i32 IntRegs:$dst),
4546 (load (HexagonCONST32 tglobaltlsaddr:$global)))]>;
4548 // This is for non-sdata.
4549 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4550 def CONST32_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
4551 "$dst = CONST32(#$global)",
4552 [(set (i32 IntRegs:$dst),
4553 (HexagonCONST32 tglobaladdr:$global))]>;
4555 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4556 def CONST32_set_jt : LDInst2<(outs IntRegs:$dst), (ins jumptablebase:$jt),
4557 "$dst = CONST32(#$jt)",
4558 [(set (i32 IntRegs:$dst),
4559 (HexagonCONST32 tjumptable:$jt))]>;
4561 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4562 def CONST32GP_set : LDInst2<(outs IntRegs:$dst), (ins globaladdress:$global),
4563 "$dst = CONST32(#$global)",
4564 [(set (i32 IntRegs:$dst),
4565 (HexagonCONST32_GP tglobaladdr:$global))]>;
4567 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4568 def CONST32_Int_Real : LDInst2<(outs IntRegs:$dst), (ins i32imm:$global),
4569 "$dst = CONST32(#$global)",
4570 [(set (i32 IntRegs:$dst), imm:$global) ]>;
4572 // Map BlockAddress lowering to CONST32_Int_Real
4573 def : Pat<(HexagonCONST32_GP tblockaddress:$addr),
4574 (CONST32_Int_Real tblockaddress:$addr)>;
4576 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4577 def CONST32_Label : LDInst2<(outs IntRegs:$dst), (ins bblabel:$label),
4578 "$dst = CONST32($label)",
4579 [(set (i32 IntRegs:$dst), (HexagonCONST32 bbl:$label))]>;
4581 let isReMaterializable = 1, isMoveImm = 1, isAsmParserOnly = 1 in
4582 def CONST64_Int_Real : LDInst2<(outs DoubleRegs:$dst), (ins i64imm:$global),
4583 "$dst = CONST64(#$global)",
4584 [(set (i64 DoubleRegs:$dst), imm:$global) ]>;
4586 let isCodeGenOnly = 1 in
4587 def TFR_PdFalse : SInst<(outs PredRegs:$dst), (ins),
4588 "$dst = xor($dst, $dst)",
4589 [(set (i1 PredRegs:$dst), 0)]>;
4591 // Pseudo instructions.
4592 def SDT_SPCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
4593 def SDT_SPCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
4594 SDTCisVT<1, i32> ]>;
4596 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_SPCallSeqStart,
4597 [SDNPHasChain, SDNPOutGlue]>;
4598 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_SPCallSeqEnd,
4599 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
4601 def SDT_SPCall : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
4603 // For tailcalls a HexagonTCRet SDNode has 3 SDNode Properties - a chain,
4604 // Optional Flag and Variable Arguments.
4605 // Its 1 Operand has pointer type.
4606 def HexagonTCRet : SDNode<"HexagonISD::TC_RETURN", SDT_SPCall,
4607 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
4609 let Defs = [R29, R30], Uses = [R31, R30, R29] in {
4610 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
4611 "Should never be emitted",
4612 [(callseq_start timm:$amt)]>;
4615 let Defs = [R29, R30, R31], Uses = [R29] in {
4616 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
4617 "Should never be emitted",
4618 [(callseq_end timm:$amt1, timm:$amt2)]>;
4621 let isCall = 1, hasSideEffects = 0, isAsmParserOnly = 1,
4622 Defs = [D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10,
4623 R22, R23, R28, R31, P0, P1, P2, P3, LC0, LC1, SA0, SA1] in {
4624 def CALL : JInst<(outs), (ins calltarget:$dst),
4628 // Call subroutine indirectly.
4629 let Defs = VolatileV3.Regs in
4630 def J2_callr : JUMPR_MISC_CALLR<0, 1>;
4632 // Indirect tail-call.
4633 let isCodeGenOnly = 1, isCall = 1, isReturn = 1 in
4634 def TCRETURNR : T_JMPr;
4636 // Direct tail-calls.
4637 let isCall = 1, isReturn = 1, isBarrier = 1, isPredicable = 0,
4638 isTerminator = 1, isCodeGenOnly = 1 in {
4639 def TCRETURNtg : JInst<(outs), (ins calltarget:$dst), "jump $dst",
4640 [], "", J_tc_2early_SLOT23>;
4641 def TCRETURNtext : JInst<(outs), (ins calltarget:$dst), "jump $dst",
4642 [], "", J_tc_2early_SLOT23>;
4646 def : Pat<(HexagonTCRet tglobaladdr:$dst),
4647 (TCRETURNtg tglobaladdr:$dst)>;
4648 def : Pat<(HexagonTCRet texternalsym:$dst),
4649 (TCRETURNtext texternalsym:$dst)>;
4650 def : Pat<(HexagonTCRet (i32 IntRegs:$dst)),
4651 (TCRETURNR (i32 IntRegs:$dst))>;
4653 // Map from r0 = and(r1, 65535) to r0 = zxth(r1)
4654 def : Pat <(and (i32 IntRegs:$src1), 65535),
4655 (A2_zxth (i32 IntRegs:$src1))>;
4657 // Map from r0 = and(r1, 255) to r0 = zxtb(r1).
4658 def : Pat <(and (i32 IntRegs:$src1), 255),
4659 (A2_zxtb (i32 IntRegs:$src1))>;
4661 // Map Add(p1, true) to p1 = not(p1).
4662 // Add(p1, false) should never be produced,
4663 // if it does, it got to be mapped to NOOP.
4664 def : Pat <(add (i1 PredRegs:$src1), -1),
4665 (C2_not (i1 PredRegs:$src1))>;
4667 // Map from p0 = pnot(p0); r0 = mux(p0, #i, #j) => r0 = mux(p0, #j, #i).
4668 def : Pat <(select (not (i1 PredRegs:$src1)), s8ImmPred:$src2, s8ImmPred:$src3),
4669 (i32 (TFR_condset_ii (i1 PredRegs:$src1), s8ImmPred:$src3,
4672 // Map from p0 = pnot(p0); r0 = select(p0, #i, r1)
4673 // => r0 = TFR_condset_ri(p0, r1, #i)
4674 def : Pat <(select (not (i1 PredRegs:$src1)), s12ImmPred:$src2,
4675 (i32 IntRegs:$src3)),
4676 (i32 (TFR_condset_ri (i1 PredRegs:$src1), (i32 IntRegs:$src3),
4677 s12ImmPred:$src2))>;
4679 // Map from p0 = pnot(p0); r0 = mux(p0, r1, #i)
4680 // => r0 = TFR_condset_ir(p0, #i, r1)
4681 def : Pat <(select (not (i1 PredRegs:$src1)), IntRegs:$src2, s12ImmPred:$src3),
4682 (i32 (TFR_condset_ir (i1 PredRegs:$src1), s12ImmPred:$src3,
4683 (i32 IntRegs:$src2)))>;
4685 // Map from p0 = pnot(p0); if (p0) jump => if (!p0) jump.
4686 def : Pat <(brcond (not (i1 PredRegs:$src1)), bb:$offset),
4687 (J2_jumpf (i1 PredRegs:$src1), bb:$offset)>;
4689 // Map from p2 = pnot(p2); p1 = and(p0, p2) => p1 = and(p0, !p2).
4690 def : Pat <(and (i1 PredRegs:$src1), (not (i1 PredRegs:$src2))),
4691 (i1 (C2_andn (i1 PredRegs:$src1), (i1 PredRegs:$src2)))>;
4694 let AddedComplexity = 100 in
4695 def : Pat <(i64 (zextloadi1 (HexagonCONST32 tglobaladdr:$global))),
4696 (i64 (A2_combinew (A2_tfrsi 0),
4697 (L2_loadrub_io (CONST32_set tglobaladdr:$global), 0)))>,
4700 // Map from i1 loads to 32 bits. This assumes that the i1* is byte aligned.
4701 let AddedComplexity = 10 in
4702 def : Pat <(i32 (zextloadi1 ADDRriS11_0:$addr)),
4703 (i32 (A2_and (i32 (L2_loadrb_io AddrFI:$addr, 0)), (A2_tfrsi 0x1)))>;
4705 // Map from Rdd = sign_extend_inreg(Rss, i32) -> Rdd = A2_sxtw(Rss.lo).
4706 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i32)),
4707 (i64 (A2_sxtw (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg))))>;
4709 // Map from Rdd = sign_extend_inreg(Rss, i16) -> Rdd = A2_sxtw(SXTH(Rss.lo)).
4710 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i16)),
4711 (i64 (A2_sxtw (i32 (A2_sxth (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
4712 subreg_loreg))))))>;
4714 // Map from Rdd = sign_extend_inreg(Rss, i8) -> Rdd = A2_sxtw(SXTB(Rss.lo)).
4715 def : Pat <(i64 (sext_inreg (i64 DoubleRegs:$src1), i8)),
4716 (i64 (A2_sxtw (i32 (A2_sxtb (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
4717 subreg_loreg))))))>;
4719 // We want to prevent emitting pnot's as much as possible.
4720 // Map brcond with an unsupported setcc to a J2_jumpf.
4721 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4723 (J2_jumpf (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
4726 def : Pat <(brcond (i1 (setne (i32 IntRegs:$src1), s10ImmPred:$src2)),
4728 (J2_jumpf (C2_cmpeqi (i32 IntRegs:$src1), s10ImmPred:$src2), bb:$offset)>;
4730 def : Pat <(brcond (i1 (setne (i1 PredRegs:$src1), (i1 -1))), bb:$offset),
4731 (J2_jumpf (i1 PredRegs:$src1), bb:$offset)>;
4733 def : Pat <(brcond (i1 (setne (i1 PredRegs:$src1), (i1 0))), bb:$offset),
4734 (J2_jumpt (i1 PredRegs:$src1), bb:$offset)>;
4736 // cmp.lt(Rs, Imm) -> !cmp.ge(Rs, Imm) -> !cmp.gt(Rs, Imm-1)
4737 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), s8ImmPred:$src2)),
4739 (J2_jumpf (C2_cmpgti (i32 IntRegs:$src1),
4740 (DEC_CONST_SIGNED s8ImmPred:$src2)), bb:$offset)>;
4742 // cmp.lt(r0, r1) -> cmp.gt(r1, r0)
4743 def : Pat <(brcond (i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4745 (J2_jumpt (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)), bb:$offset)>;
4747 def : Pat <(brcond (i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4749 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)),
4752 def : Pat <(brcond (i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4754 (J2_jumpf (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2)),
4757 def : Pat <(brcond (i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4759 (J2_jumpf (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
4762 // Map from a 64-bit select to an emulated 64-bit mux.
4763 // Hexagon does not support 64-bit MUXes; so emulate with combines.
4764 def : Pat <(select (i1 PredRegs:$src1), (i64 DoubleRegs:$src2),
4765 (i64 DoubleRegs:$src3)),
4766 (i64 (A2_combinew (i32 (C2_mux (i1 PredRegs:$src1),
4767 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
4769 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src3),
4771 (i32 (C2_mux (i1 PredRegs:$src1),
4772 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
4774 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src3),
4775 subreg_loreg))))))>;
4777 // Map from a 1-bit select to logical ops.
4778 // From LegalizeDAG.cpp: (B1 ? B2 : B3) <=> (B1 & B2)|(!B1&B3).
4779 def : Pat <(select (i1 PredRegs:$src1), (i1 PredRegs:$src2),
4780 (i1 PredRegs:$src3)),
4781 (C2_or (C2_and (i1 PredRegs:$src1), (i1 PredRegs:$src2)),
4782 (C2_and (C2_not (i1 PredRegs:$src1)), (i1 PredRegs:$src3)))>;
4784 // Map Pd = load(addr) -> Rs = load(addr); Pd = Rs.
4785 def : Pat<(i1 (load ADDRriS11_2:$addr)),
4786 (i1 (C2_tfrrp (i32 (L2_loadrb_io AddrFI:$addr, 0))))>;
4788 // Map for truncating from 64 immediates to 32 bit immediates.
4789 def : Pat<(i32 (trunc (i64 DoubleRegs:$src))),
4790 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src), subreg_loreg))>;
4792 // Map for truncating from i64 immediates to i1 bit immediates.
4793 def : Pat<(i1 (trunc (i64 DoubleRegs:$src))),
4794 (i1 (C2_tfrrp (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4797 // Map memb(Rs) = Rdd -> memb(Rs) = Rt.
4798 def : Pat<(truncstorei8 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4799 (S2_storerb_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4802 // Map memh(Rs) = Rdd -> memh(Rs) = Rt.
4803 def : Pat<(truncstorei16 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4804 (S2_storerh_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4806 // Map memw(Rs) = Rdd -> memw(Rs) = Rt
4807 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4808 (S2_storeri_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4811 // Map memw(Rs) = Rdd -> memw(Rs) = Rt.
4812 def : Pat<(truncstorei32 (i64 DoubleRegs:$src), ADDRriS11_0:$addr),
4813 (S2_storeri_io AddrFI:$addr, 0, (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src),
4816 // Map from i1 = constant<-1>; memw(addr) = i1 -> r0 = 1; memw(addr) = r0.
4817 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
4818 (S2_storerb_io AddrFI:$addr, 0, (A2_tfrsi 1))>;
4821 // Map from i1 = constant<-1>; store i1 -> r0 = 1; store r0.
4822 def : Pat<(store (i1 -1), ADDRriS11_2:$addr),
4823 (S2_storerb_io AddrFI:$addr, 0, (A2_tfrsi 1))>;
4825 // Map from memb(Rs) = Pd -> Rt = mux(Pd, #0, #1); store Rt.
4826 def : Pat<(store (i1 PredRegs:$src1), ADDRriS11_2:$addr),
4827 (S2_storerb_io AddrFI:$addr, 0, (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0)) )>;
4829 // Map Rdd = anyext(Rs) -> Rdd = A2_sxtw(Rs).
4830 // Hexagon_TODO: We can probably use combine but that will cost 2 instructions.
4831 // Better way to do this?
4832 def : Pat<(i64 (anyext (i32 IntRegs:$src1))),
4833 (i64 (A2_sxtw (i32 IntRegs:$src1)))>;
4835 // Map cmple -> cmpgt.
4836 // rs <= rt -> !(rs > rt).
4837 def : Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
4838 (i1 (C2_not (C2_cmpgti (i32 IntRegs:$src1), s10ExtPred:$src2)))>;
4840 // rs <= rt -> !(rs > rt).
4841 def : Pat<(i1 (setle (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4842 (i1 (C2_not (C2_cmpgt (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
4844 // Rss <= Rtt -> !(Rss > Rtt).
4845 def : Pat<(i1 (setle (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4846 (i1 (C2_not (C2_cmpgtp (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))))>;
4848 // Map cmpne -> cmpeq.
4849 // Hexagon_TODO: We should improve on this.
4850 // rs != rt -> !(rs == rt).
4851 def : Pat <(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
4852 (i1 (C2_not(i1 (C2_cmpeqi (i32 IntRegs:$src1), s10ExtPred:$src2))))>;
4854 // Map cmpne(Rs) -> !cmpeqe(Rs).
4855 // rs != rt -> !(rs == rt).
4856 def : Pat <(i1 (setne (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4857 (i1 (C2_not (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src2)))))>;
4859 // Convert setne back to xor for hexagon since we compute w/ pred registers.
4860 def : Pat <(i1 (setne (i1 PredRegs:$src1), (i1 PredRegs:$src2))),
4861 (i1 (C2_xor (i1 PredRegs:$src1), (i1 PredRegs:$src2)))>;
4863 // Map cmpne(Rss) -> !cmpew(Rss).
4864 // rs != rt -> !(rs == rt).
4865 def : Pat <(i1 (setne (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4866 (i1 (C2_not (i1 (C2_cmpeqp (i64 DoubleRegs:$src1),
4867 (i64 DoubleRegs:$src2)))))>;
4869 // Map cmpge(Rs, Rt) -> !(cmpgt(Rs, Rt).
4870 // rs >= rt -> !(rt > rs).
4871 def : Pat <(i1 (setge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4872 (i1 (C2_not (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))))>;
4874 // cmpge(Rs, Imm) -> cmpgt(Rs, Imm-1)
4875 def : Pat <(i1 (setge (i32 IntRegs:$src1), s8ExtPred:$src2)),
4876 (i1 (C2_cmpgti (i32 IntRegs:$src1), (DEC_CONST_SIGNED s8ExtPred:$src2)))>;
4878 // Map cmpge(Rss, Rtt) -> !cmpgt(Rtt, Rss).
4879 // rss >= rtt -> !(rtt > rss).
4880 def : Pat <(i1 (setge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4881 (i1 (C2_not (i1 (C2_cmpgtp (i64 DoubleRegs:$src2),
4882 (i64 DoubleRegs:$src1)))))>;
4884 // Map cmplt(Rs, Imm) -> !cmpge(Rs, Imm).
4885 // !cmpge(Rs, Imm) -> !cmpgt(Rs, Imm-1).
4886 // rs < rt -> !(rs >= rt).
4887 def : Pat <(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
4888 (i1 (C2_not (C2_cmpgti (i32 IntRegs:$src1), (DEC_CONST_SIGNED s8ExtPred:$src2))))>;
4890 // Map cmplt(Rs, Rt) -> cmpgt(Rt, Rs).
4891 // rs < rt -> rt > rs.
4892 // We can let assembler map it, or we can do in the compiler itself.
4893 def : Pat <(i1 (setlt (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4894 (i1 (C2_cmpgt (i32 IntRegs:$src2), (i32 IntRegs:$src1)))>;
4896 // Map cmplt(Rss, Rtt) -> cmpgt(Rtt, Rss).
4897 // rss < rtt -> (rtt > rss).
4898 def : Pat <(i1 (setlt (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4899 (i1 (C2_cmpgtp (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)))>;
4901 // Map from cmpltu(Rs, Rd) -> cmpgtu(Rd, Rs)
4902 // rs < rt -> rt > rs.
4903 // We can let assembler map it, or we can do in the compiler itself.
4904 def : Pat <(i1 (setult (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4905 (i1 (C2_cmpgtu (i32 IntRegs:$src2), (i32 IntRegs:$src1)))>;
4907 // Map from cmpltu(Rss, Rdd) -> cmpgtu(Rdd, Rss).
4908 // rs < rt -> rt > rs.
4909 def : Pat <(i1 (setult (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4910 (i1 (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1)))>;
4912 // Generate cmpgeu(Rs, #0) -> cmpeq(Rs, Rs)
4913 def : Pat <(i1 (setuge (i32 IntRegs:$src1), 0)),
4914 (i1 (C2_cmpeq (i32 IntRegs:$src1), (i32 IntRegs:$src1)))>;
4916 // Generate cmpgeu(Rs, #u8) -> cmpgtu(Rs, #u8 -1)
4917 def : Pat <(i1 (setuge (i32 IntRegs:$src1), u8ExtPred:$src2)),
4918 (i1 (C2_cmpgtui (i32 IntRegs:$src1), (DEC_CONST_UNSIGNED u8ExtPred:$src2)))>;
4920 // Generate cmpgtu(Rs, #u9)
4921 def : Pat <(i1 (setugt (i32 IntRegs:$src1), u9ExtPred:$src2)),
4922 (i1 (C2_cmpgtui (i32 IntRegs:$src1), u9ExtPred:$src2))>;
4924 // Map from Rs >= Rt -> !(Rt > Rs).
4925 // rs >= rt -> !(rt > rs).
4926 def : Pat <(i1 (setuge (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4927 (i1 (C2_not (C2_cmpgtu (i32 IntRegs:$src2), (i32 IntRegs:$src1))))>;
4929 // Map from Rs >= Rt -> !(Rt > Rs).
4930 // rs >= rt -> !(rt > rs).
4931 def : Pat <(i1 (setuge (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4932 (i1 (C2_not (C2_cmpgtup (i64 DoubleRegs:$src2), (i64 DoubleRegs:$src1))))>;
4934 // Map from cmpleu(Rs, Rt) -> !cmpgtu(Rs, Rt).
4935 // Map from (Rs <= Rt) -> !(Rs > Rt).
4936 def : Pat <(i1 (setule (i32 IntRegs:$src1), (i32 IntRegs:$src2))),
4937 (i1 (C2_not (C2_cmpgtu (i32 IntRegs:$src1), (i32 IntRegs:$src2))))>;
4939 // Map from cmpleu(Rss, Rtt) -> !cmpgtu(Rss, Rtt-1).
4940 // Map from (Rs <= Rt) -> !(Rs > Rt).
4941 def : Pat <(i1 (setule (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))),
4942 (i1 (C2_not (C2_cmpgtup (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2))))>;
4946 def : Pat <(i32 (sext (i1 PredRegs:$src1))),
4947 (i32 (C2_muxii (i1 PredRegs:$src1), -1, 0))>;
4950 def : Pat <(i64 (sext (i1 PredRegs:$src1))),
4951 (i64 (A2_combinew (A2_tfrsi -1), (C2_muxii (i1 PredRegs:$src1), -1, 0)))>;
4953 // Convert sign-extended load back to load and sign extend.
4955 def: Pat <(i64 (sextloadi8 ADDRriS11_0:$src1)),
4956 (i64 (A2_sxtw (L2_loadrb_io AddrFI:$src1, 0)))>;
4958 // Convert any-extended load back to load and sign extend.
4960 def: Pat <(i64 (extloadi8 ADDRriS11_0:$src1)),
4961 (i64 (A2_sxtw (L2_loadrb_io AddrFI:$src1, 0)))>;
4963 // Convert sign-extended load back to load and sign extend.
4965 def: Pat <(i64 (sextloadi16 ADDRriS11_1:$src1)),
4966 (i64 (A2_sxtw (L2_loadrh_io AddrFI:$src1, 0)))>;
4968 // Convert sign-extended load back to load and sign extend.
4970 def: Pat <(i64 (sextloadi32 ADDRriS11_2:$src1)),
4971 (i64 (A2_sxtw (L2_loadri_io AddrFI:$src1, 0)))>;
4976 def : Pat <(i32 (zext (i1 PredRegs:$src1))),
4977 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
4980 def : Pat <(i64 (zext (i1 PredRegs:$src1))),
4981 (i64 (A2_combinew (A2_tfrsi 0), (C2_muxii (i1 PredRegs:$src1), 1, 0)))>,
4985 def : Pat <(i64 (zext (i32 IntRegs:$src1))),
4986 (i64 (A2_combinew (A2_tfrsi 0), (i32 IntRegs:$src1)))>,
4990 def: Pat <(i64 (zextloadi8 ADDRriS11_0:$src1)),
4991 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io AddrFI:$src1, 0)))>,
4994 let AddedComplexity = 20 in
4995 def: Pat <(i64 (zextloadi8 (add (i32 IntRegs:$src1),
4996 s11_0ExtPred:$offset))),
4997 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io IntRegs:$src1,
4998 s11_0ExtPred:$offset)))>,
5002 def: Pat <(i64 (zextloadi1 ADDRriS11_0:$src1)),
5003 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io AddrFI:$src1, 0)))>,
5006 let AddedComplexity = 20 in
5007 def: Pat <(i64 (zextloadi1 (add (i32 IntRegs:$src1),
5008 s11_0ExtPred:$offset))),
5009 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrub_io IntRegs:$src1,
5010 s11_0ExtPred:$offset)))>,
5014 def: Pat <(i64 (zextloadi16 ADDRriS11_1:$src1)),
5015 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadruh_io AddrFI:$src1, 0)))>,
5018 let AddedComplexity = 20 in
5019 def: Pat <(i64 (zextloadi16 (add (i32 IntRegs:$src1),
5020 s11_1ExtPred:$offset))),
5021 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadruh_io IntRegs:$src1,
5022 s11_1ExtPred:$offset)))>,
5026 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)),
5027 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io AddrFI:$src1, 0)))>,
5030 let AddedComplexity = 100 in
5031 def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
5032 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io IntRegs:$src1,
5033 s11_2ExtPred:$offset)))>,
5036 let AddedComplexity = 10 in
5037 def: Pat <(i32 (zextloadi1 ADDRriS11_0:$src1)),
5038 (i32 (L2_loadri_io AddrFI:$src1, 0))>;
5040 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
5041 def : Pat <(i32 (zext (i1 PredRegs:$src1))),
5042 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
5044 // Map from Rs = Pd to Pd = mux(Pd, #1, #0)
5045 def : Pat <(i32 (anyext (i1 PredRegs:$src1))),
5046 (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))>;
5048 // Map from Rss = Pd to Rdd = A2_sxtw (mux(Pd, #1, #0))
5049 def : Pat <(i64 (anyext (i1 PredRegs:$src1))),
5050 (i64 (A2_sxtw (i32 (C2_muxii (i1 PredRegs:$src1), 1, 0))))>;
5053 let AddedComplexity = 100 in
5054 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5056 (i64 (zextloadi32 (i32 (add IntRegs:$src2,
5057 s11_2ExtPred:$offset2)))))),
5058 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5059 (L2_loadri_io IntRegs:$src2,
5060 s11_2ExtPred:$offset2)))>;
5062 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5064 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
5065 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5066 (L2_loadri_io AddrFI:$srcLow, 0)))>;
5068 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5070 (i64 (zext (i32 IntRegs:$srcLow))))),
5071 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5074 let AddedComplexity = 100 in
5075 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5077 (i64 (zextloadi32 (i32 (add IntRegs:$src2,
5078 s11_2ExtPred:$offset2)))))),
5079 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5080 (L2_loadri_io IntRegs:$src2,
5081 s11_2ExtPred:$offset2)))>;
5083 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5085 (i64 (zextloadi32 ADDRriS11_2:$srcLow)))),
5086 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5087 (L2_loadri_io AddrFI:$srcLow, 0)))>;
5089 def: Pat<(i64 (or (i64 (shl (i64 DoubleRegs:$srcHigh),
5091 (i64 (zext (i32 IntRegs:$srcLow))))),
5092 (i64 (A2_combinew (EXTRACT_SUBREG (i64 DoubleRegs:$srcHigh), subreg_loreg),
5095 // Any extended 64-bit load.
5096 // anyext i32 -> i64
5097 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)),
5098 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io AddrFI:$src1, 0)))>,
5101 // When there is an offset we should prefer the pattern below over the pattern above.
5102 // The complexity of the above is 13 (gleaned from HexagonGenDAGIsel.inc)
5103 // So this complexity below is comfortably higher to allow for choosing the below.
5104 // If this is not done then we generate addresses such as
5105 // ********************************************
5106 // r1 = add (r0, #4)
5107 // r1 = memw(r1 + #0)
5109 // r1 = memw(r0 + #4)
5110 // ********************************************
5111 let AddedComplexity = 100 in
5112 def: Pat <(i64 (extloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
5113 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadri_io IntRegs:$src1,
5114 s11_2ExtPred:$offset)))>,
5117 // anyext i16 -> i64.
5118 def: Pat <(i64 (extloadi16 ADDRriS11_2:$src1)),
5119 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrh_io AddrFI:$src1, 0)))>,
5122 let AddedComplexity = 20 in
5123 def: Pat <(i64 (extloadi16 (add (i32 IntRegs:$src1),
5124 s11_1ExtPred:$offset))),
5125 (i64 (A2_combinew (A2_tfrsi 0), (L2_loadrh_io IntRegs:$src1,
5126 s11_1ExtPred:$offset)))>,
5129 // Map from Rdd = zxtw(Rs) -> Rdd = combine(0, Rs).
5130 def : Pat<(i64 (zext (i32 IntRegs:$src1))),
5131 (i64 (A2_combinew (A2_tfrsi 0), (i32 IntRegs:$src1)))>,
5134 // Multiply 64-bit unsigned and use upper result.
5135 def : Pat <(mulhu (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
5150 (A2_combinew (A2_tfrsi 0),
5157 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
5159 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
5160 subreg_loreg)))), 32)),
5162 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5163 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_loreg)))),
5164 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg)),
5165 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg)))),
5166 32)), subreg_loreg)))),
5167 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5168 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg))))>;
5170 // Multiply 64-bit signed and use upper result.
5171 def : Pat <(mulhs (i64 DoubleRegs:$src1), (i64 DoubleRegs:$src2)),
5175 (A2_combinew (A2_tfrsi 0),
5185 (A2_combinew (A2_tfrsi 0),
5192 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1),
5194 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2),
5195 subreg_loreg)))), 32)),
5197 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5198 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_loreg)))),
5199 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_loreg)),
5200 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg)))),
5201 32)), subreg_loreg)))),
5202 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src1), subreg_hireg)),
5203 (i32 (EXTRACT_SUBREG (i64 DoubleRegs:$src2), subreg_hireg))))>;
5205 // Hexagon specific ISD nodes.
5206 def SDTHexagonADJDYNALLOC : SDTypeProfile<1, 2,
5207 [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
5208 def Hexagon_ADJDYNALLOC : SDNode<"HexagonISD::ADJDYNALLOC",
5209 SDTHexagonADJDYNALLOC>;
5210 // Needed to tag these instructions for stack layout.
5211 let usesCustomInserter = 1, isAsmParserOnly = 1 in
5212 def ADJDYNALLOC : ALU32_ri<(outs IntRegs:$dst), (ins IntRegs:$src1,
5214 "$dst = add($src1, #$src2)",
5215 [(set (i32 IntRegs:$dst),
5216 (Hexagon_ADJDYNALLOC (i32 IntRegs:$src1),
5217 s16ImmPred:$src2))]>;
5219 def SDTHexagonARGEXTEND : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
5220 def Hexagon_ARGEXTEND : SDNode<"HexagonISD::ARGEXTEND", SDTHexagonARGEXTEND>;
5221 let isCodeGenOnly = 1 in
5222 def ARGEXTEND : ALU32_rr <(outs IntRegs:$dst), (ins IntRegs:$src1),
5224 [(set (i32 IntRegs:$dst),
5225 (Hexagon_ARGEXTEND (i32 IntRegs:$src1)))]>;
5227 let AddedComplexity = 100 in
5228 def : Pat<(i32 (sext_inreg (Hexagon_ARGEXTEND (i32 IntRegs:$src1)), i16)),
5229 (COPY (i32 IntRegs:$src1))>;
5231 def HexagonWrapperJT: SDNode<"HexagonISD::WrapperJT", SDTIntUnaryOp>;
5233 def : Pat<(HexagonWrapperJT tjumptable:$dst),
5234 (i32 (CONST32_set_jt tjumptable:$dst))>;
5238 //===----------------------------------------------------------------------===//
5240 // Shift by immediate/register and accumulate/logical
5241 //===----------------------------------------------------------------------===//
5243 // Rx[+-&|]=asr(Rs,#u5)
5244 // Rx[+-&|^]=lsr(Rs,#u5)
5245 // Rx[+-&|^]=asl(Rs,#u5)
5247 let hasNewValue = 1, opNewValue = 0 in
5248 class T_shift_imm_acc_r <string opc1, string opc2, SDNode OpNode1,
5249 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5250 : SInst_acc<(outs IntRegs:$Rx),
5251 (ins IntRegs:$src1, IntRegs:$Rs, u5Imm:$u5),
5252 "$Rx "#opc2#opc1#"($Rs, #$u5)",
5253 [(set (i32 IntRegs:$Rx),
5254 (OpNode2 (i32 IntRegs:$src1),
5255 (OpNode1 (i32 IntRegs:$Rs), u5ImmPred:$u5)))],
5256 "$src1 = $Rx", S_2op_tc_2_SLOT23> {
5261 let IClass = 0b1000;
5263 let Inst{27-24} = 0b1110;
5264 let Inst{23-22} = majOp{2-1};
5266 let Inst{7} = majOp{0};
5267 let Inst{6-5} = minOp;
5269 let Inst{20-16} = Rs;
5270 let Inst{12-8} = u5;
5273 // Rx[+-&|]=asr(Rs,Rt)
5274 // Rx[+-&|^]=lsr(Rs,Rt)
5275 // Rx[+-&|^]=asl(Rs,Rt)
5277 let hasNewValue = 1, opNewValue = 0 in
5278 class T_shift_reg_acc_r <string opc1, string opc2, SDNode OpNode1,
5279 SDNode OpNode2, bits<2> majOp, bits<2> minOp>
5280 : SInst_acc<(outs IntRegs:$Rx),
5281 (ins IntRegs:$src1, IntRegs:$Rs, IntRegs:$Rt),
5282 "$Rx "#opc2#opc1#"($Rs, $Rt)",
5283 [(set (i32 IntRegs:$Rx),
5284 (OpNode2 (i32 IntRegs:$src1),
5285 (OpNode1 (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))],
5286 "$src1 = $Rx", S_3op_tc_2_SLOT23 > {
5291 let IClass = 0b1100;
5293 let Inst{27-24} = 0b1100;
5294 let Inst{23-22} = majOp;
5295 let Inst{7-6} = minOp;
5297 let Inst{20-16} = Rs;
5298 let Inst{12-8} = Rt;
5301 // Rxx[+-&|]=asr(Rss,#u6)
5302 // Rxx[+-&|^]=lsr(Rss,#u6)
5303 // Rxx[+-&|^]=asl(Rss,#u6)
5305 class T_shift_imm_acc_p <string opc1, string opc2, SDNode OpNode1,
5306 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5307 : SInst_acc<(outs DoubleRegs:$Rxx),
5308 (ins DoubleRegs:$src1, DoubleRegs:$Rss, u6Imm:$u6),
5309 "$Rxx "#opc2#opc1#"($Rss, #$u6)",
5310 [(set (i64 DoubleRegs:$Rxx),
5311 (OpNode2 (i64 DoubleRegs:$src1),
5312 (OpNode1 (i64 DoubleRegs:$Rss), u6ImmPred:$u6)))],
5313 "$src1 = $Rxx", S_2op_tc_2_SLOT23> {
5318 let IClass = 0b1000;
5320 let Inst{27-24} = 0b0010;
5321 let Inst{23-22} = majOp{2-1};
5322 let Inst{7} = majOp{0};
5323 let Inst{6-5} = minOp;
5324 let Inst{4-0} = Rxx;
5325 let Inst{20-16} = Rss;
5326 let Inst{13-8} = u6;
5330 // Rxx[+-&|]=asr(Rss,Rt)
5331 // Rxx[+-&|^]=lsr(Rss,Rt)
5332 // Rxx[+-&|^]=asl(Rss,Rt)
5333 // Rxx[+-&|^]=lsl(Rss,Rt)
5335 class T_shift_reg_acc_p <string opc1, string opc2, SDNode OpNode1,
5336 SDNode OpNode2, bits<3> majOp, bits<2> minOp>
5337 : SInst_acc<(outs DoubleRegs:$Rxx),
5338 (ins DoubleRegs:$src1, DoubleRegs:$Rss, IntRegs:$Rt),
5339 "$Rxx "#opc2#opc1#"($Rss, $Rt)",
5340 [(set (i64 DoubleRegs:$Rxx),
5341 (OpNode2 (i64 DoubleRegs:$src1),
5342 (OpNode1 (i64 DoubleRegs:$Rss), (i32 IntRegs:$Rt))))],
5343 "$src1 = $Rxx", S_3op_tc_2_SLOT23> {
5348 let IClass = 0b1100;
5350 let Inst{27-24} = 0b1011;
5351 let Inst{23-21} = majOp;
5352 let Inst{20-16} = Rss;
5353 let Inst{12-8} = Rt;
5354 let Inst{7-6} = minOp;
5355 let Inst{4-0} = Rxx;
5358 //===----------------------------------------------------------------------===//
5359 // Multi-class for the shift instructions with logical/arithmetic operators.
5360 //===----------------------------------------------------------------------===//
5362 multiclass xtype_imm_base<string OpcStr1, string OpcStr2, SDNode OpNode1,
5363 SDNode OpNode2, bits<3> majOp, bits<2> minOp > {
5364 def _i_r#NAME : T_shift_imm_acc_r< OpcStr1, OpcStr2, OpNode1,
5365 OpNode2, majOp, minOp >;
5366 def _i_p#NAME : T_shift_imm_acc_p< OpcStr1, OpcStr2, OpNode1,
5367 OpNode2, majOp, minOp >;
5370 multiclass xtype_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
5371 let AddedComplexity = 100 in
5372 defm _acc : xtype_imm_base< opc1, "+= ", OpNode, add, 0b001, minOp>;
5374 defm _nac : xtype_imm_base< opc1, "-= ", OpNode, sub, 0b000, minOp>;
5375 defm _and : xtype_imm_base< opc1, "&= ", OpNode, and, 0b010, minOp>;
5376 defm _or : xtype_imm_base< opc1, "|= ", OpNode, or, 0b011, minOp>;
5379 multiclass xtype_xor_imm_acc<string opc1, SDNode OpNode, bits<2>minOp> {
5380 let AddedComplexity = 100 in
5381 defm _xacc : xtype_imm_base< opc1, "^= ", OpNode, xor, 0b100, minOp>;
5384 defm S2_asr : xtype_imm_acc<"asr", sra, 0b00>;
5386 defm S2_lsr : xtype_imm_acc<"lsr", srl, 0b01>,
5387 xtype_xor_imm_acc<"lsr", srl, 0b01>;
5389 defm S2_asl : xtype_imm_acc<"asl", shl, 0b10>,
5390 xtype_xor_imm_acc<"asl", shl, 0b10>;
5392 multiclass xtype_reg_acc_r<string opc1, SDNode OpNode, bits<2>minOp> {
5393 let AddedComplexity = 100 in
5394 def _acc : T_shift_reg_acc_r <opc1, "+= ", OpNode, add, 0b11, minOp>;
5396 def _nac : T_shift_reg_acc_r <opc1, "-= ", OpNode, sub, 0b10, minOp>;
5397 def _and : T_shift_reg_acc_r <opc1, "&= ", OpNode, and, 0b01, minOp>;
5398 def _or : T_shift_reg_acc_r <opc1, "|= ", OpNode, or, 0b00, minOp>;
5401 multiclass xtype_reg_acc_p<string opc1, SDNode OpNode, bits<2>minOp> {
5402 let AddedComplexity = 100 in
5403 def _acc : T_shift_reg_acc_p <opc1, "+= ", OpNode, add, 0b110, minOp>;
5405 def _nac : T_shift_reg_acc_p <opc1, "-= ", OpNode, sub, 0b100, minOp>;
5406 def _and : T_shift_reg_acc_p <opc1, "&= ", OpNode, and, 0b010, minOp>;
5407 def _or : T_shift_reg_acc_p <opc1, "|= ", OpNode, or, 0b000, minOp>;
5408 def _xor : T_shift_reg_acc_p <opc1, "^= ", OpNode, xor, 0b011, minOp>;
5411 multiclass xtype_reg_acc<string OpcStr, SDNode OpNode, bits<2> minOp > {
5412 defm _r_r : xtype_reg_acc_r <OpcStr, OpNode, minOp>;
5413 defm _r_p : xtype_reg_acc_p <OpcStr, OpNode, minOp>;
5416 defm S2_asl : xtype_reg_acc<"asl", shl, 0b10>;
5417 defm S2_asr : xtype_reg_acc<"asr", sra, 0b00>;
5418 defm S2_lsr : xtype_reg_acc<"lsr", srl, 0b01>;
5419 defm S2_lsl : xtype_reg_acc<"lsl", shl, 0b11>;
5421 //===----------------------------------------------------------------------===//
5422 let hasSideEffects = 0 in
5423 class T_S3op_1 <string mnemonic, RegisterClass RC, bits<2> MajOp, bits<3> MinOp,
5424 bit SwapOps, bit isSat = 0, bit isRnd = 0, bit hasShift = 0>
5425 : SInst <(outs RC:$dst),
5426 (ins DoubleRegs:$src1, DoubleRegs:$src2),
5427 "$dst = "#mnemonic#"($src1, $src2)"#!if(isRnd, ":rnd", "")
5428 #!if(hasShift,":>>1","")
5429 #!if(isSat, ":sat", ""),
5430 [], "", S_3op_tc_2_SLOT23 > {
5435 let IClass = 0b1100;
5437 let Inst{27-24} = 0b0001;
5438 let Inst{23-22} = MajOp;
5439 let Inst{20-16} = !if (SwapOps, src2, src1);
5440 let Inst{12-8} = !if (SwapOps, src1, src2);
5441 let Inst{7-5} = MinOp;
5442 let Inst{4-0} = dst;
5445 class T_S3op_64 <string mnemonic, bits<2> MajOp, bits<3> MinOp, bit SwapOps,
5446 bit isSat = 0, bit isRnd = 0, bit hasShift = 0 >
5447 : T_S3op_1 <mnemonic, DoubleRegs, MajOp, MinOp, SwapOps,
5448 isSat, isRnd, hasShift>;
5450 let Itinerary = S_3op_tc_1_SLOT23 in {
5451 def S2_shuffeb : T_S3op_64 < "shuffeb", 0b00, 0b010, 0>;
5452 def S2_shuffeh : T_S3op_64 < "shuffeh", 0b00, 0b110, 0>;
5453 def S2_shuffob : T_S3op_64 < "shuffob", 0b00, 0b100, 1>;
5454 def S2_shuffoh : T_S3op_64 < "shuffoh", 0b10, 0b000, 1>;
5456 def S2_vtrunewh : T_S3op_64 < "vtrunewh", 0b10, 0b010, 0>;
5457 def S2_vtrunowh : T_S3op_64 < "vtrunowh", 0b10, 0b100, 0>;
5460 def S2_lfsp : T_S3op_64 < "lfs", 0b10, 0b110, 0>;
5462 let hasSideEffects = 0 in
5463 class T_S3op_2 <string mnemonic, bits<3> MajOp, bit SwapOps>
5464 : SInst < (outs DoubleRegs:$Rdd),
5465 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
5466 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu)",
5467 [], "", S_3op_tc_1_SLOT23 > {
5473 let IClass = 0b1100;
5475 let Inst{27-24} = 0b0010;
5476 let Inst{23-21} = MajOp;
5477 let Inst{20-16} = !if (SwapOps, Rtt, Rss);
5478 let Inst{12-8} = !if (SwapOps, Rss, Rtt);
5480 let Inst{4-0} = Rdd;
5483 def S2_valignrb : T_S3op_2 < "valignb", 0b000, 1>;
5484 def S2_vsplicerb : T_S3op_2 < "vspliceb", 0b100, 0>;
5486 //===----------------------------------------------------------------------===//
5487 // Template class used by vector shift, vector rotate, vector neg,
5488 // 32-bit shift, 64-bit shifts, etc.
5489 //===----------------------------------------------------------------------===//
5491 let hasSideEffects = 0 in
5492 class T_S3op_3 <string mnemonic, RegisterClass RC, bits<2> MajOp,
5493 bits<2> MinOp, bit isSat = 0, list<dag> pattern = [] >
5494 : SInst <(outs RC:$dst),
5495 (ins RC:$src1, IntRegs:$src2),
5496 "$dst = "#mnemonic#"($src1, $src2)"#!if(isSat, ":sat", ""),
5497 pattern, "", S_3op_tc_1_SLOT23> {
5502 let IClass = 0b1100;
5504 let Inst{27-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b0110, 0b0011);
5505 let Inst{23-22} = MajOp;
5506 let Inst{20-16} = src1;
5507 let Inst{12-8} = src2;
5508 let Inst{7-6} = MinOp;
5509 let Inst{4-0} = dst;
5512 let hasNewValue = 1 in
5513 class T_S3op_shift32 <string mnemonic, SDNode OpNode, bits<2> MinOp>
5514 : T_S3op_3 <mnemonic, IntRegs, 0b01, MinOp, 0,
5515 [(set (i32 IntRegs:$dst), (OpNode (i32 IntRegs:$src1),
5516 (i32 IntRegs:$src2)))]>;
5518 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in
5519 class T_S3op_shift32_Sat <string mnemonic, bits<2> MinOp>
5520 : T_S3op_3 <mnemonic, IntRegs, 0b00, MinOp, 1, []>;
5523 class T_S3op_shift64 <string mnemonic, SDNode OpNode, bits<2> MinOp>
5524 : T_S3op_3 <mnemonic, DoubleRegs, 0b10, MinOp, 0,
5525 [(set (i64 DoubleRegs:$dst), (OpNode (i64 DoubleRegs:$src1),
5526 (i32 IntRegs:$src2)))]>;
5529 class T_S3op_shiftVect <string mnemonic, bits<2> MajOp, bits<2> MinOp>
5530 : T_S3op_3 <mnemonic, DoubleRegs, MajOp, MinOp, 0, []>;
5533 // Shift by register
5534 // Rdd=[asr|lsr|asl|lsl](Rss,Rt)
5536 def S2_asr_r_p : T_S3op_shift64 < "asr", sra, 0b00>;
5537 def S2_lsr_r_p : T_S3op_shift64 < "lsr", srl, 0b01>;
5538 def S2_asl_r_p : T_S3op_shift64 < "asl", shl, 0b10>;
5539 def S2_lsl_r_p : T_S3op_shift64 < "lsl", shl, 0b11>;
5541 // Rd=[asr|lsr|asl|lsl](Rs,Rt)
5543 def S2_asr_r_r : T_S3op_shift32<"asr", sra, 0b00>;
5544 def S2_lsr_r_r : T_S3op_shift32<"lsr", srl, 0b01>;
5545 def S2_asl_r_r : T_S3op_shift32<"asl", shl, 0b10>;
5546 def S2_lsl_r_r : T_S3op_shift32<"lsl", shl, 0b11>;
5548 // Shift by register with saturation
5549 // Rd=asr(Rs,Rt):sat
5550 // Rd=asl(Rs,Rt):sat
5552 let Defs = [USR_OVF] in {
5553 def S2_asr_r_r_sat : T_S3op_shift32_Sat<"asr", 0b00>;
5554 def S2_asl_r_r_sat : T_S3op_shift32_Sat<"asl", 0b10>;
5557 let hasNewValue = 1, hasSideEffects = 0 in
5558 class T_S3op_8 <string opc, bits<3> MinOp, bit isSat, bit isRnd, bit hasShift, bit hasSplat = 0>
5559 : SInst < (outs IntRegs:$Rd),
5560 (ins DoubleRegs:$Rss, IntRegs:$Rt),
5561 "$Rd = "#opc#"($Rss, $Rt"#!if(hasSplat, "*", "")#")"
5562 #!if(hasShift, ":<<1", "")
5563 #!if(isRnd, ":rnd", "")
5564 #!if(isSat, ":sat", ""),
5565 [], "", S_3op_tc_1_SLOT23 > {
5570 let IClass = 0b1100;
5572 let Inst{27-24} = 0b0101;
5573 let Inst{20-16} = Rss;
5574 let Inst{12-8} = Rt;
5575 let Inst{7-5} = MinOp;
5579 def S2_asr_r_svw_trun : T_S3op_8<"vasrw", 0b010, 0, 0, 0>;
5581 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
5582 def S2_vcrotate : T_S3op_shiftVect < "vcrotate", 0b11, 0b00>;
5584 let hasSideEffects = 0 in
5585 class T_S3op_7 <string mnemonic, bit MajOp >
5586 : SInst <(outs DoubleRegs:$Rdd),
5587 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, u3Imm:$u3),
5588 "$Rdd = "#mnemonic#"($Rss, $Rtt, #$u3)" ,
5589 [], "", S_3op_tc_1_SLOT23 > {
5595 let IClass = 0b1100;
5597 let Inst{27-24} = 0b0000;
5598 let Inst{23} = MajOp;
5599 let Inst{20-16} = !if(MajOp, Rss, Rtt);
5600 let Inst{12-8} = !if(MajOp, Rtt, Rss);
5602 let Inst{4-0} = Rdd;
5605 def S2_valignib : T_S3op_7 < "valignb", 0>;
5606 def S2_vspliceib : T_S3op_7 < "vspliceb", 1>;
5608 //===----------------------------------------------------------------------===//
5609 // Template class for 'insert bitfield' instructions
5610 //===----------------------------------------------------------------------===//
5611 let hasSideEffects = 0 in
5612 class T_S3op_insert <string mnemonic, RegisterClass RC>
5613 : SInst <(outs RC:$dst),
5614 (ins RC:$src1, RC:$src2, DoubleRegs:$src3),
5615 "$dst = "#mnemonic#"($src2, $src3)" ,
5616 [], "$src1 = $dst", S_3op_tc_1_SLOT23 > {
5621 let IClass = 0b1100;
5623 let Inst{27-26} = 0b10;
5624 let Inst{25-24} = !if(!eq(!cast<string>(RC), "IntRegs"), 0b00, 0b10);
5626 let Inst{20-16} = src2;
5627 let Inst{12-8} = src3;
5628 let Inst{4-0} = dst;
5631 let hasSideEffects = 0 in
5632 class T_S2op_insert <bits<4> RegTyBits, RegisterClass RC, Operand ImmOp>
5633 : SInst <(outs RC:$dst), (ins RC:$dst2, RC:$src1, ImmOp:$src2, ImmOp:$src3),
5634 "$dst = insert($src1, #$src2, #$src3)",
5635 [], "$dst2 = $dst", S_2op_tc_2_SLOT23> {
5642 string ImmOpStr = !cast<string>(ImmOp);
5644 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5}, 0);
5645 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
5647 let IClass = 0b1000;
5649 let Inst{27-24} = RegTyBits;
5650 let Inst{23} = bit23;
5651 let Inst{22-21} = src3{4-3};
5652 let Inst{20-16} = src1;
5653 let Inst{13} = bit13;
5654 let Inst{12-8} = src2{4-0};
5655 let Inst{7-5} = src3{2-0};
5656 let Inst{4-0} = dst;
5659 // Rx=insert(Rs,Rtt)
5660 // Rx=insert(Rs,#u5,#U5)
5661 let hasNewValue = 1 in {
5662 def S2_insert_rp : T_S3op_insert <"insert", IntRegs>;
5663 def S2_insert : T_S2op_insert <0b1111, IntRegs, u5Imm>;
5666 // Rxx=insert(Rss,Rtt)
5667 // Rxx=insert(Rss,#u6,#U6)
5668 def S2_insertp_rp : T_S3op_insert<"insert", DoubleRegs>;
5669 def S2_insertp : T_S2op_insert <0b0011, DoubleRegs, u6Imm>;
5671 //===----------------------------------------------------------------------===//
5672 // Template class for 'extract bitfield' instructions
5673 //===----------------------------------------------------------------------===//
5674 let hasNewValue = 1, hasSideEffects = 0 in
5675 class T_S3op_extract <string mnemonic, bits<2> MinOp>
5676 : SInst <(outs IntRegs:$Rd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
5677 "$Rd = "#mnemonic#"($Rs, $Rtt)",
5678 [], "", S_3op_tc_2_SLOT23 > {
5683 let IClass = 0b1100;
5685 let Inst{27-22} = 0b100100;
5686 let Inst{20-16} = Rs;
5687 let Inst{12-8} = Rtt;
5688 let Inst{7-6} = MinOp;
5692 let hasSideEffects = 0 in
5693 class T_S2op_extract <string mnemonic, bits<4> RegTyBits,
5694 RegisterClass RC, Operand ImmOp>
5695 : SInst <(outs RC:$dst), (ins RC:$src1, ImmOp:$src2, ImmOp:$src3),
5696 "$dst = "#mnemonic#"($src1, #$src2, #$src3)",
5697 [], "", S_2op_tc_2_SLOT23> {
5704 string ImmOpStr = !cast<string>(ImmOp);
5706 let bit23 = !if (!eq(ImmOpStr, "u6Imm"), src3{5},
5707 !if (!eq(mnemonic, "extractu"), 0, 1));
5709 let bit13 = !if (!eq(ImmOpStr, "u6Imm"), src2{5}, 0);
5711 let IClass = 0b1000;
5713 let Inst{27-24} = RegTyBits;
5714 let Inst{23} = bit23;
5715 let Inst{22-21} = src3{4-3};
5716 let Inst{20-16} = src1;
5717 let Inst{13} = bit13;
5718 let Inst{12-8} = src2{4-0};
5719 let Inst{7-5} = src3{2-0};
5720 let Inst{4-0} = dst;
5725 // Rdd=extractu(Rss,Rtt)
5726 // Rdd=extractu(Rss,#u6,#U6)
5727 def S2_extractup_rp : T_S3op_64 < "extractu", 0b00, 0b000, 0>;
5728 def S2_extractup : T_S2op_extract <"extractu", 0b0001, DoubleRegs, u6Imm>;
5730 // Rd=extractu(Rs,Rtt)
5731 // Rd=extractu(Rs,#u5,#U5)
5732 let hasNewValue = 1 in {
5733 def S2_extractu_rp : T_S3op_extract<"extractu", 0b00>;
5734 def S2_extractu : T_S2op_extract <"extractu", 0b1101, IntRegs, u5Imm>;
5737 //===----------------------------------------------------------------------===//
5738 // :raw for of tableindx[bdhw] insns
5739 //===----------------------------------------------------------------------===//
5741 let hasSideEffects = 0, hasNewValue = 1, opNewValue = 0 in
5742 class tableidxRaw<string OpStr, bits<2>MinOp>
5743 : SInst <(outs IntRegs:$Rx),
5744 (ins IntRegs:$_dst_, IntRegs:$Rs, u4Imm:$u4, s6Imm:$S6),
5745 "$Rx = "#OpStr#"($Rs, #$u4, #$S6):raw",
5746 [], "$Rx = $_dst_" > {
5752 let IClass = 0b1000;
5754 let Inst{27-24} = 0b0111;
5755 let Inst{23-22} = MinOp;
5756 let Inst{21} = u4{3};
5757 let Inst{20-16} = Rs;
5758 let Inst{13-8} = S6;
5759 let Inst{7-5} = u4{2-0};
5763 def S2_tableidxb : tableidxRaw<"tableidxb", 0b00>;
5764 def S2_tableidxh : tableidxRaw<"tableidxh", 0b01>;
5765 def S2_tableidxw : tableidxRaw<"tableidxw", 0b10>;
5766 def S2_tableidxd : tableidxRaw<"tableidxd", 0b11>;
5768 // Change the sign of the immediate for Rd=-mpyi(Rs,#u8)
5769 def : Pat <(mul (i32 IntRegs:$src1), (ineg n8ImmPred:$src2)),
5770 (i32 (M2_mpysin (i32 IntRegs:$src1), u8ImmPred:$src2))>;
5772 //===----------------------------------------------------------------------===//
5773 // V3 Instructions +
5774 //===----------------------------------------------------------------------===//
5776 include "HexagonInstrInfoV3.td"
5778 //===----------------------------------------------------------------------===//
5779 // V3 Instructions -
5780 //===----------------------------------------------------------------------===//
5782 //===----------------------------------------------------------------------===//
5783 // V4 Instructions +
5784 //===----------------------------------------------------------------------===//
5786 include "HexagonInstrInfoV4.td"
5788 //===----------------------------------------------------------------------===//
5789 // V4 Instructions -
5790 //===----------------------------------------------------------------------===//
5792 //===----------------------------------------------------------------------===//
5793 // V5 Instructions +
5794 //===----------------------------------------------------------------------===//
5796 include "HexagonInstrInfoV5.td"
5798 //===----------------------------------------------------------------------===//
5799 // V5 Instructions -
5800 //===----------------------------------------------------------------------===//
5802 //===----------------------------------------------------------------------===//
5803 // ALU32/64/Vector +
5804 //===----------------------------------------------------------------------===///
5806 include "HexagonInstrInfoVector.td"