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 let hasSideEffects = 0 in
15 class T_Immext<Operand ImmType>
16 : EXTENDERInst<(outs), (ins ImmType:$imm),
17 "immext(#$imm)", []> {
21 let Inst{27-16} = imm{31-20};
22 let Inst{13-0} = imm{19-6};
25 def A4_ext : T_Immext<u26_6Imm>;
26 let isCodeGenOnly = 1 in {
28 def A4_ext_b : T_Immext<brtarget>;
30 def A4_ext_c : T_Immext<calltarget>;
31 def A4_ext_g : T_Immext<globaladdress>;
34 def BITPOS32 : SDNodeXForm<imm, [{
35 // Return the bit position we will set [0-31].
37 int32_t imm = N->getSExtValue();
38 return XformMskToBitPosU5Imm(imm);
41 // Fold (add (CONST32 tglobaladdr:$addr) <offset>) into a global address.
42 def FoldGlobalAddr : ComplexPattern<i32, 1, "foldGlobalAddress", [], []>;
44 // Fold (add (CONST32_GP tglobaladdr:$addr) <offset>) into a global address.
45 def FoldGlobalAddrGP : ComplexPattern<i32, 1, "foldGlobalAddressGP", [], []>;
47 def NumUsesBelowThresCONST32 : PatFrag<(ops node:$addr),
48 (HexagonCONST32 node:$addr), [{
49 return hasNumUsesBelowThresGA(N->getOperand(0).getNode());
52 // Hexagon V4 Architecture spec defines 8 instruction classes:
53 // LD ST ALU32 XTYPE J JR MEMOP NV CR SYSTEM(system is not implemented in the
57 // ========================================
58 // Loads (8/16/32/64 bit)
62 // ========================================
63 // Stores (8/16/32/64 bit)
66 // ALU32 Instructions:
67 // ========================================
68 // Arithmetic / Logical (32 bit)
71 // XTYPE Instructions (32/64 bit):
72 // ========================================
73 // Arithmetic, Logical, Bit Manipulation
74 // Multiply (Integer, Fractional, Complex)
75 // Permute / Vector Permute Operations
76 // Predicate Operations
77 // Shift / Shift with Add/Sub/Logical
79 // Vector Halfword (ALU, Shift, Multiply)
80 // Vector Word (ALU, Shift)
83 // ========================================
84 // Jump/Call PC-relative
87 // ========================================
90 // MEMOP Instructions:
91 // ========================================
92 // Operation on memory (8/16/32 bit)
95 // ========================================
100 // ========================================
101 // Control-Register Transfers
102 // Hardware Loop Setup
103 // Predicate Logicals & Reductions
105 // SYSTEM Instructions (not implemented in the compiler):
106 // ========================================
112 //===----------------------------------------------------------------------===//
114 //===----------------------------------------------------------------------===//
116 class T_ALU32_3op_not<string mnemonic, bits<3> MajOp, bits<3> MinOp,
118 : T_ALU32_3op<mnemonic, MajOp, MinOp, OpsRev, 0> {
119 let AsmString = "$Rd = "#mnemonic#"($Rs, ~$Rt)";
122 let BaseOpcode = "andn_rr", CextOpcode = "andn", isCodeGenOnly = 0 in
123 def A4_andn : T_ALU32_3op_not<"and", 0b001, 0b100, 1>;
124 let BaseOpcode = "orn_rr", CextOpcode = "orn", isCodeGenOnly = 0 in
125 def A4_orn : T_ALU32_3op_not<"or", 0b001, 0b101, 1>;
127 let CextOpcode = "rcmp.eq", isCodeGenOnly = 0 in
128 def A4_rcmpeq : T_ALU32_3op<"cmp.eq", 0b011, 0b010, 0, 1>;
129 let CextOpcode = "!rcmp.eq", isCodeGenOnly = 0 in
130 def A4_rcmpneq : T_ALU32_3op<"!cmp.eq", 0b011, 0b011, 0, 1>;
132 let isCodeGenOnly = 0 in {
133 def C4_cmpneq : T_ALU32_3op_cmp<"!cmp.eq", 0b00, 1, 1>;
134 def C4_cmplte : T_ALU32_3op_cmp<"!cmp.gt", 0b10, 1, 0>;
135 def C4_cmplteu : T_ALU32_3op_cmp<"!cmp.gtu", 0b11, 1, 0>;
138 // Pats for instruction selection.
140 // A class to embed the usual comparison patfrags within a zext to i32.
141 // The seteq/setne frags use "lhs" and "rhs" as operands, so use the same
142 // names, or else the frag's "body" won't match the operands.
143 class CmpInReg<PatFrag Op>
144 : PatFrag<(ops node:$lhs, node:$rhs),(i32 (zext (i1 Op.Fragment)))>;
146 def: T_cmp32_rr_pat<A4_rcmpeq, CmpInReg<seteq>, i32>;
147 def: T_cmp32_rr_pat<A4_rcmpneq, CmpInReg<setne>, i32>;
149 def: T_cmp32_rr_pat<C4_cmpneq, setne, i1>;
151 class T_CMP_rrbh<string mnemonic, bits<3> MinOp, bit IsComm>
152 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
153 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", S_3op_tc_2early_SLOT23>,
155 let validSubTargets = HasV4SubT;
156 let InputType = "reg";
157 let CextOpcode = mnemonic;
159 let isCommutable = IsComm;
160 let hasSideEffects = 0;
167 let Inst{27-21} = 0b0111110;
168 let Inst{20-16} = Rs;
170 let Inst{7-5} = MinOp;
174 let isCodeGenOnly = 0 in {
175 def A4_cmpbeq : T_CMP_rrbh<"cmpb.eq", 0b110, 1>;
176 def A4_cmpbgt : T_CMP_rrbh<"cmpb.gt", 0b010, 0>;
177 def A4_cmpbgtu : T_CMP_rrbh<"cmpb.gtu", 0b111, 0>;
178 def A4_cmpheq : T_CMP_rrbh<"cmph.eq", 0b011, 1>;
179 def A4_cmphgt : T_CMP_rrbh<"cmph.gt", 0b100, 0>;
180 def A4_cmphgtu : T_CMP_rrbh<"cmph.gtu", 0b101, 0>;
183 class T_CMP_ribh<string mnemonic, bits<2> MajOp, bit IsHalf, bit IsComm,
184 Operand ImmType, bit IsImmExt, bit IsImmSigned, int ImmBits>
185 : ALU64Inst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, ImmType:$Imm),
186 "$Pd = "#mnemonic#"($Rs, #$Imm)", [], "", ALU64_tc_2early_SLOT23>,
188 let validSubTargets = HasV4SubT;
189 let InputType = "imm";
190 let CextOpcode = mnemonic;
192 let isCommutable = IsComm;
193 let hasSideEffects = 0;
194 let isExtendable = IsImmExt;
195 let opExtendable = !if (IsImmExt, 2, 0);
196 let isExtentSigned = IsImmSigned;
197 let opExtentBits = ImmBits;
204 let Inst{27-24} = 0b1101;
205 let Inst{22-21} = MajOp;
206 let Inst{20-16} = Rs;
207 let Inst{12-5} = Imm;
209 let Inst{3} = IsHalf;
213 let isCodeGenOnly = 0 in {
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 validSubTargets = HasV4SubT;
226 let InputType = "imm";
227 let CextOpcode = !if (IsNeg, "!rcmp.eq", "rcmp.eq");
228 let isExtendable = 1;
229 let opExtendable = 2;
230 let isExtentSigned = 1;
231 let opExtentBits = 8;
239 let Inst{27-24} = 0b0011;
241 let Inst{21} = IsNeg;
242 let Inst{20-16} = Rs;
248 let isCodeGenOnly = 0 in {
249 def A4_rcmpeqi : T_RCMP_EQ_ri<"cmp.eq", 0>;
250 def A4_rcmpneqi : T_RCMP_EQ_ri<"!cmp.eq", 1>;
253 def: Pat<(i32 (zext (i1 (seteq (i32 IntRegs:$Rs), s8ExtPred:$s8)))),
254 (A4_rcmpeqi IntRegs:$Rs, s8ExtPred:$s8)>;
255 def: Pat<(i32 (zext (i1 (setne (i32 IntRegs:$Rs), s8ExtPred:$s8)))),
256 (A4_rcmpneqi IntRegs:$Rs, s8ExtPred:$s8)>;
258 // Preserve the S2_tstbit_r generation
259 def: Pat<(i32 (zext (i1 (setne (i32 (and (i32 (shl 1, (i32 IntRegs:$src2))),
260 (i32 IntRegs:$src1))), 0)))),
261 (C2_muxii (S2_tstbit_r IntRegs:$src1, IntRegs:$src2), 1, 0)>;
264 //===----------------------------------------------------------------------===//
266 //===----------------------------------------------------------------------===//
269 //===----------------------------------------------------------------------===//
271 //===----------------------------------------------------------------------===//
273 // Combine a word and an immediate into a register pair.
274 let hasSideEffects = 0, isExtentSigned = 1, isExtendable = 1,
276 class T_Combine1 <bits<2> MajOp, dag ins, string AsmStr>
277 : ALU32Inst <(outs DoubleRegs:$Rdd), ins, AsmStr> {
283 let Inst{27-24} = 0b0011;
284 let Inst{22-21} = MajOp;
285 let Inst{20-16} = Rs;
291 let opExtendable = 2, isCodeGenOnly = 0 in
292 def A4_combineri : T_Combine1<0b00, (ins IntRegs:$Rs, s8Ext:$s8),
293 "$Rdd = combine($Rs, #$s8)">;
295 let opExtendable = 1, isCodeGenOnly = 0 in
296 def A4_combineir : T_Combine1<0b01, (ins s8Ext:$s8, IntRegs:$Rs),
297 "$Rdd = combine(#$s8, $Rs)">;
299 def HexagonWrapperCombineRI_V4 :
300 SDNode<"HexagonISD::WrapperCombineRI_V4", SDTHexagonI64I32I32>;
301 def HexagonWrapperCombineIR_V4 :
302 SDNode<"HexagonISD::WrapperCombineIR_V4", SDTHexagonI64I32I32>;
304 def : Pat <(HexagonWrapperCombineRI_V4 IntRegs:$r, s8ExtPred:$i),
305 (A4_combineri IntRegs:$r, s8ExtPred:$i)>,
308 def : Pat <(HexagonWrapperCombineIR_V4 s8ExtPred:$i, IntRegs:$r),
309 (A4_combineir s8ExtPred:$i, IntRegs:$r)>,
312 // A4_combineii: Set two small immediates.
313 let hasSideEffects = 0, isExtendable = 1, opExtentBits = 6, opExtendable = 2 in
314 def A4_combineii: ALU32Inst<(outs DoubleRegs:$Rdd), (ins s8Imm:$s8, u6Ext:$U6),
315 "$Rdd = combine(#$s8, #$U6)"> {
321 let Inst{27-23} = 0b11001;
322 let Inst{20-16} = U6{5-1};
323 let Inst{13} = U6{0};
328 //===----------------------------------------------------------------------===//
330 //===----------------------------------------------------------------------===//
332 //===----------------------------------------------------------------------===//
334 //===----------------------------------------------------------------------===//
335 //===----------------------------------------------------------------------===//
336 // Template class for load instructions with Absolute set addressing mode.
337 //===----------------------------------------------------------------------===//
338 let isExtended = 1, opExtendable = 2, opExtentBits = 6, addrMode = AbsoluteSet,
339 hasSideEffects = 0 in
340 class T_LD_abs_set<string mnemonic, RegisterClass RC, bits<4>MajOp>:
341 LDInst<(outs RC:$dst1, IntRegs:$dst2),
343 "$dst1 = "#mnemonic#"($dst2 = #$addr)",
351 let Inst{27-25} = 0b101;
352 let Inst{24-21} = MajOp;
353 let Inst{13-12} = 0b01;
354 let Inst{4-0} = dst1;
355 let Inst{20-16} = dst2;
356 let Inst{11-8} = addr{5-2};
357 let Inst{6-5} = addr{1-0};
360 let accessSize = ByteAccess, hasNewValue = 1, isCodeGenOnly = 0 in {
361 def L4_loadrb_ap : T_LD_abs_set <"memb", IntRegs, 0b1000>;
362 def L4_loadrub_ap : T_LD_abs_set <"memub", IntRegs, 0b1001>;
365 let accessSize = HalfWordAccess, hasNewValue = 1, isCodeGenOnly = 0 in {
366 def L4_loadrh_ap : T_LD_abs_set <"memh", IntRegs, 0b1010>;
367 def L4_loadruh_ap : T_LD_abs_set <"memuh", IntRegs, 0b1011>;
370 let accessSize = WordAccess, hasNewValue = 1, isCodeGenOnly = 0 in
371 def L4_loadri_ap : T_LD_abs_set <"memw", IntRegs, 0b1100>;
373 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
374 def L4_loadrd_ap : T_LD_abs_set <"memd", DoubleRegs, 0b1110>;
376 //===----------------------------------------------------------------------===//
377 // Template classes for the non-predicated load instructions with
378 // base + register offset addressing mode
379 //===----------------------------------------------------------------------===//
380 class T_load_rr <string mnemonic, RegisterClass RC, bits<3> MajOp>:
381 LDInst<(outs RC:$dst), (ins IntRegs:$src1, IntRegs:$src2, u2Imm:$u2),
382 "$dst = "#mnemonic#"($src1 + $src2<<#$u2)",
383 [], "", V4LDST_tc_ld_SLOT01>, ImmRegShl, AddrModeRel {
391 let Inst{27-24} = 0b1010;
392 let Inst{23-21} = MajOp;
393 let Inst{20-16} = src1;
394 let Inst{12-8} = src2;
395 let Inst{13} = u2{1};
400 //===----------------------------------------------------------------------===//
401 // Template classes for the predicated load instructions with
402 // base + register offset addressing mode
403 //===----------------------------------------------------------------------===//
404 let isPredicated = 1 in
405 class T_pload_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
406 bit isNot, bit isPredNew>:
407 LDInst <(outs RC:$dst),
408 (ins PredRegs:$src1, IntRegs:$src2, IntRegs:$src3, u2Imm:$u2),
409 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
410 ") ")#"$dst = "#mnemonic#"($src2+$src3<<#$u2)",
411 [], "", V4LDST_tc_ld_SLOT01>, AddrModeRel {
418 let isPredicatedFalse = isNot;
419 let isPredicatedNew = isPredNew;
423 let Inst{27-26} = 0b00;
424 let Inst{25} = isPredNew;
425 let Inst{24} = isNot;
426 let Inst{23-21} = MajOp;
427 let Inst{20-16} = src2;
428 let Inst{12-8} = src3;
429 let Inst{13} = u2{1};
431 let Inst{6-5} = src1;
435 //===----------------------------------------------------------------------===//
436 // multiclass for load instructions with base + register offset
438 //===----------------------------------------------------------------------===//
439 let hasSideEffects = 0, addrMode = BaseRegOffset in
440 multiclass ld_idxd_shl <string mnemonic, string CextOp, RegisterClass RC,
442 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl,
443 InputType = "reg" in {
444 let isPredicable = 1 in
445 def L4_#NAME#_rr : T_load_rr <mnemonic, RC, MajOp>;
448 def L4_p#NAME#t_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 0>;
449 def L4_p#NAME#f_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 0>;
452 def L4_p#NAME#tnew_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 1>;
453 def L4_p#NAME#fnew_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 1>;
457 let hasNewValue = 1, accessSize = ByteAccess, isCodeGenOnly = 0 in {
458 defm loadrb : ld_idxd_shl<"memb", "LDrib", IntRegs, 0b000>;
459 defm loadrub : ld_idxd_shl<"memub", "LDriub", IntRegs, 0b001>;
462 let hasNewValue = 1, accessSize = HalfWordAccess, isCodeGenOnly = 0 in {
463 defm loadrh : ld_idxd_shl<"memh", "LDrih", IntRegs, 0b010>;
464 defm loadruh : ld_idxd_shl<"memuh", "LDriuh", IntRegs, 0b011>;
467 let hasNewValue = 1, accessSize = WordAccess, isCodeGenOnly = 0 in
468 defm loadri : ld_idxd_shl<"memw", "LDriw", IntRegs, 0b100>;
470 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
471 defm loadrd : ld_idxd_shl<"memd", "LDrid", DoubleRegs, 0b110>;
473 // 'def pats' for load instructions with base + register offset and non-zero
474 // immediate value. Immediate value is used to left-shift the second
476 let AddedComplexity = 40 in {
477 def : Pat <(i32 (sextloadi8 (add IntRegs:$src1,
478 (shl IntRegs:$src2, u2ImmPred:$offset)))),
479 (L4_loadrb_rr IntRegs:$src1,
480 IntRegs:$src2, u2ImmPred:$offset)>,
483 def : Pat <(i32 (zextloadi8 (add IntRegs:$src1,
484 (shl IntRegs:$src2, u2ImmPred:$offset)))),
485 (L4_loadrub_rr IntRegs:$src1,
486 IntRegs:$src2, u2ImmPred:$offset)>,
489 def : Pat <(i32 (extloadi8 (add IntRegs:$src1,
490 (shl IntRegs:$src2, u2ImmPred:$offset)))),
491 (L4_loadrub_rr IntRegs:$src1,
492 IntRegs:$src2, u2ImmPred:$offset)>,
495 def : Pat <(i32 (sextloadi16 (add IntRegs:$src1,
496 (shl IntRegs:$src2, u2ImmPred:$offset)))),
497 (L4_loadrh_rr IntRegs:$src1,
498 IntRegs:$src2, u2ImmPred:$offset)>,
501 def : Pat <(i32 (zextloadi16 (add IntRegs:$src1,
502 (shl IntRegs:$src2, u2ImmPred:$offset)))),
503 (L4_loadruh_rr IntRegs:$src1,
504 IntRegs:$src2, u2ImmPred:$offset)>,
507 def : Pat <(i32 (extloadi16 (add IntRegs:$src1,
508 (shl IntRegs:$src2, u2ImmPred:$offset)))),
509 (L4_loadruh_rr IntRegs:$src1,
510 IntRegs:$src2, u2ImmPred:$offset)>,
513 def : Pat <(i32 (load (add IntRegs:$src1,
514 (shl IntRegs:$src2, u2ImmPred:$offset)))),
515 (L4_loadri_rr IntRegs:$src1,
516 IntRegs:$src2, u2ImmPred:$offset)>,
519 def : Pat <(i64 (load (add IntRegs:$src1,
520 (shl IntRegs:$src2, u2ImmPred:$offset)))),
521 (L4_loadrd_rr IntRegs:$src1,
522 IntRegs:$src2, u2ImmPred:$offset)>,
526 // 'def pats' for load instruction base + register offset and
527 // zero immediate value.
528 class Loadxs_simple_pat<PatFrag Load, ValueType VT, InstHexagon MI>
529 : Pat<(VT (Load (add (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)))),
530 (VT (MI IntRegs:$Rs, IntRegs:$Rt, 0))>;
532 let AddedComplexity = 20 in {
533 def: Loadxs_simple_pat<extloadi8, i32, L4_loadrub_rr>;
534 def: Loadxs_simple_pat<zextloadi8, i32, L4_loadrub_rr>;
535 def: Loadxs_simple_pat<sextloadi8, i32, L4_loadrb_rr>;
536 def: Loadxs_simple_pat<extloadi16, i32, L4_loadruh_rr>;
537 def: Loadxs_simple_pat<zextloadi16, i32, L4_loadruh_rr>;
538 def: Loadxs_simple_pat<sextloadi16, i32, L4_loadrh_rr>;
539 def: Loadxs_simple_pat<load, i32, L4_loadri_rr>;
540 def: Loadxs_simple_pat<load, i64, L4_loadrd_rr>;
544 def : Pat <(i64 (zext (i1 PredRegs:$src1))),
545 (i64 (A4_combineir 0, (C2_muxii (i1 PredRegs:$src1), 1, 0)))>,
549 def : Pat <(i64 (zext (i32 IntRegs:$src1))),
550 (i64 (A4_combineir 0, (i32 IntRegs:$src1)))>,
553 def: Pat <(i64 (zextloadi8 ADDRriS11_0:$src1)),
554 (i64 (A4_combineir 0, (L2_loadrub_io AddrFI:$src1, 0)))>,
557 let AddedComplexity = 20 in
558 def: Pat <(i64 (zextloadi8 (add (i32 IntRegs:$src1),
559 s11_0ExtPred:$offset))),
560 (i64 (A4_combineir 0, (L2_loadrub_io IntRegs:$src1,
561 s11_0ExtPred:$offset)))>,
565 def: Pat <(i64 (zextloadi1 ADDRriS11_0:$src1)),
566 (i64 (A4_combineir 0, (L2_loadrub_io AddrFI:$src1, 0)))>,
569 let AddedComplexity = 20 in
570 def: Pat <(i64 (zextloadi1 (add (i32 IntRegs:$src1),
571 s11_0ExtPred:$offset))),
572 (i64 (A4_combineir 0, (L2_loadrub_io IntRegs:$src1,
573 s11_0ExtPred:$offset)))>,
577 def: Pat <(i64 (zextloadi16 ADDRriS11_1:$src1)),
578 (i64 (A4_combineir 0, (L2_loadruh_io AddrFI:$src1, 0)))>,
581 let AddedComplexity = 20 in
582 def: Pat <(i64 (zextloadi16 (add (i32 IntRegs:$src1),
583 s11_1ExtPred:$offset))),
584 (i64 (A4_combineir 0, (L2_loadruh_io IntRegs:$src1,
585 s11_1ExtPred:$offset)))>,
589 def: Pat <(i64 (extloadi16 ADDRriS11_2:$src1)),
590 (i64 (A4_combineir 0, (L2_loadrh_io AddrFI:$src1, 0)))>,
593 let AddedComplexity = 20 in
594 def: Pat <(i64 (extloadi16 (add (i32 IntRegs:$src1),
595 s11_1ExtPred:$offset))),
596 (i64 (A4_combineir 0, (L2_loadrh_io IntRegs:$src1,
597 s11_1ExtPred:$offset)))>,
601 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)),
602 (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>,
605 let AddedComplexity = 100 in
606 def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
607 (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1,
608 s11_2ExtPred:$offset)))>,
612 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)),
613 (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>,
616 let AddedComplexity = 100 in
617 def: Pat <(i64 (extloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
618 (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1,
619 s11_2ExtPred:$offset)))>,
624 //===----------------------------------------------------------------------===//
626 //===----------------------------------------------------------------------===//
628 //===----------------------------------------------------------------------===//
630 //===----------------------------------------------------------------------===//
632 //===----------------------------------------------------------------------===//
633 // Template class for store instructions with Absolute set addressing mode.
634 //===----------------------------------------------------------------------===//
635 let isExtended = 1, opExtendable = 2, validSubTargets = HasV4SubT,
636 addrMode = AbsoluteSet in
637 class T_ST_abs_set<string mnemonic, RegisterClass RC>:
638 STInst2<(outs IntRegs:$dst1),
639 (ins RC:$src1, u0AlwaysExt:$src2),
640 mnemonic#"($dst1=##$src2) = $src1",
644 def STrid_abs_set_V4 : T_ST_abs_set <"memd", DoubleRegs>;
645 def STrib_abs_set_V4 : T_ST_abs_set <"memb", IntRegs>;
646 def STrih_abs_set_V4 : T_ST_abs_set <"memh", IntRegs>;
647 def STriw_abs_set_V4 : T_ST_abs_set <"memw", IntRegs>;
649 //===----------------------------------------------------------------------===//
650 // Template classes for the non-predicated store instructions with
651 // base + register offset addressing mode
652 //===----------------------------------------------------------------------===//
653 let isPredicable = 1 in
654 class T_store_rr <string mnemonic, RegisterClass RC, bits<3> MajOp, bit isH>
655 : STInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
656 mnemonic#"($Rs + $Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
657 [],"",V4LDST_tc_st_SLOT01>, ImmRegShl, AddrModeRel {
666 let Inst{27-24} = 0b1011;
667 let Inst{23-21} = MajOp;
668 let Inst{20-16} = Rs;
670 let Inst{13} = u2{1};
675 //===----------------------------------------------------------------------===//
676 // Template classes for the predicated store instructions with
677 // base + register offset addressing mode
678 //===----------------------------------------------------------------------===//
679 let isPredicated = 1 in
680 class T_pstore_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
681 bit isNot, bit isPredNew, bit isH>
683 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
685 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
686 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
687 [], "", V4LDST_tc_st_SLOT01> , AddrModeRel{
694 let isPredicatedFalse = isNot;
695 let isPredicatedNew = isPredNew;
699 let Inst{27-26} = 0b01;
700 let Inst{25} = isPredNew;
701 let Inst{24} = isNot;
702 let Inst{23-21} = MajOp;
703 let Inst{20-16} = Rs;
705 let Inst{13} = u2{1};
711 //===----------------------------------------------------------------------===//
712 // Template classes for the new-value store instructions with
713 // base + register offset addressing mode
714 //===----------------------------------------------------------------------===//
715 let isPredicable = 1, isNewValue = 1, opNewValue = 3 in
716 class T_store_new_rr <string mnemonic, bits<2> MajOp> :
717 NVInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
718 mnemonic#"($Rs + $Ru<<#$u2) = $Nt.new",
719 [],"",V4LDST_tc_st_SLOT0>, ImmRegShl, AddrModeRel {
728 let Inst{27-21} = 0b1011101;
729 let Inst{20-16} = Rs;
731 let Inst{13} = u2{1};
733 let Inst{4-3} = MajOp;
737 //===----------------------------------------------------------------------===//
738 // Template classes for the predicated new-value store instructions with
739 // base + register offset addressing mode
740 //===----------------------------------------------------------------------===//
741 let isPredicated = 1, isNewValue = 1, opNewValue = 4 in
742 class T_pstore_new_rr <string mnemonic, bits<2> MajOp, bit isNot, bit isPredNew>
744 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
745 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
746 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Nt.new",
747 [], "", V4LDST_tc_st_SLOT0>, AddrModeRel {
754 let isPredicatedFalse = isNot;
755 let isPredicatedNew = isPredNew;
758 let Inst{27-26} = 0b01;
759 let Inst{25} = isPredNew;
760 let Inst{24} = isNot;
761 let Inst{23-21} = 0b101;
762 let Inst{20-16} = Rs;
764 let Inst{13} = u2{1};
767 let Inst{4-3} = MajOp;
771 //===----------------------------------------------------------------------===//
772 // multiclass for store instructions with base + register offset addressing
774 //===----------------------------------------------------------------------===//
775 let isNVStorable = 1 in
776 multiclass ST_Idxd_shl<string mnemonic, string CextOp, RegisterClass RC,
777 bits<3> MajOp, bit isH = 0> {
778 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
779 def S4_#NAME#_rr : T_store_rr <mnemonic, RC, MajOp, isH>;
782 def S4_p#NAME#t_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 0, isH>;
783 def S4_p#NAME#f_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 0, isH>;
786 def S4_p#NAME#tnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 1, isH>;
787 def S4_p#NAME#fnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 1, isH>;
791 //===----------------------------------------------------------------------===//
792 // multiclass for new-value store instructions with base + register offset
794 //===----------------------------------------------------------------------===//
795 let mayStore = 1, isNVStore = 1 in
796 multiclass ST_Idxd_shl_nv <string mnemonic, string CextOp, RegisterClass RC,
798 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
799 def S4_#NAME#new_rr : T_store_new_rr<mnemonic, MajOp>;
802 def S4_p#NAME#newt_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 0>;
803 def S4_p#NAME#newf_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 0>;
806 def S4_p#NAME#newtnew_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 1>;
807 def S4_p#NAME#newfnew_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 1>;
811 let addrMode = BaseRegOffset, InputType = "reg", hasSideEffects = 0,
812 isCodeGenOnly = 0 in {
813 let accessSize = ByteAccess in
814 defm storerb: ST_Idxd_shl<"memb", "STrib", IntRegs, 0b000>,
815 ST_Idxd_shl_nv<"memb", "STrib", IntRegs, 0b00>;
817 let accessSize = HalfWordAccess in
818 defm storerh: ST_Idxd_shl<"memh", "STrih", IntRegs, 0b010>,
819 ST_Idxd_shl_nv<"memh", "STrih", IntRegs, 0b01>;
821 let accessSize = WordAccess in
822 defm storeri: ST_Idxd_shl<"memw", "STriw", IntRegs, 0b100>,
823 ST_Idxd_shl_nv<"memw", "STriw", IntRegs, 0b10>;
825 let isNVStorable = 0, accessSize = DoubleWordAccess in
826 defm storerd: ST_Idxd_shl<"memd", "STrid", DoubleRegs, 0b110>;
828 let isNVStorable = 0, accessSize = HalfWordAccess in
829 defm storerf: ST_Idxd_shl<"memh", "STrif", IntRegs, 0b011, 1>;
832 let Predicates = [HasV4T], AddedComplexity = 10 in {
833 def : Pat<(truncstorei8 (i32 IntRegs:$src4),
834 (add IntRegs:$src1, (shl IntRegs:$src2,
836 (S4_storerb_rr IntRegs:$src1, IntRegs:$src2,
837 u2ImmPred:$src3, IntRegs:$src4)>;
839 def : Pat<(truncstorei16 (i32 IntRegs:$src4),
840 (add IntRegs:$src1, (shl IntRegs:$src2,
842 (S4_storerh_rr IntRegs:$src1, IntRegs:$src2,
843 u2ImmPred:$src3, IntRegs:$src4)>;
845 def : Pat<(store (i32 IntRegs:$src4),
846 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$src3))),
847 (S4_storeri_rr IntRegs:$src1, IntRegs:$src2,
848 u2ImmPred:$src3, IntRegs:$src4)>;
850 def : Pat<(store (i64 DoubleRegs:$src4),
851 (add IntRegs:$src1, (shl IntRegs:$src2, u2ImmPred:$src3))),
852 (S4_storerd_rr IntRegs:$src1, IntRegs:$src2,
853 u2ImmPred:$src3, DoubleRegs:$src4)>;
856 let isExtended = 1, opExtendable = 2 in
857 class T_ST_LongOff <string mnemonic, PatFrag stOp, RegisterClass RC, ValueType VT> :
859 (ins IntRegs:$src1, u2Imm:$src2, u0AlwaysExt:$src3, RC:$src4),
860 mnemonic#"($src1<<#$src2+##$src3) = $src4",
861 [(stOp (VT RC:$src4),
862 (add (shl (i32 IntRegs:$src1), u2ImmPred:$src2),
863 u0AlwaysExtPred:$src3))]>,
866 let isExtended = 1, opExtendable = 2, mayStore = 1, isNVStore = 1 in
867 class T_ST_LongOff_nv <string mnemonic> :
869 (ins IntRegs:$src1, u2Imm:$src2, u0AlwaysExt:$src3, IntRegs:$src4),
870 mnemonic#"($src1<<#$src2+##$src3) = $src4.new",
874 multiclass ST_LongOff <string mnemonic, string BaseOp, PatFrag stOp> {
875 let BaseOpcode = BaseOp#"_shl" in {
876 let isNVStorable = 1 in
877 def NAME#_V4 : T_ST_LongOff<mnemonic, stOp, IntRegs, i32>;
879 def NAME#_nv_V4 : T_ST_LongOff_nv<mnemonic>;
883 let AddedComplexity = 10, validSubTargets = HasV4SubT in {
884 def STrid_shl_V4 : T_ST_LongOff<"memd", store, DoubleRegs, i64>;
885 defm STrib_shl : ST_LongOff <"memb", "STrib", truncstorei8>, NewValueRel;
886 defm STrih_shl : ST_LongOff <"memh", "Strih", truncstorei16>, NewValueRel;
887 defm STriw_shl : ST_LongOff <"memw", "STriw", store>, NewValueRel;
890 let AddedComplexity = 40 in
891 multiclass T_ST_LOff_Pats <InstHexagon I, RegisterClass RC, ValueType VT,
893 def : Pat<(stOp (VT RC:$src4),
894 (add (shl IntRegs:$src1, u2ImmPred:$src2),
895 (NumUsesBelowThresCONST32 tglobaladdr:$src3))),
896 (I IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3, RC:$src4)>;
898 def : Pat<(stOp (VT RC:$src4),
900 (NumUsesBelowThresCONST32 tglobaladdr:$src3))),
901 (I IntRegs:$src1, 0, tglobaladdr:$src3, RC:$src4)>;
904 defm : T_ST_LOff_Pats<STrid_shl_V4, DoubleRegs, i64, store>;
905 defm : T_ST_LOff_Pats<STriw_shl_V4, IntRegs, i32, store>;
906 defm : T_ST_LOff_Pats<STrib_shl_V4, IntRegs, i32, truncstorei8>;
907 defm : T_ST_LOff_Pats<STrih_shl_V4, IntRegs, i32, truncstorei16>;
909 // memd(Rx++#s4:3)=Rtt
910 // memd(Rx++#s4:3:circ(Mu))=Rtt
911 // memd(Rx++I:circ(Mu))=Rtt
913 // memd(Rx++Mu:brev)=Rtt
914 // memd(gp+#u16:3)=Rtt
916 // Store doubleword conditionally.
917 // if ([!]Pv[.new]) memd(#u6)=Rtt
918 // TODO: needs to be implemented.
920 //===----------------------------------------------------------------------===//
922 //===----------------------------------------------------------------------===//
923 let isPredicable = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 8,
925 class T_StoreImm <string mnemonic, Operand OffsetOp, bits<2> MajOp >
926 : STInst <(outs ), (ins IntRegs:$Rs, OffsetOp:$offset, s8Ext:$S8),
927 mnemonic#"($Rs+#$offset)=#$S8",
928 [], "", V4LDST_tc_st_SLOT01>,
929 ImmRegRel, PredNewRel {
935 string OffsetOpStr = !cast<string>(OffsetOp);
936 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
937 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
938 /* u6_0Imm */ offset{5-0}));
942 let Inst{27-25} = 0b110;
943 let Inst{22-21} = MajOp;
944 let Inst{20-16} = Rs;
945 let Inst{12-7} = offsetBits;
946 let Inst{13} = S8{7};
947 let Inst{6-0} = S8{6-0};
950 let isPredicated = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 6,
952 class T_StoreImm_pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
953 bit isPredNot, bit isPredNew >
955 (ins PredRegs:$Pv, IntRegs:$Rs, OffsetOp:$offset, s6Ext:$S6),
956 !if(isPredNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
957 ") ")#mnemonic#"($Rs+#$offset)=#$S6",
958 [], "", V4LDST_tc_st_SLOT01>,
959 ImmRegRel, PredNewRel {
966 string OffsetOpStr = !cast<string>(OffsetOp);
967 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
968 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
969 /* u6_0Imm */ offset{5-0}));
970 let isPredicatedNew = isPredNew;
971 let isPredicatedFalse = isPredNot;
975 let Inst{27-25} = 0b100;
976 let Inst{24} = isPredNew;
977 let Inst{23} = isPredNot;
978 let Inst{22-21} = MajOp;
979 let Inst{20-16} = Rs;
980 let Inst{13} = S6{5};
981 let Inst{12-7} = offsetBits;
983 let Inst{4-0} = S6{4-0};
987 //===----------------------------------------------------------------------===//
988 // multiclass for store instructions with base + immediate offset
989 // addressing mode and immediate stored value.
990 // mem[bhw](Rx++#s4:3)=#s8
991 // if ([!]Pv[.new]) mem[bhw](Rx++#s4:3)=#s6
992 //===----------------------------------------------------------------------===//
994 multiclass ST_Imm_Pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
996 def _io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 0>;
998 def new_io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 1>;
1001 multiclass ST_Imm <string mnemonic, string CextOp, Operand OffsetOp,
1003 let CextOpcode = CextOp, BaseOpcode = CextOp#_imm in {
1004 def _io : T_StoreImm <mnemonic, OffsetOp, MajOp>;
1006 defm t : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 0>;
1007 defm f : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 1>;
1011 let hasSideEffects = 0, validSubTargets = HasV4SubT, addrMode = BaseImmOffset,
1012 InputType = "imm", isCodeGenOnly = 0 in {
1013 let accessSize = ByteAccess in
1014 defm S4_storeirb : ST_Imm<"memb", "STrib", u6_0Imm, 0b00>;
1016 let accessSize = HalfWordAccess in
1017 defm S4_storeirh : ST_Imm<"memh", "STrih", u6_1Imm, 0b01>;
1019 let accessSize = WordAccess in
1020 defm S4_storeiri : ST_Imm<"memw", "STriw", u6_2Imm, 0b10>;
1023 let Predicates = [HasV4T], AddedComplexity = 10 in {
1024 def: Pat<(truncstorei8 s8ExtPred:$src3, (add IntRegs:$src1, u6_0ImmPred:$src2)),
1025 (S4_storeirb_io IntRegs:$src1, u6_0ImmPred:$src2, s8ExtPred:$src3)>;
1027 def: Pat<(truncstorei16 s8ExtPred:$src3, (add IntRegs:$src1,
1028 u6_1ImmPred:$src2)),
1029 (S4_storeirh_io IntRegs:$src1, u6_1ImmPred:$src2, s8ExtPred:$src3)>;
1031 def: Pat<(store s8ExtPred:$src3, (add IntRegs:$src1, u6_2ImmPred:$src2)),
1032 (S4_storeiri_io IntRegs:$src1, u6_2ImmPred:$src2, s8ExtPred:$src3)>;
1035 let AddedComplexity = 6 in
1036 def : Pat <(truncstorei8 s8ExtPred:$src2, (i32 IntRegs:$src1)),
1037 (S4_storeirb_io IntRegs:$src1, 0, s8ExtPred:$src2)>,
1040 // memb(Rx++#s4:0:circ(Mu))=Rt
1041 // memb(Rx++I:circ(Mu))=Rt
1043 // memb(Rx++Mu:brev)=Rt
1044 // memb(gp+#u16:0)=Rt
1048 // TODO: needs to be implemented
1049 // memh(Re=#U6)=Rt.H
1050 // memh(Rs+#s11:1)=Rt.H
1051 let AddedComplexity = 6 in
1052 def : Pat <(truncstorei16 s8ExtPred:$src2, (i32 IntRegs:$src1)),
1053 (S4_storeirh_io IntRegs:$src1, 0, s8ExtPred:$src2)>,
1056 // memh(Rs+Ru<<#u2)=Rt.H
1057 // TODO: needs to be implemented.
1059 // memh(Ru<<#u2+#U6)=Rt.H
1060 // memh(Rx++#s4:1:circ(Mu))=Rt.H
1061 // memh(Rx++#s4:1:circ(Mu))=Rt
1062 // memh(Rx++I:circ(Mu))=Rt.H
1063 // memh(Rx++I:circ(Mu))=Rt
1064 // memh(Rx++Mu)=Rt.H
1066 // memh(Rx++Mu:brev)=Rt.H
1067 // memh(Rx++Mu:brev)=Rt
1068 // memh(gp+#u16:1)=Rt
1069 // if ([!]Pv[.new]) memh(#u6)=Rt.H
1070 // if ([!]Pv[.new]) memh(#u6)=Rt
1073 // if ([!]Pv[.new]) memh(Rs+#u6:1)=Rt.H
1074 // TODO: needs to be implemented.
1076 // if ([!]Pv[.new]) memh(Rx++#s4:1)=Rt.H
1077 // TODO: Needs to be implemented.
1081 // TODO: Needs to be implemented.
1084 let hasSideEffects = 0 in
1085 def STriw_pred_V4 : STInst2<(outs),
1086 (ins MEMri:$addr, PredRegs:$src1),
1087 "Error; should not emit",
1091 let AddedComplexity = 6 in
1092 def : Pat <(store s8ExtPred:$src2, (i32 IntRegs:$src1)),
1093 (S4_storeiri_io IntRegs:$src1, 0, s8ExtPred:$src2)>,
1096 // memw(Rx++#s4:2)=Rt
1097 // memw(Rx++#s4:2:circ(Mu))=Rt
1098 // memw(Rx++I:circ(Mu))=Rt
1100 // memw(Rx++Mu:brev)=Rt
1102 //===----------------------------------------------------------------------===
1104 //===----------------------------------------------------------------------===
1107 //===----------------------------------------------------------------------===//
1109 //===----------------------------------------------------------------------===//
1111 let opNewValue = 2, opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
1112 class T_store_io_nv <string mnemonic, RegisterClass RC,
1113 Operand ImmOp, bits<2>MajOp>
1114 : NVInst_V4 <(outs),
1115 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
1116 mnemonic#"($src1+#$src2) = $src3.new",
1117 [],"",ST_tc_st_SLOT0> {
1119 bits<13> src2; // Actual address offset
1121 bits<11> offsetBits; // Represents offset encoding
1123 let opExtentBits = !if (!eq(mnemonic, "memb"), 11,
1124 !if (!eq(mnemonic, "memh"), 12,
1125 !if (!eq(mnemonic, "memw"), 13, 0)));
1127 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1128 !if (!eq(mnemonic, "memh"), 1,
1129 !if (!eq(mnemonic, "memw"), 2, 0)));
1131 let offsetBits = !if (!eq(mnemonic, "memb"), src2{10-0},
1132 !if (!eq(mnemonic, "memh"), src2{11-1},
1133 !if (!eq(mnemonic, "memw"), src2{12-2}, 0)));
1135 let IClass = 0b1010;
1138 let Inst{26-25} = offsetBits{10-9};
1139 let Inst{24-21} = 0b1101;
1140 let Inst{20-16} = src1;
1141 let Inst{13} = offsetBits{8};
1142 let Inst{12-11} = MajOp;
1143 let Inst{10-8} = src3;
1144 let Inst{7-0} = offsetBits{7-0};
1147 let opExtendable = 2, opNewValue = 3, isPredicated = 1 in
1148 class T_pstore_io_nv <string mnemonic, RegisterClass RC, Operand predImmOp,
1149 bits<2>MajOp, bit PredNot, bit isPredNew>
1150 : NVInst_V4 <(outs),
1151 (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC:$src4),
1152 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1153 ") ")#mnemonic#"($src2+#$src3) = $src4.new",
1154 [],"",V2LDST_tc_st_SLOT0> {
1159 bits<6> offsetBits; // Represents offset encoding
1161 let isPredicatedNew = isPredNew;
1162 let isPredicatedFalse = PredNot;
1163 let opExtentBits = !if (!eq(mnemonic, "memb"), 6,
1164 !if (!eq(mnemonic, "memh"), 7,
1165 !if (!eq(mnemonic, "memw"), 8, 0)));
1167 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1168 !if (!eq(mnemonic, "memh"), 1,
1169 !if (!eq(mnemonic, "memw"), 2, 0)));
1171 let offsetBits = !if (!eq(mnemonic, "memb"), src3{5-0},
1172 !if (!eq(mnemonic, "memh"), src3{6-1},
1173 !if (!eq(mnemonic, "memw"), src3{7-2}, 0)));
1175 let IClass = 0b0100;
1178 let Inst{26} = PredNot;
1179 let Inst{25} = isPredNew;
1180 let Inst{24-21} = 0b0101;
1181 let Inst{20-16} = src2;
1182 let Inst{13} = offsetBits{5};
1183 let Inst{12-11} = MajOp;
1184 let Inst{10-8} = src4;
1185 let Inst{7-3} = offsetBits{4-0};
1187 let Inst{1-0} = src1;
1190 // multiclass for new-value store instructions with base + immediate offset.
1192 let mayStore = 1, isNVStore = 1, isNewValue = 1, hasSideEffects = 0,
1194 multiclass ST_Idxd_nv<string mnemonic, string CextOp, RegisterClass RC,
1195 Operand ImmOp, Operand predImmOp, bits<2> MajOp> {
1197 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1198 def S2_#NAME#new_io : T_store_io_nv <mnemonic, RC, ImmOp, MajOp>;
1200 def S2_p#NAME#newt_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 0, 0>;
1201 def S2_p#NAME#newf_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 1, 0>;
1203 def S4_p#NAME#newtnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1205 def S4_p#NAME#newfnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1210 let addrMode = BaseImmOffset, InputType = "imm", isCodeGenOnly = 0 in {
1211 let accessSize = ByteAccess in
1212 defm storerb: ST_Idxd_nv<"memb", "STrib", IntRegs, s11_0Ext,
1213 u6_0Ext, 0b00>, AddrModeRel;
1215 let accessSize = HalfWordAccess, opExtentAlign = 1 in
1216 defm storerh: ST_Idxd_nv<"memh", "STrih", IntRegs, s11_1Ext,
1217 u6_1Ext, 0b01>, AddrModeRel;
1219 let accessSize = WordAccess, opExtentAlign = 2 in
1220 defm storeri: ST_Idxd_nv<"memw", "STriw", IntRegs, s11_2Ext,
1221 u6_2Ext, 0b10>, AddrModeRel;
1224 //===----------------------------------------------------------------------===//
1225 // Post increment loads with register offset.
1226 //===----------------------------------------------------------------------===//
1228 let hasNewValue = 1, isCodeGenOnly = 0 in
1229 def L2_loadbsw2_pr : T_load_pr <"membh", IntRegs, 0b0001, HalfWordAccess>;
1231 let isCodeGenOnly = 0 in
1232 def L2_loadbsw4_pr : T_load_pr <"membh", DoubleRegs, 0b0111, WordAccess>;
1234 //===----------------------------------------------------------------------===//
1235 // Template class for non-predicated post increment .new stores
1236 // mem[bhwd](Rx++#s4:[0123])=Nt.new
1237 //===----------------------------------------------------------------------===//
1238 let isPredicable = 1, hasSideEffects = 0, validSubTargets = HasV4SubT,
1239 addrMode = PostInc, isNVStore = 1, isNewValue = 1, opNewValue = 3 in
1240 class T_StorePI_nv <string mnemonic, Operand ImmOp, bits<2> MajOp >
1241 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1242 (ins IntRegs:$src1, ImmOp:$offset, IntRegs:$src2),
1243 mnemonic#"($src1++#$offset) = $src2.new",
1244 [], "$src1 = $_dst_">,
1251 string ImmOpStr = !cast<string>(ImmOp);
1252 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1253 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1254 /* s4_0Imm */ offset{3-0}));
1255 let IClass = 0b1010;
1257 let Inst{27-21} = 0b1011101;
1258 let Inst{20-16} = src1;
1260 let Inst{12-11} = MajOp;
1261 let Inst{10-8} = src2;
1263 let Inst{6-3} = offsetBits;
1267 //===----------------------------------------------------------------------===//
1268 // Template class for predicated post increment .new stores
1269 // if([!]Pv[.new]) mem[bhwd](Rx++#s4:[0123])=Nt.new
1270 //===----------------------------------------------------------------------===//
1271 let isPredicated = 1, hasSideEffects = 0, validSubTargets = HasV4SubT,
1272 addrMode = PostInc, isNVStore = 1, isNewValue = 1, opNewValue = 4 in
1273 class T_StorePI_nv_pred <string mnemonic, Operand ImmOp,
1274 bits<2> MajOp, bit isPredNot, bit isPredNew >
1275 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1276 (ins PredRegs:$src1, IntRegs:$src2,
1277 ImmOp:$offset, IntRegs:$src3),
1278 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1279 ") ")#mnemonic#"($src2++#$offset) = $src3.new",
1280 [], "$src2 = $_dst_">,
1288 string ImmOpStr = !cast<string>(ImmOp);
1289 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1290 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1291 /* s4_0Imm */ offset{3-0}));
1292 let isPredicatedNew = isPredNew;
1293 let isPredicatedFalse = isPredNot;
1295 let IClass = 0b1010;
1297 let Inst{27-21} = 0b1011101;
1298 let Inst{20-16} = src2;
1300 let Inst{12-11} = MajOp;
1301 let Inst{10-8} = src3;
1302 let Inst{7} = isPredNew;
1303 let Inst{6-3} = offsetBits;
1304 let Inst{2} = isPredNot;
1305 let Inst{1-0} = src1;
1308 multiclass ST_PostInc_Pred_nv<string mnemonic, Operand ImmOp,
1309 bits<2> MajOp, bit PredNot> {
1310 def _pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 0>;
1313 def new_pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 1>;
1316 multiclass ST_PostInc_nv<string mnemonic, string BaseOp, Operand ImmOp,
1318 let BaseOpcode = "POST_"#BaseOp in {
1319 def S2_#NAME#_pi : T_StorePI_nv <mnemonic, ImmOp, MajOp>;
1322 defm S2_p#NAME#t : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 0>;
1323 defm S2_p#NAME#f : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 1>;
1327 let accessSize = ByteAccess, isCodeGenOnly = 0 in
1328 defm storerbnew: ST_PostInc_nv <"memb", "STrib", s4_0Imm, 0b00>;
1330 let accessSize = HalfWordAccess, isCodeGenOnly = 0 in
1331 defm storerhnew: ST_PostInc_nv <"memh", "STrih", s4_1Imm, 0b01>;
1333 let accessSize = WordAccess, isCodeGenOnly = 0 in
1334 defm storerinew: ST_PostInc_nv <"memw", "STriw", s4_2Imm, 0b10>;
1336 //===----------------------------------------------------------------------===//
1337 // Template class for post increment .new stores with register offset
1338 //===----------------------------------------------------------------------===//
1339 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
1340 class T_StorePI_RegNV <string mnemonic, bits<2> MajOp, MemAccessSize AccessSz>
1341 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1342 (ins IntRegs:$src1, ModRegs:$src2, IntRegs:$src3),
1343 #mnemonic#"($src1++$src2) = $src3.new",
1344 [], "$src1 = $_dst_"> {
1348 let accessSize = AccessSz;
1350 let IClass = 0b1010;
1352 let Inst{27-21} = 0b1101101;
1353 let Inst{20-16} = src1;
1354 let Inst{13} = src2;
1355 let Inst{12-11} = MajOp;
1356 let Inst{10-8} = src3;
1360 let isCodeGenOnly = 0 in {
1361 def S2_storerbnew_pr : T_StorePI_RegNV<"memb", 0b00, ByteAccess>;
1362 def S2_storerhnew_pr : T_StorePI_RegNV<"memh", 0b01, HalfWordAccess>;
1363 def S2_storerinew_pr : T_StorePI_RegNV<"memw", 0b10, WordAccess>;
1366 // memb(Rx++#s4:0:circ(Mu))=Nt.new
1367 // memb(Rx++I:circ(Mu))=Nt.new
1368 // memb(Rx++Mu)=Nt.new
1369 // memb(Rx++Mu:brev)=Nt.new
1370 // memh(Rx++#s4:1:circ(Mu))=Nt.new
1371 // memh(Rx++I:circ(Mu))=Nt.new
1372 // memh(Rx++Mu)=Nt.new
1373 // memh(Rx++Mu:brev)=Nt.new
1375 // memw(Rx++#s4:2:circ(Mu))=Nt.new
1376 // memw(Rx++I:circ(Mu))=Nt.new
1377 // memw(Rx++Mu)=Nt.new
1378 // memw(Rx++Mu:brev)=Nt.new
1380 //===----------------------------------------------------------------------===//
1382 //===----------------------------------------------------------------------===//
1384 //===----------------------------------------------------------------------===//
1386 //===----------------------------------------------------------------------===//
1388 //===----------------------------------------------------------------------===//
1389 // multiclass/template class for the new-value compare jumps with the register
1391 //===----------------------------------------------------------------------===//
1393 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1394 opExtentAlign = 2 in
1395 class NVJrr_template<string mnemonic, bits<3> majOp, bit NvOpNum,
1396 bit isNegCond, bit isTak>
1398 (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset),
1399 "if ("#!if(isNegCond, "!","")#mnemonic#
1400 "($src1"#!if(!eq(NvOpNum, 0),".new, ",", ")#
1401 "$src2"#!if(!eq(NvOpNum, 1),".new))","))")#" jump:"
1402 #!if(isTak, "t","nt")#" $offset", []> {
1406 bits<3> Ns; // New-Value Operand
1407 bits<5> RegOp; // Non-New-Value Operand
1410 let isTaken = isTak;
1411 let isPredicatedFalse = isNegCond;
1412 let opNewValue{0} = NvOpNum;
1414 let Ns = !if(!eq(NvOpNum, 0), src1{2-0}, src2{2-0});
1415 let RegOp = !if(!eq(NvOpNum, 0), src2, src1);
1417 let IClass = 0b0010;
1419 let Inst{25-23} = majOp;
1420 let Inst{22} = isNegCond;
1421 let Inst{18-16} = Ns;
1422 let Inst{13} = isTak;
1423 let Inst{12-8} = RegOp;
1424 let Inst{21-20} = offset{10-9};
1425 let Inst{7-1} = offset{8-2};
1429 multiclass NVJrr_cond<string mnemonic, bits<3> majOp, bit NvOpNum,
1431 // Branch not taken:
1432 def _nt_V4: NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 0>;
1434 def _t_V4: NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 1>;
1437 // NvOpNum = 0 -> First Operand is a new-value Register
1438 // NvOpNum = 1 -> Second Operand is a new-value Register
1440 multiclass NVJrr_base<string mnemonic, string BaseOp, bits<3> majOp,
1442 let BaseOpcode = BaseOp#_NVJ in {
1443 defm _t_Jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 0>; // True cond
1444 defm _f_Jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 1>; // False cond
1448 // if ([!]cmp.eq(Ns.new,Rt)) jump:[n]t #r9:2
1449 // if ([!]cmp.gt(Ns.new,Rt)) jump:[n]t #r9:2
1450 // if ([!]cmp.gtu(Ns.new,Rt)) jump:[n]t #r9:2
1451 // if ([!]cmp.gt(Rt,Ns.new)) jump:[n]t #r9:2
1452 // if ([!]cmp.gtu(Rt,Ns.new)) jump:[n]t #r9:2
1454 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1455 Defs = [PC], hasSideEffects = 0, validSubTargets = HasV4SubT,
1456 isCodeGenOnly = 0 in {
1457 defm CMPEQrr : NVJrr_base<"cmp.eq", "CMPEQ", 0b000, 0>, PredRel;
1458 defm CMPGTrr : NVJrr_base<"cmp.gt", "CMPGT", 0b001, 0>, PredRel;
1459 defm CMPGTUrr : NVJrr_base<"cmp.gtu", "CMPGTU", 0b010, 0>, PredRel;
1460 defm CMPLTrr : NVJrr_base<"cmp.gt", "CMPLT", 0b011, 1>, PredRel;
1461 defm CMPLTUrr : NVJrr_base<"cmp.gtu", "CMPLTU", 0b100, 1>, PredRel;
1464 //===----------------------------------------------------------------------===//
1465 // multiclass/template class for the new-value compare jumps instruction
1466 // with a register and an unsigned immediate (U5) operand.
1467 //===----------------------------------------------------------------------===//
1469 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1470 opExtentAlign = 2 in
1471 class NVJri_template<string mnemonic, bits<3> majOp, bit isNegCond,
1474 (ins IntRegs:$src1, u5Imm:$src2, brtarget:$offset),
1475 "if ("#!if(isNegCond, "!","")#mnemonic#"($src1.new, #$src2)) jump:"
1476 #!if(isTak, "t","nt")#" $offset", []> {
1478 let isTaken = isTak;
1479 let isPredicatedFalse = isNegCond;
1480 let isTaken = isTak;
1486 let IClass = 0b0010;
1488 let Inst{25-23} = majOp;
1489 let Inst{22} = isNegCond;
1490 let Inst{18-16} = src1;
1491 let Inst{13} = isTak;
1492 let Inst{12-8} = src2;
1493 let Inst{21-20} = offset{10-9};
1494 let Inst{7-1} = offset{8-2};
1497 multiclass NVJri_cond<string mnemonic, bits<3> majOp, bit isNegCond> {
1498 // Branch not taken:
1499 def _nt_V4: NVJri_template<mnemonic, majOp, isNegCond, 0>;
1501 def _t_V4: NVJri_template<mnemonic, majOp, isNegCond, 1>;
1504 multiclass NVJri_base<string mnemonic, string BaseOp, bits<3> majOp> {
1505 let BaseOpcode = BaseOp#_NVJri in {
1506 defm _t_Jumpnv : NVJri_cond<mnemonic, majOp, 0>; // True Cond
1507 defm _f_Jumpnv : NVJri_cond<mnemonic, majOp, 1>; // False cond
1511 // if ([!]cmp.eq(Ns.new,#U5)) jump:[n]t #r9:2
1512 // if ([!]cmp.gt(Ns.new,#U5)) jump:[n]t #r9:2
1513 // if ([!]cmp.gtu(Ns.new,#U5)) jump:[n]t #r9:2
1515 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1516 Defs = [PC], hasSideEffects = 0, validSubTargets = HasV4SubT,
1517 isCodeGenOnly = 0 in {
1518 defm CMPEQri : NVJri_base<"cmp.eq", "CMPEQ", 0b000>, PredRel;
1519 defm CMPGTri : NVJri_base<"cmp.gt", "CMPGT", 0b001>, PredRel;
1520 defm CMPGTUri : NVJri_base<"cmp.gtu", "CMPGTU", 0b010>, PredRel;
1523 //===----------------------------------------------------------------------===//
1524 // multiclass/template class for the new-value compare jumps instruction
1525 // with a register and an hardcoded 0/-1 immediate value.
1526 //===----------------------------------------------------------------------===//
1528 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 11,
1529 opExtentAlign = 2 in
1530 class NVJ_ConstImm_template<string mnemonic, bits<3> majOp, string ImmVal,
1531 bit isNegCond, bit isTak>
1533 (ins IntRegs:$src1, brtarget:$offset),
1534 "if ("#!if(isNegCond, "!","")#mnemonic
1535 #"($src1.new, #"#ImmVal#")) jump:"
1536 #!if(isTak, "t","nt")#" $offset", []> {
1538 let isTaken = isTak;
1539 let isPredicatedFalse = isNegCond;
1540 let isTaken = isTak;
1544 let IClass = 0b0010;
1546 let Inst{25-23} = majOp;
1547 let Inst{22} = isNegCond;
1548 let Inst{18-16} = src1;
1549 let Inst{13} = isTak;
1550 let Inst{21-20} = offset{10-9};
1551 let Inst{7-1} = offset{8-2};
1554 multiclass NVJ_ConstImm_cond<string mnemonic, bits<3> majOp, string ImmVal,
1556 // Branch not taken:
1557 def _nt_V4: NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 0>;
1559 def _t_V4: NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 1>;
1562 multiclass NVJ_ConstImm_base<string mnemonic, string BaseOp, bits<3> majOp,
1564 let BaseOpcode = BaseOp#_NVJ_ConstImm in {
1565 defm _t_Jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 0>; // True
1566 defm _f_Jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 1>; // False
1570 // if ([!]tstbit(Ns.new,#0)) jump:[n]t #r9:2
1571 // if ([!]cmp.eq(Ns.new,#-1)) jump:[n]t #r9:2
1572 // if ([!]cmp.gt(Ns.new,#-1)) jump:[n]t #r9:2
1574 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1,
1575 Defs = [PC], hasSideEffects = 0, isCodeGenOnly = 0 in {
1576 defm TSTBIT0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel;
1577 defm CMPEQn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "-1">, PredRel;
1578 defm CMPGTn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "-1">, PredRel;
1581 // J4_hintjumpr: Hint indirect conditional jump.
1582 let isBranch = 1, isIndirectBranch = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
1583 def J4_hintjumpr: JRInst <
1588 let IClass = 0b0101;
1589 let Inst{27-21} = 0b0010101;
1590 let Inst{20-16} = Rs;
1593 //===----------------------------------------------------------------------===//
1595 //===----------------------------------------------------------------------===//
1597 //===----------------------------------------------------------------------===//
1599 //===----------------------------------------------------------------------===//
1602 let hasNewValue = 1, isExtendable = 1, opExtendable = 1,
1603 isExtentSigned = 0, opExtentBits = 6, hasSideEffects = 0,
1604 Uses = [PC], validSubTargets = HasV4SubT, isCodeGenOnly = 0 in
1605 def C4_addipc : CRInst <(outs IntRegs:$Rd), (ins u6Ext:$u6),
1606 "$Rd = add(pc, #$u6)", [], "", CR_tc_2_SLOT3 > {
1610 let IClass = 0b0110;
1611 let Inst{27-16} = 0b101001001001;
1612 let Inst{12-7} = u6;
1618 let hasSideEffects = 0 in
1619 class T_LOGICAL_3OP<string MnOp1, string MnOp2, bits<2> OpBits, bit IsNeg>
1620 : CRInst<(outs PredRegs:$Pd),
1621 (ins PredRegs:$Ps, PredRegs:$Pt, PredRegs:$Pu),
1622 "$Pd = " # MnOp1 # "($Ps, " # MnOp2 # "($Pt, " #
1623 !if (IsNeg,"!","") # "$Pu))",
1624 [], "", CR_tc_2early_SLOT23> {
1630 let IClass = 0b0110;
1631 let Inst{27-24} = 0b1011;
1632 let Inst{23} = IsNeg;
1633 let Inst{22-21} = OpBits;
1635 let Inst{17-16} = Ps;
1642 let isCodeGenOnly = 0 in {
1643 def C4_and_and : T_LOGICAL_3OP<"and", "and", 0b00, 0>;
1644 def C4_and_or : T_LOGICAL_3OP<"and", "or", 0b01, 0>;
1645 def C4_or_and : T_LOGICAL_3OP<"or", "and", 0b10, 0>;
1646 def C4_or_or : T_LOGICAL_3OP<"or", "or", 0b11, 0>;
1647 def C4_and_andn : T_LOGICAL_3OP<"and", "and", 0b00, 1>;
1648 def C4_and_orn : T_LOGICAL_3OP<"and", "or", 0b01, 1>;
1649 def C4_or_andn : T_LOGICAL_3OP<"or", "and", 0b10, 1>;
1650 def C4_or_orn : T_LOGICAL_3OP<"or", "or", 0b11, 1>;
1653 //===----------------------------------------------------------------------===//
1655 //===----------------------------------------------------------------------===//
1657 //===----------------------------------------------------------------------===//
1659 //===----------------------------------------------------------------------===//
1661 // Logical with-not instructions.
1662 let validSubTargets = HasV4SubT, isCodeGenOnly = 0 in {
1663 def A4_andnp : T_ALU64_logical<"and", 0b001, 1, 0, 1>;
1664 def A4_ornp : T_ALU64_logical<"or", 0b011, 1, 0, 1>;
1667 let hasNewValue = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
1668 def S4_parity: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1669 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1674 let IClass = 0b1101;
1675 let Inst{27-21} = 0b0101111;
1676 let Inst{20-16} = Rs;
1677 let Inst{12-8} = Rt;
1680 // Add and accumulate.
1681 // Rd=add(Rs,add(Ru,#s6))
1682 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 6,
1683 opExtendable = 3, isCodeGenOnly = 0 in
1684 def S4_addaddi : ALU64Inst <(outs IntRegs:$Rd),
1685 (ins IntRegs:$Rs, IntRegs:$Ru, s6Ext:$s6),
1686 "$Rd = add($Rs, add($Ru, #$s6))" ,
1687 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs),
1688 (add (i32 IntRegs:$Ru), s6_16ExtPred:$s6)))],
1689 "", ALU64_tc_2_SLOT23> {
1695 let IClass = 0b1101;
1697 let Inst{27-23} = 0b10110;
1698 let Inst{22-21} = s6{5-4};
1699 let Inst{20-16} = Rs;
1700 let Inst{13} = s6{3};
1701 let Inst{12-8} = Rd;
1702 let Inst{7-5} = s6{2-0};
1706 let isExtentSigned = 1, hasSideEffects = 0, hasNewValue = 1, isExtendable = 1,
1707 opExtentBits = 6, opExtendable = 2, isCodeGenOnly = 0 in
1708 def S4_subaddi: ALU64Inst <(outs IntRegs:$Rd),
1709 (ins IntRegs:$Rs, s6Ext:$s6, IntRegs:$Ru),
1710 "$Rd = add($Rs, sub(#$s6, $Ru))",
1711 [], "", ALU64_tc_2_SLOT23> {
1717 let IClass = 0b1101;
1719 let Inst{27-23} = 0b10111;
1720 let Inst{22-21} = s6{5-4};
1721 let Inst{20-16} = Rs;
1722 let Inst{13} = s6{3};
1723 let Inst{12-8} = Rd;
1724 let Inst{7-5} = s6{2-0};
1729 // Rdd=extract(Rss,#u6,#U6)
1730 // Rdd=extract(Rss,Rtt)
1731 // Rd=extract(Rs,Rtt)
1732 // Rd=extract(Rs,#u5,#U5)
1734 let isCodeGenOnly = 0 in {
1735 def S4_extractp_rp : T_S3op_64 < "extract", 0b11, 0b100, 0>;
1736 def S4_extractp : T_S2op_extract <"extract", 0b1010, DoubleRegs, u6Imm>;
1739 let hasNewValue = 1, isCodeGenOnly = 0 in {
1740 def S4_extract_rp : T_S3op_extract<"extract", 0b01>;
1741 def S4_extract : T_S2op_extract <"extract", 0b1101, IntRegs, u5Imm>;
1744 let Itinerary = M_tc_3x_SLOT23, Defs = [USR_OVF], isCodeGenOnly = 0 in {
1745 def M4_mac_up_s1_sat: T_MType_acc_rr<"+= mpy", 0b011, 0b000, 0, [], 0, 1, 1>;
1746 def M4_nac_up_s1_sat: T_MType_acc_rr<"-= mpy", 0b011, 0b001, 0, [], 0, 1, 1>;
1749 // Logical xor with xor accumulation.
1750 // Rxx^=xor(Rss,Rtt)
1751 let hasSideEffects = 0, isCodeGenOnly = 0 in
1753 : SInst <(outs DoubleRegs:$Rxx),
1754 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
1755 "$Rxx ^= xor($Rss, $Rtt)",
1756 [(set (i64 DoubleRegs:$Rxx),
1757 (xor (i64 DoubleRegs:$dst2), (xor (i64 DoubleRegs:$Rss),
1758 (i64 DoubleRegs:$Rtt))))],
1759 "$dst2 = $Rxx", S_3op_tc_1_SLOT23> {
1764 let IClass = 0b1100;
1766 let Inst{27-23} = 0b10101;
1767 let Inst{20-16} = Rss;
1768 let Inst{12-8} = Rtt;
1769 let Inst{4-0} = Rxx;
1773 let isCodeGenOnly = 0 in
1774 def A4_bitspliti : T_S2op_2_di <"bitsplit", 0b110, 0b100>;
1776 // Arithmetic/Convergent round
1777 let isCodeGenOnly = 0 in
1778 def A4_cround_ri : T_S2op_2_ii <"cround", 0b111, 0b000>;
1780 let isCodeGenOnly = 0 in
1781 def A4_round_ri : T_S2op_2_ii <"round", 0b111, 0b100>;
1783 let Defs = [USR_OVF], isCodeGenOnly = 0 in
1784 def A4_round_ri_sat : T_S2op_2_ii <"round", 0b111, 0b110, 1>;
1786 // Logical-logical words.
1787 // Compound or-and -- Rx=or(Ru,and(Rx,#s10))
1788 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 10,
1789 opExtendable = 3, isCodeGenOnly = 0 in
1791 ALU64Inst<(outs IntRegs:$Rx),
1792 (ins IntRegs:$Ru, IntRegs:$_src_, s10Ext:$s10),
1793 "$Rx = or($Ru, and($_src_, #$s10))" ,
1794 [(set (i32 IntRegs:$Rx),
1795 (or (i32 IntRegs:$Ru), (and (i32 IntRegs:$_src_), s10ExtPred:$s10)))] ,
1796 "$_src_ = $Rx", ALU64_tc_2_SLOT23> {
1801 let IClass = 0b1101;
1803 let Inst{27-22} = 0b101001;
1804 let Inst{20-16} = Rx;
1805 let Inst{21} = s10{9};
1806 let Inst{13-5} = s10{8-0};
1810 // Miscellaneous ALU64 instructions.
1812 let hasNewValue = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
1813 def A4_modwrapu: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1814 "$Rd = modwrap($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1819 let IClass = 0b1101;
1820 let Inst{27-21} = 0b0011111;
1821 let Inst{20-16} = Rs;
1822 let Inst{12-8} = Rt;
1823 let Inst{7-5} = 0b111;
1827 let hasSideEffects = 0, isCodeGenOnly = 0 in
1828 def A4_bitsplit: ALU64Inst<(outs DoubleRegs:$Rd),
1829 (ins IntRegs:$Rs, IntRegs:$Rt),
1830 "$Rd = bitsplit($Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
1835 let IClass = 0b1101;
1836 let Inst{27-24} = 0b0100;
1838 let Inst{20-16} = Rs;
1839 let Inst{12-8} = Rt;
1843 let isCodeGenOnly = 0 in {
1844 // Rx[&|]=xor(Rs,Rt)
1845 def M4_or_xor : T_MType_acc_rr < "|= xor", 0b110, 0b001, 0>;
1846 def M4_and_xor : T_MType_acc_rr < "&= xor", 0b010, 0b010, 0>;
1848 // Rx[&|^]=or(Rs,Rt)
1849 def M4_xor_or : T_MType_acc_rr < "^= or", 0b110, 0b011, 0>;
1851 let CextOpcode = "ORr_ORr" in
1852 def M4_or_or : T_MType_acc_rr < "|= or", 0b110, 0b000, 0>;
1853 def M4_and_or : T_MType_acc_rr < "&= or", 0b010, 0b001, 0>;
1855 // Rx[&|^]=and(Rs,Rt)
1856 def M4_xor_and : T_MType_acc_rr < "^= and", 0b110, 0b010, 0>;
1858 let CextOpcode = "ORr_ANDr" in
1859 def M4_or_and : T_MType_acc_rr < "|= and", 0b010, 0b011, 0>;
1860 def M4_and_and : T_MType_acc_rr < "&= and", 0b010, 0b000, 0>;
1862 // Rx[&|^]=and(Rs,~Rt)
1863 def M4_xor_andn : T_MType_acc_rr < "^= and", 0b001, 0b010, 0, [], 1>;
1864 def M4_or_andn : T_MType_acc_rr < "|= and", 0b001, 0b000, 0, [], 1>;
1865 def M4_and_andn : T_MType_acc_rr < "&= and", 0b001, 0b001, 0, [], 1>;
1868 // Compound or-or and or-and
1869 let isExtentSigned = 1, InputType = "imm", hasNewValue = 1, isExtendable = 1,
1870 opExtentBits = 10, opExtendable = 3 in
1871 class T_CompOR <string mnemonic, bits<2> MajOp, SDNode OpNode>
1872 : MInst_acc <(outs IntRegs:$Rx),
1873 (ins IntRegs:$src1, IntRegs:$Rs, s10Ext:$s10),
1874 "$Rx |= "#mnemonic#"($Rs, #$s10)",
1875 [(set (i32 IntRegs:$Rx), (or (i32 IntRegs:$src1),
1876 (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10)))],
1877 "$src1 = $Rx", ALU64_tc_2_SLOT23>, ImmRegRel {
1882 let IClass = 0b1101;
1884 let Inst{27-24} = 0b1010;
1885 let Inst{23-22} = MajOp;
1886 let Inst{20-16} = Rs;
1887 let Inst{21} = s10{9};
1888 let Inst{13-5} = s10{8-0};
1892 let CextOpcode = "ORr_ANDr", isCodeGenOnly = 0 in
1893 def S4_or_andi : T_CompOR <"and", 0b00, and>;
1895 let CextOpcode = "ORr_ORr", isCodeGenOnly = 0 in
1896 def S4_or_ori : T_CompOR <"or", 0b10, or>;
1899 // Rd=modwrap(Rs,Rt)
1901 // Rd=cround(Rs,#u5)
1903 // Rd=round(Rs,#u5)[:sat]
1904 // Rd=round(Rs,Rt)[:sat]
1905 // Vector reduce add unsigned halfwords
1906 // Rd=vraddh(Rss,Rtt)
1908 // Rdd=vaddb(Rss,Rtt)
1909 // Vector conditional negate
1910 // Rdd=vcnegh(Rss,Rt)
1911 // Rxx+=vrcnegh(Rss,Rt)
1912 // Vector maximum bytes
1913 // Rdd=vmaxb(Rtt,Rss)
1914 // Vector reduce maximum halfwords
1915 // Rxx=vrmaxh(Rss,Ru)
1916 // Rxx=vrmaxuh(Rss,Ru)
1917 // Vector reduce maximum words
1918 // Rxx=vrmaxuw(Rss,Ru)
1919 // Rxx=vrmaxw(Rss,Ru)
1920 // Vector minimum bytes
1921 // Rdd=vminb(Rtt,Rss)
1922 // Vector reduce minimum halfwords
1923 // Rxx=vrminh(Rss,Ru)
1924 // Rxx=vrminuh(Rss,Ru)
1925 // Vector reduce minimum words
1926 // Rxx=vrminuw(Rss,Ru)
1927 // Rxx=vrminw(Rss,Ru)
1928 // Vector subtract bytes
1929 // Rdd=vsubb(Rss,Rtt)
1931 //===----------------------------------------------------------------------===//
1933 //===----------------------------------------------------------------------===//
1935 //===----------------------------------------------------------------------===//
1937 //===----------------------------------------------------------------------===//
1940 let isCodeGenOnly = 0 in
1941 def S2_brevp : T_S2op_3 <"brev", 0b11, 0b110>;
1944 let isCodeGenOnly = 0 in {
1945 def S2_ct0p : T_COUNT_LEADING_64<"ct0", 0b111, 0b010>;
1946 def S2_ct1p : T_COUNT_LEADING_64<"ct1", 0b111, 0b100>;
1947 def S4_clbpnorm : T_COUNT_LEADING_64<"normamt", 0b011, 0b000>;
1950 def: Pat<(i32 (trunc (cttz (i64 DoubleRegs:$Rss)))),
1951 (S2_ct0p (i64 DoubleRegs:$Rss))>;
1952 def: Pat<(i32 (trunc (cttz (not (i64 DoubleRegs:$Rss))))),
1953 (S2_ct1p (i64 DoubleRegs:$Rss))>;
1955 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
1956 def S4_clbaddi : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s6Imm:$s6),
1957 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
1961 let IClass = 0b1000;
1962 let Inst{27-24} = 0b1100;
1963 let Inst{23-21} = 0b001;
1964 let Inst{20-16} = Rs;
1965 let Inst{13-8} = s6;
1966 let Inst{7-5} = 0b000;
1970 let hasSideEffects = 0, hasNewValue = 1, isCodeGenOnly = 0 in
1971 def S4_clbpaddi : SInst<(outs IntRegs:$Rd), (ins DoubleRegs:$Rs, s6Imm:$s6),
1972 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
1976 let IClass = 0b1000;
1977 let Inst{27-24} = 0b1000;
1978 let Inst{23-21} = 0b011;
1979 let Inst{20-16} = Rs;
1980 let Inst{13-8} = s6;
1981 let Inst{7-5} = 0b010;
1986 // Bit test/set/clear
1987 let isCodeGenOnly = 0 in {
1988 def S4_ntstbit_i : T_TEST_BIT_IMM<"!tstbit", 0b001>;
1989 def S4_ntstbit_r : T_TEST_BIT_REG<"!tstbit", 1>;
1992 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
1993 def: Pat<(i1 (seteq (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
1994 (S4_ntstbit_i (i32 IntRegs:$Rs), u5ImmPred:$u5)>;
1995 def: Pat<(i1 (seteq (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
1996 (S4_ntstbit_r (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))>;
1999 // Add extra complexity to prefer these instructions over bitsset/bitsclr.
2000 // The reason is that tstbit/ntstbit can be folded into a compound instruction:
2001 // if ([!]tstbit(...)) jump ...
2002 let AddedComplexity = 100 in
2003 def: Pat<(i1 (setne (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2004 (S2_tstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2006 let AddedComplexity = 100 in
2007 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2008 (S4_ntstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2010 let isCodeGenOnly = 0 in {
2011 def C4_nbitsset : T_TEST_BITS_REG<"!bitsset", 0b01, 1>;
2012 def C4_nbitsclr : T_TEST_BITS_REG<"!bitsclr", 0b10, 1>;
2013 def C4_nbitsclri : T_TEST_BITS_IMM<"!bitsclr", 0b10, 1>;
2016 // Do not increase complexity of these patterns. In the DAG, "cmp i8" may be
2017 // represented as a compare against "value & 0xFF", which is an exact match
2018 // for cmpb (same for cmph). The patterns below do not contain any additional
2019 // complexity that would make them preferable, and if they were actually used
2020 // instead of cmpb/cmph, they would result in a compare against register that
2021 // is loaded with the byte/half mask (i.e. 0xFF or 0xFFFF).
2022 def: Pat<(i1 (setne (and I32:$Rs, u6ImmPred:$u6), 0)),
2023 (C4_nbitsclri I32:$Rs, u6ImmPred:$u6)>;
2024 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), 0)),
2025 (C4_nbitsclr I32:$Rs, I32:$Rt)>;
2026 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), I32:$Rt)),
2027 (C4_nbitsset I32:$Rs, I32:$Rt)>;
2029 //===----------------------------------------------------------------------===//
2031 //===----------------------------------------------------------------------===//
2033 //===----------------------------------------------------------------------===//
2035 //===----------------------------------------------------------------------===//
2037 // Rd=add(#u6,mpyi(Rs,#U6)) -- Multiply by immed and add immed.
2039 let hasNewValue = 1, isExtendable = 1, opExtentBits = 6, opExtendable = 1,
2040 isCodeGenOnly = 0 in
2041 def M4_mpyri_addi : MInst<(outs IntRegs:$Rd),
2042 (ins u6Ext:$u6, IntRegs:$Rs, u6Imm:$U6),
2043 "$Rd = add(#$u6, mpyi($Rs, #$U6))" ,
2044 [(set (i32 IntRegs:$Rd),
2045 (add (mul (i32 IntRegs:$Rs), u6ImmPred:$U6),
2046 u6ExtPred:$u6))] ,"",ALU64_tc_3x_SLOT23> {
2052 let IClass = 0b1101;
2054 let Inst{27-24} = 0b1000;
2055 let Inst{23} = U6{5};
2056 let Inst{22-21} = u6{5-4};
2057 let Inst{20-16} = Rs;
2058 let Inst{13} = u6{3};
2059 let Inst{12-8} = Rd;
2060 let Inst{7-5} = u6{2-0};
2061 let Inst{4-0} = U6{4-0};
2064 // Rd=add(#u6,mpyi(Rs,Rt))
2065 let CextOpcode = "ADD_MPY", InputType = "imm", hasNewValue = 1,
2066 isExtendable = 1, opExtentBits = 6, opExtendable = 1, isCodeGenOnly = 0 in
2067 def M4_mpyrr_addi : MInst <(outs IntRegs:$Rd),
2068 (ins u6Ext:$u6, IntRegs:$Rs, IntRegs:$Rt),
2069 "$Rd = add(#$u6, mpyi($Rs, $Rt))" ,
2070 [(set (i32 IntRegs:$Rd),
2071 (add (mul (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), u6ExtPred:$u6))],
2072 "", ALU64_tc_3x_SLOT23>, ImmRegRel {
2078 let IClass = 0b1101;
2080 let Inst{27-23} = 0b01110;
2081 let Inst{22-21} = u6{5-4};
2082 let Inst{20-16} = Rs;
2083 let Inst{13} = u6{3};
2084 let Inst{12-8} = Rt;
2085 let Inst{7-5} = u6{2-0};
2089 let hasNewValue = 1 in
2090 class T_AddMpy <bit MajOp, PatLeaf ImmPred, dag ins>
2091 : ALU64Inst <(outs IntRegs:$dst), ins,
2092 "$dst = add($src1, mpyi("#!if(MajOp,"$src3, #$src2))",
2094 [(set (i32 IntRegs:$dst),
2095 (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src3), ImmPred:$src2)))],
2096 "", ALU64_tc_3x_SLOT23> {
2102 let IClass = 0b1101;
2104 bits<6> ImmValue = !if(MajOp, src2{5-0}, src2{7-2});
2106 let Inst{27-24} = 0b1111;
2107 let Inst{23} = MajOp;
2108 let Inst{22-21} = ImmValue{5-4};
2109 let Inst{20-16} = src3;
2110 let Inst{13} = ImmValue{3};
2111 let Inst{12-8} = dst;
2112 let Inst{7-5} = ImmValue{2-0};
2113 let Inst{4-0} = src1;
2116 let isCodeGenOnly = 0 in
2117 def M4_mpyri_addr_u2 : T_AddMpy<0b0, u6_2ImmPred,
2118 (ins IntRegs:$src1, u6_2Imm:$src2, IntRegs:$src3)>;
2120 let isExtendable = 1, opExtentBits = 6, opExtendable = 3,
2121 CextOpcode = "ADD_MPY", InputType = "imm", isCodeGenOnly = 0 in
2122 def M4_mpyri_addr : T_AddMpy<0b1, u6ExtPred,
2123 (ins IntRegs:$src1, IntRegs:$src3, u6Ext:$src2)>, ImmRegRel;
2125 // Rx=add(Ru,mpyi(Rx,Rs))
2126 let validSubTargets = HasV4SubT, CextOpcode = "ADD_MPY", InputType = "reg",
2127 hasNewValue = 1, isCodeGenOnly = 0 in
2128 def M4_mpyrr_addr: MInst_acc <(outs IntRegs:$Rx),
2129 (ins IntRegs:$Ru, IntRegs:$_src_, IntRegs:$Rs),
2130 "$Rx = add($Ru, mpyi($_src_, $Rs))",
2131 [(set (i32 IntRegs:$Rx), (add (i32 IntRegs:$Ru),
2132 (mul (i32 IntRegs:$_src_), (i32 IntRegs:$Rs))))],
2133 "$_src_ = $Rx", M_tc_3x_SLOT23>, ImmRegRel {
2138 let IClass = 0b1110;
2140 let Inst{27-21} = 0b0011000;
2141 let Inst{12-8} = Rx;
2143 let Inst{20-16} = Rs;
2146 // Rd=add(##,mpyi(Rs,#U6))
2147 def : Pat <(add (mul (i32 IntRegs:$src2), u6ImmPred:$src3),
2148 (HexagonCONST32 tglobaladdr:$src1)),
2149 (i32 (M4_mpyri_addi tglobaladdr:$src1, IntRegs:$src2,
2152 // Rd=add(##,mpyi(Rs,Rt))
2153 def : Pat <(add (mul (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2154 (HexagonCONST32 tglobaladdr:$src1)),
2155 (i32 (M4_mpyrr_addi tglobaladdr:$src1, IntRegs:$src2,
2158 // Vector reduce multiply word by signed half (32x16)
2159 // Rdd=vrmpyweh(Rss,Rtt)[:<<1]
2160 // Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2161 // Rxx+=vrmpyweh(Rss,Rtt)[:<<1]
2162 // Rxx+=vrmpywoh(Rss,Rtt)[:<<1]
2164 // Multiply and use upper result
2165 // Rd=mpy(Rs,Rt.H):<<1:sat
2166 // Rd=mpy(Rs,Rt.L):<<1:sat
2167 // Rd=mpy(Rs,Rt):<<1
2168 // Rd=mpy(Rs,Rt):<<1:sat
2170 // Rx+=mpy(Rs,Rt):<<1:sat
2171 // Rx-=mpy(Rs,Rt):<<1:sat
2173 // Vector multiply bytes
2174 // Rdd=vmpybsu(Rs,Rt)
2175 // Rdd=vmpybu(Rs,Rt)
2176 // Rxx+=vmpybsu(Rs,Rt)
2177 // Rxx+=vmpybu(Rs,Rt)
2179 // Vector polynomial multiply halfwords
2180 // Rdd=vpmpyh(Rs,Rt)
2181 // Rxx^=vpmpyh(Rs,Rt)
2183 // Polynomial multiply words
2185 let isCodeGenOnly = 0 in
2186 def M4_pmpyw : T_XTYPE_mpy64 < "pmpyw", 0b010, 0b111, 0, 0, 0>;
2188 // Rxx^=pmpyw(Rs,Rt)
2189 let isCodeGenOnly = 0 in
2190 def M4_pmpyw_acc : T_XTYPE_mpy64_acc < "pmpyw", "^", 0b001, 0b111, 0, 0, 0>;
2192 //===----------------------------------------------------------------------===//
2194 //===----------------------------------------------------------------------===//
2197 //===----------------------------------------------------------------------===//
2199 //===----------------------------------------------------------------------===//
2200 // Shift by immediate and accumulate/logical.
2201 // Rx=add(#u8,asl(Rx,#U5)) Rx=add(#u8,lsr(Rx,#U5))
2202 // Rx=sub(#u8,asl(Rx,#U5)) Rx=sub(#u8,lsr(Rx,#U5))
2203 // Rx=and(#u8,asl(Rx,#U5)) Rx=and(#u8,lsr(Rx,#U5))
2204 // Rx=or(#u8,asl(Rx,#U5)) Rx=or(#u8,lsr(Rx,#U5))
2205 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8,
2206 hasNewValue = 1, opNewValue = 0, validSubTargets = HasV4SubT in
2207 class T_S4_ShiftOperate<string MnOp, string MnSh, SDNode Op, SDNode Sh,
2208 bit asl_lsr, bits<2> MajOp, InstrItinClass Itin>
2209 : MInst_acc<(outs IntRegs:$Rd), (ins u8Ext:$u8, IntRegs:$Rx, u5Imm:$U5),
2210 "$Rd = "#MnOp#"(#$u8, "#MnSh#"($Rx, #$U5))",
2211 [(set (i32 IntRegs:$Rd),
2212 (Op (Sh I32:$Rx, u5ImmPred:$U5), u8ExtPred:$u8))],
2213 "$Rd = $Rx", Itin> {
2220 let IClass = 0b1101;
2221 let Inst{27-24} = 0b1110;
2222 let Inst{23-21} = u8{7-5};
2223 let Inst{20-16} = Rd;
2224 let Inst{13} = u8{4};
2225 let Inst{12-8} = U5;
2226 let Inst{7-5} = u8{3-1};
2227 let Inst{4} = asl_lsr;
2228 let Inst{3} = u8{0};
2229 let Inst{2-1} = MajOp;
2232 multiclass T_ShiftOperate<string mnemonic, SDNode Op, bits<2> MajOp,
2233 InstrItinClass Itin> {
2234 def _asl_ri : T_S4_ShiftOperate<mnemonic, "asl", Op, shl, 0, MajOp, Itin>;
2235 def _lsr_ri : T_S4_ShiftOperate<mnemonic, "lsr", Op, srl, 1, MajOp, Itin>;
2238 let AddedComplexity = 200, isCodeGenOnly = 0 in {
2239 defm S4_addi : T_ShiftOperate<"add", add, 0b10, ALU64_tc_2_SLOT23>;
2240 defm S4_andi : T_ShiftOperate<"and", and, 0b00, ALU64_tc_2_SLOT23>;
2243 let AddedComplexity = 30, isCodeGenOnly = 0 in
2244 defm S4_ori : T_ShiftOperate<"or", or, 0b01, ALU64_tc_1_SLOT23>;
2246 let isCodeGenOnly = 0 in
2247 defm S4_subi : T_ShiftOperate<"sub", sub, 0b11, ALU64_tc_1_SLOT23>;
2250 // Rd=[cround|round](Rs,Rt)
2251 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23, isCodeGenOnly = 0 in {
2252 def A4_cround_rr : T_S3op_3 < "cround", IntRegs, 0b11, 0b00>;
2253 def A4_round_rr : T_S3op_3 < "round", IntRegs, 0b11, 0b10>;
2256 // Rd=round(Rs,Rt):sat
2257 let hasNewValue = 1, Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23,
2258 isCodeGenOnly = 0 in
2259 def A4_round_rr_sat : T_S3op_3 < "round", IntRegs, 0b11, 0b11, 1>;
2261 // Rdd=[add|sub](Rss,Rtt,Px):carry
2262 let isPredicateLate = 1, hasSideEffects = 0 in
2263 class T_S3op_carry <string mnemonic, bits<3> MajOp>
2264 : SInst < (outs DoubleRegs:$Rdd, PredRegs:$Px),
2265 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
2266 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu):carry",
2267 [], "$Px = $Pu", S_3op_tc_1_SLOT23 > {
2273 let IClass = 0b1100;
2275 let Inst{27-24} = 0b0010;
2276 let Inst{23-21} = MajOp;
2277 let Inst{20-16} = Rss;
2278 let Inst{12-8} = Rtt;
2280 let Inst{4-0} = Rdd;
2283 let isCodeGenOnly = 0 in {
2284 def A4_addp_c : T_S3op_carry < "add", 0b110 >;
2285 def A4_subp_c : T_S3op_carry < "sub", 0b111 >;
2288 // Shift an immediate left by register amount.
2289 let hasNewValue = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
2290 def S4_lsli: SInst <(outs IntRegs:$Rd), (ins s6Imm:$s6, IntRegs:$Rt),
2291 "$Rd = lsl(#$s6, $Rt)" ,
2292 [(set (i32 IntRegs:$Rd), (shl s6ImmPred:$s6,
2293 (i32 IntRegs:$Rt)))],
2294 "", S_3op_tc_1_SLOT23> {
2299 let IClass = 0b1100;
2301 let Inst{27-22} = 0b011010;
2302 let Inst{20-16} = s6{5-1};
2303 let Inst{12-8} = Rt;
2304 let Inst{7-6} = 0b11;
2306 let Inst{5} = s6{0};
2309 //===----------------------------------------------------------------------===//
2311 //===----------------------------------------------------------------------===//
2313 //===----------------------------------------------------------------------===//
2314 // MEMOP: Word, Half, Byte
2315 //===----------------------------------------------------------------------===//
2317 def MEMOPIMM : SDNodeXForm<imm, [{
2318 // Call the transformation function XformM5ToU5Imm to get the negative
2319 // immediate's positive counterpart.
2320 int32_t imm = N->getSExtValue();
2321 return XformM5ToU5Imm(imm);
2324 def MEMOPIMM_HALF : SDNodeXForm<imm, [{
2325 // -1 .. -31 represented as 65535..65515
2326 // assigning to a short restores our desired signed value.
2327 // Call the transformation function XformM5ToU5Imm to get the negative
2328 // immediate's positive counterpart.
2329 int16_t imm = N->getSExtValue();
2330 return XformM5ToU5Imm(imm);
2333 def MEMOPIMM_BYTE : SDNodeXForm<imm, [{
2334 // -1 .. -31 represented as 255..235
2335 // assigning to a char restores our desired signed value.
2336 // Call the transformation function XformM5ToU5Imm to get the negative
2337 // immediate's positive counterpart.
2338 int8_t imm = N->getSExtValue();
2339 return XformM5ToU5Imm(imm);
2342 def SETMEMIMM : SDNodeXForm<imm, [{
2343 // Return the bit position we will set [0-31].
2345 int32_t imm = N->getSExtValue();
2346 return XformMskToBitPosU5Imm(imm);
2349 def CLRMEMIMM : SDNodeXForm<imm, [{
2350 // Return the bit position we will clear [0-31].
2352 // we bit negate the value first
2353 int32_t imm = ~(N->getSExtValue());
2354 return XformMskToBitPosU5Imm(imm);
2357 def SETMEMIMM_SHORT : SDNodeXForm<imm, [{
2358 // Return the bit position we will set [0-15].
2360 int16_t imm = N->getSExtValue();
2361 return XformMskToBitPosU4Imm(imm);
2364 def CLRMEMIMM_SHORT : SDNodeXForm<imm, [{
2365 // Return the bit position we will clear [0-15].
2367 // we bit negate the value first
2368 int16_t imm = ~(N->getSExtValue());
2369 return XformMskToBitPosU4Imm(imm);
2372 def SETMEMIMM_BYTE : SDNodeXForm<imm, [{
2373 // Return the bit position we will set [0-7].
2375 int8_t imm = N->getSExtValue();
2376 return XformMskToBitPosU3Imm(imm);
2379 def CLRMEMIMM_BYTE : SDNodeXForm<imm, [{
2380 // Return the bit position we will clear [0-7].
2382 // we bit negate the value first
2383 int8_t imm = ~(N->getSExtValue());
2384 return XformMskToBitPosU3Imm(imm);
2387 //===----------------------------------------------------------------------===//
2388 // Template class for MemOp instructions with the register value.
2389 //===----------------------------------------------------------------------===//
2390 class MemOp_rr_base <string opc, bits<2> opcBits, Operand ImmOp,
2391 string memOp, bits<2> memOpBits> :
2393 (ins IntRegs:$base, ImmOp:$offset, IntRegs:$delta),
2394 opc#"($base+#$offset)"#memOp#"$delta",
2396 Requires<[UseMEMOP]> {
2401 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2403 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2404 !if (!eq(opcBits, 0b01), offset{6-1},
2405 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2407 let opExtentAlign = opcBits;
2408 let IClass = 0b0011;
2409 let Inst{27-24} = 0b1110;
2410 let Inst{22-21} = opcBits;
2411 let Inst{20-16} = base;
2413 let Inst{12-7} = offsetBits;
2414 let Inst{6-5} = memOpBits;
2415 let Inst{4-0} = delta;
2418 //===----------------------------------------------------------------------===//
2419 // Template class for MemOp instructions with the immediate value.
2420 //===----------------------------------------------------------------------===//
2421 class MemOp_ri_base <string opc, bits<2> opcBits, Operand ImmOp,
2422 string memOp, bits<2> memOpBits> :
2424 (ins IntRegs:$base, ImmOp:$offset, u5Imm:$delta),
2425 opc#"($base+#$offset)"#memOp#"#$delta"
2426 #!if(memOpBits{1},")", ""), // clrbit, setbit - include ')'
2428 Requires<[UseMEMOP]> {
2433 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2435 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2436 !if (!eq(opcBits, 0b01), offset{6-1},
2437 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2439 let opExtentAlign = opcBits;
2440 let IClass = 0b0011;
2441 let Inst{27-24} = 0b1111;
2442 let Inst{22-21} = opcBits;
2443 let Inst{20-16} = base;
2445 let Inst{12-7} = offsetBits;
2446 let Inst{6-5} = memOpBits;
2447 let Inst{4-0} = delta;
2450 // multiclass to define MemOp instructions with register operand.
2451 multiclass MemOp_rr<string opc, bits<2> opcBits, Operand ImmOp> {
2452 def L4_add#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " += ", 0b00>; // add
2453 def L4_sub#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " -= ", 0b01>; // sub
2454 def L4_and#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " &= ", 0b10>; // and
2455 def L4_or#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " |= ", 0b11>; // or
2458 // multiclass to define MemOp instructions with immediate Operand.
2459 multiclass MemOp_ri<string opc, bits<2> opcBits, Operand ImmOp> {
2460 def L4_iadd#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " += ", 0b00 >;
2461 def L4_isub#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " -= ", 0b01 >;
2462 def L4_iand#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = clrbit(", 0b10>;
2463 def L4_ior#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = setbit(", 0b11>;
2466 multiclass MemOp_base <string opc, bits<2> opcBits, Operand ImmOp> {
2467 defm _#NAME : MemOp_rr <opc, opcBits, ImmOp>;
2468 defm _#NAME : MemOp_ri <opc, opcBits, ImmOp>;
2471 // Define MemOp instructions.
2472 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0,
2473 validSubTargets =HasV4SubT in {
2474 let opExtentBits = 6, accessSize = ByteAccess, isCodeGenOnly = 0 in
2475 defm memopb_io : MemOp_base <"memb", 0b00, u6_0Ext>;
2477 let opExtentBits = 7, accessSize = HalfWordAccess, isCodeGenOnly = 0 in
2478 defm memoph_io : MemOp_base <"memh", 0b01, u6_1Ext>;
2480 let opExtentBits = 8, accessSize = WordAccess, isCodeGenOnly = 0 in
2481 defm memopw_io : MemOp_base <"memw", 0b10, u6_2Ext>;
2484 //===----------------------------------------------------------------------===//
2485 // Multiclass to define 'Def Pats' for ALU operations on the memory
2486 // Here value used for the ALU operation is an immediate value.
2487 // mem[bh](Rs+#0) += #U5
2488 // mem[bh](Rs+#u6) += #U5
2489 //===----------------------------------------------------------------------===//
2491 multiclass MemOpi_u5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf ExtPred,
2492 InstHexagon MI, SDNode OpNode> {
2493 let AddedComplexity = 180 in
2494 def : Pat < (stOp (OpNode (ldOp IntRegs:$addr), u5ImmPred:$addend),
2496 (MI IntRegs:$addr, #0, u5ImmPred:$addend )>;
2498 let AddedComplexity = 190 in
2499 def : Pat <(stOp (OpNode (ldOp (add IntRegs:$base, ExtPred:$offset)),
2501 (add IntRegs:$base, ExtPred:$offset)),
2502 (MI IntRegs:$base, ExtPred:$offset, u5ImmPred:$addend)>;
2505 multiclass MemOpi_u5ALUOp<PatFrag ldOp, PatFrag stOp, PatLeaf ExtPred,
2506 InstHexagon addMI, InstHexagon subMI> {
2507 defm : MemOpi_u5Pats<ldOp, stOp, ExtPred, addMI, add>;
2508 defm : MemOpi_u5Pats<ldOp, stOp, ExtPred, subMI, sub>;
2511 multiclass MemOpi_u5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2513 defm : MemOpi_u5ALUOp <ldOpHalf, truncstorei16, u6_1ExtPred,
2514 L4_iadd_memoph_io, L4_isub_memoph_io>;
2516 defm : MemOpi_u5ALUOp <ldOpByte, truncstorei8, u6ExtPred,
2517 L4_iadd_memopb_io, L4_isub_memopb_io>;
2520 let Predicates = [HasV4T, UseMEMOP] in {
2521 defm : MemOpi_u5ExtType<zextloadi8, zextloadi16>; // zero extend
2522 defm : MemOpi_u5ExtType<sextloadi8, sextloadi16>; // sign extend
2523 defm : MemOpi_u5ExtType<extloadi8, extloadi16>; // any extend
2526 defm : MemOpi_u5ALUOp <load, store, u6_2ExtPred, L4_iadd_memopw_io,
2530 //===----------------------------------------------------------------------===//
2531 // multiclass to define 'Def Pats' for ALU operations on the memory.
2532 // Here value used for the ALU operation is a negative value.
2533 // mem[bh](Rs+#0) += #m5
2534 // mem[bh](Rs+#u6) += #m5
2535 //===----------------------------------------------------------------------===//
2537 multiclass MemOpi_m5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf extPred,
2538 PatLeaf immPred, ComplexPattern addrPred,
2539 SDNodeXForm xformFunc, InstHexagon MI> {
2540 let AddedComplexity = 190 in
2541 def : Pat <(stOp (add (ldOp IntRegs:$addr), immPred:$subend),
2543 (MI IntRegs:$addr, #0, (xformFunc immPred:$subend) )>;
2545 let AddedComplexity = 195 in
2546 def : Pat<(stOp (add (ldOp (add IntRegs:$base, extPred:$offset)),
2548 (add IntRegs:$base, extPred:$offset)),
2549 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$subend))>;
2552 multiclass MemOpi_m5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2554 defm : MemOpi_m5Pats <ldOpHalf, truncstorei16, u6_1ExtPred, m5HImmPred,
2555 ADDRriU6_1, MEMOPIMM_HALF, L4_isub_memoph_io>;
2557 defm : MemOpi_m5Pats <ldOpByte, truncstorei8, u6ExtPred, m5BImmPred,
2558 ADDRriU6_0, MEMOPIMM_BYTE, L4_isub_memopb_io>;
2561 let Predicates = [HasV4T, UseMEMOP] in {
2562 defm : MemOpi_m5ExtType<zextloadi8, zextloadi16>; // zero extend
2563 defm : MemOpi_m5ExtType<sextloadi8, sextloadi16>; // sign extend
2564 defm : MemOpi_m5ExtType<extloadi8, extloadi16>; // any extend
2567 defm : MemOpi_m5Pats <load, store, u6_2ExtPred, m5ImmPred,
2568 ADDRriU6_2, MEMOPIMM, L4_isub_memopw_io>;
2571 //===----------------------------------------------------------------------===//
2572 // Multiclass to define 'def Pats' for bit operations on the memory.
2573 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
2574 // mem[bhw](Rs+#u6) = [clrbit|setbit](#U5)
2575 //===----------------------------------------------------------------------===//
2577 multiclass MemOpi_bitPats <PatFrag ldOp, PatFrag stOp, PatLeaf immPred,
2578 PatLeaf extPred, ComplexPattern addrPred,
2579 SDNodeXForm xformFunc, InstHexagon MI, SDNode OpNode> {
2581 // mem[bhw](Rs+#u6:[012]) = [clrbit|setbit](#U5)
2582 let AddedComplexity = 250 in
2583 def : Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
2585 (add IntRegs:$base, extPred:$offset)),
2586 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$bitend))>;
2588 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
2589 let AddedComplexity = 225 in
2590 def : Pat <(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)),
2592 (addrPred (i32 IntRegs:$addr), extPred:$offset)),
2593 (MI IntRegs:$addr, extPred:$offset, (xformFunc immPred:$bitend))>;
2596 multiclass MemOpi_bitExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2598 defm : MemOpi_bitPats<ldOpByte, truncstorei8, Clr3ImmPred, u6ExtPred,
2599 ADDRriU6_0, CLRMEMIMM_BYTE, L4_iand_memopb_io, and>;
2601 defm : MemOpi_bitPats<ldOpByte, truncstorei8, Set3ImmPred, u6ExtPred,
2602 ADDRriU6_0, SETMEMIMM_BYTE, L4_ior_memopb_io, or>;
2603 // Half Word - clrbit
2604 defm : MemOpi_bitPats<ldOpHalf, truncstorei16, Clr4ImmPred, u6_1ExtPred,
2605 ADDRriU6_1, CLRMEMIMM_SHORT, L4_iand_memoph_io, and>;
2606 // Half Word - setbit
2607 defm : MemOpi_bitPats<ldOpHalf, truncstorei16, Set4ImmPred, u6_1ExtPred,
2608 ADDRriU6_1, SETMEMIMM_SHORT, L4_ior_memoph_io, or>;
2611 let Predicates = [HasV4T, UseMEMOP] in {
2612 // mem[bh](Rs+#0) = [clrbit|setbit](#U5)
2613 // mem[bh](Rs+#u6:[01]) = [clrbit|setbit](#U5)
2614 defm : MemOpi_bitExtType<zextloadi8, zextloadi16>; // zero extend
2615 defm : MemOpi_bitExtType<sextloadi8, sextloadi16>; // sign extend
2616 defm : MemOpi_bitExtType<extloadi8, extloadi16>; // any extend
2618 // memw(Rs+#0) = [clrbit|setbit](#U5)
2619 // memw(Rs+#u6:2) = [clrbit|setbit](#U5)
2620 defm : MemOpi_bitPats<load, store, Clr5ImmPred, u6_2ExtPred, ADDRriU6_2,
2621 CLRMEMIMM, L4_iand_memopw_io, and>;
2622 defm : MemOpi_bitPats<load, store, Set5ImmPred, u6_2ExtPred, ADDRriU6_2,
2623 SETMEMIMM, L4_ior_memopw_io, or>;
2626 //===----------------------------------------------------------------------===//
2627 // Multiclass to define 'def Pats' for ALU operations on the memory
2628 // where addend is a register.
2629 // mem[bhw](Rs+#0) [+-&|]= Rt
2630 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
2631 //===----------------------------------------------------------------------===//
2633 multiclass MemOpr_Pats <PatFrag ldOp, PatFrag stOp, ComplexPattern addrPred,
2634 PatLeaf extPred, InstHexagon MI, SDNode OpNode> {
2635 let AddedComplexity = 141 in
2636 // mem[bhw](Rs+#0) [+-&|]= Rt
2637 def : Pat <(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)),
2638 (i32 IntRegs:$addend)),
2639 (addrPred (i32 IntRegs:$addr), extPred:$offset)),
2640 (MI IntRegs:$addr, extPred:$offset, (i32 IntRegs:$addend) )>;
2642 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
2643 let AddedComplexity = 150 in
2644 def : Pat <(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
2645 (i32 IntRegs:$orend)),
2646 (add IntRegs:$base, extPred:$offset)),
2647 (MI IntRegs:$base, extPred:$offset, (i32 IntRegs:$orend) )>;
2650 multiclass MemOPr_ALUOp<PatFrag ldOp, PatFrag stOp,
2651 ComplexPattern addrPred, PatLeaf extPred,
2652 InstHexagon addMI, InstHexagon subMI,
2653 InstHexagon andMI, InstHexagon orMI > {
2655 defm : MemOpr_Pats <ldOp, stOp, addrPred, extPred, addMI, add>;
2656 defm : MemOpr_Pats <ldOp, stOp, addrPred, extPred, subMI, sub>;
2657 defm : MemOpr_Pats <ldOp, stOp, addrPred, extPred, andMI, and>;
2658 defm : MemOpr_Pats <ldOp, stOp, addrPred, extPred, orMI, or>;
2661 multiclass MemOPr_ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2663 defm : MemOPr_ALUOp <ldOpHalf, truncstorei16, ADDRriU6_1, u6_1ExtPred,
2664 L4_add_memoph_io, L4_sub_memoph_io,
2665 L4_and_memoph_io, L4_or_memoph_io>;
2667 defm : MemOPr_ALUOp <ldOpByte, truncstorei8, ADDRriU6_0, u6ExtPred,
2668 L4_add_memopb_io, L4_sub_memopb_io,
2669 L4_and_memopb_io, L4_or_memopb_io>;
2672 // Define 'def Pats' for MemOps with register addend.
2673 let Predicates = [HasV4T, UseMEMOP] in {
2675 defm : MemOPr_ExtType<zextloadi8, zextloadi16>; // zero extend
2676 defm : MemOPr_ExtType<sextloadi8, sextloadi16>; // sign extend
2677 defm : MemOPr_ExtType<extloadi8, extloadi16>; // any extend
2679 defm : MemOPr_ALUOp <load, store, ADDRriU6_2, u6_2ExtPred, L4_add_memopw_io,
2680 L4_sub_memopw_io, L4_and_memopw_io, L4_or_memopw_io >;
2683 //===----------------------------------------------------------------------===//
2685 //===----------------------------------------------------------------------===//
2687 // Hexagon V4 only supports these flavors of byte/half compare instructions:
2688 // EQ/GT/GTU. Other flavors like GE/GEU/LT/LTU/LE/LEU are not supported by
2689 // hardware. However, compiler can still implement these patterns through
2690 // appropriate patterns combinations based on current implemented patterns.
2691 // The implemented patterns are: EQ/GT/GTU.
2692 // Missing patterns are: GE/GEU/LT/LTU/LE/LEU.
2694 // Following instruction is not being extended as it results into the
2695 // incorrect code for negative numbers.
2696 // Pd=cmpb.eq(Rs,#u8)
2698 // p=!cmp.eq(r1,#s10)
2699 let isCodeGenOnly = 0 in {
2700 def C4_cmpneqi : T_CMP <"cmp.eq", 0b00, 1, s10Ext>;
2701 def C4_cmpltei : T_CMP <"cmp.gt", 0b01, 1, s10Ext>;
2702 def C4_cmplteui : T_CMP <"cmp.gtu", 0b10, 1, u9Ext>;
2705 def : T_CMP_pat <C4_cmpneqi, setne, s10ExtPred>;
2706 def : T_CMP_pat <C4_cmpltei, setle, s10ExtPred>;
2707 def : T_CMP_pat <C4_cmplteui, setule, u9ImmPred>;
2709 // rs <= rt -> !(rs > rt).
2711 def: Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
2712 (C2_not (C2_cmpgti IntRegs:$src1, s10ExtPred:$src2))>;
2713 // (C4_cmpltei IntRegs:$src1, s10ExtPred:$src2)>;
2715 // Map cmplt(Rs, Imm) -> !cmpgt(Rs, Imm-1).
2716 def: Pat<(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
2717 (C4_cmpltei IntRegs:$src1, (DEC_CONST_SIGNED s8ExtPred:$src2))>;
2719 // rs != rt -> !(rs == rt).
2720 def: Pat<(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
2721 (C4_cmpneqi IntRegs:$src1, s10ExtPred:$src2)>;
2723 // SDNode for converting immediate C to C-1.
2724 def DEC_CONST_BYTE : SDNodeXForm<imm, [{
2725 // Return the byte immediate const-1 as an SDNode.
2726 int32_t imm = N->getSExtValue();
2727 return XformU7ToU7M1Imm(imm);
2731 // zext( seteq ( and(Rs, 255), u8))
2733 // Pd=cmpb.eq(Rs, #u8)
2734 // if (Pd.new) Rd=#1
2735 // if (!Pd.new) Rd=#0
2736 def : Pat <(i32 (zext (i1 (seteq (i32 (and (i32 IntRegs:$Rs), 255)),
2738 (i32 (TFR_condset_ii (i1 (A4_cmpbeqi (i32 IntRegs:$Rs),
2744 // zext( setne ( and(Rs, 255), u8))
2746 // Pd=cmpb.eq(Rs, #u8)
2747 // if (Pd.new) Rd=#0
2748 // if (!Pd.new) Rd=#1
2749 def : Pat <(i32 (zext (i1 (setne (i32 (and (i32 IntRegs:$Rs), 255)),
2751 (i32 (TFR_condset_ii (i1 (A4_cmpbeqi (i32 IntRegs:$Rs),
2757 // zext( seteq (Rs, and(Rt, 255)))
2759 // Pd=cmpb.eq(Rs, Rt)
2760 // if (Pd.new) Rd=#1
2761 // if (!Pd.new) Rd=#0
2762 def : Pat <(i32 (zext (i1 (seteq (i32 IntRegs:$Rt),
2763 (i32 (and (i32 IntRegs:$Rs), 255)))))),
2764 (i32 (TFR_condset_ii (i1 (A4_cmpbeq (i32 IntRegs:$Rs),
2765 (i32 IntRegs:$Rt))),
2770 // zext( setne (Rs, and(Rt, 255)))
2772 // Pd=cmpb.eq(Rs, Rt)
2773 // if (Pd.new) Rd=#0
2774 // if (!Pd.new) Rd=#1
2775 def : Pat <(i32 (zext (i1 (setne (i32 IntRegs:$Rt),
2776 (i32 (and (i32 IntRegs:$Rs), 255)))))),
2777 (i32 (TFR_condset_ii (i1 (A4_cmpbeq (i32 IntRegs:$Rs),
2778 (i32 IntRegs:$Rt))),
2783 // zext( setugt ( and(Rs, 255), u8))
2785 // Pd=cmpb.gtu(Rs, #u8)
2786 // if (Pd.new) Rd=#1
2787 // if (!Pd.new) Rd=#0
2788 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 255)),
2790 (i32 (TFR_condset_ii (i1 (A4_cmpbgtui (i32 IntRegs:$Rs),
2796 // zext( setugt ( and(Rs, 254), u8))
2798 // Pd=cmpb.gtu(Rs, #u8)
2799 // if (Pd.new) Rd=#1
2800 // if (!Pd.new) Rd=#0
2801 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 254)),
2803 (i32 (TFR_condset_ii (i1 (A4_cmpbgtui (i32 IntRegs:$Rs),
2809 // zext( setult ( Rs, Rt))
2811 // Pd=cmp.ltu(Rs, Rt)
2812 // if (Pd.new) Rd=#1
2813 // if (!Pd.new) Rd=#0
2814 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs)
2815 def : Pat <(i32 (zext (i1 (setult (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2816 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt),
2817 (i32 IntRegs:$Rs))),
2822 // zext( setlt ( Rs, Rt))
2824 // Pd=cmp.lt(Rs, Rt)
2825 // if (Pd.new) Rd=#1
2826 // if (!Pd.new) Rd=#0
2827 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs)
2828 def : Pat <(i32 (zext (i1 (setlt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2829 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt),
2830 (i32 IntRegs:$Rs))),
2835 // zext( setugt ( Rs, Rt))
2837 // Pd=cmp.gtu(Rs, Rt)
2838 // if (Pd.new) Rd=#1
2839 // if (!Pd.new) Rd=#0
2840 def : Pat <(i32 (zext (i1 (setugt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2841 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs),
2842 (i32 IntRegs:$Rt))),
2846 // This pattern interefers with coremark performance, not implementing at this
2849 // zext( setgt ( Rs, Rt))
2851 // Pd=cmp.gt(Rs, Rt)
2852 // if (Pd.new) Rd=#1
2853 // if (!Pd.new) Rd=#0
2856 // zext( setuge ( Rs, Rt))
2858 // Pd=cmp.ltu(Rs, Rt)
2859 // if (Pd.new) Rd=#0
2860 // if (!Pd.new) Rd=#1
2861 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs)
2862 def : Pat <(i32 (zext (i1 (setuge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2863 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt),
2864 (i32 IntRegs:$Rs))),
2869 // zext( setge ( Rs, Rt))
2871 // Pd=cmp.lt(Rs, Rt)
2872 // if (Pd.new) Rd=#0
2873 // if (!Pd.new) Rd=#1
2874 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs)
2875 def : Pat <(i32 (zext (i1 (setge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2876 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt),
2877 (i32 IntRegs:$Rs))),
2882 // zext( setule ( Rs, Rt))
2884 // Pd=cmp.gtu(Rs, Rt)
2885 // if (Pd.new) Rd=#0
2886 // if (!Pd.new) Rd=#1
2887 def : Pat <(i32 (zext (i1 (setule (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2888 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs),
2889 (i32 IntRegs:$Rt))),
2894 // zext( setle ( Rs, Rt))
2896 // Pd=cmp.gt(Rs, Rt)
2897 // if (Pd.new) Rd=#0
2898 // if (!Pd.new) Rd=#1
2899 def : Pat <(i32 (zext (i1 (setle (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
2900 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rs),
2901 (i32 IntRegs:$Rt))),
2906 // zext( setult ( and(Rs, 255), u8))
2907 // Use the isdigit transformation below
2909 // Generate code of the form 'mux_ii(cmpbgtu(Rdd, C-1),0,1)'
2910 // for C code of the form r = ((c>='0') & (c<='9')) ? 1 : 0;.
2911 // The isdigit transformation relies on two 'clever' aspects:
2912 // 1) The data type is unsigned which allows us to eliminate a zero test after
2913 // biasing the expression by 48. We are depending on the representation of
2914 // the unsigned types, and semantics.
2915 // 2) The front end has converted <= 9 into < 10 on entry to LLVM
2918 // retval = ((c>='0') & (c<='9')) ? 1 : 0;
2919 // The code is transformed upstream of llvm into
2920 // retval = (c-48) < 10 ? 1 : 0;
2921 let AddedComplexity = 139 in
2922 def : Pat <(i32 (zext (i1 (setult (i32 (and (i32 IntRegs:$src1), 255)),
2923 u7StrictPosImmPred:$src2)))),
2924 (i32 (C2_muxii (i1 (A4_cmpbgtui (i32 IntRegs:$src1),
2925 (DEC_CONST_BYTE u7StrictPosImmPred:$src2))),
2929 //===----------------------------------------------------------------------===//
2931 //===----------------------------------------------------------------------===//
2933 //===----------------------------------------------------------------------===//
2934 // Multiclass for DeallocReturn
2935 //===----------------------------------------------------------------------===//
2936 class L4_RETURN<string mnemonic, bit isNot, bit isPredNew, bit isTak>
2937 : LD0Inst<(outs), (ins PredRegs:$src),
2938 !if(isNot, "if (!$src", "if ($src")#
2939 !if(isPredNew, ".new) ", ") ")#mnemonic#
2940 !if(isPredNew, #!if(isTak,":t", ":nt"),""),
2941 [], "", LD_tc_3or4stall_SLOT0> {
2944 let BaseOpcode = "L4_RETURN";
2945 let isPredicatedFalse = isNot;
2946 let isPredicatedNew = isPredNew;
2947 let isTaken = isTak;
2948 let IClass = 0b1001;
2950 let Inst{27-16} = 0b011000011110;
2952 let Inst{13} = isNot;
2953 let Inst{12} = isTak;
2954 let Inst{11} = isPredNew;
2956 let Inst{9-8} = src;
2957 let Inst{4-0} = 0b11110;
2960 // Produce all predicated forms, p, !p, p.new, !p.new, :t, :nt
2961 multiclass L4_RETURN_PRED<string mnemonic, bit PredNot> {
2962 let isPredicated = 1 in {
2963 def _#NAME# : L4_RETURN <mnemonic, PredNot, 0, 1>;
2964 def _#NAME#new_pnt : L4_RETURN <mnemonic, PredNot, 1, 0>;
2965 def _#NAME#new_pt : L4_RETURN <mnemonic, PredNot, 1, 1>;
2969 multiclass LD_MISC_L4_RETURN<string mnemonic> {
2970 let isBarrier = 1, isPredicable = 1 in
2971 def NAME : LD0Inst <(outs), (ins), mnemonic, [], "",
2972 LD_tc_3or4stall_SLOT0> {
2973 let BaseOpcode = "L4_RETURN";
2974 let IClass = 0b1001;
2975 let Inst{27-16} = 0b011000011110;
2976 let Inst{13-10} = 0b0000;
2977 let Inst{4-0} = 0b11110;
2979 defm t : L4_RETURN_PRED<mnemonic, 0 >;
2980 defm f : L4_RETURN_PRED<mnemonic, 1 >;
2983 let isReturn = 1, isTerminator = 1,
2984 Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0,
2985 validSubTargets = HasV4SubT, isCodeGenOnly = 0 in
2986 defm L4_return: LD_MISC_L4_RETURN <"dealloc_return">, PredNewRel;
2988 // Restore registers and dealloc return function call.
2989 let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1,
2990 Defs = [R29, R30, R31, PC] in {
2991 let validSubTargets = HasV4SubT in
2992 def RESTORE_DEALLOC_RET_JMP_V4 : JInst<(outs),
2993 (ins calltarget:$dst),
2999 // Restore registers and dealloc frame before a tail call.
3000 let isCall = 1, isBarrier = 1,
3001 Defs = [R29, R30, R31, PC] in {
3002 let validSubTargets = HasV4SubT in
3003 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : JInst<(outs),
3004 (ins calltarget:$dst),
3010 // Save registers function call.
3011 let isCall = 1, isBarrier = 1,
3012 Uses = [R29, R31] in {
3013 def SAVE_REGISTERS_CALL_V4 : JInst<(outs),
3014 (ins calltarget:$dst),
3015 "call $dst // Save_calle_saved_registers",
3020 //===----------------------------------------------------------------------===//
3021 // Template class for non predicated store instructions with
3022 // GP-Relative or absolute addressing.
3023 //===----------------------------------------------------------------------===//
3024 let hasSideEffects = 0, isPredicable = 1, isNVStorable = 1 in
3025 class T_StoreAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3026 bits<2>MajOp, Operand AddrOp, bit isAbs, bit isHalf>
3027 : STInst<(outs), (ins AddrOp:$addr, RC:$src),
3028 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src"#!if(isHalf, ".h",""),
3029 [], "", V2LDST_tc_st_SLOT01> {
3032 bits<16> offsetBits;
3034 string ImmOpStr = !cast<string>(ImmOp);
3035 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3036 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3037 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3038 /* u16_0Imm */ addr{15-0})));
3039 let IClass = 0b0100;
3041 let Inst{26-25} = offsetBits{15-14};
3043 let Inst{23-22} = MajOp;
3044 let Inst{21} = isHalf;
3045 let Inst{20-16} = offsetBits{13-9};
3046 let Inst{13} = offsetBits{8};
3047 let Inst{12-8} = src;
3048 let Inst{7-0} = offsetBits{7-0};
3051 //===----------------------------------------------------------------------===//
3052 // Template class for predicated store instructions with
3053 // GP-Relative or absolute addressing.
3054 //===----------------------------------------------------------------------===//
3055 let hasSideEffects = 0, isPredicated = 1, isNVStorable = 1, opExtentBits = 6,
3057 class T_StoreAbs_Pred <string mnemonic, RegisterClass RC, bits<2> MajOp,
3058 bit isHalf, bit isNot, bit isNew>
3059 : STInst<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, RC: $src2),
3060 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3061 ") ")#mnemonic#"(#$absaddr) = $src2"#!if(isHalf, ".h",""),
3062 [], "", ST_tc_st_SLOT01>, AddrModeRel {
3067 let isPredicatedNew = isNew;
3068 let isPredicatedFalse = isNot;
3070 let IClass = 0b1010;
3072 let Inst{27-24} = 0b1111;
3073 let Inst{23-22} = MajOp;
3074 let Inst{21} = isHalf;
3075 let Inst{17-16} = absaddr{5-4};
3076 let Inst{13} = isNew;
3077 let Inst{12-8} = src2;
3079 let Inst{6-3} = absaddr{3-0};
3080 let Inst{2} = isNot;
3081 let Inst{1-0} = src1;
3084 //===----------------------------------------------------------------------===//
3085 // Template class for predicated store instructions with absolute addressing.
3086 //===----------------------------------------------------------------------===//
3087 class T_StoreAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3088 bits<2> MajOp, bit isHalf>
3089 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, u0AlwaysExt, 1, isHalf>,
3091 string ImmOpStr = !cast<string>(ImmOp);
3092 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3093 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3094 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3095 /* u16_0Imm */ 16)));
3097 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3098 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3099 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3100 /* u16_0Imm */ 0)));
3103 //===----------------------------------------------------------------------===//
3104 // Multiclass for store instructions with absolute addressing.
3105 //===----------------------------------------------------------------------===//
3106 let validSubTargets = HasV4SubT, addrMode = Absolute, isExtended = 1 in
3107 multiclass ST_Abs<string mnemonic, string CextOp, RegisterClass RC,
3108 Operand ImmOp, bits<2> MajOp, bit isHalf = 0> {
3109 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3110 let opExtendable = 0, isPredicable = 1 in
3111 def S2_#NAME#abs : T_StoreAbs <mnemonic, RC, ImmOp, MajOp, isHalf>;
3114 def S4_p#NAME#t_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 0>;
3115 def S4_p#NAME#f_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 0>;
3118 def S4_p#NAME#tnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 1>;
3119 def S4_p#NAME#fnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 1>;
3123 //===----------------------------------------------------------------------===//
3124 // Template class for non predicated new-value store instructions with
3125 // GP-Relative or absolute addressing.
3126 //===----------------------------------------------------------------------===//
3127 let hasSideEffects = 0, isPredicable = 1, mayStore = 1, isNVStore = 1,
3128 isNewValue = 1, opNewValue = 1 in
3129 class T_StoreAbsGP_NV <string mnemonic, Operand ImmOp, bits<2>MajOp, bit isAbs>
3130 : NVInst_V4<(outs), (ins u0AlwaysExt:$addr, IntRegs:$src),
3131 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src.new",
3132 [], "", V2LDST_tc_st_SLOT0> {
3135 bits<16> offsetBits;
3137 string ImmOpStr = !cast<string>(ImmOp);
3138 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3139 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3140 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3141 /* u16_0Imm */ addr{15-0})));
3142 let IClass = 0b0100;
3145 let Inst{26-25} = offsetBits{15-14};
3146 let Inst{24-21} = 0b0101;
3147 let Inst{20-16} = offsetBits{13-9};
3148 let Inst{13} = offsetBits{8};
3149 let Inst{12-11} = MajOp;
3150 let Inst{10-8} = src;
3151 let Inst{7-0} = offsetBits{7-0};
3154 //===----------------------------------------------------------------------===//
3155 // Template class for predicated new-value store instructions with
3156 // absolute addressing.
3157 //===----------------------------------------------------------------------===//
3158 let hasSideEffects = 0, isPredicated = 1, mayStore = 1, isNVStore = 1,
3159 isNewValue = 1, opNewValue = 2, opExtentBits = 6, opExtendable = 1 in
3160 class T_StoreAbs_NV_Pred <string mnemonic, bits<2> MajOp, bit isNot, bit isNew>
3161 : NVInst_V4<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, IntRegs:$src2),
3162 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3163 ") ")#mnemonic#"(#$absaddr) = $src2.new",
3164 [], "", ST_tc_st_SLOT0>, AddrModeRel {
3169 let isPredicatedNew = isNew;
3170 let isPredicatedFalse = isNot;
3172 let IClass = 0b1010;
3174 let Inst{27-24} = 0b1111;
3175 let Inst{23-21} = 0b101;
3176 let Inst{17-16} = absaddr{5-4};
3177 let Inst{13} = isNew;
3178 let Inst{12-11} = MajOp;
3179 let Inst{10-8} = src2;
3181 let Inst{6-3} = absaddr{3-0};
3182 let Inst{2} = isNot;
3183 let Inst{1-0} = src1;
3186 //===----------------------------------------------------------------------===//
3187 // Template class for non-predicated new-value store instructions with
3188 // absolute addressing.
3189 //===----------------------------------------------------------------------===//
3190 class T_StoreAbs_NV <string mnemonic, Operand ImmOp, bits<2> MajOp>
3191 : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 1>, AddrModeRel {
3193 string ImmOpStr = !cast<string>(ImmOp);
3194 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3195 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3196 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3197 /* u16_0Imm */ 16)));
3199 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3200 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3201 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3202 /* u16_0Imm */ 0)));
3205 //===----------------------------------------------------------------------===//
3206 // Multiclass for new-value store instructions with absolute addressing.
3207 //===----------------------------------------------------------------------===//
3208 let validSubTargets = HasV4SubT, addrMode = Absolute, isExtended = 1 in
3209 multiclass ST_Abs_NV <string mnemonic, string CextOp, Operand ImmOp,
3211 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3212 let opExtendable = 0, isPredicable = 1 in
3213 def S2_#NAME#newabs : T_StoreAbs_NV <mnemonic, ImmOp, MajOp>;
3216 def S4_p#NAME#newt_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 0>;
3217 def S4_p#NAME#newf_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 0>;
3220 def S4_p#NAME#newtnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 1>;
3221 def S4_p#NAME#newfnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 1>;
3225 //===----------------------------------------------------------------------===//
3226 // Stores with absolute addressing
3227 //===----------------------------------------------------------------------===//
3228 let accessSize = ByteAccess, isCodeGenOnly = 0 in
3229 defm storerb : ST_Abs <"memb", "STrib", IntRegs, u16_0Imm, 0b00>,
3230 ST_Abs_NV <"memb", "STrib", u16_0Imm, 0b00>;
3232 let accessSize = HalfWordAccess, isCodeGenOnly = 0 in
3233 defm storerh : ST_Abs <"memh", "STrih", IntRegs, u16_1Imm, 0b01>,
3234 ST_Abs_NV <"memh", "STrih", u16_1Imm, 0b01>;
3236 let accessSize = WordAccess, isCodeGenOnly = 0 in
3237 defm storeri : ST_Abs <"memw", "STriw", IntRegs, u16_2Imm, 0b10>,
3238 ST_Abs_NV <"memw", "STriw", u16_2Imm, 0b10>;
3240 let isNVStorable = 0, accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
3241 defm storerd : ST_Abs <"memd", "STrid", DoubleRegs, u16_3Imm, 0b11>;
3243 let isNVStorable = 0, accessSize = HalfWordAccess, isCodeGenOnly = 0 in
3244 defm storerf : ST_Abs <"memh", "STrif", IntRegs, u16_1Imm, 0b01, 1>;
3246 //===----------------------------------------------------------------------===//
3247 // GP-relative stores.
3248 // mem[bhwd](#global)=Rt
3249 // Once predicated, these instructions map to absolute addressing mode.
3250 // if ([!]Pv[.new]) mem[bhwd](##global)=Rt
3251 //===----------------------------------------------------------------------===//
3253 let validSubTargets = HasV4SubT in
3254 class T_StoreGP <string mnemonic, string BaseOp, RegisterClass RC,
3255 Operand ImmOp, bits<2> MajOp, bit isHalf = 0>
3256 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0, isHalf> {
3257 // Set BaseOpcode same as absolute addressing instructions so that
3258 // non-predicated GP-Rel instructions can have relate with predicated
3259 // Absolute instruction.
3260 let BaseOpcode = BaseOp#_abs;
3263 let validSubTargets = HasV4SubT in
3264 multiclass ST_GP <string mnemonic, string BaseOp, Operand ImmOp,
3265 bits<2> MajOp, bit isHalf = 0> {
3266 // Set BaseOpcode same as absolute addressing instructions so that
3267 // non-predicated GP-Rel instructions can have relate with predicated
3268 // Absolute instruction.
3269 let BaseOpcode = BaseOp#_abs in {
3270 def NAME#gp : T_StoreAbsGP <mnemonic, IntRegs, ImmOp, MajOp,
3271 globaladdress, 0, isHalf>;
3273 def NAME#newgp : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 0> ;
3277 let accessSize = ByteAccess in
3278 defm S2_storerb : ST_GP<"memb", "STrib", u16_0Imm, 0b00>, NewValueRel;
3280 let accessSize = HalfWordAccess in
3281 defm S2_storerh : ST_GP<"memh", "STrih", u16_1Imm, 0b01>, NewValueRel;
3283 let accessSize = WordAccess in
3284 defm S2_storeri : ST_GP<"memw", "STriw", u16_2Imm, 0b10>, NewValueRel;
3286 let isNVStorable = 0, accessSize = DoubleWordAccess in
3287 def S2_storerdgp : T_StoreGP <"memd", "STrid", DoubleRegs,
3288 u16_3Imm, 0b11>, PredNewRel;
3290 let isNVStorable = 0, accessSize = HalfWordAccess in
3291 def S2_storerfgp : T_StoreGP <"memh", "STrif", IntRegs,
3292 u16_1Imm, 0b01, 1>, PredNewRel;
3294 let Predicates = [HasV4T], AddedComplexity = 30 in {
3295 def : Pat<(truncstorei8 (i32 IntRegs:$src1),
3296 (HexagonCONST32 tglobaladdr:$absaddr)),
3297 (S2_storerbabs tglobaladdr: $absaddr, IntRegs: $src1)>;
3299 def : Pat<(truncstorei16 (i32 IntRegs:$src1),
3300 (HexagonCONST32 tglobaladdr:$absaddr)),
3301 (S2_storerhabs tglobaladdr: $absaddr, IntRegs: $src1)>;
3303 def : Pat<(store (i32 IntRegs:$src1), (HexagonCONST32 tglobaladdr:$absaddr)),
3304 (S2_storeriabs tglobaladdr: $absaddr, IntRegs: $src1)>;
3306 def : Pat<(store (i64 DoubleRegs:$src1),
3307 (HexagonCONST32 tglobaladdr:$absaddr)),
3308 (S2_storerdabs tglobaladdr: $absaddr, DoubleRegs: $src1)>;
3311 // 64 bit atomic store
3312 def : Pat <(atomic_store_64 (HexagonCONST32_GP tglobaladdr:$global),
3313 (i64 DoubleRegs:$src1)),
3314 (S2_storerdgp tglobaladdr:$global, (i64 DoubleRegs:$src1))>,
3317 // Map from store(globaladdress) -> memd(#foo)
3318 let AddedComplexity = 100 in
3319 def : Pat <(store (i64 DoubleRegs:$src1),
3320 (HexagonCONST32_GP tglobaladdr:$global)),
3321 (S2_storerdgp tglobaladdr:$global, (i64 DoubleRegs:$src1))>;
3323 // 8 bit atomic store
3324 def : Pat < (atomic_store_8 (HexagonCONST32_GP tglobaladdr:$global),
3325 (i32 IntRegs:$src1)),
3326 (S2_storerbgp tglobaladdr:$global, (i32 IntRegs:$src1))>;
3328 // Map from store(globaladdress) -> memb(#foo)
3329 let AddedComplexity = 100 in
3330 def : Pat<(truncstorei8 (i32 IntRegs:$src1),
3331 (HexagonCONST32_GP tglobaladdr:$global)),
3332 (S2_storerbgp tglobaladdr:$global, (i32 IntRegs:$src1))>;
3334 // Map from "i1 = constant<-1>; memw(CONST32(#foo)) = i1"
3335 // to "r0 = 1; memw(#foo) = r0"
3336 let AddedComplexity = 100 in
3337 def : Pat<(store (i1 -1), (HexagonCONST32_GP tglobaladdr:$global)),
3338 (S2_storerbgp tglobaladdr:$global, (A2_tfrsi 1))>;
3340 def : Pat<(atomic_store_16 (HexagonCONST32_GP tglobaladdr:$global),
3341 (i32 IntRegs:$src1)),
3342 (S2_storerhgp tglobaladdr:$global, (i32 IntRegs:$src1))>;
3344 // Map from store(globaladdress) -> memh(#foo)
3345 let AddedComplexity = 100 in
3346 def : Pat<(truncstorei16 (i32 IntRegs:$src1),
3347 (HexagonCONST32_GP tglobaladdr:$global)),
3348 (S2_storerhgp tglobaladdr:$global, (i32 IntRegs:$src1))>;
3350 // 32 bit atomic store
3351 def : Pat<(atomic_store_32 (HexagonCONST32_GP tglobaladdr:$global),
3352 (i32 IntRegs:$src1)),
3353 (S2_storerigp tglobaladdr:$global, (i32 IntRegs:$src1))>;
3355 // Map from store(globaladdress) -> memw(#foo)
3356 let AddedComplexity = 100 in
3357 def : Pat<(store (i32 IntRegs:$src1), (HexagonCONST32_GP tglobaladdr:$global)),
3358 (S2_storerigp tglobaladdr:$global, (i32 IntRegs:$src1))>;
3360 //===----------------------------------------------------------------------===//
3361 // Template class for non predicated load instructions with
3362 // absolute addressing mode.
3363 //===----------------------------------------------------------------------===//
3364 let isPredicable = 1, hasSideEffects = 0, validSubTargets = HasV4SubT in
3365 class T_LoadAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3366 bits<3> MajOp, Operand AddrOp, bit isAbs>
3367 : LDInst <(outs RC:$dst), (ins AddrOp:$addr),
3368 "$dst = "#mnemonic# !if(isAbs, "(##", "(#")#"$addr)",
3369 [], "", V2LDST_tc_ld_SLOT01> {
3372 bits<16> offsetBits;
3374 string ImmOpStr = !cast<string>(ImmOp);
3375 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3376 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3377 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3378 /* u16_0Imm */ addr{15-0})));
3380 let IClass = 0b0100;
3383 let Inst{26-25} = offsetBits{15-14};
3385 let Inst{23-21} = MajOp;
3386 let Inst{20-16} = offsetBits{13-9};
3387 let Inst{13-5} = offsetBits{8-0};
3388 let Inst{4-0} = dst;
3391 class T_LoadAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3393 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, u0AlwaysExt, 1>, AddrModeRel {
3395 string ImmOpStr = !cast<string>(ImmOp);
3396 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3397 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3398 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3399 /* u16_0Imm */ 16)));
3401 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3402 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3403 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3404 /* u16_0Imm */ 0)));
3406 //===----------------------------------------------------------------------===//
3407 // Template class for predicated load instructions with
3408 // absolute addressing mode.
3409 //===----------------------------------------------------------------------===//
3410 let isPredicated = 1, hasNewValue = 1, opExtentBits = 6, opExtendable = 2 in
3411 class T_LoadAbs_Pred <string mnemonic, RegisterClass RC, bits<3> MajOp,
3412 bit isPredNot, bit isPredNew>
3413 : LDInst <(outs RC:$dst), (ins PredRegs:$src1, u6Ext:$absaddr),
3414 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3415 ") ")#"$dst = "#mnemonic#"(#$absaddr)">, AddrModeRel {
3420 let isPredicatedNew = isPredNew;
3421 let isPredicatedFalse = isPredNot;
3423 let IClass = 0b1001;
3425 let Inst{27-24} = 0b1111;
3426 let Inst{23-21} = MajOp;
3427 let Inst{20-16} = absaddr{5-1};
3429 let Inst{12} = isPredNew;
3430 let Inst{11} = isPredNot;
3431 let Inst{10-9} = src1;
3432 let Inst{8} = absaddr{0};
3434 let Inst{4-0} = dst;
3437 //===----------------------------------------------------------------------===//
3438 // Multiclass for the load instructions with absolute addressing mode.
3439 //===----------------------------------------------------------------------===//
3440 multiclass LD_Abs_Pred<string mnemonic, RegisterClass RC, bits<3> MajOp,
3442 def _abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 0>;
3444 def new_abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 1>;
3447 let addrMode = Absolute, isExtended = 1 in
3448 multiclass LD_Abs<string mnemonic, string CextOp, RegisterClass RC,
3449 Operand ImmOp, bits<3> MajOp> {
3450 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3451 let opExtendable = 1, isPredicable = 1 in
3452 def L4_#NAME#_abs: T_LoadAbs <mnemonic, RC, ImmOp, MajOp>;
3455 defm L4_p#NAME#t : LD_Abs_Pred<mnemonic, RC, MajOp, 0>;
3456 defm L4_p#NAME#f : LD_Abs_Pred<mnemonic, RC, MajOp, 1>;
3460 let accessSize = ByteAccess, hasNewValue = 1, isCodeGenOnly = 0 in {
3461 defm loadrb : LD_Abs<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3462 defm loadrub : LD_Abs<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3465 let accessSize = HalfWordAccess, hasNewValue = 1, isCodeGenOnly = 0 in {
3466 defm loadrh : LD_Abs<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3467 defm loadruh : LD_Abs<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3470 let accessSize = WordAccess, hasNewValue = 1, isCodeGenOnly = 0 in
3471 defm loadri : LD_Abs<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3473 let accessSize = DoubleWordAccess, isCodeGenOnly = 0 in
3474 defm loadrd : LD_Abs<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3476 //===----------------------------------------------------------------------===//
3477 // multiclass for load instructions with GP-relative addressing mode.
3478 // Rx=mem[bhwd](##global)
3479 // Once predicated, these instructions map to absolute addressing mode.
3480 // if ([!]Pv[.new]) Rx=mem[bhwd](##global)
3481 //===----------------------------------------------------------------------===//
3483 class T_LoadGP <string mnemonic, string BaseOp, RegisterClass RC, Operand ImmOp,
3485 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0>, PredNewRel {
3486 let BaseOpcode = BaseOp#_abs;
3489 let accessSize = ByteAccess, hasNewValue = 1 in {
3490 def L2_loadrbgp : T_LoadGP<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3491 def L2_loadrubgp : T_LoadGP<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3494 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3495 def L2_loadrhgp : T_LoadGP<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3496 def L2_loadruhgp : T_LoadGP<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3499 let accessSize = WordAccess, hasNewValue = 1 in
3500 def L2_loadrigp : T_LoadGP<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3502 let accessSize = DoubleWordAccess in
3503 def L2_loadrdgp : T_LoadGP<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3505 let Predicates = [HasV4T], AddedComplexity = 30 in {
3506 def : Pat<(i32 (load (HexagonCONST32 tglobaladdr:$absaddr))),
3507 (L4_loadri_abs tglobaladdr: $absaddr)>;
3509 def : Pat<(i32 (sextloadi8 (HexagonCONST32 tglobaladdr:$absaddr))),
3510 (L4_loadrb_abs tglobaladdr:$absaddr)>;
3512 def : Pat<(i32 (zextloadi8 (HexagonCONST32 tglobaladdr:$absaddr))),
3513 (L4_loadrub_abs tglobaladdr:$absaddr)>;
3515 def : Pat<(i32 (sextloadi16 (HexagonCONST32 tglobaladdr:$absaddr))),
3516 (L4_loadrh_abs tglobaladdr:$absaddr)>;
3518 def : Pat<(i32 (zextloadi16 (HexagonCONST32 tglobaladdr:$absaddr))),
3519 (L4_loadruh_abs tglobaladdr:$absaddr)>;
3522 def : Pat <(atomic_load_64 (HexagonCONST32_GP tglobaladdr:$global)),
3523 (i64 (L2_loadrdgp tglobaladdr:$global))>;
3525 def : Pat <(atomic_load_32 (HexagonCONST32_GP tglobaladdr:$global)),
3526 (i32 (L2_loadrigp tglobaladdr:$global))>;
3528 def : Pat <(atomic_load_16 (HexagonCONST32_GP tglobaladdr:$global)),
3529 (i32 (L2_loadruhgp tglobaladdr:$global))>;
3531 def : Pat <(atomic_load_8 (HexagonCONST32_GP tglobaladdr:$global)),
3532 (i32 (L2_loadrubgp tglobaladdr:$global))>;
3534 // Map from load(globaladdress) -> memw(#foo + 0)
3535 let AddedComplexity = 100 in
3536 def : Pat <(i64 (load (HexagonCONST32_GP tglobaladdr:$global))),
3537 (i64 (L2_loadrdgp tglobaladdr:$global))>;
3539 // Map from Pd = load(globaladdress) -> Rd = memb(globaladdress), Pd = Rd
3540 let AddedComplexity = 100 in
3541 def : Pat <(i1 (load (HexagonCONST32_GP tglobaladdr:$global))),
3542 (i1 (C2_tfrrp (i32 (L2_loadrbgp tglobaladdr:$global))))>;
3544 // When the Interprocedural Global Variable optimizer realizes that a certain
3545 // global variable takes only two constant values, it shrinks the global to
3546 // a boolean. Catch those loads here in the following 3 patterns.
3547 let AddedComplexity = 100 in
3548 def : Pat <(i32 (extloadi1 (HexagonCONST32_GP tglobaladdr:$global))),
3549 (i32 (L2_loadrbgp tglobaladdr:$global))>;
3551 let AddedComplexity = 100 in
3552 def : Pat <(i32 (sextloadi1 (HexagonCONST32_GP tglobaladdr:$global))),
3553 (i32 (L2_loadrbgp tglobaladdr:$global))>;
3555 // Map from load(globaladdress) -> memb(#foo)
3556 let AddedComplexity = 100 in
3557 def : Pat <(i32 (extloadi8 (HexagonCONST32_GP tglobaladdr:$global))),
3558 (i32 (L2_loadrbgp tglobaladdr:$global))>;
3560 // Map from load(globaladdress) -> memb(#foo)
3561 let AddedComplexity = 100 in
3562 def : Pat <(i32 (sextloadi8 (HexagonCONST32_GP tglobaladdr:$global))),
3563 (i32 (L2_loadrbgp tglobaladdr:$global))>;
3565 let AddedComplexity = 100 in
3566 def : Pat <(i32 (zextloadi1 (HexagonCONST32_GP tglobaladdr:$global))),
3567 (i32 (L2_loadrubgp tglobaladdr:$global))>;
3569 // Map from load(globaladdress) -> memub(#foo)
3570 let AddedComplexity = 100 in
3571 def : Pat <(i32 (zextloadi8 (HexagonCONST32_GP tglobaladdr:$global))),
3572 (i32 (L2_loadrubgp tglobaladdr:$global))>;
3574 // Map from load(globaladdress) -> memh(#foo)
3575 let AddedComplexity = 100 in
3576 def : Pat <(i32 (extloadi16 (HexagonCONST32_GP tglobaladdr:$global))),
3577 (i32 (L2_loadrhgp tglobaladdr:$global))>;
3579 // Map from load(globaladdress) -> memh(#foo)
3580 let AddedComplexity = 100 in
3581 def : Pat <(i32 (sextloadi16 (HexagonCONST32_GP tglobaladdr:$global))),
3582 (i32 (L2_loadrhgp tglobaladdr:$global))>;
3584 // Map from load(globaladdress) -> memuh(#foo)
3585 let AddedComplexity = 100 in
3586 def : Pat <(i32 (zextloadi16 (HexagonCONST32_GP tglobaladdr:$global))),
3587 (i32 (L2_loadruhgp tglobaladdr:$global))>;
3589 // Map from load(globaladdress) -> memw(#foo)
3590 let AddedComplexity = 100 in
3591 def : Pat <(i32 (load (HexagonCONST32_GP tglobaladdr:$global))),
3592 (i32 (L2_loadrigp tglobaladdr:$global))>;
3595 // Transfer global address into a register
3596 let isExtended = 1, opExtendable = 1, AddedComplexity=50, isMoveImm = 1,
3597 isAsCheapAsAMove = 1, isReMaterializable = 1, validSubTargets = HasV4SubT in
3598 def TFRI_V4 : ALU32_ri<(outs IntRegs:$dst), (ins s16Ext:$src1),
3600 [(set IntRegs:$dst, (HexagonCONST32 tglobaladdr:$src1))]>,
3603 // Transfer a block address into a register
3604 def : Pat<(HexagonCONST32_GP tblockaddress:$src1),
3605 (TFRI_V4 tblockaddress:$src1)>,
3608 let isExtended = 1, opExtendable = 2, AddedComplexity=50,
3609 hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in
3610 def TFRI_cPt_V4 : ALU32_ri<(outs IntRegs:$dst),
3611 (ins PredRegs:$src1, s16Ext:$src2),
3612 "if($src1) $dst = #$src2",
3616 let isExtended = 1, opExtendable = 2, AddedComplexity=50, isPredicatedFalse = 1,
3617 hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in
3618 def TFRI_cNotPt_V4 : ALU32_ri<(outs IntRegs:$dst),
3619 (ins PredRegs:$src1, s16Ext:$src2),
3620 "if(!$src1) $dst = #$src2",
3624 let isExtended = 1, opExtendable = 2, AddedComplexity=50,
3625 hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in
3626 def TFRI_cdnPt_V4 : ALU32_ri<(outs IntRegs:$dst),
3627 (ins PredRegs:$src1, s16Ext:$src2),
3628 "if($src1.new) $dst = #$src2",
3632 let isExtended = 1, opExtendable = 2, AddedComplexity=50, isPredicatedFalse = 1,
3633 hasSideEffects = 0, isPredicated = 1, validSubTargets = HasV4SubT in
3634 def TFRI_cdnNotPt_V4 : ALU32_ri<(outs IntRegs:$dst),
3635 (ins PredRegs:$src1, s16Ext:$src2),
3636 "if(!$src1.new) $dst = #$src2",
3640 let AddedComplexity = 50, Predicates = [HasV4T] in
3641 def : Pat<(HexagonCONST32_GP tglobaladdr:$src1),
3642 (TFRI_V4 tglobaladdr:$src1)>,
3646 // Load - Indirect with long offset: These instructions take global address
3648 let isExtended = 1, opExtendable = 3, AddedComplexity = 40,
3649 validSubTargets = HasV4SubT in
3650 def LDrid_ind_lo_V4 : LDInst<(outs DoubleRegs:$dst),
3651 (ins IntRegs:$src1, u2Imm:$src2, globaladdressExt:$offset),
3652 "$dst=memd($src1<<#$src2+##$offset)",
3653 [(set (i64 DoubleRegs:$dst),
3654 (load (add (shl IntRegs:$src1, u2ImmPred:$src2),
3655 (HexagonCONST32 tglobaladdr:$offset))))]>,
3658 let AddedComplexity = 40 in
3659 multiclass LD_indirect_lo<string OpcStr, PatFrag OpNode> {
3660 let isExtended = 1, opExtendable = 3, validSubTargets = HasV4SubT in
3661 def _lo_V4 : LDInst<(outs IntRegs:$dst),
3662 (ins IntRegs:$src1, u2Imm:$src2, globaladdressExt:$offset),
3663 !strconcat("$dst = ",
3664 !strconcat(OpcStr, "($src1<<#$src2+##$offset)")),
3666 (i32 (OpNode (add (shl IntRegs:$src1, u2ImmPred:$src2),
3667 (HexagonCONST32 tglobaladdr:$offset)))))]>,
3671 defm LDrib_ind : LD_indirect_lo<"memb", sextloadi8>;
3672 defm LDriub_ind : LD_indirect_lo<"memub", zextloadi8>;
3673 defm LDriub_ind_anyext : LD_indirect_lo<"memub", extloadi8>;
3674 defm LDrih_ind : LD_indirect_lo<"memh", sextloadi16>;
3675 defm LDriuh_ind : LD_indirect_lo<"memuh", zextloadi16>;
3676 defm LDriuh_ind_anyext : LD_indirect_lo<"memuh", extloadi16>;
3677 defm LDriw_ind : LD_indirect_lo<"memw", load>;
3679 let AddedComplexity = 40 in
3680 def : Pat <(i32 (sextloadi8 (add IntRegs:$src1,
3681 (NumUsesBelowThresCONST32 tglobaladdr:$offset)))),
3682 (i32 (LDrib_ind_lo_V4 IntRegs:$src1, 0, tglobaladdr:$offset))>,
3685 let AddedComplexity = 40 in
3686 def : Pat <(i32 (zextloadi8 (add IntRegs:$src1,
3687 (NumUsesBelowThresCONST32 tglobaladdr:$offset)))),
3688 (i32 (LDriub_ind_lo_V4 IntRegs:$src1, 0, tglobaladdr:$offset))>,
3691 let Predicates = [HasV4T], AddedComplexity = 30 in {
3692 def : Pat<(truncstorei8 (i32 IntRegs:$src1), u0AlwaysExtPred:$src2),
3693 (S2_storerbabs u0AlwaysExtPred:$src2, IntRegs: $src1)>;
3695 def : Pat<(truncstorei16 (i32 IntRegs:$src1), u0AlwaysExtPred:$src2),
3696 (S2_storerhabs u0AlwaysExtPred:$src2, IntRegs: $src1)>;
3698 def : Pat<(store (i32 IntRegs:$src1), u0AlwaysExtPred:$src2),
3699 (S2_storeriabs u0AlwaysExtPred:$src2, IntRegs: $src1)>;
3702 let Predicates = [HasV4T], AddedComplexity = 30 in {
3703 def : Pat<(i32 (load u0AlwaysExtPred:$src)),
3704 (L4_loadri_abs u0AlwaysExtPred:$src)>;
3706 def : Pat<(i32 (sextloadi8 u0AlwaysExtPred:$src)),
3707 (L4_loadrb_abs u0AlwaysExtPred:$src)>;
3709 def : Pat<(i32 (zextloadi8 u0AlwaysExtPred:$src)),
3710 (L4_loadrub_abs u0AlwaysExtPred:$src)>;
3712 def : Pat<(i32 (sextloadi16 u0AlwaysExtPred:$src)),
3713 (L4_loadrh_abs u0AlwaysExtPred:$src)>;
3715 def : Pat<(i32 (zextloadi16 u0AlwaysExtPred:$src)),
3716 (L4_loadruh_abs u0AlwaysExtPred:$src)>;
3719 // Indexed store word - global address.
3720 // memw(Rs+#u6:2)=#S8
3721 let AddedComplexity = 10 in
3722 def STriw_offset_ext_V4 : STInst<(outs),
3723 (ins IntRegs:$src1, u6_2Imm:$src2, globaladdress:$src3),
3724 "memw($src1+#$src2) = ##$src3",
3725 [(store (HexagonCONST32 tglobaladdr:$src3),
3726 (add IntRegs:$src1, u6_2ImmPred:$src2))]>,
3729 def : Pat<(i64 (ctlz (i64 DoubleRegs:$src1))),
3730 (i64 (A4_combineir (i32 0), (i32 (S2_cl0p DoubleRegs:$src1))))>,
3733 def : Pat<(i64 (cttz (i64 DoubleRegs:$src1))),
3734 (i64 (A4_combineir (i32 0), (i32 (S2_ct0p DoubleRegs:$src1))))>,
3739 // We need a complexity of 120 here to override preceding handling of
3741 let Predicates = [HasV4T], AddedComplexity = 120 in {
3742 def: Pat <(i64 (extloadi8 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3743 (i64 (A4_combineir 0, (L4_loadrb_abs tglobaladdr:$addr)))>;
3745 def: Pat <(i64 (zextloadi8 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3746 (i64 (A4_combineir 0, (L4_loadrub_abs tglobaladdr:$addr)))>;
3748 def: Pat <(i64 (sextloadi8 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3749 (i64 (A2_sxtw (L4_loadrb_abs tglobaladdr:$addr)))>;
3751 def: Pat <(i64 (extloadi8 FoldGlobalAddr:$addr)),
3752 (i64 (A4_combineir 0, (L4_loadrb_abs FoldGlobalAddr:$addr)))>;
3754 def: Pat <(i64 (zextloadi8 FoldGlobalAddr:$addr)),
3755 (i64 (A4_combineir 0, (L4_loadrub_abs FoldGlobalAddr:$addr)))>;
3757 def: Pat <(i64 (sextloadi8 FoldGlobalAddr:$addr)),
3758 (i64 (A2_sxtw (L4_loadrb_abs FoldGlobalAddr:$addr)))>;
3761 // We need a complexity of 120 here to override preceding handling of
3763 let AddedComplexity = 120 in {
3764 def: Pat <(i64 (extloadi16 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3765 (i64 (A4_combineir 0, (L4_loadrh_abs tglobaladdr:$addr)))>,
3768 def: Pat <(i64 (zextloadi16 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3769 (i64 (A4_combineir 0, (L4_loadruh_abs tglobaladdr:$addr)))>,
3772 def: Pat <(i64 (sextloadi16 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3773 (i64 (A2_sxtw (L4_loadrh_abs tglobaladdr:$addr)))>,
3776 def: Pat <(i64 (extloadi16 FoldGlobalAddr:$addr)),
3777 (i64 (A4_combineir 0, (L4_loadrh_abs FoldGlobalAddr:$addr)))>,
3780 def: Pat <(i64 (zextloadi16 FoldGlobalAddr:$addr)),
3781 (i64 (A4_combineir 0, (L4_loadruh_abs FoldGlobalAddr:$addr)))>,
3784 def: Pat <(i64 (sextloadi16 FoldGlobalAddr:$addr)),
3785 (i64 (A2_sxtw (L4_loadrh_abs FoldGlobalAddr:$addr)))>,
3789 // We need a complexity of 120 here to override preceding handling of
3791 let AddedComplexity = 120 in {
3792 def: Pat <(i64 (extloadi32 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3793 (i64 (A4_combineir 0, (L4_loadri_abs tglobaladdr:$addr)))>,
3796 def: Pat <(i64 (zextloadi32 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3797 (i64 (A4_combineir 0, (L4_loadri_abs tglobaladdr:$addr)))>,
3800 def: Pat <(i64 (sextloadi32 (NumUsesBelowThresCONST32 tglobaladdr:$addr))),
3801 (i64 (A2_sxtw (L4_loadri_abs tglobaladdr:$addr)))>,
3804 def: Pat <(i64 (extloadi32 FoldGlobalAddr:$addr)),
3805 (i64 (A4_combineir 0, (L4_loadri_abs FoldGlobalAddr:$addr)))>,
3808 def: Pat <(i64 (zextloadi32 FoldGlobalAddr:$addr)),
3809 (i64 (A4_combineir 0, (L4_loadri_abs FoldGlobalAddr:$addr)))>,
3812 def: Pat <(i64 (sextloadi32 FoldGlobalAddr:$addr)),
3813 (i64 (A2_sxtw (L4_loadri_abs FoldGlobalAddr:$addr)))>,
3817 // Indexed store double word - global address.
3818 // memw(Rs+#u6:2)=#S8
3819 let AddedComplexity = 10 in
3820 def STrih_offset_ext_V4 : STInst<(outs),
3821 (ins IntRegs:$src1, u6_1Imm:$src2, globaladdress:$src3),
3822 "memh($src1+#$src2) = ##$src3",
3823 [(truncstorei16 (HexagonCONST32 tglobaladdr:$src3),
3824 (add IntRegs:$src1, u6_1ImmPred:$src2))]>,
3826 // Map from store(globaladdress + x) -> memd(#foo + x)
3827 let AddedComplexity = 100 in
3828 def : Pat<(store (i64 DoubleRegs:$src1),
3829 FoldGlobalAddrGP:$addr),
3830 (S2_storerdabs FoldGlobalAddrGP:$addr, (i64 DoubleRegs:$src1))>,
3833 def : Pat<(atomic_store_64 FoldGlobalAddrGP:$addr,
3834 (i64 DoubleRegs:$src1)),
3835 (S2_storerdabs FoldGlobalAddrGP:$addr, (i64 DoubleRegs:$src1))>,
3838 // Map from store(globaladdress + x) -> memb(#foo + x)
3839 let AddedComplexity = 100 in
3840 def : Pat<(truncstorei8 (i32 IntRegs:$src1), FoldGlobalAddrGP:$addr),
3841 (S2_storerbabs FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>,
3844 def : Pat<(atomic_store_8 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1)),
3845 (S2_storerbabs FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>,
3848 // Map from store(globaladdress + x) -> memh(#foo + x)
3849 let AddedComplexity = 100 in
3850 def : Pat<(truncstorei16 (i32 IntRegs:$src1), FoldGlobalAddrGP:$addr),
3851 (S2_storerhabs FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>,
3854 def : Pat<(atomic_store_16 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1)),
3855 (S2_storerhabs FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>,
3858 // Map from store(globaladdress + x) -> memw(#foo + x)
3859 let AddedComplexity = 100 in
3860 def : Pat<(store (i32 IntRegs:$src1), FoldGlobalAddrGP:$addr),
3861 (S2_storeriabs FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>,
3864 def : Pat<(atomic_store_32 FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1)),
3865 (S2_storeriabs FoldGlobalAddrGP:$addr, (i32 IntRegs:$src1))>,
3868 // Map from load(globaladdress + x) -> memd(#foo + x)
3869 let AddedComplexity = 100 in
3870 def : Pat<(i64 (load FoldGlobalAddrGP:$addr)),
3871 (i64 (L4_loadrd_abs FoldGlobalAddrGP:$addr))>,
3874 def : Pat<(atomic_load_64 FoldGlobalAddrGP:$addr),
3875 (i64 (L4_loadrd_abs FoldGlobalAddrGP:$addr))>,
3878 // Map from load(globaladdress + x) -> memb(#foo + x)
3879 let AddedComplexity = 100 in
3880 def : Pat<(i32 (extloadi8 FoldGlobalAddrGP:$addr)),
3881 (i32 (L4_loadrb_abs FoldGlobalAddrGP:$addr))>,
3884 // Map from load(globaladdress + x) -> memb(#foo + x)
3885 let AddedComplexity = 100 in
3886 def : Pat<(i32 (sextloadi8 FoldGlobalAddrGP:$addr)),
3887 (i32 (L4_loadrb_abs FoldGlobalAddrGP:$addr))>,
3890 //let AddedComplexity = 100 in
3891 let AddedComplexity = 100 in
3892 def : Pat<(i32 (extloadi16 FoldGlobalAddrGP:$addr)),
3893 (i32 (L4_loadrh_abs FoldGlobalAddrGP:$addr))>,
3896 // Map from load(globaladdress + x) -> memh(#foo + x)
3897 let AddedComplexity = 100 in
3898 def : Pat<(i32 (sextloadi16 FoldGlobalAddrGP:$addr)),
3899 (i32 (L4_loadrh_abs FoldGlobalAddrGP:$addr))>,
3902 // Map from load(globaladdress + x) -> memuh(#foo + x)
3903 let AddedComplexity = 100 in
3904 def : Pat<(i32 (zextloadi16 FoldGlobalAddrGP:$addr)),
3905 (i32 (L4_loadruh_abs FoldGlobalAddrGP:$addr))>,
3908 def : Pat<(atomic_load_16 FoldGlobalAddrGP:$addr),
3909 (i32 (L4_loadruh_abs FoldGlobalAddrGP:$addr))>,
3912 // Map from load(globaladdress + x) -> memub(#foo + x)
3913 let AddedComplexity = 100 in
3914 def : Pat<(i32 (zextloadi8 FoldGlobalAddrGP:$addr)),
3915 (i32 (L4_loadrub_abs FoldGlobalAddrGP:$addr))>,
3918 def : Pat<(atomic_load_8 FoldGlobalAddrGP:$addr),
3919 (i32 (L4_loadrub_abs FoldGlobalAddrGP:$addr))>,
3922 // Map from load(globaladdress + x) -> memw(#foo + x)
3923 let AddedComplexity = 100 in
3924 def : Pat<(i32 (load FoldGlobalAddrGP:$addr)),
3925 (i32 (L4_loadri_abs FoldGlobalAddrGP:$addr))>,
3928 def : Pat<(atomic_load_32 FoldGlobalAddrGP:$addr),
3929 (i32 (L4_loadri_abs FoldGlobalAddrGP:$addr))>,
3932 //===----------------------------------------------------------------------===//
3933 // :raw for of boundscheck:hi:lo insns
3934 //===----------------------------------------------------------------------===//
3936 // A4_boundscheck_lo: Detect if a register is within bounds.
3937 let hasSideEffects = 0, isCodeGenOnly = 0 in
3938 def A4_boundscheck_lo: ALU64Inst <
3939 (outs PredRegs:$Pd),
3940 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3941 "$Pd = boundscheck($Rss, $Rtt):raw:lo"> {
3946 let IClass = 0b1101;
3948 let Inst{27-23} = 0b00100;
3950 let Inst{7-5} = 0b100;
3952 let Inst{20-16} = Rss;
3953 let Inst{12-8} = Rtt;
3956 // A4_boundscheck_hi: Detect if a register is within bounds.
3957 let hasSideEffects = 0, isCodeGenOnly = 0 in
3958 def A4_boundscheck_hi: ALU64Inst <
3959 (outs PredRegs:$Pd),
3960 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3961 "$Pd = boundscheck($Rss, $Rtt):raw:hi"> {
3966 let IClass = 0b1101;
3968 let Inst{27-23} = 0b00100;
3970 let Inst{7-5} = 0b101;
3972 let Inst{20-16} = Rss;
3973 let Inst{12-8} = Rtt;
3976 let hasSideEffects = 0 in
3977 def A4_boundscheck : MInst <
3978 (outs PredRegs:$Pd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
3979 "$Pd=boundscheck($Rs,$Rtt)">;
3981 // A4_tlbmatch: Detect if a VA/ASID matches a TLB entry.
3982 let isPredicateLate = 1, hasSideEffects = 0, isCodeGenOnly = 0 in
3983 def A4_tlbmatch : ALU64Inst<(outs PredRegs:$Pd),
3984 (ins DoubleRegs:$Rs, IntRegs:$Rt),
3985 "$Pd = tlbmatch($Rs, $Rt)",
3986 [], "", ALU64_tc_2early_SLOT23> {
3991 let IClass = 0b1101;
3992 let Inst{27-23} = 0b00100;
3993 let Inst{20-16} = Rs;
3995 let Inst{12-8} = Rt;
3996 let Inst{7-5} = 0b011;
4000 // We need custom lowering of ISD::PREFETCH into HexagonISD::DCFETCH
4001 // because the SDNode ISD::PREFETCH has properties MayLoad and MayStore.
4002 // We don't really want either one here.
4003 def SDTHexagonDCFETCH : SDTypeProfile<0, 2, [SDTCisPtrTy<0>,SDTCisInt<1>]>;
4004 def HexagonDCFETCH : SDNode<"HexagonISD::DCFETCH", SDTHexagonDCFETCH,
4007 // Use LD0Inst for dcfetch, but set "mayLoad" to 0 because this doesn't
4008 // really do a load.
4009 let hasSideEffects = 1, mayLoad = 0, isCodeGenOnly = 0 in
4010 def Y2_dcfetchbo : LD0Inst<(outs), (ins IntRegs:$Rs, u11_3Imm:$u11_3),
4011 "dcfetch($Rs + #$u11_3)",
4012 [(HexagonDCFETCH IntRegs:$Rs, u11_3ImmPred:$u11_3)],
4013 "", LD_tc_ld_SLOT0> {
4017 let IClass = 0b1001;
4018 let Inst{27-21} = 0b0100000;
4019 let Inst{20-16} = Rs;
4021 let Inst{10-0} = u11_3{13-3};
4024 //===----------------------------------------------------------------------===//
4025 // Compound instructions
4026 //===----------------------------------------------------------------------===//
4028 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4029 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1,
4030 opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
4031 isTerminator = 1, validSubTargets = HasV4SubT in
4032 class CJInst_tstbit_R0<string px, bit np, string tnt>
4033 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
4034 ""#px#" = tstbit($Rs, #0); if ("
4035 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4036 [], "", COMPOUND, TypeCOMPOUND> {
4041 let isPredicatedFalse = np;
4042 // tnt: Taken/Not Taken
4043 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4044 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4046 let IClass = 0b0001;
4047 let Inst{27-26} = 0b00;
4048 let Inst{25} = !if (!eq(px, "!p1"), 1,
4049 !if (!eq(px, "p1"), 1, 0));
4050 let Inst{24-23} = 0b11;
4052 let Inst{21-20} = r9_2{10-9};
4053 let Inst{19-16} = Rs;
4054 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4055 let Inst{9-8} = 0b11;
4056 let Inst{7-1} = r9_2{8-2};
4059 let Defs = [PC, P0], Uses = [P0], isCodeGenOnly = 0 in {
4060 def J4_tstbit0_tp0_jump_nt : CJInst_tstbit_R0<"p0", 0, "nt">;
4061 def J4_tstbit0_tp0_jump_t : CJInst_tstbit_R0<"p0", 0, "t">;
4062 def J4_tstbit0_fp0_jump_nt : CJInst_tstbit_R0<"p0", 1, "nt">;
4063 def J4_tstbit0_fp0_jump_t : CJInst_tstbit_R0<"p0", 1, "t">;
4066 let Defs = [PC, P1], Uses = [P1], isCodeGenOnly = 0 in {
4067 def J4_tstbit0_tp1_jump_nt : CJInst_tstbit_R0<"p1", 0, "nt">;
4068 def J4_tstbit0_tp1_jump_t : CJInst_tstbit_R0<"p1", 0, "t">;
4069 def J4_tstbit0_fp1_jump_nt : CJInst_tstbit_R0<"p1", 1, "nt">;
4070 def J4_tstbit0_fp1_jump_t : CJInst_tstbit_R0<"p1", 1, "t">;
4074 let isBranch = 1, hasSideEffects = 0,
4075 isExtentSigned = 1, isPredicated = 1, isPredicatedNew = 1,
4076 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2,
4077 opExtendable = 2, isTerminator = 1, validSubTargets = HasV4SubT in
4078 class CJInst_RR<string px, string op, bit np, string tnt>
4079 : InstHexagon<(outs), (ins IntRegs:$Rs, IntRegs:$Rt, brtarget:$r9_2),
4080 ""#px#" = cmp."#op#"($Rs, $Rt); if ("
4081 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4082 [], "", COMPOUND, TypeCOMPOUND> {
4088 let isPredicatedFalse = np;
4089 // tnt: Taken/Not Taken
4090 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4091 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4093 let IClass = 0b0001;
4094 let Inst{27-23} = !if (!eq(op, "eq"), 0b01000,
4095 !if (!eq(op, "gt"), 0b01001,
4096 !if (!eq(op, "gtu"), 0b01010, 0)));
4098 let Inst{21-20} = r9_2{10-9};
4099 let Inst{19-16} = Rs;
4100 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4101 // px: Predicate reg 0/1
4102 let Inst{12} = !if (!eq(px, "!p1"), 1,
4103 !if (!eq(px, "p1"), 1, 0));
4104 let Inst{11-8} = Rt;
4105 let Inst{7-1} = r9_2{8-2};
4108 // P[10] taken/not taken.
4109 multiclass T_tnt_CJInst_RR<string op, bit np> {
4110 let Defs = [PC, P0], Uses = [P0] in {
4111 def NAME#p0_jump_nt : CJInst_RR<"p0", op, np, "nt">;
4112 def NAME#p0_jump_t : CJInst_RR<"p0", op, np, "t">;
4114 let Defs = [PC, P1], Uses = [P1] in {
4115 def NAME#p1_jump_nt : CJInst_RR<"p1", op, np, "nt">;
4116 def NAME#p1_jump_t : CJInst_RR<"p1", op, np, "t">;
4119 // Predicate / !Predicate
4120 multiclass T_pnp_CJInst_RR<string op>{
4121 defm J4_cmp#NAME#_t : T_tnt_CJInst_RR<op, 0>;
4122 defm J4_cmp#NAME#_f : T_tnt_CJInst_RR<op, 1>;
4124 // TypeCJ Instructions compare RR and jump
4125 let isCodeGenOnly = 0 in {
4126 defm eq : T_pnp_CJInst_RR<"eq">;
4127 defm gt : T_pnp_CJInst_RR<"gt">;
4128 defm gtu : T_pnp_CJInst_RR<"gtu">;
4131 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4132 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1, opExtentBits = 11,
4133 opExtentAlign = 2, opExtendable = 2, isTerminator = 1,
4134 validSubTargets = HasV4SubT in
4135 class CJInst_RU5<string px, string op, bit np, string tnt>
4136 : InstHexagon<(outs), (ins IntRegs:$Rs, u5Imm:$U5, brtarget:$r9_2),
4137 ""#px#" = cmp."#op#"($Rs, #$U5); if ("
4138 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4139 [], "", COMPOUND, TypeCOMPOUND> {
4145 let isPredicatedFalse = np;
4146 // tnt: Taken/Not Taken
4147 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4148 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4150 let IClass = 0b0001;
4151 let Inst{27-26} = 0b00;
4152 // px: Predicate reg 0/1
4153 let Inst{25} = !if (!eq(px, "!p1"), 1,
4154 !if (!eq(px, "p1"), 1, 0));
4155 let Inst{24-23} = !if (!eq(op, "eq"), 0b00,
4156 !if (!eq(op, "gt"), 0b01,
4157 !if (!eq(op, "gtu"), 0b10, 0)));
4159 let Inst{21-20} = r9_2{10-9};
4160 let Inst{19-16} = Rs;
4161 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4162 let Inst{12-8} = U5;
4163 let Inst{7-1} = r9_2{8-2};
4165 // P[10] taken/not taken.
4166 multiclass T_tnt_CJInst_RU5<string op, bit np> {
4167 let Defs = [PC, P0], Uses = [P0] in {
4168 def NAME#p0_jump_nt : CJInst_RU5<"p0", op, np, "nt">;
4169 def NAME#p0_jump_t : CJInst_RU5<"p0", op, np, "t">;
4171 let Defs = [PC, P1], Uses = [P1] in {
4172 def NAME#p1_jump_nt : CJInst_RU5<"p1", op, np, "nt">;
4173 def NAME#p1_jump_t : CJInst_RU5<"p1", op, np, "t">;
4176 // Predicate / !Predicate
4177 multiclass T_pnp_CJInst_RU5<string op>{
4178 defm J4_cmp#NAME#i_t : T_tnt_CJInst_RU5<op, 0>;
4179 defm J4_cmp#NAME#i_f : T_tnt_CJInst_RU5<op, 1>;
4181 // TypeCJ Instructions compare RI and jump
4182 let isCodeGenOnly = 0 in {
4183 defm eq : T_pnp_CJInst_RU5<"eq">;
4184 defm gt : T_pnp_CJInst_RU5<"gt">;
4185 defm gtu : T_pnp_CJInst_RU5<"gtu">;
4188 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4189 isPredicated = 1, isPredicatedFalse = 1, isPredicatedNew = 1,
4190 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
4191 isTerminator = 1, validSubTargets = HasV4SubT in
4192 class CJInst_Rn1<string px, string op, bit np, string tnt>
4193 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
4194 ""#px#" = cmp."#op#"($Rs,#-1); if ("
4195 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4196 [], "", COMPOUND, TypeCOMPOUND> {
4201 let isPredicatedFalse = np;
4202 // tnt: Taken/Not Taken
4203 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4204 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4206 let IClass = 0b0001;
4207 let Inst{27-26} = 0b00;
4208 let Inst{25} = !if (!eq(px, "!p1"), 1,
4209 !if (!eq(px, "p1"), 1, 0));
4211 let Inst{24-23} = 0b11;
4213 let Inst{21-20} = r9_2{10-9};
4214 let Inst{19-16} = Rs;
4215 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4216 let Inst{9-8} = !if (!eq(op, "eq"), 0b00,
4217 !if (!eq(op, "gt"), 0b01, 0));
4218 let Inst{7-1} = r9_2{8-2};
4221 // P[10] taken/not taken.
4222 multiclass T_tnt_CJInst_Rn1<string op, bit np> {
4223 let Defs = [PC, P0], Uses = [P0] in {
4224 def NAME#p0_jump_nt : CJInst_Rn1<"p0", op, np, "nt">;
4225 def NAME#p0_jump_t : CJInst_Rn1<"p0", op, np, "t">;
4227 let Defs = [PC, P1], Uses = [P1] in {
4228 def NAME#p1_jump_nt : CJInst_Rn1<"p1", op, np, "nt">;
4229 def NAME#p1_jump_t : CJInst_Rn1<"p1", op, np, "t">;
4232 // Predicate / !Predicate
4233 multiclass T_pnp_CJInst_Rn1<string op>{
4234 defm J4_cmp#NAME#n1_t : T_tnt_CJInst_Rn1<op, 0>;
4235 defm J4_cmp#NAME#n1_f : T_tnt_CJInst_Rn1<op, 1>;
4237 // TypeCJ Instructions compare -1 and jump
4238 let isCodeGenOnly = 0 in {
4239 defm eq : T_pnp_CJInst_Rn1<"eq">;
4240 defm gt : T_pnp_CJInst_Rn1<"gt">;
4243 // J4_jumpseti: Direct unconditional jump and set register to immediate.
4244 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4245 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4246 opExtentAlign = 2, opExtendable = 2, validSubTargets = HasV4SubT,
4247 isCodeGenOnly = 0 in
4248 def J4_jumpseti: CJInst <
4250 (ins u6Imm:$U6, brtarget:$r9_2),
4251 "$Rd = #$U6 ; jump $r9_2"> {
4256 let IClass = 0b0001;
4257 let Inst{27-24} = 0b0110;
4258 let Inst{21-20} = r9_2{10-9};
4259 let Inst{19-16} = Rd;
4260 let Inst{13-8} = U6;
4261 let Inst{7-1} = r9_2{8-2};
4264 // J4_jumpsetr: Direct unconditional jump and transfer register.
4265 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4266 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4267 opExtentAlign = 2, opExtendable = 2, validSubTargets = HasV4SubT,
4268 isCodeGenOnly = 0 in
4269 def J4_jumpsetr: CJInst <
4271 (ins IntRegs:$Rs, brtarget:$r9_2),
4272 "$Rd = $Rs ; jump $r9_2"> {
4277 let IClass = 0b0001;
4278 let Inst{27-24} = 0b0111;
4279 let Inst{21-20} = r9_2{10-9};
4280 let Inst{11-8} = Rd;
4281 let Inst{19-16} = Rs;
4282 let Inst{7-1} = r9_2{8-2};