1 //=- HexagonInstrInfoV4.td - Target Desc. for Hexagon Target -*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the Hexagon V4 instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 def addrga: PatLeaf<(i32 AddrGA:$Addr)>;
15 def addrgp: PatLeaf<(i32 AddrGP:$Addr)>;
17 let hasSideEffects = 0 in
18 class T_Immext<Operand ImmType>
19 : EXTENDERInst<(outs), (ins ImmType:$imm),
20 "immext(#$imm)", []> {
24 let Inst{27-16} = imm{31-20};
25 let Inst{13-0} = imm{19-6};
28 def A4_ext : T_Immext<u26_6Imm>;
29 let isCodeGenOnly = 1 in {
31 def A4_ext_b : T_Immext<brtarget>;
33 def A4_ext_c : T_Immext<calltarget>;
34 def A4_ext_g : T_Immext<globaladdress>;
37 def BITPOS32 : SDNodeXForm<imm, [{
38 // Return the bit position we will set [0-31].
40 int32_t imm = N->getSExtValue();
41 return XformMskToBitPosU5Imm(imm);
44 // Fold (add (CONST32 tglobaladdr:$addr) <offset>) into a global address.
45 def FoldGlobalAddr : ComplexPattern<i32, 1, "foldGlobalAddress", [], []>;
47 // Fold (add (CONST32_GP tglobaladdr:$addr) <offset>) into a global address.
48 def FoldGlobalAddrGP : ComplexPattern<i32, 1, "foldGlobalAddressGP", [], []>;
50 def NumUsesBelowThresCONST32 : PatFrag<(ops node:$addr),
51 (HexagonCONST32 node:$addr), [{
52 return hasNumUsesBelowThresGA(N->getOperand(0).getNode());
55 // Hexagon V4 Architecture spec defines 8 instruction classes:
56 // LD ST ALU32 XTYPE J JR MEMOP NV CR SYSTEM(system is not implemented in the
60 // ========================================
61 // Loads (8/16/32/64 bit)
65 // ========================================
66 // Stores (8/16/32/64 bit)
69 // ALU32 Instructions:
70 // ========================================
71 // Arithmetic / Logical (32 bit)
74 // XTYPE Instructions (32/64 bit):
75 // ========================================
76 // Arithmetic, Logical, Bit Manipulation
77 // Multiply (Integer, Fractional, Complex)
78 // Permute / Vector Permute Operations
79 // Predicate Operations
80 // Shift / Shift with Add/Sub/Logical
82 // Vector Halfword (ALU, Shift, Multiply)
83 // Vector Word (ALU, Shift)
86 // ========================================
87 // Jump/Call PC-relative
90 // ========================================
93 // MEMOP Instructions:
94 // ========================================
95 // Operation on memory (8/16/32 bit)
98 // ========================================
103 // ========================================
104 // Control-Register Transfers
105 // Hardware Loop Setup
106 // Predicate Logicals & Reductions
108 // SYSTEM Instructions (not implemented in the compiler):
109 // ========================================
115 //===----------------------------------------------------------------------===//
117 //===----------------------------------------------------------------------===//
119 class T_ALU32_3op_not<string mnemonic, bits<3> MajOp, bits<3> MinOp,
121 : T_ALU32_3op<mnemonic, MajOp, MinOp, OpsRev, 0> {
122 let AsmString = "$Rd = "#mnemonic#"($Rs, ~$Rt)";
125 let BaseOpcode = "andn_rr", CextOpcode = "andn" in
126 def A4_andn : T_ALU32_3op_not<"and", 0b001, 0b100, 1>;
127 let BaseOpcode = "orn_rr", CextOpcode = "orn" in
128 def A4_orn : T_ALU32_3op_not<"or", 0b001, 0b101, 1>;
130 let CextOpcode = "rcmp.eq" in
131 def A4_rcmpeq : T_ALU32_3op<"cmp.eq", 0b011, 0b010, 0, 1>;
132 let CextOpcode = "!rcmp.eq" in
133 def A4_rcmpneq : T_ALU32_3op<"!cmp.eq", 0b011, 0b011, 0, 1>;
135 def C4_cmpneq : T_ALU32_3op_cmp<"!cmp.eq", 0b00, 1, 1>;
136 def C4_cmplte : T_ALU32_3op_cmp<"!cmp.gt", 0b10, 1, 0>;
137 def C4_cmplteu : T_ALU32_3op_cmp<"!cmp.gtu", 0b11, 1, 0>;
139 // Pats for instruction selection.
141 // A class to embed the usual comparison patfrags within a zext to i32.
142 // The seteq/setne frags use "lhs" and "rhs" as operands, so use the same
143 // names, or else the frag's "body" won't match the operands.
144 class CmpInReg<PatFrag Op>
145 : PatFrag<(ops node:$lhs, node:$rhs),(i32 (zext (i1 Op.Fragment)))>;
147 def: T_cmp32_rr_pat<A4_rcmpeq, CmpInReg<seteq>, i32>;
148 def: T_cmp32_rr_pat<A4_rcmpneq, CmpInReg<setne>, i32>;
150 def: T_cmp32_rr_pat<C4_cmpneq, setne, i1>;
152 class T_CMP_rrbh<string mnemonic, bits<3> MinOp, bit IsComm>
153 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
154 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", S_3op_tc_2early_SLOT23>,
156 let validSubTargets = HasV4SubT;
157 let InputType = "reg";
158 let CextOpcode = mnemonic;
160 let isCommutable = IsComm;
161 let hasSideEffects = 0;
168 let Inst{27-21} = 0b0111110;
169 let Inst{20-16} = Rs;
171 let Inst{7-5} = MinOp;
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>;
182 class T_CMP_ribh<string mnemonic, bits<2> MajOp, bit IsHalf, bit IsComm,
183 Operand ImmType, bit IsImmExt, bit IsImmSigned, int ImmBits>
184 : ALU64Inst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, ImmType:$Imm),
185 "$Pd = "#mnemonic#"($Rs, #$Imm)", [], "", ALU64_tc_2early_SLOT23>,
187 let validSubTargets = HasV4SubT;
188 let InputType = "imm";
189 let CextOpcode = mnemonic;
191 let isCommutable = IsComm;
192 let hasSideEffects = 0;
193 let isExtendable = IsImmExt;
194 let opExtendable = !if (IsImmExt, 2, 0);
195 let isExtentSigned = IsImmSigned;
196 let opExtentBits = ImmBits;
203 let Inst{27-24} = 0b1101;
204 let Inst{22-21} = MajOp;
205 let Inst{20-16} = Rs;
206 let Inst{12-5} = Imm;
208 let Inst{3} = IsHalf;
212 def A4_cmpbeqi : T_CMP_ribh<"cmpb.eq", 0b00, 0, 1, u8Imm, 0, 0, 8>;
213 def A4_cmpbgti : T_CMP_ribh<"cmpb.gt", 0b01, 0, 0, s8Imm, 0, 1, 8>;
214 def A4_cmpbgtui : T_CMP_ribh<"cmpb.gtu", 0b10, 0, 0, u7Ext, 1, 0, 7>;
215 def A4_cmpheqi : T_CMP_ribh<"cmph.eq", 0b00, 1, 1, s8Ext, 1, 1, 8>;
216 def A4_cmphgti : T_CMP_ribh<"cmph.gt", 0b01, 1, 0, s8Ext, 1, 1, 8>;
217 def A4_cmphgtui : T_CMP_ribh<"cmph.gtu", 0b10, 1, 0, u7Ext, 1, 0, 7>;
219 class T_RCMP_EQ_ri<string mnemonic, bit IsNeg>
220 : ALU32_ri<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s8Ext:$s8),
221 "$Rd = "#mnemonic#"($Rs, #$s8)", [], "", ALU32_2op_tc_1_SLOT0123>,
223 let validSubTargets = HasV4SubT;
224 let InputType = "imm";
225 let CextOpcode = !if (IsNeg, "!rcmp.eq", "rcmp.eq");
226 let isExtendable = 1;
227 let opExtendable = 2;
228 let isExtentSigned = 1;
229 let opExtentBits = 8;
237 let Inst{27-24} = 0b0011;
239 let Inst{21} = IsNeg;
240 let Inst{20-16} = Rs;
246 def A4_rcmpeqi : T_RCMP_EQ_ri<"cmp.eq", 0>;
247 def A4_rcmpneqi : T_RCMP_EQ_ri<"!cmp.eq", 1>;
249 def: Pat<(i32 (zext (i1 (seteq (i32 IntRegs:$Rs), s8ExtPred:$s8)))),
250 (A4_rcmpeqi IntRegs:$Rs, s8ExtPred:$s8)>;
251 def: Pat<(i32 (zext (i1 (setne (i32 IntRegs:$Rs), s8ExtPred:$s8)))),
252 (A4_rcmpneqi IntRegs:$Rs, s8ExtPred:$s8)>;
254 // Preserve the S2_tstbit_r generation
255 def: Pat<(i32 (zext (i1 (setne (i32 (and (i32 (shl 1, (i32 IntRegs:$src2))),
256 (i32 IntRegs:$src1))), 0)))),
257 (C2_muxii (S2_tstbit_r IntRegs:$src1, IntRegs:$src2), 1, 0)>;
259 //===----------------------------------------------------------------------===//
261 //===----------------------------------------------------------------------===//
264 //===----------------------------------------------------------------------===//
266 //===----------------------------------------------------------------------===//
268 // Combine a word and an immediate into a register pair.
269 let hasSideEffects = 0, isExtentSigned = 1, isExtendable = 1,
271 class T_Combine1 <bits<2> MajOp, dag ins, string AsmStr>
272 : ALU32Inst <(outs DoubleRegs:$Rdd), ins, AsmStr> {
278 let Inst{27-24} = 0b0011;
279 let Inst{22-21} = MajOp;
280 let Inst{20-16} = Rs;
286 let opExtendable = 2 in
287 def A4_combineri : T_Combine1<0b00, (ins IntRegs:$Rs, s8Ext:$s8),
288 "$Rdd = combine($Rs, #$s8)">;
290 let opExtendable = 1 in
291 def A4_combineir : T_Combine1<0b01, (ins s8Ext:$s8, IntRegs:$Rs),
292 "$Rdd = combine(#$s8, $Rs)">;
294 def HexagonWrapperCombineRI_V4 :
295 SDNode<"HexagonISD::WrapperCombineRI_V4", SDTHexagonI64I32I32>;
296 def HexagonWrapperCombineIR_V4 :
297 SDNode<"HexagonISD::WrapperCombineIR_V4", SDTHexagonI64I32I32>;
299 def : Pat <(HexagonWrapperCombineRI_V4 IntRegs:$r, s8ExtPred:$i),
300 (A4_combineri IntRegs:$r, s8ExtPred:$i)>,
303 def : Pat <(HexagonWrapperCombineIR_V4 s8ExtPred:$i, IntRegs:$r),
304 (A4_combineir s8ExtPred:$i, IntRegs:$r)>,
307 // A4_combineii: Set two small immediates.
308 let hasSideEffects = 0, isExtendable = 1, opExtentBits = 6, opExtendable = 2 in
309 def A4_combineii: ALU32Inst<(outs DoubleRegs:$Rdd), (ins s8Imm:$s8, u6Ext:$U6),
310 "$Rdd = combine(#$s8, #$U6)"> {
316 let Inst{27-23} = 0b11001;
317 let Inst{20-16} = U6{5-1};
318 let Inst{13} = U6{0};
323 //===----------------------------------------------------------------------===//
325 //===----------------------------------------------------------------------===//
327 //===----------------------------------------------------------------------===//
329 //===----------------------------------------------------------------------===//
331 def Zext64: OutPatFrag<(ops node:$Rs),
332 (i64 (A4_combineir 0, (i32 $Rs)))>;
333 def Sext64: OutPatFrag<(ops node:$Rs),
334 (i64 (A2_sxtw (i32 $Rs)))>;
336 // Patterns to generate indexed loads with different forms of the address:
339 // - base (without offset).
340 multiclass Loadxm_pat<PatFrag Load, ValueType VT, PatFrag ValueMod,
341 PatLeaf ImmPred, InstHexagon MI> {
342 def: Pat<(VT (Load AddrFI:$fi)),
343 (VT (ValueMod (MI AddrFI:$fi, 0)))>;
344 def: Pat<(VT (Load (add IntRegs:$Rs, ImmPred:$Off))),
345 (VT (ValueMod (MI IntRegs:$Rs, imm:$Off)))>;
346 def: Pat<(VT (Load (i32 IntRegs:$Rs))),
347 (VT (ValueMod (MI IntRegs:$Rs, 0)))>;
350 defm: Loadxm_pat<extloadi1, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
351 defm: Loadxm_pat<extloadi8, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
352 defm: Loadxm_pat<extloadi16, i64, Zext64, s11_1ExtPred, L2_loadruh_io>;
353 defm: Loadxm_pat<zextloadi1, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
354 defm: Loadxm_pat<zextloadi8, i64, Zext64, s11_0ExtPred, L2_loadrub_io>;
355 defm: Loadxm_pat<zextloadi16, i64, Zext64, s11_1ExtPred, L2_loadruh_io>;
356 defm: Loadxm_pat<sextloadi8, i64, Sext64, s11_0ExtPred, L2_loadrb_io>;
357 defm: Loadxm_pat<sextloadi16, i64, Sext64, s11_1ExtPred, L2_loadrh_io>;
359 // Map Rdd = anyext(Rs) -> Rdd = combine(#0, Rs).
360 def: Pat<(i64 (anyext (i32 IntRegs:$src1))), (Zext64 IntRegs:$src1)>;
362 //===----------------------------------------------------------------------===//
363 // Template class for load instructions with Absolute set addressing mode.
364 //===----------------------------------------------------------------------===//
365 let isExtended = 1, opExtendable = 2, opExtentBits = 6, addrMode = AbsoluteSet,
366 hasSideEffects = 0 in
367 class T_LD_abs_set<string mnemonic, RegisterClass RC, bits<4>MajOp>:
368 LDInst<(outs RC:$dst1, IntRegs:$dst2),
370 "$dst1 = "#mnemonic#"($dst2 = #$addr)",
378 let Inst{27-25} = 0b101;
379 let Inst{24-21} = MajOp;
380 let Inst{13-12} = 0b01;
381 let Inst{4-0} = dst1;
382 let Inst{20-16} = dst2;
383 let Inst{11-8} = addr{5-2};
384 let Inst{6-5} = addr{1-0};
387 let accessSize = ByteAccess, hasNewValue = 1 in {
388 def L4_loadrb_ap : T_LD_abs_set <"memb", IntRegs, 0b1000>;
389 def L4_loadrub_ap : T_LD_abs_set <"memub", IntRegs, 0b1001>;
392 let accessSize = HalfWordAccess, hasNewValue = 1 in {
393 def L4_loadrh_ap : T_LD_abs_set <"memh", IntRegs, 0b1010>;
394 def L4_loadruh_ap : T_LD_abs_set <"memuh", IntRegs, 0b1011>;
397 let accessSize = WordAccess, hasNewValue = 1 in
398 def L4_loadri_ap : T_LD_abs_set <"memw", IntRegs, 0b1100>;
400 let accessSize = DoubleWordAccess in
401 def L4_loadrd_ap : T_LD_abs_set <"memd", DoubleRegs, 0b1110>;
402 // Load - Indirect with long offset
403 let InputType = "imm", addrMode = BaseLongOffset, isExtended = 1,
404 opExtentBits = 6, opExtendable = 3 in
405 class T_LoadAbsReg <string mnemonic, string CextOp, RegisterClass RC,
407 : LDInst <(outs RC:$dst), (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3),
408 "$dst = "#mnemonic#"($src1<<#$src2 + #$src3)",
414 let CextOpcode = CextOp;
415 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
418 let Inst{27-25} = 0b110;
419 let Inst{24-21} = MajOp;
420 let Inst{20-16} = src1;
421 let Inst{13} = src2{1};
423 let Inst{11-8} = src3{5-2};
424 let Inst{7} = src2{0};
425 let Inst{6-5} = src3{1-0};
429 let accessSize = ByteAccess in {
430 def L4_loadrb_ur : T_LoadAbsReg<"memb", "LDrib", IntRegs, 0b1000>;
431 def L4_loadrub_ur : T_LoadAbsReg<"memub", "LDriub", IntRegs, 0b1001>;
432 def L4_loadalignb_ur : T_LoadAbsReg<"memb_fifo", "LDrib_fifo",
436 let accessSize = HalfWordAccess in {
437 def L4_loadrh_ur : T_LoadAbsReg<"memh", "LDrih", IntRegs, 0b1010>;
438 def L4_loadruh_ur : T_LoadAbsReg<"memuh", "LDriuh", IntRegs, 0b1011>;
439 def L4_loadbsw2_ur : T_LoadAbsReg<"membh", "LDribh2", IntRegs, 0b0001>;
440 def L4_loadbzw2_ur : T_LoadAbsReg<"memubh", "LDriubh2", IntRegs, 0b0011>;
441 def L4_loadalignh_ur : T_LoadAbsReg<"memh_fifo", "LDrih_fifo",
445 let accessSize = WordAccess in {
446 def L4_loadri_ur : T_LoadAbsReg<"memw", "LDriw", IntRegs, 0b1100>;
447 def L4_loadbsw4_ur : T_LoadAbsReg<"membh", "LDribh4", DoubleRegs, 0b0111>;
448 def L4_loadbzw4_ur : T_LoadAbsReg<"memubh", "LDriubh4", DoubleRegs, 0b0101>;
451 let accessSize = DoubleWordAccess in
452 def L4_loadrd_ur : T_LoadAbsReg<"memd", "LDrid", DoubleRegs, 0b1110>;
455 multiclass T_LoadAbsReg_Pat <PatFrag ldOp, InstHexagon MI, ValueType VT = i32> {
456 def : Pat <(VT (ldOp (add (shl IntRegs:$src1, u2ImmPred:$src2),
457 (HexagonCONST32 tglobaladdr:$src3)))),
458 (MI IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3)>;
460 def : Pat <(VT (ldOp (add IntRegs:$src1,
461 (HexagonCONST32 tglobaladdr:$src2)))),
462 (MI IntRegs:$src1, 0, tglobaladdr:$src2)>;
465 let AddedComplexity = 60 in {
466 defm : T_LoadAbsReg_Pat <sextloadi8, L4_loadrb_ur>;
467 defm : T_LoadAbsReg_Pat <zextloadi8, L4_loadrub_ur>;
468 defm : T_LoadAbsReg_Pat <extloadi8, L4_loadrub_ur>;
470 defm : T_LoadAbsReg_Pat <sextloadi16, L4_loadrh_ur>;
471 defm : T_LoadAbsReg_Pat <zextloadi16, L4_loadruh_ur>;
472 defm : T_LoadAbsReg_Pat <extloadi16, L4_loadruh_ur>;
474 defm : T_LoadAbsReg_Pat <load, L4_loadri_ur>;
475 defm : T_LoadAbsReg_Pat <load, L4_loadrd_ur, i64>;
478 //===----------------------------------------------------------------------===//
479 // Template classes for the non-predicated load instructions with
480 // base + register offset addressing mode
481 //===----------------------------------------------------------------------===//
482 class T_load_rr <string mnemonic, RegisterClass RC, bits<3> MajOp>:
483 LDInst<(outs RC:$dst), (ins IntRegs:$src1, IntRegs:$src2, u2Imm:$u2),
484 "$dst = "#mnemonic#"($src1 + $src2<<#$u2)",
485 [], "", V4LDST_tc_ld_SLOT01>, ImmRegShl, AddrModeRel {
493 let Inst{27-24} = 0b1010;
494 let Inst{23-21} = MajOp;
495 let Inst{20-16} = src1;
496 let Inst{12-8} = src2;
497 let Inst{13} = u2{1};
502 //===----------------------------------------------------------------------===//
503 // Template classes for the predicated load instructions with
504 // base + register offset addressing mode
505 //===----------------------------------------------------------------------===//
506 let isPredicated = 1 in
507 class T_pload_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
508 bit isNot, bit isPredNew>:
509 LDInst <(outs RC:$dst),
510 (ins PredRegs:$src1, IntRegs:$src2, IntRegs:$src3, u2Imm:$u2),
511 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
512 ") ")#"$dst = "#mnemonic#"($src2+$src3<<#$u2)",
513 [], "", V4LDST_tc_ld_SLOT01>, AddrModeRel {
520 let isPredicatedFalse = isNot;
521 let isPredicatedNew = isPredNew;
525 let Inst{27-26} = 0b00;
526 let Inst{25} = isPredNew;
527 let Inst{24} = isNot;
528 let Inst{23-21} = MajOp;
529 let Inst{20-16} = src2;
530 let Inst{12-8} = src3;
531 let Inst{13} = u2{1};
533 let Inst{6-5} = src1;
537 //===----------------------------------------------------------------------===//
538 // multiclass for load instructions with base + register offset
540 //===----------------------------------------------------------------------===//
541 let hasSideEffects = 0, addrMode = BaseRegOffset in
542 multiclass ld_idxd_shl <string mnemonic, string CextOp, RegisterClass RC,
544 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl,
545 InputType = "reg" in {
546 let isPredicable = 1 in
547 def L4_#NAME#_rr : T_load_rr <mnemonic, RC, MajOp>;
550 def L4_p#NAME#t_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 0>;
551 def L4_p#NAME#f_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 0>;
554 def L4_p#NAME#tnew_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 1>;
555 def L4_p#NAME#fnew_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 1>;
559 let hasNewValue = 1, accessSize = ByteAccess in {
560 defm loadrb : ld_idxd_shl<"memb", "LDrib", IntRegs, 0b000>;
561 defm loadrub : ld_idxd_shl<"memub", "LDriub", IntRegs, 0b001>;
564 let hasNewValue = 1, accessSize = HalfWordAccess in {
565 defm loadrh : ld_idxd_shl<"memh", "LDrih", IntRegs, 0b010>;
566 defm loadruh : ld_idxd_shl<"memuh", "LDriuh", IntRegs, 0b011>;
569 let hasNewValue = 1, accessSize = WordAccess in
570 defm loadri : ld_idxd_shl<"memw", "LDriw", IntRegs, 0b100>;
572 let accessSize = DoubleWordAccess in
573 defm loadrd : ld_idxd_shl<"memd", "LDrid", DoubleRegs, 0b110>;
575 // 'def pats' for load instructions with base + register offset and non-zero
576 // immediate value. Immediate value is used to left-shift the second
578 class Loadxs_pat<PatFrag Load, ValueType VT, InstHexagon MI>
579 : Pat<(VT (Load (add (i32 IntRegs:$Rs),
580 (i32 (shl (i32 IntRegs:$Rt), u2ImmPred:$u2))))),
581 (VT (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2))>;
583 let AddedComplexity = 40 in {
584 def: Loadxs_pat<extloadi8, i32, L4_loadrub_rr>;
585 def: Loadxs_pat<zextloadi8, i32, L4_loadrub_rr>;
586 def: Loadxs_pat<sextloadi8, i32, L4_loadrb_rr>;
587 def: Loadxs_pat<extloadi16, i32, L4_loadruh_rr>;
588 def: Loadxs_pat<zextloadi16, i32, L4_loadruh_rr>;
589 def: Loadxs_pat<sextloadi16, i32, L4_loadrh_rr>;
590 def: Loadxs_pat<load, i32, L4_loadri_rr>;
591 def: Loadxs_pat<load, i64, L4_loadrd_rr>;
594 // 'def pats' for load instruction base + register offset and
595 // zero immediate value.
596 class Loadxs_simple_pat<PatFrag Load, ValueType VT, InstHexagon MI>
597 : Pat<(VT (Load (add (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)))),
598 (VT (MI IntRegs:$Rs, IntRegs:$Rt, 0))>;
600 let AddedComplexity = 20 in {
601 def: Loadxs_simple_pat<extloadi8, i32, L4_loadrub_rr>;
602 def: Loadxs_simple_pat<zextloadi8, i32, L4_loadrub_rr>;
603 def: Loadxs_simple_pat<sextloadi8, i32, L4_loadrb_rr>;
604 def: Loadxs_simple_pat<extloadi16, i32, L4_loadruh_rr>;
605 def: Loadxs_simple_pat<zextloadi16, i32, L4_loadruh_rr>;
606 def: Loadxs_simple_pat<sextloadi16, i32, L4_loadrh_rr>;
607 def: Loadxs_simple_pat<load, i32, L4_loadri_rr>;
608 def: Loadxs_simple_pat<load, i64, L4_loadrd_rr>;
612 def: Pat<(i64 (zext (i1 PredRegs:$src1))),
613 (Zext64 (C2_muxii PredRegs:$src1, 1, 0))>;
616 def: Pat<(i64 (zext (i32 IntRegs:$src1))),
617 (Zext64 IntRegs:$src1)>;
620 def: Pat <(i64 (zextloadi32 ADDRriS11_2:$src1)),
621 (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>,
624 let AddedComplexity = 100 in
625 def: Pat <(i64 (zextloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
626 (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1,
627 s11_2ExtPred:$offset)))>,
631 def: Pat <(i64 (extloadi32 ADDRriS11_2:$src1)),
632 (i64 (A4_combineir 0, (L2_loadri_io AddrFI:$src1, 0)))>,
635 let AddedComplexity = 100 in
636 def: Pat <(i64 (extloadi32 (i32 (add IntRegs:$src1, s11_2ExtPred:$offset)))),
637 (i64 (A4_combineir 0, (L2_loadri_io IntRegs:$src1,
638 s11_2ExtPred:$offset)))>,
643 //===----------------------------------------------------------------------===//
645 //===----------------------------------------------------------------------===//
647 //===----------------------------------------------------------------------===//
649 //===----------------------------------------------------------------------===//
651 //===----------------------------------------------------------------------===//
652 // Template class for store instructions with Absolute set addressing mode.
653 //===----------------------------------------------------------------------===//
654 let isExtended = 1, opExtendable = 1, opExtentBits = 6,
655 addrMode = AbsoluteSet, isNVStorable = 1 in
656 class T_ST_absset <string mnemonic, string BaseOp, RegisterClass RC,
657 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
658 : STInst<(outs IntRegs:$dst),
659 (ins u6Ext:$addr, RC:$src),
660 mnemonic#"($dst = #$addr) = $src"#!if(isHalf, ".h","")>, NewValueRel {
664 let accessSize = AccessSz;
665 let BaseOpcode = BaseOp#"_AbsSet";
669 let Inst{27-24} = 0b1011;
670 let Inst{23-21} = MajOp;
671 let Inst{20-16} = dst;
673 let Inst{12-8} = src;
675 let Inst{5-0} = addr;
678 def S4_storerb_ap : T_ST_absset <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
679 def S4_storerh_ap : T_ST_absset <"memh", "STrih", IntRegs, 0b010,
681 def S4_storeri_ap : T_ST_absset <"memw", "STriw", IntRegs, 0b100, WordAccess>;
683 let isNVStorable = 0 in {
684 def S4_storerf_ap : T_ST_absset <"memh", "STrif", IntRegs,
685 0b011, HalfWordAccess, 1>;
686 def S4_storerd_ap : T_ST_absset <"memd", "STrid", DoubleRegs,
687 0b110, DoubleWordAccess>;
690 let opExtendable = 1, isNewValue = 1, isNVStore = 1, opNewValue = 2,
691 isExtended = 1, opExtentBits= 6 in
692 class T_ST_absset_nv <string mnemonic, string BaseOp, bits<2> MajOp,
693 MemAccessSize AccessSz >
694 : NVInst <(outs IntRegs:$dst),
695 (ins u6Ext:$addr, IntRegs:$src),
696 mnemonic#"($dst = #$addr) = $src.new">, NewValueRel {
700 let accessSize = AccessSz;
701 let BaseOpcode = BaseOp#"_AbsSet";
705 let Inst{27-21} = 0b1011101;
706 let Inst{20-16} = dst;
707 let Inst{13-11} = 0b000;
708 let Inst{12-11} = MajOp;
709 let Inst{10-8} = src;
711 let Inst{5-0} = addr;
714 let mayStore = 1, addrMode = AbsoluteSet in {
715 def S4_storerbnew_ap : T_ST_absset_nv <"memb", "STrib", 0b00, ByteAccess>;
716 def S4_storerhnew_ap : T_ST_absset_nv <"memh", "STrih", 0b01, HalfWordAccess>;
717 def S4_storerinew_ap : T_ST_absset_nv <"memw", "STriw", 0b10, WordAccess>;
720 let isExtended = 1, opExtendable = 2, opExtentBits = 6, InputType = "imm",
721 addrMode = BaseLongOffset, AddedComplexity = 40 in
722 class T_StoreAbsReg <string mnemonic, string CextOp, RegisterClass RC,
723 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
725 (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3, RC:$src4),
726 mnemonic#"($src1<<#$src2 + #$src3) = $src4"#!if(isHalf, ".h",""),
727 []>, ImmRegShl, NewValueRel {
734 let accessSize = AccessSz;
735 let CextOpcode = CextOp;
736 let BaseOpcode = CextOp#"_shl";
739 let Inst{27-24} =0b1101;
740 let Inst{23-21} = MajOp;
741 let Inst{20-16} = src1;
742 let Inst{13} = src2{1};
743 let Inst{12-8} = src4;
745 let Inst{6} = src2{0};
746 let Inst{5-0} = src3;
749 def S4_storerb_ur : T_StoreAbsReg <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
750 def S4_storerh_ur : T_StoreAbsReg <"memh", "STrih", IntRegs, 0b010,
752 def S4_storerf_ur : T_StoreAbsReg <"memh", "STrif", IntRegs, 0b011,
754 def S4_storeri_ur : T_StoreAbsReg <"memw", "STriw", IntRegs, 0b100, WordAccess>;
755 def S4_storerd_ur : T_StoreAbsReg <"memd", "STrid", DoubleRegs, 0b110,
758 let AddedComplexity = 40 in
759 multiclass T_StoreAbsReg_Pats <InstHexagon MI, RegisterClass RC, ValueType VT,
761 def : Pat<(stOp (VT RC:$src4),
762 (add (shl (i32 IntRegs:$src1), u2ImmPred:$src2),
763 u0AlwaysExtPred:$src3)),
764 (MI IntRegs:$src1, u2ImmPred:$src2, u0AlwaysExtPred:$src3, RC:$src4)>;
766 def : Pat<(stOp (VT RC:$src4),
767 (add (shl IntRegs:$src1, u2ImmPred:$src2),
768 (HexagonCONST32 tglobaladdr:$src3))),
769 (MI IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3, RC:$src4)>;
771 def : Pat<(stOp (VT RC:$src4),
772 (add IntRegs:$src1, (HexagonCONST32 tglobaladdr:$src3))),
773 (MI IntRegs:$src1, 0, tglobaladdr:$src3, RC:$src4)>;
776 defm : T_StoreAbsReg_Pats <S4_storerd_ur, DoubleRegs, i64, store>;
777 defm : T_StoreAbsReg_Pats <S4_storeri_ur, IntRegs, i32, store>;
778 defm : T_StoreAbsReg_Pats <S4_storerb_ur, IntRegs, i32, truncstorei8>;
779 defm : T_StoreAbsReg_Pats <S4_storerh_ur, IntRegs, i32, truncstorei16>;
781 let mayStore = 1, isNVStore = 1, isExtended = 1, addrMode = BaseLongOffset,
782 opExtentBits = 6, isNewValue = 1, opNewValue = 3, opExtendable = 2 in
783 class T_StoreAbsRegNV <string mnemonic, string CextOp, bits<2> MajOp,
784 MemAccessSize AccessSz>
786 (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3, IntRegs:$src4),
787 mnemonic#"($src1<<#$src2 + #$src3) = $src4.new">, NewValueRel {
793 let CextOpcode = CextOp;
794 let BaseOpcode = CextOp#"_shl";
797 let Inst{27-21} = 0b1101101;
798 let Inst{12-11} = 0b00;
800 let Inst{20-16} = src1;
801 let Inst{13} = src2{1};
802 let Inst{12-11} = MajOp;
803 let Inst{10-8} = src4;
804 let Inst{6} = src2{0};
805 let Inst{5-0} = src3;
808 def S4_storerbnew_ur : T_StoreAbsRegNV <"memb", "STrib", 0b00, ByteAccess>;
809 def S4_storerhnew_ur : T_StoreAbsRegNV <"memh", "STrih", 0b01, HalfWordAccess>;
810 def S4_storerinew_ur : T_StoreAbsRegNV <"memw", "STriw", 0b10, WordAccess>;
812 //===----------------------------------------------------------------------===//
813 // Template classes for the non-predicated store instructions with
814 // base + register offset addressing mode
815 //===----------------------------------------------------------------------===//
816 let isPredicable = 1 in
817 class T_store_rr <string mnemonic, RegisterClass RC, bits<3> MajOp, bit isH>
818 : STInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
819 mnemonic#"($Rs + $Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
820 [],"",V4LDST_tc_st_SLOT01>, ImmRegShl, AddrModeRel {
829 let Inst{27-24} = 0b1011;
830 let Inst{23-21} = MajOp;
831 let Inst{20-16} = Rs;
833 let Inst{13} = u2{1};
838 //===----------------------------------------------------------------------===//
839 // Template classes for the predicated store instructions with
840 // base + register offset addressing mode
841 //===----------------------------------------------------------------------===//
842 let isPredicated = 1 in
843 class T_pstore_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
844 bit isNot, bit isPredNew, bit isH>
846 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
848 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
849 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
850 [], "", V4LDST_tc_st_SLOT01> , AddrModeRel{
857 let isPredicatedFalse = isNot;
858 let isPredicatedNew = isPredNew;
862 let Inst{27-26} = 0b01;
863 let Inst{25} = isPredNew;
864 let Inst{24} = isNot;
865 let Inst{23-21} = MajOp;
866 let Inst{20-16} = Rs;
868 let Inst{13} = u2{1};
874 //===----------------------------------------------------------------------===//
875 // Template classes for the new-value store instructions with
876 // base + register offset addressing mode
877 //===----------------------------------------------------------------------===//
878 let isPredicable = 1, isNewValue = 1, opNewValue = 3 in
879 class T_store_new_rr <string mnemonic, bits<2> MajOp> :
880 NVInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
881 mnemonic#"($Rs + $Ru<<#$u2) = $Nt.new",
882 [],"",V4LDST_tc_st_SLOT0>, ImmRegShl, AddrModeRel {
891 let Inst{27-21} = 0b1011101;
892 let Inst{20-16} = Rs;
894 let Inst{13} = u2{1};
896 let Inst{4-3} = MajOp;
900 //===----------------------------------------------------------------------===//
901 // Template classes for the predicated new-value store instructions with
902 // base + register offset addressing mode
903 //===----------------------------------------------------------------------===//
904 let isPredicated = 1, isNewValue = 1, opNewValue = 4 in
905 class T_pstore_new_rr <string mnemonic, bits<2> MajOp, bit isNot, bit isPredNew>
907 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
908 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
909 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Nt.new",
910 [], "", V4LDST_tc_st_SLOT0>, AddrModeRel {
917 let isPredicatedFalse = isNot;
918 let isPredicatedNew = isPredNew;
921 let Inst{27-26} = 0b01;
922 let Inst{25} = isPredNew;
923 let Inst{24} = isNot;
924 let Inst{23-21} = 0b101;
925 let Inst{20-16} = Rs;
927 let Inst{13} = u2{1};
930 let Inst{4-3} = MajOp;
934 //===----------------------------------------------------------------------===//
935 // multiclass for store instructions with base + register offset addressing
937 //===----------------------------------------------------------------------===//
938 let isNVStorable = 1 in
939 multiclass ST_Idxd_shl<string mnemonic, string CextOp, RegisterClass RC,
940 bits<3> MajOp, bit isH = 0> {
941 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
942 def S4_#NAME#_rr : T_store_rr <mnemonic, RC, MajOp, isH>;
945 def S4_p#NAME#t_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 0, isH>;
946 def S4_p#NAME#f_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 0, isH>;
949 def S4_p#NAME#tnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 1, isH>;
950 def S4_p#NAME#fnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 1, isH>;
954 //===----------------------------------------------------------------------===//
955 // multiclass for new-value store instructions with base + register offset
957 //===----------------------------------------------------------------------===//
958 let mayStore = 1, isNVStore = 1 in
959 multiclass ST_Idxd_shl_nv <string mnemonic, string CextOp, RegisterClass RC,
961 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
962 def S4_#NAME#new_rr : T_store_new_rr<mnemonic, MajOp>;
965 def S4_p#NAME#newt_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 0>;
966 def S4_p#NAME#newf_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 0>;
969 def S4_p#NAME#newtnew_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 1>;
970 def S4_p#NAME#newfnew_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 1>;
974 let addrMode = BaseRegOffset, InputType = "reg", hasSideEffects = 0 in {
975 let accessSize = ByteAccess in
976 defm storerb: ST_Idxd_shl<"memb", "STrib", IntRegs, 0b000>,
977 ST_Idxd_shl_nv<"memb", "STrib", IntRegs, 0b00>;
979 let accessSize = HalfWordAccess in
980 defm storerh: ST_Idxd_shl<"memh", "STrih", IntRegs, 0b010>,
981 ST_Idxd_shl_nv<"memh", "STrih", IntRegs, 0b01>;
983 let accessSize = WordAccess in
984 defm storeri: ST_Idxd_shl<"memw", "STriw", IntRegs, 0b100>,
985 ST_Idxd_shl_nv<"memw", "STriw", IntRegs, 0b10>;
987 let isNVStorable = 0, accessSize = DoubleWordAccess in
988 defm storerd: ST_Idxd_shl<"memd", "STrid", DoubleRegs, 0b110>;
990 let isNVStorable = 0, accessSize = HalfWordAccess in
991 defm storerf: ST_Idxd_shl<"memh", "STrif", IntRegs, 0b011, 1>;
994 class Storexs_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
995 : Pat<(Store Value:$Ru, (add (i32 IntRegs:$Rs),
996 (i32 (shl (i32 IntRegs:$Rt), u2ImmPred:$u2)))),
997 (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2, Value:$Ru)>;
999 let AddedComplexity = 40 in {
1000 def: Storexs_pat<truncstorei8, I32, S4_storerb_rr>;
1001 def: Storexs_pat<truncstorei16, I32, S4_storerh_rr>;
1002 def: Storexs_pat<store, I32, S4_storeri_rr>;
1003 def: Storexs_pat<store, I64, S4_storerd_rr>;
1006 // memd(Rx++#s4:3)=Rtt
1007 // memd(Rx++#s4:3:circ(Mu))=Rtt
1008 // memd(Rx++I:circ(Mu))=Rtt
1010 // memd(Rx++Mu:brev)=Rtt
1011 // memd(gp+#u16:3)=Rtt
1013 // Store doubleword conditionally.
1014 // if ([!]Pv[.new]) memd(#u6)=Rtt
1015 // TODO: needs to be implemented.
1017 //===----------------------------------------------------------------------===//
1019 //===----------------------------------------------------------------------===//
1020 let isPredicable = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 8,
1022 class T_StoreImm <string mnemonic, Operand OffsetOp, bits<2> MajOp >
1023 : STInst <(outs ), (ins IntRegs:$Rs, OffsetOp:$offset, s8Ext:$S8),
1024 mnemonic#"($Rs+#$offset)=#$S8",
1025 [], "", V4LDST_tc_st_SLOT01>,
1026 ImmRegRel, PredNewRel {
1032 string OffsetOpStr = !cast<string>(OffsetOp);
1033 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
1034 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
1035 /* u6_0Imm */ offset{5-0}));
1037 let IClass = 0b0011;
1039 let Inst{27-25} = 0b110;
1040 let Inst{22-21} = MajOp;
1041 let Inst{20-16} = Rs;
1042 let Inst{12-7} = offsetBits;
1043 let Inst{13} = S8{7};
1044 let Inst{6-0} = S8{6-0};
1047 let isPredicated = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 6,
1049 class T_StoreImm_pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
1050 bit isPredNot, bit isPredNew >
1052 (ins PredRegs:$Pv, IntRegs:$Rs, OffsetOp:$offset, s6Ext:$S6),
1053 !if(isPredNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
1054 ") ")#mnemonic#"($Rs+#$offset)=#$S6",
1055 [], "", V4LDST_tc_st_SLOT01>,
1056 ImmRegRel, PredNewRel {
1063 string OffsetOpStr = !cast<string>(OffsetOp);
1064 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
1065 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
1066 /* u6_0Imm */ offset{5-0}));
1067 let isPredicatedNew = isPredNew;
1068 let isPredicatedFalse = isPredNot;
1070 let IClass = 0b0011;
1072 let Inst{27-25} = 0b100;
1073 let Inst{24} = isPredNew;
1074 let Inst{23} = isPredNot;
1075 let Inst{22-21} = MajOp;
1076 let Inst{20-16} = Rs;
1077 let Inst{13} = S6{5};
1078 let Inst{12-7} = offsetBits;
1080 let Inst{4-0} = S6{4-0};
1084 //===----------------------------------------------------------------------===//
1085 // multiclass for store instructions with base + immediate offset
1086 // addressing mode and immediate stored value.
1087 // mem[bhw](Rx++#s4:3)=#s8
1088 // if ([!]Pv[.new]) mem[bhw](Rx++#s4:3)=#s6
1089 //===----------------------------------------------------------------------===//
1091 multiclass ST_Imm_Pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
1093 def _io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 0>;
1095 def new_io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 1>;
1098 multiclass ST_Imm <string mnemonic, string CextOp, Operand OffsetOp,
1100 let CextOpcode = CextOp, BaseOpcode = CextOp#_imm in {
1101 def _io : T_StoreImm <mnemonic, OffsetOp, MajOp>;
1103 defm t : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 0>;
1104 defm f : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 1>;
1108 let hasSideEffects = 0, validSubTargets = HasV4SubT, addrMode = BaseImmOffset,
1109 InputType = "imm" in {
1110 let accessSize = ByteAccess in
1111 defm S4_storeirb : ST_Imm<"memb", "STrib", u6_0Imm, 0b00>;
1113 let accessSize = HalfWordAccess in
1114 defm S4_storeirh : ST_Imm<"memh", "STrih", u6_1Imm, 0b01>;
1116 let accessSize = WordAccess in
1117 defm S4_storeiri : ST_Imm<"memw", "STriw", u6_2Imm, 0b10>;
1120 let Predicates = [HasV4T], AddedComplexity = 10 in {
1121 def: Pat<(truncstorei8 s8ExtPred:$src3, (add IntRegs:$src1, u6_0ImmPred:$src2)),
1122 (S4_storeirb_io IntRegs:$src1, u6_0ImmPred:$src2, s8ExtPred:$src3)>;
1124 def: Pat<(truncstorei16 s8ExtPred:$src3, (add IntRegs:$src1,
1125 u6_1ImmPred:$src2)),
1126 (S4_storeirh_io IntRegs:$src1, u6_1ImmPred:$src2, s8ExtPred:$src3)>;
1128 def: Pat<(store s8ExtPred:$src3, (add IntRegs:$src1, u6_2ImmPred:$src2)),
1129 (S4_storeiri_io IntRegs:$src1, u6_2ImmPred:$src2, s8ExtPred:$src3)>;
1132 let AddedComplexity = 6 in
1133 def : Pat <(truncstorei8 s8ExtPred:$src2, (i32 IntRegs:$src1)),
1134 (S4_storeirb_io IntRegs:$src1, 0, s8ExtPred:$src2)>,
1137 // memb(Rx++#s4:0:circ(Mu))=Rt
1138 // memb(Rx++I:circ(Mu))=Rt
1140 // memb(Rx++Mu:brev)=Rt
1141 // memb(gp+#u16:0)=Rt
1145 // TODO: needs to be implemented
1146 // memh(Re=#U6)=Rt.H
1147 // memh(Rs+#s11:1)=Rt.H
1148 let AddedComplexity = 6 in
1149 def : Pat <(truncstorei16 s8ExtPred:$src2, (i32 IntRegs:$src1)),
1150 (S4_storeirh_io IntRegs:$src1, 0, s8ExtPred:$src2)>,
1153 // memh(Rs+Ru<<#u2)=Rt.H
1154 // TODO: needs to be implemented.
1156 // memh(Ru<<#u2+#U6)=Rt.H
1157 // memh(Rx++#s4:1:circ(Mu))=Rt.H
1158 // memh(Rx++#s4:1:circ(Mu))=Rt
1159 // memh(Rx++I:circ(Mu))=Rt.H
1160 // memh(Rx++I:circ(Mu))=Rt
1161 // memh(Rx++Mu)=Rt.H
1163 // memh(Rx++Mu:brev)=Rt.H
1164 // memh(Rx++Mu:brev)=Rt
1165 // memh(gp+#u16:1)=Rt
1166 // if ([!]Pv[.new]) memh(#u6)=Rt.H
1167 // if ([!]Pv[.new]) memh(#u6)=Rt
1170 // if ([!]Pv[.new]) memh(Rs+#u6:1)=Rt.H
1171 // TODO: needs to be implemented.
1173 // if ([!]Pv[.new]) memh(Rx++#s4:1)=Rt.H
1174 // TODO: Needs to be implemented.
1178 // TODO: Needs to be implemented.
1180 let AddedComplexity = 6 in
1181 def : Pat <(store s8ExtPred:$src2, (i32 IntRegs:$src1)),
1182 (S4_storeiri_io IntRegs:$src1, 0, s8ExtPred:$src2)>,
1185 // memw(Rx++#s4:2)=Rt
1186 // memw(Rx++#s4:2:circ(Mu))=Rt
1187 // memw(Rx++I:circ(Mu))=Rt
1189 // memw(Rx++Mu:brev)=Rt
1191 //===----------------------------------------------------------------------===
1193 //===----------------------------------------------------------------------===
1196 //===----------------------------------------------------------------------===//
1198 //===----------------------------------------------------------------------===//
1200 let opNewValue = 2, opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
1201 class T_store_io_nv <string mnemonic, RegisterClass RC,
1202 Operand ImmOp, bits<2>MajOp>
1203 : NVInst_V4 <(outs),
1204 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
1205 mnemonic#"($src1+#$src2) = $src3.new",
1206 [],"",ST_tc_st_SLOT0> {
1208 bits<13> src2; // Actual address offset
1210 bits<11> offsetBits; // Represents offset encoding
1212 let opExtentBits = !if (!eq(mnemonic, "memb"), 11,
1213 !if (!eq(mnemonic, "memh"), 12,
1214 !if (!eq(mnemonic, "memw"), 13, 0)));
1216 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1217 !if (!eq(mnemonic, "memh"), 1,
1218 !if (!eq(mnemonic, "memw"), 2, 0)));
1220 let offsetBits = !if (!eq(mnemonic, "memb"), src2{10-0},
1221 !if (!eq(mnemonic, "memh"), src2{11-1},
1222 !if (!eq(mnemonic, "memw"), src2{12-2}, 0)));
1224 let IClass = 0b1010;
1227 let Inst{26-25} = offsetBits{10-9};
1228 let Inst{24-21} = 0b1101;
1229 let Inst{20-16} = src1;
1230 let Inst{13} = offsetBits{8};
1231 let Inst{12-11} = MajOp;
1232 let Inst{10-8} = src3;
1233 let Inst{7-0} = offsetBits{7-0};
1236 let opExtendable = 2, opNewValue = 3, isPredicated = 1 in
1237 class T_pstore_io_nv <string mnemonic, RegisterClass RC, Operand predImmOp,
1238 bits<2>MajOp, bit PredNot, bit isPredNew>
1239 : NVInst_V4 <(outs),
1240 (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC:$src4),
1241 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1242 ") ")#mnemonic#"($src2+#$src3) = $src4.new",
1243 [],"",V2LDST_tc_st_SLOT0> {
1248 bits<6> offsetBits; // Represents offset encoding
1250 let isPredicatedNew = isPredNew;
1251 let isPredicatedFalse = PredNot;
1252 let opExtentBits = !if (!eq(mnemonic, "memb"), 6,
1253 !if (!eq(mnemonic, "memh"), 7,
1254 !if (!eq(mnemonic, "memw"), 8, 0)));
1256 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1257 !if (!eq(mnemonic, "memh"), 1,
1258 !if (!eq(mnemonic, "memw"), 2, 0)));
1260 let offsetBits = !if (!eq(mnemonic, "memb"), src3{5-0},
1261 !if (!eq(mnemonic, "memh"), src3{6-1},
1262 !if (!eq(mnemonic, "memw"), src3{7-2}, 0)));
1264 let IClass = 0b0100;
1267 let Inst{26} = PredNot;
1268 let Inst{25} = isPredNew;
1269 let Inst{24-21} = 0b0101;
1270 let Inst{20-16} = src2;
1271 let Inst{13} = offsetBits{5};
1272 let Inst{12-11} = MajOp;
1273 let Inst{10-8} = src4;
1274 let Inst{7-3} = offsetBits{4-0};
1276 let Inst{1-0} = src1;
1279 // multiclass for new-value store instructions with base + immediate offset.
1281 let mayStore = 1, isNVStore = 1, isNewValue = 1, hasSideEffects = 0,
1283 multiclass ST_Idxd_nv<string mnemonic, string CextOp, RegisterClass RC,
1284 Operand ImmOp, Operand predImmOp, bits<2> MajOp> {
1286 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1287 def S2_#NAME#new_io : T_store_io_nv <mnemonic, RC, ImmOp, MajOp>;
1289 def S2_p#NAME#newt_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 0, 0>;
1290 def S2_p#NAME#newf_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 1, 0>;
1292 def S4_p#NAME#newtnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1294 def S4_p#NAME#newfnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1299 let addrMode = BaseImmOffset, InputType = "imm" in {
1300 let accessSize = ByteAccess in
1301 defm storerb: ST_Idxd_nv<"memb", "STrib", IntRegs, s11_0Ext,
1302 u6_0Ext, 0b00>, AddrModeRel;
1304 let accessSize = HalfWordAccess, opExtentAlign = 1 in
1305 defm storerh: ST_Idxd_nv<"memh", "STrih", IntRegs, s11_1Ext,
1306 u6_1Ext, 0b01>, AddrModeRel;
1308 let accessSize = WordAccess, opExtentAlign = 2 in
1309 defm storeri: ST_Idxd_nv<"memw", "STriw", IntRegs, s11_2Ext,
1310 u6_2Ext, 0b10>, AddrModeRel;
1313 //===----------------------------------------------------------------------===//
1314 // Post increment loads with register offset.
1315 //===----------------------------------------------------------------------===//
1317 let hasNewValue = 1 in
1318 def L2_loadbsw2_pr : T_load_pr <"membh", IntRegs, 0b0001, HalfWordAccess>;
1320 def L2_loadbsw4_pr : T_load_pr <"membh", DoubleRegs, 0b0111, WordAccess>;
1322 //===----------------------------------------------------------------------===//
1323 // Template class for non-predicated post increment .new stores
1324 // mem[bhwd](Rx++#s4:[0123])=Nt.new
1325 //===----------------------------------------------------------------------===//
1326 let isPredicable = 1, hasSideEffects = 0, validSubTargets = HasV4SubT,
1327 addrMode = PostInc, isNVStore = 1, isNewValue = 1, opNewValue = 3 in
1328 class T_StorePI_nv <string mnemonic, Operand ImmOp, bits<2> MajOp >
1329 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1330 (ins IntRegs:$src1, ImmOp:$offset, IntRegs:$src2),
1331 mnemonic#"($src1++#$offset) = $src2.new",
1332 [], "$src1 = $_dst_">,
1339 string ImmOpStr = !cast<string>(ImmOp);
1340 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1341 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1342 /* s4_0Imm */ offset{3-0}));
1343 let IClass = 0b1010;
1345 let Inst{27-21} = 0b1011101;
1346 let Inst{20-16} = src1;
1348 let Inst{12-11} = MajOp;
1349 let Inst{10-8} = src2;
1351 let Inst{6-3} = offsetBits;
1355 //===----------------------------------------------------------------------===//
1356 // Template class for predicated post increment .new stores
1357 // if([!]Pv[.new]) mem[bhwd](Rx++#s4:[0123])=Nt.new
1358 //===----------------------------------------------------------------------===//
1359 let isPredicated = 1, hasSideEffects = 0, validSubTargets = HasV4SubT,
1360 addrMode = PostInc, isNVStore = 1, isNewValue = 1, opNewValue = 4 in
1361 class T_StorePI_nv_pred <string mnemonic, Operand ImmOp,
1362 bits<2> MajOp, bit isPredNot, bit isPredNew >
1363 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1364 (ins PredRegs:$src1, IntRegs:$src2,
1365 ImmOp:$offset, IntRegs:$src3),
1366 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1367 ") ")#mnemonic#"($src2++#$offset) = $src3.new",
1368 [], "$src2 = $_dst_">,
1376 string ImmOpStr = !cast<string>(ImmOp);
1377 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1378 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1379 /* s4_0Imm */ offset{3-0}));
1380 let isPredicatedNew = isPredNew;
1381 let isPredicatedFalse = isPredNot;
1383 let IClass = 0b1010;
1385 let Inst{27-21} = 0b1011101;
1386 let Inst{20-16} = src2;
1388 let Inst{12-11} = MajOp;
1389 let Inst{10-8} = src3;
1390 let Inst{7} = isPredNew;
1391 let Inst{6-3} = offsetBits;
1392 let Inst{2} = isPredNot;
1393 let Inst{1-0} = src1;
1396 multiclass ST_PostInc_Pred_nv<string mnemonic, Operand ImmOp,
1397 bits<2> MajOp, bit PredNot> {
1398 def _pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 0>;
1401 def new_pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 1>;
1404 multiclass ST_PostInc_nv<string mnemonic, string BaseOp, Operand ImmOp,
1406 let BaseOpcode = "POST_"#BaseOp in {
1407 def S2_#NAME#_pi : T_StorePI_nv <mnemonic, ImmOp, MajOp>;
1410 defm S2_p#NAME#t : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 0>;
1411 defm S2_p#NAME#f : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 1>;
1415 let accessSize = ByteAccess in
1416 defm storerbnew: ST_PostInc_nv <"memb", "STrib", s4_0Imm, 0b00>;
1418 let accessSize = HalfWordAccess in
1419 defm storerhnew: ST_PostInc_nv <"memh", "STrih", s4_1Imm, 0b01>;
1421 let accessSize = WordAccess in
1422 defm storerinew: ST_PostInc_nv <"memw", "STriw", s4_2Imm, 0b10>;
1424 //===----------------------------------------------------------------------===//
1425 // Template class for post increment .new stores with register offset
1426 //===----------------------------------------------------------------------===//
1427 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
1428 class T_StorePI_RegNV <string mnemonic, bits<2> MajOp, MemAccessSize AccessSz>
1429 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1430 (ins IntRegs:$src1, ModRegs:$src2, IntRegs:$src3),
1431 #mnemonic#"($src1++$src2) = $src3.new",
1432 [], "$src1 = $_dst_"> {
1436 let accessSize = AccessSz;
1438 let IClass = 0b1010;
1440 let Inst{27-21} = 0b1101101;
1441 let Inst{20-16} = src1;
1442 let Inst{13} = src2;
1443 let Inst{12-11} = MajOp;
1444 let Inst{10-8} = src3;
1448 def S2_storerbnew_pr : T_StorePI_RegNV<"memb", 0b00, ByteAccess>;
1449 def S2_storerhnew_pr : T_StorePI_RegNV<"memh", 0b01, HalfWordAccess>;
1450 def S2_storerinew_pr : T_StorePI_RegNV<"memw", 0b10, WordAccess>;
1452 // memb(Rx++#s4:0:circ(Mu))=Nt.new
1453 // memb(Rx++I:circ(Mu))=Nt.new
1454 // memb(Rx++Mu)=Nt.new
1455 // memb(Rx++Mu:brev)=Nt.new
1456 // memh(Rx++#s4:1:circ(Mu))=Nt.new
1457 // memh(Rx++I:circ(Mu))=Nt.new
1458 // memh(Rx++Mu)=Nt.new
1459 // memh(Rx++Mu:brev)=Nt.new
1461 // memw(Rx++#s4:2:circ(Mu))=Nt.new
1462 // memw(Rx++I:circ(Mu))=Nt.new
1463 // memw(Rx++Mu)=Nt.new
1464 // memw(Rx++Mu:brev)=Nt.new
1466 //===----------------------------------------------------------------------===//
1468 //===----------------------------------------------------------------------===//
1470 //===----------------------------------------------------------------------===//
1472 //===----------------------------------------------------------------------===//
1474 //===----------------------------------------------------------------------===//
1475 // multiclass/template class for the new-value compare jumps with the register
1477 //===----------------------------------------------------------------------===//
1479 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1480 opExtentAlign = 2 in
1481 class NVJrr_template<string mnemonic, bits<3> majOp, bit NvOpNum,
1482 bit isNegCond, bit isTak>
1484 (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset),
1485 "if ("#!if(isNegCond, "!","")#mnemonic#
1486 "($src1"#!if(!eq(NvOpNum, 0),".new, ",", ")#
1487 "$src2"#!if(!eq(NvOpNum, 1),".new))","))")#" jump:"
1488 #!if(isTak, "t","nt")#" $offset", []> {
1492 bits<3> Ns; // New-Value Operand
1493 bits<5> RegOp; // Non-New-Value Operand
1496 let isTaken = isTak;
1497 let isPredicatedFalse = isNegCond;
1498 let opNewValue{0} = NvOpNum;
1500 let Ns = !if(!eq(NvOpNum, 0), src1{2-0}, src2{2-0});
1501 let RegOp = !if(!eq(NvOpNum, 0), src2, src1);
1503 let IClass = 0b0010;
1504 let Inst{27-26} = 0b00;
1505 let Inst{25-23} = majOp;
1506 let Inst{22} = isNegCond;
1507 let Inst{18-16} = Ns;
1508 let Inst{13} = isTak;
1509 let Inst{12-8} = RegOp;
1510 let Inst{21-20} = offset{10-9};
1511 let Inst{7-1} = offset{8-2};
1515 multiclass NVJrr_cond<string mnemonic, bits<3> majOp, bit NvOpNum,
1517 // Branch not taken:
1518 def _nt: NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 0>;
1520 def _t : NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 1>;
1523 // NvOpNum = 0 -> First Operand is a new-value Register
1524 // NvOpNum = 1 -> Second Operand is a new-value Register
1526 multiclass NVJrr_base<string mnemonic, string BaseOp, bits<3> majOp,
1528 let BaseOpcode = BaseOp#_NVJ in {
1529 defm _t_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 0>; // True cond
1530 defm _f_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 1>; // False cond
1534 // if ([!]cmp.eq(Ns.new,Rt)) jump:[n]t #r9:2
1535 // if ([!]cmp.gt(Ns.new,Rt)) jump:[n]t #r9:2
1536 // if ([!]cmp.gtu(Ns.new,Rt)) jump:[n]t #r9:2
1537 // if ([!]cmp.gt(Rt,Ns.new)) jump:[n]t #r9:2
1538 // if ([!]cmp.gtu(Rt,Ns.new)) jump:[n]t #r9:2
1540 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1541 Defs = [PC], hasSideEffects = 0, validSubTargets = HasV4SubT in {
1542 defm J4_cmpeq : NVJrr_base<"cmp.eq", "CMPEQ", 0b000, 0>, PredRel;
1543 defm J4_cmpgt : NVJrr_base<"cmp.gt", "CMPGT", 0b001, 0>, PredRel;
1544 defm J4_cmpgtu : NVJrr_base<"cmp.gtu", "CMPGTU", 0b010, 0>, PredRel;
1545 defm J4_cmplt : NVJrr_base<"cmp.gt", "CMPLT", 0b011, 1>, PredRel;
1546 defm J4_cmpltu : NVJrr_base<"cmp.gtu", "CMPLTU", 0b100, 1>, PredRel;
1549 //===----------------------------------------------------------------------===//
1550 // multiclass/template class for the new-value compare jumps instruction
1551 // with a register and an unsigned immediate (U5) operand.
1552 //===----------------------------------------------------------------------===//
1554 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1555 opExtentAlign = 2 in
1556 class NVJri_template<string mnemonic, bits<3> majOp, bit isNegCond,
1559 (ins IntRegs:$src1, u5Imm:$src2, brtarget:$offset),
1560 "if ("#!if(isNegCond, "!","")#mnemonic#"($src1.new, #$src2)) jump:"
1561 #!if(isTak, "t","nt")#" $offset", []> {
1563 let isTaken = isTak;
1564 let isPredicatedFalse = isNegCond;
1565 let isTaken = isTak;
1571 let IClass = 0b0010;
1573 let Inst{25-23} = majOp;
1574 let Inst{22} = isNegCond;
1575 let Inst{18-16} = src1;
1576 let Inst{13} = isTak;
1577 let Inst{12-8} = src2;
1578 let Inst{21-20} = offset{10-9};
1579 let Inst{7-1} = offset{8-2};
1582 multiclass NVJri_cond<string mnemonic, bits<3> majOp, bit isNegCond> {
1583 // Branch not taken:
1584 def _nt: NVJri_template<mnemonic, majOp, isNegCond, 0>;
1586 def _t : NVJri_template<mnemonic, majOp, isNegCond, 1>;
1589 multiclass NVJri_base<string mnemonic, string BaseOp, bits<3> majOp> {
1590 let BaseOpcode = BaseOp#_NVJri in {
1591 defm _t_jumpnv : NVJri_cond<mnemonic, majOp, 0>; // True Cond
1592 defm _f_jumpnv : NVJri_cond<mnemonic, majOp, 1>; // False cond
1596 // if ([!]cmp.eq(Ns.new,#U5)) jump:[n]t #r9:2
1597 // if ([!]cmp.gt(Ns.new,#U5)) jump:[n]t #r9:2
1598 // if ([!]cmp.gtu(Ns.new,#U5)) jump:[n]t #r9:2
1600 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1601 Defs = [PC], hasSideEffects = 0, validSubTargets = HasV4SubT in {
1602 defm J4_cmpeqi : NVJri_base<"cmp.eq", "CMPEQ", 0b000>, PredRel;
1603 defm J4_cmpgti : NVJri_base<"cmp.gt", "CMPGT", 0b001>, PredRel;
1604 defm J4_cmpgtui : NVJri_base<"cmp.gtu", "CMPGTU", 0b010>, PredRel;
1607 //===----------------------------------------------------------------------===//
1608 // multiclass/template class for the new-value compare jumps instruction
1609 // with a register and an hardcoded 0/-1 immediate value.
1610 //===----------------------------------------------------------------------===//
1612 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 11,
1613 opExtentAlign = 2 in
1614 class NVJ_ConstImm_template<string mnemonic, bits<3> majOp, string ImmVal,
1615 bit isNegCond, bit isTak>
1617 (ins IntRegs:$src1, brtarget:$offset),
1618 "if ("#!if(isNegCond, "!","")#mnemonic
1619 #"($src1.new, #"#ImmVal#")) jump:"
1620 #!if(isTak, "t","nt")#" $offset", []> {
1622 let isTaken = isTak;
1623 let isPredicatedFalse = isNegCond;
1624 let isTaken = isTak;
1628 let IClass = 0b0010;
1630 let Inst{25-23} = majOp;
1631 let Inst{22} = isNegCond;
1632 let Inst{18-16} = src1;
1633 let Inst{13} = isTak;
1634 let Inst{21-20} = offset{10-9};
1635 let Inst{7-1} = offset{8-2};
1638 multiclass NVJ_ConstImm_cond<string mnemonic, bits<3> majOp, string ImmVal,
1640 // Branch not taken:
1641 def _nt: NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 0>;
1643 def _t : NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 1>;
1646 multiclass NVJ_ConstImm_base<string mnemonic, string BaseOp, bits<3> majOp,
1648 let BaseOpcode = BaseOp#_NVJ_ConstImm in {
1649 defm _t_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 0>; // True
1650 defm _f_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 1>; // False
1654 // if ([!]tstbit(Ns.new,#0)) jump:[n]t #r9:2
1655 // if ([!]cmp.eq(Ns.new,#-1)) jump:[n]t #r9:2
1656 // if ([!]cmp.gt(Ns.new,#-1)) jump:[n]t #r9:2
1658 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1,
1659 Defs = [PC], hasSideEffects = 0 in {
1660 defm J4_tstbit0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel;
1661 defm J4_cmpeqn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "-1">, PredRel;
1662 defm J4_cmpgtn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "-1">, PredRel;
1665 // J4_hintjumpr: Hint indirect conditional jump.
1666 let isBranch = 1, isIndirectBranch = 1, hasSideEffects = 0 in
1667 def J4_hintjumpr: JRInst <
1672 let IClass = 0b0101;
1673 let Inst{27-21} = 0b0010101;
1674 let Inst{20-16} = Rs;
1677 //===----------------------------------------------------------------------===//
1679 //===----------------------------------------------------------------------===//
1681 //===----------------------------------------------------------------------===//
1683 //===----------------------------------------------------------------------===//
1686 let hasNewValue = 1, isExtendable = 1, opExtendable = 1,
1687 isExtentSigned = 0, opExtentBits = 6, hasSideEffects = 0,
1688 Uses = [PC], validSubTargets = HasV4SubT in
1689 def C4_addipc : CRInst <(outs IntRegs:$Rd), (ins u6Ext:$u6),
1690 "$Rd = add(pc, #$u6)", [], "", CR_tc_2_SLOT3 > {
1694 let IClass = 0b0110;
1695 let Inst{27-16} = 0b101001001001;
1696 let Inst{12-7} = u6;
1702 let hasSideEffects = 0 in
1703 class T_LOGICAL_3OP<string MnOp1, string MnOp2, bits<2> OpBits, bit IsNeg>
1704 : CRInst<(outs PredRegs:$Pd),
1705 (ins PredRegs:$Ps, PredRegs:$Pt, PredRegs:$Pu),
1706 "$Pd = " # MnOp1 # "($Ps, " # MnOp2 # "($Pt, " #
1707 !if (IsNeg,"!","") # "$Pu))",
1708 [], "", CR_tc_2early_SLOT23> {
1714 let IClass = 0b0110;
1715 let Inst{27-24} = 0b1011;
1716 let Inst{23} = IsNeg;
1717 let Inst{22-21} = OpBits;
1719 let Inst{17-16} = Ps;
1726 def C4_and_and : T_LOGICAL_3OP<"and", "and", 0b00, 0>;
1727 def C4_and_or : T_LOGICAL_3OP<"and", "or", 0b01, 0>;
1728 def C4_or_and : T_LOGICAL_3OP<"or", "and", 0b10, 0>;
1729 def C4_or_or : T_LOGICAL_3OP<"or", "or", 0b11, 0>;
1730 def C4_and_andn : T_LOGICAL_3OP<"and", "and", 0b00, 1>;
1731 def C4_and_orn : T_LOGICAL_3OP<"and", "or", 0b01, 1>;
1732 def C4_or_andn : T_LOGICAL_3OP<"or", "and", 0b10, 1>;
1733 def C4_or_orn : T_LOGICAL_3OP<"or", "or", 0b11, 1>;
1735 //===----------------------------------------------------------------------===//
1737 //===----------------------------------------------------------------------===//
1739 //===----------------------------------------------------------------------===//
1741 //===----------------------------------------------------------------------===//
1743 // Logical with-not instructions.
1744 let validSubTargets = HasV4SubT in {
1745 def A4_andnp : T_ALU64_logical<"and", 0b001, 1, 0, 1>;
1746 def A4_ornp : T_ALU64_logical<"or", 0b011, 1, 0, 1>;
1749 let hasNewValue = 1, hasSideEffects = 0 in
1750 def S4_parity: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1751 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1756 let IClass = 0b1101;
1757 let Inst{27-21} = 0b0101111;
1758 let Inst{20-16} = Rs;
1759 let Inst{12-8} = Rt;
1763 // Add and accumulate.
1764 // Rd=add(Rs,add(Ru,#s6))
1765 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 6,
1767 def S4_addaddi : ALU64Inst <(outs IntRegs:$Rd),
1768 (ins IntRegs:$Rs, IntRegs:$Ru, s6Ext:$s6),
1769 "$Rd = add($Rs, add($Ru, #$s6))" ,
1770 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs),
1771 (add (i32 IntRegs:$Ru), s6_16ExtPred:$s6)))],
1772 "", ALU64_tc_2_SLOT23> {
1778 let IClass = 0b1101;
1780 let Inst{27-23} = 0b10110;
1781 let Inst{22-21} = s6{5-4};
1782 let Inst{20-16} = Rs;
1783 let Inst{13} = s6{3};
1784 let Inst{12-8} = Rd;
1785 let Inst{7-5} = s6{2-0};
1789 let isExtentSigned = 1, hasSideEffects = 0, hasNewValue = 1, isExtendable = 1,
1790 opExtentBits = 6, opExtendable = 2 in
1791 def S4_subaddi: ALU64Inst <(outs IntRegs:$Rd),
1792 (ins IntRegs:$Rs, s6Ext:$s6, IntRegs:$Ru),
1793 "$Rd = add($Rs, sub(#$s6, $Ru))",
1794 [], "", ALU64_tc_2_SLOT23> {
1800 let IClass = 0b1101;
1802 let Inst{27-23} = 0b10111;
1803 let Inst{22-21} = s6{5-4};
1804 let Inst{20-16} = Rs;
1805 let Inst{13} = s6{3};
1806 let Inst{12-8} = Rd;
1807 let Inst{7-5} = s6{2-0};
1812 // Rdd=extract(Rss,#u6,#U6)
1813 // Rdd=extract(Rss,Rtt)
1814 // Rd=extract(Rs,Rtt)
1815 // Rd=extract(Rs,#u5,#U5)
1817 def S4_extractp_rp : T_S3op_64 < "extract", 0b11, 0b100, 0>;
1818 def S4_extractp : T_S2op_extract <"extract", 0b1010, DoubleRegs, u6Imm>;
1820 let hasNewValue = 1 in {
1821 def S4_extract_rp : T_S3op_extract<"extract", 0b01>;
1822 def S4_extract : T_S2op_extract <"extract", 0b1101, IntRegs, u5Imm>;
1825 // Complex add/sub halfwords/words
1826 let Defs = [USR_OVF] in {
1827 def S4_vxaddsubh : T_S3op_64 < "vxaddsubh", 0b01, 0b100, 0, 1>;
1828 def S4_vxaddsubw : T_S3op_64 < "vxaddsubw", 0b01, 0b000, 0, 1>;
1829 def S4_vxsubaddh : T_S3op_64 < "vxsubaddh", 0b01, 0b110, 0, 1>;
1830 def S4_vxsubaddw : T_S3op_64 < "vxsubaddw", 0b01, 0b010, 0, 1>;
1833 let Defs = [USR_OVF] in {
1834 def S4_vxaddsubhr : T_S3op_64 < "vxaddsubh", 0b11, 0b000, 0, 1, 1, 1>;
1835 def S4_vxsubaddhr : T_S3op_64 < "vxsubaddh", 0b11, 0b010, 0, 1, 1, 1>;
1838 let Itinerary = M_tc_3x_SLOT23, Defs = [USR_OVF] in {
1839 def M4_mac_up_s1_sat: T_MType_acc_rr<"+= mpy", 0b011, 0b000, 0, [], 0, 1, 1>;
1840 def M4_nac_up_s1_sat: T_MType_acc_rr<"-= mpy", 0b011, 0b001, 0, [], 0, 1, 1>;
1843 // Logical xor with xor accumulation.
1844 // Rxx^=xor(Rss,Rtt)
1845 let hasSideEffects = 0 in
1847 : SInst <(outs DoubleRegs:$Rxx),
1848 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
1849 "$Rxx ^= xor($Rss, $Rtt)",
1850 [(set (i64 DoubleRegs:$Rxx),
1851 (xor (i64 DoubleRegs:$dst2), (xor (i64 DoubleRegs:$Rss),
1852 (i64 DoubleRegs:$Rtt))))],
1853 "$dst2 = $Rxx", S_3op_tc_1_SLOT23> {
1858 let IClass = 0b1100;
1860 let Inst{27-22} = 0b101010;
1861 let Inst{20-16} = Rss;
1862 let Inst{12-8} = Rtt;
1863 let Inst{7-5} = 0b000;
1864 let Inst{4-0} = Rxx;
1867 // Rotate and reduce bytes
1868 // Rdd=vrcrotate(Rss,Rt,#u2)
1869 let hasSideEffects = 0 in
1871 : SInst <(outs DoubleRegs:$Rdd),
1872 (ins DoubleRegs:$Rss, IntRegs:$Rt, u2Imm:$u2),
1873 "$Rdd = vrcrotate($Rss, $Rt, #$u2)",
1874 [], "", S_3op_tc_3x_SLOT23> {
1880 let IClass = 0b1100;
1882 let Inst{27-22} = 0b001111;
1883 let Inst{20-16} = Rss;
1884 let Inst{13} = u2{1};
1885 let Inst{12-8} = Rt;
1886 let Inst{7-6} = 0b11;
1887 let Inst{5} = u2{0};
1888 let Inst{4-0} = Rdd;
1891 // Rotate and reduce bytes with accumulation
1892 // Rxx+=vrcrotate(Rss,Rt,#u2)
1893 let hasSideEffects = 0 in
1894 def S4_vrcrotate_acc
1895 : SInst <(outs DoubleRegs:$Rxx),
1896 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt, u2Imm:$u2),
1897 "$Rxx += vrcrotate($Rss, $Rt, #$u2)", [],
1898 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
1904 let IClass = 0b1100;
1906 let Inst{27-21} = 0b1011101;
1907 let Inst{20-16} = Rss;
1908 let Inst{13} = u2{1};
1909 let Inst{12-8} = Rt;
1910 let Inst{5} = u2{0};
1911 let Inst{4-0} = Rxx;
1914 // Vector reduce conditional negate halfwords
1915 let hasSideEffects = 0 in
1917 : SInst <(outs DoubleRegs:$Rxx),
1918 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt),
1919 "$Rxx += vrcnegh($Rss, $Rt)", [],
1920 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
1925 let IClass = 0b1100;
1927 let Inst{27-21} = 0b1011001;
1928 let Inst{20-16} = Rss;
1930 let Inst{12-8} = Rt;
1931 let Inst{7-5} = 0b111;
1932 let Inst{4-0} = Rxx;
1936 def A4_bitspliti : T_S2op_2_di <"bitsplit", 0b110, 0b100>;
1938 // Arithmetic/Convergent round
1939 def A4_cround_ri : T_S2op_2_ii <"cround", 0b111, 0b000>;
1941 def A4_round_ri : T_S2op_2_ii <"round", 0b111, 0b100>;
1943 let Defs = [USR_OVF] in
1944 def A4_round_ri_sat : T_S2op_2_ii <"round", 0b111, 0b110, 1>;
1946 // Logical-logical words.
1947 // Compound or-and -- Rx=or(Ru,and(Rx,#s10))
1948 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 10,
1951 ALU64Inst<(outs IntRegs:$Rx),
1952 (ins IntRegs:$Ru, IntRegs:$_src_, s10Ext:$s10),
1953 "$Rx = or($Ru, and($_src_, #$s10))" ,
1954 [(set (i32 IntRegs:$Rx),
1955 (or (i32 IntRegs:$Ru), (and (i32 IntRegs:$_src_), s10ExtPred:$s10)))] ,
1956 "$_src_ = $Rx", ALU64_tc_2_SLOT23> {
1961 let IClass = 0b1101;
1963 let Inst{27-22} = 0b101001;
1964 let Inst{20-16} = Rx;
1965 let Inst{21} = s10{9};
1966 let Inst{13-5} = s10{8-0};
1970 // Miscellaneous ALU64 instructions.
1972 let hasNewValue = 1, hasSideEffects = 0 in
1973 def A4_modwrapu: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1974 "$Rd = modwrap($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1979 let IClass = 0b1101;
1980 let Inst{27-21} = 0b0011111;
1981 let Inst{20-16} = Rs;
1982 let Inst{12-8} = Rt;
1983 let Inst{7-5} = 0b111;
1987 let hasSideEffects = 0 in
1988 def A4_bitsplit: ALU64Inst<(outs DoubleRegs:$Rd),
1989 (ins IntRegs:$Rs, IntRegs:$Rt),
1990 "$Rd = bitsplit($Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
1995 let IClass = 0b1101;
1996 let Inst{27-24} = 0b0100;
1998 let Inst{20-16} = Rs;
1999 let Inst{12-8} = Rt;
2003 // Rx[&|]=xor(Rs,Rt)
2004 def M4_or_xor : T_MType_acc_rr < "|= xor", 0b110, 0b001, 0>;
2005 def M4_and_xor : T_MType_acc_rr < "&= xor", 0b010, 0b010, 0>;
2007 // Rx[&|^]=or(Rs,Rt)
2008 def M4_xor_or : T_MType_acc_rr < "^= or", 0b110, 0b011, 0>;
2010 let CextOpcode = "ORr_ORr" in
2011 def M4_or_or : T_MType_acc_rr < "|= or", 0b110, 0b000, 0>;
2012 def M4_and_or : T_MType_acc_rr < "&= or", 0b010, 0b001, 0>;
2014 // Rx[&|^]=and(Rs,Rt)
2015 def M4_xor_and : T_MType_acc_rr < "^= and", 0b110, 0b010, 0>;
2017 let CextOpcode = "ORr_ANDr" in
2018 def M4_or_and : T_MType_acc_rr < "|= and", 0b010, 0b011, 0>;
2019 def M4_and_and : T_MType_acc_rr < "&= and", 0b010, 0b000, 0>;
2021 // Rx[&|^]=and(Rs,~Rt)
2022 def M4_xor_andn : T_MType_acc_rr < "^= and", 0b001, 0b010, 0, [], 1>;
2023 def M4_or_andn : T_MType_acc_rr < "|= and", 0b001, 0b000, 0, [], 1>;
2024 def M4_and_andn : T_MType_acc_rr < "&= and", 0b001, 0b001, 0, [], 1>;
2026 // Compound or-or and or-and
2027 let isExtentSigned = 1, InputType = "imm", hasNewValue = 1, isExtendable = 1,
2028 opExtentBits = 10, opExtendable = 3 in
2029 class T_CompOR <string mnemonic, bits<2> MajOp, SDNode OpNode>
2030 : MInst_acc <(outs IntRegs:$Rx),
2031 (ins IntRegs:$src1, IntRegs:$Rs, s10Ext:$s10),
2032 "$Rx |= "#mnemonic#"($Rs, #$s10)",
2033 [(set (i32 IntRegs:$Rx), (or (i32 IntRegs:$src1),
2034 (OpNode (i32 IntRegs:$Rs), s10ExtPred:$s10)))],
2035 "$src1 = $Rx", ALU64_tc_2_SLOT23>, ImmRegRel {
2040 let IClass = 0b1101;
2042 let Inst{27-24} = 0b1010;
2043 let Inst{23-22} = MajOp;
2044 let Inst{20-16} = Rs;
2045 let Inst{21} = s10{9};
2046 let Inst{13-5} = s10{8-0};
2050 let CextOpcode = "ORr_ANDr" in
2051 def S4_or_andi : T_CompOR <"and", 0b00, and>;
2053 let CextOpcode = "ORr_ORr" in
2054 def S4_or_ori : T_CompOR <"or", 0b10, or>;
2057 // Rd=modwrap(Rs,Rt)
2059 // Rd=cround(Rs,#u5)
2061 // Rd=round(Rs,#u5)[:sat]
2062 // Rd=round(Rs,Rt)[:sat]
2063 // Vector reduce add unsigned halfwords
2064 // Rd=vraddh(Rss,Rtt)
2066 // Rdd=vaddb(Rss,Rtt)
2067 // Vector conditional negate
2068 // Rdd=vcnegh(Rss,Rt)
2069 // Rxx+=vrcnegh(Rss,Rt)
2070 // Vector maximum bytes
2071 // Rdd=vmaxb(Rtt,Rss)
2072 // Vector reduce maximum halfwords
2073 // Rxx=vrmaxh(Rss,Ru)
2074 // Rxx=vrmaxuh(Rss,Ru)
2075 // Vector reduce maximum words
2076 // Rxx=vrmaxuw(Rss,Ru)
2077 // Rxx=vrmaxw(Rss,Ru)
2078 // Vector minimum bytes
2079 // Rdd=vminb(Rtt,Rss)
2080 // Vector reduce minimum halfwords
2081 // Rxx=vrminh(Rss,Ru)
2082 // Rxx=vrminuh(Rss,Ru)
2083 // Vector reduce minimum words
2084 // Rxx=vrminuw(Rss,Ru)
2085 // Rxx=vrminw(Rss,Ru)
2086 // Vector subtract bytes
2087 // Rdd=vsubb(Rss,Rtt)
2089 //===----------------------------------------------------------------------===//
2091 //===----------------------------------------------------------------------===//
2093 //===----------------------------------------------------------------------===//
2095 //===----------------------------------------------------------------------===//
2098 def S2_brevp : T_S2op_3 <"brev", 0b11, 0b110>;
2101 def S2_ct0p : T_COUNT_LEADING_64<"ct0", 0b111, 0b010>;
2102 def S2_ct1p : T_COUNT_LEADING_64<"ct1", 0b111, 0b100>;
2103 def S4_clbpnorm : T_COUNT_LEADING_64<"normamt", 0b011, 0b000>;
2105 def: Pat<(i32 (trunc (cttz (i64 DoubleRegs:$Rss)))),
2106 (S2_ct0p (i64 DoubleRegs:$Rss))>;
2107 def: Pat<(i32 (trunc (cttz (not (i64 DoubleRegs:$Rss))))),
2108 (S2_ct1p (i64 DoubleRegs:$Rss))>;
2110 let hasSideEffects = 0, hasNewValue = 1 in
2111 def S4_clbaddi : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s6Imm:$s6),
2112 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
2116 let IClass = 0b1000;
2117 let Inst{27-24} = 0b1100;
2118 let Inst{23-21} = 0b001;
2119 let Inst{20-16} = Rs;
2120 let Inst{13-8} = s6;
2121 let Inst{7-5} = 0b000;
2125 let hasSideEffects = 0, hasNewValue = 1 in
2126 def S4_clbpaddi : SInst<(outs IntRegs:$Rd), (ins DoubleRegs:$Rs, s6Imm:$s6),
2127 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
2131 let IClass = 0b1000;
2132 let Inst{27-24} = 0b1000;
2133 let Inst{23-21} = 0b011;
2134 let Inst{20-16} = Rs;
2135 let Inst{13-8} = s6;
2136 let Inst{7-5} = 0b010;
2141 // Bit test/set/clear
2142 def S4_ntstbit_i : T_TEST_BIT_IMM<"!tstbit", 0b001>;
2143 def S4_ntstbit_r : T_TEST_BIT_REG<"!tstbit", 1>;
2145 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
2146 def: Pat<(i1 (seteq (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
2147 (S4_ntstbit_i (i32 IntRegs:$Rs), u5ImmPred:$u5)>;
2148 def: Pat<(i1 (seteq (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
2149 (S4_ntstbit_r (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))>;
2152 // Add extra complexity to prefer these instructions over bitsset/bitsclr.
2153 // The reason is that tstbit/ntstbit can be folded into a compound instruction:
2154 // if ([!]tstbit(...)) jump ...
2155 let AddedComplexity = 100 in
2156 def: Pat<(i1 (setne (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2157 (S2_tstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2159 let AddedComplexity = 100 in
2160 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2161 (S4_ntstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2163 def C4_nbitsset : T_TEST_BITS_REG<"!bitsset", 0b01, 1>;
2164 def C4_nbitsclr : T_TEST_BITS_REG<"!bitsclr", 0b10, 1>;
2165 def C4_nbitsclri : T_TEST_BITS_IMM<"!bitsclr", 0b10, 1>;
2167 // Do not increase complexity of these patterns. In the DAG, "cmp i8" may be
2168 // represented as a compare against "value & 0xFF", which is an exact match
2169 // for cmpb (same for cmph). The patterns below do not contain any additional
2170 // complexity that would make them preferable, and if they were actually used
2171 // instead of cmpb/cmph, they would result in a compare against register that
2172 // is loaded with the byte/half mask (i.e. 0xFF or 0xFFFF).
2173 def: Pat<(i1 (setne (and I32:$Rs, u6ImmPred:$u6), 0)),
2174 (C4_nbitsclri I32:$Rs, u6ImmPred:$u6)>;
2175 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), 0)),
2176 (C4_nbitsclr I32:$Rs, I32:$Rt)>;
2177 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), I32:$Rt)),
2178 (C4_nbitsset I32:$Rs, I32:$Rt)>;
2180 //===----------------------------------------------------------------------===//
2182 //===----------------------------------------------------------------------===//
2184 //===----------------------------------------------------------------------===//
2186 //===----------------------------------------------------------------------===//
2188 // Rd=add(#u6,mpyi(Rs,#U6)) -- Multiply by immed and add immed.
2190 let hasNewValue = 1, isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
2191 def M4_mpyri_addi : MInst<(outs IntRegs:$Rd),
2192 (ins u6Ext:$u6, IntRegs:$Rs, u6Imm:$U6),
2193 "$Rd = add(#$u6, mpyi($Rs, #$U6))" ,
2194 [(set (i32 IntRegs:$Rd),
2195 (add (mul (i32 IntRegs:$Rs), u6ImmPred:$U6),
2196 u6ExtPred:$u6))] ,"",ALU64_tc_3x_SLOT23> {
2202 let IClass = 0b1101;
2204 let Inst{27-24} = 0b1000;
2205 let Inst{23} = U6{5};
2206 let Inst{22-21} = u6{5-4};
2207 let Inst{20-16} = Rs;
2208 let Inst{13} = u6{3};
2209 let Inst{12-8} = Rd;
2210 let Inst{7-5} = u6{2-0};
2211 let Inst{4-0} = U6{4-0};
2214 // Rd=add(#u6,mpyi(Rs,Rt))
2215 let CextOpcode = "ADD_MPY", InputType = "imm", hasNewValue = 1,
2216 isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
2217 def M4_mpyrr_addi : MInst <(outs IntRegs:$Rd),
2218 (ins u6Ext:$u6, IntRegs:$Rs, IntRegs:$Rt),
2219 "$Rd = add(#$u6, mpyi($Rs, $Rt))" ,
2220 [(set (i32 IntRegs:$Rd),
2221 (add (mul (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), u6ExtPred:$u6))],
2222 "", ALU64_tc_3x_SLOT23>, ImmRegRel {
2228 let IClass = 0b1101;
2230 let Inst{27-23} = 0b01110;
2231 let Inst{22-21} = u6{5-4};
2232 let Inst{20-16} = Rs;
2233 let Inst{13} = u6{3};
2234 let Inst{12-8} = Rt;
2235 let Inst{7-5} = u6{2-0};
2239 let hasNewValue = 1 in
2240 class T_AddMpy <bit MajOp, PatLeaf ImmPred, dag ins>
2241 : ALU64Inst <(outs IntRegs:$dst), ins,
2242 "$dst = add($src1, mpyi("#!if(MajOp,"$src3, #$src2))",
2244 [(set (i32 IntRegs:$dst),
2245 (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src3), ImmPred:$src2)))],
2246 "", ALU64_tc_3x_SLOT23> {
2252 let IClass = 0b1101;
2254 bits<6> ImmValue = !if(MajOp, src2{5-0}, src2{7-2});
2256 let Inst{27-24} = 0b1111;
2257 let Inst{23} = MajOp;
2258 let Inst{22-21} = ImmValue{5-4};
2259 let Inst{20-16} = src3;
2260 let Inst{13} = ImmValue{3};
2261 let Inst{12-8} = dst;
2262 let Inst{7-5} = ImmValue{2-0};
2263 let Inst{4-0} = src1;
2266 def M4_mpyri_addr_u2 : T_AddMpy<0b0, u6_2ImmPred,
2267 (ins IntRegs:$src1, u6_2Imm:$src2, IntRegs:$src3)>;
2269 let isExtendable = 1, opExtentBits = 6, opExtendable = 3,
2270 CextOpcode = "ADD_MPY", InputType = "imm" in
2271 def M4_mpyri_addr : T_AddMpy<0b1, u6ExtPred,
2272 (ins IntRegs:$src1, IntRegs:$src3, u6Ext:$src2)>, ImmRegRel;
2274 // Rx=add(Ru,mpyi(Rx,Rs))
2275 let validSubTargets = HasV4SubT, CextOpcode = "ADD_MPY", InputType = "reg",
2277 def M4_mpyrr_addr: MInst_acc <(outs IntRegs:$Rx),
2278 (ins IntRegs:$Ru, IntRegs:$_src_, IntRegs:$Rs),
2279 "$Rx = add($Ru, mpyi($_src_, $Rs))",
2280 [(set (i32 IntRegs:$Rx), (add (i32 IntRegs:$Ru),
2281 (mul (i32 IntRegs:$_src_), (i32 IntRegs:$Rs))))],
2282 "$_src_ = $Rx", M_tc_3x_SLOT23>, ImmRegRel {
2287 let IClass = 0b1110;
2289 let Inst{27-21} = 0b0011000;
2290 let Inst{12-8} = Rx;
2292 let Inst{20-16} = Rs;
2295 // Rd=add(##,mpyi(Rs,#U6))
2296 def : Pat <(add (mul (i32 IntRegs:$src2), u6ImmPred:$src3),
2297 (HexagonCONST32 tglobaladdr:$src1)),
2298 (i32 (M4_mpyri_addi tglobaladdr:$src1, IntRegs:$src2,
2301 // Rd=add(##,mpyi(Rs,Rt))
2302 def : Pat <(add (mul (i32 IntRegs:$src2), (i32 IntRegs:$src3)),
2303 (HexagonCONST32 tglobaladdr:$src1)),
2304 (i32 (M4_mpyrr_addi tglobaladdr:$src1, IntRegs:$src2,
2307 // Vector reduce multiply word by signed half (32x16)
2308 //Rdd=vrmpyweh(Rss,Rtt)[:<<1]
2309 def M4_vrmpyeh_s0 : T_M2_vmpy<"vrmpyweh", 0b010, 0b100, 0, 0, 0>;
2310 def M4_vrmpyeh_s1 : T_M2_vmpy<"vrmpyweh", 0b110, 0b100, 1, 0, 0>;
2312 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2313 def M4_vrmpyoh_s0 : T_M2_vmpy<"vrmpywoh", 0b001, 0b010, 0, 0, 0>;
2314 def M4_vrmpyoh_s1 : T_M2_vmpy<"vrmpywoh", 0b101, 0b010, 1, 0, 0>;
2316 //Rdd+=vrmpyweh(Rss,Rtt)[:<<1]
2317 def M4_vrmpyeh_acc_s0: T_M2_vmpy_acc<"vrmpyweh", 0b001, 0b110, 0, 0>;
2318 def M4_vrmpyeh_acc_s1: T_M2_vmpy_acc<"vrmpyweh", 0b101, 0b110, 1, 0>;
2320 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2321 def M4_vrmpyoh_acc_s0: T_M2_vmpy_acc<"vrmpywoh", 0b011, 0b110, 0, 0>;
2322 def M4_vrmpyoh_acc_s1: T_M2_vmpy_acc<"vrmpywoh", 0b111, 0b110, 1, 0>;
2324 // Vector multiply halfwords, signed by unsigned
2325 // Rdd=vmpyhsu(Rs,Rt)[:<<]:sat
2326 def M2_vmpy2su_s0 : T_XTYPE_mpy64 < "vmpyhsu", 0b000, 0b111, 1, 0, 0>;
2327 def M2_vmpy2su_s1 : T_XTYPE_mpy64 < "vmpyhsu", 0b100, 0b111, 1, 1, 0>;
2329 // Rxx+=vmpyhsu(Rs,Rt)[:<<1]:sat
2330 def M2_vmac2su_s0 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b011, 0b101, 1, 0, 0>;
2331 def M2_vmac2su_s1 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b111, 0b101, 1, 1, 0>;
2333 // Vector polynomial multiply halfwords
2334 // Rdd=vpmpyh(Rs,Rt)
2335 def M4_vpmpyh : T_XTYPE_mpy64 < "vpmpyh", 0b110, 0b111, 0, 0, 0>;
2337 // Rxx^=vpmpyh(Rs,Rt)
2338 def M4_vpmpyh_acc : T_XTYPE_mpy64_acc < "vpmpyh", "^", 0b101, 0b111, 0, 0, 0>;
2340 // Polynomial multiply words
2342 def M4_pmpyw : T_XTYPE_mpy64 < "pmpyw", 0b010, 0b111, 0, 0, 0>;
2344 // Rxx^=pmpyw(Rs,Rt)
2345 def M4_pmpyw_acc : T_XTYPE_mpy64_acc < "pmpyw", "^", 0b001, 0b111, 0, 0, 0>;
2347 //===----------------------------------------------------------------------===//
2349 //===----------------------------------------------------------------------===//
2351 //===----------------------------------------------------------------------===//
2352 // ALU64/Vector compare
2353 //===----------------------------------------------------------------------===//
2354 //===----------------------------------------------------------------------===//
2355 // Template class for vector compare
2356 //===----------------------------------------------------------------------===//
2358 let hasSideEffects = 0 in
2359 class T_vcmpImm <string Str, bits<2> cmpOp, bits<2> minOp, Operand ImmOprnd>
2360 : ALU64_rr <(outs PredRegs:$Pd),
2361 (ins DoubleRegs:$Rss, ImmOprnd:$Imm),
2362 "$Pd = "#Str#"($Rss, #$Imm)",
2363 [], "", ALU64_tc_2early_SLOT23> {
2368 let ImmBits{6-0} = Imm{6-0};
2369 let ImmBits{7} = !if (!eq(cmpOp,0b10), 0b0, Imm{7}); // 0 for vcmp[bhw].gtu
2371 let IClass = 0b1101;
2373 let Inst{27-24} = 0b1100;
2374 let Inst{22-21} = cmpOp;
2375 let Inst{20-16} = Rss;
2376 let Inst{12-5} = ImmBits;
2377 let Inst{4-3} = minOp;
2381 // Vector compare bytes
2382 def A4_vcmpbgt : T_vcmp <"vcmpb.gt", 0b1010>;
2383 def: T_vcmp_pat<A4_vcmpbgt, setgt, v8i8>;
2385 let AsmString = "$Pd = any8(vcmpb.eq($Rss, $Rtt))" in
2386 def A4_vcmpbeq_any : T_vcmp <"any8(vcmpb.gt", 0b1000>;
2388 def A4_vcmpbeqi : T_vcmpImm <"vcmpb.eq", 0b00, 0b00, u8Imm>;
2389 def A4_vcmpbgti : T_vcmpImm <"vcmpb.gt", 0b01, 0b00, s8Imm>;
2390 def A4_vcmpbgtui : T_vcmpImm <"vcmpb.gtu", 0b10, 0b00, u7Imm>;
2392 // Vector compare halfwords
2393 def A4_vcmpheqi : T_vcmpImm <"vcmph.eq", 0b00, 0b01, s8Imm>;
2394 def A4_vcmphgti : T_vcmpImm <"vcmph.gt", 0b01, 0b01, s8Imm>;
2395 def A4_vcmphgtui : T_vcmpImm <"vcmph.gtu", 0b10, 0b01, u7Imm>;
2397 // Vector compare words
2398 def A4_vcmpweqi : T_vcmpImm <"vcmpw.eq", 0b00, 0b10, s8Imm>;
2399 def A4_vcmpwgti : T_vcmpImm <"vcmpw.gt", 0b01, 0b10, s8Imm>;
2400 def A4_vcmpwgtui : T_vcmpImm <"vcmpw.gtu", 0b10, 0b10, u7Imm>;
2402 //===----------------------------------------------------------------------===//
2404 //===----------------------------------------------------------------------===//
2405 // Shift by immediate and accumulate/logical.
2406 // Rx=add(#u8,asl(Rx,#U5)) Rx=add(#u8,lsr(Rx,#U5))
2407 // Rx=sub(#u8,asl(Rx,#U5)) Rx=sub(#u8,lsr(Rx,#U5))
2408 // Rx=and(#u8,asl(Rx,#U5)) Rx=and(#u8,lsr(Rx,#U5))
2409 // Rx=or(#u8,asl(Rx,#U5)) Rx=or(#u8,lsr(Rx,#U5))
2410 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8,
2411 hasNewValue = 1, opNewValue = 0, validSubTargets = HasV4SubT in
2412 class T_S4_ShiftOperate<string MnOp, string MnSh, SDNode Op, SDNode Sh,
2413 bit asl_lsr, bits<2> MajOp, InstrItinClass Itin>
2414 : MInst_acc<(outs IntRegs:$Rd), (ins u8Ext:$u8, IntRegs:$Rx, u5Imm:$U5),
2415 "$Rd = "#MnOp#"(#$u8, "#MnSh#"($Rx, #$U5))",
2416 [(set (i32 IntRegs:$Rd),
2417 (Op (Sh I32:$Rx, u5ImmPred:$U5), u8ExtPred:$u8))],
2418 "$Rd = $Rx", Itin> {
2425 let IClass = 0b1101;
2426 let Inst{27-24} = 0b1110;
2427 let Inst{23-21} = u8{7-5};
2428 let Inst{20-16} = Rd;
2429 let Inst{13} = u8{4};
2430 let Inst{12-8} = U5;
2431 let Inst{7-5} = u8{3-1};
2432 let Inst{4} = asl_lsr;
2433 let Inst{3} = u8{0};
2434 let Inst{2-1} = MajOp;
2437 multiclass T_ShiftOperate<string mnemonic, SDNode Op, bits<2> MajOp,
2438 InstrItinClass Itin> {
2439 def _asl_ri : T_S4_ShiftOperate<mnemonic, "asl", Op, shl, 0, MajOp, Itin>;
2440 def _lsr_ri : T_S4_ShiftOperate<mnemonic, "lsr", Op, srl, 1, MajOp, Itin>;
2443 let AddedComplexity = 200 in {
2444 defm S4_addi : T_ShiftOperate<"add", add, 0b10, ALU64_tc_2_SLOT23>;
2445 defm S4_andi : T_ShiftOperate<"and", and, 0b00, ALU64_tc_2_SLOT23>;
2448 let AddedComplexity = 30 in
2449 defm S4_ori : T_ShiftOperate<"or", or, 0b01, ALU64_tc_1_SLOT23>;
2451 defm S4_subi : T_ShiftOperate<"sub", sub, 0b11, ALU64_tc_1_SLOT23>;
2453 // Vector conditional negate
2454 // Rdd=vcnegh(Rss,Rt)
2455 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2456 def S2_vcnegh : T_S3op_shiftVect < "vcnegh", 0b11, 0b01>;
2458 // Rd=[cround|round](Rs,Rt)
2459 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in {
2460 def A4_cround_rr : T_S3op_3 < "cround", IntRegs, 0b11, 0b00>;
2461 def A4_round_rr : T_S3op_3 < "round", IntRegs, 0b11, 0b10>;
2464 // Rd=round(Rs,Rt):sat
2465 let hasNewValue = 1, Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2466 def A4_round_rr_sat : T_S3op_3 < "round", IntRegs, 0b11, 0b11, 1>;
2468 // Rd=[cmpyiwh|cmpyrwh](Rss,Rt):<<1:rnd:sat
2469 let Defs = [USR_OVF], Itinerary = S_3op_tc_3x_SLOT23 in {
2470 def M4_cmpyi_wh : T_S3op_8<"cmpyiwh", 0b100, 1, 1, 1>;
2471 def M4_cmpyr_wh : T_S3op_8<"cmpyrwh", 0b110, 1, 1, 1>;
2474 // Rdd=[add|sub](Rss,Rtt,Px):carry
2475 let isPredicateLate = 1, hasSideEffects = 0 in
2476 class T_S3op_carry <string mnemonic, bits<3> MajOp>
2477 : SInst < (outs DoubleRegs:$Rdd, PredRegs:$Px),
2478 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
2479 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu):carry",
2480 [], "$Px = $Pu", S_3op_tc_1_SLOT23 > {
2486 let IClass = 0b1100;
2488 let Inst{27-24} = 0b0010;
2489 let Inst{23-21} = MajOp;
2490 let Inst{20-16} = Rss;
2491 let Inst{12-8} = Rtt;
2493 let Inst{4-0} = Rdd;
2496 def A4_addp_c : T_S3op_carry < "add", 0b110 >;
2497 def A4_subp_c : T_S3op_carry < "sub", 0b111 >;
2499 let Itinerary = S_3op_tc_3_SLOT23, hasSideEffects = 0 in
2500 class T_S3op_6 <string mnemonic, bits<3> MinOp, bit isUnsigned>
2501 : SInst <(outs DoubleRegs:$Rxx),
2502 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Ru),
2503 "$Rxx = "#mnemonic#"($Rss, $Ru)" ,
2504 [] , "$dst2 = $Rxx"> {
2509 let IClass = 0b1100;
2511 let Inst{27-21} = 0b1011001;
2512 let Inst{20-16} = Rss;
2513 let Inst{13} = isUnsigned;
2514 let Inst{12-8} = Rxx;
2515 let Inst{7-5} = MinOp;
2519 // Vector reduce maximum halfwords
2520 // Rxx=vrmax[u]h(Rss,Ru)
2521 def A4_vrmaxh : T_S3op_6 < "vrmaxh", 0b001, 0>;
2522 def A4_vrmaxuh : T_S3op_6 < "vrmaxuh", 0b001, 1>;
2524 // Vector reduce maximum words
2525 // Rxx=vrmax[u]w(Rss,Ru)
2526 def A4_vrmaxw : T_S3op_6 < "vrmaxw", 0b010, 0>;
2527 def A4_vrmaxuw : T_S3op_6 < "vrmaxuw", 0b010, 1>;
2529 // Vector reduce minimum halfwords
2530 // Rxx=vrmin[u]h(Rss,Ru)
2531 def A4_vrminh : T_S3op_6 < "vrminh", 0b101, 0>;
2532 def A4_vrminuh : T_S3op_6 < "vrminuh", 0b101, 1>;
2534 // Vector reduce minimum words
2535 // Rxx=vrmin[u]w(Rss,Ru)
2536 def A4_vrminw : T_S3op_6 < "vrminw", 0b110, 0>;
2537 def A4_vrminuw : T_S3op_6 < "vrminuw", 0b110, 1>;
2539 // Shift an immediate left by register amount.
2540 let hasNewValue = 1, hasSideEffects = 0 in
2541 def S4_lsli: SInst <(outs IntRegs:$Rd), (ins s6Imm:$s6, IntRegs:$Rt),
2542 "$Rd = lsl(#$s6, $Rt)" ,
2543 [(set (i32 IntRegs:$Rd), (shl s6ImmPred:$s6,
2544 (i32 IntRegs:$Rt)))],
2545 "", S_3op_tc_1_SLOT23> {
2550 let IClass = 0b1100;
2552 let Inst{27-22} = 0b011010;
2553 let Inst{20-16} = s6{5-1};
2554 let Inst{12-8} = Rt;
2555 let Inst{7-6} = 0b11;
2557 let Inst{5} = s6{0};
2560 //===----------------------------------------------------------------------===//
2562 //===----------------------------------------------------------------------===//
2564 //===----------------------------------------------------------------------===//
2565 // MEMOP: Word, Half, Byte
2566 //===----------------------------------------------------------------------===//
2568 def MEMOPIMM : SDNodeXForm<imm, [{
2569 // Call the transformation function XformM5ToU5Imm to get the negative
2570 // immediate's positive counterpart.
2571 int32_t imm = N->getSExtValue();
2572 return XformM5ToU5Imm(imm);
2575 def MEMOPIMM_HALF : SDNodeXForm<imm, [{
2576 // -1 .. -31 represented as 65535..65515
2577 // assigning to a short restores our desired signed value.
2578 // Call the transformation function XformM5ToU5Imm to get the negative
2579 // immediate's positive counterpart.
2580 int16_t imm = N->getSExtValue();
2581 return XformM5ToU5Imm(imm);
2584 def MEMOPIMM_BYTE : SDNodeXForm<imm, [{
2585 // -1 .. -31 represented as 255..235
2586 // assigning to a char restores our desired signed value.
2587 // Call the transformation function XformM5ToU5Imm to get the negative
2588 // immediate's positive counterpart.
2589 int8_t imm = N->getSExtValue();
2590 return XformM5ToU5Imm(imm);
2593 def SETMEMIMM : SDNodeXForm<imm, [{
2594 // Return the bit position we will set [0-31].
2596 int32_t imm = N->getSExtValue();
2597 return XformMskToBitPosU5Imm(imm);
2600 def CLRMEMIMM : SDNodeXForm<imm, [{
2601 // Return the bit position we will clear [0-31].
2603 // we bit negate the value first
2604 int32_t imm = ~(N->getSExtValue());
2605 return XformMskToBitPosU5Imm(imm);
2608 def SETMEMIMM_SHORT : SDNodeXForm<imm, [{
2609 // Return the bit position we will set [0-15].
2611 int16_t imm = N->getSExtValue();
2612 return XformMskToBitPosU4Imm(imm);
2615 def CLRMEMIMM_SHORT : SDNodeXForm<imm, [{
2616 // Return the bit position we will clear [0-15].
2618 // we bit negate the value first
2619 int16_t imm = ~(N->getSExtValue());
2620 return XformMskToBitPosU4Imm(imm);
2623 def SETMEMIMM_BYTE : SDNodeXForm<imm, [{
2624 // Return the bit position we will set [0-7].
2626 int8_t imm = N->getSExtValue();
2627 return XformMskToBitPosU3Imm(imm);
2630 def CLRMEMIMM_BYTE : SDNodeXForm<imm, [{
2631 // Return the bit position we will clear [0-7].
2633 // we bit negate the value first
2634 int8_t imm = ~(N->getSExtValue());
2635 return XformMskToBitPosU3Imm(imm);
2638 //===----------------------------------------------------------------------===//
2639 // Template class for MemOp instructions with the register value.
2640 //===----------------------------------------------------------------------===//
2641 class MemOp_rr_base <string opc, bits<2> opcBits, Operand ImmOp,
2642 string memOp, bits<2> memOpBits> :
2644 (ins IntRegs:$base, ImmOp:$offset, IntRegs:$delta),
2645 opc#"($base+#$offset)"#memOp#"$delta",
2647 Requires<[UseMEMOP]> {
2652 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2654 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2655 !if (!eq(opcBits, 0b01), offset{6-1},
2656 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2658 let opExtentAlign = opcBits;
2659 let IClass = 0b0011;
2660 let Inst{27-24} = 0b1110;
2661 let Inst{22-21} = opcBits;
2662 let Inst{20-16} = base;
2664 let Inst{12-7} = offsetBits;
2665 let Inst{6-5} = memOpBits;
2666 let Inst{4-0} = delta;
2669 //===----------------------------------------------------------------------===//
2670 // Template class for MemOp instructions with the immediate value.
2671 //===----------------------------------------------------------------------===//
2672 class MemOp_ri_base <string opc, bits<2> opcBits, Operand ImmOp,
2673 string memOp, bits<2> memOpBits> :
2675 (ins IntRegs:$base, ImmOp:$offset, u5Imm:$delta),
2676 opc#"($base+#$offset)"#memOp#"#$delta"
2677 #!if(memOpBits{1},")", ""), // clrbit, setbit - include ')'
2679 Requires<[UseMEMOP]> {
2684 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2686 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2687 !if (!eq(opcBits, 0b01), offset{6-1},
2688 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2690 let opExtentAlign = opcBits;
2691 let IClass = 0b0011;
2692 let Inst{27-24} = 0b1111;
2693 let Inst{22-21} = opcBits;
2694 let Inst{20-16} = base;
2696 let Inst{12-7} = offsetBits;
2697 let Inst{6-5} = memOpBits;
2698 let Inst{4-0} = delta;
2701 // multiclass to define MemOp instructions with register operand.
2702 multiclass MemOp_rr<string opc, bits<2> opcBits, Operand ImmOp> {
2703 def L4_add#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " += ", 0b00>; // add
2704 def L4_sub#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " -= ", 0b01>; // sub
2705 def L4_and#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " &= ", 0b10>; // and
2706 def L4_or#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " |= ", 0b11>; // or
2709 // multiclass to define MemOp instructions with immediate Operand.
2710 multiclass MemOp_ri<string opc, bits<2> opcBits, Operand ImmOp> {
2711 def L4_iadd#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " += ", 0b00 >;
2712 def L4_isub#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " -= ", 0b01 >;
2713 def L4_iand#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = clrbit(", 0b10>;
2714 def L4_ior#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = setbit(", 0b11>;
2717 multiclass MemOp_base <string opc, bits<2> opcBits, Operand ImmOp> {
2718 defm _#NAME : MemOp_rr <opc, opcBits, ImmOp>;
2719 defm _#NAME : MemOp_ri <opc, opcBits, ImmOp>;
2722 // Define MemOp instructions.
2723 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0,
2724 validSubTargets =HasV4SubT in {
2725 let opExtentBits = 6, accessSize = ByteAccess in
2726 defm memopb_io : MemOp_base <"memb", 0b00, u6_0Ext>;
2728 let opExtentBits = 7, accessSize = HalfWordAccess in
2729 defm memoph_io : MemOp_base <"memh", 0b01, u6_1Ext>;
2731 let opExtentBits = 8, accessSize = WordAccess in
2732 defm memopw_io : MemOp_base <"memw", 0b10, u6_2Ext>;
2735 //===----------------------------------------------------------------------===//
2736 // Multiclass to define 'Def Pats' for ALU operations on the memory
2737 // Here value used for the ALU operation is an immediate value.
2738 // mem[bh](Rs+#0) += #U5
2739 // mem[bh](Rs+#u6) += #U5
2740 //===----------------------------------------------------------------------===//
2742 multiclass MemOpi_u5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf ExtPred,
2743 InstHexagon MI, SDNode OpNode> {
2744 let AddedComplexity = 180 in
2745 def: Pat<(stOp (OpNode (ldOp IntRegs:$addr), u5ImmPred:$addend),
2747 (MI IntRegs:$addr, 0, u5ImmPred:$addend)>;
2749 let AddedComplexity = 190 in
2750 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, ExtPred:$offset)),
2752 (add IntRegs:$base, ExtPred:$offset)),
2753 (MI IntRegs:$base, ExtPred:$offset, u5ImmPred:$addend)>;
2756 multiclass MemOpi_u5ALUOp<PatFrag ldOp, PatFrag stOp, PatLeaf ExtPred,
2757 InstHexagon addMI, InstHexagon subMI> {
2758 defm: MemOpi_u5Pats<ldOp, stOp, ExtPred, addMI, add>;
2759 defm: MemOpi_u5Pats<ldOp, stOp, ExtPred, subMI, sub>;
2762 multiclass MemOpi_u5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2764 defm: MemOpi_u5ALUOp <ldOpHalf, truncstorei16, u6_1ExtPred,
2765 L4_iadd_memoph_io, L4_isub_memoph_io>;
2767 defm: MemOpi_u5ALUOp <ldOpByte, truncstorei8, u6ExtPred,
2768 L4_iadd_memopb_io, L4_isub_memopb_io>;
2771 let Predicates = [HasV4T, UseMEMOP] in {
2772 defm: MemOpi_u5ExtType<zextloadi8, zextloadi16>; // zero extend
2773 defm: MemOpi_u5ExtType<sextloadi8, sextloadi16>; // sign extend
2774 defm: MemOpi_u5ExtType<extloadi8, extloadi16>; // any extend
2777 defm: MemOpi_u5ALUOp <load, store, u6_2ExtPred, L4_iadd_memopw_io,
2781 //===----------------------------------------------------------------------===//
2782 // multiclass to define 'Def Pats' for ALU operations on the memory.
2783 // Here value used for the ALU operation is a negative value.
2784 // mem[bh](Rs+#0) += #m5
2785 // mem[bh](Rs+#u6) += #m5
2786 //===----------------------------------------------------------------------===//
2788 multiclass MemOpi_m5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf extPred,
2789 PatLeaf immPred, ComplexPattern addrPred,
2790 SDNodeXForm xformFunc, InstHexagon MI> {
2791 let AddedComplexity = 190 in
2792 def: Pat<(stOp (add (ldOp IntRegs:$addr), immPred:$subend), IntRegs:$addr),
2793 (MI IntRegs:$addr, 0, (xformFunc immPred:$subend))>;
2795 let AddedComplexity = 195 in
2796 def: Pat<(stOp (add (ldOp (add IntRegs:$base, extPred:$offset)),
2798 (add IntRegs:$base, extPred:$offset)),
2799 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$subend))>;
2802 multiclass MemOpi_m5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2804 defm: MemOpi_m5Pats <ldOpHalf, truncstorei16, u6_1ExtPred, m5HImmPred,
2805 ADDRriU6_1, MEMOPIMM_HALF, L4_isub_memoph_io>;
2807 defm: MemOpi_m5Pats <ldOpByte, truncstorei8, u6ExtPred, m5BImmPred,
2808 ADDRriU6_0, MEMOPIMM_BYTE, L4_isub_memopb_io>;
2811 let Predicates = [HasV4T, UseMEMOP] in {
2812 defm: MemOpi_m5ExtType<zextloadi8, zextloadi16>; // zero extend
2813 defm: MemOpi_m5ExtType<sextloadi8, sextloadi16>; // sign extend
2814 defm: MemOpi_m5ExtType<extloadi8, extloadi16>; // any extend
2817 defm: MemOpi_m5Pats <load, store, u6_2ExtPred, m5ImmPred,
2818 ADDRriU6_2, MEMOPIMM, L4_isub_memopw_io>;
2821 //===----------------------------------------------------------------------===//
2822 // Multiclass to define 'def Pats' for bit operations on the memory.
2823 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
2824 // mem[bhw](Rs+#u6) = [clrbit|setbit](#U5)
2825 //===----------------------------------------------------------------------===//
2827 multiclass MemOpi_bitPats <PatFrag ldOp, PatFrag stOp, PatLeaf immPred,
2828 PatLeaf extPred, ComplexPattern addrPred,
2829 SDNodeXForm xformFunc, InstHexagon MI, SDNode OpNode> {
2831 // mem[bhw](Rs+#u6:[012]) = [clrbit|setbit](#U5)
2832 let AddedComplexity = 250 in
2833 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
2835 (add IntRegs:$base, extPred:$offset)),
2836 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$bitend))>;
2838 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
2839 let AddedComplexity = 225 in
2840 def: Pat<(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)),
2842 (addrPred (i32 IntRegs:$addr), extPred:$offset)),
2843 (MI IntRegs:$addr, extPred:$offset, (xformFunc immPred:$bitend))>;
2846 multiclass MemOpi_bitExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2848 defm: MemOpi_bitPats<ldOpByte, truncstorei8, Clr3ImmPred, u6ExtPred,
2849 ADDRriU6_0, CLRMEMIMM_BYTE, L4_iand_memopb_io, and>;
2851 defm: MemOpi_bitPats<ldOpByte, truncstorei8, Set3ImmPred, u6ExtPred,
2852 ADDRriU6_0, SETMEMIMM_BYTE, L4_ior_memopb_io, or>;
2853 // Half Word - clrbit
2854 defm: MemOpi_bitPats<ldOpHalf, truncstorei16, Clr4ImmPred, u6_1ExtPred,
2855 ADDRriU6_1, CLRMEMIMM_SHORT, L4_iand_memoph_io, and>;
2856 // Half Word - setbit
2857 defm: MemOpi_bitPats<ldOpHalf, truncstorei16, Set4ImmPred, u6_1ExtPred,
2858 ADDRriU6_1, SETMEMIMM_SHORT, L4_ior_memoph_io, or>;
2861 let Predicates = [HasV4T, UseMEMOP] in {
2862 // mem[bh](Rs+#0) = [clrbit|setbit](#U5)
2863 // mem[bh](Rs+#u6:[01]) = [clrbit|setbit](#U5)
2864 defm: MemOpi_bitExtType<zextloadi8, zextloadi16>; // zero extend
2865 defm: MemOpi_bitExtType<sextloadi8, sextloadi16>; // sign extend
2866 defm: MemOpi_bitExtType<extloadi8, extloadi16>; // any extend
2868 // memw(Rs+#0) = [clrbit|setbit](#U5)
2869 // memw(Rs+#u6:2) = [clrbit|setbit](#U5)
2870 defm: MemOpi_bitPats<load, store, Clr5ImmPred, u6_2ExtPred, ADDRriU6_2,
2871 CLRMEMIMM, L4_iand_memopw_io, and>;
2872 defm: MemOpi_bitPats<load, store, Set5ImmPred, u6_2ExtPred, ADDRriU6_2,
2873 SETMEMIMM, L4_ior_memopw_io, or>;
2876 //===----------------------------------------------------------------------===//
2877 // Multiclass to define 'def Pats' for ALU operations on the memory
2878 // where addend is a register.
2879 // mem[bhw](Rs+#0) [+-&|]= Rt
2880 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
2881 //===----------------------------------------------------------------------===//
2883 multiclass MemOpr_Pats <PatFrag ldOp, PatFrag stOp, ComplexPattern addrPred,
2884 PatLeaf extPred, InstHexagon MI, SDNode OpNode> {
2885 let AddedComplexity = 141 in
2886 // mem[bhw](Rs+#0) [+-&|]= Rt
2887 def: Pat<(stOp (OpNode (ldOp (addrPred IntRegs:$addr, extPred:$offset)),
2888 (i32 IntRegs:$addend)),
2889 (addrPred (i32 IntRegs:$addr), extPred:$offset)),
2890 (MI IntRegs:$addr, extPred:$offset, (i32 IntRegs:$addend) )>;
2892 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
2893 let AddedComplexity = 150 in
2894 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
2895 (i32 IntRegs:$orend)),
2896 (add IntRegs:$base, extPred:$offset)),
2897 (MI IntRegs:$base, extPred:$offset, (i32 IntRegs:$orend))>;
2900 multiclass MemOPr_ALUOp<PatFrag ldOp, PatFrag stOp,
2901 ComplexPattern addrPred, PatLeaf extPred,
2902 InstHexagon addMI, InstHexagon subMI,
2903 InstHexagon andMI, InstHexagon orMI > {
2905 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, addMI, add>;
2906 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, subMI, sub>;
2907 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, andMI, and>;
2908 defm: MemOpr_Pats <ldOp, stOp, addrPred, extPred, orMI, or>;
2911 multiclass MemOPr_ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2913 defm: MemOPr_ALUOp <ldOpHalf, truncstorei16, ADDRriU6_1, u6_1ExtPred,
2914 L4_add_memoph_io, L4_sub_memoph_io,
2915 L4_and_memoph_io, L4_or_memoph_io>;
2917 defm: MemOPr_ALUOp <ldOpByte, truncstorei8, ADDRriU6_0, u6ExtPred,
2918 L4_add_memopb_io, L4_sub_memopb_io,
2919 L4_and_memopb_io, L4_or_memopb_io>;
2922 // Define 'def Pats' for MemOps with register addend.
2923 let Predicates = [HasV4T, UseMEMOP] in {
2925 defm: MemOPr_ExtType<zextloadi8, zextloadi16>; // zero extend
2926 defm: MemOPr_ExtType<sextloadi8, sextloadi16>; // sign extend
2927 defm: MemOPr_ExtType<extloadi8, extloadi16>; // any extend
2929 defm: MemOPr_ALUOp <load, store, ADDRriU6_2, u6_2ExtPred, L4_add_memopw_io,
2930 L4_sub_memopw_io, L4_and_memopw_io, L4_or_memopw_io>;
2933 //===----------------------------------------------------------------------===//
2935 //===----------------------------------------------------------------------===//
2937 // Hexagon V4 only supports these flavors of byte/half compare instructions:
2938 // EQ/GT/GTU. Other flavors like GE/GEU/LT/LTU/LE/LEU are not supported by
2939 // hardware. However, compiler can still implement these patterns through
2940 // appropriate patterns combinations based on current implemented patterns.
2941 // The implemented patterns are: EQ/GT/GTU.
2942 // Missing patterns are: GE/GEU/LT/LTU/LE/LEU.
2944 // Following instruction is not being extended as it results into the
2945 // incorrect code for negative numbers.
2946 // Pd=cmpb.eq(Rs,#u8)
2948 // p=!cmp.eq(r1,#s10)
2949 def C4_cmpneqi : T_CMP <"cmp.eq", 0b00, 1, s10Ext>;
2950 def C4_cmpltei : T_CMP <"cmp.gt", 0b01, 1, s10Ext>;
2951 def C4_cmplteui : T_CMP <"cmp.gtu", 0b10, 1, u9Ext>;
2953 def : T_CMP_pat <C4_cmpneqi, setne, s10ExtPred>;
2954 def : T_CMP_pat <C4_cmpltei, setle, s10ExtPred>;
2955 def : T_CMP_pat <C4_cmplteui, setule, u9ImmPred>;
2957 // rs <= rt -> !(rs > rt).
2959 def: Pat<(i1 (setle (i32 IntRegs:$src1), s10ExtPred:$src2)),
2960 (C2_not (C2_cmpgti IntRegs:$src1, s10ExtPred:$src2))>;
2961 // (C4_cmpltei IntRegs:$src1, s10ExtPred:$src2)>;
2963 // Map cmplt(Rs, Imm) -> !cmpgt(Rs, Imm-1).
2964 def: Pat<(i1 (setlt (i32 IntRegs:$src1), s8ExtPred:$src2)),
2965 (C4_cmpltei IntRegs:$src1, (DEC_CONST_SIGNED s8ExtPred:$src2))>;
2967 // rs != rt -> !(rs == rt).
2968 def: Pat<(i1 (setne (i32 IntRegs:$src1), s10ExtPred:$src2)),
2969 (C4_cmpneqi IntRegs:$src1, s10ExtPred:$src2)>;
2971 // SDNode for converting immediate C to C-1.
2972 def DEC_CONST_BYTE : SDNodeXForm<imm, [{
2973 // Return the byte immediate const-1 as an SDNode.
2974 int32_t imm = N->getSExtValue();
2975 return XformU7ToU7M1Imm(imm);
2979 // zext( seteq ( and(Rs, 255), u8))
2981 // Pd=cmpb.eq(Rs, #u8)
2982 // if (Pd.new) Rd=#1
2983 // if (!Pd.new) Rd=#0
2984 def : Pat <(i32 (zext (i1 (seteq (i32 (and (i32 IntRegs:$Rs), 255)),
2986 (i32 (TFR_condset_ii (i1 (A4_cmpbeqi (i32 IntRegs:$Rs),
2992 // zext( setne ( and(Rs, 255), u8))
2994 // Pd=cmpb.eq(Rs, #u8)
2995 // if (Pd.new) Rd=#0
2996 // if (!Pd.new) Rd=#1
2997 def : Pat <(i32 (zext (i1 (setne (i32 (and (i32 IntRegs:$Rs), 255)),
2999 (i32 (TFR_condset_ii (i1 (A4_cmpbeqi (i32 IntRegs:$Rs),
3005 // zext( seteq (Rs, and(Rt, 255)))
3007 // Pd=cmpb.eq(Rs, Rt)
3008 // if (Pd.new) Rd=#1
3009 // if (!Pd.new) Rd=#0
3010 def : Pat <(i32 (zext (i1 (seteq (i32 IntRegs:$Rt),
3011 (i32 (and (i32 IntRegs:$Rs), 255)))))),
3012 (i32 (TFR_condset_ii (i1 (A4_cmpbeq (i32 IntRegs:$Rs),
3013 (i32 IntRegs:$Rt))),
3018 // zext( setne (Rs, and(Rt, 255)))
3020 // Pd=cmpb.eq(Rs, Rt)
3021 // if (Pd.new) Rd=#0
3022 // if (!Pd.new) Rd=#1
3023 def : Pat <(i32 (zext (i1 (setne (i32 IntRegs:$Rt),
3024 (i32 (and (i32 IntRegs:$Rs), 255)))))),
3025 (i32 (TFR_condset_ii (i1 (A4_cmpbeq (i32 IntRegs:$Rs),
3026 (i32 IntRegs:$Rt))),
3031 // zext( setugt ( and(Rs, 255), u8))
3033 // Pd=cmpb.gtu(Rs, #u8)
3034 // if (Pd.new) Rd=#1
3035 // if (!Pd.new) Rd=#0
3036 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 255)),
3038 (i32 (TFR_condset_ii (i1 (A4_cmpbgtui (i32 IntRegs:$Rs),
3044 // zext( setugt ( and(Rs, 254), u8))
3046 // Pd=cmpb.gtu(Rs, #u8)
3047 // if (Pd.new) Rd=#1
3048 // if (!Pd.new) Rd=#0
3049 def : Pat <(i32 (zext (i1 (setugt (i32 (and (i32 IntRegs:$Rs), 254)),
3051 (i32 (TFR_condset_ii (i1 (A4_cmpbgtui (i32 IntRegs:$Rs),
3057 // zext( setult ( Rs, Rt))
3059 // Pd=cmp.ltu(Rs, Rt)
3060 // if (Pd.new) Rd=#1
3061 // if (!Pd.new) Rd=#0
3062 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs)
3063 def : Pat <(i32 (zext (i1 (setult (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3064 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt),
3065 (i32 IntRegs:$Rs))),
3070 // zext( setlt ( Rs, Rt))
3072 // Pd=cmp.lt(Rs, Rt)
3073 // if (Pd.new) Rd=#1
3074 // if (!Pd.new) Rd=#0
3075 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs)
3076 def : Pat <(i32 (zext (i1 (setlt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3077 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt),
3078 (i32 IntRegs:$Rs))),
3083 // zext( setugt ( Rs, Rt))
3085 // Pd=cmp.gtu(Rs, Rt)
3086 // if (Pd.new) Rd=#1
3087 // if (!Pd.new) Rd=#0
3088 def : Pat <(i32 (zext (i1 (setugt (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3089 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs),
3090 (i32 IntRegs:$Rt))),
3094 // This pattern interefers with coremark performance, not implementing at this
3097 // zext( setgt ( Rs, Rt))
3099 // Pd=cmp.gt(Rs, Rt)
3100 // if (Pd.new) Rd=#1
3101 // if (!Pd.new) Rd=#0
3104 // zext( setuge ( Rs, Rt))
3106 // Pd=cmp.ltu(Rs, Rt)
3107 // if (Pd.new) Rd=#0
3108 // if (!Pd.new) Rd=#1
3109 // cmp.ltu(Rs, Rt) -> cmp.gtu(Rt, Rs)
3110 def : Pat <(i32 (zext (i1 (setuge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3111 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rt),
3112 (i32 IntRegs:$Rs))),
3117 // zext( setge ( Rs, Rt))
3119 // Pd=cmp.lt(Rs, Rt)
3120 // if (Pd.new) Rd=#0
3121 // if (!Pd.new) Rd=#1
3122 // cmp.lt(Rs, Rt) -> cmp.gt(Rt, Rs)
3123 def : Pat <(i32 (zext (i1 (setge (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3124 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rt),
3125 (i32 IntRegs:$Rs))),
3130 // zext( setule ( Rs, Rt))
3132 // Pd=cmp.gtu(Rs, Rt)
3133 // if (Pd.new) Rd=#0
3134 // if (!Pd.new) Rd=#1
3135 def : Pat <(i32 (zext (i1 (setule (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3136 (i32 (TFR_condset_ii (i1 (C2_cmpgtu (i32 IntRegs:$Rs),
3137 (i32 IntRegs:$Rt))),
3142 // zext( setle ( Rs, Rt))
3144 // Pd=cmp.gt(Rs, Rt)
3145 // if (Pd.new) Rd=#0
3146 // if (!Pd.new) Rd=#1
3147 def : Pat <(i32 (zext (i1 (setle (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))))),
3148 (i32 (TFR_condset_ii (i1 (C2_cmpgt (i32 IntRegs:$Rs),
3149 (i32 IntRegs:$Rt))),
3154 // zext( setult ( and(Rs, 255), u8))
3155 // Use the isdigit transformation below
3157 // Generate code of the form 'C2_muxii(cmpbgtui(Rdd, C-1),0,1)'
3158 // for C code of the form r = ((c>='0') & (c<='9')) ? 1 : 0;.
3159 // The isdigit transformation relies on two 'clever' aspects:
3160 // 1) The data type is unsigned which allows us to eliminate a zero test after
3161 // biasing the expression by 48. We are depending on the representation of
3162 // the unsigned types, and semantics.
3163 // 2) The front end has converted <= 9 into < 10 on entry to LLVM
3166 // retval = ((c>='0') & (c<='9')) ? 1 : 0;
3167 // The code is transformed upstream of llvm into
3168 // retval = (c-48) < 10 ? 1 : 0;
3169 let AddedComplexity = 139 in
3170 def: Pat<(i32 (zext (i1 (setult (i32 (and (i32 IntRegs:$src1), 255)),
3171 u7StrictPosImmPred:$src2)))),
3172 (C2_muxii (A4_cmpbgtui IntRegs:$src1,
3173 (DEC_CONST_BYTE u7StrictPosImmPred:$src2)),
3174 0, 1)>, Requires<[HasV4T]>;
3176 //===----------------------------------------------------------------------===//
3178 //===----------------------------------------------------------------------===//
3180 //===----------------------------------------------------------------------===//
3181 // Multiclass for DeallocReturn
3182 //===----------------------------------------------------------------------===//
3183 class L4_RETURN<string mnemonic, bit isNot, bit isPredNew, bit isTak>
3184 : LD0Inst<(outs), (ins PredRegs:$src),
3185 !if(isNot, "if (!$src", "if ($src")#
3186 !if(isPredNew, ".new) ", ") ")#mnemonic#
3187 !if(isPredNew, #!if(isTak,":t", ":nt"),""),
3188 [], "", LD_tc_3or4stall_SLOT0> {
3191 let BaseOpcode = "L4_RETURN";
3192 let isPredicatedFalse = isNot;
3193 let isPredicatedNew = isPredNew;
3194 let isTaken = isTak;
3195 let IClass = 0b1001;
3197 let Inst{27-16} = 0b011000011110;
3199 let Inst{13} = isNot;
3200 let Inst{12} = isTak;
3201 let Inst{11} = isPredNew;
3203 let Inst{9-8} = src;
3204 let Inst{4-0} = 0b11110;
3207 // Produce all predicated forms, p, !p, p.new, !p.new, :t, :nt
3208 multiclass L4_RETURN_PRED<string mnemonic, bit PredNot> {
3209 let isPredicated = 1 in {
3210 def _#NAME# : L4_RETURN <mnemonic, PredNot, 0, 1>;
3211 def _#NAME#new_pnt : L4_RETURN <mnemonic, PredNot, 1, 0>;
3212 def _#NAME#new_pt : L4_RETURN <mnemonic, PredNot, 1, 1>;
3216 multiclass LD_MISC_L4_RETURN<string mnemonic> {
3217 let isBarrier = 1, isPredicable = 1 in
3218 def NAME : LD0Inst <(outs), (ins), mnemonic, [], "",
3219 LD_tc_3or4stall_SLOT0> {
3220 let BaseOpcode = "L4_RETURN";
3221 let IClass = 0b1001;
3222 let Inst{27-16} = 0b011000011110;
3223 let Inst{13-10} = 0b0000;
3224 let Inst{4-0} = 0b11110;
3226 defm t : L4_RETURN_PRED<mnemonic, 0 >;
3227 defm f : L4_RETURN_PRED<mnemonic, 1 >;
3230 let isReturn = 1, isTerminator = 1,
3231 Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0,
3232 validSubTargets = HasV4SubT in
3233 defm L4_return: LD_MISC_L4_RETURN <"dealloc_return">, PredNewRel;
3235 // Restore registers and dealloc return function call.
3236 let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1,
3237 Defs = [R29, R30, R31, PC], isAsmParserOnly = 1 in {
3238 let validSubTargets = HasV4SubT in
3239 def RESTORE_DEALLOC_RET_JMP_V4 : JInst<(outs),
3240 (ins calltarget:$dst),
3246 // Restore registers and dealloc frame before a tail call.
3247 let isCall = 1, isBarrier = 1, isAsmParserOnly = 1,
3248 Defs = [R29, R30, R31, PC] in {
3249 let validSubTargets = HasV4SubT in
3250 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : JInst<(outs),
3251 (ins calltarget:$dst),
3257 // Save registers function call.
3258 let isCall = 1, isBarrier = 1, isAsmParserOnly = 1,
3259 Uses = [R29, R31] in {
3260 def SAVE_REGISTERS_CALL_V4 : JInst<(outs),
3261 (ins calltarget:$dst),
3262 "call $dst // Save_calle_saved_registers",
3267 //===----------------------------------------------------------------------===//
3268 // Template class for non predicated store instructions with
3269 // GP-Relative or absolute addressing.
3270 //===----------------------------------------------------------------------===//
3271 let hasSideEffects = 0, isPredicable = 1, isNVStorable = 1 in
3272 class T_StoreAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3273 bits<2>MajOp, Operand AddrOp, bit isAbs, bit isHalf>
3274 : STInst<(outs), (ins AddrOp:$addr, RC:$src),
3275 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src"#!if(isHalf, ".h",""),
3276 [], "", V2LDST_tc_st_SLOT01> {
3279 bits<16> offsetBits;
3281 string ImmOpStr = !cast<string>(ImmOp);
3282 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3283 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3284 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3285 /* u16_0Imm */ addr{15-0})));
3286 let IClass = 0b0100;
3288 let Inst{26-25} = offsetBits{15-14};
3290 let Inst{23-22} = MajOp;
3291 let Inst{21} = isHalf;
3292 let Inst{20-16} = offsetBits{13-9};
3293 let Inst{13} = offsetBits{8};
3294 let Inst{12-8} = src;
3295 let Inst{7-0} = offsetBits{7-0};
3298 //===----------------------------------------------------------------------===//
3299 // Template class for predicated store instructions with
3300 // GP-Relative or absolute addressing.
3301 //===----------------------------------------------------------------------===//
3302 let hasSideEffects = 0, isPredicated = 1, isNVStorable = 1, opExtentBits = 6,
3304 class T_StoreAbs_Pred <string mnemonic, RegisterClass RC, bits<2> MajOp,
3305 bit isHalf, bit isNot, bit isNew>
3306 : STInst<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, RC: $src2),
3307 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3308 ") ")#mnemonic#"(#$absaddr) = $src2"#!if(isHalf, ".h",""),
3309 [], "", ST_tc_st_SLOT01>, AddrModeRel {
3314 let isPredicatedNew = isNew;
3315 let isPredicatedFalse = isNot;
3317 let IClass = 0b1010;
3319 let Inst{27-24} = 0b1111;
3320 let Inst{23-22} = MajOp;
3321 let Inst{21} = isHalf;
3322 let Inst{17-16} = absaddr{5-4};
3323 let Inst{13} = isNew;
3324 let Inst{12-8} = src2;
3326 let Inst{6-3} = absaddr{3-0};
3327 let Inst{2} = isNot;
3328 let Inst{1-0} = src1;
3331 //===----------------------------------------------------------------------===//
3332 // Template class for predicated store instructions with absolute addressing.
3333 //===----------------------------------------------------------------------===//
3334 class T_StoreAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3335 bits<2> MajOp, bit isHalf>
3336 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, u0AlwaysExt, 1, isHalf>,
3338 string ImmOpStr = !cast<string>(ImmOp);
3339 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3340 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3341 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3342 /* u16_0Imm */ 16)));
3344 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3345 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3346 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3347 /* u16_0Imm */ 0)));
3350 //===----------------------------------------------------------------------===//
3351 // Multiclass for store instructions with absolute addressing.
3352 //===----------------------------------------------------------------------===//
3353 let validSubTargets = HasV4SubT, addrMode = Absolute, isExtended = 1 in
3354 multiclass ST_Abs<string mnemonic, string CextOp, RegisterClass RC,
3355 Operand ImmOp, bits<2> MajOp, bit isHalf = 0> {
3356 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3357 let opExtendable = 0, isPredicable = 1 in
3358 def S2_#NAME#abs : T_StoreAbs <mnemonic, RC, ImmOp, MajOp, isHalf>;
3361 def S4_p#NAME#t_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 0>;
3362 def S4_p#NAME#f_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 0>;
3365 def S4_p#NAME#tnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 1>;
3366 def S4_p#NAME#fnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 1>;
3370 //===----------------------------------------------------------------------===//
3371 // Template class for non predicated new-value store instructions with
3372 // GP-Relative or absolute addressing.
3373 //===----------------------------------------------------------------------===//
3374 let hasSideEffects = 0, isPredicable = 1, mayStore = 1, isNVStore = 1,
3375 isNewValue = 1, opNewValue = 1 in
3376 class T_StoreAbsGP_NV <string mnemonic, Operand ImmOp, bits<2>MajOp, bit isAbs>
3377 : NVInst_V4<(outs), (ins u0AlwaysExt:$addr, IntRegs:$src),
3378 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src.new",
3379 [], "", V2LDST_tc_st_SLOT0> {
3382 bits<16> offsetBits;
3384 string ImmOpStr = !cast<string>(ImmOp);
3385 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3386 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3387 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3388 /* u16_0Imm */ addr{15-0})));
3389 let IClass = 0b0100;
3392 let Inst{26-25} = offsetBits{15-14};
3393 let Inst{24-21} = 0b0101;
3394 let Inst{20-16} = offsetBits{13-9};
3395 let Inst{13} = offsetBits{8};
3396 let Inst{12-11} = MajOp;
3397 let Inst{10-8} = src;
3398 let Inst{7-0} = offsetBits{7-0};
3401 //===----------------------------------------------------------------------===//
3402 // Template class for predicated new-value store instructions with
3403 // absolute addressing.
3404 //===----------------------------------------------------------------------===//
3405 let hasSideEffects = 0, isPredicated = 1, mayStore = 1, isNVStore = 1,
3406 isNewValue = 1, opNewValue = 2, opExtentBits = 6, opExtendable = 1 in
3407 class T_StoreAbs_NV_Pred <string mnemonic, bits<2> MajOp, bit isNot, bit isNew>
3408 : NVInst_V4<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, IntRegs:$src2),
3409 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3410 ") ")#mnemonic#"(#$absaddr) = $src2.new",
3411 [], "", ST_tc_st_SLOT0>, AddrModeRel {
3416 let isPredicatedNew = isNew;
3417 let isPredicatedFalse = isNot;
3419 let IClass = 0b1010;
3421 let Inst{27-24} = 0b1111;
3422 let Inst{23-21} = 0b101;
3423 let Inst{17-16} = absaddr{5-4};
3424 let Inst{13} = isNew;
3425 let Inst{12-11} = MajOp;
3426 let Inst{10-8} = src2;
3428 let Inst{6-3} = absaddr{3-0};
3429 let Inst{2} = isNot;
3430 let Inst{1-0} = src1;
3433 //===----------------------------------------------------------------------===//
3434 // Template class for non-predicated new-value store instructions with
3435 // absolute addressing.
3436 //===----------------------------------------------------------------------===//
3437 class T_StoreAbs_NV <string mnemonic, Operand ImmOp, bits<2> MajOp>
3438 : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 1>, AddrModeRel {
3440 string ImmOpStr = !cast<string>(ImmOp);
3441 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3442 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3443 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3444 /* u16_0Imm */ 16)));
3446 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3447 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3448 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3449 /* u16_0Imm */ 0)));
3452 //===----------------------------------------------------------------------===//
3453 // Multiclass for new-value store instructions with absolute addressing.
3454 //===----------------------------------------------------------------------===//
3455 let validSubTargets = HasV4SubT, addrMode = Absolute, isExtended = 1 in
3456 multiclass ST_Abs_NV <string mnemonic, string CextOp, Operand ImmOp,
3458 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3459 let opExtendable = 0, isPredicable = 1 in
3460 def S2_#NAME#newabs : T_StoreAbs_NV <mnemonic, ImmOp, MajOp>;
3463 def S4_p#NAME#newt_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 0>;
3464 def S4_p#NAME#newf_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 0>;
3467 def S4_p#NAME#newtnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 1>;
3468 def S4_p#NAME#newfnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 1>;
3472 //===----------------------------------------------------------------------===//
3473 // Stores with absolute addressing
3474 //===----------------------------------------------------------------------===//
3475 let accessSize = ByteAccess in
3476 defm storerb : ST_Abs <"memb", "STrib", IntRegs, u16_0Imm, 0b00>,
3477 ST_Abs_NV <"memb", "STrib", u16_0Imm, 0b00>;
3479 let accessSize = HalfWordAccess in
3480 defm storerh : ST_Abs <"memh", "STrih", IntRegs, u16_1Imm, 0b01>,
3481 ST_Abs_NV <"memh", "STrih", u16_1Imm, 0b01>;
3483 let accessSize = WordAccess in
3484 defm storeri : ST_Abs <"memw", "STriw", IntRegs, u16_2Imm, 0b10>,
3485 ST_Abs_NV <"memw", "STriw", u16_2Imm, 0b10>;
3487 let isNVStorable = 0, accessSize = DoubleWordAccess in
3488 defm storerd : ST_Abs <"memd", "STrid", DoubleRegs, u16_3Imm, 0b11>;
3490 let isNVStorable = 0, accessSize = HalfWordAccess in
3491 defm storerf : ST_Abs <"memh", "STrif", IntRegs, u16_1Imm, 0b01, 1>;
3493 //===----------------------------------------------------------------------===//
3494 // GP-relative stores.
3495 // mem[bhwd](#global)=Rt
3496 // Once predicated, these instructions map to absolute addressing mode.
3497 // if ([!]Pv[.new]) mem[bhwd](##global)=Rt
3498 //===----------------------------------------------------------------------===//
3500 let validSubTargets = HasV4SubT, isAsmParserOnly = 1 in
3501 class T_StoreGP <string mnemonic, string BaseOp, RegisterClass RC,
3502 Operand ImmOp, bits<2> MajOp, bit isHalf = 0>
3503 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0, isHalf> {
3504 // Set BaseOpcode same as absolute addressing instructions so that
3505 // non-predicated GP-Rel instructions can have relate with predicated
3506 // Absolute instruction.
3507 let BaseOpcode = BaseOp#_abs;
3510 let validSubTargets = HasV4SubT, isAsmParserOnly = 1 in
3511 multiclass ST_GP <string mnemonic, string BaseOp, Operand ImmOp,
3512 bits<2> MajOp, bit isHalf = 0> {
3513 // Set BaseOpcode same as absolute addressing instructions so that
3514 // non-predicated GP-Rel instructions can have relate with predicated
3515 // Absolute instruction.
3516 let BaseOpcode = BaseOp#_abs in {
3517 def NAME#gp : T_StoreAbsGP <mnemonic, IntRegs, ImmOp, MajOp,
3518 globaladdress, 0, isHalf>;
3520 def NAME#newgp : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 0> ;
3524 let accessSize = ByteAccess in
3525 defm S2_storerb : ST_GP<"memb", "STrib", u16_0Imm, 0b00>, NewValueRel;
3527 let accessSize = HalfWordAccess in
3528 defm S2_storerh : ST_GP<"memh", "STrih", u16_1Imm, 0b01>, NewValueRel;
3530 let accessSize = WordAccess in
3531 defm S2_storeri : ST_GP<"memw", "STriw", u16_2Imm, 0b10>, NewValueRel;
3533 let isNVStorable = 0, accessSize = DoubleWordAccess in
3534 def S2_storerdgp : T_StoreGP <"memd", "STrid", DoubleRegs,
3535 u16_3Imm, 0b11>, PredNewRel;
3537 let isNVStorable = 0, accessSize = HalfWordAccess in
3538 def S2_storerfgp : T_StoreGP <"memh", "STrif", IntRegs,
3539 u16_1Imm, 0b01, 1>, PredNewRel;
3541 class Loada_pat<PatFrag Load, ValueType VT, PatFrag Addr, InstHexagon MI>
3542 : Pat<(VT (Load Addr:$addr)), (MI Addr:$addr)>;
3544 class Loadam_pat<PatFrag Load, ValueType VT, PatFrag Addr, PatFrag ValueMod,
3546 : Pat<(VT (Load Addr:$addr)), (ValueMod (MI Addr:$addr))>;
3548 class Storea_pat<PatFrag Store, PatFrag Value, PatFrag Addr, InstHexagon MI>
3549 : Pat<(Store Value:$val, Addr:$addr), (MI Addr:$addr, Value:$val)>;
3551 class Stoream_pat<PatFrag Store, PatFrag Value, PatFrag Addr, PatFrag ValueMod,
3553 : Pat<(Store Value:$val, Addr:$addr),
3554 (MI Addr:$addr, (ValueMod Value:$val))>;
3556 def: Storea_pat<SwapSt<atomic_store_8>, I32, addrgp, S2_storerbgp>;
3557 def: Storea_pat<SwapSt<atomic_store_16>, I32, addrgp, S2_storerhgp>;
3558 def: Storea_pat<SwapSt<atomic_store_32>, I32, addrgp, S2_storerigp>;
3559 def: Storea_pat<SwapSt<atomic_store_64>, I64, addrgp, S2_storerdgp>;
3561 let AddedComplexity = 100 in {
3562 def: Storea_pat<truncstorei8, I32, addrgp, S2_storerbgp>;
3563 def: Storea_pat<truncstorei16, I32, addrgp, S2_storerhgp>;
3564 def: Storea_pat<store, I32, addrgp, S2_storerigp>;
3565 def: Storea_pat<store, I64, addrgp, S2_storerdgp>;
3567 // Map from "i1 = constant<-1>; memw(CONST32(#foo)) = i1"
3568 // to "r0 = 1; memw(#foo) = r0"
3569 let AddedComplexity = 100 in
3570 def: Pat<(store (i1 -1), (HexagonCONST32_GP tglobaladdr:$global)),
3571 (S2_storerbgp tglobaladdr:$global, (A2_tfrsi 1))>;
3574 //===----------------------------------------------------------------------===//
3575 // Template class for non predicated load instructions with
3576 // absolute addressing mode.
3577 //===----------------------------------------------------------------------===//
3578 let isPredicable = 1, hasSideEffects = 0, validSubTargets = HasV4SubT in
3579 class T_LoadAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3580 bits<3> MajOp, Operand AddrOp, bit isAbs>
3581 : LDInst <(outs RC:$dst), (ins AddrOp:$addr),
3582 "$dst = "#mnemonic# !if(isAbs, "(##", "(#")#"$addr)",
3583 [], "", V2LDST_tc_ld_SLOT01> {
3586 bits<16> offsetBits;
3588 string ImmOpStr = !cast<string>(ImmOp);
3589 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3590 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3591 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3592 /* u16_0Imm */ addr{15-0})));
3594 let IClass = 0b0100;
3597 let Inst{26-25} = offsetBits{15-14};
3599 let Inst{23-21} = MajOp;
3600 let Inst{20-16} = offsetBits{13-9};
3601 let Inst{13-5} = offsetBits{8-0};
3602 let Inst{4-0} = dst;
3605 class T_LoadAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3607 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, u0AlwaysExt, 1>, AddrModeRel {
3609 string ImmOpStr = !cast<string>(ImmOp);
3610 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3611 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3612 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3613 /* u16_0Imm */ 16)));
3615 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3616 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3617 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3618 /* u16_0Imm */ 0)));
3621 //===----------------------------------------------------------------------===//
3622 // Template class for predicated load instructions with
3623 // absolute addressing mode.
3624 //===----------------------------------------------------------------------===//
3625 let isPredicated = 1, opExtentBits = 6, opExtendable = 2 in
3626 class T_LoadAbs_Pred <string mnemonic, RegisterClass RC, bits<3> MajOp,
3627 bit isPredNot, bit isPredNew>
3628 : LDInst <(outs RC:$dst), (ins PredRegs:$src1, u6Ext:$absaddr),
3629 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3630 ") ")#"$dst = "#mnemonic#"(#$absaddr)">, AddrModeRel {
3635 let isPredicatedNew = isPredNew;
3636 let isPredicatedFalse = isPredNot;
3637 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
3639 let IClass = 0b1001;
3641 let Inst{27-24} = 0b1111;
3642 let Inst{23-21} = MajOp;
3643 let Inst{20-16} = absaddr{5-1};
3645 let Inst{12} = isPredNew;
3646 let Inst{11} = isPredNot;
3647 let Inst{10-9} = src1;
3648 let Inst{8} = absaddr{0};
3650 let Inst{4-0} = dst;
3653 //===----------------------------------------------------------------------===//
3654 // Multiclass for the load instructions with absolute addressing mode.
3655 //===----------------------------------------------------------------------===//
3656 multiclass LD_Abs_Pred<string mnemonic, RegisterClass RC, bits<3> MajOp,
3658 def _abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 0>;
3660 def new_abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 1>;
3663 let addrMode = Absolute, isExtended = 1 in
3664 multiclass LD_Abs<string mnemonic, string CextOp, RegisterClass RC,
3665 Operand ImmOp, bits<3> MajOp> {
3666 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3667 let opExtendable = 1, isPredicable = 1 in
3668 def L4_#NAME#_abs: T_LoadAbs <mnemonic, RC, ImmOp, MajOp>;
3671 defm L4_p#NAME#t : LD_Abs_Pred<mnemonic, RC, MajOp, 0>;
3672 defm L4_p#NAME#f : LD_Abs_Pred<mnemonic, RC, MajOp, 1>;
3676 let accessSize = ByteAccess, hasNewValue = 1 in {
3677 defm loadrb : LD_Abs<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3678 defm loadrub : LD_Abs<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3681 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3682 defm loadrh : LD_Abs<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3683 defm loadruh : LD_Abs<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3686 let accessSize = WordAccess, hasNewValue = 1 in
3687 defm loadri : LD_Abs<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3689 let accessSize = DoubleWordAccess in
3690 defm loadrd : LD_Abs<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3692 //===----------------------------------------------------------------------===//
3693 // multiclass for load instructions with GP-relative addressing mode.
3694 // Rx=mem[bhwd](##global)
3695 // Once predicated, these instructions map to absolute addressing mode.
3696 // if ([!]Pv[.new]) Rx=mem[bhwd](##global)
3697 //===----------------------------------------------------------------------===//
3699 let isAsmParserOnly = 1 in
3700 class T_LoadGP <string mnemonic, string BaseOp, RegisterClass RC, Operand ImmOp,
3702 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0>, PredNewRel {
3703 let BaseOpcode = BaseOp#_abs;
3706 let accessSize = ByteAccess, hasNewValue = 1 in {
3707 def L2_loadrbgp : T_LoadGP<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3708 def L2_loadrubgp : T_LoadGP<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3711 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3712 def L2_loadrhgp : T_LoadGP<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3713 def L2_loadruhgp : T_LoadGP<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3716 let accessSize = WordAccess, hasNewValue = 1 in
3717 def L2_loadrigp : T_LoadGP<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3719 let accessSize = DoubleWordAccess in
3720 def L2_loadrdgp : T_LoadGP<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3722 def: Loada_pat<atomic_load_8, i32, addrgp, L2_loadrubgp>;
3723 def: Loada_pat<atomic_load_16, i32, addrgp, L2_loadruhgp>;
3724 def: Loada_pat<atomic_load_32, i32, addrgp, L2_loadrigp>;
3725 def: Loada_pat<atomic_load_64, i64, addrgp, L2_loadrdgp>;
3727 // Map from load(globaladdress) -> mem[u][bhwd](#foo)
3728 class LoadGP_pats <PatFrag ldOp, InstHexagon MI, ValueType VT = i32>
3729 : Pat <(VT (ldOp (HexagonCONST32_GP tglobaladdr:$global))),
3730 (VT (MI tglobaladdr:$global))>;
3732 let AddedComplexity = 100 in {
3733 def: LoadGP_pats <extloadi8, L2_loadrbgp>;
3734 def: LoadGP_pats <sextloadi8, L2_loadrbgp>;
3735 def: LoadGP_pats <zextloadi8, L2_loadrubgp>;
3736 def: LoadGP_pats <extloadi16, L2_loadrhgp>;
3737 def: LoadGP_pats <sextloadi16, L2_loadrhgp>;
3738 def: LoadGP_pats <zextloadi16, L2_loadruhgp>;
3739 def: LoadGP_pats <load, L2_loadrigp>;
3740 def: LoadGP_pats <load, L2_loadrdgp, i64>;
3743 // When the Interprocedural Global Variable optimizer realizes that a certain
3744 // global variable takes only two constant values, it shrinks the global to
3745 // a boolean. Catch those loads here in the following 3 patterns.
3746 let AddedComplexity = 100 in {
3747 def: LoadGP_pats <extloadi1, L2_loadrubgp>;
3748 def: LoadGP_pats <zextloadi1, L2_loadrubgp>;
3751 def: Pat<(i64 (ctlz I64:$src1)), (Zext64 (S2_cl0p I64:$src1))>;
3752 def: Pat<(i64 (cttz I64:$src1)), (Zext64 (S2_ct0p I64:$src1))>;
3754 let AddedComplexity = 30 in {
3755 def: Storea_pat<truncstorei8, I32, u0AlwaysExtPred, S2_storerbabs>;
3756 def: Storea_pat<truncstorei16, I32, u0AlwaysExtPred, S2_storerhabs>;
3757 def: Storea_pat<store, I32, u0AlwaysExtPred, S2_storeriabs>;
3760 let AddedComplexity = 30 in {
3761 def: Loada_pat<load, i32, u0AlwaysExtPred, L4_loadri_abs>;
3762 def: Loada_pat<sextloadi8, i32, u0AlwaysExtPred, L4_loadrb_abs>;
3763 def: Loada_pat<zextloadi8, i32, u0AlwaysExtPred, L4_loadrub_abs>;
3764 def: Loada_pat<sextloadi16, i32, u0AlwaysExtPred, L4_loadrh_abs>;
3765 def: Loada_pat<zextloadi16, i32, u0AlwaysExtPred, L4_loadruh_abs>;
3768 // Indexed store word - global address.
3769 // memw(Rs+#u6:2)=#S8
3770 let AddedComplexity = 100 in
3771 def: Storex_add_pat<store, addrga, u6_2ImmPred, S4_storeiri_io>;
3773 // Load from a global address that has only one use in the current basic block.
3774 let AddedComplexity = 100 in {
3775 def: Loada_pat<extloadi8, i32, addrga, L4_loadrub_abs>;
3776 def: Loada_pat<sextloadi8, i32, addrga, L4_loadrb_abs>;
3777 def: Loada_pat<zextloadi8, i32, addrga, L4_loadrub_abs>;
3779 def: Loada_pat<extloadi16, i32, addrga, L4_loadruh_abs>;
3780 def: Loada_pat<sextloadi16, i32, addrga, L4_loadrh_abs>;
3781 def: Loada_pat<zextloadi16, i32, addrga, L4_loadruh_abs>;
3783 def: Loada_pat<load, i32, addrga, L4_loadri_abs>;
3784 def: Loada_pat<load, i64, addrga, L4_loadrd_abs>;
3787 // Store to a global address that has only one use in the current basic block.
3788 let AddedComplexity = 100 in {
3789 def: Storea_pat<truncstorei8, I32, addrga, S2_storerbabs>;
3790 def: Storea_pat<truncstorei16, I32, addrga, S2_storerhabs>;
3791 def: Storea_pat<store, I32, addrga, S2_storeriabs>;
3792 def: Storea_pat<store, I64, addrga, S2_storerdabs>;
3794 def: Stoream_pat<truncstorei32, I64, addrga, LoReg, S2_storeriabs>;
3797 // Map from Pd = load(globaladdress) -> Rd = memb(globaladdress), Pd = Rd
3798 let AddedComplexity = 100 in
3799 def : Pat <(i1 (load (HexagonCONST32_GP tglobaladdr:$global))),
3800 (i1 (C2_tfrrp (i32 (L2_loadrbgp tglobaladdr:$global))))>;
3802 // Transfer global address into a register
3803 let isExtended = 1, opExtendable = 1, AddedComplexity=50, isMoveImm = 1,
3804 isAsCheapAsAMove = 1, isReMaterializable = 1, validSubTargets = HasV4SubT,
3805 isCodeGenOnly = 1 in
3806 def TFRI_V4 : ALU32_ri<(outs IntRegs:$dst), (ins s16Ext:$src1),
3808 [(set IntRegs:$dst, (HexagonCONST32 tglobaladdr:$src1))]>,
3811 // Transfer a block address into a register
3812 def : Pat<(HexagonCONST32_GP tblockaddress:$src1),
3813 (TFRI_V4 tblockaddress:$src1)>,
3816 let AddedComplexity = 50, Predicates = [HasV4T] in
3817 def : Pat<(HexagonCONST32_GP tglobaladdr:$src1),
3818 (TFRI_V4 tglobaladdr:$src1)>,
3821 // i8/i16/i32 -> i64 loads
3822 // We need a complexity of 120 here to override preceding handling of
3824 let AddedComplexity = 120 in {
3825 def: Loadam_pat<extloadi8, i64, addrga, Zext64, L4_loadrub_abs>;
3826 def: Loadam_pat<sextloadi8, i64, addrga, Sext64, L4_loadrb_abs>;
3827 def: Loadam_pat<zextloadi8, i64, addrga, Zext64, L4_loadrub_abs>;
3829 def: Loadam_pat<extloadi16, i64, addrga, Zext64, L4_loadruh_abs>;
3830 def: Loadam_pat<sextloadi16, i64, addrga, Sext64, L4_loadrh_abs>;
3831 def: Loadam_pat<zextloadi16, i64, addrga, Zext64, L4_loadruh_abs>;
3833 def: Loadam_pat<extloadi32, i64, addrga, Zext64, L4_loadri_abs>;
3834 def: Loadam_pat<sextloadi32, i64, addrga, Sext64, L4_loadri_abs>;
3835 def: Loadam_pat<zextloadi32, i64, addrga, Zext64, L4_loadri_abs>;
3838 let AddedComplexity = 100 in {
3839 def: Loada_pat<extloadi8, i32, addrgp, L4_loadrub_abs>;
3840 def: Loada_pat<sextloadi8, i32, addrgp, L4_loadrb_abs>;
3841 def: Loada_pat<zextloadi8, i32, addrgp, L4_loadrub_abs>;
3843 def: Loada_pat<extloadi16, i32, addrgp, L4_loadruh_abs>;
3844 def: Loada_pat<sextloadi16, i32, addrgp, L4_loadrh_abs>;
3845 def: Loada_pat<zextloadi16, i32, addrgp, L4_loadruh_abs>;
3847 def: Loada_pat<load, i32, addrgp, L4_loadri_abs>;
3848 def: Loada_pat<load, i64, addrgp, L4_loadrd_abs>;
3851 let AddedComplexity = 100 in {
3852 def: Storea_pat<truncstorei8, I32, addrgp, S2_storerbabs>;
3853 def: Storea_pat<truncstorei16, I32, addrgp, S2_storerhabs>;
3854 def: Storea_pat<store, I32, addrgp, S2_storeriabs>;
3855 def: Storea_pat<store, I64, addrgp, S2_storerdabs>;
3858 def: Loada_pat<atomic_load_8, i32, addrgp, L4_loadrub_abs>;
3859 def: Loada_pat<atomic_load_16, i32, addrgp, L4_loadruh_abs>;
3860 def: Loada_pat<atomic_load_32, i32, addrgp, L4_loadri_abs>;
3861 def: Loada_pat<atomic_load_64, i64, addrgp, L4_loadrd_abs>;
3863 def: Storea_pat<SwapSt<atomic_store_8>, I32, addrgp, S2_storerbabs>;
3864 def: Storea_pat<SwapSt<atomic_store_16>, I32, addrgp, S2_storerhabs>;
3865 def: Storea_pat<SwapSt<atomic_store_32>, I32, addrgp, S2_storeriabs>;
3866 def: Storea_pat<SwapSt<atomic_store_64>, I64, addrgp, S2_storerdabs>;
3868 //===----------------------------------------------------------------------===//
3869 // :raw for of boundscheck:hi:lo insns
3870 //===----------------------------------------------------------------------===//
3872 // A4_boundscheck_lo: Detect if a register is within bounds.
3873 let hasSideEffects = 0 in
3874 def A4_boundscheck_lo: ALU64Inst <
3875 (outs PredRegs:$Pd),
3876 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3877 "$Pd = boundscheck($Rss, $Rtt):raw:lo"> {
3882 let IClass = 0b1101;
3884 let Inst{27-23} = 0b00100;
3886 let Inst{7-5} = 0b100;
3888 let Inst{20-16} = Rss;
3889 let Inst{12-8} = Rtt;
3892 // A4_boundscheck_hi: Detect if a register is within bounds.
3893 let hasSideEffects = 0 in
3894 def A4_boundscheck_hi: ALU64Inst <
3895 (outs PredRegs:$Pd),
3896 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3897 "$Pd = boundscheck($Rss, $Rtt):raw:hi"> {
3902 let IClass = 0b1101;
3904 let Inst{27-23} = 0b00100;
3906 let Inst{7-5} = 0b101;
3908 let Inst{20-16} = Rss;
3909 let Inst{12-8} = Rtt;
3912 let hasSideEffects = 0, isAsmParserOnly = 1 in
3913 def A4_boundscheck : MInst <
3914 (outs PredRegs:$Pd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
3915 "$Pd=boundscheck($Rs,$Rtt)">;
3917 // A4_tlbmatch: Detect if a VA/ASID matches a TLB entry.
3918 let isPredicateLate = 1, hasSideEffects = 0 in
3919 def A4_tlbmatch : ALU64Inst<(outs PredRegs:$Pd),
3920 (ins DoubleRegs:$Rs, IntRegs:$Rt),
3921 "$Pd = tlbmatch($Rs, $Rt)",
3922 [], "", ALU64_tc_2early_SLOT23> {
3927 let IClass = 0b1101;
3928 let Inst{27-23} = 0b00100;
3929 let Inst{20-16} = Rs;
3931 let Inst{12-8} = Rt;
3932 let Inst{7-5} = 0b011;
3936 // We need custom lowering of ISD::PREFETCH into HexagonISD::DCFETCH
3937 // because the SDNode ISD::PREFETCH has properties MayLoad and MayStore.
3938 // We don't really want either one here.
3939 def SDTHexagonDCFETCH : SDTypeProfile<0, 2, [SDTCisPtrTy<0>,SDTCisInt<1>]>;
3940 def HexagonDCFETCH : SDNode<"HexagonISD::DCFETCH", SDTHexagonDCFETCH,
3943 // Use LD0Inst for dcfetch, but set "mayLoad" to 0 because this doesn't
3944 // really do a load.
3945 let hasSideEffects = 1, mayLoad = 0 in
3946 def Y2_dcfetchbo : LD0Inst<(outs), (ins IntRegs:$Rs, u11_3Imm:$u11_3),
3947 "dcfetch($Rs + #$u11_3)",
3948 [(HexagonDCFETCH IntRegs:$Rs, u11_3ImmPred:$u11_3)],
3949 "", LD_tc_ld_SLOT0> {
3953 let IClass = 0b1001;
3954 let Inst{27-21} = 0b0100000;
3955 let Inst{20-16} = Rs;
3957 let Inst{10-0} = u11_3{13-3};
3960 //===----------------------------------------------------------------------===//
3961 // Compound instructions
3962 //===----------------------------------------------------------------------===//
3964 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
3965 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1,
3966 opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
3967 isTerminator = 1, validSubTargets = HasV4SubT in
3968 class CJInst_tstbit_R0<string px, bit np, string tnt>
3969 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
3970 ""#px#" = tstbit($Rs, #0); if ("
3971 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
3972 [], "", COMPOUND, TypeCOMPOUND> {
3977 let isPredicatedFalse = np;
3978 // tnt: Taken/Not Taken
3979 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
3980 let isTaken = !if (!eq(tnt, "t"), 1, 0);
3982 let IClass = 0b0001;
3983 let Inst{27-26} = 0b00;
3984 let Inst{25} = !if (!eq(px, "!p1"), 1,
3985 !if (!eq(px, "p1"), 1, 0));
3986 let Inst{24-23} = 0b11;
3988 let Inst{21-20} = r9_2{10-9};
3989 let Inst{19-16} = Rs;
3990 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
3991 let Inst{9-8} = 0b11;
3992 let Inst{7-1} = r9_2{8-2};
3995 let Defs = [PC, P0], Uses = [P0] in {
3996 def J4_tstbit0_tp0_jump_nt : CJInst_tstbit_R0<"p0", 0, "nt">;
3997 def J4_tstbit0_tp0_jump_t : CJInst_tstbit_R0<"p0", 0, "t">;
3998 def J4_tstbit0_fp0_jump_nt : CJInst_tstbit_R0<"p0", 1, "nt">;
3999 def J4_tstbit0_fp0_jump_t : CJInst_tstbit_R0<"p0", 1, "t">;
4002 let Defs = [PC, P1], Uses = [P1] in {
4003 def J4_tstbit0_tp1_jump_nt : CJInst_tstbit_R0<"p1", 0, "nt">;
4004 def J4_tstbit0_tp1_jump_t : CJInst_tstbit_R0<"p1", 0, "t">;
4005 def J4_tstbit0_fp1_jump_nt : CJInst_tstbit_R0<"p1", 1, "nt">;
4006 def J4_tstbit0_fp1_jump_t : CJInst_tstbit_R0<"p1", 1, "t">;
4010 let isBranch = 1, hasSideEffects = 0,
4011 isExtentSigned = 1, isPredicated = 1, isPredicatedNew = 1,
4012 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2,
4013 opExtendable = 2, isTerminator = 1, validSubTargets = HasV4SubT in
4014 class CJInst_RR<string px, string op, bit np, string tnt>
4015 : InstHexagon<(outs), (ins IntRegs:$Rs, IntRegs:$Rt, brtarget:$r9_2),
4016 ""#px#" = cmp."#op#"($Rs, $Rt); if ("
4017 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4018 [], "", COMPOUND, TypeCOMPOUND> {
4024 let isPredicatedFalse = np;
4025 // tnt: Taken/Not Taken
4026 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4027 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4029 let IClass = 0b0001;
4030 let Inst{27-23} = !if (!eq(op, "eq"), 0b01000,
4031 !if (!eq(op, "gt"), 0b01001,
4032 !if (!eq(op, "gtu"), 0b01010, 0)));
4034 let Inst{21-20} = r9_2{10-9};
4035 let Inst{19-16} = Rs;
4036 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4037 // px: Predicate reg 0/1
4038 let Inst{12} = !if (!eq(px, "!p1"), 1,
4039 !if (!eq(px, "p1"), 1, 0));
4040 let Inst{11-8} = Rt;
4041 let Inst{7-1} = r9_2{8-2};
4044 // P[10] taken/not taken.
4045 multiclass T_tnt_CJInst_RR<string op, bit np> {
4046 let Defs = [PC, P0], Uses = [P0] in {
4047 def NAME#p0_jump_nt : CJInst_RR<"p0", op, np, "nt">;
4048 def NAME#p0_jump_t : CJInst_RR<"p0", op, np, "t">;
4050 let Defs = [PC, P1], Uses = [P1] in {
4051 def NAME#p1_jump_nt : CJInst_RR<"p1", op, np, "nt">;
4052 def NAME#p1_jump_t : CJInst_RR<"p1", op, np, "t">;
4055 // Predicate / !Predicate
4056 multiclass T_pnp_CJInst_RR<string op>{
4057 defm J4_cmp#NAME#_t : T_tnt_CJInst_RR<op, 0>;
4058 defm J4_cmp#NAME#_f : T_tnt_CJInst_RR<op, 1>;
4060 // TypeCJ Instructions compare RR and jump
4061 defm eq : T_pnp_CJInst_RR<"eq">;
4062 defm gt : T_pnp_CJInst_RR<"gt">;
4063 defm gtu : T_pnp_CJInst_RR<"gtu">;
4065 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4066 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1, opExtentBits = 11,
4067 opExtentAlign = 2, opExtendable = 2, isTerminator = 1,
4068 validSubTargets = HasV4SubT in
4069 class CJInst_RU5<string px, string op, bit np, string tnt>
4070 : InstHexagon<(outs), (ins IntRegs:$Rs, u5Imm:$U5, brtarget:$r9_2),
4071 ""#px#" = cmp."#op#"($Rs, #$U5); if ("
4072 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4073 [], "", COMPOUND, TypeCOMPOUND> {
4079 let isPredicatedFalse = np;
4080 // tnt: Taken/Not Taken
4081 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4082 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4084 let IClass = 0b0001;
4085 let Inst{27-26} = 0b00;
4086 // px: Predicate reg 0/1
4087 let Inst{25} = !if (!eq(px, "!p1"), 1,
4088 !if (!eq(px, "p1"), 1, 0));
4089 let Inst{24-23} = !if (!eq(op, "eq"), 0b00,
4090 !if (!eq(op, "gt"), 0b01,
4091 !if (!eq(op, "gtu"), 0b10, 0)));
4093 let Inst{21-20} = r9_2{10-9};
4094 let Inst{19-16} = Rs;
4095 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4096 let Inst{12-8} = U5;
4097 let Inst{7-1} = r9_2{8-2};
4099 // P[10] taken/not taken.
4100 multiclass T_tnt_CJInst_RU5<string op, bit np> {
4101 let Defs = [PC, P0], Uses = [P0] in {
4102 def NAME#p0_jump_nt : CJInst_RU5<"p0", op, np, "nt">;
4103 def NAME#p0_jump_t : CJInst_RU5<"p0", op, np, "t">;
4105 let Defs = [PC, P1], Uses = [P1] in {
4106 def NAME#p1_jump_nt : CJInst_RU5<"p1", op, np, "nt">;
4107 def NAME#p1_jump_t : CJInst_RU5<"p1", op, np, "t">;
4110 // Predicate / !Predicate
4111 multiclass T_pnp_CJInst_RU5<string op>{
4112 defm J4_cmp#NAME#i_t : T_tnt_CJInst_RU5<op, 0>;
4113 defm J4_cmp#NAME#i_f : T_tnt_CJInst_RU5<op, 1>;
4115 // TypeCJ Instructions compare RI and jump
4116 defm eq : T_pnp_CJInst_RU5<"eq">;
4117 defm gt : T_pnp_CJInst_RU5<"gt">;
4118 defm gtu : T_pnp_CJInst_RU5<"gtu">;
4120 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4121 isPredicated = 1, isPredicatedFalse = 1, isPredicatedNew = 1,
4122 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
4123 isTerminator = 1, validSubTargets = HasV4SubT in
4124 class CJInst_Rn1<string px, string op, bit np, string tnt>
4125 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
4126 ""#px#" = cmp."#op#"($Rs,#-1); if ("
4127 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4128 [], "", COMPOUND, TypeCOMPOUND> {
4133 let isPredicatedFalse = np;
4134 // tnt: Taken/Not Taken
4135 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4136 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4138 let IClass = 0b0001;
4139 let Inst{27-26} = 0b00;
4140 let Inst{25} = !if (!eq(px, "!p1"), 1,
4141 !if (!eq(px, "p1"), 1, 0));
4143 let Inst{24-23} = 0b11;
4145 let Inst{21-20} = r9_2{10-9};
4146 let Inst{19-16} = Rs;
4147 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4148 let Inst{9-8} = !if (!eq(op, "eq"), 0b00,
4149 !if (!eq(op, "gt"), 0b01, 0));
4150 let Inst{7-1} = r9_2{8-2};
4153 // P[10] taken/not taken.
4154 multiclass T_tnt_CJInst_Rn1<string op, bit np> {
4155 let Defs = [PC, P0], Uses = [P0] in {
4156 def NAME#p0_jump_nt : CJInst_Rn1<"p0", op, np, "nt">;
4157 def NAME#p0_jump_t : CJInst_Rn1<"p0", op, np, "t">;
4159 let Defs = [PC, P1], Uses = [P1] in {
4160 def NAME#p1_jump_nt : CJInst_Rn1<"p1", op, np, "nt">;
4161 def NAME#p1_jump_t : CJInst_Rn1<"p1", op, np, "t">;
4164 // Predicate / !Predicate
4165 multiclass T_pnp_CJInst_Rn1<string op>{
4166 defm J4_cmp#NAME#n1_t : T_tnt_CJInst_Rn1<op, 0>;
4167 defm J4_cmp#NAME#n1_f : T_tnt_CJInst_Rn1<op, 1>;
4169 // TypeCJ Instructions compare -1 and jump
4170 defm eq : T_pnp_CJInst_Rn1<"eq">;
4171 defm gt : T_pnp_CJInst_Rn1<"gt">;
4173 // J4_jumpseti: Direct unconditional jump and set register to immediate.
4174 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4175 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4176 opExtentAlign = 2, opExtendable = 2, validSubTargets = HasV4SubT in
4177 def J4_jumpseti: CJInst <
4179 (ins u6Imm:$U6, brtarget:$r9_2),
4180 "$Rd = #$U6 ; jump $r9_2"> {
4185 let IClass = 0b0001;
4186 let Inst{27-24} = 0b0110;
4187 let Inst{21-20} = r9_2{10-9};
4188 let Inst{19-16} = Rd;
4189 let Inst{13-8} = U6;
4190 let Inst{7-1} = r9_2{8-2};
4193 // J4_jumpsetr: Direct unconditional jump and transfer register.
4194 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4195 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4196 opExtentAlign = 2, opExtendable = 2, validSubTargets = HasV4SubT in
4197 def J4_jumpsetr: CJInst <
4199 (ins IntRegs:$Rs, brtarget:$r9_2),
4200 "$Rd = $Rs ; jump $r9_2"> {
4205 let IClass = 0b0001;
4206 let Inst{27-24} = 0b0111;
4207 let Inst{21-20} = r9_2{10-9};
4208 let Inst{11-8} = Rd;
4209 let Inst{19-16} = Rs;
4210 let Inst{7-1} = r9_2{8-2};