1 //=- HexagonInstrInfoV4.td - Target Desc. for Hexagon Target -*- 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 V4 instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 def addrga: PatLeaf<(i32 AddrGA:$Addr)>;
15 def addrgp: PatLeaf<(i32 AddrGP:$Addr)>;
17 let hasSideEffects = 0 in
18 class T_Immext<Operand ImmType>
19 : EXTENDERInst<(outs), (ins ImmType:$imm),
20 "immext(#$imm)", []> {
24 let Inst{27-16} = imm{31-20};
25 let Inst{13-0} = imm{19-6};
28 def A4_ext : T_Immext<u26_6Imm>;
29 let isCodeGenOnly = 1 in {
31 def A4_ext_b : T_Immext<brtarget>;
33 def A4_ext_c : T_Immext<calltarget>;
34 def A4_ext_g : T_Immext<globaladdress>;
37 def BITPOS32 : SDNodeXForm<imm, [{
38 // Return the bit position we will set [0-31].
40 int32_t imm = N->getSExtValue();
41 return XformMskToBitPosU5Imm(imm);
44 // Hexagon V4 Architecture spec defines 8 instruction classes:
45 // LD ST ALU32 XTYPE J JR MEMOP NV CR SYSTEM(system is not implemented in the
49 // ========================================
50 // Loads (8/16/32/64 bit)
54 // ========================================
55 // Stores (8/16/32/64 bit)
58 // ALU32 Instructions:
59 // ========================================
60 // Arithmetic / Logical (32 bit)
63 // XTYPE Instructions (32/64 bit):
64 // ========================================
65 // Arithmetic, Logical, Bit Manipulation
66 // Multiply (Integer, Fractional, Complex)
67 // Permute / Vector Permute Operations
68 // Predicate Operations
69 // Shift / Shift with Add/Sub/Logical
71 // Vector Halfword (ALU, Shift, Multiply)
72 // Vector Word (ALU, Shift)
75 // ========================================
76 // Jump/Call PC-relative
79 // ========================================
82 // MEMOP Instructions:
83 // ========================================
84 // Operation on memory (8/16/32 bit)
87 // ========================================
92 // ========================================
93 // Control-Register Transfers
94 // Hardware Loop Setup
95 // Predicate Logicals & Reductions
97 // SYSTEM Instructions (not implemented in the compiler):
98 // ========================================
104 //===----------------------------------------------------------------------===//
106 //===----------------------------------------------------------------------===//
108 class T_ALU32_3op_not<string mnemonic, bits<3> MajOp, bits<3> MinOp,
110 : T_ALU32_3op<mnemonic, MajOp, MinOp, OpsRev, 0> {
111 let AsmString = "$Rd = "#mnemonic#"($Rs, ~$Rt)";
114 let BaseOpcode = "andn_rr", CextOpcode = "andn" in
115 def A4_andn : T_ALU32_3op_not<"and", 0b001, 0b100, 1>;
116 let BaseOpcode = "orn_rr", CextOpcode = "orn" in
117 def A4_orn : T_ALU32_3op_not<"or", 0b001, 0b101, 1>;
119 let CextOpcode = "rcmp.eq" in
120 def A4_rcmpeq : T_ALU32_3op<"cmp.eq", 0b011, 0b010, 0, 1>;
121 let CextOpcode = "!rcmp.eq" in
122 def A4_rcmpneq : T_ALU32_3op<"!cmp.eq", 0b011, 0b011, 0, 1>;
124 def C4_cmpneq : T_ALU32_3op_cmp<"!cmp.eq", 0b00, 1, 1>;
125 def C4_cmplte : T_ALU32_3op_cmp<"!cmp.gt", 0b10, 1, 0>;
126 def C4_cmplteu : T_ALU32_3op_cmp<"!cmp.gtu", 0b11, 1, 0>;
128 // Pats for instruction selection.
130 // A class to embed the usual comparison patfrags within a zext to i32.
131 // The seteq/setne frags use "lhs" and "rhs" as operands, so use the same
132 // names, or else the frag's "body" won't match the operands.
133 class CmpInReg<PatFrag Op>
134 : PatFrag<(ops node:$lhs, node:$rhs),(i32 (zext (i1 Op.Fragment)))>;
136 def: T_cmp32_rr_pat<A4_rcmpeq, CmpInReg<seteq>, i32>;
137 def: T_cmp32_rr_pat<A4_rcmpneq, CmpInReg<setne>, i32>;
139 def: T_cmp32_rr_pat<C4_cmpneq, setne, i1>;
141 class T_CMP_rrbh<string mnemonic, bits<3> MinOp, bit IsComm>
142 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
143 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", S_3op_tc_2early_SLOT23>,
145 let InputType = "reg";
146 let CextOpcode = mnemonic;
148 let isCommutable = IsComm;
149 let hasSideEffects = 0;
156 let Inst{27-21} = 0b0111110;
157 let Inst{20-16} = Rs;
159 let Inst{7-5} = MinOp;
163 def A4_cmpbeq : T_CMP_rrbh<"cmpb.eq", 0b110, 1>;
164 def A4_cmpbgt : T_CMP_rrbh<"cmpb.gt", 0b010, 0>;
165 def A4_cmpbgtu : T_CMP_rrbh<"cmpb.gtu", 0b111, 0>;
166 def A4_cmpheq : T_CMP_rrbh<"cmph.eq", 0b011, 1>;
167 def A4_cmphgt : T_CMP_rrbh<"cmph.gt", 0b100, 0>;
168 def A4_cmphgtu : T_CMP_rrbh<"cmph.gtu", 0b101, 0>;
170 let AddedComplexity = 100 in {
171 def: Pat<(i1 (seteq (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
173 (A4_cmpbeq IntRegs:$Rs, IntRegs:$Rt)>;
174 def: Pat<(i1 (setne (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
176 (C2_not (A4_cmpbeq IntRegs:$Rs, IntRegs:$Rt))>;
177 def: Pat<(i1 (seteq (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
179 (A4_cmpheq IntRegs:$Rs, IntRegs:$Rt)>;
180 def: Pat<(i1 (setne (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
182 (C2_not (A4_cmpheq IntRegs:$Rs, IntRegs:$Rt))>;
185 class T_CMP_ribh<string mnemonic, bits<2> MajOp, bit IsHalf, bit IsComm,
186 Operand ImmType, bit IsImmExt, bit IsImmSigned, int ImmBits>
187 : ALU64Inst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, ImmType:$Imm),
188 "$Pd = "#mnemonic#"($Rs, #$Imm)", [], "", ALU64_tc_2early_SLOT23>,
190 let InputType = "imm";
191 let CextOpcode = mnemonic;
193 let isCommutable = IsComm;
194 let hasSideEffects = 0;
195 let isExtendable = IsImmExt;
196 let opExtendable = !if (IsImmExt, 2, 0);
197 let isExtentSigned = IsImmSigned;
198 let opExtentBits = ImmBits;
205 let Inst{27-24} = 0b1101;
206 let Inst{22-21} = MajOp;
207 let Inst{20-16} = Rs;
208 let Inst{12-5} = Imm;
210 let Inst{3} = IsHalf;
214 def A4_cmpbeqi : T_CMP_ribh<"cmpb.eq", 0b00, 0, 1, u8Imm, 0, 0, 8>;
215 def A4_cmpbgti : T_CMP_ribh<"cmpb.gt", 0b01, 0, 0, s8Imm, 0, 1, 8>;
216 def A4_cmpbgtui : T_CMP_ribh<"cmpb.gtu", 0b10, 0, 0, u7Ext, 1, 0, 7>;
217 def A4_cmpheqi : T_CMP_ribh<"cmph.eq", 0b00, 1, 1, s8Ext, 1, 1, 8>;
218 def A4_cmphgti : T_CMP_ribh<"cmph.gt", 0b01, 1, 0, s8Ext, 1, 1, 8>;
219 def A4_cmphgtui : T_CMP_ribh<"cmph.gtu", 0b10, 1, 0, u7Ext, 1, 0, 7>;
221 class T_RCMP_EQ_ri<string mnemonic, bit IsNeg>
222 : ALU32_ri<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s8Ext:$s8),
223 "$Rd = "#mnemonic#"($Rs, #$s8)", [], "", ALU32_2op_tc_1_SLOT0123>,
225 let InputType = "imm";
226 let CextOpcode = !if (IsNeg, "!rcmp.eq", "rcmp.eq");
227 let isExtendable = 1;
228 let opExtendable = 2;
229 let isExtentSigned = 1;
230 let opExtentBits = 8;
238 let Inst{27-24} = 0b0011;
240 let Inst{21} = IsNeg;
241 let Inst{20-16} = Rs;
247 def A4_rcmpeqi : T_RCMP_EQ_ri<"cmp.eq", 0>;
248 def A4_rcmpneqi : T_RCMP_EQ_ri<"!cmp.eq", 1>;
250 def: Pat<(i32 (zext (i1 (seteq (i32 IntRegs:$Rs), s8ExtPred:$s8)))),
251 (A4_rcmpeqi IntRegs:$Rs, s8ExtPred:$s8)>;
252 def: Pat<(i32 (zext (i1 (setne (i32 IntRegs:$Rs), s8ExtPred:$s8)))),
253 (A4_rcmpneqi IntRegs:$Rs, s8ExtPred:$s8)>;
255 // Preserve the S2_tstbit_r generation
256 def: Pat<(i32 (zext (i1 (setne (i32 (and (i32 (shl 1, (i32 IntRegs:$src2))),
257 (i32 IntRegs:$src1))), 0)))),
258 (C2_muxii (S2_tstbit_r IntRegs:$src1, IntRegs:$src2), 1, 0)>;
260 //===----------------------------------------------------------------------===//
262 //===----------------------------------------------------------------------===//
265 //===----------------------------------------------------------------------===//
267 //===----------------------------------------------------------------------===//
269 // Combine a word and an immediate into a register pair.
270 let hasSideEffects = 0, isExtentSigned = 1, isExtendable = 1,
272 class T_Combine1 <bits<2> MajOp, dag ins, string AsmStr>
273 : ALU32Inst <(outs DoubleRegs:$Rdd), ins, AsmStr> {
279 let Inst{27-24} = 0b0011;
280 let Inst{22-21} = MajOp;
281 let Inst{20-16} = Rs;
287 let opExtendable = 2 in
288 def A4_combineri : T_Combine1<0b00, (ins IntRegs:$Rs, s8Ext:$s8),
289 "$Rdd = combine($Rs, #$s8)">;
291 let opExtendable = 1 in
292 def A4_combineir : T_Combine1<0b01, (ins s8Ext:$s8, IntRegs:$Rs),
293 "$Rdd = combine(#$s8, $Rs)">;
295 def HexagonWrapperCombineRI_V4 :
296 SDNode<"HexagonISD::WrapperCombineRI_V4", SDTHexagonI64I32I32>;
297 def HexagonWrapperCombineIR_V4 :
298 SDNode<"HexagonISD::WrapperCombineIR_V4", SDTHexagonI64I32I32>;
300 def : Pat <(HexagonWrapperCombineRI_V4 IntRegs:$r, s8ExtPred:$i),
301 (A4_combineri IntRegs:$r, s8ExtPred:$i)>;
303 def : Pat <(HexagonWrapperCombineIR_V4 s8ExtPred:$i, IntRegs:$r),
304 (A4_combineir s8ExtPred:$i, IntRegs:$r)>;
306 // A4_combineii: Set two small immediates.
307 let hasSideEffects = 0, isExtendable = 1, opExtentBits = 6, opExtendable = 2 in
308 def A4_combineii: ALU32Inst<(outs DoubleRegs:$Rdd), (ins s8Imm:$s8, u6Ext:$U6),
309 "$Rdd = combine(#$s8, #$U6)"> {
315 let Inst{27-23} = 0b11001;
316 let Inst{20-16} = U6{5-1};
317 let Inst{13} = U6{0};
322 // The complexity of the combine with two immediates should be greater than
323 // the complexity of a combine involving a register.
324 let AddedComplexity = 75 in
325 def: Pat<(HexagonCOMBINE s8ImmPred:$s8, u6ExtPred:$u6),
326 (A4_combineii imm:$s8, imm:$u6)>;
328 //===----------------------------------------------------------------------===//
330 //===----------------------------------------------------------------------===//
332 //===----------------------------------------------------------------------===//
334 //===----------------------------------------------------------------------===//
336 def Zext64: OutPatFrag<(ops node:$Rs),
337 (i64 (A4_combineir 0, (i32 $Rs)))>;
338 def Sext64: OutPatFrag<(ops node:$Rs),
339 (i64 (A2_sxtw (i32 $Rs)))>;
341 // Patterns to generate indexed loads with different forms of the address:
344 // - base (without offset).
345 multiclass Loadxm_pat<PatFrag Load, ValueType VT, PatFrag ValueMod,
346 PatLeaf ImmPred, InstHexagon MI> {
347 def: Pat<(VT (Load AddrFI:$fi)),
348 (VT (ValueMod (MI AddrFI:$fi, 0)))>;
349 def: Pat<(VT (Load (add IntRegs:$Rs, ImmPred:$Off))),
350 (VT (ValueMod (MI IntRegs:$Rs, imm:$Off)))>;
351 def: Pat<(VT (Load (i32 IntRegs:$Rs))),
352 (VT (ValueMod (MI IntRegs:$Rs, 0)))>;
355 defm: Loadxm_pat<extloadi1, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
356 defm: Loadxm_pat<extloadi8, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
357 defm: Loadxm_pat<extloadi16, i64, Zext64, s11_1ExtPred, L2_loadruh_io>;
358 defm: Loadxm_pat<zextloadi1, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
359 defm: Loadxm_pat<zextloadi8, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
360 defm: Loadxm_pat<zextloadi16, i64, Zext64, s11_1ExtPred, L2_loadruh_io>;
361 defm: Loadxm_pat<sextloadi8, i64, Sext64, s11_0ExtPred, L2_loadrb_io>;
362 defm: Loadxm_pat<sextloadi16, i64, Sext64, s11_1ExtPred, L2_loadrh_io>;
364 // Map Rdd = anyext(Rs) -> Rdd = combine(#0, Rs).
365 def: Pat<(i64 (anyext (i32 IntRegs:$src1))), (Zext64 IntRegs:$src1)>;
367 //===----------------------------------------------------------------------===//
368 // Template class for load instructions with Absolute set addressing mode.
369 //===----------------------------------------------------------------------===//
370 let isExtended = 1, opExtendable = 2, opExtentBits = 6, addrMode = AbsoluteSet,
371 hasSideEffects = 0 in
372 class T_LD_abs_set<string mnemonic, RegisterClass RC, bits<4>MajOp>:
373 LDInst<(outs RC:$dst1, IntRegs:$dst2),
375 "$dst1 = "#mnemonic#"($dst2 = #$addr)",
383 let Inst{27-25} = 0b101;
384 let Inst{24-21} = MajOp;
385 let Inst{13-12} = 0b01;
386 let Inst{4-0} = dst1;
387 let Inst{20-16} = dst2;
388 let Inst{11-8} = addr{5-2};
389 let Inst{6-5} = addr{1-0};
392 let accessSize = ByteAccess, hasNewValue = 1 in {
393 def L4_loadrb_ap : T_LD_abs_set <"memb", IntRegs, 0b1000>;
394 def L4_loadrub_ap : T_LD_abs_set <"memub", IntRegs, 0b1001>;
397 let accessSize = HalfWordAccess, hasNewValue = 1 in {
398 def L4_loadrh_ap : T_LD_abs_set <"memh", IntRegs, 0b1010>;
399 def L4_loadruh_ap : T_LD_abs_set <"memuh", IntRegs, 0b1011>;
402 let accessSize = WordAccess, hasNewValue = 1 in
403 def L4_loadri_ap : T_LD_abs_set <"memw", IntRegs, 0b1100>;
405 let accessSize = DoubleWordAccess in
406 def L4_loadrd_ap : T_LD_abs_set <"memd", DoubleRegs, 0b1110>;
407 // Load - Indirect with long offset
408 let InputType = "imm", addrMode = BaseLongOffset, isExtended = 1,
409 opExtentBits = 6, opExtendable = 3 in
410 class T_LoadAbsReg <string mnemonic, string CextOp, RegisterClass RC,
412 : LDInst <(outs RC:$dst), (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3),
413 "$dst = "#mnemonic#"($src1<<#$src2 + #$src3)",
419 let CextOpcode = CextOp;
420 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
423 let Inst{27-25} = 0b110;
424 let Inst{24-21} = MajOp;
425 let Inst{20-16} = src1;
426 let Inst{13} = src2{1};
428 let Inst{11-8} = src3{5-2};
429 let Inst{7} = src2{0};
430 let Inst{6-5} = src3{1-0};
434 let accessSize = ByteAccess in {
435 def L4_loadrb_ur : T_LoadAbsReg<"memb", "LDrib", IntRegs, 0b1000>;
436 def L4_loadrub_ur : T_LoadAbsReg<"memub", "LDriub", IntRegs, 0b1001>;
437 def L4_loadalignb_ur : T_LoadAbsReg<"memb_fifo", "LDrib_fifo",
441 let accessSize = HalfWordAccess in {
442 def L4_loadrh_ur : T_LoadAbsReg<"memh", "LDrih", IntRegs, 0b1010>;
443 def L4_loadruh_ur : T_LoadAbsReg<"memuh", "LDriuh", IntRegs, 0b1011>;
444 def L4_loadbsw2_ur : T_LoadAbsReg<"membh", "LDribh2", IntRegs, 0b0001>;
445 def L4_loadbzw2_ur : T_LoadAbsReg<"memubh", "LDriubh2", IntRegs, 0b0011>;
446 def L4_loadalignh_ur : T_LoadAbsReg<"memh_fifo", "LDrih_fifo",
450 let accessSize = WordAccess in {
451 def L4_loadri_ur : T_LoadAbsReg<"memw", "LDriw", IntRegs, 0b1100>;
452 def L4_loadbsw4_ur : T_LoadAbsReg<"membh", "LDribh4", DoubleRegs, 0b0111>;
453 def L4_loadbzw4_ur : T_LoadAbsReg<"memubh", "LDriubh4", DoubleRegs, 0b0101>;
456 let accessSize = DoubleWordAccess in
457 def L4_loadrd_ur : T_LoadAbsReg<"memd", "LDrid", DoubleRegs, 0b1110>;
460 multiclass T_LoadAbsReg_Pat <PatFrag ldOp, InstHexagon MI, ValueType VT = i32> {
461 def : Pat <(VT (ldOp (add (shl IntRegs:$src1, u2ImmPred:$src2),
462 (HexagonCONST32 tglobaladdr:$src3)))),
463 (MI IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3)>;
465 def : Pat <(VT (ldOp (add IntRegs:$src1,
466 (HexagonCONST32 tglobaladdr:$src2)))),
467 (MI IntRegs:$src1, 0, tglobaladdr:$src2)>;
470 let AddedComplexity = 60 in {
471 defm : T_LoadAbsReg_Pat <sextloadi8, L4_loadrb_ur>;
472 defm : T_LoadAbsReg_Pat <zextloadi8, L4_loadrub_ur>;
473 defm : T_LoadAbsReg_Pat <extloadi8, L4_loadrub_ur>;
475 defm : T_LoadAbsReg_Pat <sextloadi16, L4_loadrh_ur>;
476 defm : T_LoadAbsReg_Pat <zextloadi16, L4_loadruh_ur>;
477 defm : T_LoadAbsReg_Pat <extloadi16, L4_loadruh_ur>;
479 defm : T_LoadAbsReg_Pat <load, L4_loadri_ur>;
480 defm : T_LoadAbsReg_Pat <load, L4_loadrd_ur, i64>;
483 //===----------------------------------------------------------------------===//
484 // Template classes for the non-predicated load instructions with
485 // base + register offset addressing mode
486 //===----------------------------------------------------------------------===//
487 class T_load_rr <string mnemonic, RegisterClass RC, bits<3> MajOp>:
488 LDInst<(outs RC:$dst), (ins IntRegs:$src1, IntRegs:$src2, u2Imm:$u2),
489 "$dst = "#mnemonic#"($src1 + $src2<<#$u2)",
490 [], "", V4LDST_tc_ld_SLOT01>, ImmRegShl, AddrModeRel {
498 let Inst{27-24} = 0b1010;
499 let Inst{23-21} = MajOp;
500 let Inst{20-16} = src1;
501 let Inst{12-8} = src2;
502 let Inst{13} = u2{1};
507 //===----------------------------------------------------------------------===//
508 // Template classes for the predicated load instructions with
509 // base + register offset addressing mode
510 //===----------------------------------------------------------------------===//
511 let isPredicated = 1 in
512 class T_pload_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
513 bit isNot, bit isPredNew>:
514 LDInst <(outs RC:$dst),
515 (ins PredRegs:$src1, IntRegs:$src2, IntRegs:$src3, u2Imm:$u2),
516 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
517 ") ")#"$dst = "#mnemonic#"($src2+$src3<<#$u2)",
518 [], "", V4LDST_tc_ld_SLOT01>, AddrModeRel {
525 let isPredicatedFalse = isNot;
526 let isPredicatedNew = isPredNew;
530 let Inst{27-26} = 0b00;
531 let Inst{25} = isPredNew;
532 let Inst{24} = isNot;
533 let Inst{23-21} = MajOp;
534 let Inst{20-16} = src2;
535 let Inst{12-8} = src3;
536 let Inst{13} = u2{1};
538 let Inst{6-5} = src1;
542 //===----------------------------------------------------------------------===//
543 // multiclass for load instructions with base + register offset
545 //===----------------------------------------------------------------------===//
546 let hasSideEffects = 0, addrMode = BaseRegOffset in
547 multiclass ld_idxd_shl <string mnemonic, string CextOp, RegisterClass RC,
549 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl,
550 InputType = "reg" in {
551 let isPredicable = 1 in
552 def L4_#NAME#_rr : T_load_rr <mnemonic, RC, MajOp>;
555 def L4_p#NAME#t_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 0>;
556 def L4_p#NAME#f_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 0>;
559 def L4_p#NAME#tnew_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 1>;
560 def L4_p#NAME#fnew_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 1>;
564 let hasNewValue = 1, accessSize = ByteAccess in {
565 defm loadrb : ld_idxd_shl<"memb", "LDrib", IntRegs, 0b000>;
566 defm loadrub : ld_idxd_shl<"memub", "LDriub", IntRegs, 0b001>;
569 let hasNewValue = 1, accessSize = HalfWordAccess in {
570 defm loadrh : ld_idxd_shl<"memh", "LDrih", IntRegs, 0b010>;
571 defm loadruh : ld_idxd_shl<"memuh", "LDriuh", IntRegs, 0b011>;
574 let hasNewValue = 1, accessSize = WordAccess in
575 defm loadri : ld_idxd_shl<"memw", "LDriw", IntRegs, 0b100>;
577 let accessSize = DoubleWordAccess in
578 defm loadrd : ld_idxd_shl<"memd", "LDrid", DoubleRegs, 0b110>;
580 // 'def pats' for load instructions with base + register offset and non-zero
581 // immediate value. Immediate value is used to left-shift the second
583 class Loadxs_pat<PatFrag Load, ValueType VT, InstHexagon MI>
584 : Pat<(VT (Load (add (i32 IntRegs:$Rs),
585 (i32 (shl (i32 IntRegs:$Rt), u2ImmPred:$u2))))),
586 (VT (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2))>;
588 let AddedComplexity = 40 in {
589 def: Loadxs_pat<extloadi8, i32, L4_loadrub_rr>;
590 def: Loadxs_pat<zextloadi8, i32, L4_loadrub_rr>;
591 def: Loadxs_pat<sextloadi8, i32, L4_loadrb_rr>;
592 def: Loadxs_pat<extloadi16, i32, L4_loadruh_rr>;
593 def: Loadxs_pat<zextloadi16, i32, L4_loadruh_rr>;
594 def: Loadxs_pat<sextloadi16, i32, L4_loadrh_rr>;
595 def: Loadxs_pat<load, i32, L4_loadri_rr>;
596 def: Loadxs_pat<load, i64, L4_loadrd_rr>;
599 // 'def pats' for load instruction base + register offset and
600 // zero immediate value.
601 class Loadxs_simple_pat<PatFrag Load, ValueType VT, InstHexagon MI>
602 : Pat<(VT (Load (add (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)))),
603 (VT (MI IntRegs:$Rs, IntRegs:$Rt, 0))>;
605 let AddedComplexity = 20 in {
606 def: Loadxs_simple_pat<extloadi8, i32, L4_loadrub_rr>;
607 def: Loadxs_simple_pat<zextloadi8, i32, L4_loadrub_rr>;
608 def: Loadxs_simple_pat<sextloadi8, i32, L4_loadrb_rr>;
609 def: Loadxs_simple_pat<extloadi16, i32, L4_loadruh_rr>;
610 def: Loadxs_simple_pat<zextloadi16, i32, L4_loadruh_rr>;
611 def: Loadxs_simple_pat<sextloadi16, i32, L4_loadrh_rr>;
612 def: Loadxs_simple_pat<load, i32, L4_loadri_rr>;
613 def: Loadxs_simple_pat<load, i64, L4_loadrd_rr>;
617 def: Pat<(i64 (zext (i1 PredRegs:$src1))),
618 (Zext64 (C2_muxii PredRegs:$src1, 1, 0))>;
621 def: Pat<(i64 (zext (i32 IntRegs:$src1))),
622 (Zext64 IntRegs:$src1)>;
625 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)),
626 (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>;
628 let AddedComplexity = 100 in
629 def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
630 (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1,
631 s11_2ExtPred:$offset)))>;
634 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)),
635 (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>;
637 //===----------------------------------------------------------------------===//
639 //===----------------------------------------------------------------------===//
641 //===----------------------------------------------------------------------===//
643 //===----------------------------------------------------------------------===//
645 //===----------------------------------------------------------------------===//
646 // Template class for store instructions with Absolute set addressing mode.
647 //===----------------------------------------------------------------------===//
648 let isExtended = 1, opExtendable = 1, opExtentBits = 6,
649 addrMode = AbsoluteSet, isNVStorable = 1 in
650 class T_ST_absset <string mnemonic, string BaseOp, RegisterClass RC,
651 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
652 : STInst<(outs IntRegs:$dst),
653 (ins u6Ext:$addr, RC:$src),
654 mnemonic#"($dst = #$addr) = $src"#!if(isHalf, ".h","")>, NewValueRel {
658 let accessSize = AccessSz;
659 let BaseOpcode = BaseOp#"_AbsSet";
663 let Inst{27-24} = 0b1011;
664 let Inst{23-21} = MajOp;
665 let Inst{20-16} = dst;
667 let Inst{12-8} = src;
669 let Inst{5-0} = addr;
672 def S4_storerb_ap : T_ST_absset <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
673 def S4_storerh_ap : T_ST_absset <"memh", "STrih", IntRegs, 0b010,
675 def S4_storeri_ap : T_ST_absset <"memw", "STriw", IntRegs, 0b100, WordAccess>;
677 let isNVStorable = 0 in {
678 def S4_storerf_ap : T_ST_absset <"memh", "STrif", IntRegs,
679 0b011, HalfWordAccess, 1>;
680 def S4_storerd_ap : T_ST_absset <"memd", "STrid", DoubleRegs,
681 0b110, DoubleWordAccess>;
684 let opExtendable = 1, isNewValue = 1, isNVStore = 1, opNewValue = 2,
685 isExtended = 1, opExtentBits= 6 in
686 class T_ST_absset_nv <string mnemonic, string BaseOp, bits<2> MajOp,
687 MemAccessSize AccessSz >
688 : NVInst <(outs IntRegs:$dst),
689 (ins u6Ext:$addr, IntRegs:$src),
690 mnemonic#"($dst = #$addr) = $src.new">, NewValueRel {
694 let accessSize = AccessSz;
695 let BaseOpcode = BaseOp#"_AbsSet";
699 let Inst{27-21} = 0b1011101;
700 let Inst{20-16} = dst;
701 let Inst{13-11} = 0b000;
702 let Inst{12-11} = MajOp;
703 let Inst{10-8} = src;
705 let Inst{5-0} = addr;
708 let mayStore = 1, addrMode = AbsoluteSet in {
709 def S4_storerbnew_ap : T_ST_absset_nv <"memb", "STrib", 0b00, ByteAccess>;
710 def S4_storerhnew_ap : T_ST_absset_nv <"memh", "STrih", 0b01, HalfWordAccess>;
711 def S4_storerinew_ap : T_ST_absset_nv <"memw", "STriw", 0b10, WordAccess>;
714 let isExtended = 1, opExtendable = 2, opExtentBits = 6, InputType = "imm",
715 addrMode = BaseLongOffset, AddedComplexity = 40 in
716 class T_StoreAbsReg <string mnemonic, string CextOp, RegisterClass RC,
717 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
719 (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3, RC:$src4),
720 mnemonic#"($src1<<#$src2 + #$src3) = $src4"#!if(isHalf, ".h",""),
721 []>, ImmRegShl, NewValueRel {
728 let accessSize = AccessSz;
729 let CextOpcode = CextOp;
730 let BaseOpcode = CextOp#"_shl";
733 let Inst{27-24} =0b1101;
734 let Inst{23-21} = MajOp;
735 let Inst{20-16} = src1;
736 let Inst{13} = src2{1};
737 let Inst{12-8} = src4;
739 let Inst{6} = src2{0};
740 let Inst{5-0} = src3;
743 def S4_storerb_ur : T_StoreAbsReg <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
744 def S4_storerh_ur : T_StoreAbsReg <"memh", "STrih", IntRegs, 0b010,
746 def S4_storerf_ur : T_StoreAbsReg <"memh", "STrif", IntRegs, 0b011,
748 def S4_storeri_ur : T_StoreAbsReg <"memw", "STriw", IntRegs, 0b100, WordAccess>;
749 def S4_storerd_ur : T_StoreAbsReg <"memd", "STrid", DoubleRegs, 0b110,
752 let AddedComplexity = 40 in
753 multiclass T_StoreAbsReg_Pats <InstHexagon MI, RegisterClass RC, ValueType VT,
755 def : Pat<(stOp (VT RC:$src4),
756 (add (shl (i32 IntRegs:$src1), u2ImmPred:$src2),
757 u0AlwaysExtPred:$src3)),
758 (MI IntRegs:$src1, u2ImmPred:$src2, u0AlwaysExtPred:$src3, RC:$src4)>;
760 def : Pat<(stOp (VT RC:$src4),
761 (add (shl IntRegs:$src1, u2ImmPred:$src2),
762 (HexagonCONST32 tglobaladdr:$src3))),
763 (MI IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3, RC:$src4)>;
765 def : Pat<(stOp (VT RC:$src4),
766 (add IntRegs:$src1, (HexagonCONST32 tglobaladdr:$src3))),
767 (MI IntRegs:$src1, 0, tglobaladdr:$src3, RC:$src4)>;
770 defm : T_StoreAbsReg_Pats <S4_storerd_ur, DoubleRegs, i64, store>;
771 defm : T_StoreAbsReg_Pats <S4_storeri_ur, IntRegs, i32, store>;
772 defm : T_StoreAbsReg_Pats <S4_storerb_ur, IntRegs, i32, truncstorei8>;
773 defm : T_StoreAbsReg_Pats <S4_storerh_ur, IntRegs, i32, truncstorei16>;
775 let mayStore = 1, isNVStore = 1, isExtended = 1, addrMode = BaseLongOffset,
776 opExtentBits = 6, isNewValue = 1, opNewValue = 3, opExtendable = 2 in
777 class T_StoreAbsRegNV <string mnemonic, string CextOp, bits<2> MajOp,
778 MemAccessSize AccessSz>
780 (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3, IntRegs:$src4),
781 mnemonic#"($src1<<#$src2 + #$src3) = $src4.new">, NewValueRel {
787 let CextOpcode = CextOp;
788 let BaseOpcode = CextOp#"_shl";
791 let Inst{27-21} = 0b1101101;
792 let Inst{12-11} = 0b00;
794 let Inst{20-16} = src1;
795 let Inst{13} = src2{1};
796 let Inst{12-11} = MajOp;
797 let Inst{10-8} = src4;
798 let Inst{6} = src2{0};
799 let Inst{5-0} = src3;
802 def S4_storerbnew_ur : T_StoreAbsRegNV <"memb", "STrib", 0b00, ByteAccess>;
803 def S4_storerhnew_ur : T_StoreAbsRegNV <"memh", "STrih", 0b01, HalfWordAccess>;
804 def S4_storerinew_ur : T_StoreAbsRegNV <"memw", "STriw", 0b10, WordAccess>;
806 //===----------------------------------------------------------------------===//
807 // Template classes for the non-predicated store instructions with
808 // base + register offset addressing mode
809 //===----------------------------------------------------------------------===//
810 let isPredicable = 1 in
811 class T_store_rr <string mnemonic, RegisterClass RC, bits<3> MajOp, bit isH>
812 : STInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
813 mnemonic#"($Rs + $Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
814 [],"",V4LDST_tc_st_SLOT01>, ImmRegShl, AddrModeRel {
823 let Inst{27-24} = 0b1011;
824 let Inst{23-21} = MajOp;
825 let Inst{20-16} = Rs;
827 let Inst{13} = u2{1};
832 //===----------------------------------------------------------------------===//
833 // Template classes for the predicated store instructions with
834 // base + register offset addressing mode
835 //===----------------------------------------------------------------------===//
836 let isPredicated = 1 in
837 class T_pstore_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
838 bit isNot, bit isPredNew, bit isH>
840 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
842 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
843 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
844 [], "", V4LDST_tc_st_SLOT01> , AddrModeRel{
851 let isPredicatedFalse = isNot;
852 let isPredicatedNew = isPredNew;
856 let Inst{27-26} = 0b01;
857 let Inst{25} = isPredNew;
858 let Inst{24} = isNot;
859 let Inst{23-21} = MajOp;
860 let Inst{20-16} = Rs;
862 let Inst{13} = u2{1};
868 //===----------------------------------------------------------------------===//
869 // Template classes for the new-value store instructions with
870 // base + register offset addressing mode
871 //===----------------------------------------------------------------------===//
872 let isPredicable = 1, isNewValue = 1, opNewValue = 3 in
873 class T_store_new_rr <string mnemonic, bits<2> MajOp> :
874 NVInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
875 mnemonic#"($Rs + $Ru<<#$u2) = $Nt.new",
876 [],"",V4LDST_tc_st_SLOT0>, ImmRegShl, AddrModeRel {
885 let Inst{27-21} = 0b1011101;
886 let Inst{20-16} = Rs;
888 let Inst{13} = u2{1};
890 let Inst{4-3} = MajOp;
894 //===----------------------------------------------------------------------===//
895 // Template classes for the predicated new-value store instructions with
896 // base + register offset addressing mode
897 //===----------------------------------------------------------------------===//
898 let isPredicated = 1, isNewValue = 1, opNewValue = 4 in
899 class T_pstore_new_rr <string mnemonic, bits<2> MajOp, bit isNot, bit isPredNew>
901 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
902 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
903 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Nt.new",
904 [], "", V4LDST_tc_st_SLOT0>, AddrModeRel {
911 let isPredicatedFalse = isNot;
912 let isPredicatedNew = isPredNew;
915 let Inst{27-26} = 0b01;
916 let Inst{25} = isPredNew;
917 let Inst{24} = isNot;
918 let Inst{23-21} = 0b101;
919 let Inst{20-16} = Rs;
921 let Inst{13} = u2{1};
924 let Inst{4-3} = MajOp;
928 //===----------------------------------------------------------------------===//
929 // multiclass for store instructions with base + register offset addressing
931 //===----------------------------------------------------------------------===//
932 let isNVStorable = 1 in
933 multiclass ST_Idxd_shl<string mnemonic, string CextOp, RegisterClass RC,
934 bits<3> MajOp, bit isH = 0> {
935 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
936 def S4_#NAME#_rr : T_store_rr <mnemonic, RC, MajOp, isH>;
939 def S4_p#NAME#t_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 0, isH>;
940 def S4_p#NAME#f_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 0, isH>;
943 def S4_p#NAME#tnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 1, isH>;
944 def S4_p#NAME#fnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 1, isH>;
948 //===----------------------------------------------------------------------===//
949 // multiclass for new-value store instructions with base + register offset
951 //===----------------------------------------------------------------------===//
952 let mayStore = 1, isNVStore = 1 in
953 multiclass ST_Idxd_shl_nv <string mnemonic, string CextOp, RegisterClass RC,
955 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
956 def S4_#NAME#new_rr : T_store_new_rr<mnemonic, MajOp>;
959 def S4_p#NAME#newt_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 0>;
960 def S4_p#NAME#newf_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 0>;
963 def S4_p#NAME#newtnew_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 1>;
964 def S4_p#NAME#newfnew_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 1>;
968 let addrMode = BaseRegOffset, InputType = "reg", hasSideEffects = 0 in {
969 let accessSize = ByteAccess in
970 defm storerb: ST_Idxd_shl<"memb", "STrib", IntRegs, 0b000>,
971 ST_Idxd_shl_nv<"memb", "STrib", IntRegs, 0b00>;
973 let accessSize = HalfWordAccess in
974 defm storerh: ST_Idxd_shl<"memh", "STrih", IntRegs, 0b010>,
975 ST_Idxd_shl_nv<"memh", "STrih", IntRegs, 0b01>;
977 let accessSize = WordAccess in
978 defm storeri: ST_Idxd_shl<"memw", "STriw", IntRegs, 0b100>,
979 ST_Idxd_shl_nv<"memw", "STriw", IntRegs, 0b10>;
981 let isNVStorable = 0, accessSize = DoubleWordAccess in
982 defm storerd: ST_Idxd_shl<"memd", "STrid", DoubleRegs, 0b110>;
984 let isNVStorable = 0, accessSize = HalfWordAccess in
985 defm storerf: ST_Idxd_shl<"memh", "STrif", IntRegs, 0b011, 1>;
988 class Storexs_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
989 : Pat<(Store Value:$Ru, (add (i32 IntRegs:$Rs),
990 (i32 (shl (i32 IntRegs:$Rt), u2ImmPred:$u2)))),
991 (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2, Value:$Ru)>;
993 let AddedComplexity = 40 in {
994 def: Storexs_pat<truncstorei8, I32, S4_storerb_rr>;
995 def: Storexs_pat<truncstorei16, I32, S4_storerh_rr>;
996 def: Storexs_pat<store, I32, S4_storeri_rr>;
997 def: Storexs_pat<store, I64, S4_storerd_rr>;
1000 // memd(Rx++#s4:3)=Rtt
1001 // memd(Rx++#s4:3:circ(Mu))=Rtt
1002 // memd(Rx++I:circ(Mu))=Rtt
1004 // memd(Rx++Mu:brev)=Rtt
1005 // memd(gp+#u16:3)=Rtt
1007 // Store doubleword conditionally.
1008 // if ([!]Pv[.new]) memd(#u6)=Rtt
1009 // TODO: needs to be implemented.
1011 //===----------------------------------------------------------------------===//
1013 //===----------------------------------------------------------------------===//
1014 let isPredicable = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 8,
1016 class T_StoreImm <string mnemonic, Operand OffsetOp, bits<2> MajOp >
1017 : STInst <(outs ), (ins IntRegs:$Rs, OffsetOp:$offset, s8Ext:$S8),
1018 mnemonic#"($Rs+#$offset)=#$S8",
1019 [], "", V4LDST_tc_st_SLOT01>,
1020 ImmRegRel, PredNewRel {
1026 string OffsetOpStr = !cast<string>(OffsetOp);
1027 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
1028 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
1029 /* u6_0Imm */ offset{5-0}));
1031 let IClass = 0b0011;
1033 let Inst{27-25} = 0b110;
1034 let Inst{22-21} = MajOp;
1035 let Inst{20-16} = Rs;
1036 let Inst{12-7} = offsetBits;
1037 let Inst{13} = S8{7};
1038 let Inst{6-0} = S8{6-0};
1041 let isPredicated = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 6,
1043 class T_StoreImm_pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
1044 bit isPredNot, bit isPredNew >
1046 (ins PredRegs:$Pv, IntRegs:$Rs, OffsetOp:$offset, s6Ext:$S6),
1047 !if(isPredNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
1048 ") ")#mnemonic#"($Rs+#$offset)=#$S6",
1049 [], "", V4LDST_tc_st_SLOT01>,
1050 ImmRegRel, PredNewRel {
1057 string OffsetOpStr = !cast<string>(OffsetOp);
1058 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
1059 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
1060 /* u6_0Imm */ offset{5-0}));
1061 let isPredicatedNew = isPredNew;
1062 let isPredicatedFalse = isPredNot;
1064 let IClass = 0b0011;
1066 let Inst{27-25} = 0b100;
1067 let Inst{24} = isPredNew;
1068 let Inst{23} = isPredNot;
1069 let Inst{22-21} = MajOp;
1070 let Inst{20-16} = Rs;
1071 let Inst{13} = S6{5};
1072 let Inst{12-7} = offsetBits;
1074 let Inst{4-0} = S6{4-0};
1078 //===----------------------------------------------------------------------===//
1079 // multiclass for store instructions with base + immediate offset
1080 // addressing mode and immediate stored value.
1081 // mem[bhw](Rx++#s4:3)=#s8
1082 // if ([!]Pv[.new]) mem[bhw](Rx++#s4:3)=#s6
1083 //===----------------------------------------------------------------------===//
1085 multiclass ST_Imm_Pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
1087 def _io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 0>;
1089 def new_io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 1>;
1092 multiclass ST_Imm <string mnemonic, string CextOp, Operand OffsetOp,
1094 let CextOpcode = CextOp, BaseOpcode = CextOp#_imm in {
1095 def _io : T_StoreImm <mnemonic, OffsetOp, MajOp>;
1097 defm t : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 0>;
1098 defm f : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 1>;
1102 let hasSideEffects = 0, addrMode = BaseImmOffset,
1103 InputType = "imm" in {
1104 let accessSize = ByteAccess in
1105 defm S4_storeirb : ST_Imm<"memb", "STrib", u6_0Imm, 0b00>;
1107 let accessSize = HalfWordAccess in
1108 defm S4_storeirh : ST_Imm<"memh", "STrih", u6_1Imm, 0b01>;
1110 let accessSize = WordAccess in
1111 defm S4_storeiri : ST_Imm<"memw", "STriw", u6_2Imm, 0b10>;
1114 def IMM_BYTE : SDNodeXForm<imm, [{
1115 // -1 etc is represented as 255 etc
1116 // assigning to a byte restores our desired signed value.
1117 int8_t imm = N->getSExtValue();
1118 return CurDAG->getTargetConstant(imm, MVT::i32);
1121 def IMM_HALF : SDNodeXForm<imm, [{
1122 // -1 etc is represented as 65535 etc
1123 // assigning to a short restores our desired signed value.
1124 int16_t imm = N->getSExtValue();
1125 return CurDAG->getTargetConstant(imm, MVT::i32);
1128 def IMM_WORD : SDNodeXForm<imm, [{
1129 // -1 etc can be represented as 4294967295 etc
1130 // Currently, it's not doing this. But some optimization
1131 // might convert -1 to a large +ve number.
1132 // assigning to a word restores our desired signed value.
1133 int32_t imm = N->getSExtValue();
1134 return CurDAG->getTargetConstant(imm, MVT::i32);
1137 def ToImmByte : OutPatFrag<(ops node:$R), (IMM_BYTE $R)>;
1138 def ToImmHalf : OutPatFrag<(ops node:$R), (IMM_HALF $R)>;
1139 def ToImmWord : OutPatFrag<(ops node:$R), (IMM_WORD $R)>;
1141 let AddedComplexity = 40 in {
1142 // Not using frameindex patterns for these stores, because the offset
1143 // is not extendable. This could cause problems during removing the frame
1144 // indices, since the offset with respect to R29/R30 may not fit in the
1146 def: Storexm_add_pat<truncstorei8, s8ExtPred, u6_0ImmPred, ToImmByte,
1148 def: Storexm_add_pat<truncstorei16, s8ExtPred, u6_1ImmPred, ToImmHalf,
1150 def: Storexm_add_pat<store, s8ExtPred, u6_2ImmPred, ToImmWord,
1154 def: Storexm_simple_pat<truncstorei8, s8ExtPred, ToImmByte, S4_storeirb_io>;
1155 def: Storexm_simple_pat<truncstorei16, s8ExtPred, ToImmHalf, S4_storeirh_io>;
1156 def: Storexm_simple_pat<store, s8ExtPred, ToImmWord, S4_storeiri_io>;
1158 // memb(Rx++#s4:0:circ(Mu))=Rt
1159 // memb(Rx++I:circ(Mu))=Rt
1161 // memb(Rx++Mu:brev)=Rt
1162 // memb(gp+#u16:0)=Rt
1165 // TODO: needs to be implemented
1166 // memh(Re=#U6)=Rt.H
1167 // memh(Rs+#s11:1)=Rt.H
1168 // memh(Rs+Ru<<#u2)=Rt.H
1169 // TODO: needs to be implemented.
1171 // memh(Ru<<#u2+#U6)=Rt.H
1172 // memh(Rx++#s4:1:circ(Mu))=Rt.H
1173 // memh(Rx++#s4:1:circ(Mu))=Rt
1174 // memh(Rx++I:circ(Mu))=Rt.H
1175 // memh(Rx++I:circ(Mu))=Rt
1176 // memh(Rx++Mu)=Rt.H
1178 // memh(Rx++Mu:brev)=Rt.H
1179 // memh(Rx++Mu:brev)=Rt
1180 // memh(gp+#u16:1)=Rt
1181 // if ([!]Pv[.new]) memh(#u6)=Rt.H
1182 // if ([!]Pv[.new]) memh(#u6)=Rt
1184 // if ([!]Pv[.new]) memh(Rs+#u6:1)=Rt.H
1185 // TODO: needs to be implemented.
1187 // if ([!]Pv[.new]) memh(Rx++#s4:1)=Rt.H
1188 // TODO: Needs to be implemented.
1192 // TODO: Needs to be implemented.
1193 // memw(Rx++#s4:2)=Rt
1194 // memw(Rx++#s4:2:circ(Mu))=Rt
1195 // memw(Rx++I:circ(Mu))=Rt
1197 // memw(Rx++Mu:brev)=Rt
1199 //===----------------------------------------------------------------------===
1201 //===----------------------------------------------------------------------===
1204 //===----------------------------------------------------------------------===//
1206 //===----------------------------------------------------------------------===//
1208 let opNewValue = 2, opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
1209 class T_store_io_nv <string mnemonic, RegisterClass RC,
1210 Operand ImmOp, bits<2>MajOp>
1211 : NVInst_V4 <(outs),
1212 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
1213 mnemonic#"($src1+#$src2) = $src3.new",
1214 [],"",ST_tc_st_SLOT0> {
1216 bits<13> src2; // Actual address offset
1218 bits<11> offsetBits; // Represents offset encoding
1220 let opExtentBits = !if (!eq(mnemonic, "memb"), 11,
1221 !if (!eq(mnemonic, "memh"), 12,
1222 !if (!eq(mnemonic, "memw"), 13, 0)));
1224 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1225 !if (!eq(mnemonic, "memh"), 1,
1226 !if (!eq(mnemonic, "memw"), 2, 0)));
1228 let offsetBits = !if (!eq(mnemonic, "memb"), src2{10-0},
1229 !if (!eq(mnemonic, "memh"), src2{11-1},
1230 !if (!eq(mnemonic, "memw"), src2{12-2}, 0)));
1232 let IClass = 0b1010;
1235 let Inst{26-25} = offsetBits{10-9};
1236 let Inst{24-21} = 0b1101;
1237 let Inst{20-16} = src1;
1238 let Inst{13} = offsetBits{8};
1239 let Inst{12-11} = MajOp;
1240 let Inst{10-8} = src3;
1241 let Inst{7-0} = offsetBits{7-0};
1244 let opExtendable = 2, opNewValue = 3, isPredicated = 1 in
1245 class T_pstore_io_nv <string mnemonic, RegisterClass RC, Operand predImmOp,
1246 bits<2>MajOp, bit PredNot, bit isPredNew>
1247 : NVInst_V4 <(outs),
1248 (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC:$src4),
1249 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1250 ") ")#mnemonic#"($src2+#$src3) = $src4.new",
1251 [],"",V2LDST_tc_st_SLOT0> {
1256 bits<6> offsetBits; // Represents offset encoding
1258 let isPredicatedNew = isPredNew;
1259 let isPredicatedFalse = PredNot;
1260 let opExtentBits = !if (!eq(mnemonic, "memb"), 6,
1261 !if (!eq(mnemonic, "memh"), 7,
1262 !if (!eq(mnemonic, "memw"), 8, 0)));
1264 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1265 !if (!eq(mnemonic, "memh"), 1,
1266 !if (!eq(mnemonic, "memw"), 2, 0)));
1268 let offsetBits = !if (!eq(mnemonic, "memb"), src3{5-0},
1269 !if (!eq(mnemonic, "memh"), src3{6-1},
1270 !if (!eq(mnemonic, "memw"), src3{7-2}, 0)));
1272 let IClass = 0b0100;
1275 let Inst{26} = PredNot;
1276 let Inst{25} = isPredNew;
1277 let Inst{24-21} = 0b0101;
1278 let Inst{20-16} = src2;
1279 let Inst{13} = offsetBits{5};
1280 let Inst{12-11} = MajOp;
1281 let Inst{10-8} = src4;
1282 let Inst{7-3} = offsetBits{4-0};
1284 let Inst{1-0} = src1;
1287 // multiclass for new-value store instructions with base + immediate offset.
1289 let mayStore = 1, isNVStore = 1, isNewValue = 1, hasSideEffects = 0,
1291 multiclass ST_Idxd_nv<string mnemonic, string CextOp, RegisterClass RC,
1292 Operand ImmOp, Operand predImmOp, bits<2> MajOp> {
1294 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1295 def S2_#NAME#new_io : T_store_io_nv <mnemonic, RC, ImmOp, MajOp>;
1297 def S2_p#NAME#newt_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 0, 0>;
1298 def S2_p#NAME#newf_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 1, 0>;
1300 def S4_p#NAME#newtnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1302 def S4_p#NAME#newfnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1307 let addrMode = BaseImmOffset, InputType = "imm" in {
1308 let accessSize = ByteAccess in
1309 defm storerb: ST_Idxd_nv<"memb", "STrib", IntRegs, s11_0Ext,
1310 u6_0Ext, 0b00>, AddrModeRel;
1312 let accessSize = HalfWordAccess, opExtentAlign = 1 in
1313 defm storerh: ST_Idxd_nv<"memh", "STrih", IntRegs, s11_1Ext,
1314 u6_1Ext, 0b01>, AddrModeRel;
1316 let accessSize = WordAccess, opExtentAlign = 2 in
1317 defm storeri: ST_Idxd_nv<"memw", "STriw", IntRegs, s11_2Ext,
1318 u6_2Ext, 0b10>, AddrModeRel;
1321 //===----------------------------------------------------------------------===//
1322 // Post increment loads with register offset.
1323 //===----------------------------------------------------------------------===//
1325 let hasNewValue = 1 in
1326 def L2_loadbsw2_pr : T_load_pr <"membh", IntRegs, 0b0001, HalfWordAccess>;
1328 def L2_loadbsw4_pr : T_load_pr <"membh", DoubleRegs, 0b0111, WordAccess>;
1330 //===----------------------------------------------------------------------===//
1331 // Template class for non-predicated post increment .new stores
1332 // mem[bhwd](Rx++#s4:[0123])=Nt.new
1333 //===----------------------------------------------------------------------===//
1334 let isPredicable = 1, hasSideEffects = 0, addrMode = PostInc, isNVStore = 1,
1335 isNewValue = 1, opNewValue = 3 in
1336 class T_StorePI_nv <string mnemonic, Operand ImmOp, bits<2> MajOp >
1337 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1338 (ins IntRegs:$src1, ImmOp:$offset, IntRegs:$src2),
1339 mnemonic#"($src1++#$offset) = $src2.new",
1340 [], "$src1 = $_dst_">,
1347 string ImmOpStr = !cast<string>(ImmOp);
1348 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1349 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1350 /* s4_0Imm */ offset{3-0}));
1351 let IClass = 0b1010;
1353 let Inst{27-21} = 0b1011101;
1354 let Inst{20-16} = src1;
1356 let Inst{12-11} = MajOp;
1357 let Inst{10-8} = src2;
1359 let Inst{6-3} = offsetBits;
1363 //===----------------------------------------------------------------------===//
1364 // Template class for predicated post increment .new stores
1365 // if([!]Pv[.new]) mem[bhwd](Rx++#s4:[0123])=Nt.new
1366 //===----------------------------------------------------------------------===//
1367 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc, isNVStore = 1,
1368 isNewValue = 1, opNewValue = 4 in
1369 class T_StorePI_nv_pred <string mnemonic, Operand ImmOp,
1370 bits<2> MajOp, bit isPredNot, bit isPredNew >
1371 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1372 (ins PredRegs:$src1, IntRegs:$src2,
1373 ImmOp:$offset, IntRegs:$src3),
1374 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1375 ") ")#mnemonic#"($src2++#$offset) = $src3.new",
1376 [], "$src2 = $_dst_">,
1384 string ImmOpStr = !cast<string>(ImmOp);
1385 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1386 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1387 /* s4_0Imm */ offset{3-0}));
1388 let isPredicatedNew = isPredNew;
1389 let isPredicatedFalse = isPredNot;
1391 let IClass = 0b1010;
1393 let Inst{27-21} = 0b1011101;
1394 let Inst{20-16} = src2;
1396 let Inst{12-11} = MajOp;
1397 let Inst{10-8} = src3;
1398 let Inst{7} = isPredNew;
1399 let Inst{6-3} = offsetBits;
1400 let Inst{2} = isPredNot;
1401 let Inst{1-0} = src1;
1404 multiclass ST_PostInc_Pred_nv<string mnemonic, Operand ImmOp,
1405 bits<2> MajOp, bit PredNot> {
1406 def _pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 0>;
1409 def new_pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 1>;
1412 multiclass ST_PostInc_nv<string mnemonic, string BaseOp, Operand ImmOp,
1414 let BaseOpcode = "POST_"#BaseOp in {
1415 def S2_#NAME#_pi : T_StorePI_nv <mnemonic, ImmOp, MajOp>;
1418 defm S2_p#NAME#t : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 0>;
1419 defm S2_p#NAME#f : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 1>;
1423 let accessSize = ByteAccess in
1424 defm storerbnew: ST_PostInc_nv <"memb", "STrib", s4_0Imm, 0b00>;
1426 let accessSize = HalfWordAccess in
1427 defm storerhnew: ST_PostInc_nv <"memh", "STrih", s4_1Imm, 0b01>;
1429 let accessSize = WordAccess in
1430 defm storerinew: ST_PostInc_nv <"memw", "STriw", s4_2Imm, 0b10>;
1432 //===----------------------------------------------------------------------===//
1433 // Template class for post increment .new stores with register offset
1434 //===----------------------------------------------------------------------===//
1435 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
1436 class T_StorePI_RegNV <string mnemonic, bits<2> MajOp, MemAccessSize AccessSz>
1437 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1438 (ins IntRegs:$src1, ModRegs:$src2, IntRegs:$src3),
1439 #mnemonic#"($src1++$src2) = $src3.new",
1440 [], "$src1 = $_dst_"> {
1444 let accessSize = AccessSz;
1446 let IClass = 0b1010;
1448 let Inst{27-21} = 0b1101101;
1449 let Inst{20-16} = src1;
1450 let Inst{13} = src2;
1451 let Inst{12-11} = MajOp;
1452 let Inst{10-8} = src3;
1456 def S2_storerbnew_pr : T_StorePI_RegNV<"memb", 0b00, ByteAccess>;
1457 def S2_storerhnew_pr : T_StorePI_RegNV<"memh", 0b01, HalfWordAccess>;
1458 def S2_storerinew_pr : T_StorePI_RegNV<"memw", 0b10, WordAccess>;
1460 // memb(Rx++#s4:0:circ(Mu))=Nt.new
1461 // memb(Rx++I:circ(Mu))=Nt.new
1462 // memb(Rx++Mu:brev)=Nt.new
1463 // memh(Rx++#s4:1:circ(Mu))=Nt.new
1464 // memh(Rx++I:circ(Mu))=Nt.new
1465 // memh(Rx++Mu)=Nt.new
1466 // memh(Rx++Mu:brev)=Nt.new
1468 // memw(Rx++#s4:2:circ(Mu))=Nt.new
1469 // memw(Rx++I:circ(Mu))=Nt.new
1470 // memw(Rx++Mu)=Nt.new
1471 // memw(Rx++Mu:brev)=Nt.new
1473 //===----------------------------------------------------------------------===//
1475 //===----------------------------------------------------------------------===//
1477 //===----------------------------------------------------------------------===//
1479 //===----------------------------------------------------------------------===//
1481 //===----------------------------------------------------------------------===//
1482 // multiclass/template class for the new-value compare jumps with the register
1484 //===----------------------------------------------------------------------===//
1486 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1487 opExtentAlign = 2 in
1488 class NVJrr_template<string mnemonic, bits<3> majOp, bit NvOpNum,
1489 bit isNegCond, bit isTak>
1491 (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset),
1492 "if ("#!if(isNegCond, "!","")#mnemonic#
1493 "($src1"#!if(!eq(NvOpNum, 0),".new, ",", ")#
1494 "$src2"#!if(!eq(NvOpNum, 1),".new))","))")#" jump:"
1495 #!if(isTak, "t","nt")#" $offset", []> {
1499 bits<3> Ns; // New-Value Operand
1500 bits<5> RegOp; // Non-New-Value Operand
1503 let isTaken = isTak;
1504 let isPredicatedFalse = isNegCond;
1505 let opNewValue{0} = NvOpNum;
1507 let Ns = !if(!eq(NvOpNum, 0), src1{2-0}, src2{2-0});
1508 let RegOp = !if(!eq(NvOpNum, 0), src2, src1);
1510 let IClass = 0b0010;
1511 let Inst{27-26} = 0b00;
1512 let Inst{25-23} = majOp;
1513 let Inst{22} = isNegCond;
1514 let Inst{18-16} = Ns;
1515 let Inst{13} = isTak;
1516 let Inst{12-8} = RegOp;
1517 let Inst{21-20} = offset{10-9};
1518 let Inst{7-1} = offset{8-2};
1522 multiclass NVJrr_cond<string mnemonic, bits<3> majOp, bit NvOpNum,
1524 // Branch not taken:
1525 def _nt: NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 0>;
1527 def _t : NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 1>;
1530 // NvOpNum = 0 -> First Operand is a new-value Register
1531 // NvOpNum = 1 -> Second Operand is a new-value Register
1533 multiclass NVJrr_base<string mnemonic, string BaseOp, bits<3> majOp,
1535 let BaseOpcode = BaseOp#_NVJ in {
1536 defm _t_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 0>; // True cond
1537 defm _f_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 1>; // False cond
1541 // if ([!]cmp.eq(Ns.new,Rt)) jump:[n]t #r9:2
1542 // if ([!]cmp.gt(Ns.new,Rt)) jump:[n]t #r9:2
1543 // if ([!]cmp.gtu(Ns.new,Rt)) jump:[n]t #r9:2
1544 // if ([!]cmp.gt(Rt,Ns.new)) jump:[n]t #r9:2
1545 // if ([!]cmp.gtu(Rt,Ns.new)) jump:[n]t #r9:2
1547 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1548 Defs = [PC], hasSideEffects = 0 in {
1549 defm J4_cmpeq : NVJrr_base<"cmp.eq", "CMPEQ", 0b000, 0>, PredRel;
1550 defm J4_cmpgt : NVJrr_base<"cmp.gt", "CMPGT", 0b001, 0>, PredRel;
1551 defm J4_cmpgtu : NVJrr_base<"cmp.gtu", "CMPGTU", 0b010, 0>, PredRel;
1552 defm J4_cmplt : NVJrr_base<"cmp.gt", "CMPLT", 0b011, 1>, PredRel;
1553 defm J4_cmpltu : NVJrr_base<"cmp.gtu", "CMPLTU", 0b100, 1>, PredRel;
1556 //===----------------------------------------------------------------------===//
1557 // multiclass/template class for the new-value compare jumps instruction
1558 // with a register and an unsigned immediate (U5) operand.
1559 //===----------------------------------------------------------------------===//
1561 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1562 opExtentAlign = 2 in
1563 class NVJri_template<string mnemonic, bits<3> majOp, bit isNegCond,
1566 (ins IntRegs:$src1, u5Imm:$src2, brtarget:$offset),
1567 "if ("#!if(isNegCond, "!","")#mnemonic#"($src1.new, #$src2)) jump:"
1568 #!if(isTak, "t","nt")#" $offset", []> {
1570 let isTaken = isTak;
1571 let isPredicatedFalse = isNegCond;
1572 let isTaken = isTak;
1578 let IClass = 0b0010;
1580 let Inst{25-23} = majOp;
1581 let Inst{22} = isNegCond;
1582 let Inst{18-16} = src1;
1583 let Inst{13} = isTak;
1584 let Inst{12-8} = src2;
1585 let Inst{21-20} = offset{10-9};
1586 let Inst{7-1} = offset{8-2};
1589 multiclass NVJri_cond<string mnemonic, bits<3> majOp, bit isNegCond> {
1590 // Branch not taken:
1591 def _nt: NVJri_template<mnemonic, majOp, isNegCond, 0>;
1593 def _t : NVJri_template<mnemonic, majOp, isNegCond, 1>;
1596 multiclass NVJri_base<string mnemonic, string BaseOp, bits<3> majOp> {
1597 let BaseOpcode = BaseOp#_NVJri in {
1598 defm _t_jumpnv : NVJri_cond<mnemonic, majOp, 0>; // True Cond
1599 defm _f_jumpnv : NVJri_cond<mnemonic, majOp, 1>; // False cond
1603 // if ([!]cmp.eq(Ns.new,#U5)) jump:[n]t #r9:2
1604 // if ([!]cmp.gt(Ns.new,#U5)) jump:[n]t #r9:2
1605 // if ([!]cmp.gtu(Ns.new,#U5)) jump:[n]t #r9:2
1607 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1608 Defs = [PC], hasSideEffects = 0 in {
1609 defm J4_cmpeqi : NVJri_base<"cmp.eq", "CMPEQ", 0b000>, PredRel;
1610 defm J4_cmpgti : NVJri_base<"cmp.gt", "CMPGT", 0b001>, PredRel;
1611 defm J4_cmpgtui : NVJri_base<"cmp.gtu", "CMPGTU", 0b010>, PredRel;
1614 //===----------------------------------------------------------------------===//
1615 // multiclass/template class for the new-value compare jumps instruction
1616 // with a register and an hardcoded 0/-1 immediate value.
1617 //===----------------------------------------------------------------------===//
1619 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 11,
1620 opExtentAlign = 2 in
1621 class NVJ_ConstImm_template<string mnemonic, bits<3> majOp, string ImmVal,
1622 bit isNegCond, bit isTak>
1624 (ins IntRegs:$src1, brtarget:$offset),
1625 "if ("#!if(isNegCond, "!","")#mnemonic
1626 #"($src1.new, #"#ImmVal#")) jump:"
1627 #!if(isTak, "t","nt")#" $offset", []> {
1629 let isTaken = isTak;
1630 let isPredicatedFalse = isNegCond;
1631 let isTaken = isTak;
1635 let IClass = 0b0010;
1637 let Inst{25-23} = majOp;
1638 let Inst{22} = isNegCond;
1639 let Inst{18-16} = src1;
1640 let Inst{13} = isTak;
1641 let Inst{21-20} = offset{10-9};
1642 let Inst{7-1} = offset{8-2};
1645 multiclass NVJ_ConstImm_cond<string mnemonic, bits<3> majOp, string ImmVal,
1647 // Branch not taken:
1648 def _nt: NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 0>;
1650 def _t : NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 1>;
1653 multiclass NVJ_ConstImm_base<string mnemonic, string BaseOp, bits<3> majOp,
1655 let BaseOpcode = BaseOp#_NVJ_ConstImm in {
1656 defm _t_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 0>; // True
1657 defm _f_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 1>; // False
1661 // if ([!]tstbit(Ns.new,#0)) jump:[n]t #r9:2
1662 // if ([!]cmp.eq(Ns.new,#-1)) jump:[n]t #r9:2
1663 // if ([!]cmp.gt(Ns.new,#-1)) jump:[n]t #r9:2
1665 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1,
1666 Defs = [PC], hasSideEffects = 0 in {
1667 defm J4_tstbit0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel;
1668 defm J4_cmpeqn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "-1">, PredRel;
1669 defm J4_cmpgtn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "-1">, PredRel;
1672 // J4_hintjumpr: Hint indirect conditional jump.
1673 let isBranch = 1, isIndirectBranch = 1, hasSideEffects = 0 in
1674 def J4_hintjumpr: JRInst <
1679 let IClass = 0b0101;
1680 let Inst{27-21} = 0b0010101;
1681 let Inst{20-16} = Rs;
1684 //===----------------------------------------------------------------------===//
1686 //===----------------------------------------------------------------------===//
1688 //===----------------------------------------------------------------------===//
1690 //===----------------------------------------------------------------------===//
1693 let hasNewValue = 1, isExtendable = 1, opExtendable = 1,
1694 isExtentSigned = 0, opExtentBits = 6, hasSideEffects = 0, Uses = [PC] in
1695 def C4_addipc : CRInst <(outs IntRegs:$Rd), (ins u6Ext:$u6),
1696 "$Rd = add(pc, #$u6)", [], "", CR_tc_2_SLOT3 > {
1700 let IClass = 0b0110;
1701 let Inst{27-16} = 0b101001001001;
1702 let Inst{12-7} = u6;
1708 let hasSideEffects = 0 in
1709 class T_LOGICAL_3OP<string MnOp1, string MnOp2, bits<2> OpBits, bit IsNeg>
1710 : CRInst<(outs PredRegs:$Pd),
1711 (ins PredRegs:$Ps, PredRegs:$Pt, PredRegs:$Pu),
1712 "$Pd = " # MnOp1 # "($Ps, " # MnOp2 # "($Pt, " #
1713 !if (IsNeg,"!","") # "$Pu))",
1714 [], "", CR_tc_2early_SLOT23> {
1720 let IClass = 0b0110;
1721 let Inst{27-24} = 0b1011;
1722 let Inst{23} = IsNeg;
1723 let Inst{22-21} = OpBits;
1725 let Inst{17-16} = Ps;
1732 def C4_and_and : T_LOGICAL_3OP<"and", "and", 0b00, 0>;
1733 def C4_and_or : T_LOGICAL_3OP<"and", "or", 0b01, 0>;
1734 def C4_or_and : T_LOGICAL_3OP<"or", "and", 0b10, 0>;
1735 def C4_or_or : T_LOGICAL_3OP<"or", "or", 0b11, 0>;
1736 def C4_and_andn : T_LOGICAL_3OP<"and", "and", 0b00, 1>;
1737 def C4_and_orn : T_LOGICAL_3OP<"and", "or", 0b01, 1>;
1738 def C4_or_andn : T_LOGICAL_3OP<"or", "and", 0b10, 1>;
1739 def C4_or_orn : T_LOGICAL_3OP<"or", "or", 0b11, 1>;
1741 //===----------------------------------------------------------------------===//
1743 //===----------------------------------------------------------------------===//
1745 //===----------------------------------------------------------------------===//
1747 //===----------------------------------------------------------------------===//
1749 // Logical with-not instructions.
1750 def A4_andnp : T_ALU64_logical<"and", 0b001, 1, 0, 1>;
1751 def A4_ornp : T_ALU64_logical<"or", 0b011, 1, 0, 1>;
1753 def: Pat<(i64 (and (i64 DoubleRegs:$Rs), (i64 (not (i64 DoubleRegs:$Rt))))),
1754 (A4_andnp DoubleRegs:$Rs, DoubleRegs:$Rt)>;
1755 def: Pat<(i64 (or (i64 DoubleRegs:$Rs), (i64 (not (i64 DoubleRegs:$Rt))))),
1756 (A4_ornp DoubleRegs:$Rs, DoubleRegs:$Rt)>;
1758 let hasNewValue = 1, hasSideEffects = 0 in
1759 def S4_parity: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1760 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1765 let IClass = 0b1101;
1766 let Inst{27-21} = 0b0101111;
1767 let Inst{20-16} = Rs;
1768 let Inst{12-8} = Rt;
1772 // Add and accumulate.
1773 // Rd=add(Rs,add(Ru,#s6))
1774 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 6,
1776 def S4_addaddi : ALU64Inst <(outs IntRegs:$Rd),
1777 (ins IntRegs:$Rs, IntRegs:$Ru, s6Ext:$s6),
1778 "$Rd = add($Rs, add($Ru, #$s6))" ,
1779 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs),
1780 (add (i32 IntRegs:$Ru), s6_16ExtPred:$s6)))],
1781 "", ALU64_tc_2_SLOT23> {
1787 let IClass = 0b1101;
1789 let Inst{27-23} = 0b10110;
1790 let Inst{22-21} = s6{5-4};
1791 let Inst{20-16} = Rs;
1792 let Inst{13} = s6{3};
1793 let Inst{12-8} = Rd;
1794 let Inst{7-5} = s6{2-0};
1798 let isExtentSigned = 1, hasSideEffects = 0, hasNewValue = 1, isExtendable = 1,
1799 opExtentBits = 6, opExtendable = 2 in
1800 def S4_subaddi: ALU64Inst <(outs IntRegs:$Rd),
1801 (ins IntRegs:$Rs, s6Ext:$s6, IntRegs:$Ru),
1802 "$Rd = add($Rs, sub(#$s6, $Ru))",
1803 [], "", ALU64_tc_2_SLOT23> {
1809 let IClass = 0b1101;
1811 let Inst{27-23} = 0b10111;
1812 let Inst{22-21} = s6{5-4};
1813 let Inst{20-16} = Rs;
1814 let Inst{13} = s6{3};
1815 let Inst{12-8} = Rd;
1816 let Inst{7-5} = s6{2-0};
1820 // Rd=add(Rs,sub(#s6,Ru))
1821 def: Pat<(add (i32 IntRegs:$src1), (sub s6_10ExtPred:$src2,
1822 (i32 IntRegs:$src3))),
1823 (S4_subaddi IntRegs:$src1, s6_10ExtPred:$src2, IntRegs:$src3)>;
1825 // Rd=sub(add(Rs,#s6),Ru)
1826 def: Pat<(sub (add (i32 IntRegs:$src1), s6_10ExtPred:$src2),
1827 (i32 IntRegs:$src3)),
1828 (S4_subaddi IntRegs:$src1, s6_10ExtPred:$src2, IntRegs:$src3)>;
1830 // Rd=add(sub(Rs,Ru),#s6)
1831 def: Pat<(add (sub (i32 IntRegs:$src1), (i32 IntRegs:$src3)),
1832 (s6_10ExtPred:$src2)),
1833 (S4_subaddi IntRegs:$src1, s6_10ExtPred:$src2, IntRegs:$src3)>;
1836 // Add or subtract doublewords with carry.
1838 // Rdd=add(Rss,Rtt,Px):carry
1840 // Rdd=sub(Rss,Rtt,Px):carry
1843 // Rdd=extract(Rss,#u6,#U6)
1844 // Rdd=extract(Rss,Rtt)
1845 // Rd=extract(Rs,Rtt)
1846 // Rd=extract(Rs,#u5,#U5)
1848 def S4_extractp_rp : T_S3op_64 < "extract", 0b11, 0b100, 0>;
1849 def S4_extractp : T_S2op_extract <"extract", 0b1010, DoubleRegs, u6Imm>;
1851 let hasNewValue = 1 in {
1852 def S4_extract_rp : T_S3op_extract<"extract", 0b01>;
1853 def S4_extract : T_S2op_extract <"extract", 0b1101, IntRegs, u5Imm>;
1856 // Complex add/sub halfwords/words
1857 let Defs = [USR_OVF] in {
1858 def S4_vxaddsubh : T_S3op_64 < "vxaddsubh", 0b01, 0b100, 0, 1>;
1859 def S4_vxaddsubw : T_S3op_64 < "vxaddsubw", 0b01, 0b000, 0, 1>;
1860 def S4_vxsubaddh : T_S3op_64 < "vxsubaddh", 0b01, 0b110, 0, 1>;
1861 def S4_vxsubaddw : T_S3op_64 < "vxsubaddw", 0b01, 0b010, 0, 1>;
1864 let Defs = [USR_OVF] in {
1865 def S4_vxaddsubhr : T_S3op_64 < "vxaddsubh", 0b11, 0b000, 0, 1, 1, 1>;
1866 def S4_vxsubaddhr : T_S3op_64 < "vxsubaddh", 0b11, 0b010, 0, 1, 1, 1>;
1869 let Itinerary = M_tc_3x_SLOT23, Defs = [USR_OVF] in {
1870 def M4_mac_up_s1_sat: T_MType_acc_rr<"+= mpy", 0b011, 0b000, 0, [], 0, 1, 1>;
1871 def M4_nac_up_s1_sat: T_MType_acc_rr<"-= mpy", 0b011, 0b001, 0, [], 0, 1, 1>;
1874 // Logical xor with xor accumulation.
1875 // Rxx^=xor(Rss,Rtt)
1876 let hasSideEffects = 0 in
1878 : SInst <(outs DoubleRegs:$Rxx),
1879 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
1880 "$Rxx ^= xor($Rss, $Rtt)",
1881 [(set (i64 DoubleRegs:$Rxx),
1882 (xor (i64 DoubleRegs:$dst2), (xor (i64 DoubleRegs:$Rss),
1883 (i64 DoubleRegs:$Rtt))))],
1884 "$dst2 = $Rxx", S_3op_tc_1_SLOT23> {
1889 let IClass = 0b1100;
1891 let Inst{27-22} = 0b101010;
1892 let Inst{20-16} = Rss;
1893 let Inst{12-8} = Rtt;
1894 let Inst{7-5} = 0b000;
1895 let Inst{4-0} = Rxx;
1898 // Rotate and reduce bytes
1899 // Rdd=vrcrotate(Rss,Rt,#u2)
1900 let hasSideEffects = 0 in
1902 : SInst <(outs DoubleRegs:$Rdd),
1903 (ins DoubleRegs:$Rss, IntRegs:$Rt, u2Imm:$u2),
1904 "$Rdd = vrcrotate($Rss, $Rt, #$u2)",
1905 [], "", S_3op_tc_3x_SLOT23> {
1911 let IClass = 0b1100;
1913 let Inst{27-22} = 0b001111;
1914 let Inst{20-16} = Rss;
1915 let Inst{13} = u2{1};
1916 let Inst{12-8} = Rt;
1917 let Inst{7-6} = 0b11;
1918 let Inst{5} = u2{0};
1919 let Inst{4-0} = Rdd;
1922 // Rotate and reduce bytes with accumulation
1923 // Rxx+=vrcrotate(Rss,Rt,#u2)
1924 let hasSideEffects = 0 in
1925 def S4_vrcrotate_acc
1926 : SInst <(outs DoubleRegs:$Rxx),
1927 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt, u2Imm:$u2),
1928 "$Rxx += vrcrotate($Rss, $Rt, #$u2)", [],
1929 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
1935 let IClass = 0b1100;
1937 let Inst{27-21} = 0b1011101;
1938 let Inst{20-16} = Rss;
1939 let Inst{13} = u2{1};
1940 let Inst{12-8} = Rt;
1941 let Inst{5} = u2{0};
1942 let Inst{4-0} = Rxx;
1945 // Vector reduce conditional negate halfwords
1946 let hasSideEffects = 0 in
1948 : SInst <(outs DoubleRegs:$Rxx),
1949 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt),
1950 "$Rxx += vrcnegh($Rss, $Rt)", [],
1951 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
1956 let IClass = 0b1100;
1958 let Inst{27-21} = 0b1011001;
1959 let Inst{20-16} = Rss;
1961 let Inst{12-8} = Rt;
1962 let Inst{7-5} = 0b111;
1963 let Inst{4-0} = Rxx;
1967 def A4_bitspliti : T_S2op_2_di <"bitsplit", 0b110, 0b100>;
1969 // Arithmetic/Convergent round
1970 def A4_cround_ri : T_S2op_2_ii <"cround", 0b111, 0b000>;
1972 def A4_round_ri : T_S2op_2_ii <"round", 0b111, 0b100>;
1974 let Defs = [USR_OVF] in
1975 def A4_round_ri_sat : T_S2op_2_ii <"round", 0b111, 0b110, 1>;
1977 // Logical-logical words.
1978 // Compound or-and -- Rx=or(Ru,and(Rx,#s10))
1979 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 10,
1982 ALU64Inst<(outs IntRegs:$Rx),
1983 (ins IntRegs:$Ru, IntRegs:$_src_, s10Ext:$s10),
1984 "$Rx = or($Ru, and($_src_, #$s10))" ,
1985 [(set (i32 IntRegs:$Rx),
1986 (or (i32 IntRegs:$Ru), (and (i32 IntRegs:$_src_), s10ExtPred:$s10)))] ,
1987 "$_src_ = $Rx", ALU64_tc_2_SLOT23> {
1992 let IClass = 0b1101;
1994 let Inst{27-22} = 0b101001;
1995 let Inst{20-16} = Rx;
1996 let Inst{21} = s10{9};
1997 let Inst{13-5} = s10{8-0};
2001 // Miscellaneous ALU64 instructions.
2003 let hasNewValue = 1, hasSideEffects = 0 in
2004 def A4_modwrapu: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
2005 "$Rd = modwrap($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
2010 let IClass = 0b1101;
2011 let Inst{27-21} = 0b0011111;
2012 let Inst{20-16} = Rs;
2013 let Inst{12-8} = Rt;
2014 let Inst{7-5} = 0b111;
2018 let hasSideEffects = 0 in
2019 def A4_bitsplit: ALU64Inst<(outs DoubleRegs:$Rd),
2020 (ins IntRegs:$Rs, IntRegs:$Rt),
2021 "$Rd = bitsplit($Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
2026 let IClass = 0b1101;
2027 let Inst{27-24} = 0b0100;
2029 let Inst{20-16} = Rs;
2030 let Inst{12-8} = Rt;
2034 // Rx[&|]=xor(Rs,Rt)
2035 def M4_or_xor : T_MType_acc_rr < "|= xor", 0b110, 0b001, 0>;
2036 def M4_and_xor : T_MType_acc_rr < "&= xor", 0b010, 0b010, 0>;
2038 // Rx[&|^]=or(Rs,Rt)
2039 def M4_xor_or : T_MType_acc_rr < "^= or", 0b110, 0b011, 0>;
2041 let CextOpcode = "ORr_ORr" in
2042 def M4_or_or : T_MType_acc_rr < "|= or", 0b110, 0b000, 0>;
2043 def M4_and_or : T_MType_acc_rr < "&= or", 0b010, 0b001, 0>;
2045 // Rx[&|^]=and(Rs,Rt)
2046 def M4_xor_and : T_MType_acc_rr < "^= and", 0b110, 0b010, 0>;
2048 let CextOpcode = "ORr_ANDr" in
2049 def M4_or_and : T_MType_acc_rr < "|= and", 0b010, 0b011, 0>;
2050 def M4_and_and : T_MType_acc_rr < "&= and", 0b010, 0b000, 0>;
2052 // Rx[&|^]=and(Rs,~Rt)
2053 def M4_xor_andn : T_MType_acc_rr < "^= and", 0b001, 0b010, 0, [], 1>;
2054 def M4_or_andn : T_MType_acc_rr < "|= and", 0b001, 0b000, 0, [], 1>;
2055 def M4_and_andn : T_MType_acc_rr < "&= and", 0b001, 0b001, 0, [], 1>;
2057 // Compound or-or and or-and
2058 let isExtentSigned = 1, InputType = "imm", hasNewValue = 1, isExtendable = 1,
2059 opExtentBits = 10, opExtendable = 3 in
2060 class T_CompOR <string mnemonic, bits<2> MajOp, SDNode OpNode>
2061 : MInst_acc <(outs IntRegs:$Rx),
2062 (ins IntRegs:$src1, IntRegs:$Rs, s10Ext:$s10),
2063 "$Rx |= "#mnemonic#"($Rs, #$s10)",
2064 [(set (i32 IntRegs:$Rx), (or (i32 IntRegs:$src1),
2065 (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10)))],
2066 "$src1 = $Rx", ALU64_tc_2_SLOT23>, ImmRegRel {
2071 let IClass = 0b1101;
2073 let Inst{27-24} = 0b1010;
2074 let Inst{23-22} = MajOp;
2075 let Inst{20-16} = Rs;
2076 let Inst{21} = s10{9};
2077 let Inst{13-5} = s10{8-0};
2081 let CextOpcode = "ORr_ANDr" in
2082 def S4_or_andi : T_CompOR <"and", 0b00, and>;
2084 let CextOpcode = "ORr_ORr" in
2085 def S4_or_ori : T_CompOR <"or", 0b10, or>;
2088 // Rd=modwrap(Rs,Rt)
2090 // Rd=cround(Rs,#u5)
2092 // Rd=round(Rs,#u5)[:sat]
2093 // Rd=round(Rs,Rt)[:sat]
2094 // Vector reduce add unsigned halfwords
2095 // Rd=vraddh(Rss,Rtt)
2097 // Rdd=vaddb(Rss,Rtt)
2098 // Vector conditional negate
2099 // Rdd=vcnegh(Rss,Rt)
2100 // Rxx+=vrcnegh(Rss,Rt)
2101 // Vector maximum bytes
2102 // Rdd=vmaxb(Rtt,Rss)
2103 // Vector reduce maximum halfwords
2104 // Rxx=vrmaxh(Rss,Ru)
2105 // Rxx=vrmaxuh(Rss,Ru)
2106 // Vector reduce maximum words
2107 // Rxx=vrmaxuw(Rss,Ru)
2108 // Rxx=vrmaxw(Rss,Ru)
2109 // Vector minimum bytes
2110 // Rdd=vminb(Rtt,Rss)
2111 // Vector reduce minimum halfwords
2112 // Rxx=vrminh(Rss,Ru)
2113 // Rxx=vrminuh(Rss,Ru)
2114 // Vector reduce minimum words
2115 // Rxx=vrminuw(Rss,Ru)
2116 // Rxx=vrminw(Rss,Ru)
2117 // Vector subtract bytes
2118 // Rdd=vsubb(Rss,Rtt)
2120 //===----------------------------------------------------------------------===//
2122 //===----------------------------------------------------------------------===//
2124 //===----------------------------------------------------------------------===//
2126 //===----------------------------------------------------------------------===//
2129 def S2_brevp : T_S2op_3 <"brev", 0b11, 0b110>;
2132 def S2_ct0p : T_COUNT_LEADING_64<"ct0", 0b111, 0b010>;
2133 def S2_ct1p : T_COUNT_LEADING_64<"ct1", 0b111, 0b100>;
2134 def S4_clbpnorm : T_COUNT_LEADING_64<"normamt", 0b011, 0b000>;
2136 def: Pat<(i32 (trunc (cttz (i64 DoubleRegs:$Rss)))),
2137 (S2_ct0p (i64 DoubleRegs:$Rss))>;
2138 def: Pat<(i32 (trunc (cttz (not (i64 DoubleRegs:$Rss))))),
2139 (S2_ct1p (i64 DoubleRegs:$Rss))>;
2141 let hasSideEffects = 0, hasNewValue = 1 in
2142 def S4_clbaddi : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s6Imm:$s6),
2143 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
2147 let IClass = 0b1000;
2148 let Inst{27-24} = 0b1100;
2149 let Inst{23-21} = 0b001;
2150 let Inst{20-16} = Rs;
2151 let Inst{13-8} = s6;
2152 let Inst{7-5} = 0b000;
2156 let hasSideEffects = 0, hasNewValue = 1 in
2157 def S4_clbpaddi : SInst<(outs IntRegs:$Rd), (ins DoubleRegs:$Rs, s6Imm:$s6),
2158 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
2162 let IClass = 0b1000;
2163 let Inst{27-24} = 0b1000;
2164 let Inst{23-21} = 0b011;
2165 let Inst{20-16} = Rs;
2166 let Inst{13-8} = s6;
2167 let Inst{7-5} = 0b010;
2172 // Bit test/set/clear
2173 def S4_ntstbit_i : T_TEST_BIT_IMM<"!tstbit", 0b001>;
2174 def S4_ntstbit_r : T_TEST_BIT_REG<"!tstbit", 1>;
2176 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
2177 def: Pat<(i1 (seteq (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
2178 (S4_ntstbit_i (i32 IntRegs:$Rs), u5ImmPred:$u5)>;
2179 def: Pat<(i1 (seteq (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
2180 (S4_ntstbit_r (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))>;
2183 // Add extra complexity to prefer these instructions over bitsset/bitsclr.
2184 // The reason is that tstbit/ntstbit can be folded into a compound instruction:
2185 // if ([!]tstbit(...)) jump ...
2186 let AddedComplexity = 100 in
2187 def: Pat<(i1 (setne (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2188 (S2_tstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2190 let AddedComplexity = 100 in
2191 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2192 (S4_ntstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2194 def C4_nbitsset : T_TEST_BITS_REG<"!bitsset", 0b01, 1>;
2195 def C4_nbitsclr : T_TEST_BITS_REG<"!bitsclr", 0b10, 1>;
2196 def C4_nbitsclri : T_TEST_BITS_IMM<"!bitsclr", 0b10, 1>;
2198 // Do not increase complexity of these patterns. In the DAG, "cmp i8" may be
2199 // represented as a compare against "value & 0xFF", which is an exact match
2200 // for cmpb (same for cmph). The patterns below do not contain any additional
2201 // complexity that would make them preferable, and if they were actually used
2202 // instead of cmpb/cmph, they would result in a compare against register that
2203 // is loaded with the byte/half mask (i.e. 0xFF or 0xFFFF).
2204 def: Pat<(i1 (setne (and I32:$Rs, u6ImmPred:$u6), 0)),
2205 (C4_nbitsclri I32:$Rs, u6ImmPred:$u6)>;
2206 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), 0)),
2207 (C4_nbitsclr I32:$Rs, I32:$Rt)>;
2208 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), I32:$Rt)),
2209 (C4_nbitsset I32:$Rs, I32:$Rt)>;
2211 //===----------------------------------------------------------------------===//
2213 //===----------------------------------------------------------------------===//
2215 //===----------------------------------------------------------------------===//
2217 //===----------------------------------------------------------------------===//
2219 // Rd=add(#u6,mpyi(Rs,#U6)) -- Multiply by immed and add immed.
2221 let hasNewValue = 1, isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
2222 def M4_mpyri_addi : MInst<(outs IntRegs:$Rd),
2223 (ins u6Ext:$u6, IntRegs:$Rs, u6Imm:$U6),
2224 "$Rd = add(#$u6, mpyi($Rs, #$U6))" ,
2225 [(set (i32 IntRegs:$Rd),
2226 (add (mul (i32 IntRegs:$Rs), u6ImmPred:$U6),
2227 u6ExtPred:$u6))] ,"",ALU64_tc_3x_SLOT23> {
2233 let IClass = 0b1101;
2235 let Inst{27-24} = 0b1000;
2236 let Inst{23} = U6{5};
2237 let Inst{22-21} = u6{5-4};
2238 let Inst{20-16} = Rs;
2239 let Inst{13} = u6{3};
2240 let Inst{12-8} = Rd;
2241 let Inst{7-5} = u6{2-0};
2242 let Inst{4-0} = U6{4-0};
2245 // Rd=add(#u6,mpyi(Rs,Rt))
2246 let CextOpcode = "ADD_MPY", InputType = "imm", hasNewValue = 1,
2247 isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
2248 def M4_mpyrr_addi : MInst <(outs IntRegs:$Rd),
2249 (ins u6Ext:$u6, IntRegs:$Rs, IntRegs:$Rt),
2250 "$Rd = add(#$u6, mpyi($Rs, $Rt))" ,
2251 [(set (i32 IntRegs:$Rd),
2252 (add (mul (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), u6ExtPred:$u6))],
2253 "", ALU64_tc_3x_SLOT23>, ImmRegRel {
2259 let IClass = 0b1101;
2261 let Inst{27-23} = 0b01110;
2262 let Inst{22-21} = u6{5-4};
2263 let Inst{20-16} = Rs;
2264 let Inst{13} = u6{3};
2265 let Inst{12-8} = Rt;
2266 let Inst{7-5} = u6{2-0};
2270 let hasNewValue = 1 in
2271 class T_AddMpy <bit MajOp, PatLeaf ImmPred, dag ins>
2272 : ALU64Inst <(outs IntRegs:$dst), ins,
2273 "$dst = add($src1, mpyi("#!if(MajOp,"$src3, #$src2))",
2275 [(set (i32 IntRegs:$dst),
2276 (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src3), ImmPred:$src2)))],
2277 "", ALU64_tc_3x_SLOT23> {
2283 let IClass = 0b1101;
2285 bits<6> ImmValue = !if(MajOp, src2{5-0}, src2{7-2});
2287 let Inst{27-24} = 0b1111;
2288 let Inst{23} = MajOp;
2289 let Inst{22-21} = ImmValue{5-4};
2290 let Inst{20-16} = src3;
2291 let Inst{13} = ImmValue{3};
2292 let Inst{12-8} = dst;
2293 let Inst{7-5} = ImmValue{2-0};
2294 let Inst{4-0} = src1;
2297 def M4_mpyri_addr_u2 : T_AddMpy<0b0, u6_2ImmPred,
2298 (ins IntRegs:$src1, u6_2Imm:$src2, IntRegs:$src3)>;
2300 let isExtendable = 1, opExtentBits = 6, opExtendable = 3,
2301 CextOpcode = "ADD_MPY", InputType = "imm" in
2302 def M4_mpyri_addr : T_AddMpy<0b1, u6ExtPred,
2303 (ins IntRegs:$src1, IntRegs:$src3, u6Ext:$src2)>, ImmRegRel;
2305 // Rx=add(Ru,mpyi(Rx,Rs))
2306 let CextOpcode = "ADD_MPY", InputType = "reg", hasNewValue = 1 in
2307 def M4_mpyrr_addr: MInst_acc <(outs IntRegs:$Rx),
2308 (ins IntRegs:$Ru, IntRegs:$_src_, IntRegs:$Rs),
2309 "$Rx = add($Ru, mpyi($_src_, $Rs))",
2310 [(set (i32 IntRegs:$Rx), (add (i32 IntRegs:$Ru),
2311 (mul (i32 IntRegs:$_src_), (i32 IntRegs:$Rs))))],
2312 "$_src_ = $Rx", M_tc_3x_SLOT23>, ImmRegRel {
2317 let IClass = 0b1110;
2319 let Inst{27-21} = 0b0011000;
2320 let Inst{12-8} = Rx;
2322 let Inst{20-16} = Rs;
2325 // Rd=add(##,mpyi(Rs,#U6))
2326 def : Pat <(add (mul (i32 IntRegs:$src2), u6ImmPred:$src3),
2327 (HexagonCONST32 tglobaladdr:$src1)),
2328 (i32 (M4_mpyri_addi tglobaladdr:$src1, IntRegs:$src2,
2331 // Rd=add(##,mpyi(Rs,Rt))
2332 def : Pat <(add (mul (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2333 (HexagonCONST32 tglobaladdr:$src1)),
2334 (i32 (M4_mpyrr_addi tglobaladdr:$src1, IntRegs:$src2,
2337 // Vector reduce multiply word by signed half (32x16)
2338 //Rdd=vrmpyweh(Rss,Rtt)[:<<1]
2339 def M4_vrmpyeh_s0 : T_M2_vmpy<"vrmpyweh", 0b010, 0b100, 0, 0, 0>;
2340 def M4_vrmpyeh_s1 : T_M2_vmpy<"vrmpyweh", 0b110, 0b100, 1, 0, 0>;
2342 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2343 def M4_vrmpyoh_s0 : T_M2_vmpy<"vrmpywoh", 0b001, 0b010, 0, 0, 0>;
2344 def M4_vrmpyoh_s1 : T_M2_vmpy<"vrmpywoh", 0b101, 0b010, 1, 0, 0>;
2346 //Rdd+=vrmpyweh(Rss,Rtt)[:<<1]
2347 def M4_vrmpyeh_acc_s0: T_M2_vmpy_acc<"vrmpyweh", 0b001, 0b110, 0, 0>;
2348 def M4_vrmpyeh_acc_s1: T_M2_vmpy_acc<"vrmpyweh", 0b101, 0b110, 1, 0>;
2350 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2351 def M4_vrmpyoh_acc_s0: T_M2_vmpy_acc<"vrmpywoh", 0b011, 0b110, 0, 0>;
2352 def M4_vrmpyoh_acc_s1: T_M2_vmpy_acc<"vrmpywoh", 0b111, 0b110, 1, 0>;
2354 // Vector multiply halfwords, signed by unsigned
2355 // Rdd=vmpyhsu(Rs,Rt)[:<<]:sat
2356 def M2_vmpy2su_s0 : T_XTYPE_mpy64 < "vmpyhsu", 0b000, 0b111, 1, 0, 0>;
2357 def M2_vmpy2su_s1 : T_XTYPE_mpy64 < "vmpyhsu", 0b100, 0b111, 1, 1, 0>;
2359 // Rxx+=vmpyhsu(Rs,Rt)[:<<1]:sat
2360 def M2_vmac2su_s0 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b011, 0b101, 1, 0, 0>;
2361 def M2_vmac2su_s1 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b111, 0b101, 1, 1, 0>;
2363 // Vector polynomial multiply halfwords
2364 // Rdd=vpmpyh(Rs,Rt)
2365 def M4_vpmpyh : T_XTYPE_mpy64 < "vpmpyh", 0b110, 0b111, 0, 0, 0>;
2367 // Rxx^=vpmpyh(Rs,Rt)
2368 def M4_vpmpyh_acc : T_XTYPE_mpy64_acc < "vpmpyh", "^", 0b101, 0b111, 0, 0, 0>;
2370 // Polynomial multiply words
2372 def M4_pmpyw : T_XTYPE_mpy64 < "pmpyw", 0b010, 0b111, 0, 0, 0>;
2374 // Rxx^=pmpyw(Rs,Rt)
2375 def M4_pmpyw_acc : T_XTYPE_mpy64_acc < "pmpyw", "^", 0b001, 0b111, 0, 0, 0>;
2377 //===----------------------------------------------------------------------===//
2379 //===----------------------------------------------------------------------===//
2381 //===----------------------------------------------------------------------===//
2382 // ALU64/Vector compare
2383 //===----------------------------------------------------------------------===//
2384 //===----------------------------------------------------------------------===//
2385 // Template class for vector compare
2386 //===----------------------------------------------------------------------===//
2388 let hasSideEffects = 0 in
2389 class T_vcmpImm <string Str, bits<2> cmpOp, bits<2> minOp, Operand ImmOprnd>
2390 : ALU64_rr <(outs PredRegs:$Pd),
2391 (ins DoubleRegs:$Rss, ImmOprnd:$Imm),
2392 "$Pd = "#Str#"($Rss, #$Imm)",
2393 [], "", ALU64_tc_2early_SLOT23> {
2398 let ImmBits{6-0} = Imm{6-0};
2399 let ImmBits{7} = !if (!eq(cmpOp,0b10), 0b0, Imm{7}); // 0 for vcmp[bhw].gtu
2401 let IClass = 0b1101;
2403 let Inst{27-24} = 0b1100;
2404 let Inst{22-21} = cmpOp;
2405 let Inst{20-16} = Rss;
2406 let Inst{12-5} = ImmBits;
2407 let Inst{4-3} = minOp;
2411 // Vector compare bytes
2412 def A4_vcmpbgt : T_vcmp <"vcmpb.gt", 0b1010>;
2413 def: T_vcmp_pat<A4_vcmpbgt, setgt, v8i8>;
2415 let AsmString = "$Pd = any8(vcmpb.eq($Rss, $Rtt))" in
2416 def A4_vcmpbeq_any : T_vcmp <"any8(vcmpb.gt", 0b1000>;
2418 def A4_vcmpbeqi : T_vcmpImm <"vcmpb.eq", 0b00, 0b00, u8Imm>;
2419 def A4_vcmpbgti : T_vcmpImm <"vcmpb.gt", 0b01, 0b00, s8Imm>;
2420 def A4_vcmpbgtui : T_vcmpImm <"vcmpb.gtu", 0b10, 0b00, u7Imm>;
2422 // Vector compare halfwords
2423 def A4_vcmpheqi : T_vcmpImm <"vcmph.eq", 0b00, 0b01, s8Imm>;
2424 def A4_vcmphgti : T_vcmpImm <"vcmph.gt", 0b01, 0b01, s8Imm>;
2425 def A4_vcmphgtui : T_vcmpImm <"vcmph.gtu", 0b10, 0b01, u7Imm>;
2427 // Vector compare words
2428 def A4_vcmpweqi : T_vcmpImm <"vcmpw.eq", 0b00, 0b10, s8Imm>;
2429 def A4_vcmpwgti : T_vcmpImm <"vcmpw.gt", 0b01, 0b10, s8Imm>;
2430 def A4_vcmpwgtui : T_vcmpImm <"vcmpw.gtu", 0b10, 0b10, u7Imm>;
2432 //===----------------------------------------------------------------------===//
2434 //===----------------------------------------------------------------------===//
2435 // Shift by immediate and accumulate/logical.
2436 // Rx=add(#u8,asl(Rx,#U5)) Rx=add(#u8,lsr(Rx,#U5))
2437 // Rx=sub(#u8,asl(Rx,#U5)) Rx=sub(#u8,lsr(Rx,#U5))
2438 // Rx=and(#u8,asl(Rx,#U5)) Rx=and(#u8,lsr(Rx,#U5))
2439 // Rx=or(#u8,asl(Rx,#U5)) Rx=or(#u8,lsr(Rx,#U5))
2440 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8,
2441 hasNewValue = 1, opNewValue = 0 in
2442 class T_S4_ShiftOperate<string MnOp, string MnSh, SDNode Op, SDNode Sh,
2443 bit asl_lsr, bits<2> MajOp, InstrItinClass Itin>
2444 : MInst_acc<(outs IntRegs:$Rd), (ins u8Ext:$u8, IntRegs:$Rx, u5Imm:$U5),
2445 "$Rd = "#MnOp#"(#$u8, "#MnSh#"($Rx, #$U5))",
2446 [(set (i32 IntRegs:$Rd),
2447 (Op (Sh I32:$Rx, u5ImmPred:$U5), u8ExtPred:$u8))],
2448 "$Rd = $Rx", Itin> {
2455 let IClass = 0b1101;
2456 let Inst{27-24} = 0b1110;
2457 let Inst{23-21} = u8{7-5};
2458 let Inst{20-16} = Rd;
2459 let Inst{13} = u8{4};
2460 let Inst{12-8} = U5;
2461 let Inst{7-5} = u8{3-1};
2462 let Inst{4} = asl_lsr;
2463 let Inst{3} = u8{0};
2464 let Inst{2-1} = MajOp;
2467 multiclass T_ShiftOperate<string mnemonic, SDNode Op, bits<2> MajOp,
2468 InstrItinClass Itin> {
2469 def _asl_ri : T_S4_ShiftOperate<mnemonic, "asl", Op, shl, 0, MajOp, Itin>;
2470 def _lsr_ri : T_S4_ShiftOperate<mnemonic, "lsr", Op, srl, 1, MajOp, Itin>;
2473 let AddedComplexity = 200 in {
2474 defm S4_addi : T_ShiftOperate<"add", add, 0b10, ALU64_tc_2_SLOT23>;
2475 defm S4_andi : T_ShiftOperate<"and", and, 0b00, ALU64_tc_2_SLOT23>;
2478 let AddedComplexity = 30 in
2479 defm S4_ori : T_ShiftOperate<"or", or, 0b01, ALU64_tc_1_SLOT23>;
2481 defm S4_subi : T_ShiftOperate<"sub", sub, 0b11, ALU64_tc_1_SLOT23>;
2483 // Vector conditional negate
2484 // Rdd=vcnegh(Rss,Rt)
2485 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2486 def S2_vcnegh : T_S3op_shiftVect < "vcnegh", 0b11, 0b01>;
2488 // Rd=[cround|round](Rs,Rt)
2489 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in {
2490 def A4_cround_rr : T_S3op_3 < "cround", IntRegs, 0b11, 0b00>;
2491 def A4_round_rr : T_S3op_3 < "round", IntRegs, 0b11, 0b10>;
2494 // Rd=round(Rs,Rt):sat
2495 let hasNewValue = 1, Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2496 def A4_round_rr_sat : T_S3op_3 < "round", IntRegs, 0b11, 0b11, 1>;
2498 // Rd=[cmpyiwh|cmpyrwh](Rss,Rt):<<1:rnd:sat
2499 let Defs = [USR_OVF], Itinerary = S_3op_tc_3x_SLOT23 in {
2500 def M4_cmpyi_wh : T_S3op_8<"cmpyiwh", 0b100, 1, 1, 1>;
2501 def M4_cmpyr_wh : T_S3op_8<"cmpyrwh", 0b110, 1, 1, 1>;
2504 // Rdd=[add|sub](Rss,Rtt,Px):carry
2505 let isPredicateLate = 1, hasSideEffects = 0 in
2506 class T_S3op_carry <string mnemonic, bits<3> MajOp>
2507 : SInst < (outs DoubleRegs:$Rdd, PredRegs:$Px),
2508 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
2509 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu):carry",
2510 [], "$Px = $Pu", S_3op_tc_1_SLOT23 > {
2516 let IClass = 0b1100;
2518 let Inst{27-24} = 0b0010;
2519 let Inst{23-21} = MajOp;
2520 let Inst{20-16} = Rss;
2521 let Inst{12-8} = Rtt;
2523 let Inst{4-0} = Rdd;
2526 def A4_addp_c : T_S3op_carry < "add", 0b110 >;
2527 def A4_subp_c : T_S3op_carry < "sub", 0b111 >;
2529 let Itinerary = S_3op_tc_3_SLOT23, hasSideEffects = 0 in
2530 class T_S3op_6 <string mnemonic, bits<3> MinOp, bit isUnsigned>
2531 : SInst <(outs DoubleRegs:$Rxx),
2532 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Ru),
2533 "$Rxx = "#mnemonic#"($Rss, $Ru)" ,
2534 [] , "$dst2 = $Rxx"> {
2539 let IClass = 0b1100;
2541 let Inst{27-21} = 0b1011001;
2542 let Inst{20-16} = Rss;
2543 let Inst{13} = isUnsigned;
2544 let Inst{12-8} = Rxx;
2545 let Inst{7-5} = MinOp;
2549 // Vector reduce maximum halfwords
2550 // Rxx=vrmax[u]h(Rss,Ru)
2551 def A4_vrmaxh : T_S3op_6 < "vrmaxh", 0b001, 0>;
2552 def A4_vrmaxuh : T_S3op_6 < "vrmaxuh", 0b001, 1>;
2554 // Vector reduce maximum words
2555 // Rxx=vrmax[u]w(Rss,Ru)
2556 def A4_vrmaxw : T_S3op_6 < "vrmaxw", 0b010, 0>;
2557 def A4_vrmaxuw : T_S3op_6 < "vrmaxuw", 0b010, 1>;
2559 // Vector reduce minimum halfwords
2560 // Rxx=vrmin[u]h(Rss,Ru)
2561 def A4_vrminh : T_S3op_6 < "vrminh", 0b101, 0>;
2562 def A4_vrminuh : T_S3op_6 < "vrminuh", 0b101, 1>;
2564 // Vector reduce minimum words
2565 // Rxx=vrmin[u]w(Rss,Ru)
2566 def A4_vrminw : T_S3op_6 < "vrminw", 0b110, 0>;
2567 def A4_vrminuw : T_S3op_6 < "vrminuw", 0b110, 1>;
2569 // Shift an immediate left by register amount.
2570 let hasNewValue = 1, hasSideEffects = 0 in
2571 def S4_lsli: SInst <(outs IntRegs:$Rd), (ins s6Imm:$s6, IntRegs:$Rt),
2572 "$Rd = lsl(#$s6, $Rt)" ,
2573 [(set (i32 IntRegs:$Rd), (shl s6ImmPred:$s6,
2574 (i32 IntRegs:$Rt)))],
2575 "", S_3op_tc_1_SLOT23> {
2580 let IClass = 0b1100;
2582 let Inst{27-22} = 0b011010;
2583 let Inst{20-16} = s6{5-1};
2584 let Inst{12-8} = Rt;
2585 let Inst{7-6} = 0b11;
2587 let Inst{5} = s6{0};
2590 //===----------------------------------------------------------------------===//
2592 //===----------------------------------------------------------------------===//
2594 //===----------------------------------------------------------------------===//
2595 // MEMOP: Word, Half, Byte
2596 //===----------------------------------------------------------------------===//
2598 def MEMOPIMM : SDNodeXForm<imm, [{
2599 // Call the transformation function XformM5ToU5Imm to get the negative
2600 // immediate's positive counterpart.
2601 int32_t imm = N->getSExtValue();
2602 return XformM5ToU5Imm(imm);
2605 def MEMOPIMM_HALF : SDNodeXForm<imm, [{
2606 // -1 .. -31 represented as 65535..65515
2607 // assigning to a short restores our desired signed value.
2608 // Call the transformation function XformM5ToU5Imm to get the negative
2609 // immediate's positive counterpart.
2610 int16_t imm = N->getSExtValue();
2611 return XformM5ToU5Imm(imm);
2614 def MEMOPIMM_BYTE : SDNodeXForm<imm, [{
2615 // -1 .. -31 represented as 255..235
2616 // assigning to a char restores our desired signed value.
2617 // Call the transformation function XformM5ToU5Imm to get the negative
2618 // immediate's positive counterpart.
2619 int8_t imm = N->getSExtValue();
2620 return XformM5ToU5Imm(imm);
2623 def SETMEMIMM : SDNodeXForm<imm, [{
2624 // Return the bit position we will set [0-31].
2626 int32_t imm = N->getSExtValue();
2627 return XformMskToBitPosU5Imm(imm);
2630 def CLRMEMIMM : SDNodeXForm<imm, [{
2631 // Return the bit position we will clear [0-31].
2633 // we bit negate the value first
2634 int32_t imm = ~(N->getSExtValue());
2635 return XformMskToBitPosU5Imm(imm);
2638 def SETMEMIMM_SHORT : SDNodeXForm<imm, [{
2639 // Return the bit position we will set [0-15].
2641 int16_t imm = N->getSExtValue();
2642 return XformMskToBitPosU4Imm(imm);
2645 def CLRMEMIMM_SHORT : SDNodeXForm<imm, [{
2646 // Return the bit position we will clear [0-15].
2648 // we bit negate the value first
2649 int16_t imm = ~(N->getSExtValue());
2650 return XformMskToBitPosU4Imm(imm);
2653 def SETMEMIMM_BYTE : SDNodeXForm<imm, [{
2654 // Return the bit position we will set [0-7].
2656 int8_t imm = N->getSExtValue();
2657 return XformMskToBitPosU3Imm(imm);
2660 def CLRMEMIMM_BYTE : SDNodeXForm<imm, [{
2661 // Return the bit position we will clear [0-7].
2663 // we bit negate the value first
2664 int8_t imm = ~(N->getSExtValue());
2665 return XformMskToBitPosU3Imm(imm);
2668 //===----------------------------------------------------------------------===//
2669 // Template class for MemOp instructions with the register value.
2670 //===----------------------------------------------------------------------===//
2671 class MemOp_rr_base <string opc, bits<2> opcBits, Operand ImmOp,
2672 string memOp, bits<2> memOpBits> :
2674 (ins IntRegs:$base, ImmOp:$offset, IntRegs:$delta),
2675 opc#"($base+#$offset)"#memOp#"$delta",
2677 Requires<[UseMEMOP]> {
2682 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2684 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2685 !if (!eq(opcBits, 0b01), offset{6-1},
2686 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2688 let opExtentAlign = opcBits;
2689 let IClass = 0b0011;
2690 let Inst{27-24} = 0b1110;
2691 let Inst{22-21} = opcBits;
2692 let Inst{20-16} = base;
2694 let Inst{12-7} = offsetBits;
2695 let Inst{6-5} = memOpBits;
2696 let Inst{4-0} = delta;
2699 //===----------------------------------------------------------------------===//
2700 // Template class for MemOp instructions with the immediate value.
2701 //===----------------------------------------------------------------------===//
2702 class MemOp_ri_base <string opc, bits<2> opcBits, Operand ImmOp,
2703 string memOp, bits<2> memOpBits> :
2705 (ins IntRegs:$base, ImmOp:$offset, u5Imm:$delta),
2706 opc#"($base+#$offset)"#memOp#"#$delta"
2707 #!if(memOpBits{1},")", ""), // clrbit, setbit - include ')'
2709 Requires<[UseMEMOP]> {
2714 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2716 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2717 !if (!eq(opcBits, 0b01), offset{6-1},
2718 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2720 let opExtentAlign = opcBits;
2721 let IClass = 0b0011;
2722 let Inst{27-24} = 0b1111;
2723 let Inst{22-21} = opcBits;
2724 let Inst{20-16} = base;
2726 let Inst{12-7} = offsetBits;
2727 let Inst{6-5} = memOpBits;
2728 let Inst{4-0} = delta;
2731 // multiclass to define MemOp instructions with register operand.
2732 multiclass MemOp_rr<string opc, bits<2> opcBits, Operand ImmOp> {
2733 def L4_add#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " += ", 0b00>; // add
2734 def L4_sub#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " -= ", 0b01>; // sub
2735 def L4_and#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " &= ", 0b10>; // and
2736 def L4_or#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " |= ", 0b11>; // or
2739 // multiclass to define MemOp instructions with immediate Operand.
2740 multiclass MemOp_ri<string opc, bits<2> opcBits, Operand ImmOp> {
2741 def L4_iadd#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " += ", 0b00 >;
2742 def L4_isub#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " -= ", 0b01 >;
2743 def L4_iand#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = clrbit(", 0b10>;
2744 def L4_ior#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = setbit(", 0b11>;
2747 multiclass MemOp_base <string opc, bits<2> opcBits, Operand ImmOp> {
2748 defm _#NAME : MemOp_rr <opc, opcBits, ImmOp>;
2749 defm _#NAME : MemOp_ri <opc, opcBits, ImmOp>;
2752 // Define MemOp instructions.
2753 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0 in {
2754 let opExtentBits = 6, accessSize = ByteAccess in
2755 defm memopb_io : MemOp_base <"memb", 0b00, u6_0Ext>;
2757 let opExtentBits = 7, accessSize = HalfWordAccess in
2758 defm memoph_io : MemOp_base <"memh", 0b01, u6_1Ext>;
2760 let opExtentBits = 8, accessSize = WordAccess in
2761 defm memopw_io : MemOp_base <"memw", 0b10, u6_2Ext>;
2764 //===----------------------------------------------------------------------===//
2765 // Multiclass to define 'Def Pats' for ALU operations on the memory
2766 // Here value used for the ALU operation is an immediate value.
2767 // mem[bh](Rs+#0) += #U5
2768 // mem[bh](Rs+#u6) += #U5
2769 //===----------------------------------------------------------------------===//
2771 multiclass MemOpi_u5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf ExtPred,
2772 InstHexagon MI, SDNode OpNode> {
2773 let AddedComplexity = 180 in
2774 def: Pat<(stOp (OpNode (ldOp IntRegs:$addr), u5ImmPred:$addend),
2776 (MI IntRegs:$addr, 0, u5ImmPred:$addend)>;
2778 let AddedComplexity = 190 in
2779 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, ExtPred:$offset)),
2781 (add IntRegs:$base, ExtPred:$offset)),
2782 (MI IntRegs:$base, ExtPred:$offset, u5ImmPred:$addend)>;
2785 multiclass MemOpi_u5ALUOp<PatFrag ldOp, PatFrag stOp, PatLeaf ExtPred,
2786 InstHexagon addMI, InstHexagon subMI> {
2787 defm: MemOpi_u5Pats<ldOp, stOp, ExtPred, addMI, add>;
2788 defm: MemOpi_u5Pats<ldOp, stOp, ExtPred, subMI, sub>;
2791 multiclass MemOpi_u5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2793 defm: MemOpi_u5ALUOp <ldOpHalf, truncstorei16, u6_1ExtPred,
2794 L4_iadd_memoph_io, L4_isub_memoph_io>;
2796 defm: MemOpi_u5ALUOp <ldOpByte, truncstorei8, u6ExtPred,
2797 L4_iadd_memopb_io, L4_isub_memopb_io>;
2800 let Predicates = [UseMEMOP] in {
2801 defm: MemOpi_u5ExtType<zextloadi8, zextloadi16>; // zero extend
2802 defm: MemOpi_u5ExtType<sextloadi8, sextloadi16>; // sign extend
2803 defm: MemOpi_u5ExtType<extloadi8, extloadi16>; // any extend
2806 defm: MemOpi_u5ALUOp <load, store, u6_2ExtPred, L4_iadd_memopw_io,
2810 //===----------------------------------------------------------------------===//
2811 // multiclass to define 'Def Pats' for ALU operations on the memory.
2812 // Here value used for the ALU operation is a negative value.
2813 // mem[bh](Rs+#0) += #m5
2814 // mem[bh](Rs+#u6) += #m5
2815 //===----------------------------------------------------------------------===//
2817 multiclass MemOpi_m5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf extPred,
2818 PatLeaf immPred, ComplexPattern addrPred,
2819 SDNodeXForm xformFunc, InstHexagon MI> {
2820 let AddedComplexity = 190 in
2821 def: Pat<(stOp (add (ldOp IntRegs:$addr), immPred:$subend), IntRegs:$addr),
2822 (MI IntRegs:$addr, 0, (xformFunc immPred:$subend))>;
2824 let AddedComplexity = 195 in
2825 def: Pat<(stOp (add (ldOp (add IntRegs:$base, extPred:$offset)),
2827 (add IntRegs:$base, extPred:$offset)),
2828 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$subend))>;
2831 multiclass MemOpi_m5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2833 defm: MemOpi_m5Pats <ldOpHalf, truncstorei16, u6_1ExtPred, m5HImmPred,
2834 ADDRriU6_1, MEMOPIMM_HALF, L4_isub_memoph_io>;
2836 defm: MemOpi_m5Pats <ldOpByte, truncstorei8, u6ExtPred, m5BImmPred,
2837 ADDRriU6_0, MEMOPIMM_BYTE, L4_isub_memopb_io>;
2840 let Predicates = [UseMEMOP] in {
2841 defm: MemOpi_m5ExtType<zextloadi8, zextloadi16>; // zero extend
2842 defm: MemOpi_m5ExtType<sextloadi8, sextloadi16>; // sign extend
2843 defm: MemOpi_m5ExtType<extloadi8, extloadi16>; // any extend
2846 defm: MemOpi_m5Pats <load, store, u6_2ExtPred, m5ImmPred,
2847 ADDRriU6_2, MEMOPIMM, L4_isub_memopw_io>;
2850 //===----------------------------------------------------------------------===//
2851 // Multiclass to define 'def Pats' for bit operations on the memory.
2852 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
2853 // mem[bhw](Rs+#u6) = [clrbit|setbit](#U5)
2854 //===----------------------------------------------------------------------===//
2856 multiclass MemOpi_bitPats <PatFrag ldOp, PatFrag stOp, PatLeaf immPred,
2857 PatLeaf extPred, ComplexPattern addrPred,
2858 SDNodeXForm xformFunc, InstHexagon MI, SDNode OpNode> {
2860 // mem[bhw](Rs+#u6:[012]) = [clrbit|setbit](#U5)
2861 let AddedComplexity = 250 in
2862 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
2864 (add IntRegs:$base, extPred:$offset)),
2865 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$bitend))>;
2867 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
2868 let AddedComplexity = 225 in
2869 def: Pat<(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)),
2871 (addrPred (i32 IntRegs:$addr), extPred:$offset)),
2872 (MI IntRegs:$addr, extPred:$offset, (xformFunc immPred:$bitend))>;
2875 multiclass MemOpi_bitExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2877 defm: MemOpi_bitPats<ldOpByte, truncstorei8, Clr3ImmPred, u6ExtPred,
2878 ADDRriU6_0, CLRMEMIMM_BYTE, L4_iand_memopb_io, and>;
2880 defm: MemOpi_bitPats<ldOpByte, truncstorei8, Set3ImmPred, u6ExtPred,
2881 ADDRriU6_0, SETMEMIMM_BYTE, L4_ior_memopb_io, or>;
2882 // Half Word - clrbit
2883 defm: MemOpi_bitPats<ldOpHalf, truncstorei16, Clr4ImmPred, u6_1ExtPred,
2884 ADDRriU6_1, CLRMEMIMM_SHORT, L4_iand_memoph_io, and>;
2885 // Half Word - setbit
2886 defm: MemOpi_bitPats<ldOpHalf, truncstorei16, Set4ImmPred, u6_1ExtPred,
2887 ADDRriU6_1, SETMEMIMM_SHORT, L4_ior_memoph_io, or>;
2890 let Predicates = [UseMEMOP] in {
2891 // mem[bh](Rs+#0) = [clrbit|setbit](#U5)
2892 // mem[bh](Rs+#u6:[01]) = [clrbit|setbit](#U5)
2893 defm: MemOpi_bitExtType<zextloadi8, zextloadi16>; // zero extend
2894 defm: MemOpi_bitExtType<sextloadi8, sextloadi16>; // sign extend
2895 defm: MemOpi_bitExtType<extloadi8, extloadi16>; // any extend
2897 // memw(Rs+#0) = [clrbit|setbit](#U5)
2898 // memw(Rs+#u6:2) = [clrbit|setbit](#U5)
2899 defm: MemOpi_bitPats<load, store, Clr5ImmPred, u6_2ExtPred, ADDRriU6_2,
2900 CLRMEMIMM, L4_iand_memopw_io, and>;
2901 defm: MemOpi_bitPats<load, store, Set5ImmPred, u6_2ExtPred, ADDRriU6_2,
2902 SETMEMIMM, L4_ior_memopw_io, or>;
2905 //===----------------------------------------------------------------------===//
2906 // Multiclass to define 'def Pats' for ALU operations on the memory
2907 // where addend is a register.
2908 // mem[bhw](Rs+#0) [+-&|]= Rt
2909 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
2910 //===----------------------------------------------------------------------===//
2912 multiclass MemOpr_Pats <PatFrag ldOp, PatFrag stOp, ComplexPattern addrPred,
2913 PatLeaf extPred, InstHexagon MI, SDNode OpNode> {
2914 let AddedComplexity = 141 in
2915 // mem[bhw](Rs+#0) [+-&|]= Rt
2916 def: Pat<(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)),
2917 (i32 IntRegs:$addend)),
2918 (addrPred (i32 IntRegs:$addr), extPred:$offset)),
2919 (MI IntRegs:$addr, extPred:$offset, (i32 IntRegs:$addend) )>;
2921 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
2922 let AddedComplexity = 150 in
2923 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
2924 (i32 IntRegs:$orend)),
2925 (add IntRegs:$base, extPred:$offset)),
2926 (MI IntRegs:$base, extPred:$offset, (i32 IntRegs:$orend))>;
2929 multiclass MemOPr_ALUOp<PatFrag ldOp, PatFrag stOp,
2930 ComplexPattern addrPred, PatLeaf extPred,
2931 InstHexagon addMI, InstHexagon subMI,
2932 InstHexagon andMI, InstHexagon orMI > {
2934 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, addMI, add>;
2935 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, subMI, sub>;
2936 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, andMI, and>;
2937 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, orMI, or>;
2940 multiclass MemOPr_ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2942 defm: MemOPr_ALUOp <ldOpHalf, truncstorei16, ADDRriU6_1, u6_1ExtPred,
2943 L4_add_memoph_io, L4_sub_memoph_io,
2944 L4_and_memoph_io, L4_or_memoph_io>;
2946 defm: MemOPr_ALUOp <ldOpByte, truncstorei8, ADDRriU6_0, u6ExtPred,
2947 L4_add_memopb_io, L4_sub_memopb_io,
2948 L4_and_memopb_io, L4_or_memopb_io>;
2951 // Define 'def Pats' for MemOps with register addend.
2952 let Predicates = [UseMEMOP] in {
2954 defm: MemOPr_ExtType<zextloadi8, zextloadi16>; // zero extend
2955 defm: MemOPr_ExtType<sextloadi8, sextloadi16>; // sign extend
2956 defm: MemOPr_ExtType<extloadi8, extloadi16>; // any extend
2958 defm: MemOPr_ALUOp <load, store, ADDRriU6_2, u6_2ExtPred, L4_add_memopw_io,
2959 L4_sub_memopw_io, L4_and_memopw_io, L4_or_memopw_io>;
2962 //===----------------------------------------------------------------------===//
2964 //===----------------------------------------------------------------------===//
2966 // Hexagon V4 only supports these flavors of byte/half compare instructions:
2967 // EQ/GT/GTU. Other flavors like GE/GEU/LT/LTU/LE/LEU are not supported by
2968 // hardware. However, compiler can still implement these patterns through
2969 // appropriate patterns combinations based on current implemented patterns.
2970 // The implemented patterns are: EQ/GT/GTU.
2971 // Missing patterns are: GE/GEU/LT/LTU/LE/LEU.
2973 // Following instruction is not being extended as it results into the
2974 // incorrect code for negative numbers.
2975 // Pd=cmpb.eq(Rs,#u8)
2977 // p=!cmp.eq(r1,#s10)
2978 def C4_cmpneqi : T_CMP <"cmp.eq", 0b00, 1, s10Ext>;
2979 def C4_cmpltei : T_CMP <"cmp.gt", 0b01, 1, s10Ext>;
2980 def C4_cmplteui : T_CMP <"cmp.gtu", 0b10, 1, u9Ext>;
2982 def : T_CMP_pat <C4_cmpneqi, setne, s10ExtPred>;
2983 def : T_CMP_pat <C4_cmpltei, setle, s10ExtPred>;
2984 def : T_CMP_pat <C4_cmplteui, setule, u9ImmPred>;
2986 // rs <= rt -> !(rs > rt).
2988 def: Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
2989 (C2_not (C2_cmpgti IntRegs:$src1, s10ExtPred:$src2))>;
2990 // (C4_cmpltei IntRegs:$src1, s10ExtPred:$src2)>;
2992 // Map cmplt(Rs, Imm) -> !cmpgt(Rs, Imm-1).
2993 def: Pat<(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
2994 (C4_cmpltei IntRegs:$src1, (DEC_CONST_SIGNED s8ExtPred:$src2))>;
2996 // rs != rt -> !(rs == rt).
2997 def: Pat<(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
2998 (C4_cmpneqi IntRegs:$src1, s10ExtPred:$src2)>;
3000 // SDNode for converting immediate C to C-1.
3001 def DEC_CONST_BYTE : SDNodeXForm<imm, [{
3002 // Return the byte immediate const-1 as an SDNode.
3003 int32_t imm = N->getSExtValue();
3004 return XformU7ToU7M1Imm(imm);
3008 // zext( seteq ( and(Rs, 255), u8))
3010 // Pd=cmpb.eq(Rs, #u8)
3011 // if (Pd.new) Rd=#1
3012 // if (!Pd.new) Rd=#0
3013 def : Pat <(i32 (zext (i1 (seteq (i32 (and (i32 IntRegs:$Rs), 255)),
3015 (i32 (TFR_condset_ii (i1 (A4_cmpbeqi (i32 IntRegs:$Rs),
3020 // zext( setne ( and(Rs, 255), u8))
3022 // Pd=cmpb.eq(Rs, #u8)
3023 // if (Pd.new) Rd=#0
3024 // if (!Pd.new) Rd=#1
3025 def : Pat <(i32 (zext (i1 (setne (i32 (and (i32 IntRegs:$Rs), 255)),
3027 (i32 (TFR_condset_ii (i1 (A4_cmpbeqi (i32 IntRegs:$Rs),
3032 // zext( seteq (Rs, and(Rt, 255)))
3034 // Pd=cmpb.eq(Rs, Rt)
3035 // if (Pd.new) Rd=#1
3036 // if (!Pd.new) Rd=#0
3037 def : Pat <(i32 (zext (i1 (seteq (i32 IntRegs:$Rt),
3038 (i32 (and (i32 IntRegs:$Rs), 255)))))),
3039 (i32 (TFR_condset_ii (i1 (A4_cmpbeq (i32 IntRegs:$Rs),
3040 (i32 IntRegs:$Rt))),
3044 // zext( setne (Rs, and(Rt, 255)))
3046 // Pd=cmpb.eq(Rs, Rt)
3047 // if (Pd.new) Rd=#0
3048 // if (!Pd.new) Rd=#1
3049 def : Pat <(i32 (zext (i1 (setne (i32 IntRegs:$Rt),
3050 (i32 (and (i32 IntRegs:$Rs), 255)))))),
3051 (i32 (TFR_condset_ii (i1 (A4_cmpbeq (i32 IntRegs:$Rs),
3052 (i32 IntRegs:$Rt))),
3056 // zext( setugt ( and(Rs, 255), u8))
3058 // Pd=cmpb.gtu(Rs, #u8)
3059 // if (Pd.new) Rd=#1
3060 // if (!Pd.new) Rd=#0
3061 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 255)),
3063 (i32 (TFR_condset_ii (i1 (A4_cmpbgtui (i32 IntRegs:$Rs),
3068 // zext( setugt ( and(Rs, 254), u8))
3070 // Pd=cmpb.gtu(Rs, #u8)
3071 // if (Pd.new) Rd=#1
3072 // if (!Pd.new) Rd=#0
3073 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 254)),
3075 (i32 (TFR_condset_ii (i1 (A4_cmpbgtui (i32 IntRegs:$Rs),
3080 // zext( setult ( Rs, Rt))
3082 // Pd=cmp.ltu(Rs, Rt)
3083 // if (Pd.new) Rd=#1
3084 // if (!Pd.new) Rd=#0
3085 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs)
3086 def : Pat <(i32 (zext (i1 (setult (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3087 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt),
3088 (i32 IntRegs:$Rs))),
3092 // zext( setlt ( Rs, Rt))
3094 // Pd=cmp.lt(Rs, Rt)
3095 // if (Pd.new) Rd=#1
3096 // if (!Pd.new) Rd=#0
3097 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs)
3098 def : Pat <(i32 (zext (i1 (setlt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3099 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt),
3100 (i32 IntRegs:$Rs))),
3104 // zext( setugt ( Rs, Rt))
3106 // Pd=cmp.gtu(Rs, Rt)
3107 // if (Pd.new) Rd=#1
3108 // if (!Pd.new) Rd=#0
3109 def : Pat <(i32 (zext (i1 (setugt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3110 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs),
3111 (i32 IntRegs:$Rt))),
3114 // This pattern interefers with coremark performance, not implementing at this
3117 // zext( setgt ( Rs, Rt))
3119 // Pd=cmp.gt(Rs, Rt)
3120 // if (Pd.new) Rd=#1
3121 // if (!Pd.new) Rd=#0
3124 // zext( setuge ( Rs, Rt))
3126 // Pd=cmp.ltu(Rs, Rt)
3127 // if (Pd.new) Rd=#0
3128 // if (!Pd.new) Rd=#1
3129 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs)
3130 def : Pat <(i32 (zext (i1 (setuge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3131 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt),
3132 (i32 IntRegs:$Rs))),
3136 // zext( setge ( Rs, Rt))
3138 // Pd=cmp.lt(Rs, Rt)
3139 // if (Pd.new) Rd=#0
3140 // if (!Pd.new) Rd=#1
3141 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs)
3142 def : Pat <(i32 (zext (i1 (setge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3143 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt),
3144 (i32 IntRegs:$Rs))),
3148 // zext( setule ( Rs, Rt))
3150 // Pd=cmp.gtu(Rs, Rt)
3151 // if (Pd.new) Rd=#0
3152 // if (!Pd.new) Rd=#1
3153 def : Pat <(i32 (zext (i1 (setule (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3154 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs),
3155 (i32 IntRegs:$Rt))),
3159 // zext( setle ( Rs, Rt))
3161 // Pd=cmp.gt(Rs, Rt)
3162 // if (Pd.new) Rd=#0
3163 // if (!Pd.new) Rd=#1
3164 def : Pat <(i32 (zext (i1 (setle (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3165 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rs),
3166 (i32 IntRegs:$Rt))),
3170 // zext( setult ( and(Rs, 255), u8))
3171 // Use the isdigit transformation below
3173 // Generate code of the form 'C2_muxii(cmpbgtui(Rdd, C-1),0,1)'
3174 // for C code of the form r = ((c>='0') & (c<='9')) ? 1 : 0;.
3175 // The isdigit transformation relies on two 'clever' aspects:
3176 // 1) The data type is unsigned which allows us to eliminate a zero test after
3177 // biasing the expression by 48. We are depending on the representation of
3178 // the unsigned types, and semantics.
3179 // 2) The front end has converted <= 9 into < 10 on entry to LLVM
3182 // retval = ((c>='0') & (c<='9')) ? 1 : 0;
3183 // The code is transformed upstream of llvm into
3184 // retval = (c-48) < 10 ? 1 : 0;
3185 let AddedComplexity = 139 in
3186 def: Pat<(i32 (zext (i1 (setult (i32 (and (i32 IntRegs:$src1), 255)),
3187 u7StrictPosImmPred:$src2)))),
3188 (C2_muxii (A4_cmpbgtui IntRegs:$src1,
3189 (DEC_CONST_BYTE u7StrictPosImmPred:$src2)),
3192 //===----------------------------------------------------------------------===//
3194 //===----------------------------------------------------------------------===//
3196 //===----------------------------------------------------------------------===//
3197 // Multiclass for DeallocReturn
3198 //===----------------------------------------------------------------------===//
3199 class L4_RETURN<string mnemonic, bit isNot, bit isPredNew, bit isTak>
3200 : LD0Inst<(outs), (ins PredRegs:$src),
3201 !if(isNot, "if (!$src", "if ($src")#
3202 !if(isPredNew, ".new) ", ") ")#mnemonic#
3203 !if(isPredNew, #!if(isTak,":t", ":nt"),""),
3204 [], "", LD_tc_3or4stall_SLOT0> {
3207 let BaseOpcode = "L4_RETURN";
3208 let isPredicatedFalse = isNot;
3209 let isPredicatedNew = isPredNew;
3210 let isTaken = isTak;
3211 let IClass = 0b1001;
3213 let Inst{27-16} = 0b011000011110;
3215 let Inst{13} = isNot;
3216 let Inst{12} = isTak;
3217 let Inst{11} = isPredNew;
3219 let Inst{9-8} = src;
3220 let Inst{4-0} = 0b11110;
3223 // Produce all predicated forms, p, !p, p.new, !p.new, :t, :nt
3224 multiclass L4_RETURN_PRED<string mnemonic, bit PredNot> {
3225 let isPredicated = 1 in {
3226 def _#NAME# : L4_RETURN <mnemonic, PredNot, 0, 1>;
3227 def _#NAME#new_pnt : L4_RETURN <mnemonic, PredNot, 1, 0>;
3228 def _#NAME#new_pt : L4_RETURN <mnemonic, PredNot, 1, 1>;
3232 multiclass LD_MISC_L4_RETURN<string mnemonic> {
3233 let isBarrier = 1, isPredicable = 1 in
3234 def NAME : LD0Inst <(outs), (ins), mnemonic, [], "",
3235 LD_tc_3or4stall_SLOT0> {
3236 let BaseOpcode = "L4_RETURN";
3237 let IClass = 0b1001;
3238 let Inst{27-16} = 0b011000011110;
3239 let Inst{13-10} = 0b0000;
3240 let Inst{4-0} = 0b11110;
3242 defm t : L4_RETURN_PRED<mnemonic, 0 >;
3243 defm f : L4_RETURN_PRED<mnemonic, 1 >;
3246 let isReturn = 1, isTerminator = 1,
3247 Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0 in
3248 defm L4_return: LD_MISC_L4_RETURN <"dealloc_return">, PredNewRel;
3250 // Restore registers and dealloc return function call.
3251 let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1,
3252 Defs = [R29, R30, R31, PC], isPredicable = 0, isAsmParserOnly = 1 in {
3253 def RESTORE_DEALLOC_RET_JMP_V4 : JInst<(outs),
3254 (ins calltarget:$dst),
3259 // Restore registers and dealloc frame before a tail call.
3260 let isCall = 1, Defs = [R29, R30, R31, PC], isAsmParserOnly = 1 in {
3261 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : JInst<(outs),
3262 (ins calltarget:$dst),
3267 // Save registers function call.
3268 let isCall = 1, Uses = [R29, R31], isAsmParserOnly = 1 in {
3269 def SAVE_REGISTERS_CALL_V4 : JInst<(outs),
3270 (ins calltarget:$dst),
3271 "call $dst // Save_calle_saved_registers",
3275 //===----------------------------------------------------------------------===//
3276 // Template class for non predicated store instructions with
3277 // GP-Relative or absolute addressing.
3278 //===----------------------------------------------------------------------===//
3279 let hasSideEffects = 0, isPredicable = 1, isNVStorable = 1 in
3280 class T_StoreAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3281 bits<2>MajOp, Operand AddrOp, bit isAbs, bit isHalf>
3282 : STInst<(outs), (ins AddrOp:$addr, RC:$src),
3283 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src"#!if(isHalf, ".h",""),
3284 [], "", V2LDST_tc_st_SLOT01> {
3287 bits<16> offsetBits;
3289 string ImmOpStr = !cast<string>(ImmOp);
3290 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3291 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3292 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3293 /* u16_0Imm */ addr{15-0})));
3294 let IClass = 0b0100;
3296 let Inst{26-25} = offsetBits{15-14};
3298 let Inst{23-22} = MajOp;
3299 let Inst{21} = isHalf;
3300 let Inst{20-16} = offsetBits{13-9};
3301 let Inst{13} = offsetBits{8};
3302 let Inst{12-8} = src;
3303 let Inst{7-0} = offsetBits{7-0};
3306 //===----------------------------------------------------------------------===//
3307 // Template class for predicated store instructions with
3308 // GP-Relative or absolute addressing.
3309 //===----------------------------------------------------------------------===//
3310 let hasSideEffects = 0, isPredicated = 1, isNVStorable = 1, opExtentBits = 6,
3312 class T_StoreAbs_Pred <string mnemonic, RegisterClass RC, bits<2> MajOp,
3313 bit isHalf, bit isNot, bit isNew>
3314 : STInst<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, RC: $src2),
3315 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3316 ") ")#mnemonic#"(#$absaddr) = $src2"#!if(isHalf, ".h",""),
3317 [], "", ST_tc_st_SLOT01>, AddrModeRel {
3322 let isPredicatedNew = isNew;
3323 let isPredicatedFalse = isNot;
3325 let IClass = 0b1010;
3327 let Inst{27-24} = 0b1111;
3328 let Inst{23-22} = MajOp;
3329 let Inst{21} = isHalf;
3330 let Inst{17-16} = absaddr{5-4};
3331 let Inst{13} = isNew;
3332 let Inst{12-8} = src2;
3334 let Inst{6-3} = absaddr{3-0};
3335 let Inst{2} = isNot;
3336 let Inst{1-0} = src1;
3339 //===----------------------------------------------------------------------===//
3340 // Template class for predicated store instructions with absolute addressing.
3341 //===----------------------------------------------------------------------===//
3342 class T_StoreAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3343 bits<2> MajOp, bit isHalf>
3344 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, u0AlwaysExt, 1, isHalf>,
3346 string ImmOpStr = !cast<string>(ImmOp);
3347 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3348 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3349 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3350 /* u16_0Imm */ 16)));
3352 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3353 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3354 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3355 /* u16_0Imm */ 0)));
3358 //===----------------------------------------------------------------------===//
3359 // Multiclass for store instructions with absolute addressing.
3360 //===----------------------------------------------------------------------===//
3361 let addrMode = Absolute, isExtended = 1 in
3362 multiclass ST_Abs<string mnemonic, string CextOp, RegisterClass RC,
3363 Operand ImmOp, bits<2> MajOp, bit isHalf = 0> {
3364 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3365 let opExtendable = 0, isPredicable = 1 in
3366 def S2_#NAME#abs : T_StoreAbs <mnemonic, RC, ImmOp, MajOp, isHalf>;
3369 def S4_p#NAME#t_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 0>;
3370 def S4_p#NAME#f_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 0>;
3373 def S4_p#NAME#tnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 1>;
3374 def S4_p#NAME#fnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 1>;
3378 //===----------------------------------------------------------------------===//
3379 // Template class for non predicated new-value store instructions with
3380 // GP-Relative or absolute addressing.
3381 //===----------------------------------------------------------------------===//
3382 let hasSideEffects = 0, isPredicable = 1, mayStore = 1, isNVStore = 1,
3383 isNewValue = 1, opNewValue = 1 in
3384 class T_StoreAbsGP_NV <string mnemonic, Operand ImmOp, bits<2>MajOp, bit isAbs>
3385 : NVInst_V4<(outs), (ins u0AlwaysExt:$addr, IntRegs:$src),
3386 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src.new",
3387 [], "", V2LDST_tc_st_SLOT0> {
3390 bits<16> offsetBits;
3392 string ImmOpStr = !cast<string>(ImmOp);
3393 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3394 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3395 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3396 /* u16_0Imm */ addr{15-0})));
3397 let IClass = 0b0100;
3400 let Inst{26-25} = offsetBits{15-14};
3401 let Inst{24-21} = 0b0101;
3402 let Inst{20-16} = offsetBits{13-9};
3403 let Inst{13} = offsetBits{8};
3404 let Inst{12-11} = MajOp;
3405 let Inst{10-8} = src;
3406 let Inst{7-0} = offsetBits{7-0};
3409 //===----------------------------------------------------------------------===//
3410 // Template class for predicated new-value store instructions with
3411 // absolute addressing.
3412 //===----------------------------------------------------------------------===//
3413 let hasSideEffects = 0, isPredicated = 1, mayStore = 1, isNVStore = 1,
3414 isNewValue = 1, opNewValue = 2, opExtentBits = 6, opExtendable = 1 in
3415 class T_StoreAbs_NV_Pred <string mnemonic, bits<2> MajOp, bit isNot, bit isNew>
3416 : NVInst_V4<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, IntRegs:$src2),
3417 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3418 ") ")#mnemonic#"(#$absaddr) = $src2.new",
3419 [], "", ST_tc_st_SLOT0>, AddrModeRel {
3424 let isPredicatedNew = isNew;
3425 let isPredicatedFalse = isNot;
3427 let IClass = 0b1010;
3429 let Inst{27-24} = 0b1111;
3430 let Inst{23-21} = 0b101;
3431 let Inst{17-16} = absaddr{5-4};
3432 let Inst{13} = isNew;
3433 let Inst{12-11} = MajOp;
3434 let Inst{10-8} = src2;
3436 let Inst{6-3} = absaddr{3-0};
3437 let Inst{2} = isNot;
3438 let Inst{1-0} = src1;
3441 //===----------------------------------------------------------------------===//
3442 // Template class for non-predicated new-value store instructions with
3443 // absolute addressing.
3444 //===----------------------------------------------------------------------===//
3445 class T_StoreAbs_NV <string mnemonic, Operand ImmOp, bits<2> MajOp>
3446 : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 1>, AddrModeRel {
3448 string ImmOpStr = !cast<string>(ImmOp);
3449 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3450 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3451 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3452 /* u16_0Imm */ 16)));
3454 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3455 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3456 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3457 /* u16_0Imm */ 0)));
3460 //===----------------------------------------------------------------------===//
3461 // Multiclass for new-value store instructions with absolute addressing.
3462 //===----------------------------------------------------------------------===//
3463 let addrMode = Absolute, isExtended = 1 in
3464 multiclass ST_Abs_NV <string mnemonic, string CextOp, Operand ImmOp,
3466 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3467 let opExtendable = 0, isPredicable = 1 in
3468 def S2_#NAME#newabs : T_StoreAbs_NV <mnemonic, ImmOp, MajOp>;
3471 def S4_p#NAME#newt_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 0>;
3472 def S4_p#NAME#newf_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 0>;
3475 def S4_p#NAME#newtnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 1>;
3476 def S4_p#NAME#newfnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 1>;
3480 //===----------------------------------------------------------------------===//
3481 // Stores with absolute addressing
3482 //===----------------------------------------------------------------------===//
3483 let accessSize = ByteAccess in
3484 defm storerb : ST_Abs <"memb", "STrib", IntRegs, u16_0Imm, 0b00>,
3485 ST_Abs_NV <"memb", "STrib", u16_0Imm, 0b00>;
3487 let accessSize = HalfWordAccess in
3488 defm storerh : ST_Abs <"memh", "STrih", IntRegs, u16_1Imm, 0b01>,
3489 ST_Abs_NV <"memh", "STrih", u16_1Imm, 0b01>;
3491 let accessSize = WordAccess in
3492 defm storeri : ST_Abs <"memw", "STriw", IntRegs, u16_2Imm, 0b10>,
3493 ST_Abs_NV <"memw", "STriw", u16_2Imm, 0b10>;
3495 let isNVStorable = 0, accessSize = DoubleWordAccess in
3496 defm storerd : ST_Abs <"memd", "STrid", DoubleRegs, u16_3Imm, 0b11>;
3498 let isNVStorable = 0, accessSize = HalfWordAccess in
3499 defm storerf : ST_Abs <"memh", "STrif", IntRegs, u16_1Imm, 0b01, 1>;
3501 //===----------------------------------------------------------------------===//
3502 // GP-relative stores.
3503 // mem[bhwd](#global)=Rt
3504 // Once predicated, these instructions map to absolute addressing mode.
3505 // if ([!]Pv[.new]) mem[bhwd](##global)=Rt
3506 //===----------------------------------------------------------------------===//
3508 let isAsmParserOnly = 1 in
3509 class T_StoreGP <string mnemonic, string BaseOp, RegisterClass RC,
3510 Operand ImmOp, bits<2> MajOp, bit isHalf = 0>
3511 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0, isHalf> {
3512 // Set BaseOpcode same as absolute addressing instructions so that
3513 // non-predicated GP-Rel instructions can have relate with predicated
3514 // Absolute instruction.
3515 let BaseOpcode = BaseOp#_abs;
3518 let isAsmParserOnly = 1 in
3519 multiclass ST_GP <string mnemonic, string BaseOp, Operand ImmOp,
3520 bits<2> MajOp, bit isHalf = 0> {
3521 // Set BaseOpcode same as absolute addressing instructions so that
3522 // non-predicated GP-Rel instructions can have relate with predicated
3523 // Absolute instruction.
3524 let BaseOpcode = BaseOp#_abs in {
3525 def NAME#gp : T_StoreAbsGP <mnemonic, IntRegs, ImmOp, MajOp,
3526 globaladdress, 0, isHalf>;
3528 def NAME#newgp : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 0> ;
3532 let accessSize = ByteAccess in
3533 defm S2_storerb : ST_GP<"memb", "STrib", u16_0Imm, 0b00>, NewValueRel;
3535 let accessSize = HalfWordAccess in
3536 defm S2_storerh : ST_GP<"memh", "STrih", u16_1Imm, 0b01>, NewValueRel;
3538 let accessSize = WordAccess in
3539 defm S2_storeri : ST_GP<"memw", "STriw", u16_2Imm, 0b10>, NewValueRel;
3541 let isNVStorable = 0, accessSize = DoubleWordAccess in
3542 def S2_storerdgp : T_StoreGP <"memd", "STrid", DoubleRegs,
3543 u16_3Imm, 0b11>, PredNewRel;
3545 let isNVStorable = 0, accessSize = HalfWordAccess in
3546 def S2_storerfgp : T_StoreGP <"memh", "STrif", IntRegs,
3547 u16_1Imm, 0b01, 1>, PredNewRel;
3549 class Loada_pat<PatFrag Load, ValueType VT, PatFrag Addr, InstHexagon MI>
3550 : Pat<(VT (Load Addr:$addr)), (MI Addr:$addr)>;
3552 class Loadam_pat<PatFrag Load, ValueType VT, PatFrag Addr, PatFrag ValueMod,
3554 : Pat<(VT (Load Addr:$addr)), (ValueMod (MI Addr:$addr))>;
3556 class Storea_pat<PatFrag Store, PatFrag Value, PatFrag Addr, InstHexagon MI>
3557 : Pat<(Store Value:$val, Addr:$addr), (MI Addr:$addr, Value:$val)>;
3559 class Stoream_pat<PatFrag Store, PatFrag Value, PatFrag Addr, PatFrag ValueMod,
3561 : Pat<(Store Value:$val, Addr:$addr),
3562 (MI Addr:$addr, (ValueMod Value:$val))>;
3564 def: Storea_pat<SwapSt<atomic_store_8>, I32, addrgp, S2_storerbgp>;
3565 def: Storea_pat<SwapSt<atomic_store_16>, I32, addrgp, S2_storerhgp>;
3566 def: Storea_pat<SwapSt<atomic_store_32>, I32, addrgp, S2_storerigp>;
3567 def: Storea_pat<SwapSt<atomic_store_64>, I64, addrgp, S2_storerdgp>;
3569 let AddedComplexity = 100 in {
3570 def: Storea_pat<truncstorei8, I32, addrgp, S2_storerbgp>;
3571 def: Storea_pat<truncstorei16, I32, addrgp, S2_storerhgp>;
3572 def: Storea_pat<store, I32, addrgp, S2_storerigp>;
3573 def: Storea_pat<store, I64, addrgp, S2_storerdgp>;
3575 // Map from "i1 = constant<-1>; memw(CONST32(#foo)) = i1"
3576 // to "r0 = 1; memw(#foo) = r0"
3577 let AddedComplexity = 100 in
3578 def: Pat<(store (i1 -1), (HexagonCONST32_GP tglobaladdr:$global)),
3579 (S2_storerbgp tglobaladdr:$global, (A2_tfrsi 1))>;
3582 //===----------------------------------------------------------------------===//
3583 // Template class for non predicated load instructions with
3584 // absolute addressing mode.
3585 //===----------------------------------------------------------------------===//
3586 let isPredicable = 1, hasSideEffects = 0 in
3587 class T_LoadAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3588 bits<3> MajOp, Operand AddrOp, bit isAbs>
3589 : LDInst <(outs RC:$dst), (ins AddrOp:$addr),
3590 "$dst = "#mnemonic# !if(isAbs, "(##", "(#")#"$addr)",
3591 [], "", V2LDST_tc_ld_SLOT01> {
3594 bits<16> offsetBits;
3596 string ImmOpStr = !cast<string>(ImmOp);
3597 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3598 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3599 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3600 /* u16_0Imm */ addr{15-0})));
3602 let IClass = 0b0100;
3605 let Inst{26-25} = offsetBits{15-14};
3607 let Inst{23-21} = MajOp;
3608 let Inst{20-16} = offsetBits{13-9};
3609 let Inst{13-5} = offsetBits{8-0};
3610 let Inst{4-0} = dst;
3613 class T_LoadAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3615 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, u0AlwaysExt, 1>, AddrModeRel {
3617 string ImmOpStr = !cast<string>(ImmOp);
3618 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3619 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3620 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3621 /* u16_0Imm */ 16)));
3623 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3624 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3625 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3626 /* u16_0Imm */ 0)));
3629 //===----------------------------------------------------------------------===//
3630 // Template class for predicated load instructions with
3631 // absolute addressing mode.
3632 //===----------------------------------------------------------------------===//
3633 let isPredicated = 1, opExtentBits = 6, opExtendable = 2 in
3634 class T_LoadAbs_Pred <string mnemonic, RegisterClass RC, bits<3> MajOp,
3635 bit isPredNot, bit isPredNew>
3636 : LDInst <(outs RC:$dst), (ins PredRegs:$src1, u6Ext:$absaddr),
3637 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3638 ") ")#"$dst = "#mnemonic#"(#$absaddr)">, AddrModeRel {
3643 let isPredicatedNew = isPredNew;
3644 let isPredicatedFalse = isPredNot;
3645 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
3647 let IClass = 0b1001;
3649 let Inst{27-24} = 0b1111;
3650 let Inst{23-21} = MajOp;
3651 let Inst{20-16} = absaddr{5-1};
3653 let Inst{12} = isPredNew;
3654 let Inst{11} = isPredNot;
3655 let Inst{10-9} = src1;
3656 let Inst{8} = absaddr{0};
3658 let Inst{4-0} = dst;
3661 //===----------------------------------------------------------------------===//
3662 // Multiclass for the load instructions with absolute addressing mode.
3663 //===----------------------------------------------------------------------===//
3664 multiclass LD_Abs_Pred<string mnemonic, RegisterClass RC, bits<3> MajOp,
3666 def _abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 0>;
3668 def new_abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 1>;
3671 let addrMode = Absolute, isExtended = 1 in
3672 multiclass LD_Abs<string mnemonic, string CextOp, RegisterClass RC,
3673 Operand ImmOp, bits<3> MajOp> {
3674 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3675 let opExtendable = 1, isPredicable = 1 in
3676 def L4_#NAME#_abs: T_LoadAbs <mnemonic, RC, ImmOp, MajOp>;
3679 defm L4_p#NAME#t : LD_Abs_Pred<mnemonic, RC, MajOp, 0>;
3680 defm L4_p#NAME#f : LD_Abs_Pred<mnemonic, RC, MajOp, 1>;
3684 let accessSize = ByteAccess, hasNewValue = 1 in {
3685 defm loadrb : LD_Abs<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3686 defm loadrub : LD_Abs<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3689 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3690 defm loadrh : LD_Abs<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3691 defm loadruh : LD_Abs<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3694 let accessSize = WordAccess, hasNewValue = 1 in
3695 defm loadri : LD_Abs<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3697 let accessSize = DoubleWordAccess in
3698 defm loadrd : LD_Abs<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3700 //===----------------------------------------------------------------------===//
3701 // multiclass for load instructions with GP-relative addressing mode.
3702 // Rx=mem[bhwd](##global)
3703 // Once predicated, these instructions map to absolute addressing mode.
3704 // if ([!]Pv[.new]) Rx=mem[bhwd](##global)
3705 //===----------------------------------------------------------------------===//
3707 let isAsmParserOnly = 1 in
3708 class T_LoadGP <string mnemonic, string BaseOp, RegisterClass RC, Operand ImmOp,
3710 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0>, PredNewRel {
3711 let BaseOpcode = BaseOp#_abs;
3714 let accessSize = ByteAccess, hasNewValue = 1 in {
3715 def L2_loadrbgp : T_LoadGP<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3716 def L2_loadrubgp : T_LoadGP<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3719 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3720 def L2_loadrhgp : T_LoadGP<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3721 def L2_loadruhgp : T_LoadGP<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3724 let accessSize = WordAccess, hasNewValue = 1 in
3725 def L2_loadrigp : T_LoadGP<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3727 let accessSize = DoubleWordAccess in
3728 def L2_loadrdgp : T_LoadGP<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3730 def: Loada_pat<atomic_load_8, i32, addrgp, L2_loadrubgp>;
3731 def: Loada_pat<atomic_load_16, i32, addrgp, L2_loadruhgp>;
3732 def: Loada_pat<atomic_load_32, i32, addrgp, L2_loadrigp>;
3733 def: Loada_pat<atomic_load_64, i64, addrgp, L2_loadrdgp>;
3735 // Map from load(globaladdress) -> mem[u][bhwd](#foo)
3736 class LoadGP_pats <PatFrag ldOp, InstHexagon MI, ValueType VT = i32>
3737 : Pat <(VT (ldOp (HexagonCONST32_GP tglobaladdr:$global))),
3738 (VT (MI tglobaladdr:$global))>;
3740 let AddedComplexity = 100 in {
3741 def: LoadGP_pats <extloadi8, L2_loadrbgp>;
3742 def: LoadGP_pats <sextloadi8, L2_loadrbgp>;
3743 def: LoadGP_pats <zextloadi8, L2_loadrubgp>;
3744 def: LoadGP_pats <extloadi16, L2_loadrhgp>;
3745 def: LoadGP_pats <sextloadi16, L2_loadrhgp>;
3746 def: LoadGP_pats <zextloadi16, L2_loadruhgp>;
3747 def: LoadGP_pats <load, L2_loadrigp>;
3748 def: LoadGP_pats <load, L2_loadrdgp, i64>;
3751 // When the Interprocedural Global Variable optimizer realizes that a certain
3752 // global variable takes only two constant values, it shrinks the global to
3753 // a boolean. Catch those loads here in the following 3 patterns.
3754 let AddedComplexity = 100 in {
3755 def: LoadGP_pats <extloadi1, L2_loadrubgp>;
3756 def: LoadGP_pats <zextloadi1, L2_loadrubgp>;
3759 def: Pat<(i64 (ctlz I64:$src1)), (Zext64 (S2_cl0p I64:$src1))>;
3760 def: Pat<(i64 (cttz I64:$src1)), (Zext64 (S2_ct0p I64:$src1))>;
3762 let AddedComplexity = 30 in {
3763 def: Storea_pat<truncstorei8, I32, u0AlwaysExtPred, S2_storerbabs>;
3764 def: Storea_pat<truncstorei16, I32, u0AlwaysExtPred, S2_storerhabs>;
3765 def: Storea_pat<store, I32, u0AlwaysExtPred, S2_storeriabs>;
3768 let AddedComplexity = 30 in {
3769 def: Loada_pat<load, i32, u0AlwaysExtPred, L4_loadri_abs>;
3770 def: Loada_pat<sextloadi8, i32, u0AlwaysExtPred, L4_loadrb_abs>;
3771 def: Loada_pat<zextloadi8, i32, u0AlwaysExtPred, L4_loadrub_abs>;
3772 def: Loada_pat<sextloadi16, i32, u0AlwaysExtPred, L4_loadrh_abs>;
3773 def: Loada_pat<zextloadi16, i32, u0AlwaysExtPred, L4_loadruh_abs>;
3776 // Indexed store word - global address.
3777 // memw(Rs+#u6:2)=#S8
3778 let AddedComplexity = 100 in
3779 def: Storex_add_pat<store, addrga, u6_2ImmPred, S4_storeiri_io>;
3781 // Load from a global address that has only one use in the current basic block.
3782 let AddedComplexity = 100 in {
3783 def: Loada_pat<extloadi8, i32, addrga, L4_loadrub_abs>;
3784 def: Loada_pat<sextloadi8, i32, addrga, L4_loadrb_abs>;
3785 def: Loada_pat<zextloadi8, i32, addrga, L4_loadrub_abs>;
3787 def: Loada_pat<extloadi16, i32, addrga, L4_loadruh_abs>;
3788 def: Loada_pat<sextloadi16, i32, addrga, L4_loadrh_abs>;
3789 def: Loada_pat<zextloadi16, i32, addrga, L4_loadruh_abs>;
3791 def: Loada_pat<load, i32, addrga, L4_loadri_abs>;
3792 def: Loada_pat<load, i64, addrga, L4_loadrd_abs>;
3795 // Store to a global address that has only one use in the current basic block.
3796 let AddedComplexity = 100 in {
3797 def: Storea_pat<truncstorei8, I32, addrga, S2_storerbabs>;
3798 def: Storea_pat<truncstorei16, I32, addrga, S2_storerhabs>;
3799 def: Storea_pat<store, I32, addrga, S2_storeriabs>;
3800 def: Storea_pat<store, I64, addrga, S2_storerdabs>;
3802 def: Stoream_pat<truncstorei32, I64, addrga, LoReg, S2_storeriabs>;
3805 // Map from Pd = load(globaladdress) -> Rd = memb(globaladdress), Pd = Rd
3806 let AddedComplexity = 100 in
3807 def : Pat <(i1 (load (HexagonCONST32_GP tglobaladdr:$global))),
3808 (i1 (C2_tfrrp (i32 (L2_loadrbgp tglobaladdr:$global))))>;
3810 // Transfer global address into a register
3811 let isExtended = 1, opExtendable = 1, AddedComplexity=50, isMoveImm = 1,
3812 isAsCheapAsAMove = 1, isReMaterializable = 1, isCodeGenOnly = 1 in
3813 def TFRI_V4 : ALU32_ri<(outs IntRegs:$dst), (ins s16Ext:$src1),
3815 [(set IntRegs:$dst, (HexagonCONST32 tglobaladdr:$src1))]>;
3817 // Transfer a block address into a register
3818 def : Pat<(HexagonCONST32_GP tblockaddress:$src1),
3819 (TFRI_V4 tblockaddress:$src1)>;
3821 let AddedComplexity = 50 in
3822 def : Pat<(HexagonCONST32_GP tglobaladdr:$src1),
3823 (TFRI_V4 tglobaladdr:$src1)>;
3825 // i8/i16/i32 -> i64 loads
3826 // We need a complexity of 120 here to override preceding handling of
3828 let AddedComplexity = 120 in {
3829 def: Loadam_pat<extloadi8, i64, addrga, Zext64, L4_loadrub_abs>;
3830 def: Loadam_pat<sextloadi8, i64, addrga, Sext64, L4_loadrb_abs>;
3831 def: Loadam_pat<zextloadi8, i64, addrga, Zext64, L4_loadrub_abs>;
3833 def: Loadam_pat<extloadi16, i64, addrga, Zext64, L4_loadruh_abs>;
3834 def: Loadam_pat<sextloadi16, i64, addrga, Sext64, L4_loadrh_abs>;
3835 def: Loadam_pat<zextloadi16, i64, addrga, Zext64, L4_loadruh_abs>;
3837 def: Loadam_pat<extloadi32, i64, addrga, Zext64, L4_loadri_abs>;
3838 def: Loadam_pat<sextloadi32, i64, addrga, Sext64, L4_loadri_abs>;
3839 def: Loadam_pat<zextloadi32, i64, addrga, Zext64, L4_loadri_abs>;
3842 let AddedComplexity = 100 in {
3843 def: Loada_pat<extloadi8, i32, addrgp, L4_loadrub_abs>;
3844 def: Loada_pat<sextloadi8, i32, addrgp, L4_loadrb_abs>;
3845 def: Loada_pat<zextloadi8, i32, addrgp, L4_loadrub_abs>;
3847 def: Loada_pat<extloadi16, i32, addrgp, L4_loadruh_abs>;
3848 def: Loada_pat<sextloadi16, i32, addrgp, L4_loadrh_abs>;
3849 def: Loada_pat<zextloadi16, i32, addrgp, L4_loadruh_abs>;
3851 def: Loada_pat<load, i32, addrgp, L4_loadri_abs>;
3852 def: Loada_pat<load, i64, addrgp, L4_loadrd_abs>;
3855 let AddedComplexity = 100 in {
3856 def: Storea_pat<truncstorei8, I32, addrgp, S2_storerbabs>;
3857 def: Storea_pat<truncstorei16, I32, addrgp, S2_storerhabs>;
3858 def: Storea_pat<store, I32, addrgp, S2_storeriabs>;
3859 def: Storea_pat<store, I64, addrgp, S2_storerdabs>;
3862 def: Loada_pat<atomic_load_8, i32, addrgp, L4_loadrub_abs>;
3863 def: Loada_pat<atomic_load_16, i32, addrgp, L4_loadruh_abs>;
3864 def: Loada_pat<atomic_load_32, i32, addrgp, L4_loadri_abs>;
3865 def: Loada_pat<atomic_load_64, i64, addrgp, L4_loadrd_abs>;
3867 def: Storea_pat<SwapSt<atomic_store_8>, I32, addrgp, S2_storerbabs>;
3868 def: Storea_pat<SwapSt<atomic_store_16>, I32, addrgp, S2_storerhabs>;
3869 def: Storea_pat<SwapSt<atomic_store_32>, I32, addrgp, S2_storeriabs>;
3870 def: Storea_pat<SwapSt<atomic_store_64>, I64, addrgp, S2_storerdabs>;
3872 //===----------------------------------------------------------------------===//
3873 // :raw for of boundscheck:hi:lo insns
3874 //===----------------------------------------------------------------------===//
3876 // A4_boundscheck_lo: Detect if a register is within bounds.
3877 let hasSideEffects = 0 in
3878 def A4_boundscheck_lo: ALU64Inst <
3879 (outs PredRegs:$Pd),
3880 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3881 "$Pd = boundscheck($Rss, $Rtt):raw:lo"> {
3886 let IClass = 0b1101;
3888 let Inst{27-23} = 0b00100;
3890 let Inst{7-5} = 0b100;
3892 let Inst{20-16} = Rss;
3893 let Inst{12-8} = Rtt;
3896 // A4_boundscheck_hi: Detect if a register is within bounds.
3897 let hasSideEffects = 0 in
3898 def A4_boundscheck_hi: ALU64Inst <
3899 (outs PredRegs:$Pd),
3900 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3901 "$Pd = boundscheck($Rss, $Rtt):raw:hi"> {
3906 let IClass = 0b1101;
3908 let Inst{27-23} = 0b00100;
3910 let Inst{7-5} = 0b101;
3912 let Inst{20-16} = Rss;
3913 let Inst{12-8} = Rtt;
3916 let hasSideEffects = 0, isAsmParserOnly = 1 in
3917 def A4_boundscheck : MInst <
3918 (outs PredRegs:$Pd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
3919 "$Pd=boundscheck($Rs,$Rtt)">;
3921 // A4_tlbmatch: Detect if a VA/ASID matches a TLB entry.
3922 let isPredicateLate = 1, hasSideEffects = 0 in
3923 def A4_tlbmatch : ALU64Inst<(outs PredRegs:$Pd),
3924 (ins DoubleRegs:$Rs, IntRegs:$Rt),
3925 "$Pd = tlbmatch($Rs, $Rt)",
3926 [], "", ALU64_tc_2early_SLOT23> {
3931 let IClass = 0b1101;
3932 let Inst{27-23} = 0b00100;
3933 let Inst{20-16} = Rs;
3935 let Inst{12-8} = Rt;
3936 let Inst{7-5} = 0b011;
3940 // We need custom lowering of ISD::PREFETCH into HexagonISD::DCFETCH
3941 // because the SDNode ISD::PREFETCH has properties MayLoad and MayStore.
3942 // We don't really want either one here.
3943 def SDTHexagonDCFETCH : SDTypeProfile<0, 2, [SDTCisPtrTy<0>,SDTCisInt<1>]>;
3944 def HexagonDCFETCH : SDNode<"HexagonISD::DCFETCH", SDTHexagonDCFETCH,
3947 // Use LD0Inst for dcfetch, but set "mayLoad" to 0 because this doesn't
3948 // really do a load.
3949 let hasSideEffects = 1, mayLoad = 0 in
3950 def Y2_dcfetchbo : LD0Inst<(outs), (ins IntRegs:$Rs, u11_3Imm:$u11_3),
3951 "dcfetch($Rs + #$u11_3)",
3952 [(HexagonDCFETCH IntRegs:$Rs, u11_3ImmPred:$u11_3)],
3953 "", LD_tc_ld_SLOT0> {
3957 let IClass = 0b1001;
3958 let Inst{27-21} = 0b0100000;
3959 let Inst{20-16} = Rs;
3961 let Inst{10-0} = u11_3{13-3};
3964 //===----------------------------------------------------------------------===//
3965 // Compound instructions
3966 //===----------------------------------------------------------------------===//
3968 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
3969 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1,
3970 opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
3972 class CJInst_tstbit_R0<string px, bit np, string tnt>
3973 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
3974 ""#px#" = tstbit($Rs, #0); if ("
3975 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
3976 [], "", COMPOUND, TypeCOMPOUND> {
3981 let isPredicatedFalse = np;
3982 // tnt: Taken/Not Taken
3983 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
3984 let isTaken = !if (!eq(tnt, "t"), 1, 0);
3986 let IClass = 0b0001;
3987 let Inst{27-26} = 0b00;
3988 let Inst{25} = !if (!eq(px, "!p1"), 1,
3989 !if (!eq(px, "p1"), 1, 0));
3990 let Inst{24-23} = 0b11;
3992 let Inst{21-20} = r9_2{10-9};
3993 let Inst{19-16} = Rs;
3994 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
3995 let Inst{9-8} = 0b11;
3996 let Inst{7-1} = r9_2{8-2};
3999 let Defs = [PC, P0], Uses = [P0] in {
4000 def J4_tstbit0_tp0_jump_nt : CJInst_tstbit_R0<"p0", 0, "nt">;
4001 def J4_tstbit0_tp0_jump_t : CJInst_tstbit_R0<"p0", 0, "t">;
4002 def J4_tstbit0_fp0_jump_nt : CJInst_tstbit_R0<"p0", 1, "nt">;
4003 def J4_tstbit0_fp0_jump_t : CJInst_tstbit_R0<"p0", 1, "t">;
4006 let Defs = [PC, P1], Uses = [P1] in {
4007 def J4_tstbit0_tp1_jump_nt : CJInst_tstbit_R0<"p1", 0, "nt">;
4008 def J4_tstbit0_tp1_jump_t : CJInst_tstbit_R0<"p1", 0, "t">;
4009 def J4_tstbit0_fp1_jump_nt : CJInst_tstbit_R0<"p1", 1, "nt">;
4010 def J4_tstbit0_fp1_jump_t : CJInst_tstbit_R0<"p1", 1, "t">;
4014 let isBranch = 1, hasSideEffects = 0,
4015 isExtentSigned = 1, isPredicated = 1, isPredicatedNew = 1,
4016 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2,
4017 opExtendable = 2, isTerminator = 1 in
4018 class CJInst_RR<string px, string op, bit np, string tnt>
4019 : InstHexagon<(outs), (ins IntRegs:$Rs, IntRegs:$Rt, brtarget:$r9_2),
4020 ""#px#" = cmp."#op#"($Rs, $Rt); if ("
4021 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4022 [], "", COMPOUND, TypeCOMPOUND> {
4028 let isPredicatedFalse = np;
4029 // tnt: Taken/Not Taken
4030 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4031 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4033 let IClass = 0b0001;
4034 let Inst{27-23} = !if (!eq(op, "eq"), 0b01000,
4035 !if (!eq(op, "gt"), 0b01001,
4036 !if (!eq(op, "gtu"), 0b01010, 0)));
4038 let Inst{21-20} = r9_2{10-9};
4039 let Inst{19-16} = Rs;
4040 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4041 // px: Predicate reg 0/1
4042 let Inst{12} = !if (!eq(px, "!p1"), 1,
4043 !if (!eq(px, "p1"), 1, 0));
4044 let Inst{11-8} = Rt;
4045 let Inst{7-1} = r9_2{8-2};
4048 // P[10] taken/not taken.
4049 multiclass T_tnt_CJInst_RR<string op, bit np> {
4050 let Defs = [PC, P0], Uses = [P0] in {
4051 def NAME#p0_jump_nt : CJInst_RR<"p0", op, np, "nt">;
4052 def NAME#p0_jump_t : CJInst_RR<"p0", op, np, "t">;
4054 let Defs = [PC, P1], Uses = [P1] in {
4055 def NAME#p1_jump_nt : CJInst_RR<"p1", op, np, "nt">;
4056 def NAME#p1_jump_t : CJInst_RR<"p1", op, np, "t">;
4059 // Predicate / !Predicate
4060 multiclass T_pnp_CJInst_RR<string op>{
4061 defm J4_cmp#NAME#_t : T_tnt_CJInst_RR<op, 0>;
4062 defm J4_cmp#NAME#_f : T_tnt_CJInst_RR<op, 1>;
4064 // TypeCJ Instructions compare RR and jump
4065 defm eq : T_pnp_CJInst_RR<"eq">;
4066 defm gt : T_pnp_CJInst_RR<"gt">;
4067 defm gtu : T_pnp_CJInst_RR<"gtu">;
4069 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4070 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1, opExtentBits = 11,
4071 opExtentAlign = 2, opExtendable = 2, isTerminator = 1 in
4072 class CJInst_RU5<string px, string op, bit np, string tnt>
4073 : InstHexagon<(outs), (ins IntRegs:$Rs, u5Imm:$U5, brtarget:$r9_2),
4074 ""#px#" = cmp."#op#"($Rs, #$U5); if ("
4075 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4076 [], "", COMPOUND, TypeCOMPOUND> {
4082 let isPredicatedFalse = np;
4083 // tnt: Taken/Not Taken
4084 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4085 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4087 let IClass = 0b0001;
4088 let Inst{27-26} = 0b00;
4089 // px: Predicate reg 0/1
4090 let Inst{25} = !if (!eq(px, "!p1"), 1,
4091 !if (!eq(px, "p1"), 1, 0));
4092 let Inst{24-23} = !if (!eq(op, "eq"), 0b00,
4093 !if (!eq(op, "gt"), 0b01,
4094 !if (!eq(op, "gtu"), 0b10, 0)));
4096 let Inst{21-20} = r9_2{10-9};
4097 let Inst{19-16} = Rs;
4098 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4099 let Inst{12-8} = U5;
4100 let Inst{7-1} = r9_2{8-2};
4102 // P[10] taken/not taken.
4103 multiclass T_tnt_CJInst_RU5<string op, bit np> {
4104 let Defs = [PC, P0], Uses = [P0] in {
4105 def NAME#p0_jump_nt : CJInst_RU5<"p0", op, np, "nt">;
4106 def NAME#p0_jump_t : CJInst_RU5<"p0", op, np, "t">;
4108 let Defs = [PC, P1], Uses = [P1] in {
4109 def NAME#p1_jump_nt : CJInst_RU5<"p1", op, np, "nt">;
4110 def NAME#p1_jump_t : CJInst_RU5<"p1", op, np, "t">;
4113 // Predicate / !Predicate
4114 multiclass T_pnp_CJInst_RU5<string op>{
4115 defm J4_cmp#NAME#i_t : T_tnt_CJInst_RU5<op, 0>;
4116 defm J4_cmp#NAME#i_f : T_tnt_CJInst_RU5<op, 1>;
4118 // TypeCJ Instructions compare RI and jump
4119 defm eq : T_pnp_CJInst_RU5<"eq">;
4120 defm gt : T_pnp_CJInst_RU5<"gt">;
4121 defm gtu : T_pnp_CJInst_RU5<"gtu">;
4123 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4124 isPredicated = 1, isPredicatedFalse = 1, isPredicatedNew = 1,
4125 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
4127 class CJInst_Rn1<string px, string op, bit np, string tnt>
4128 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
4129 ""#px#" = cmp."#op#"($Rs,#-1); if ("
4130 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4131 [], "", COMPOUND, TypeCOMPOUND> {
4136 let isPredicatedFalse = np;
4137 // tnt: Taken/Not Taken
4138 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4139 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4141 let IClass = 0b0001;
4142 let Inst{27-26} = 0b00;
4143 let Inst{25} = !if (!eq(px, "!p1"), 1,
4144 !if (!eq(px, "p1"), 1, 0));
4146 let Inst{24-23} = 0b11;
4148 let Inst{21-20} = r9_2{10-9};
4149 let Inst{19-16} = Rs;
4150 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4151 let Inst{9-8} = !if (!eq(op, "eq"), 0b00,
4152 !if (!eq(op, "gt"), 0b01, 0));
4153 let Inst{7-1} = r9_2{8-2};
4156 // P[10] taken/not taken.
4157 multiclass T_tnt_CJInst_Rn1<string op, bit np> {
4158 let Defs = [PC, P0], Uses = [P0] in {
4159 def NAME#p0_jump_nt : CJInst_Rn1<"p0", op, np, "nt">;
4160 def NAME#p0_jump_t : CJInst_Rn1<"p0", op, np, "t">;
4162 let Defs = [PC, P1], Uses = [P1] in {
4163 def NAME#p1_jump_nt : CJInst_Rn1<"p1", op, np, "nt">;
4164 def NAME#p1_jump_t : CJInst_Rn1<"p1", op, np, "t">;
4167 // Predicate / !Predicate
4168 multiclass T_pnp_CJInst_Rn1<string op>{
4169 defm J4_cmp#NAME#n1_t : T_tnt_CJInst_Rn1<op, 0>;
4170 defm J4_cmp#NAME#n1_f : T_tnt_CJInst_Rn1<op, 1>;
4172 // TypeCJ Instructions compare -1 and jump
4173 defm eq : T_pnp_CJInst_Rn1<"eq">;
4174 defm gt : T_pnp_CJInst_Rn1<"gt">;
4176 // J4_jumpseti: Direct unconditional jump and set register to immediate.
4177 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4178 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4179 opExtentAlign = 2, opExtendable = 2 in
4180 def J4_jumpseti: CJInst <
4182 (ins u6Imm:$U6, brtarget:$r9_2),
4183 "$Rd = #$U6 ; jump $r9_2"> {
4188 let IClass = 0b0001;
4189 let Inst{27-24} = 0b0110;
4190 let Inst{21-20} = r9_2{10-9};
4191 let Inst{19-16} = Rd;
4192 let Inst{13-8} = U6;
4193 let Inst{7-1} = r9_2{8-2};
4196 // J4_jumpsetr: Direct unconditional jump and transfer register.
4197 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4198 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4199 opExtentAlign = 2, opExtendable = 2 in
4200 def J4_jumpsetr: CJInst <
4202 (ins IntRegs:$Rs, brtarget:$r9_2),
4203 "$Rd = $Rs ; jump $r9_2"> {
4208 let IClass = 0b0001;
4209 let Inst{27-24} = 0b0111;
4210 let Inst{21-20} = r9_2{10-9};
4211 let Inst{11-8} = Rd;
4212 let Inst{19-16} = Rs;
4213 let Inst{7-1} = r9_2{8-2};