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 DuplexIClass0: InstDuplex < 0 >;
15 def DuplexIClass1: InstDuplex < 1 >;
16 def DuplexIClass2: InstDuplex < 2 >;
17 let isExtendable = 1 in {
18 def DuplexIClass3: InstDuplex < 3 >;
19 def DuplexIClass4: InstDuplex < 4 >;
20 def DuplexIClass5: InstDuplex < 5 >;
21 def DuplexIClass6: InstDuplex < 6 >;
22 def DuplexIClass7: InstDuplex < 7 >;
24 def DuplexIClass8: InstDuplex < 8 >;
25 def DuplexIClass9: InstDuplex < 9 >;
26 def DuplexIClassA: InstDuplex < 0xA >;
27 def DuplexIClassB: InstDuplex < 0xB >;
28 def DuplexIClassC: InstDuplex < 0xC >;
29 def DuplexIClassD: InstDuplex < 0xD >;
30 def DuplexIClassE: InstDuplex < 0xE >;
31 def DuplexIClassF: InstDuplex < 0xF >;
33 def addrga: PatLeaf<(i32 AddrGA:$Addr)>;
34 def addrgp: PatLeaf<(i32 AddrGP:$Addr)>;
36 let hasSideEffects = 0 in
37 class T_Immext<Operand ImmType>
38 : EXTENDERInst<(outs), (ins ImmType:$imm),
39 "immext(#$imm)", []> {
43 let Inst{27-16} = imm{31-20};
44 let Inst{13-0} = imm{19-6};
47 def A4_ext : T_Immext<u26_6Imm>;
48 let isCodeGenOnly = 1 in {
50 def A4_ext_b : T_Immext<brtarget>;
52 def A4_ext_c : T_Immext<calltarget>;
53 def A4_ext_g : T_Immext<globaladdress>;
56 def BITPOS32 : SDNodeXForm<imm, [{
57 // Return the bit position we will set [0-31].
59 int32_t imm = N->getSExtValue();
60 return XformMskToBitPosU5Imm(imm);
63 // Hexagon V4 Architecture spec defines 8 instruction classes:
64 // LD ST ALU32 XTYPE J JR MEMOP NV CR SYSTEM(system is not implemented in the
68 // ========================================
69 // Loads (8/16/32/64 bit)
73 // ========================================
74 // Stores (8/16/32/64 bit)
77 // ALU32 Instructions:
78 // ========================================
79 // Arithmetic / Logical (32 bit)
82 // XTYPE Instructions (32/64 bit):
83 // ========================================
84 // Arithmetic, Logical, Bit Manipulation
85 // Multiply (Integer, Fractional, Complex)
86 // Permute / Vector Permute Operations
87 // Predicate Operations
88 // Shift / Shift with Add/Sub/Logical
90 // Vector Halfword (ALU, Shift, Multiply)
91 // Vector Word (ALU, Shift)
94 // ========================================
95 // Jump/Call PC-relative
98 // ========================================
101 // MEMOP Instructions:
102 // ========================================
103 // Operation on memory (8/16/32 bit)
106 // ========================================
111 // ========================================
112 // Control-Register Transfers
113 // Hardware Loop Setup
114 // Predicate Logicals & Reductions
116 // SYSTEM Instructions (not implemented in the compiler):
117 // ========================================
123 //===----------------------------------------------------------------------===//
125 //===----------------------------------------------------------------------===//
127 class T_ALU32_3op_not<string mnemonic, bits<3> MajOp, bits<3> MinOp,
129 : T_ALU32_3op<mnemonic, MajOp, MinOp, OpsRev, 0> {
130 let AsmString = "$Rd = "#mnemonic#"($Rs, ~$Rt)";
133 let BaseOpcode = "andn_rr", CextOpcode = "andn" in
134 def A4_andn : T_ALU32_3op_not<"and", 0b001, 0b100, 1>;
135 let BaseOpcode = "orn_rr", CextOpcode = "orn" in
136 def A4_orn : T_ALU32_3op_not<"or", 0b001, 0b101, 1>;
138 let CextOpcode = "rcmp.eq" in
139 def A4_rcmpeq : T_ALU32_3op<"cmp.eq", 0b011, 0b010, 0, 1>;
140 let CextOpcode = "!rcmp.eq" in
141 def A4_rcmpneq : T_ALU32_3op<"!cmp.eq", 0b011, 0b011, 0, 1>;
143 def C4_cmpneq : T_ALU32_3op_cmp<"!cmp.eq", 0b00, 1, 1>;
144 def C4_cmplte : T_ALU32_3op_cmp<"!cmp.gt", 0b10, 1, 0>;
145 def C4_cmplteu : T_ALU32_3op_cmp<"!cmp.gtu", 0b11, 1, 0>;
147 // Pats for instruction selection.
149 // A class to embed the usual comparison patfrags within a zext to i32.
150 // The seteq/setne frags use "lhs" and "rhs" as operands, so use the same
151 // names, or else the frag's "body" won't match the operands.
152 class CmpInReg<PatFrag Op>
153 : PatFrag<(ops node:$lhs, node:$rhs),(i32 (zext (i1 Op.Fragment)))>;
155 def: T_cmp32_rr_pat<A4_rcmpeq, CmpInReg<seteq>, i32>;
156 def: T_cmp32_rr_pat<A4_rcmpneq, CmpInReg<setne>, i32>;
158 def: T_cmp32_rr_pat<C4_cmpneq, setne, i1>;
159 def: T_cmp32_rr_pat<C4_cmplteu, setule, i1>;
161 def: T_cmp32_rr_pat<C4_cmplteu, RevCmp<setuge>, i1>;
163 class T_CMP_rrbh<string mnemonic, bits<3> MinOp, bit IsComm>
164 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
165 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", S_3op_tc_2early_SLOT23>,
167 let InputType = "reg";
168 let CextOpcode = mnemonic;
170 let isCommutable = IsComm;
171 let hasSideEffects = 0;
178 let Inst{27-21} = 0b0111110;
179 let Inst{20-16} = Rs;
181 let Inst{7-5} = MinOp;
185 def A4_cmpbeq : T_CMP_rrbh<"cmpb.eq", 0b110, 1>;
186 def A4_cmpbgt : T_CMP_rrbh<"cmpb.gt", 0b010, 0>;
187 def A4_cmpbgtu : T_CMP_rrbh<"cmpb.gtu", 0b111, 0>;
188 def A4_cmpheq : T_CMP_rrbh<"cmph.eq", 0b011, 1>;
189 def A4_cmphgt : T_CMP_rrbh<"cmph.gt", 0b100, 0>;
190 def A4_cmphgtu : T_CMP_rrbh<"cmph.gtu", 0b101, 0>;
192 let AddedComplexity = 100 in {
193 def: Pat<(i1 (seteq (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
195 (A4_cmpbeq IntRegs:$Rs, IntRegs:$Rt)>;
196 def: Pat<(i1 (setne (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
198 (C2_not (A4_cmpbeq IntRegs:$Rs, IntRegs:$Rt))>;
199 def: Pat<(i1 (seteq (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
201 (A4_cmpheq IntRegs:$Rs, IntRegs:$Rt)>;
202 def: Pat<(i1 (setne (and (xor (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)),
204 (C2_not (A4_cmpheq IntRegs:$Rs, IntRegs:$Rt))>;
207 class T_CMP_ribh<string mnemonic, bits<2> MajOp, bit IsHalf, bit IsComm,
208 Operand ImmType, bit IsImmExt, bit IsImmSigned, int ImmBits>
209 : ALU64Inst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, ImmType:$Imm),
210 "$Pd = "#mnemonic#"($Rs, #$Imm)", [], "", ALU64_tc_2early_SLOT23>,
212 let InputType = "imm";
213 let CextOpcode = mnemonic;
215 let isCommutable = IsComm;
216 let hasSideEffects = 0;
217 let isExtendable = IsImmExt;
218 let opExtendable = !if (IsImmExt, 2, 0);
219 let isExtentSigned = IsImmSigned;
220 let opExtentBits = ImmBits;
227 let Inst{27-24} = 0b1101;
228 let Inst{22-21} = MajOp;
229 let Inst{20-16} = Rs;
230 let Inst{12-5} = Imm;
232 let Inst{3} = IsHalf;
236 def A4_cmpbeqi : T_CMP_ribh<"cmpb.eq", 0b00, 0, 1, u8Imm, 0, 0, 8>;
237 def A4_cmpbgti : T_CMP_ribh<"cmpb.gt", 0b01, 0, 0, s8Imm, 0, 1, 8>;
238 def A4_cmpbgtui : T_CMP_ribh<"cmpb.gtu", 0b10, 0, 0, u7Ext, 1, 0, 7>;
239 def A4_cmpheqi : T_CMP_ribh<"cmph.eq", 0b00, 1, 1, s8Ext, 1, 1, 8>;
240 def A4_cmphgti : T_CMP_ribh<"cmph.gt", 0b01, 1, 0, s8Ext, 1, 1, 8>;
241 def A4_cmphgtui : T_CMP_ribh<"cmph.gtu", 0b10, 1, 0, u7Ext, 1, 0, 7>;
243 class T_RCMP_EQ_ri<string mnemonic, bit IsNeg>
244 : ALU32_ri<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s8Ext:$s8),
245 "$Rd = "#mnemonic#"($Rs, #$s8)", [], "", ALU32_2op_tc_1_SLOT0123>,
247 let InputType = "imm";
248 let CextOpcode = !if (IsNeg, "!rcmp.eq", "rcmp.eq");
249 let isExtendable = 1;
250 let opExtendable = 2;
251 let isExtentSigned = 1;
252 let opExtentBits = 8;
260 let Inst{27-24} = 0b0011;
262 let Inst{21} = IsNeg;
263 let Inst{20-16} = Rs;
269 def A4_rcmpeqi : T_RCMP_EQ_ri<"cmp.eq", 0>;
270 def A4_rcmpneqi : T_RCMP_EQ_ri<"!cmp.eq", 1>;
272 def: Pat<(i32 (zext (i1 (seteq (i32 IntRegs:$Rs), s32ImmPred:$s8)))),
273 (A4_rcmpeqi IntRegs:$Rs, s32ImmPred:$s8)>;
274 def: Pat<(i32 (zext (i1 (setne (i32 IntRegs:$Rs), s32ImmPred:$s8)))),
275 (A4_rcmpneqi IntRegs:$Rs, s32ImmPred:$s8)>;
277 // Preserve the S2_tstbit_r generation
278 def: Pat<(i32 (zext (i1 (setne (i32 (and (i32 (shl 1, (i32 IntRegs:$src2))),
279 (i32 IntRegs:$src1))), 0)))),
280 (C2_muxii (S2_tstbit_r IntRegs:$src1, IntRegs:$src2), 1, 0)>;
282 //===----------------------------------------------------------------------===//
284 //===----------------------------------------------------------------------===//
287 //===----------------------------------------------------------------------===//
289 //===----------------------------------------------------------------------===//
291 // Combine a word and an immediate into a register pair.
292 let hasSideEffects = 0, isExtentSigned = 1, isExtendable = 1,
294 class T_Combine1 <bits<2> MajOp, dag ins, string AsmStr>
295 : ALU32Inst <(outs DoubleRegs:$Rdd), ins, AsmStr> {
301 let Inst{27-24} = 0b0011;
302 let Inst{22-21} = MajOp;
303 let Inst{20-16} = Rs;
309 let opExtendable = 2 in
310 def A4_combineri : T_Combine1<0b00, (ins IntRegs:$Rs, s8Ext:$s8),
311 "$Rdd = combine($Rs, #$s8)">;
313 let opExtendable = 1 in
314 def A4_combineir : T_Combine1<0b01, (ins s8Ext:$s8, IntRegs:$Rs),
315 "$Rdd = combine(#$s8, $Rs)">;
317 // The complexity of the combines involving immediates should be greater
318 // than the complexity of the combine with two registers.
319 let AddedComplexity = 50 in {
320 def: Pat<(HexagonCOMBINE IntRegs:$r, s32ImmPred:$i),
321 (A4_combineri IntRegs:$r, s32ImmPred:$i)>;
323 def: Pat<(HexagonCOMBINE s32ImmPred:$i, IntRegs:$r),
324 (A4_combineir s32ImmPred:$i, IntRegs:$r)>;
327 // A4_combineii: Set two small immediates.
328 let hasSideEffects = 0, isExtendable = 1, opExtentBits = 6, opExtendable = 2 in
329 def A4_combineii: ALU32Inst<(outs DoubleRegs:$Rdd), (ins s8Imm:$s8, u6Ext:$U6),
330 "$Rdd = combine(#$s8, #$U6)"> {
336 let Inst{27-23} = 0b11001;
337 let Inst{20-16} = U6{5-1};
338 let Inst{13} = U6{0};
343 // The complexity of the combine with two immediates should be greater than
344 // the complexity of a combine involving a register.
345 let AddedComplexity = 75 in
346 def: Pat<(HexagonCOMBINE s8ImmPred:$s8, u32ImmPred:$u6),
347 (A4_combineii imm:$s8, imm:$u6)>;
349 //===----------------------------------------------------------------------===//
351 //===----------------------------------------------------------------------===//
353 //===----------------------------------------------------------------------===//
355 //===----------------------------------------------------------------------===//
357 def Zext64: OutPatFrag<(ops node:$Rs),
358 (i64 (A4_combineir 0, (i32 $Rs)))>;
359 def Sext64: OutPatFrag<(ops node:$Rs),
360 (i64 (A2_sxtw (i32 $Rs)))>;
362 // Patterns to generate indexed loads with different forms of the address:
365 // - base (without offset).
366 multiclass Loadxm_pat<PatFrag Load, ValueType VT, PatFrag ValueMod,
367 PatLeaf ImmPred, InstHexagon MI> {
368 def: Pat<(VT (Load AddrFI:$fi)),
369 (VT (ValueMod (MI AddrFI:$fi, 0)))>;
370 def: Pat<(VT (Load (add AddrFI:$fi, ImmPred:$Off))),
371 (VT (ValueMod (MI AddrFI:$fi, imm:$Off)))>;
372 def: Pat<(VT (Load (add IntRegs:$Rs, ImmPred:$Off))),
373 (VT (ValueMod (MI IntRegs:$Rs, imm:$Off)))>;
374 def: Pat<(VT (Load (i32 IntRegs:$Rs))),
375 (VT (ValueMod (MI IntRegs:$Rs, 0)))>;
378 defm: Loadxm_pat<extloadi1, i64, Zext64, s32_0ImmPred, L2_loadrub_io>;
379 defm: Loadxm_pat<extloadi8, i64, Zext64, s32_0ImmPred, L2_loadrub_io>;
380 defm: Loadxm_pat<extloadi16, i64, Zext64, s31_1ImmPred, L2_loadruh_io>;
381 defm: Loadxm_pat<zextloadi1, i64, Zext64, s32_0ImmPred, L2_loadrub_io>;
382 defm: Loadxm_pat<zextloadi8, i64, Zext64, s32_0ImmPred, L2_loadrub_io>;
383 defm: Loadxm_pat<zextloadi16, i64, Zext64, s31_1ImmPred, L2_loadruh_io>;
384 defm: Loadxm_pat<sextloadi8, i64, Sext64, s32_0ImmPred, L2_loadrb_io>;
385 defm: Loadxm_pat<sextloadi16, i64, Sext64, s31_1ImmPred, L2_loadrh_io>;
387 // Map Rdd = anyext(Rs) -> Rdd = combine(#0, Rs).
388 def: Pat<(i64 (anyext (i32 IntRegs:$src1))), (Zext64 IntRegs:$src1)>;
390 //===----------------------------------------------------------------------===//
391 // Template class for load instructions with Absolute set addressing mode.
392 //===----------------------------------------------------------------------===//
393 let isExtended = 1, opExtendable = 2, opExtentBits = 6, addrMode = AbsoluteSet,
394 hasSideEffects = 0 in
395 class T_LD_abs_set<string mnemonic, RegisterClass RC, bits<4>MajOp>:
396 LDInst<(outs RC:$dst1, IntRegs:$dst2),
398 "$dst1 = "#mnemonic#"($dst2 = #$addr)",
406 let Inst{27-25} = 0b101;
407 let Inst{24-21} = MajOp;
408 let Inst{13-12} = 0b01;
409 let Inst{4-0} = dst1;
410 let Inst{20-16} = dst2;
411 let Inst{11-8} = addr{5-2};
412 let Inst{6-5} = addr{1-0};
415 let accessSize = ByteAccess, hasNewValue = 1 in {
416 def L4_loadrb_ap : T_LD_abs_set <"memb", IntRegs, 0b1000>;
417 def L4_loadrub_ap : T_LD_abs_set <"memub", IntRegs, 0b1001>;
420 let accessSize = HalfWordAccess, hasNewValue = 1 in {
421 def L4_loadrh_ap : T_LD_abs_set <"memh", IntRegs, 0b1010>;
422 def L4_loadruh_ap : T_LD_abs_set <"memuh", IntRegs, 0b1011>;
423 def L4_loadbsw2_ap : T_LD_abs_set <"membh", IntRegs, 0b0001>;
424 def L4_loadbzw2_ap : T_LD_abs_set <"memubh", IntRegs, 0b0011>;
427 let accessSize = WordAccess, hasNewValue = 1 in
428 def L4_loadri_ap : T_LD_abs_set <"memw", IntRegs, 0b1100>;
430 let accessSize = WordAccess in {
431 def L4_loadbzw4_ap : T_LD_abs_set <"memubh", DoubleRegs, 0b0101>;
432 def L4_loadbsw4_ap : T_LD_abs_set <"membh", DoubleRegs, 0b0111>;
435 let accessSize = DoubleWordAccess in
436 def L4_loadrd_ap : T_LD_abs_set <"memd", DoubleRegs, 0b1110>;
438 let accessSize = ByteAccess in
439 def L4_loadalignb_ap : T_LD_abs_set <"memb_fifo", DoubleRegs, 0b0100>;
441 let accessSize = HalfWordAccess in
442 def L4_loadalignh_ap : T_LD_abs_set <"memh_fifo", DoubleRegs, 0b0010>;
444 // Load - Indirect with long offset
445 let InputType = "imm", addrMode = BaseLongOffset, isExtended = 1,
446 opExtentBits = 6, opExtendable = 3 in
447 class T_LoadAbsReg <string mnemonic, string CextOp, RegisterClass RC,
449 : LDInst <(outs RC:$dst), (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3),
450 "$dst = "#mnemonic#"($src1<<#$src2 + #$src3)",
456 let CextOpcode = CextOp;
457 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
460 let Inst{27-25} = 0b110;
461 let Inst{24-21} = MajOp;
462 let Inst{20-16} = src1;
463 let Inst{13} = src2{1};
465 let Inst{11-8} = src3{5-2};
466 let Inst{7} = src2{0};
467 let Inst{6-5} = src3{1-0};
471 let accessSize = ByteAccess in {
472 def L4_loadrb_ur : T_LoadAbsReg<"memb", "LDrib", IntRegs, 0b1000>;
473 def L4_loadrub_ur : T_LoadAbsReg<"memub", "LDriub", IntRegs, 0b1001>;
474 def L4_loadalignb_ur : T_LoadAbsReg<"memb_fifo", "LDrib_fifo",
478 let accessSize = HalfWordAccess in {
479 def L4_loadrh_ur : T_LoadAbsReg<"memh", "LDrih", IntRegs, 0b1010>;
480 def L4_loadruh_ur : T_LoadAbsReg<"memuh", "LDriuh", IntRegs, 0b1011>;
481 def L4_loadbsw2_ur : T_LoadAbsReg<"membh", "LDribh2", IntRegs, 0b0001>;
482 def L4_loadbzw2_ur : T_LoadAbsReg<"memubh", "LDriubh2", IntRegs, 0b0011>;
483 def L4_loadalignh_ur : T_LoadAbsReg<"memh_fifo", "LDrih_fifo",
487 let accessSize = WordAccess in {
488 def L4_loadri_ur : T_LoadAbsReg<"memw", "LDriw", IntRegs, 0b1100>;
489 def L4_loadbsw4_ur : T_LoadAbsReg<"membh", "LDribh4", DoubleRegs, 0b0111>;
490 def L4_loadbzw4_ur : T_LoadAbsReg<"memubh", "LDriubh4", DoubleRegs, 0b0101>;
493 let accessSize = DoubleWordAccess in
494 def L4_loadrd_ur : T_LoadAbsReg<"memd", "LDrid", DoubleRegs, 0b1110>;
497 multiclass T_LoadAbsReg_Pat <PatFrag ldOp, InstHexagon MI, ValueType VT = i32> {
498 def : Pat <(VT (ldOp (add (shl IntRegs:$src1, u2ImmPred:$src2),
499 (HexagonCONST32 tglobaladdr:$src3)))),
500 (MI IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3)>;
502 def : Pat <(VT (ldOp (add IntRegs:$src1,
503 (HexagonCONST32 tglobaladdr:$src2)))),
504 (MI IntRegs:$src1, 0, tglobaladdr:$src2)>;
507 let AddedComplexity = 60 in {
508 defm : T_LoadAbsReg_Pat <sextloadi8, L4_loadrb_ur>;
509 defm : T_LoadAbsReg_Pat <zextloadi8, L4_loadrub_ur>;
510 defm : T_LoadAbsReg_Pat <extloadi8, L4_loadrub_ur>;
512 defm : T_LoadAbsReg_Pat <sextloadi16, L4_loadrh_ur>;
513 defm : T_LoadAbsReg_Pat <zextloadi16, L4_loadruh_ur>;
514 defm : T_LoadAbsReg_Pat <extloadi16, L4_loadruh_ur>;
516 defm : T_LoadAbsReg_Pat <load, L4_loadri_ur>;
517 defm : T_LoadAbsReg_Pat <load, L4_loadrd_ur, i64>;
520 //===----------------------------------------------------------------------===//
521 // Template classes for the non-predicated load instructions with
522 // base + register offset addressing mode
523 //===----------------------------------------------------------------------===//
524 class T_load_rr <string mnemonic, RegisterClass RC, bits<3> MajOp>:
525 LDInst<(outs RC:$dst), (ins IntRegs:$src1, IntRegs:$src2, u2Imm:$u2),
526 "$dst = "#mnemonic#"($src1 + $src2<<#$u2)",
527 [], "", V4LDST_tc_ld_SLOT01>, ImmRegShl, AddrModeRel {
535 let Inst{27-24} = 0b1010;
536 let Inst{23-21} = MajOp;
537 let Inst{20-16} = src1;
538 let Inst{12-8} = src2;
539 let Inst{13} = u2{1};
544 //===----------------------------------------------------------------------===//
545 // Template classes for the predicated load instructions with
546 // base + register offset addressing mode
547 //===----------------------------------------------------------------------===//
548 let isPredicated = 1 in
549 class T_pload_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
550 bit isNot, bit isPredNew>:
551 LDInst <(outs RC:$dst),
552 (ins PredRegs:$src1, IntRegs:$src2, IntRegs:$src3, u2Imm:$u2),
553 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
554 ") ")#"$dst = "#mnemonic#"($src2+$src3<<#$u2)",
555 [], "", V4LDST_tc_ld_SLOT01>, AddrModeRel {
562 let isPredicatedFalse = isNot;
563 let isPredicatedNew = isPredNew;
567 let Inst{27-26} = 0b00;
568 let Inst{25} = isPredNew;
569 let Inst{24} = isNot;
570 let Inst{23-21} = MajOp;
571 let Inst{20-16} = src2;
572 let Inst{12-8} = src3;
573 let Inst{13} = u2{1};
575 let Inst{6-5} = src1;
579 //===----------------------------------------------------------------------===//
580 // multiclass for load instructions with base + register offset
582 //===----------------------------------------------------------------------===//
583 let hasSideEffects = 0, addrMode = BaseRegOffset in
584 multiclass ld_idxd_shl <string mnemonic, string CextOp, RegisterClass RC,
586 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl,
587 InputType = "reg" in {
588 let isPredicable = 1 in
589 def L4_#NAME#_rr : T_load_rr <mnemonic, RC, MajOp>;
592 def L4_p#NAME#t_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 0>;
593 def L4_p#NAME#f_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 0>;
596 def L4_p#NAME#tnew_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 1>;
597 def L4_p#NAME#fnew_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 1>;
601 let hasNewValue = 1, accessSize = ByteAccess in {
602 defm loadrb : ld_idxd_shl<"memb", "LDrib", IntRegs, 0b000>;
603 defm loadrub : ld_idxd_shl<"memub", "LDriub", IntRegs, 0b001>;
606 let hasNewValue = 1, accessSize = HalfWordAccess in {
607 defm loadrh : ld_idxd_shl<"memh", "LDrih", IntRegs, 0b010>;
608 defm loadruh : ld_idxd_shl<"memuh", "LDriuh", IntRegs, 0b011>;
611 let hasNewValue = 1, accessSize = WordAccess in
612 defm loadri : ld_idxd_shl<"memw", "LDriw", IntRegs, 0b100>;
614 let accessSize = DoubleWordAccess in
615 defm loadrd : ld_idxd_shl<"memd", "LDrid", DoubleRegs, 0b110>;
617 // 'def pats' for load instructions with base + register offset and non-zero
618 // immediate value. Immediate value is used to left-shift the second
620 class Loadxs_pat<PatFrag Load, ValueType VT, InstHexagon MI>
621 : Pat<(VT (Load (add (i32 IntRegs:$Rs),
622 (i32 (shl (i32 IntRegs:$Rt), u2ImmPred:$u2))))),
623 (VT (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2))>;
625 let AddedComplexity = 40 in {
626 def: Loadxs_pat<extloadi8, i32, L4_loadrub_rr>;
627 def: Loadxs_pat<zextloadi8, i32, L4_loadrub_rr>;
628 def: Loadxs_pat<sextloadi8, i32, L4_loadrb_rr>;
629 def: Loadxs_pat<extloadi16, i32, L4_loadruh_rr>;
630 def: Loadxs_pat<zextloadi16, i32, L4_loadruh_rr>;
631 def: Loadxs_pat<sextloadi16, i32, L4_loadrh_rr>;
632 def: Loadxs_pat<load, i32, L4_loadri_rr>;
633 def: Loadxs_pat<load, i64, L4_loadrd_rr>;
636 // 'def pats' for load instruction base + register offset and
637 // zero immediate value.
638 class Loadxs_simple_pat<PatFrag Load, ValueType VT, InstHexagon MI>
639 : Pat<(VT (Load (add (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)))),
640 (VT (MI IntRegs:$Rs, IntRegs:$Rt, 0))>;
642 let AddedComplexity = 20 in {
643 def: Loadxs_simple_pat<extloadi8, i32, L4_loadrub_rr>;
644 def: Loadxs_simple_pat<zextloadi8, i32, L4_loadrub_rr>;
645 def: Loadxs_simple_pat<sextloadi8, i32, L4_loadrb_rr>;
646 def: Loadxs_simple_pat<extloadi16, i32, L4_loadruh_rr>;
647 def: Loadxs_simple_pat<zextloadi16, i32, L4_loadruh_rr>;
648 def: Loadxs_simple_pat<sextloadi16, i32, L4_loadrh_rr>;
649 def: Loadxs_simple_pat<load, i32, L4_loadri_rr>;
650 def: Loadxs_simple_pat<load, i64, L4_loadrd_rr>;
654 def: Pat<(i64 (zext (i1 PredRegs:$src1))),
655 (Zext64 (C2_muxii PredRegs:$src1, 1, 0))>;
658 def: Pat<(i64 (zext (i32 IntRegs:$src1))),
659 (Zext64 IntRegs:$src1)>;
661 //===----------------------------------------------------------------------===//
663 //===----------------------------------------------------------------------===//
665 //===----------------------------------------------------------------------===//
667 //===----------------------------------------------------------------------===//
669 //===----------------------------------------------------------------------===//
670 // Template class for store instructions with Absolute set addressing mode.
671 //===----------------------------------------------------------------------===//
672 let isExtended = 1, opExtendable = 1, opExtentBits = 6,
673 addrMode = AbsoluteSet, isNVStorable = 1 in
674 class T_ST_absset <string mnemonic, string BaseOp, RegisterClass RC,
675 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
676 : STInst<(outs IntRegs:$dst),
677 (ins u6Ext:$addr, RC:$src),
678 mnemonic#"($dst = #$addr) = $src"#!if(isHalf, ".h","")>, NewValueRel {
682 let accessSize = AccessSz;
683 let BaseOpcode = BaseOp#"_AbsSet";
687 let Inst{27-24} = 0b1011;
688 let Inst{23-21} = MajOp;
689 let Inst{20-16} = dst;
691 let Inst{12-8} = src;
693 let Inst{5-0} = addr;
696 def S4_storerb_ap : T_ST_absset <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
697 def S4_storerh_ap : T_ST_absset <"memh", "STrih", IntRegs, 0b010,
699 def S4_storeri_ap : T_ST_absset <"memw", "STriw", IntRegs, 0b100, WordAccess>;
701 let isNVStorable = 0 in {
702 def S4_storerf_ap : T_ST_absset <"memh", "STrif", IntRegs,
703 0b011, HalfWordAccess, 1>;
704 def S4_storerd_ap : T_ST_absset <"memd", "STrid", DoubleRegs,
705 0b110, DoubleWordAccess>;
708 let opExtendable = 1, isNewValue = 1, isNVStore = 1, opNewValue = 2,
709 isExtended = 1, opExtentBits= 6 in
710 class T_ST_absset_nv <string mnemonic, string BaseOp, bits<2> MajOp,
711 MemAccessSize AccessSz >
712 : NVInst <(outs IntRegs:$dst),
713 (ins u6Ext:$addr, IntRegs:$src),
714 mnemonic#"($dst = #$addr) = $src.new">, NewValueRel {
718 let accessSize = AccessSz;
719 let BaseOpcode = BaseOp#"_AbsSet";
723 let Inst{27-21} = 0b1011101;
724 let Inst{20-16} = dst;
725 let Inst{13-11} = 0b000;
726 let Inst{12-11} = MajOp;
727 let Inst{10-8} = src;
729 let Inst{5-0} = addr;
732 let mayStore = 1, addrMode = AbsoluteSet in {
733 def S4_storerbnew_ap : T_ST_absset_nv <"memb", "STrib", 0b00, ByteAccess>;
734 def S4_storerhnew_ap : T_ST_absset_nv <"memh", "STrih", 0b01, HalfWordAccess>;
735 def S4_storerinew_ap : T_ST_absset_nv <"memw", "STriw", 0b10, WordAccess>;
738 let isExtended = 1, opExtendable = 2, opExtentBits = 6, InputType = "imm",
739 addrMode = BaseLongOffset, AddedComplexity = 40 in
740 class T_StoreAbsReg <string mnemonic, string CextOp, RegisterClass RC,
741 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
743 (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3, RC:$src4),
744 mnemonic#"($src1<<#$src2 + #$src3) = $src4"#!if(isHalf, ".h",""),
745 []>, ImmRegShl, NewValueRel {
752 let accessSize = AccessSz;
753 let CextOpcode = CextOp;
754 let BaseOpcode = CextOp#"_shl";
757 let Inst{27-24} =0b1101;
758 let Inst{23-21} = MajOp;
759 let Inst{20-16} = src1;
760 let Inst{13} = src2{1};
761 let Inst{12-8} = src4;
763 let Inst{6} = src2{0};
764 let Inst{5-0} = src3;
767 def S4_storerb_ur : T_StoreAbsReg <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
768 def S4_storerh_ur : T_StoreAbsReg <"memh", "STrih", IntRegs, 0b010,
770 def S4_storerf_ur : T_StoreAbsReg <"memh", "STrif", IntRegs, 0b011,
772 def S4_storeri_ur : T_StoreAbsReg <"memw", "STriw", IntRegs, 0b100, WordAccess>;
773 def S4_storerd_ur : T_StoreAbsReg <"memd", "STrid", DoubleRegs, 0b110,
776 let AddedComplexity = 40 in
777 multiclass T_StoreAbsReg_Pats <InstHexagon MI, RegisterClass RC, ValueType VT,
779 def : Pat<(stOp (VT RC:$src4),
780 (add (shl (i32 IntRegs:$src1), u2ImmPred:$src2),
782 (MI IntRegs:$src1, u2ImmPred:$src2, u32ImmPred:$src3, RC:$src4)>;
784 def : Pat<(stOp (VT RC:$src4),
785 (add (shl IntRegs:$src1, u2ImmPred:$src2),
786 (HexagonCONST32 tglobaladdr:$src3))),
787 (MI IntRegs:$src1, u2ImmPred:$src2, tglobaladdr:$src3, RC:$src4)>;
789 def : Pat<(stOp (VT RC:$src4),
790 (add IntRegs:$src1, (HexagonCONST32 tglobaladdr:$src3))),
791 (MI IntRegs:$src1, 0, tglobaladdr:$src3, RC:$src4)>;
794 defm : T_StoreAbsReg_Pats <S4_storerd_ur, DoubleRegs, i64, store>;
795 defm : T_StoreAbsReg_Pats <S4_storeri_ur, IntRegs, i32, store>;
796 defm : T_StoreAbsReg_Pats <S4_storerb_ur, IntRegs, i32, truncstorei8>;
797 defm : T_StoreAbsReg_Pats <S4_storerh_ur, IntRegs, i32, truncstorei16>;
799 let mayStore = 1, isNVStore = 1, isExtended = 1, addrMode = BaseLongOffset,
800 opExtentBits = 6, isNewValue = 1, opNewValue = 3, opExtendable = 2 in
801 class T_StoreAbsRegNV <string mnemonic, string CextOp, bits<2> MajOp,
802 MemAccessSize AccessSz>
804 (ins IntRegs:$src1, u2Imm:$src2, u6Ext:$src3, IntRegs:$src4),
805 mnemonic#"($src1<<#$src2 + #$src3) = $src4.new">, NewValueRel {
811 let CextOpcode = CextOp;
812 let BaseOpcode = CextOp#"_shl";
815 let Inst{27-21} = 0b1101101;
816 let Inst{12-11} = 0b00;
818 let Inst{20-16} = src1;
819 let Inst{13} = src2{1};
820 let Inst{12-11} = MajOp;
821 let Inst{10-8} = src4;
822 let Inst{6} = src2{0};
823 let Inst{5-0} = src3;
826 def S4_storerbnew_ur : T_StoreAbsRegNV <"memb", "STrib", 0b00, ByteAccess>;
827 def S4_storerhnew_ur : T_StoreAbsRegNV <"memh", "STrih", 0b01, HalfWordAccess>;
828 def S4_storerinew_ur : T_StoreAbsRegNV <"memw", "STriw", 0b10, WordAccess>;
830 //===----------------------------------------------------------------------===//
831 // Template classes for the non-predicated store instructions with
832 // base + register offset addressing mode
833 //===----------------------------------------------------------------------===//
834 let isPredicable = 1 in
835 class T_store_rr <string mnemonic, RegisterClass RC, bits<3> MajOp, bit isH>
836 : STInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
837 mnemonic#"($Rs + $Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
838 [],"",V4LDST_tc_st_SLOT01>, ImmRegShl, AddrModeRel {
847 let Inst{27-24} = 0b1011;
848 let Inst{23-21} = MajOp;
849 let Inst{20-16} = Rs;
851 let Inst{13} = u2{1};
856 //===----------------------------------------------------------------------===//
857 // Template classes for the predicated store instructions with
858 // base + register offset addressing mode
859 //===----------------------------------------------------------------------===//
860 let isPredicated = 1 in
861 class T_pstore_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
862 bit isNot, bit isPredNew, bit isH>
864 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, RC:$Rt),
866 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
867 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
868 [], "", V4LDST_tc_st_SLOT01> , AddrModeRel{
875 let isPredicatedFalse = isNot;
876 let isPredicatedNew = isPredNew;
880 let Inst{27-26} = 0b01;
881 let Inst{25} = isPredNew;
882 let Inst{24} = isNot;
883 let Inst{23-21} = MajOp;
884 let Inst{20-16} = Rs;
886 let Inst{13} = u2{1};
892 //===----------------------------------------------------------------------===//
893 // Template classes for the new-value store instructions with
894 // base + register offset addressing mode
895 //===----------------------------------------------------------------------===//
896 let isPredicable = 1, isNewValue = 1, opNewValue = 3 in
897 class T_store_new_rr <string mnemonic, bits<2> MajOp> :
898 NVInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
899 mnemonic#"($Rs + $Ru<<#$u2) = $Nt.new",
900 [],"",V4LDST_tc_st_SLOT0>, ImmRegShl, AddrModeRel {
909 let Inst{27-21} = 0b1011101;
910 let Inst{20-16} = Rs;
912 let Inst{13} = u2{1};
914 let Inst{4-3} = MajOp;
918 //===----------------------------------------------------------------------===//
919 // Template classes for the predicated new-value store instructions with
920 // base + register offset addressing mode
921 //===----------------------------------------------------------------------===//
922 let isPredicated = 1, isNewValue = 1, opNewValue = 4 in
923 class T_pstore_new_rr <string mnemonic, bits<2> MajOp, bit isNot, bit isPredNew>
925 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2Imm:$u2, IntRegs:$Nt),
926 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
927 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Nt.new",
928 [], "", V4LDST_tc_st_SLOT0>, AddrModeRel {
935 let isPredicatedFalse = isNot;
936 let isPredicatedNew = isPredNew;
939 let Inst{27-26} = 0b01;
940 let Inst{25} = isPredNew;
941 let Inst{24} = isNot;
942 let Inst{23-21} = 0b101;
943 let Inst{20-16} = Rs;
945 let Inst{13} = u2{1};
948 let Inst{4-3} = MajOp;
952 //===----------------------------------------------------------------------===//
953 // multiclass for store instructions with base + register offset addressing
955 //===----------------------------------------------------------------------===//
956 let isNVStorable = 1 in
957 multiclass ST_Idxd_shl<string mnemonic, string CextOp, RegisterClass RC,
958 bits<3> MajOp, bit isH = 0> {
959 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
960 def S4_#NAME#_rr : T_store_rr <mnemonic, RC, MajOp, isH>;
963 def S4_p#NAME#t_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 0, isH>;
964 def S4_p#NAME#f_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 0, isH>;
967 def S4_p#NAME#tnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 1, isH>;
968 def S4_p#NAME#fnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 1, isH>;
972 //===----------------------------------------------------------------------===//
973 // multiclass for new-value store instructions with base + register offset
975 //===----------------------------------------------------------------------===//
976 let mayStore = 1, isNVStore = 1 in
977 multiclass ST_Idxd_shl_nv <string mnemonic, string CextOp, RegisterClass RC,
979 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
980 def S4_#NAME#new_rr : T_store_new_rr<mnemonic, MajOp>;
983 def S4_p#NAME#newt_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 0>;
984 def S4_p#NAME#newf_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 0>;
987 def S4_p#NAME#newtnew_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 1>;
988 def S4_p#NAME#newfnew_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 1>;
992 let addrMode = BaseRegOffset, InputType = "reg", hasSideEffects = 0 in {
993 let accessSize = ByteAccess in
994 defm storerb: ST_Idxd_shl<"memb", "STrib", IntRegs, 0b000>,
995 ST_Idxd_shl_nv<"memb", "STrib", IntRegs, 0b00>;
997 let accessSize = HalfWordAccess in
998 defm storerh: ST_Idxd_shl<"memh", "STrih", IntRegs, 0b010>,
999 ST_Idxd_shl_nv<"memh", "STrih", IntRegs, 0b01>;
1001 let accessSize = WordAccess in
1002 defm storeri: ST_Idxd_shl<"memw", "STriw", IntRegs, 0b100>,
1003 ST_Idxd_shl_nv<"memw", "STriw", IntRegs, 0b10>;
1005 let isNVStorable = 0, accessSize = DoubleWordAccess in
1006 defm storerd: ST_Idxd_shl<"memd", "STrid", DoubleRegs, 0b110>;
1008 let isNVStorable = 0, accessSize = HalfWordAccess in
1009 defm storerf: ST_Idxd_shl<"memh", "STrif", IntRegs, 0b011, 1>;
1012 class Storexs_pat<PatFrag Store, PatFrag Value, InstHexagon MI>
1013 : Pat<(Store Value:$Ru, (add (i32 IntRegs:$Rs),
1014 (i32 (shl (i32 IntRegs:$Rt), u2ImmPred:$u2)))),
1015 (MI IntRegs:$Rs, IntRegs:$Rt, imm:$u2, Value:$Ru)>;
1017 let AddedComplexity = 40 in {
1018 def: Storexs_pat<truncstorei8, I32, S4_storerb_rr>;
1019 def: Storexs_pat<truncstorei16, I32, S4_storerh_rr>;
1020 def: Storexs_pat<store, I32, S4_storeri_rr>;
1021 def: Storexs_pat<store, I64, S4_storerd_rr>;
1024 // memd(Rx++#s4:3)=Rtt
1025 // memd(Rx++#s4:3:circ(Mu))=Rtt
1026 // memd(Rx++I:circ(Mu))=Rtt
1028 // memd(Rx++Mu:brev)=Rtt
1029 // memd(gp+#u16:3)=Rtt
1031 // Store doubleword conditionally.
1032 // if ([!]Pv[.new]) memd(#u6)=Rtt
1033 // TODO: needs to be implemented.
1035 //===----------------------------------------------------------------------===//
1037 //===----------------------------------------------------------------------===//
1038 let isPredicable = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 8,
1040 class T_StoreImm <string mnemonic, Operand OffsetOp, bits<2> MajOp >
1041 : STInst <(outs ), (ins IntRegs:$Rs, OffsetOp:$offset, s8Ext:$S8),
1042 mnemonic#"($Rs+#$offset)=#$S8",
1043 [], "", V4LDST_tc_st_SLOT01>,
1044 ImmRegRel, PredNewRel {
1050 string OffsetOpStr = !cast<string>(OffsetOp);
1051 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
1052 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
1053 /* u6_0Imm */ offset{5-0}));
1055 let IClass = 0b0011;
1057 let Inst{27-25} = 0b110;
1058 let Inst{22-21} = MajOp;
1059 let Inst{20-16} = Rs;
1060 let Inst{12-7} = offsetBits;
1061 let Inst{13} = S8{7};
1062 let Inst{6-0} = S8{6-0};
1065 let isPredicated = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 6,
1067 class T_StoreImm_pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
1068 bit isPredNot, bit isPredNew >
1070 (ins PredRegs:$Pv, IntRegs:$Rs, OffsetOp:$offset, s6Ext:$S6),
1071 !if(isPredNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
1072 ") ")#mnemonic#"($Rs+#$offset)=#$S6",
1073 [], "", V4LDST_tc_st_SLOT01>,
1074 ImmRegRel, PredNewRel {
1081 string OffsetOpStr = !cast<string>(OffsetOp);
1082 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
1083 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
1084 /* u6_0Imm */ offset{5-0}));
1085 let isPredicatedNew = isPredNew;
1086 let isPredicatedFalse = isPredNot;
1088 let IClass = 0b0011;
1090 let Inst{27-25} = 0b100;
1091 let Inst{24} = isPredNew;
1092 let Inst{23} = isPredNot;
1093 let Inst{22-21} = MajOp;
1094 let Inst{20-16} = Rs;
1095 let Inst{13} = S6{5};
1096 let Inst{12-7} = offsetBits;
1098 let Inst{4-0} = S6{4-0};
1102 //===----------------------------------------------------------------------===//
1103 // multiclass for store instructions with base + immediate offset
1104 // addressing mode and immediate stored value.
1105 // mem[bhw](Rx++#s4:3)=#s8
1106 // if ([!]Pv[.new]) mem[bhw](Rx++#s4:3)=#s6
1107 //===----------------------------------------------------------------------===//
1109 multiclass ST_Imm_Pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
1111 def _io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 0>;
1113 def new_io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 1>;
1116 multiclass ST_Imm <string mnemonic, string CextOp, Operand OffsetOp,
1118 let CextOpcode = CextOp, BaseOpcode = CextOp#_imm in {
1119 def _io : T_StoreImm <mnemonic, OffsetOp, MajOp>;
1121 defm t : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 0>;
1122 defm f : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 1>;
1126 let hasSideEffects = 0, addrMode = BaseImmOffset,
1127 InputType = "imm" in {
1128 let accessSize = ByteAccess in
1129 defm S4_storeirb : ST_Imm<"memb", "STrib", u6_0Imm, 0b00>;
1131 let accessSize = HalfWordAccess in
1132 defm S4_storeirh : ST_Imm<"memh", "STrih", u6_1Imm, 0b01>;
1134 let accessSize = WordAccess in
1135 defm S4_storeiri : ST_Imm<"memw", "STriw", u6_2Imm, 0b10>;
1138 def IMM_BYTE : SDNodeXForm<imm, [{
1139 // -1 etc is represented as 255 etc
1140 // assigning to a byte restores our desired signed value.
1141 int8_t imm = N->getSExtValue();
1142 return CurDAG->getTargetConstant(imm, MVT::i32);
1145 def IMM_HALF : SDNodeXForm<imm, [{
1146 // -1 etc is represented as 65535 etc
1147 // assigning to a short restores our desired signed value.
1148 int16_t imm = N->getSExtValue();
1149 return CurDAG->getTargetConstant(imm, MVT::i32);
1152 def IMM_WORD : SDNodeXForm<imm, [{
1153 // -1 etc can be represented as 4294967295 etc
1154 // Currently, it's not doing this. But some optimization
1155 // might convert -1 to a large +ve number.
1156 // assigning to a word restores our desired signed value.
1157 int32_t imm = N->getSExtValue();
1158 return CurDAG->getTargetConstant(imm, MVT::i32);
1161 def ToImmByte : OutPatFrag<(ops node:$R), (IMM_BYTE $R)>;
1162 def ToImmHalf : OutPatFrag<(ops node:$R), (IMM_HALF $R)>;
1163 def ToImmWord : OutPatFrag<(ops node:$R), (IMM_WORD $R)>;
1165 let AddedComplexity = 40 in {
1166 // Not using frameindex patterns for these stores, because the offset
1167 // is not extendable. This could cause problems during removing the frame
1168 // indices, since the offset with respect to R29/R30 may not fit in the
1170 def: Storexm_add_pat<truncstorei8, s32ImmPred, u6_0ImmPred, ToImmByte,
1172 def: Storexm_add_pat<truncstorei16, s32ImmPred, u6_1ImmPred, ToImmHalf,
1174 def: Storexm_add_pat<store, s32ImmPred, u6_2ImmPred, ToImmWord,
1178 def: Storexm_simple_pat<truncstorei8, s32ImmPred, ToImmByte, S4_storeirb_io>;
1179 def: Storexm_simple_pat<truncstorei16, s32ImmPred, ToImmHalf, S4_storeirh_io>;
1180 def: Storexm_simple_pat<store, s32ImmPred, ToImmWord, S4_storeiri_io>;
1182 // memb(Rx++#s4:0:circ(Mu))=Rt
1183 // memb(Rx++I:circ(Mu))=Rt
1185 // memb(Rx++Mu:brev)=Rt
1186 // memb(gp+#u16:0)=Rt
1189 // TODO: needs to be implemented
1190 // memh(Re=#U6)=Rt.H
1191 // memh(Rs+#s11:1)=Rt.H
1192 // memh(Rs+Ru<<#u2)=Rt.H
1193 // TODO: needs to be implemented.
1195 // memh(Ru<<#u2+#U6)=Rt.H
1196 // memh(Rx++#s4:1:circ(Mu))=Rt.H
1197 // memh(Rx++#s4:1:circ(Mu))=Rt
1198 // memh(Rx++I:circ(Mu))=Rt.H
1199 // memh(Rx++I:circ(Mu))=Rt
1200 // memh(Rx++Mu)=Rt.H
1202 // memh(Rx++Mu:brev)=Rt.H
1203 // memh(Rx++Mu:brev)=Rt
1204 // memh(gp+#u16:1)=Rt
1205 // if ([!]Pv[.new]) memh(#u6)=Rt.H
1206 // if ([!]Pv[.new]) memh(#u6)=Rt
1208 // if ([!]Pv[.new]) memh(Rs+#u6:1)=Rt.H
1209 // TODO: needs to be implemented.
1211 // if ([!]Pv[.new]) memh(Rx++#s4:1)=Rt.H
1212 // TODO: Needs to be implemented.
1216 // TODO: Needs to be implemented.
1217 // memw(Rx++#s4:2)=Rt
1218 // memw(Rx++#s4:2:circ(Mu))=Rt
1219 // memw(Rx++I:circ(Mu))=Rt
1221 // memw(Rx++Mu:brev)=Rt
1223 //===----------------------------------------------------------------------===
1225 //===----------------------------------------------------------------------===
1228 //===----------------------------------------------------------------------===//
1230 //===----------------------------------------------------------------------===//
1232 let opNewValue = 2, opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
1233 class T_store_io_nv <string mnemonic, RegisterClass RC,
1234 Operand ImmOp, bits<2>MajOp>
1235 : NVInst_V4 <(outs),
1236 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
1237 mnemonic#"($src1+#$src2) = $src3.new",
1238 [],"",ST_tc_st_SLOT0> {
1240 bits<13> src2; // Actual address offset
1242 bits<11> offsetBits; // Represents offset encoding
1244 let opExtentBits = !if (!eq(mnemonic, "memb"), 11,
1245 !if (!eq(mnemonic, "memh"), 12,
1246 !if (!eq(mnemonic, "memw"), 13, 0)));
1248 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1249 !if (!eq(mnemonic, "memh"), 1,
1250 !if (!eq(mnemonic, "memw"), 2, 0)));
1252 let offsetBits = !if (!eq(mnemonic, "memb"), src2{10-0},
1253 !if (!eq(mnemonic, "memh"), src2{11-1},
1254 !if (!eq(mnemonic, "memw"), src2{12-2}, 0)));
1256 let IClass = 0b1010;
1259 let Inst{26-25} = offsetBits{10-9};
1260 let Inst{24-21} = 0b1101;
1261 let Inst{20-16} = src1;
1262 let Inst{13} = offsetBits{8};
1263 let Inst{12-11} = MajOp;
1264 let Inst{10-8} = src3;
1265 let Inst{7-0} = offsetBits{7-0};
1268 let opExtendable = 2, opNewValue = 3, isPredicated = 1 in
1269 class T_pstore_io_nv <string mnemonic, RegisterClass RC, Operand predImmOp,
1270 bits<2>MajOp, bit PredNot, bit isPredNew>
1271 : NVInst_V4 <(outs),
1272 (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC:$src4),
1273 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1274 ") ")#mnemonic#"($src2+#$src3) = $src4.new",
1275 [],"",V2LDST_tc_st_SLOT0> {
1280 bits<6> offsetBits; // Represents offset encoding
1282 let isPredicatedNew = isPredNew;
1283 let isPredicatedFalse = PredNot;
1284 let opExtentBits = !if (!eq(mnemonic, "memb"), 6,
1285 !if (!eq(mnemonic, "memh"), 7,
1286 !if (!eq(mnemonic, "memw"), 8, 0)));
1288 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1289 !if (!eq(mnemonic, "memh"), 1,
1290 !if (!eq(mnemonic, "memw"), 2, 0)));
1292 let offsetBits = !if (!eq(mnemonic, "memb"), src3{5-0},
1293 !if (!eq(mnemonic, "memh"), src3{6-1},
1294 !if (!eq(mnemonic, "memw"), src3{7-2}, 0)));
1296 let IClass = 0b0100;
1299 let Inst{26} = PredNot;
1300 let Inst{25} = isPredNew;
1301 let Inst{24-21} = 0b0101;
1302 let Inst{20-16} = src2;
1303 let Inst{13} = offsetBits{5};
1304 let Inst{12-11} = MajOp;
1305 let Inst{10-8} = src4;
1306 let Inst{7-3} = offsetBits{4-0};
1308 let Inst{1-0} = src1;
1311 // multiclass for new-value store instructions with base + immediate offset.
1313 let mayStore = 1, isNVStore = 1, isNewValue = 1, hasSideEffects = 0,
1315 multiclass ST_Idxd_nv<string mnemonic, string CextOp, RegisterClass RC,
1316 Operand ImmOp, Operand predImmOp, bits<2> MajOp> {
1318 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1319 def S2_#NAME#new_io : T_store_io_nv <mnemonic, RC, ImmOp, MajOp>;
1321 def S2_p#NAME#newt_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 0, 0>;
1322 def S2_p#NAME#newf_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 1, 0>;
1324 def S4_p#NAME#newtnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1326 def S4_p#NAME#newfnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1331 let addrMode = BaseImmOffset, InputType = "imm" in {
1332 let accessSize = ByteAccess in
1333 defm storerb: ST_Idxd_nv<"memb", "STrib", IntRegs, s11_0Ext,
1334 u6_0Ext, 0b00>, AddrModeRel;
1336 let accessSize = HalfWordAccess, opExtentAlign = 1 in
1337 defm storerh: ST_Idxd_nv<"memh", "STrih", IntRegs, s11_1Ext,
1338 u6_1Ext, 0b01>, AddrModeRel;
1340 let accessSize = WordAccess, opExtentAlign = 2 in
1341 defm storeri: ST_Idxd_nv<"memw", "STriw", IntRegs, s11_2Ext,
1342 u6_2Ext, 0b10>, AddrModeRel;
1345 //===----------------------------------------------------------------------===//
1346 // Post increment loads with register offset.
1347 //===----------------------------------------------------------------------===//
1349 let hasNewValue = 1 in
1350 def L2_loadbsw2_pr : T_load_pr <"membh", IntRegs, 0b0001, HalfWordAccess>;
1352 def L2_loadbsw4_pr : T_load_pr <"membh", DoubleRegs, 0b0111, WordAccess>;
1354 let hasSideEffects = 0, addrMode = PostInc in
1355 class T_loadalign_pr <string mnemonic, bits<4> MajOp, MemAccessSize AccessSz>
1356 : LDInstPI <(outs DoubleRegs:$dst, IntRegs:$_dst_),
1357 (ins DoubleRegs:$src1, IntRegs:$src2, ModRegs:$src3),
1358 "$dst = "#mnemonic#"($src2++$src3)", [],
1359 "$src1 = $dst, $src2 = $_dst_"> {
1364 let accessSize = AccessSz;
1365 let IClass = 0b1001;
1367 let Inst{27-25} = 0b110;
1368 let Inst{24-21} = MajOp;
1369 let Inst{20-16} = src2;
1370 let Inst{13} = src3;
1373 let Inst{4-0} = dst;
1376 def L2_loadalignb_pr : T_loadalign_pr <"memb_fifo", 0b0100, ByteAccess>;
1377 def L2_loadalignh_pr : T_loadalign_pr <"memh_fifo", 0b0010, HalfWordAccess>;
1379 //===----------------------------------------------------------------------===//
1380 // Template class for non-predicated post increment .new stores
1381 // mem[bhwd](Rx++#s4:[0123])=Nt.new
1382 //===----------------------------------------------------------------------===//
1383 let isPredicable = 1, hasSideEffects = 0, addrMode = PostInc, isNVStore = 1,
1384 isNewValue = 1, opNewValue = 3 in
1385 class T_StorePI_nv <string mnemonic, Operand ImmOp, bits<2> MajOp >
1386 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1387 (ins IntRegs:$src1, ImmOp:$offset, IntRegs:$src2),
1388 mnemonic#"($src1++#$offset) = $src2.new",
1389 [], "$src1 = $_dst_">,
1396 string ImmOpStr = !cast<string>(ImmOp);
1397 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1398 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1399 /* s4_0Imm */ offset{3-0}));
1400 let IClass = 0b1010;
1402 let Inst{27-21} = 0b1011101;
1403 let Inst{20-16} = src1;
1405 let Inst{12-11} = MajOp;
1406 let Inst{10-8} = src2;
1408 let Inst{6-3} = offsetBits;
1412 //===----------------------------------------------------------------------===//
1413 // Template class for predicated post increment .new stores
1414 // if([!]Pv[.new]) mem[bhwd](Rx++#s4:[0123])=Nt.new
1415 //===----------------------------------------------------------------------===//
1416 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc, isNVStore = 1,
1417 isNewValue = 1, opNewValue = 4 in
1418 class T_StorePI_nv_pred <string mnemonic, Operand ImmOp,
1419 bits<2> MajOp, bit isPredNot, bit isPredNew >
1420 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1421 (ins PredRegs:$src1, IntRegs:$src2,
1422 ImmOp:$offset, IntRegs:$src3),
1423 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1424 ") ")#mnemonic#"($src2++#$offset) = $src3.new",
1425 [], "$src2 = $_dst_">,
1433 string ImmOpStr = !cast<string>(ImmOp);
1434 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1435 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1436 /* s4_0Imm */ offset{3-0}));
1437 let isPredicatedNew = isPredNew;
1438 let isPredicatedFalse = isPredNot;
1440 let IClass = 0b1010;
1442 let Inst{27-21} = 0b1011101;
1443 let Inst{20-16} = src2;
1445 let Inst{12-11} = MajOp;
1446 let Inst{10-8} = src3;
1447 let Inst{7} = isPredNew;
1448 let Inst{6-3} = offsetBits;
1449 let Inst{2} = isPredNot;
1450 let Inst{1-0} = src1;
1453 multiclass ST_PostInc_Pred_nv<string mnemonic, Operand ImmOp,
1454 bits<2> MajOp, bit PredNot> {
1455 def _pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 0>;
1458 def new_pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 1>;
1461 multiclass ST_PostInc_nv<string mnemonic, string BaseOp, Operand ImmOp,
1463 let BaseOpcode = "POST_"#BaseOp in {
1464 def S2_#NAME#_pi : T_StorePI_nv <mnemonic, ImmOp, MajOp>;
1467 defm S2_p#NAME#t : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 0>;
1468 defm S2_p#NAME#f : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 1>;
1472 let accessSize = ByteAccess in
1473 defm storerbnew: ST_PostInc_nv <"memb", "STrib", s4_0Imm, 0b00>;
1475 let accessSize = HalfWordAccess in
1476 defm storerhnew: ST_PostInc_nv <"memh", "STrih", s4_1Imm, 0b01>;
1478 let accessSize = WordAccess in
1479 defm storerinew: ST_PostInc_nv <"memw", "STriw", s4_2Imm, 0b10>;
1481 //===----------------------------------------------------------------------===//
1482 // Template class for post increment .new stores with register offset
1483 //===----------------------------------------------------------------------===//
1484 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
1485 class T_StorePI_RegNV <string mnemonic, bits<2> MajOp, MemAccessSize AccessSz>
1486 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1487 (ins IntRegs:$src1, ModRegs:$src2, IntRegs:$src3),
1488 #mnemonic#"($src1++$src2) = $src3.new",
1489 [], "$src1 = $_dst_"> {
1493 let accessSize = AccessSz;
1495 let IClass = 0b1010;
1497 let Inst{27-21} = 0b1101101;
1498 let Inst{20-16} = src1;
1499 let Inst{13} = src2;
1500 let Inst{12-11} = MajOp;
1501 let Inst{10-8} = src3;
1505 def S2_storerbnew_pr : T_StorePI_RegNV<"memb", 0b00, ByteAccess>;
1506 def S2_storerhnew_pr : T_StorePI_RegNV<"memh", 0b01, HalfWordAccess>;
1507 def S2_storerinew_pr : T_StorePI_RegNV<"memw", 0b10, WordAccess>;
1509 // memb(Rx++#s4:0:circ(Mu))=Nt.new
1510 // memb(Rx++I:circ(Mu))=Nt.new
1511 // memb(Rx++Mu:brev)=Nt.new
1512 // memh(Rx++#s4:1:circ(Mu))=Nt.new
1513 // memh(Rx++I:circ(Mu))=Nt.new
1514 // memh(Rx++Mu)=Nt.new
1515 // memh(Rx++Mu:brev)=Nt.new
1517 // memw(Rx++#s4:2:circ(Mu))=Nt.new
1518 // memw(Rx++I:circ(Mu))=Nt.new
1519 // memw(Rx++Mu)=Nt.new
1520 // memw(Rx++Mu:brev)=Nt.new
1522 //===----------------------------------------------------------------------===//
1524 //===----------------------------------------------------------------------===//
1526 //===----------------------------------------------------------------------===//
1528 //===----------------------------------------------------------------------===//
1530 //===----------------------------------------------------------------------===//
1531 // multiclass/template class for the new-value compare jumps with the register
1533 //===----------------------------------------------------------------------===//
1535 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1536 opExtentAlign = 2 in
1537 class NVJrr_template<string mnemonic, bits<3> majOp, bit NvOpNum,
1538 bit isNegCond, bit isTak>
1540 (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset),
1541 "if ("#!if(isNegCond, "!","")#mnemonic#
1542 "($src1"#!if(!eq(NvOpNum, 0),".new, ",", ")#
1543 "$src2"#!if(!eq(NvOpNum, 1),".new))","))")#" jump:"
1544 #!if(isTak, "t","nt")#" $offset", []> {
1548 bits<3> Ns; // New-Value Operand
1549 bits<5> RegOp; // Non-New-Value Operand
1552 let isTaken = isTak;
1553 let isPredicatedFalse = isNegCond;
1554 let opNewValue{0} = NvOpNum;
1556 let Ns = !if(!eq(NvOpNum, 0), src1{2-0}, src2{2-0});
1557 let RegOp = !if(!eq(NvOpNum, 0), src2, src1);
1559 let IClass = 0b0010;
1560 let Inst{27-26} = 0b00;
1561 let Inst{25-23} = majOp;
1562 let Inst{22} = isNegCond;
1563 let Inst{18-16} = Ns;
1564 let Inst{13} = isTak;
1565 let Inst{12-8} = RegOp;
1566 let Inst{21-20} = offset{10-9};
1567 let Inst{7-1} = offset{8-2};
1571 multiclass NVJrr_cond<string mnemonic, bits<3> majOp, bit NvOpNum,
1573 // Branch not taken:
1574 def _nt: NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 0>;
1576 def _t : NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 1>;
1579 // NvOpNum = 0 -> First Operand is a new-value Register
1580 // NvOpNum = 1 -> Second Operand is a new-value Register
1582 multiclass NVJrr_base<string mnemonic, string BaseOp, bits<3> majOp,
1584 let BaseOpcode = BaseOp#_NVJ in {
1585 defm _t_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 0>; // True cond
1586 defm _f_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 1>; // False cond
1590 // if ([!]cmp.eq(Ns.new,Rt)) jump:[n]t #r9:2
1591 // if ([!]cmp.gt(Ns.new,Rt)) jump:[n]t #r9:2
1592 // if ([!]cmp.gtu(Ns.new,Rt)) jump:[n]t #r9:2
1593 // if ([!]cmp.gt(Rt,Ns.new)) jump:[n]t #r9:2
1594 // if ([!]cmp.gtu(Rt,Ns.new)) jump:[n]t #r9:2
1596 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1597 Defs = [PC], hasSideEffects = 0 in {
1598 defm J4_cmpeq : NVJrr_base<"cmp.eq", "CMPEQ", 0b000, 0>, PredRel;
1599 defm J4_cmpgt : NVJrr_base<"cmp.gt", "CMPGT", 0b001, 0>, PredRel;
1600 defm J4_cmpgtu : NVJrr_base<"cmp.gtu", "CMPGTU", 0b010, 0>, PredRel;
1601 defm J4_cmplt : NVJrr_base<"cmp.gt", "CMPLT", 0b011, 1>, PredRel;
1602 defm J4_cmpltu : NVJrr_base<"cmp.gtu", "CMPLTU", 0b100, 1>, PredRel;
1605 //===----------------------------------------------------------------------===//
1606 // multiclass/template class for the new-value compare jumps instruction
1607 // with a register and an unsigned immediate (U5) operand.
1608 //===----------------------------------------------------------------------===//
1610 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1611 opExtentAlign = 2 in
1612 class NVJri_template<string mnemonic, bits<3> majOp, bit isNegCond,
1615 (ins IntRegs:$src1, u5Imm:$src2, brtarget:$offset),
1616 "if ("#!if(isNegCond, "!","")#mnemonic#"($src1.new, #$src2)) jump:"
1617 #!if(isTak, "t","nt")#" $offset", []> {
1619 let isTaken = isTak;
1620 let isPredicatedFalse = isNegCond;
1621 let isTaken = isTak;
1627 let IClass = 0b0010;
1629 let Inst{25-23} = majOp;
1630 let Inst{22} = isNegCond;
1631 let Inst{18-16} = src1;
1632 let Inst{13} = isTak;
1633 let Inst{12-8} = src2;
1634 let Inst{21-20} = offset{10-9};
1635 let Inst{7-1} = offset{8-2};
1638 multiclass NVJri_cond<string mnemonic, bits<3> majOp, bit isNegCond> {
1639 // Branch not taken:
1640 def _nt: NVJri_template<mnemonic, majOp, isNegCond, 0>;
1642 def _t : NVJri_template<mnemonic, majOp, isNegCond, 1>;
1645 multiclass NVJri_base<string mnemonic, string BaseOp, bits<3> majOp> {
1646 let BaseOpcode = BaseOp#_NVJri in {
1647 defm _t_jumpnv : NVJri_cond<mnemonic, majOp, 0>; // True Cond
1648 defm _f_jumpnv : NVJri_cond<mnemonic, majOp, 1>; // False cond
1652 // if ([!]cmp.eq(Ns.new,#U5)) jump:[n]t #r9:2
1653 // if ([!]cmp.gt(Ns.new,#U5)) jump:[n]t #r9:2
1654 // if ([!]cmp.gtu(Ns.new,#U5)) jump:[n]t #r9:2
1656 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1657 Defs = [PC], hasSideEffects = 0 in {
1658 defm J4_cmpeqi : NVJri_base<"cmp.eq", "CMPEQ", 0b000>, PredRel;
1659 defm J4_cmpgti : NVJri_base<"cmp.gt", "CMPGT", 0b001>, PredRel;
1660 defm J4_cmpgtui : NVJri_base<"cmp.gtu", "CMPGTU", 0b010>, PredRel;
1663 //===----------------------------------------------------------------------===//
1664 // multiclass/template class for the new-value compare jumps instruction
1665 // with a register and an hardcoded 0/-1 immediate value.
1666 //===----------------------------------------------------------------------===//
1668 let isExtendable = 1, opExtendable = 1, isExtentSigned = 1, opExtentBits = 11,
1669 opExtentAlign = 2 in
1670 class NVJ_ConstImm_template<string mnemonic, bits<3> majOp, string ImmVal,
1671 bit isNegCond, bit isTak>
1673 (ins IntRegs:$src1, brtarget:$offset),
1674 "if ("#!if(isNegCond, "!","")#mnemonic
1675 #"($src1.new, #"#ImmVal#")) jump:"
1676 #!if(isTak, "t","nt")#" $offset", []> {
1678 let isTaken = isTak;
1679 let isPredicatedFalse = isNegCond;
1680 let isTaken = isTak;
1684 let IClass = 0b0010;
1686 let Inst{25-23} = majOp;
1687 let Inst{22} = isNegCond;
1688 let Inst{18-16} = src1;
1689 let Inst{13} = isTak;
1690 let Inst{21-20} = offset{10-9};
1691 let Inst{7-1} = offset{8-2};
1694 multiclass NVJ_ConstImm_cond<string mnemonic, bits<3> majOp, string ImmVal,
1696 // Branch not taken:
1697 def _nt: NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 0>;
1699 def _t : NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 1>;
1702 multiclass NVJ_ConstImm_base<string mnemonic, string BaseOp, bits<3> majOp,
1704 let BaseOpcode = BaseOp#_NVJ_ConstImm in {
1705 defm _t_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 0>; // True
1706 defm _f_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 1>; // False
1710 // if ([!]tstbit(Ns.new,#0)) jump:[n]t #r9:2
1711 // if ([!]cmp.eq(Ns.new,#-1)) jump:[n]t #r9:2
1712 // if ([!]cmp.gt(Ns.new,#-1)) jump:[n]t #r9:2
1714 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1,
1715 Defs = [PC], hasSideEffects = 0 in {
1716 defm J4_tstbit0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel;
1717 defm J4_cmpeqn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "-1">, PredRel;
1718 defm J4_cmpgtn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "-1">, PredRel;
1721 // J4_hintjumpr: Hint indirect conditional jump.
1722 let isBranch = 1, isIndirectBranch = 1, hasSideEffects = 0 in
1723 def J4_hintjumpr: JRInst <
1728 let IClass = 0b0101;
1729 let Inst{27-21} = 0b0010101;
1730 let Inst{20-16} = Rs;
1733 //===----------------------------------------------------------------------===//
1735 //===----------------------------------------------------------------------===//
1737 //===----------------------------------------------------------------------===//
1739 //===----------------------------------------------------------------------===//
1742 let hasNewValue = 1, isExtendable = 1, opExtendable = 1,
1743 isExtentSigned = 0, opExtentBits = 6, hasSideEffects = 0, Uses = [PC] in
1744 def C4_addipc : CRInst <(outs IntRegs:$Rd), (ins u6Ext:$u6),
1745 "$Rd = add(pc, #$u6)", [], "", CR_tc_2_SLOT3 > {
1749 let IClass = 0b0110;
1750 let Inst{27-16} = 0b101001001001;
1751 let Inst{12-7} = u6;
1757 let hasSideEffects = 0 in
1758 class T_LOGICAL_3OP<string MnOp1, string MnOp2, bits<2> OpBits, bit IsNeg>
1759 : CRInst<(outs PredRegs:$Pd),
1760 (ins PredRegs:$Ps, PredRegs:$Pt, PredRegs:$Pu),
1761 "$Pd = " # MnOp1 # "($Ps, " # MnOp2 # "($Pt, " #
1762 !if (IsNeg,"!","") # "$Pu))",
1763 [], "", CR_tc_2early_SLOT23> {
1769 let IClass = 0b0110;
1770 let Inst{27-24} = 0b1011;
1771 let Inst{23} = IsNeg;
1772 let Inst{22-21} = OpBits;
1774 let Inst{17-16} = Ps;
1781 def C4_and_and : T_LOGICAL_3OP<"and", "and", 0b00, 0>;
1782 def C4_and_or : T_LOGICAL_3OP<"and", "or", 0b01, 0>;
1783 def C4_or_and : T_LOGICAL_3OP<"or", "and", 0b10, 0>;
1784 def C4_or_or : T_LOGICAL_3OP<"or", "or", 0b11, 0>;
1785 def C4_and_andn : T_LOGICAL_3OP<"and", "and", 0b00, 1>;
1786 def C4_and_orn : T_LOGICAL_3OP<"and", "or", 0b01, 1>;
1787 def C4_or_andn : T_LOGICAL_3OP<"or", "and", 0b10, 1>;
1788 def C4_or_orn : T_LOGICAL_3OP<"or", "or", 0b11, 1>;
1790 // op(Ps, op(Pt, Pu))
1791 class LogLog_pat<SDNode Op1, SDNode Op2, InstHexagon MI>
1792 : Pat<(i1 (Op1 I1:$Ps, (Op2 I1:$Pt, I1:$Pu))),
1793 (MI I1:$Ps, I1:$Pt, I1:$Pu)>;
1795 // op(Ps, op(Pt, ~Pu))
1796 class LogLogNot_pat<SDNode Op1, SDNode Op2, InstHexagon MI>
1797 : Pat<(i1 (Op1 I1:$Ps, (Op2 I1:$Pt, (not I1:$Pu)))),
1798 (MI I1:$Ps, I1:$Pt, I1:$Pu)>;
1800 def: LogLog_pat<and, and, C4_and_and>;
1801 def: LogLog_pat<and, or, C4_and_or>;
1802 def: LogLog_pat<or, and, C4_or_and>;
1803 def: LogLog_pat<or, or, C4_or_or>;
1805 def: LogLogNot_pat<and, and, C4_and_andn>;
1806 def: LogLogNot_pat<and, or, C4_and_orn>;
1807 def: LogLogNot_pat<or, and, C4_or_andn>;
1808 def: LogLogNot_pat<or, or, C4_or_orn>;
1810 //===----------------------------------------------------------------------===//
1811 // PIC: Support for PIC compilations. The patterns and SD nodes defined
1812 // below are needed to support code generation for PIC
1813 //===----------------------------------------------------------------------===//
1815 def SDT_HexagonPICAdd
1816 : SDTypeProfile<1, 1, [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
1817 def SDT_HexagonGOTAdd
1818 : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
1820 def SDT_HexagonGOTAddInternal : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
1821 def SDT_HexagonGOTAddInternalJT : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
1822 def SDT_HexagonGOTAddInternalBA : SDTypeProfile<1, 1, [SDTCisVT<0, i32>]>;
1824 def Hexagonpic_add : SDNode<"HexagonISD::PIC_ADD", SDT_HexagonPICAdd>;
1825 def Hexagonat_got : SDNode<"HexagonISD::AT_GOT", SDT_HexagonGOTAdd>;
1826 def Hexagongat_pcrel : SDNode<"HexagonISD::AT_PCREL",
1827 SDT_HexagonGOTAddInternal>;
1828 def Hexagongat_pcrel_jt : SDNode<"HexagonISD::AT_PCREL",
1829 SDT_HexagonGOTAddInternalJT>;
1830 def Hexagongat_pcrel_ba : SDNode<"HexagonISD::AT_PCREL",
1831 SDT_HexagonGOTAddInternalBA>;
1833 // PIC: Map from a block address computation to a PC-relative add
1834 def: Pat<(Hexagongat_pcrel_ba tblockaddress:$src1),
1835 (C4_addipc u32ImmPred:$src1)>;
1837 // PIC: Map from the computation to generate a GOT pointer to a PC-relative add
1838 def: Pat<(Hexagonpic_add texternalsym:$src1),
1839 (C4_addipc u32ImmPred:$src1)>;
1841 // PIC: Map from a jump table address computation to a PC-relative add
1842 def: Pat<(Hexagongat_pcrel_jt tjumptable:$src1),
1843 (C4_addipc u32ImmPred:$src1)>;
1845 // PIC: Map from a GOT-relative symbol reference to a load
1846 def: Pat<(Hexagonat_got (i32 IntRegs:$src1), tglobaladdr:$src2),
1847 (L2_loadri_io IntRegs:$src1, s30_2ImmPred:$src2)>;
1849 // PIC: Map from a static symbol reference to a PC-relative add
1850 def: Pat<(Hexagongat_pcrel tglobaladdr:$src1),
1851 (C4_addipc u32ImmPred:$src1)>;
1853 //===----------------------------------------------------------------------===//
1855 //===----------------------------------------------------------------------===//
1857 //===----------------------------------------------------------------------===//
1859 //===----------------------------------------------------------------------===//
1861 // Logical with-not instructions.
1862 def A4_andnp : T_ALU64_logical<"and", 0b001, 1, 0, 1>;
1863 def A4_ornp : T_ALU64_logical<"or", 0b011, 1, 0, 1>;
1865 def: Pat<(i64 (and (i64 DoubleRegs:$Rs), (i64 (not (i64 DoubleRegs:$Rt))))),
1866 (A4_andnp DoubleRegs:$Rs, DoubleRegs:$Rt)>;
1867 def: Pat<(i64 (or (i64 DoubleRegs:$Rs), (i64 (not (i64 DoubleRegs:$Rt))))),
1868 (A4_ornp DoubleRegs:$Rs, DoubleRegs:$Rt)>;
1870 let hasNewValue = 1, hasSideEffects = 0 in
1871 def S4_parity: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1872 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1877 let IClass = 0b1101;
1878 let Inst{27-21} = 0b0101111;
1879 let Inst{20-16} = Rs;
1880 let Inst{12-8} = Rt;
1884 // Add and accumulate.
1885 // Rd=add(Rs,add(Ru,#s6))
1886 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 6,
1888 def S4_addaddi : ALU64Inst <(outs IntRegs:$Rd),
1889 (ins IntRegs:$Rs, IntRegs:$Ru, s6Ext:$s6),
1890 "$Rd = add($Rs, add($Ru, #$s6))" ,
1891 [(set (i32 IntRegs:$Rd), (add (i32 IntRegs:$Rs),
1892 (add (i32 IntRegs:$Ru), s16_16ImmPred:$s6)))],
1893 "", ALU64_tc_2_SLOT23> {
1899 let IClass = 0b1101;
1901 let Inst{27-23} = 0b10110;
1902 let Inst{22-21} = s6{5-4};
1903 let Inst{20-16} = Rs;
1904 let Inst{13} = s6{3};
1905 let Inst{12-8} = Rd;
1906 let Inst{7-5} = s6{2-0};
1910 let isExtentSigned = 1, hasSideEffects = 0, hasNewValue = 1, isExtendable = 1,
1911 opExtentBits = 6, opExtendable = 2 in
1912 def S4_subaddi: ALU64Inst <(outs IntRegs:$Rd),
1913 (ins IntRegs:$Rs, s6Ext:$s6, IntRegs:$Ru),
1914 "$Rd = add($Rs, sub(#$s6, $Ru))",
1915 [], "", ALU64_tc_2_SLOT23> {
1921 let IClass = 0b1101;
1923 let Inst{27-23} = 0b10111;
1924 let Inst{22-21} = s6{5-4};
1925 let Inst{20-16} = Rs;
1926 let Inst{13} = s6{3};
1927 let Inst{12-8} = Rd;
1928 let Inst{7-5} = s6{2-0};
1932 // Rd=add(Rs,sub(#s6,Ru))
1933 def: Pat<(add (i32 IntRegs:$src1), (sub s32ImmPred:$src2,
1934 (i32 IntRegs:$src3))),
1935 (S4_subaddi IntRegs:$src1, s32ImmPred:$src2, IntRegs:$src3)>;
1937 // Rd=sub(add(Rs,#s6),Ru)
1938 def: Pat<(sub (add (i32 IntRegs:$src1), s32ImmPred:$src2),
1939 (i32 IntRegs:$src3)),
1940 (S4_subaddi IntRegs:$src1, s32ImmPred:$src2, IntRegs:$src3)>;
1942 // Rd=add(sub(Rs,Ru),#s6)
1943 def: Pat<(add (sub (i32 IntRegs:$src1), (i32 IntRegs:$src3)),
1944 (s32ImmPred:$src2)),
1945 (S4_subaddi IntRegs:$src1, s32ImmPred:$src2, IntRegs:$src3)>;
1948 // Add or subtract doublewords with carry.
1950 // Rdd=add(Rss,Rtt,Px):carry
1952 // Rdd=sub(Rss,Rtt,Px):carry
1955 // Rdd=extract(Rss,#u6,#U6)
1956 // Rdd=extract(Rss,Rtt)
1957 // Rd=extract(Rs,Rtt)
1958 // Rd=extract(Rs,#u5,#U5)
1960 def S4_extractp_rp : T_S3op_64 < "extract", 0b11, 0b100, 0>;
1961 def S4_extractp : T_S2op_extract <"extract", 0b1010, DoubleRegs, u6Imm>;
1963 let hasNewValue = 1 in {
1964 def S4_extract_rp : T_S3op_extract<"extract", 0b01>;
1965 def S4_extract : T_S2op_extract <"extract", 0b1101, IntRegs, u5Imm>;
1968 // Complex add/sub halfwords/words
1969 let Defs = [USR_OVF] in {
1970 def S4_vxaddsubh : T_S3op_64 < "vxaddsubh", 0b01, 0b100, 0, 1>;
1971 def S4_vxaddsubw : T_S3op_64 < "vxaddsubw", 0b01, 0b000, 0, 1>;
1972 def S4_vxsubaddh : T_S3op_64 < "vxsubaddh", 0b01, 0b110, 0, 1>;
1973 def S4_vxsubaddw : T_S3op_64 < "vxsubaddw", 0b01, 0b010, 0, 1>;
1976 let Defs = [USR_OVF] in {
1977 def S4_vxaddsubhr : T_S3op_64 < "vxaddsubh", 0b11, 0b000, 0, 1, 1, 1>;
1978 def S4_vxsubaddhr : T_S3op_64 < "vxsubaddh", 0b11, 0b010, 0, 1, 1, 1>;
1981 let Itinerary = M_tc_3x_SLOT23, Defs = [USR_OVF] in {
1982 def M4_mac_up_s1_sat: T_MType_acc_rr<"+= mpy", 0b011, 0b000, 0, [], 0, 1, 1>;
1983 def M4_nac_up_s1_sat: T_MType_acc_rr<"-= mpy", 0b011, 0b001, 0, [], 0, 1, 1>;
1986 // Logical xor with xor accumulation.
1987 // Rxx^=xor(Rss,Rtt)
1988 let hasSideEffects = 0 in
1990 : SInst <(outs DoubleRegs:$Rxx),
1991 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
1992 "$Rxx ^= xor($Rss, $Rtt)",
1993 [(set (i64 DoubleRegs:$Rxx),
1994 (xor (i64 DoubleRegs:$dst2), (xor (i64 DoubleRegs:$Rss),
1995 (i64 DoubleRegs:$Rtt))))],
1996 "$dst2 = $Rxx", S_3op_tc_1_SLOT23> {
2001 let IClass = 0b1100;
2003 let Inst{27-22} = 0b101010;
2004 let Inst{20-16} = Rss;
2005 let Inst{12-8} = Rtt;
2006 let Inst{7-5} = 0b000;
2007 let Inst{4-0} = Rxx;
2010 // Rotate and reduce bytes
2011 // Rdd=vrcrotate(Rss,Rt,#u2)
2012 let hasSideEffects = 0 in
2014 : SInst <(outs DoubleRegs:$Rdd),
2015 (ins DoubleRegs:$Rss, IntRegs:$Rt, u2Imm:$u2),
2016 "$Rdd = vrcrotate($Rss, $Rt, #$u2)",
2017 [], "", S_3op_tc_3x_SLOT23> {
2023 let IClass = 0b1100;
2025 let Inst{27-22} = 0b001111;
2026 let Inst{20-16} = Rss;
2027 let Inst{13} = u2{1};
2028 let Inst{12-8} = Rt;
2029 let Inst{7-6} = 0b11;
2030 let Inst{5} = u2{0};
2031 let Inst{4-0} = Rdd;
2034 // Rotate and reduce bytes with accumulation
2035 // Rxx+=vrcrotate(Rss,Rt,#u2)
2036 let hasSideEffects = 0 in
2037 def S4_vrcrotate_acc
2038 : SInst <(outs DoubleRegs:$Rxx),
2039 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt, u2Imm:$u2),
2040 "$Rxx += vrcrotate($Rss, $Rt, #$u2)", [],
2041 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
2047 let IClass = 0b1100;
2049 let Inst{27-21} = 0b1011101;
2050 let Inst{20-16} = Rss;
2051 let Inst{13} = u2{1};
2052 let Inst{12-8} = Rt;
2053 let Inst{5} = u2{0};
2054 let Inst{4-0} = Rxx;
2057 // Vector reduce conditional negate halfwords
2058 let hasSideEffects = 0 in
2060 : SInst <(outs DoubleRegs:$Rxx),
2061 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt),
2062 "$Rxx += vrcnegh($Rss, $Rt)", [],
2063 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
2068 let IClass = 0b1100;
2070 let Inst{27-21} = 0b1011001;
2071 let Inst{20-16} = Rss;
2073 let Inst{12-8} = Rt;
2074 let Inst{7-5} = 0b111;
2075 let Inst{4-0} = Rxx;
2079 def A4_bitspliti : T_S2op_2_di <"bitsplit", 0b110, 0b100>;
2081 // Arithmetic/Convergent round
2082 def A4_cround_ri : T_S2op_2_ii <"cround", 0b111, 0b000>;
2084 def A4_round_ri : T_S2op_2_ii <"round", 0b111, 0b100>;
2086 let Defs = [USR_OVF] in
2087 def A4_round_ri_sat : T_S2op_2_ii <"round", 0b111, 0b110, 1>;
2089 // Logical-logical words.
2090 // Compound or-and -- Rx=or(Ru,and(Rx,#s10))
2091 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 10,
2094 ALU64Inst<(outs IntRegs:$Rx),
2095 (ins IntRegs:$Ru, IntRegs:$_src_, s10Ext:$s10),
2096 "$Rx = or($Ru, and($_src_, #$s10))" ,
2097 [(set (i32 IntRegs:$Rx),
2098 (or (i32 IntRegs:$Ru), (and (i32 IntRegs:$_src_), s32ImmPred:$s10)))] ,
2099 "$_src_ = $Rx", ALU64_tc_2_SLOT23> {
2104 let IClass = 0b1101;
2106 let Inst{27-22} = 0b101001;
2107 let Inst{20-16} = Rx;
2108 let Inst{21} = s10{9};
2109 let Inst{13-5} = s10{8-0};
2113 // Miscellaneous ALU64 instructions.
2115 let hasNewValue = 1, hasSideEffects = 0 in
2116 def A4_modwrapu: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
2117 "$Rd = modwrap($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
2122 let IClass = 0b1101;
2123 let Inst{27-21} = 0b0011111;
2124 let Inst{20-16} = Rs;
2125 let Inst{12-8} = Rt;
2126 let Inst{7-5} = 0b111;
2130 let hasSideEffects = 0 in
2131 def A4_bitsplit: ALU64Inst<(outs DoubleRegs:$Rd),
2132 (ins IntRegs:$Rs, IntRegs:$Rt),
2133 "$Rd = bitsplit($Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
2138 let IClass = 0b1101;
2139 let Inst{27-24} = 0b0100;
2141 let Inst{20-16} = Rs;
2142 let Inst{12-8} = Rt;
2146 let hasSideEffects = 0 in
2147 def dep_S2_packhl: ALU64Inst<(outs DoubleRegs:$Rd),
2148 (ins IntRegs:$Rs, IntRegs:$Rt),
2149 "$Rd = packhl($Rs, $Rt):deprecated", [], "", ALU64_tc_1_SLOT23> {
2154 let IClass = 0b1101;
2155 let Inst{27-24} = 0b0100;
2157 let Inst{20-16} = Rs;
2158 let Inst{12-8} = Rt;
2162 let hasNewValue = 1, hasSideEffects = 0 in
2163 def dep_A2_addsat: ALU64Inst<(outs IntRegs:$Rd),
2164 (ins IntRegs:$Rs, IntRegs:$Rt),
2165 "$Rd = add($Rs, $Rt):sat:deprecated", [], "", ALU64_tc_2_SLOT23> {
2170 let IClass = 0b1101;
2171 let Inst{27-21} = 0b0101100;
2172 let Inst{20-16} = Rs;
2173 let Inst{12-8} = Rt;
2178 let hasNewValue = 1, hasSideEffects = 0 in
2179 def dep_A2_subsat: ALU64Inst<(outs IntRegs:$Rd),
2180 (ins IntRegs:$Rs, IntRegs:$Rt),
2181 "$Rd = sub($Rs, $Rt):sat:deprecated", [], "", ALU64_tc_2_SLOT23> {
2186 let IClass = 0b1101;
2187 let Inst{27-21} = 0b0101100;
2188 let Inst{20-16} = Rt;
2189 let Inst{12-8} = Rs;
2194 // Rx[&|]=xor(Rs,Rt)
2195 def M4_or_xor : T_MType_acc_rr < "|= xor", 0b110, 0b001, 0>;
2196 def M4_and_xor : T_MType_acc_rr < "&= xor", 0b010, 0b010, 0>;
2198 // Rx[&|^]=or(Rs,Rt)
2199 def M4_xor_or : T_MType_acc_rr < "^= or", 0b110, 0b011, 0>;
2201 let CextOpcode = "ORr_ORr" in
2202 def M4_or_or : T_MType_acc_rr < "|= or", 0b110, 0b000, 0>;
2203 def M4_and_or : T_MType_acc_rr < "&= or", 0b010, 0b001, 0>;
2205 // Rx[&|^]=and(Rs,Rt)
2206 def M4_xor_and : T_MType_acc_rr < "^= and", 0b110, 0b010, 0>;
2208 let CextOpcode = "ORr_ANDr" in
2209 def M4_or_and : T_MType_acc_rr < "|= and", 0b010, 0b011, 0>;
2210 def M4_and_and : T_MType_acc_rr < "&= and", 0b010, 0b000, 0>;
2212 // Rx[&|^]=and(Rs,~Rt)
2213 def M4_xor_andn : T_MType_acc_rr < "^= and", 0b001, 0b010, 0, [], 1>;
2214 def M4_or_andn : T_MType_acc_rr < "|= and", 0b001, 0b000, 0, [], 1>;
2215 def M4_and_andn : T_MType_acc_rr < "&= and", 0b001, 0b001, 0, [], 1>;
2217 def: T_MType_acc_pat2 <M4_or_xor, xor, or>;
2218 def: T_MType_acc_pat2 <M4_and_xor, xor, and>;
2219 def: T_MType_acc_pat2 <M4_or_and, and, or>;
2220 def: T_MType_acc_pat2 <M4_and_and, and, and>;
2221 def: T_MType_acc_pat2 <M4_xor_and, and, xor>;
2222 def: T_MType_acc_pat2 <M4_or_or, or, or>;
2223 def: T_MType_acc_pat2 <M4_and_or, or, and>;
2224 def: T_MType_acc_pat2 <M4_xor_or, or, xor>;
2226 class T_MType_acc_pat3 <InstHexagon MI, SDNode firstOp, SDNode secOp>
2227 : Pat <(i32 (secOp IntRegs:$src1, (firstOp IntRegs:$src2,
2228 (not IntRegs:$src3)))),
2229 (i32 (MI IntRegs:$src1, IntRegs:$src2, IntRegs:$src3))>;
2231 def: T_MType_acc_pat3 <M4_or_andn, and, or>;
2232 def: T_MType_acc_pat3 <M4_and_andn, and, and>;
2233 def: T_MType_acc_pat3 <M4_xor_andn, and, xor>;
2235 // Compound or-or and or-and
2236 let isExtentSigned = 1, InputType = "imm", hasNewValue = 1, isExtendable = 1,
2237 opExtentBits = 10, opExtendable = 3 in
2238 class T_CompOR <string mnemonic, bits<2> MajOp, SDNode OpNode>
2239 : MInst_acc <(outs IntRegs:$Rx),
2240 (ins IntRegs:$src1, IntRegs:$Rs, s10Ext:$s10),
2241 "$Rx |= "#mnemonic#"($Rs, #$s10)",
2242 [(set (i32 IntRegs:$Rx), (or (i32 IntRegs:$src1),
2243 (OpNode (i32 IntRegs:$Rs), s32ImmPred:$s10)))],
2244 "$src1 = $Rx", ALU64_tc_2_SLOT23>, ImmRegRel {
2249 let IClass = 0b1101;
2251 let Inst{27-24} = 0b1010;
2252 let Inst{23-22} = MajOp;
2253 let Inst{20-16} = Rs;
2254 let Inst{21} = s10{9};
2255 let Inst{13-5} = s10{8-0};
2259 let CextOpcode = "ORr_ANDr" in
2260 def S4_or_andi : T_CompOR <"and", 0b00, and>;
2262 let CextOpcode = "ORr_ORr" in
2263 def S4_or_ori : T_CompOR <"or", 0b10, or>;
2266 // Rd=modwrap(Rs,Rt)
2268 // Rd=cround(Rs,#u5)
2270 // Rd=round(Rs,#u5)[:sat]
2271 // Rd=round(Rs,Rt)[:sat]
2272 // Vector reduce add unsigned halfwords
2273 // Rd=vraddh(Rss,Rtt)
2275 // Rdd=vaddb(Rss,Rtt)
2276 // Vector conditional negate
2277 // Rdd=vcnegh(Rss,Rt)
2278 // Rxx+=vrcnegh(Rss,Rt)
2279 // Vector maximum bytes
2280 // Rdd=vmaxb(Rtt,Rss)
2281 // Vector reduce maximum halfwords
2282 // Rxx=vrmaxh(Rss,Ru)
2283 // Rxx=vrmaxuh(Rss,Ru)
2284 // Vector reduce maximum words
2285 // Rxx=vrmaxuw(Rss,Ru)
2286 // Rxx=vrmaxw(Rss,Ru)
2287 // Vector minimum bytes
2288 // Rdd=vminb(Rtt,Rss)
2289 // Vector reduce minimum halfwords
2290 // Rxx=vrminh(Rss,Ru)
2291 // Rxx=vrminuh(Rss,Ru)
2292 // Vector reduce minimum words
2293 // Rxx=vrminuw(Rss,Ru)
2294 // Rxx=vrminw(Rss,Ru)
2295 // Vector subtract bytes
2296 // Rdd=vsubb(Rss,Rtt)
2298 //===----------------------------------------------------------------------===//
2300 //===----------------------------------------------------------------------===//
2302 //===----------------------------------------------------------------------===//
2304 //===----------------------------------------------------------------------===//
2307 def S2_brevp : T_S2op_3 <"brev", 0b11, 0b110>;
2310 def S2_ct0p : T_COUNT_LEADING_64<"ct0", 0b111, 0b010>;
2311 def S2_ct1p : T_COUNT_LEADING_64<"ct1", 0b111, 0b100>;
2312 def S4_clbpnorm : T_COUNT_LEADING_64<"normamt", 0b011, 0b000>;
2314 def: Pat<(i32 (trunc (cttz (i64 DoubleRegs:$Rss)))),
2315 (S2_ct0p (i64 DoubleRegs:$Rss))>;
2316 def: Pat<(i32 (trunc (cttz (not (i64 DoubleRegs:$Rss))))),
2317 (S2_ct1p (i64 DoubleRegs:$Rss))>;
2319 let hasSideEffects = 0, hasNewValue = 1 in
2320 def S4_clbaddi : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s6Imm:$s6),
2321 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
2325 let IClass = 0b1000;
2326 let Inst{27-24} = 0b1100;
2327 let Inst{23-21} = 0b001;
2328 let Inst{20-16} = Rs;
2329 let Inst{13-8} = s6;
2330 let Inst{7-5} = 0b000;
2334 let hasSideEffects = 0, hasNewValue = 1 in
2335 def S4_clbpaddi : SInst<(outs IntRegs:$Rd), (ins DoubleRegs:$Rs, s6Imm:$s6),
2336 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
2340 let IClass = 0b1000;
2341 let Inst{27-24} = 0b1000;
2342 let Inst{23-21} = 0b011;
2343 let Inst{20-16} = Rs;
2344 let Inst{13-8} = s6;
2345 let Inst{7-5} = 0b010;
2350 // Bit test/set/clear
2351 def S4_ntstbit_i : T_TEST_BIT_IMM<"!tstbit", 0b001>;
2352 def S4_ntstbit_r : T_TEST_BIT_REG<"!tstbit", 1>;
2354 let AddedComplexity = 20 in { // Complexity greater than cmp reg-imm.
2355 def: Pat<(i1 (seteq (and (shl 1, u5ImmPred:$u5), (i32 IntRegs:$Rs)), 0)),
2356 (S4_ntstbit_i (i32 IntRegs:$Rs), u5ImmPred:$u5)>;
2357 def: Pat<(i1 (seteq (and (shl 1, (i32 IntRegs:$Rt)), (i32 IntRegs:$Rs)), 0)),
2358 (S4_ntstbit_r (i32 IntRegs:$Rs), (i32 IntRegs:$Rt))>;
2361 // Add extra complexity to prefer these instructions over bitsset/bitsclr.
2362 // The reason is that tstbit/ntstbit can be folded into a compound instruction:
2363 // if ([!]tstbit(...)) jump ...
2364 let AddedComplexity = 100 in
2365 def: Pat<(i1 (setne (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2366 (S2_tstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2368 let AddedComplexity = 100 in
2369 def: Pat<(i1 (seteq (and (i32 IntRegs:$Rs), (i32 Set5ImmPred:$u5)), (i32 0))),
2370 (S4_ntstbit_i (i32 IntRegs:$Rs), (BITPOS32 Set5ImmPred:$u5))>;
2372 def C4_nbitsset : T_TEST_BITS_REG<"!bitsset", 0b01, 1>;
2373 def C4_nbitsclr : T_TEST_BITS_REG<"!bitsclr", 0b10, 1>;
2374 def C4_nbitsclri : T_TEST_BITS_IMM<"!bitsclr", 0b10, 1>;
2376 // Do not increase complexity of these patterns. In the DAG, "cmp i8" may be
2377 // represented as a compare against "value & 0xFF", which is an exact match
2378 // for cmpb (same for cmph). The patterns below do not contain any additional
2379 // complexity that would make them preferable, and if they were actually used
2380 // instead of cmpb/cmph, they would result in a compare against register that
2381 // is loaded with the byte/half mask (i.e. 0xFF or 0xFFFF).
2382 def: Pat<(i1 (setne (and I32:$Rs, u6ImmPred:$u6), 0)),
2383 (C4_nbitsclri I32:$Rs, u6ImmPred:$u6)>;
2384 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), 0)),
2385 (C4_nbitsclr I32:$Rs, I32:$Rt)>;
2386 def: Pat<(i1 (setne (and I32:$Rs, I32:$Rt), I32:$Rt)),
2387 (C4_nbitsset I32:$Rs, I32:$Rt)>;
2389 //===----------------------------------------------------------------------===//
2391 //===----------------------------------------------------------------------===//
2393 //===----------------------------------------------------------------------===//
2395 //===----------------------------------------------------------------------===//
2397 // Rd=add(#u6,mpyi(Rs,#U6)) -- Multiply by immed and add immed.
2399 let hasNewValue = 1, isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
2400 def M4_mpyri_addi : MInst<(outs IntRegs:$Rd),
2401 (ins u6Ext:$u6, IntRegs:$Rs, u6Imm:$U6),
2402 "$Rd = add(#$u6, mpyi($Rs, #$U6))" ,
2403 [(set (i32 IntRegs:$Rd),
2404 (add (mul (i32 IntRegs:$Rs), u6ImmPred:$U6),
2405 u32ImmPred:$u6))] ,"",ALU64_tc_3x_SLOT23> {
2411 let IClass = 0b1101;
2413 let Inst{27-24} = 0b1000;
2414 let Inst{23} = U6{5};
2415 let Inst{22-21} = u6{5-4};
2416 let Inst{20-16} = Rs;
2417 let Inst{13} = u6{3};
2418 let Inst{12-8} = Rd;
2419 let Inst{7-5} = u6{2-0};
2420 let Inst{4-0} = U6{4-0};
2423 // Rd=add(#u6,mpyi(Rs,Rt))
2424 let CextOpcode = "ADD_MPY", InputType = "imm", hasNewValue = 1,
2425 isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
2426 def M4_mpyrr_addi : MInst <(outs IntRegs:$Rd),
2427 (ins u6Ext:$u6, IntRegs:$Rs, IntRegs:$Rt),
2428 "$Rd = add(#$u6, mpyi($Rs, $Rt))" ,
2429 [(set (i32 IntRegs:$Rd),
2430 (add (mul (i32 IntRegs:$Rs), (i32 IntRegs:$Rt)), u32ImmPred:$u6))],
2431 "", ALU64_tc_3x_SLOT23>, ImmRegRel {
2437 let IClass = 0b1101;
2439 let Inst{27-23} = 0b01110;
2440 let Inst{22-21} = u6{5-4};
2441 let Inst{20-16} = Rs;
2442 let Inst{13} = u6{3};
2443 let Inst{12-8} = Rt;
2444 let Inst{7-5} = u6{2-0};
2448 let hasNewValue = 1 in
2449 class T_AddMpy <bit MajOp, PatLeaf ImmPred, dag ins>
2450 : ALU64Inst <(outs IntRegs:$dst), ins,
2451 "$dst = add($src1, mpyi("#!if(MajOp,"$src3, #$src2))",
2453 [(set (i32 IntRegs:$dst),
2454 (add (i32 IntRegs:$src1), (mul (i32 IntRegs:$src3), ImmPred:$src2)))],
2455 "", ALU64_tc_3x_SLOT23> {
2461 let IClass = 0b1101;
2463 bits<6> ImmValue = !if(MajOp, src2{5-0}, src2{7-2});
2465 let Inst{27-24} = 0b1111;
2466 let Inst{23} = MajOp;
2467 let Inst{22-21} = ImmValue{5-4};
2468 let Inst{20-16} = src3;
2469 let Inst{13} = ImmValue{3};
2470 let Inst{12-8} = dst;
2471 let Inst{7-5} = ImmValue{2-0};
2472 let Inst{4-0} = src1;
2475 def M4_mpyri_addr_u2 : T_AddMpy<0b0, u6_2ImmPred,
2476 (ins IntRegs:$src1, u6_2Imm:$src2, IntRegs:$src3)>;
2478 let isExtendable = 1, opExtentBits = 6, opExtendable = 3,
2479 CextOpcode = "ADD_MPY", InputType = "imm" in
2480 def M4_mpyri_addr : T_AddMpy<0b1, u32ImmPred,
2481 (ins IntRegs:$src1, IntRegs:$src3, u6Ext:$src2)>, ImmRegRel;
2483 // Rx=add(Ru,mpyi(Rx,Rs))
2484 let CextOpcode = "ADD_MPY", InputType = "reg", hasNewValue = 1 in
2485 def M4_mpyrr_addr: MInst_acc <(outs IntRegs:$Rx),
2486 (ins IntRegs:$Ru, IntRegs:$_src_, IntRegs:$Rs),
2487 "$Rx = add($Ru, mpyi($_src_, $Rs))",
2488 [(set (i32 IntRegs:$Rx), (add (i32 IntRegs:$Ru),
2489 (mul (i32 IntRegs:$_src_), (i32 IntRegs:$Rs))))],
2490 "$_src_ = $Rx", M_tc_3x_SLOT23>, ImmRegRel {
2495 let IClass = 0b1110;
2497 let Inst{27-21} = 0b0011000;
2498 let Inst{12-8} = Rx;
2500 let Inst{20-16} = Rs;
2504 // Vector reduce multiply word by signed half (32x16)
2505 //Rdd=vrmpyweh(Rss,Rtt)[:<<1]
2506 def M4_vrmpyeh_s0 : T_M2_vmpy<"vrmpyweh", 0b010, 0b100, 0, 0, 0>;
2507 def M4_vrmpyeh_s1 : T_M2_vmpy<"vrmpyweh", 0b110, 0b100, 1, 0, 0>;
2509 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2510 def M4_vrmpyoh_s0 : T_M2_vmpy<"vrmpywoh", 0b001, 0b010, 0, 0, 0>;
2511 def M4_vrmpyoh_s1 : T_M2_vmpy<"vrmpywoh", 0b101, 0b010, 1, 0, 0>;
2513 //Rdd+=vrmpyweh(Rss,Rtt)[:<<1]
2514 def M4_vrmpyeh_acc_s0: T_M2_vmpy_acc<"vrmpyweh", 0b001, 0b110, 0, 0>;
2515 def M4_vrmpyeh_acc_s1: T_M2_vmpy_acc<"vrmpyweh", 0b101, 0b110, 1, 0>;
2517 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2518 def M4_vrmpyoh_acc_s0: T_M2_vmpy_acc<"vrmpywoh", 0b011, 0b110, 0, 0>;
2519 def M4_vrmpyoh_acc_s1: T_M2_vmpy_acc<"vrmpywoh", 0b111, 0b110, 1, 0>;
2521 // Vector multiply halfwords, signed by unsigned
2522 // Rdd=vmpyhsu(Rs,Rt)[:<<]:sat
2523 def M2_vmpy2su_s0 : T_XTYPE_mpy64 < "vmpyhsu", 0b000, 0b111, 1, 0, 0>;
2524 def M2_vmpy2su_s1 : T_XTYPE_mpy64 < "vmpyhsu", 0b100, 0b111, 1, 1, 0>;
2526 // Rxx+=vmpyhsu(Rs,Rt)[:<<1]:sat
2527 def M2_vmac2su_s0 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b011, 0b101, 1, 0, 0>;
2528 def M2_vmac2su_s1 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b111, 0b101, 1, 1, 0>;
2530 // Vector polynomial multiply halfwords
2531 // Rdd=vpmpyh(Rs,Rt)
2532 def M4_vpmpyh : T_XTYPE_mpy64 < "vpmpyh", 0b110, 0b111, 0, 0, 0>;
2534 // Rxx^=vpmpyh(Rs,Rt)
2535 def M4_vpmpyh_acc : T_XTYPE_mpy64_acc < "vpmpyh", "^", 0b101, 0b111, 0, 0, 0>;
2537 // Polynomial multiply words
2539 def M4_pmpyw : T_XTYPE_mpy64 < "pmpyw", 0b010, 0b111, 0, 0, 0>;
2541 // Rxx^=pmpyw(Rs,Rt)
2542 def M4_pmpyw_acc : T_XTYPE_mpy64_acc < "pmpyw", "^", 0b001, 0b111, 0, 0, 0>;
2544 //===----------------------------------------------------------------------===//
2546 //===----------------------------------------------------------------------===//
2548 //===----------------------------------------------------------------------===//
2549 // ALU64/Vector compare
2550 //===----------------------------------------------------------------------===//
2551 //===----------------------------------------------------------------------===//
2552 // Template class for vector compare
2553 //===----------------------------------------------------------------------===//
2555 let hasSideEffects = 0 in
2556 class T_vcmpImm <string Str, bits<2> cmpOp, bits<2> minOp, Operand ImmOprnd>
2557 : ALU64_rr <(outs PredRegs:$Pd),
2558 (ins DoubleRegs:$Rss, ImmOprnd:$Imm),
2559 "$Pd = "#Str#"($Rss, #$Imm)",
2560 [], "", ALU64_tc_2early_SLOT23> {
2565 let ImmBits{6-0} = Imm{6-0};
2566 let ImmBits{7} = !if (!eq(cmpOp,0b10), 0b0, Imm{7}); // 0 for vcmp[bhw].gtu
2568 let IClass = 0b1101;
2570 let Inst{27-24} = 0b1100;
2571 let Inst{22-21} = cmpOp;
2572 let Inst{20-16} = Rss;
2573 let Inst{12-5} = ImmBits;
2574 let Inst{4-3} = minOp;
2578 // Vector compare bytes
2579 def A4_vcmpbgt : T_vcmp <"vcmpb.gt", 0b1010>;
2580 def: T_vcmp_pat<A4_vcmpbgt, setgt, v8i8>;
2582 let AsmString = "$Pd = any8(vcmpb.eq($Rss, $Rtt))" in
2583 def A4_vcmpbeq_any : T_vcmp <"any8(vcmpb.gt", 0b1000>;
2585 def A4_vcmpbeqi : T_vcmpImm <"vcmpb.eq", 0b00, 0b00, u8Imm>;
2586 def A4_vcmpbgti : T_vcmpImm <"vcmpb.gt", 0b01, 0b00, s8Imm>;
2587 def A4_vcmpbgtui : T_vcmpImm <"vcmpb.gtu", 0b10, 0b00, u7Imm>;
2589 // Vector compare halfwords
2590 def A4_vcmpheqi : T_vcmpImm <"vcmph.eq", 0b00, 0b01, s8Imm>;
2591 def A4_vcmphgti : T_vcmpImm <"vcmph.gt", 0b01, 0b01, s8Imm>;
2592 def A4_vcmphgtui : T_vcmpImm <"vcmph.gtu", 0b10, 0b01, u7Imm>;
2594 // Vector compare words
2595 def A4_vcmpweqi : T_vcmpImm <"vcmpw.eq", 0b00, 0b10, s8Imm>;
2596 def A4_vcmpwgti : T_vcmpImm <"vcmpw.gt", 0b01, 0b10, s8Imm>;
2597 def A4_vcmpwgtui : T_vcmpImm <"vcmpw.gtu", 0b10, 0b10, u7Imm>;
2599 //===----------------------------------------------------------------------===//
2601 //===----------------------------------------------------------------------===//
2602 // Shift by immediate and accumulate/logical.
2603 // Rx=add(#u8,asl(Rx,#U5)) Rx=add(#u8,lsr(Rx,#U5))
2604 // Rx=sub(#u8,asl(Rx,#U5)) Rx=sub(#u8,lsr(Rx,#U5))
2605 // Rx=and(#u8,asl(Rx,#U5)) Rx=and(#u8,lsr(Rx,#U5))
2606 // Rx=or(#u8,asl(Rx,#U5)) Rx=or(#u8,lsr(Rx,#U5))
2607 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8,
2608 hasNewValue = 1, opNewValue = 0 in
2609 class T_S4_ShiftOperate<string MnOp, string MnSh, SDNode Op, SDNode Sh,
2610 bit asl_lsr, bits<2> MajOp, InstrItinClass Itin>
2611 : MInst_acc<(outs IntRegs:$Rd), (ins u8Ext:$u8, IntRegs:$Rx, u5Imm:$U5),
2612 "$Rd = "#MnOp#"(#$u8, "#MnSh#"($Rx, #$U5))",
2613 [(set (i32 IntRegs:$Rd),
2614 (Op (Sh I32:$Rx, u5ImmPred:$U5), u32ImmPred:$u8))],
2615 "$Rd = $Rx", Itin> {
2622 let IClass = 0b1101;
2623 let Inst{27-24} = 0b1110;
2624 let Inst{23-21} = u8{7-5};
2625 let Inst{20-16} = Rd;
2626 let Inst{13} = u8{4};
2627 let Inst{12-8} = U5;
2628 let Inst{7-5} = u8{3-1};
2629 let Inst{4} = asl_lsr;
2630 let Inst{3} = u8{0};
2631 let Inst{2-1} = MajOp;
2634 multiclass T_ShiftOperate<string mnemonic, SDNode Op, bits<2> MajOp,
2635 InstrItinClass Itin> {
2636 def _asl_ri : T_S4_ShiftOperate<mnemonic, "asl", Op, shl, 0, MajOp, Itin>;
2637 def _lsr_ri : T_S4_ShiftOperate<mnemonic, "lsr", Op, srl, 1, MajOp, Itin>;
2640 let AddedComplexity = 200 in {
2641 defm S4_addi : T_ShiftOperate<"add", add, 0b10, ALU64_tc_2_SLOT23>;
2642 defm S4_andi : T_ShiftOperate<"and", and, 0b00, ALU64_tc_2_SLOT23>;
2645 let AddedComplexity = 30 in
2646 defm S4_ori : T_ShiftOperate<"or", or, 0b01, ALU64_tc_1_SLOT23>;
2648 defm S4_subi : T_ShiftOperate<"sub", sub, 0b11, ALU64_tc_1_SLOT23>;
2650 let AddedComplexity = 200 in {
2651 def: Pat<(add addrga:$addr, (shl I32:$src2, u5ImmPred:$src3)),
2652 (S4_addi_asl_ri addrga:$addr, IntRegs:$src2, u5ImmPred:$src3)>;
2653 def: Pat<(add addrga:$addr, (srl I32:$src2, u5ImmPred:$src3)),
2654 (S4_addi_lsr_ri addrga:$addr, IntRegs:$src2, u5ImmPred:$src3)>;
2655 def: Pat<(sub addrga:$addr, (shl I32:$src2, u5ImmPred:$src3)),
2656 (S4_subi_asl_ri addrga:$addr, IntRegs:$src2, u5ImmPred:$src3)>;
2657 def: Pat<(sub addrga:$addr, (srl I32:$src2, u5ImmPred:$src3)),
2658 (S4_subi_lsr_ri addrga:$addr, IntRegs:$src2, u5ImmPred:$src3)>;
2661 // Vector conditional negate
2662 // Rdd=vcnegh(Rss,Rt)
2663 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2664 def S2_vcnegh : T_S3op_shiftVect < "vcnegh", 0b11, 0b01>;
2666 // Rd=[cround|round](Rs,Rt)
2667 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in {
2668 def A4_cround_rr : T_S3op_3 < "cround", IntRegs, 0b11, 0b00>;
2669 def A4_round_rr : T_S3op_3 < "round", IntRegs, 0b11, 0b10>;
2672 // Rd=round(Rs,Rt):sat
2673 let hasNewValue = 1, Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2674 def A4_round_rr_sat : T_S3op_3 < "round", IntRegs, 0b11, 0b11, 1>;
2676 // Rd=[cmpyiwh|cmpyrwh](Rss,Rt):<<1:rnd:sat
2677 let Defs = [USR_OVF], Itinerary = S_3op_tc_3x_SLOT23 in {
2678 def M4_cmpyi_wh : T_S3op_8<"cmpyiwh", 0b100, 1, 1, 1>;
2679 def M4_cmpyr_wh : T_S3op_8<"cmpyrwh", 0b110, 1, 1, 1>;
2682 // Rdd=[add|sub](Rss,Rtt,Px):carry
2683 let isPredicateLate = 1, hasSideEffects = 0 in
2684 class T_S3op_carry <string mnemonic, bits<3> MajOp>
2685 : SInst < (outs DoubleRegs:$Rdd, PredRegs:$Px),
2686 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
2687 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu):carry",
2688 [], "$Px = $Pu", S_3op_tc_1_SLOT23 > {
2694 let IClass = 0b1100;
2696 let Inst{27-24} = 0b0010;
2697 let Inst{23-21} = MajOp;
2698 let Inst{20-16} = Rss;
2699 let Inst{12-8} = Rtt;
2701 let Inst{4-0} = Rdd;
2704 def A4_addp_c : T_S3op_carry < "add", 0b110 >;
2705 def A4_subp_c : T_S3op_carry < "sub", 0b111 >;
2707 let Itinerary = S_3op_tc_3_SLOT23, hasSideEffects = 0 in
2708 class T_S3op_6 <string mnemonic, bits<3> MinOp, bit isUnsigned>
2709 : SInst <(outs DoubleRegs:$Rxx),
2710 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Ru),
2711 "$Rxx = "#mnemonic#"($Rss, $Ru)" ,
2712 [] , "$dst2 = $Rxx"> {
2717 let IClass = 0b1100;
2719 let Inst{27-21} = 0b1011001;
2720 let Inst{20-16} = Rss;
2721 let Inst{13} = isUnsigned;
2722 let Inst{12-8} = Rxx;
2723 let Inst{7-5} = MinOp;
2727 // Vector reduce maximum halfwords
2728 // Rxx=vrmax[u]h(Rss,Ru)
2729 def A4_vrmaxh : T_S3op_6 < "vrmaxh", 0b001, 0>;
2730 def A4_vrmaxuh : T_S3op_6 < "vrmaxuh", 0b001, 1>;
2732 // Vector reduce maximum words
2733 // Rxx=vrmax[u]w(Rss,Ru)
2734 def A4_vrmaxw : T_S3op_6 < "vrmaxw", 0b010, 0>;
2735 def A4_vrmaxuw : T_S3op_6 < "vrmaxuw", 0b010, 1>;
2737 // Vector reduce minimum halfwords
2738 // Rxx=vrmin[u]h(Rss,Ru)
2739 def A4_vrminh : T_S3op_6 < "vrminh", 0b101, 0>;
2740 def A4_vrminuh : T_S3op_6 < "vrminuh", 0b101, 1>;
2742 // Vector reduce minimum words
2743 // Rxx=vrmin[u]w(Rss,Ru)
2744 def A4_vrminw : T_S3op_6 < "vrminw", 0b110, 0>;
2745 def A4_vrminuw : T_S3op_6 < "vrminuw", 0b110, 1>;
2747 // Shift an immediate left by register amount.
2748 let hasNewValue = 1, hasSideEffects = 0 in
2749 def S4_lsli: SInst <(outs IntRegs:$Rd), (ins s6Imm:$s6, IntRegs:$Rt),
2750 "$Rd = lsl(#$s6, $Rt)" ,
2751 [(set (i32 IntRegs:$Rd), (shl s6ImmPred:$s6,
2752 (i32 IntRegs:$Rt)))],
2753 "", S_3op_tc_1_SLOT23> {
2758 let IClass = 0b1100;
2760 let Inst{27-22} = 0b011010;
2761 let Inst{20-16} = s6{5-1};
2762 let Inst{12-8} = Rt;
2763 let Inst{7-6} = 0b11;
2765 let Inst{5} = s6{0};
2768 //===----------------------------------------------------------------------===//
2770 //===----------------------------------------------------------------------===//
2772 //===----------------------------------------------------------------------===//
2773 // MEMOP: Word, Half, Byte
2774 //===----------------------------------------------------------------------===//
2776 def MEMOPIMM : SDNodeXForm<imm, [{
2777 // Call the transformation function XformM5ToU5Imm to get the negative
2778 // immediate's positive counterpart.
2779 int32_t imm = N->getSExtValue();
2780 return XformM5ToU5Imm(imm);
2783 def MEMOPIMM_HALF : SDNodeXForm<imm, [{
2784 // -1 .. -31 represented as 65535..65515
2785 // assigning to a short restores our desired signed value.
2786 // Call the transformation function XformM5ToU5Imm to get the negative
2787 // immediate's positive counterpart.
2788 int16_t imm = N->getSExtValue();
2789 return XformM5ToU5Imm(imm);
2792 def MEMOPIMM_BYTE : SDNodeXForm<imm, [{
2793 // -1 .. -31 represented as 255..235
2794 // assigning to a char restores our desired signed value.
2795 // Call the transformation function XformM5ToU5Imm to get the negative
2796 // immediate's positive counterpart.
2797 int8_t imm = N->getSExtValue();
2798 return XformM5ToU5Imm(imm);
2801 def SETMEMIMM : SDNodeXForm<imm, [{
2802 // Return the bit position we will set [0-31].
2804 int32_t imm = N->getSExtValue();
2805 return XformMskToBitPosU5Imm(imm);
2808 def CLRMEMIMM : SDNodeXForm<imm, [{
2809 // Return the bit position we will clear [0-31].
2811 // we bit negate the value first
2812 int32_t imm = ~(N->getSExtValue());
2813 return XformMskToBitPosU5Imm(imm);
2816 def SETMEMIMM_SHORT : SDNodeXForm<imm, [{
2817 // Return the bit position we will set [0-15].
2819 int16_t imm = N->getSExtValue();
2820 return XformMskToBitPosU4Imm(imm);
2823 def CLRMEMIMM_SHORT : SDNodeXForm<imm, [{
2824 // Return the bit position we will clear [0-15].
2826 // we bit negate the value first
2827 int16_t imm = ~(N->getSExtValue());
2828 return XformMskToBitPosU4Imm(imm);
2831 def SETMEMIMM_BYTE : SDNodeXForm<imm, [{
2832 // Return the bit position we will set [0-7].
2834 int8_t imm = N->getSExtValue();
2835 return XformMskToBitPosU3Imm(imm);
2838 def CLRMEMIMM_BYTE : SDNodeXForm<imm, [{
2839 // Return the bit position we will clear [0-7].
2841 // we bit negate the value first
2842 int8_t imm = ~(N->getSExtValue());
2843 return XformMskToBitPosU3Imm(imm);
2846 //===----------------------------------------------------------------------===//
2847 // Template class for MemOp instructions with the register value.
2848 //===----------------------------------------------------------------------===//
2849 class MemOp_rr_base <string opc, bits<2> opcBits, Operand ImmOp,
2850 string memOp, bits<2> memOpBits> :
2852 (ins IntRegs:$base, ImmOp:$offset, IntRegs:$delta),
2853 opc#"($base+#$offset)"#memOp#"$delta",
2855 Requires<[UseMEMOP]> {
2860 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2862 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2863 !if (!eq(opcBits, 0b01), offset{6-1},
2864 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2866 let opExtentAlign = opcBits;
2867 let IClass = 0b0011;
2868 let Inst{27-24} = 0b1110;
2869 let Inst{22-21} = opcBits;
2870 let Inst{20-16} = base;
2872 let Inst{12-7} = offsetBits;
2873 let Inst{6-5} = memOpBits;
2874 let Inst{4-0} = delta;
2877 //===----------------------------------------------------------------------===//
2878 // Template class for MemOp instructions with the immediate value.
2879 //===----------------------------------------------------------------------===//
2880 class MemOp_ri_base <string opc, bits<2> opcBits, Operand ImmOp,
2881 string memOp, bits<2> memOpBits> :
2883 (ins IntRegs:$base, ImmOp:$offset, u5Imm:$delta),
2884 opc#"($base+#$offset)"#memOp#"#$delta"
2885 #!if(memOpBits{1},")", ""), // clrbit, setbit - include ')'
2887 Requires<[UseMEMOP]> {
2892 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2894 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2895 !if (!eq(opcBits, 0b01), offset{6-1},
2896 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2898 let opExtentAlign = opcBits;
2899 let IClass = 0b0011;
2900 let Inst{27-24} = 0b1111;
2901 let Inst{22-21} = opcBits;
2902 let Inst{20-16} = base;
2904 let Inst{12-7} = offsetBits;
2905 let Inst{6-5} = memOpBits;
2906 let Inst{4-0} = delta;
2909 // multiclass to define MemOp instructions with register operand.
2910 multiclass MemOp_rr<string opc, bits<2> opcBits, Operand ImmOp> {
2911 def L4_add#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " += ", 0b00>; // add
2912 def L4_sub#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " -= ", 0b01>; // sub
2913 def L4_and#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " &= ", 0b10>; // and
2914 def L4_or#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " |= ", 0b11>; // or
2917 // multiclass to define MemOp instructions with immediate Operand.
2918 multiclass MemOp_ri<string opc, bits<2> opcBits, Operand ImmOp> {
2919 def L4_iadd#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " += ", 0b00 >;
2920 def L4_isub#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " -= ", 0b01 >;
2921 def L4_iand#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = clrbit(", 0b10>;
2922 def L4_ior#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = setbit(", 0b11>;
2925 multiclass MemOp_base <string opc, bits<2> opcBits, Operand ImmOp> {
2926 defm _#NAME : MemOp_rr <opc, opcBits, ImmOp>;
2927 defm _#NAME : MemOp_ri <opc, opcBits, ImmOp>;
2930 // Define MemOp instructions.
2931 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0 in {
2932 let opExtentBits = 6, accessSize = ByteAccess in
2933 defm memopb_io : MemOp_base <"memb", 0b00, u6_0Ext>;
2935 let opExtentBits = 7, accessSize = HalfWordAccess in
2936 defm memoph_io : MemOp_base <"memh", 0b01, u6_1Ext>;
2938 let opExtentBits = 8, accessSize = WordAccess in
2939 defm memopw_io : MemOp_base <"memw", 0b10, u6_2Ext>;
2942 //===----------------------------------------------------------------------===//
2943 // Multiclass to define 'Def Pats' for ALU operations on the memory
2944 // Here value used for the ALU operation is an immediate value.
2945 // mem[bh](Rs+#0) += #U5
2946 // mem[bh](Rs+#u6) += #U5
2947 //===----------------------------------------------------------------------===//
2949 multiclass MemOpi_u5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf ImmPred,
2950 InstHexagon MI, SDNode OpNode> {
2951 let AddedComplexity = 180 in
2952 def: Pat<(stOp (OpNode (ldOp IntRegs:$addr), u5ImmPred:$addend),
2954 (MI IntRegs:$addr, 0, u5ImmPred:$addend)>;
2956 let AddedComplexity = 190 in
2957 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, ImmPred:$offset)),
2959 (add IntRegs:$base, ImmPred:$offset)),
2960 (MI IntRegs:$base, ImmPred:$offset, u5ImmPred:$addend)>;
2963 multiclass MemOpi_u5ALUOp<PatFrag ldOp, PatFrag stOp, PatLeaf ImmPred,
2964 InstHexagon addMI, InstHexagon subMI> {
2965 defm: MemOpi_u5Pats<ldOp, stOp, ImmPred, addMI, add>;
2966 defm: MemOpi_u5Pats<ldOp, stOp, ImmPred, subMI, sub>;
2969 multiclass MemOpi_u5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
2971 defm: MemOpi_u5ALUOp <ldOpHalf, truncstorei16, u31_1ImmPred,
2972 L4_iadd_memoph_io, L4_isub_memoph_io>;
2974 defm: MemOpi_u5ALUOp <ldOpByte, truncstorei8, u32ImmPred,
2975 L4_iadd_memopb_io, L4_isub_memopb_io>;
2978 let Predicates = [UseMEMOP] in {
2979 defm: MemOpi_u5ExtType<zextloadi8, zextloadi16>; // zero extend
2980 defm: MemOpi_u5ExtType<sextloadi8, sextloadi16>; // sign extend
2981 defm: MemOpi_u5ExtType<extloadi8, extloadi16>; // any extend
2984 defm: MemOpi_u5ALUOp <load, store, u30_2ImmPred, L4_iadd_memopw_io,
2988 //===----------------------------------------------------------------------===//
2989 // multiclass to define 'Def Pats' for ALU operations on the memory.
2990 // Here value used for the ALU operation is a negative value.
2991 // mem[bh](Rs+#0) += #m5
2992 // mem[bh](Rs+#u6) += #m5
2993 //===----------------------------------------------------------------------===//
2995 multiclass MemOpi_m5Pats <PatFrag ldOp, PatFrag stOp, PatLeaf ImmPred,
2996 PatLeaf immPred, SDNodeXForm xformFunc,
2998 let AddedComplexity = 190 in
2999 def: Pat<(stOp (add (ldOp IntRegs:$addr), immPred:$subend), IntRegs:$addr),
3000 (MI IntRegs:$addr, 0, (xformFunc immPred:$subend))>;
3002 let AddedComplexity = 195 in
3003 def: Pat<(stOp (add (ldOp (add IntRegs:$base, ImmPred:$offset)),
3005 (add IntRegs:$base, ImmPred:$offset)),
3006 (MI IntRegs:$base, ImmPred:$offset, (xformFunc immPred:$subend))>;
3009 multiclass MemOpi_m5ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
3011 defm: MemOpi_m5Pats <ldOpHalf, truncstorei16, u31_1ImmPred, m5HImmPred,
3012 MEMOPIMM_HALF, L4_isub_memoph_io>;
3014 defm: MemOpi_m5Pats <ldOpByte, truncstorei8, u32ImmPred, m5BImmPred,
3015 MEMOPIMM_BYTE, L4_isub_memopb_io>;
3018 let Predicates = [UseMEMOP] in {
3019 defm: MemOpi_m5ExtType<zextloadi8, zextloadi16>; // zero extend
3020 defm: MemOpi_m5ExtType<sextloadi8, sextloadi16>; // sign extend
3021 defm: MemOpi_m5ExtType<extloadi8, extloadi16>; // any extend
3024 defm: MemOpi_m5Pats <load, store, u30_2ImmPred, m5ImmPred,
3025 MEMOPIMM, L4_isub_memopw_io>;
3028 //===----------------------------------------------------------------------===//
3029 // Multiclass to define 'def Pats' for bit operations on the memory.
3030 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
3031 // mem[bhw](Rs+#u6) = [clrbit|setbit](#U5)
3032 //===----------------------------------------------------------------------===//
3034 multiclass MemOpi_bitPats <PatFrag ldOp, PatFrag stOp, PatLeaf immPred,
3035 PatLeaf extPred, SDNodeXForm xformFunc, InstHexagon MI,
3038 // mem[bhw](Rs+#u6:[012]) = [clrbit|setbit](#U5)
3039 let AddedComplexity = 250 in
3040 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
3042 (add IntRegs:$base, extPred:$offset)),
3043 (MI IntRegs:$base, extPred:$offset, (xformFunc immPred:$bitend))>;
3045 // mem[bhw](Rs+#0) = [clrbit|setbit](#U5)
3046 let AddedComplexity = 225 in
3047 def: Pat<(stOp (OpNode (ldOp IntRegs:$addr), immPred:$bitend), IntRegs:$addr),
3048 (MI IntRegs:$addr, 0, (xformFunc immPred:$bitend))>;
3051 multiclass MemOpi_bitExtType<PatFrag ldOpByte, PatFrag ldOpHalf> {
3053 defm: MemOpi_bitPats<ldOpByte, truncstorei8, Clr3ImmPred, u32ImmPred,
3054 CLRMEMIMM_BYTE, L4_iand_memopb_io, and>;
3056 defm: MemOpi_bitPats<ldOpByte, truncstorei8, Set3ImmPred, u32ImmPred,
3057 SETMEMIMM_BYTE, L4_ior_memopb_io, or>;
3058 // Half Word - clrbit
3059 defm: MemOpi_bitPats<ldOpHalf, truncstorei16, Clr4ImmPred, u31_1ImmPred,
3060 CLRMEMIMM_SHORT, L4_iand_memoph_io, and>;
3061 // Half Word - setbit
3062 defm: MemOpi_bitPats<ldOpHalf, truncstorei16, Set4ImmPred, u31_1ImmPred,
3063 SETMEMIMM_SHORT, L4_ior_memoph_io, or>;
3066 let Predicates = [UseMEMOP] in {
3067 // mem[bh](Rs+#0) = [clrbit|setbit](#U5)
3068 // mem[bh](Rs+#u6:[01]) = [clrbit|setbit](#U5)
3069 defm: MemOpi_bitExtType<zextloadi8, zextloadi16>; // zero extend
3070 defm: MemOpi_bitExtType<sextloadi8, sextloadi16>; // sign extend
3071 defm: MemOpi_bitExtType<extloadi8, extloadi16>; // any extend
3073 // memw(Rs+#0) = [clrbit|setbit](#U5)
3074 // memw(Rs+#u6:2) = [clrbit|setbit](#U5)
3075 defm: MemOpi_bitPats<load, store, Clr5ImmPred, u30_2ImmPred, CLRMEMIMM,
3076 L4_iand_memopw_io, and>;
3077 defm: MemOpi_bitPats<load, store, Set5ImmPred, u30_2ImmPred, SETMEMIMM,
3078 L4_ior_memopw_io, or>;
3081 //===----------------------------------------------------------------------===//
3082 // Multiclass to define 'def Pats' for ALU operations on the memory
3083 // where addend is a register.
3084 // mem[bhw](Rs+#0) [+-&|]= Rt
3085 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
3086 //===----------------------------------------------------------------------===//
3088 multiclass MemOpr_Pats <PatFrag ldOp, PatFrag stOp, PatLeaf extPred,
3089 InstHexagon MI, SDNode OpNode> {
3090 let AddedComplexity = 141 in
3091 // mem[bhw](Rs+#0) [+-&|]= Rt
3092 def: Pat<(stOp (OpNode (ldOp IntRegs:$addr), (i32 IntRegs:$addend)),
3094 (MI IntRegs:$addr, 0, (i32 IntRegs:$addend))>;
3096 // mem[bhw](Rs+#U6:[012]) [+-&|]= Rt
3097 let AddedComplexity = 150 in
3098 def: Pat<(stOp (OpNode (ldOp (add IntRegs:$base, extPred:$offset)),
3099 (i32 IntRegs:$orend)),
3100 (add IntRegs:$base, extPred:$offset)),
3101 (MI IntRegs:$base, extPred:$offset, (i32 IntRegs:$orend))>;
3104 multiclass MemOPr_ALUOp<PatFrag ldOp, PatFrag stOp, PatLeaf extPred,
3105 InstHexagon addMI, InstHexagon subMI,
3106 InstHexagon andMI, InstHexagon orMI> {
3107 defm: MemOpr_Pats <ldOp, stOp, extPred, addMI, add>;
3108 defm: MemOpr_Pats <ldOp, stOp, extPred, subMI, sub>;
3109 defm: MemOpr_Pats <ldOp, stOp, extPred, andMI, and>;
3110 defm: MemOpr_Pats <ldOp, stOp, extPred, orMI, or>;
3113 multiclass MemOPr_ExtType<PatFrag ldOpByte, PatFrag ldOpHalf > {
3115 defm: MemOPr_ALUOp <ldOpHalf, truncstorei16, u31_1ImmPred,
3116 L4_add_memoph_io, L4_sub_memoph_io,
3117 L4_and_memoph_io, L4_or_memoph_io>;
3119 defm: MemOPr_ALUOp <ldOpByte, truncstorei8, u32ImmPred,
3120 L4_add_memopb_io, L4_sub_memopb_io,
3121 L4_and_memopb_io, L4_or_memopb_io>;
3124 // Define 'def Pats' for MemOps with register addend.
3125 let Predicates = [UseMEMOP] in {
3127 defm: MemOPr_ExtType<zextloadi8, zextloadi16>; // zero extend
3128 defm: MemOPr_ExtType<sextloadi8, sextloadi16>; // sign extend
3129 defm: MemOPr_ExtType<extloadi8, extloadi16>; // any extend
3131 defm: MemOPr_ALUOp <load, store, u30_2ImmPred, L4_add_memopw_io,
3132 L4_sub_memopw_io, L4_and_memopw_io, L4_or_memopw_io>;
3135 //===----------------------------------------------------------------------===//
3137 //===----------------------------------------------------------------------===//
3139 // Hexagon V4 only supports these flavors of byte/half compare instructions:
3140 // EQ/GT/GTU. Other flavors like GE/GEU/LT/LTU/LE/LEU are not supported by
3141 // hardware. However, compiler can still implement these patterns through
3142 // appropriate patterns combinations based on current implemented patterns.
3143 // The implemented patterns are: EQ/GT/GTU.
3144 // Missing patterns are: GE/GEU/LT/LTU/LE/LEU.
3146 // Following instruction is not being extended as it results into the
3147 // incorrect code for negative numbers.
3148 // Pd=cmpb.eq(Rs,#u8)
3150 // p=!cmp.eq(r1,#s10)
3151 def C4_cmpneqi : T_CMP <"cmp.eq", 0b00, 1, s10Ext>;
3152 def C4_cmpltei : T_CMP <"cmp.gt", 0b01, 1, s10Ext>;
3153 def C4_cmplteui : T_CMP <"cmp.gtu", 0b10, 1, u9Ext>;
3155 def : T_CMP_pat <C4_cmpneqi, setne, s32ImmPred>;
3156 def : T_CMP_pat <C4_cmpltei, setle, s32ImmPred>;
3157 def : T_CMP_pat <C4_cmplteui, setule, u9ImmPred>;
3159 // rs <= rt -> !(rs > rt).
3161 def: Pat<(i1 (setle (i32 IntRegs:$src1), s32ImmPred:$src2)),
3162 (C2_not (C2_cmpgti IntRegs:$src1, s32ImmPred:$src2))>;
3163 // (C4_cmpltei IntRegs:$src1, s32ImmPred:$src2)>;
3165 // Map cmplt(Rs, Imm) -> !cmpgt(Rs, Imm-1).
3166 def: Pat<(i1 (setlt (i32 IntRegs:$src1), s32ImmPred:$src2)),
3167 (C4_cmpltei IntRegs:$src1, (DEC_CONST_SIGNED s32ImmPred:$src2))>;
3169 // rs != rt -> !(rs == rt).
3170 def: Pat<(i1 (setne (i32 IntRegs:$src1), s32ImmPred:$src2)),
3171 (C4_cmpneqi IntRegs:$src1, s32ImmPred:$src2)>;
3173 // SDNode for converting immediate C to C-1.
3174 def DEC_CONST_BYTE : SDNodeXForm<imm, [{
3175 // Return the byte immediate const-1 as an SDNode.
3176 int32_t imm = N->getSExtValue();
3177 return XformU7ToU7M1Imm(imm);
3181 // zext( setult ( and(Rs, 255), u8))
3182 // Use the isdigit transformation below
3184 // Generate code of the form 'C2_muxii(cmpbgtui(Rdd, C-1),0,1)'
3185 // for C code of the form r = ((c>='0') & (c<='9')) ? 1 : 0;.
3186 // The isdigit transformation relies on two 'clever' aspects:
3187 // 1) The data type is unsigned which allows us to eliminate a zero test after
3188 // biasing the expression by 48. We are depending on the representation of
3189 // the unsigned types, and semantics.
3190 // 2) The front end has converted <= 9 into < 10 on entry to LLVM
3193 // retval = ((c>='0') & (c<='9')) ? 1 : 0;
3194 // The code is transformed upstream of llvm into
3195 // retval = (c-48) < 10 ? 1 : 0;
3196 let AddedComplexity = 139 in
3197 def: Pat<(i32 (zext (i1 (setult (i32 (and (i32 IntRegs:$src1), 255)),
3198 u7StrictPosImmPred:$src2)))),
3199 (C2_muxii (A4_cmpbgtui IntRegs:$src1,
3200 (DEC_CONST_BYTE u7StrictPosImmPred:$src2)),
3203 //===----------------------------------------------------------------------===//
3205 //===----------------------------------------------------------------------===//
3207 //===----------------------------------------------------------------------===//
3208 // Multiclass for DeallocReturn
3209 //===----------------------------------------------------------------------===//
3210 class L4_RETURN<string mnemonic, bit isNot, bit isPredNew, bit isTak>
3211 : LD0Inst<(outs), (ins PredRegs:$src),
3212 !if(isNot, "if (!$src", "if ($src")#
3213 !if(isPredNew, ".new) ", ") ")#mnemonic#
3214 !if(isPredNew, #!if(isTak,":t", ":nt"),""),
3215 [], "", LD_tc_3or4stall_SLOT0> {
3218 let BaseOpcode = "L4_RETURN";
3219 let isPredicatedFalse = isNot;
3220 let isPredicatedNew = isPredNew;
3221 let isTaken = isTak;
3222 let IClass = 0b1001;
3224 let Inst{27-16} = 0b011000011110;
3226 let Inst{13} = isNot;
3227 let Inst{12} = isTak;
3228 let Inst{11} = isPredNew;
3230 let Inst{9-8} = src;
3231 let Inst{4-0} = 0b11110;
3234 // Produce all predicated forms, p, !p, p.new, !p.new, :t, :nt
3235 multiclass L4_RETURN_PRED<string mnemonic, bit PredNot> {
3236 let isPredicated = 1 in {
3237 def _#NAME# : L4_RETURN <mnemonic, PredNot, 0, 1>;
3238 def _#NAME#new_pnt : L4_RETURN <mnemonic, PredNot, 1, 0>;
3239 def _#NAME#new_pt : L4_RETURN <mnemonic, PredNot, 1, 1>;
3243 multiclass LD_MISC_L4_RETURN<string mnemonic> {
3244 let isBarrier = 1, isPredicable = 1 in
3245 def NAME : LD0Inst <(outs), (ins), mnemonic, [], "",
3246 LD_tc_3or4stall_SLOT0> {
3247 let BaseOpcode = "L4_RETURN";
3248 let IClass = 0b1001;
3249 let Inst{27-16} = 0b011000011110;
3250 let Inst{13-10} = 0b0000;
3251 let Inst{4-0} = 0b11110;
3253 defm t : L4_RETURN_PRED<mnemonic, 0 >;
3254 defm f : L4_RETURN_PRED<mnemonic, 1 >;
3257 let isReturn = 1, isTerminator = 1,
3258 Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0 in
3259 defm L4_return: LD_MISC_L4_RETURN <"dealloc_return">, PredNewRel;
3261 // Restore registers and dealloc return function call.
3262 let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1,
3263 Defs = [R29, R30, R31, PC], isPredicable = 0, isAsmParserOnly = 1 in {
3264 def RESTORE_DEALLOC_RET_JMP_V4 : T_JMP<"">;
3267 // Restore registers and dealloc frame before a tail call.
3268 let isCall = 1, Defs = [R29, R30, R31, PC], isAsmParserOnly = 1 in {
3269 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : T_Call<"">, PredRel;
3272 // Save registers function call.
3273 let isCall = 1, Uses = [R29, R31], isAsmParserOnly = 1 in {
3274 def SAVE_REGISTERS_CALL_V4 : T_Call<"">, PredRel;
3277 //===----------------------------------------------------------------------===//
3278 // Template class for non predicated store instructions with
3279 // GP-Relative or absolute addressing.
3280 //===----------------------------------------------------------------------===//
3281 let hasSideEffects = 0, isPredicable = 1, isNVStorable = 1 in
3282 class T_StoreAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3283 bits<2>MajOp, Operand AddrOp, bit isAbs, bit isHalf>
3284 : STInst<(outs), (ins AddrOp:$addr, RC:$src),
3285 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src"#!if(isHalf, ".h",""),
3286 [], "", V2LDST_tc_st_SLOT01> {
3289 bits<16> offsetBits;
3291 string ImmOpStr = !cast<string>(ImmOp);
3292 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3293 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3294 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3295 /* u16_0Imm */ addr{15-0})));
3296 let IClass = 0b0100;
3298 let Inst{26-25} = offsetBits{15-14};
3300 let Inst{23-22} = MajOp;
3301 let Inst{21} = isHalf;
3302 let Inst{20-16} = offsetBits{13-9};
3303 let Inst{13} = offsetBits{8};
3304 let Inst{12-8} = src;
3305 let Inst{7-0} = offsetBits{7-0};
3308 //===----------------------------------------------------------------------===//
3309 // Template class for predicated store instructions with
3310 // GP-Relative or absolute addressing.
3311 //===----------------------------------------------------------------------===//
3312 let hasSideEffects = 0, isPredicated = 1, isNVStorable = 1, opExtentBits = 6,
3314 class T_StoreAbs_Pred <string mnemonic, RegisterClass RC, bits<2> MajOp,
3315 bit isHalf, bit isNot, bit isNew>
3316 : STInst<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, RC: $src2),
3317 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3318 ") ")#mnemonic#"(#$absaddr) = $src2"#!if(isHalf, ".h",""),
3319 [], "", ST_tc_st_SLOT01>, AddrModeRel {
3324 let isPredicatedNew = isNew;
3325 let isPredicatedFalse = isNot;
3327 let IClass = 0b1010;
3329 let Inst{27-24} = 0b1111;
3330 let Inst{23-22} = MajOp;
3331 let Inst{21} = isHalf;
3332 let Inst{17-16} = absaddr{5-4};
3333 let Inst{13} = isNew;
3334 let Inst{12-8} = src2;
3336 let Inst{6-3} = absaddr{3-0};
3337 let Inst{2} = isNot;
3338 let Inst{1-0} = src1;
3341 //===----------------------------------------------------------------------===//
3342 // Template class for predicated store instructions with absolute addressing.
3343 //===----------------------------------------------------------------------===//
3344 class T_StoreAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3345 bits<2> MajOp, bit isHalf>
3346 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, u32Imm, 1, isHalf>,
3348 string ImmOpStr = !cast<string>(ImmOp);
3349 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3350 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3351 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3352 /* u16_0Imm */ 16)));
3354 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3355 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3356 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3357 /* u16_0Imm */ 0)));
3360 //===----------------------------------------------------------------------===//
3361 // Multiclass for store instructions with absolute addressing.
3362 //===----------------------------------------------------------------------===//
3363 let addrMode = Absolute, isExtended = 1 in
3364 multiclass ST_Abs<string mnemonic, string CextOp, RegisterClass RC,
3365 Operand ImmOp, bits<2> MajOp, bit isHalf = 0> {
3366 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3367 let opExtendable = 0, isPredicable = 1 in
3368 def S2_#NAME#abs : T_StoreAbs <mnemonic, RC, ImmOp, MajOp, isHalf>;
3371 def S4_p#NAME#t_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 0>;
3372 def S4_p#NAME#f_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 0>;
3375 def S4_p#NAME#tnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 1>;
3376 def S4_p#NAME#fnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 1>;
3380 //===----------------------------------------------------------------------===//
3381 // Template class for non predicated new-value store instructions with
3382 // GP-Relative or absolute addressing.
3383 //===----------------------------------------------------------------------===//
3384 let hasSideEffects = 0, isPredicable = 1, mayStore = 1, isNVStore = 1,
3385 isNewValue = 1, opNewValue = 1 in
3386 class T_StoreAbsGP_NV <string mnemonic, Operand ImmOp, bits<2>MajOp, bit isAbs>
3387 : NVInst_V4<(outs), (ins u32Imm:$addr, IntRegs:$src),
3388 mnemonic # !if(isAbs, "(##", "(#")#"$addr) = $src.new",
3389 [], "", V2LDST_tc_st_SLOT0> {
3392 bits<16> offsetBits;
3394 string ImmOpStr = !cast<string>(ImmOp);
3395 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3396 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3397 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3398 /* u16_0Imm */ addr{15-0})));
3399 let IClass = 0b0100;
3402 let Inst{26-25} = offsetBits{15-14};
3403 let Inst{24-21} = 0b0101;
3404 let Inst{20-16} = offsetBits{13-9};
3405 let Inst{13} = offsetBits{8};
3406 let Inst{12-11} = MajOp;
3407 let Inst{10-8} = src;
3408 let Inst{7-0} = offsetBits{7-0};
3411 //===----------------------------------------------------------------------===//
3412 // Template class for predicated new-value store instructions with
3413 // absolute addressing.
3414 //===----------------------------------------------------------------------===//
3415 let hasSideEffects = 0, isPredicated = 1, mayStore = 1, isNVStore = 1,
3416 isNewValue = 1, opNewValue = 2, opExtentBits = 6, opExtendable = 1 in
3417 class T_StoreAbs_NV_Pred <string mnemonic, bits<2> MajOp, bit isNot, bit isNew>
3418 : NVInst_V4<(outs), (ins PredRegs:$src1, u6Ext:$absaddr, IntRegs:$src2),
3419 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
3420 ") ")#mnemonic#"(#$absaddr) = $src2.new",
3421 [], "", ST_tc_st_SLOT0>, AddrModeRel {
3426 let isPredicatedNew = isNew;
3427 let isPredicatedFalse = isNot;
3429 let IClass = 0b1010;
3431 let Inst{27-24} = 0b1111;
3432 let Inst{23-21} = 0b101;
3433 let Inst{17-16} = absaddr{5-4};
3434 let Inst{13} = isNew;
3435 let Inst{12-11} = MajOp;
3436 let Inst{10-8} = src2;
3438 let Inst{6-3} = absaddr{3-0};
3439 let Inst{2} = isNot;
3440 let Inst{1-0} = src1;
3443 //===----------------------------------------------------------------------===//
3444 // Template class for non-predicated new-value store instructions with
3445 // absolute addressing.
3446 //===----------------------------------------------------------------------===//
3447 class T_StoreAbs_NV <string mnemonic, Operand ImmOp, bits<2> MajOp>
3448 : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 1>, AddrModeRel {
3450 string ImmOpStr = !cast<string>(ImmOp);
3451 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3452 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3453 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3454 /* u16_0Imm */ 16)));
3456 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3457 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3458 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3459 /* u16_0Imm */ 0)));
3462 //===----------------------------------------------------------------------===//
3463 // Multiclass for new-value store instructions with absolute addressing.
3464 //===----------------------------------------------------------------------===//
3465 let addrMode = Absolute, isExtended = 1 in
3466 multiclass ST_Abs_NV <string mnemonic, string CextOp, Operand ImmOp,
3468 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3469 let opExtendable = 0, isPredicable = 1 in
3470 def S2_#NAME#newabs : T_StoreAbs_NV <mnemonic, ImmOp, MajOp>;
3473 def S4_p#NAME#newt_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 0>;
3474 def S4_p#NAME#newf_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 0>;
3477 def S4_p#NAME#newtnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 1>;
3478 def S4_p#NAME#newfnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 1>;
3482 //===----------------------------------------------------------------------===//
3483 // Stores with absolute addressing
3484 //===----------------------------------------------------------------------===//
3485 let accessSize = ByteAccess in
3486 defm storerb : ST_Abs <"memb", "STrib", IntRegs, u16_0Imm, 0b00>,
3487 ST_Abs_NV <"memb", "STrib", u16_0Imm, 0b00>;
3489 let accessSize = HalfWordAccess in
3490 defm storerh : ST_Abs <"memh", "STrih", IntRegs, u16_1Imm, 0b01>,
3491 ST_Abs_NV <"memh", "STrih", u16_1Imm, 0b01>;
3493 let accessSize = WordAccess in
3494 defm storeri : ST_Abs <"memw", "STriw", IntRegs, u16_2Imm, 0b10>,
3495 ST_Abs_NV <"memw", "STriw", u16_2Imm, 0b10>;
3497 let isNVStorable = 0, accessSize = DoubleWordAccess in
3498 defm storerd : ST_Abs <"memd", "STrid", DoubleRegs, u16_3Imm, 0b11>;
3500 let isNVStorable = 0, accessSize = HalfWordAccess in
3501 defm storerf : ST_Abs <"memh", "STrif", IntRegs, u16_1Imm, 0b01, 1>;
3503 //===----------------------------------------------------------------------===//
3504 // GP-relative stores.
3505 // mem[bhwd](#global)=Rt
3506 // Once predicated, these instructions map to absolute addressing mode.
3507 // if ([!]Pv[.new]) mem[bhwd](##global)=Rt
3508 //===----------------------------------------------------------------------===//
3510 let isAsmParserOnly = 1 in
3511 class T_StoreGP <string mnemonic, string BaseOp, RegisterClass RC,
3512 Operand ImmOp, bits<2> MajOp, bit isHalf = 0>
3513 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0, isHalf> {
3514 // Set BaseOpcode same as absolute addressing instructions so that
3515 // non-predicated GP-Rel instructions can have relate with predicated
3516 // Absolute instruction.
3517 let BaseOpcode = BaseOp#_abs;
3520 let isAsmParserOnly = 1 in
3521 multiclass ST_GP <string mnemonic, string BaseOp, Operand ImmOp,
3522 bits<2> MajOp, bit isHalf = 0> {
3523 // Set BaseOpcode same as absolute addressing instructions so that
3524 // non-predicated GP-Rel instructions can have relate with predicated
3525 // Absolute instruction.
3526 let BaseOpcode = BaseOp#_abs in {
3527 def NAME#gp : T_StoreAbsGP <mnemonic, IntRegs, ImmOp, MajOp,
3528 globaladdress, 0, isHalf>;
3530 def NAME#newgp : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp, 0> ;
3534 let accessSize = ByteAccess in
3535 defm S2_storerb : ST_GP<"memb", "STrib", u16_0Imm, 0b00>, NewValueRel;
3537 let accessSize = HalfWordAccess in
3538 defm S2_storerh : ST_GP<"memh", "STrih", u16_1Imm, 0b01>, NewValueRel;
3540 let accessSize = WordAccess in
3541 defm S2_storeri : ST_GP<"memw", "STriw", u16_2Imm, 0b10>, NewValueRel;
3543 let isNVStorable = 0, accessSize = DoubleWordAccess in
3544 def S2_storerdgp : T_StoreGP <"memd", "STrid", DoubleRegs,
3545 u16_3Imm, 0b11>, PredNewRel;
3547 let isNVStorable = 0, accessSize = HalfWordAccess in
3548 def S2_storerfgp : T_StoreGP <"memh", "STrif", IntRegs,
3549 u16_1Imm, 0b01, 1>, PredNewRel;
3551 class Loada_pat<PatFrag Load, ValueType VT, PatFrag Addr, InstHexagon MI>
3552 : Pat<(VT (Load Addr:$addr)), (MI Addr:$addr)>;
3554 class Loadam_pat<PatFrag Load, ValueType VT, PatFrag Addr, PatFrag ValueMod,
3556 : Pat<(VT (Load Addr:$addr)), (ValueMod (MI Addr:$addr))>;
3558 class Storea_pat<PatFrag Store, PatFrag Value, PatFrag Addr, InstHexagon MI>
3559 : Pat<(Store Value:$val, Addr:$addr), (MI Addr:$addr, Value:$val)>;
3561 class Stoream_pat<PatFrag Store, PatFrag Value, PatFrag Addr, PatFrag ValueMod,
3563 : Pat<(Store Value:$val, Addr:$addr),
3564 (MI Addr:$addr, (ValueMod Value:$val))>;
3566 def: Storea_pat<SwapSt<atomic_store_8>, I32, addrgp, S2_storerbgp>;
3567 def: Storea_pat<SwapSt<atomic_store_16>, I32, addrgp, S2_storerhgp>;
3568 def: Storea_pat<SwapSt<atomic_store_32>, I32, addrgp, S2_storerigp>;
3569 def: Storea_pat<SwapSt<atomic_store_64>, I64, addrgp, S2_storerdgp>;
3571 let AddedComplexity = 100 in {
3572 def: Storea_pat<truncstorei8, I32, addrgp, S2_storerbgp>;
3573 def: Storea_pat<truncstorei16, I32, addrgp, S2_storerhgp>;
3574 def: Storea_pat<store, I32, addrgp, S2_storerigp>;
3575 def: Storea_pat<store, I64, addrgp, S2_storerdgp>;
3577 // Map from "i1 = constant<-1>; memw(CONST32(#foo)) = i1"
3578 // to "r0 = 1; memw(#foo) = r0"
3579 let AddedComplexity = 100 in
3580 def: Pat<(store (i1 -1), (HexagonCONST32_GP tglobaladdr:$global)),
3581 (S2_storerbgp tglobaladdr:$global, (A2_tfrsi 1))>;
3584 //===----------------------------------------------------------------------===//
3585 // Template class for non predicated load instructions with
3586 // absolute addressing mode.
3587 //===----------------------------------------------------------------------===//
3588 let isPredicable = 1, hasSideEffects = 0 in
3589 class T_LoadAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
3590 bits<3> MajOp, Operand AddrOp, bit isAbs>
3591 : LDInst <(outs RC:$dst), (ins AddrOp:$addr),
3592 "$dst = "#mnemonic# !if(isAbs, "(##", "(#")#"$addr)",
3593 [], "", V2LDST_tc_ld_SLOT01> {
3596 bits<16> offsetBits;
3598 string ImmOpStr = !cast<string>(ImmOp);
3599 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
3600 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
3601 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
3602 /* u16_0Imm */ addr{15-0})));
3604 let IClass = 0b0100;
3607 let Inst{26-25} = offsetBits{15-14};
3609 let Inst{23-21} = MajOp;
3610 let Inst{20-16} = offsetBits{13-9};
3611 let Inst{13-5} = offsetBits{8-0};
3612 let Inst{4-0} = dst;
3615 class T_LoadAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
3617 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, u32Imm, 1>, AddrModeRel {
3619 string ImmOpStr = !cast<string>(ImmOp);
3620 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
3621 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
3622 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
3623 /* u16_0Imm */ 16)));
3625 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
3626 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
3627 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
3628 /* u16_0Imm */ 0)));
3631 //===----------------------------------------------------------------------===//
3632 // Template class for predicated load instructions with
3633 // absolute addressing mode.
3634 //===----------------------------------------------------------------------===//
3635 let isPredicated = 1, opExtentBits = 6, opExtendable = 2 in
3636 class T_LoadAbs_Pred <string mnemonic, RegisterClass RC, bits<3> MajOp,
3637 bit isPredNot, bit isPredNew>
3638 : LDInst <(outs RC:$dst), (ins PredRegs:$src1, u6Ext:$absaddr),
3639 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
3640 ") ")#"$dst = "#mnemonic#"(#$absaddr)">, AddrModeRel {
3645 let isPredicatedNew = isPredNew;
3646 let isPredicatedFalse = isPredNot;
3647 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
3649 let IClass = 0b1001;
3651 let Inst{27-24} = 0b1111;
3652 let Inst{23-21} = MajOp;
3653 let Inst{20-16} = absaddr{5-1};
3655 let Inst{12} = isPredNew;
3656 let Inst{11} = isPredNot;
3657 let Inst{10-9} = src1;
3658 let Inst{8} = absaddr{0};
3660 let Inst{4-0} = dst;
3663 //===----------------------------------------------------------------------===//
3664 // Multiclass for the load instructions with absolute addressing mode.
3665 //===----------------------------------------------------------------------===//
3666 multiclass LD_Abs_Pred<string mnemonic, RegisterClass RC, bits<3> MajOp,
3668 def _abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 0>;
3670 def new_abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 1>;
3673 let addrMode = Absolute, isExtended = 1 in
3674 multiclass LD_Abs<string mnemonic, string CextOp, RegisterClass RC,
3675 Operand ImmOp, bits<3> MajOp> {
3676 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
3677 let opExtendable = 1, isPredicable = 1 in
3678 def L4_#NAME#_abs: T_LoadAbs <mnemonic, RC, ImmOp, MajOp>;
3681 defm L4_p#NAME#t : LD_Abs_Pred<mnemonic, RC, MajOp, 0>;
3682 defm L4_p#NAME#f : LD_Abs_Pred<mnemonic, RC, MajOp, 1>;
3686 let accessSize = ByteAccess, hasNewValue = 1 in {
3687 defm loadrb : LD_Abs<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3688 defm loadrub : LD_Abs<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3691 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3692 defm loadrh : LD_Abs<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3693 defm loadruh : LD_Abs<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3696 let accessSize = WordAccess, hasNewValue = 1 in
3697 defm loadri : LD_Abs<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3699 let accessSize = DoubleWordAccess in
3700 defm loadrd : LD_Abs<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3702 //===----------------------------------------------------------------------===//
3703 // multiclass for load instructions with GP-relative addressing mode.
3704 // Rx=mem[bhwd](##global)
3705 // Once predicated, these instructions map to absolute addressing mode.
3706 // if ([!]Pv[.new]) Rx=mem[bhwd](##global)
3707 //===----------------------------------------------------------------------===//
3709 let isAsmParserOnly = 1 in
3710 class T_LoadGP <string mnemonic, string BaseOp, RegisterClass RC, Operand ImmOp,
3712 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp, globaladdress, 0>, PredNewRel {
3713 let BaseOpcode = BaseOp#_abs;
3716 let accessSize = ByteAccess, hasNewValue = 1 in {
3717 def L2_loadrbgp : T_LoadGP<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
3718 def L2_loadrubgp : T_LoadGP<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
3721 let accessSize = HalfWordAccess, hasNewValue = 1 in {
3722 def L2_loadrhgp : T_LoadGP<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
3723 def L2_loadruhgp : T_LoadGP<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
3726 let accessSize = WordAccess, hasNewValue = 1 in
3727 def L2_loadrigp : T_LoadGP<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
3729 let accessSize = DoubleWordAccess in
3730 def L2_loadrdgp : T_LoadGP<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
3732 def: Loada_pat<atomic_load_8, i32, addrgp, L2_loadrubgp>;
3733 def: Loada_pat<atomic_load_16, i32, addrgp, L2_loadruhgp>;
3734 def: Loada_pat<atomic_load_32, i32, addrgp, L2_loadrigp>;
3735 def: Loada_pat<atomic_load_64, i64, addrgp, L2_loadrdgp>;
3737 // Map from Pd = load(globaladdress) -> Rd = memb(globaladdress), Pd = Rd
3738 def: Loadam_pat<load, i1, addrga, I32toI1, L4_loadrub_abs>;
3739 def: Loadam_pat<load, i1, addrgp, I32toI1, L2_loadrubgp>;
3741 def: Stoream_pat<store, I1, addrga, I1toI32, S2_storerbabs>;
3742 def: Stoream_pat<store, I1, addrgp, I1toI32, S2_storerbgp>;
3744 // Map from load(globaladdress) -> mem[u][bhwd](#foo)
3745 class LoadGP_pats <PatFrag ldOp, InstHexagon MI, ValueType VT = i32>
3746 : Pat <(VT (ldOp (HexagonCONST32_GP tglobaladdr:$global))),
3747 (VT (MI tglobaladdr:$global))>;
3749 let AddedComplexity = 100 in {
3750 def: LoadGP_pats <extloadi8, L2_loadrbgp>;
3751 def: LoadGP_pats <sextloadi8, L2_loadrbgp>;
3752 def: LoadGP_pats <zextloadi8, L2_loadrubgp>;
3753 def: LoadGP_pats <extloadi16, L2_loadrhgp>;
3754 def: LoadGP_pats <sextloadi16, L2_loadrhgp>;
3755 def: LoadGP_pats <zextloadi16, L2_loadruhgp>;
3756 def: LoadGP_pats <load, L2_loadrigp>;
3757 def: LoadGP_pats <load, L2_loadrdgp, i64>;
3760 // When the Interprocedural Global Variable optimizer realizes that a certain
3761 // global variable takes only two constant values, it shrinks the global to
3762 // a boolean. Catch those loads here in the following 3 patterns.
3763 let AddedComplexity = 100 in {
3764 def: LoadGP_pats <extloadi1, L2_loadrubgp>;
3765 def: LoadGP_pats <zextloadi1, L2_loadrubgp>;
3768 // Transfer global address into a register
3769 def: Pat<(HexagonCONST32 tglobaladdr:$Rs), (A2_tfrsi s16Ext:$Rs)>;
3770 def: Pat<(HexagonCONST32_GP tblockaddress:$Rs), (A2_tfrsi s16Ext:$Rs)>;
3771 def: Pat<(HexagonCONST32_GP tglobaladdr:$Rs), (A2_tfrsi s16Ext:$Rs)>;
3773 def: Pat<(i64 (ctlz I64:$src1)), (Zext64 (S2_cl0p I64:$src1))>;
3774 def: Pat<(i64 (cttz I64:$src1)), (Zext64 (S2_ct0p I64:$src1))>;
3776 let AddedComplexity = 30 in {
3777 def: Storea_pat<truncstorei8, I32, u32ImmPred, S2_storerbabs>;
3778 def: Storea_pat<truncstorei16, I32, u32ImmPred, S2_storerhabs>;
3779 def: Storea_pat<store, I32, u32ImmPred, S2_storeriabs>;
3782 let AddedComplexity = 30 in {
3783 def: Loada_pat<load, i32, u32ImmPred, L4_loadri_abs>;
3784 def: Loada_pat<sextloadi8, i32, u32ImmPred, L4_loadrb_abs>;
3785 def: Loada_pat<zextloadi8, i32, u32ImmPred, L4_loadrub_abs>;
3786 def: Loada_pat<sextloadi16, i32, u32ImmPred, L4_loadrh_abs>;
3787 def: Loada_pat<zextloadi16, i32, u32ImmPred, L4_loadruh_abs>;
3790 // Indexed store word - global address.
3791 // memw(Rs+#u6:2)=#S8
3792 let AddedComplexity = 100 in
3793 def: Storex_add_pat<store, addrga, u6_2ImmPred, S4_storeiri_io>;
3795 // Load from a global address that has only one use in the current basic block.
3796 let AddedComplexity = 100 in {
3797 def: Loada_pat<extloadi8, i32, addrga, L4_loadrub_abs>;
3798 def: Loada_pat<sextloadi8, i32, addrga, L4_loadrb_abs>;
3799 def: Loada_pat<zextloadi8, i32, addrga, L4_loadrub_abs>;
3801 def: Loada_pat<extloadi16, i32, addrga, L4_loadruh_abs>;
3802 def: Loada_pat<sextloadi16, i32, addrga, L4_loadrh_abs>;
3803 def: Loada_pat<zextloadi16, i32, addrga, L4_loadruh_abs>;
3805 def: Loada_pat<load, i32, addrga, L4_loadri_abs>;
3806 def: Loada_pat<load, i64, addrga, L4_loadrd_abs>;
3809 // Store to a global address that has only one use in the current basic block.
3810 let AddedComplexity = 100 in {
3811 def: Storea_pat<truncstorei8, I32, addrga, S2_storerbabs>;
3812 def: Storea_pat<truncstorei16, I32, addrga, S2_storerhabs>;
3813 def: Storea_pat<store, I32, addrga, S2_storeriabs>;
3814 def: Storea_pat<store, I64, addrga, S2_storerdabs>;
3816 def: Stoream_pat<truncstorei32, I64, addrga, LoReg, S2_storeriabs>;
3819 // Map from Pd = load(globaladdress) -> Rd = memb(globaladdress), Pd = Rd
3820 let AddedComplexity = 100 in
3821 def : Pat <(i1 (load (HexagonCONST32_GP tglobaladdr:$global))),
3822 (i1 (C2_tfrrp (i32 (L2_loadrbgp tglobaladdr:$global))))>;
3824 // Transfer global address into a register
3825 let isExtended = 1, opExtendable = 1, AddedComplexity=50, isMoveImm = 1,
3826 isAsCheapAsAMove = 1, isReMaterializable = 1, isCodeGenOnly = 1 in
3827 def TFRI_V4 : ALU32_ri<(outs IntRegs:$dst), (ins s16Ext:$src1),
3829 [(set IntRegs:$dst, (HexagonCONST32 tglobaladdr:$src1))]>;
3831 // Transfer a block address into a register
3832 def : Pat<(HexagonCONST32_GP tblockaddress:$src1),
3833 (TFRI_V4 tblockaddress:$src1)>;
3835 let AddedComplexity = 50 in
3836 def : Pat<(HexagonCONST32_GP tglobaladdr:$src1),
3837 (TFRI_V4 tglobaladdr:$src1)>;
3839 // i8/i16/i32 -> i64 loads
3840 // We need a complexity of 120 here to override preceding handling of
3842 let AddedComplexity = 120 in {
3843 def: Loadam_pat<extloadi8, i64, addrga, Zext64, L4_loadrub_abs>;
3844 def: Loadam_pat<sextloadi8, i64, addrga, Sext64, L4_loadrb_abs>;
3845 def: Loadam_pat<zextloadi8, i64, addrga, Zext64, L4_loadrub_abs>;
3847 def: Loadam_pat<extloadi16, i64, addrga, Zext64, L4_loadruh_abs>;
3848 def: Loadam_pat<sextloadi16, i64, addrga, Sext64, L4_loadrh_abs>;
3849 def: Loadam_pat<zextloadi16, i64, addrga, Zext64, L4_loadruh_abs>;
3851 def: Loadam_pat<extloadi32, i64, addrga, Zext64, L4_loadri_abs>;
3852 def: Loadam_pat<sextloadi32, i64, addrga, Sext64, L4_loadri_abs>;
3853 def: Loadam_pat<zextloadi32, i64, addrga, Zext64, L4_loadri_abs>;
3856 let AddedComplexity = 100 in {
3857 def: Loada_pat<extloadi8, i32, addrgp, L4_loadrub_abs>;
3858 def: Loada_pat<sextloadi8, i32, addrgp, L4_loadrb_abs>;
3859 def: Loada_pat<zextloadi8, i32, addrgp, L4_loadrub_abs>;
3861 def: Loada_pat<extloadi16, i32, addrgp, L4_loadruh_abs>;
3862 def: Loada_pat<sextloadi16, i32, addrgp, L4_loadrh_abs>;
3863 def: Loada_pat<zextloadi16, i32, addrgp, L4_loadruh_abs>;
3865 def: Loada_pat<load, i32, addrgp, L4_loadri_abs>;
3866 def: Loada_pat<load, i64, addrgp, L4_loadrd_abs>;
3869 let AddedComplexity = 100 in {
3870 def: Storea_pat<truncstorei8, I32, addrgp, S2_storerbabs>;
3871 def: Storea_pat<truncstorei16, I32, addrgp, S2_storerhabs>;
3872 def: Storea_pat<store, I32, addrgp, S2_storeriabs>;
3873 def: Storea_pat<store, I64, addrgp, S2_storerdabs>;
3876 def: Loada_pat<atomic_load_8, i32, addrgp, L4_loadrub_abs>;
3877 def: Loada_pat<atomic_load_16, i32, addrgp, L4_loadruh_abs>;
3878 def: Loada_pat<atomic_load_32, i32, addrgp, L4_loadri_abs>;
3879 def: Loada_pat<atomic_load_64, i64, addrgp, L4_loadrd_abs>;
3881 def: Storea_pat<SwapSt<atomic_store_8>, I32, addrgp, S2_storerbabs>;
3882 def: Storea_pat<SwapSt<atomic_store_16>, I32, addrgp, S2_storerhabs>;
3883 def: Storea_pat<SwapSt<atomic_store_32>, I32, addrgp, S2_storeriabs>;
3884 def: Storea_pat<SwapSt<atomic_store_64>, I64, addrgp, S2_storerdabs>;
3886 let Constraints = "@earlyclobber $dst" in
3887 def Insert4 : PseudoM<(outs DoubleRegs:$dst), (ins IntRegs:$a, IntRegs:$b,
3888 IntRegs:$c, IntRegs:$d),
3889 ".error \"Should never try to emit Insert4\"",
3890 [(set (i64 DoubleRegs:$dst),
3891 (or (or (or (shl (i64 (zext (i32 (and (i32 IntRegs:$b), (i32 65535))))),
3893 (i64 (zext (i32 (and (i32 IntRegs:$a), (i32 65535)))))),
3894 (shl (i64 (anyext (i32 (and (i32 IntRegs:$c), (i32 65535))))),
3896 (shl (i64 (anyext (i32 IntRegs:$d))), (i32 48))))]>;
3898 //===----------------------------------------------------------------------===//
3899 // :raw for of boundscheck:hi:lo insns
3900 //===----------------------------------------------------------------------===//
3902 // A4_boundscheck_lo: Detect if a register is within bounds.
3903 let hasSideEffects = 0 in
3904 def A4_boundscheck_lo: ALU64Inst <
3905 (outs PredRegs:$Pd),
3906 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3907 "$Pd = boundscheck($Rss, $Rtt):raw:lo"> {
3912 let IClass = 0b1101;
3914 let Inst{27-23} = 0b00100;
3916 let Inst{7-5} = 0b100;
3918 let Inst{20-16} = Rss;
3919 let Inst{12-8} = Rtt;
3922 // A4_boundscheck_hi: Detect if a register is within bounds.
3923 let hasSideEffects = 0 in
3924 def A4_boundscheck_hi: ALU64Inst <
3925 (outs PredRegs:$Pd),
3926 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
3927 "$Pd = boundscheck($Rss, $Rtt):raw:hi"> {
3932 let IClass = 0b1101;
3934 let Inst{27-23} = 0b00100;
3936 let Inst{7-5} = 0b101;
3938 let Inst{20-16} = Rss;
3939 let Inst{12-8} = Rtt;
3942 let hasSideEffects = 0, isAsmParserOnly = 1 in
3943 def A4_boundscheck : MInst <
3944 (outs PredRegs:$Pd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
3945 "$Pd=boundscheck($Rs,$Rtt)">;
3947 // A4_tlbmatch: Detect if a VA/ASID matches a TLB entry.
3948 let isPredicateLate = 1, hasSideEffects = 0 in
3949 def A4_tlbmatch : ALU64Inst<(outs PredRegs:$Pd),
3950 (ins DoubleRegs:$Rs, IntRegs:$Rt),
3951 "$Pd = tlbmatch($Rs, $Rt)",
3952 [], "", ALU64_tc_2early_SLOT23> {
3957 let IClass = 0b1101;
3958 let Inst{27-23} = 0b00100;
3959 let Inst{20-16} = Rs;
3961 let Inst{12-8} = Rt;
3962 let Inst{7-5} = 0b011;
3966 // We need custom lowering of ISD::PREFETCH into HexagonISD::DCFETCH
3967 // because the SDNode ISD::PREFETCH has properties MayLoad and MayStore.
3968 // We don't really want either one here.
3969 def SDTHexagonDCFETCH : SDTypeProfile<0, 2, [SDTCisPtrTy<0>,SDTCisInt<1>]>;
3970 def HexagonDCFETCH : SDNode<"HexagonISD::DCFETCH", SDTHexagonDCFETCH,
3973 // Use LD0Inst for dcfetch, but set "mayLoad" to 0 because this doesn't
3974 // really do a load.
3975 let hasSideEffects = 1, mayLoad = 0 in
3976 def Y2_dcfetchbo : LD0Inst<(outs), (ins IntRegs:$Rs, u11_3Imm:$u11_3),
3977 "dcfetch($Rs + #$u11_3)",
3978 [(HexagonDCFETCH IntRegs:$Rs, u11_3ImmPred:$u11_3)],
3979 "", LD_tc_ld_SLOT0> {
3983 let IClass = 0b1001;
3984 let Inst{27-21} = 0b0100000;
3985 let Inst{20-16} = Rs;
3987 let Inst{10-0} = u11_3{13-3};
3990 //===----------------------------------------------------------------------===//
3991 // Compound instructions
3992 //===----------------------------------------------------------------------===//
3994 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
3995 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1,
3996 opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
3998 class CJInst_tstbit_R0<string px, bit np, string tnt>
3999 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
4000 ""#px#" = tstbit($Rs, #0); if ("
4001 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4002 [], "", COMPOUND, TypeCOMPOUND>, OpcodeHexagon {
4007 let isPredicatedFalse = np;
4008 // tnt: Taken/Not Taken
4009 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4010 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4012 let IClass = 0b0001;
4013 let Inst{27-26} = 0b00;
4014 let Inst{25} = !if (!eq(px, "!p1"), 1,
4015 !if (!eq(px, "p1"), 1, 0));
4016 let Inst{24-23} = 0b11;
4018 let Inst{21-20} = r9_2{10-9};
4019 let Inst{19-16} = Rs;
4020 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4021 let Inst{9-8} = 0b11;
4022 let Inst{7-1} = r9_2{8-2};
4025 let Defs = [PC, P0], Uses = [P0] in {
4026 def J4_tstbit0_tp0_jump_nt : CJInst_tstbit_R0<"p0", 0, "nt">;
4027 def J4_tstbit0_tp0_jump_t : CJInst_tstbit_R0<"p0", 0, "t">;
4028 def J4_tstbit0_fp0_jump_nt : CJInst_tstbit_R0<"p0", 1, "nt">;
4029 def J4_tstbit0_fp0_jump_t : CJInst_tstbit_R0<"p0", 1, "t">;
4032 let Defs = [PC, P1], Uses = [P1] in {
4033 def J4_tstbit0_tp1_jump_nt : CJInst_tstbit_R0<"p1", 0, "nt">;
4034 def J4_tstbit0_tp1_jump_t : CJInst_tstbit_R0<"p1", 0, "t">;
4035 def J4_tstbit0_fp1_jump_nt : CJInst_tstbit_R0<"p1", 1, "nt">;
4036 def J4_tstbit0_fp1_jump_t : CJInst_tstbit_R0<"p1", 1, "t">;
4040 let isBranch = 1, hasSideEffects = 0,
4041 isExtentSigned = 1, isPredicated = 1, isPredicatedNew = 1,
4042 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2,
4043 opExtendable = 2, isTerminator = 1 in
4044 class CJInst_RR<string px, string op, bit np, string tnt>
4045 : InstHexagon<(outs), (ins IntRegs:$Rs, IntRegs:$Rt, brtarget:$r9_2),
4046 ""#px#" = cmp."#op#"($Rs, $Rt); if ("
4047 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4048 [], "", COMPOUND, TypeCOMPOUND>, OpcodeHexagon {
4054 let isPredicatedFalse = np;
4055 // tnt: Taken/Not Taken
4056 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4057 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4059 let IClass = 0b0001;
4060 let Inst{27-23} = !if (!eq(op, "eq"), 0b01000,
4061 !if (!eq(op, "gt"), 0b01001,
4062 !if (!eq(op, "gtu"), 0b01010, 0)));
4064 let Inst{21-20} = r9_2{10-9};
4065 let Inst{19-16} = Rs;
4066 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4067 // px: Predicate reg 0/1
4068 let Inst{12} = !if (!eq(px, "!p1"), 1,
4069 !if (!eq(px, "p1"), 1, 0));
4070 let Inst{11-8} = Rt;
4071 let Inst{7-1} = r9_2{8-2};
4074 // P[10] taken/not taken.
4075 multiclass T_tnt_CJInst_RR<string op, bit np> {
4076 let Defs = [PC, P0], Uses = [P0] in {
4077 def NAME#p0_jump_nt : CJInst_RR<"p0", op, np, "nt">;
4078 def NAME#p0_jump_t : CJInst_RR<"p0", op, np, "t">;
4080 let Defs = [PC, P1], Uses = [P1] in {
4081 def NAME#p1_jump_nt : CJInst_RR<"p1", op, np, "nt">;
4082 def NAME#p1_jump_t : CJInst_RR<"p1", op, np, "t">;
4085 // Predicate / !Predicate
4086 multiclass T_pnp_CJInst_RR<string op>{
4087 defm J4_cmp#NAME#_t : T_tnt_CJInst_RR<op, 0>;
4088 defm J4_cmp#NAME#_f : T_tnt_CJInst_RR<op, 1>;
4090 // TypeCJ Instructions compare RR and jump
4091 defm eq : T_pnp_CJInst_RR<"eq">;
4092 defm gt : T_pnp_CJInst_RR<"gt">;
4093 defm gtu : T_pnp_CJInst_RR<"gtu">;
4095 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4096 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1, opExtentBits = 11,
4097 opExtentAlign = 2, opExtendable = 2, isTerminator = 1 in
4098 class CJInst_RU5<string px, string op, bit np, string tnt>
4099 : InstHexagon<(outs), (ins IntRegs:$Rs, u5Imm:$U5, brtarget:$r9_2),
4100 ""#px#" = cmp."#op#"($Rs, #$U5); if ("
4101 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4102 [], "", COMPOUND, TypeCOMPOUND>, OpcodeHexagon {
4108 let isPredicatedFalse = np;
4109 // tnt: Taken/Not Taken
4110 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4111 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4113 let IClass = 0b0001;
4114 let Inst{27-26} = 0b00;
4115 // px: Predicate reg 0/1
4116 let Inst{25} = !if (!eq(px, "!p1"), 1,
4117 !if (!eq(px, "p1"), 1, 0));
4118 let Inst{24-23} = !if (!eq(op, "eq"), 0b00,
4119 !if (!eq(op, "gt"), 0b01,
4120 !if (!eq(op, "gtu"), 0b10, 0)));
4122 let Inst{21-20} = r9_2{10-9};
4123 let Inst{19-16} = Rs;
4124 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4125 let Inst{12-8} = U5;
4126 let Inst{7-1} = r9_2{8-2};
4128 // P[10] taken/not taken.
4129 multiclass T_tnt_CJInst_RU5<string op, bit np> {
4130 let Defs = [PC, P0], Uses = [P0] in {
4131 def NAME#p0_jump_nt : CJInst_RU5<"p0", op, np, "nt">;
4132 def NAME#p0_jump_t : CJInst_RU5<"p0", op, np, "t">;
4134 let Defs = [PC, P1], Uses = [P1] in {
4135 def NAME#p1_jump_nt : CJInst_RU5<"p1", op, np, "nt">;
4136 def NAME#p1_jump_t : CJInst_RU5<"p1", op, np, "t">;
4139 // Predicate / !Predicate
4140 multiclass T_pnp_CJInst_RU5<string op>{
4141 defm J4_cmp#NAME#i_t : T_tnt_CJInst_RU5<op, 0>;
4142 defm J4_cmp#NAME#i_f : T_tnt_CJInst_RU5<op, 1>;
4144 // TypeCJ Instructions compare RI and jump
4145 defm eq : T_pnp_CJInst_RU5<"eq">;
4146 defm gt : T_pnp_CJInst_RU5<"gt">;
4147 defm gtu : T_pnp_CJInst_RU5<"gtu">;
4149 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
4150 isPredicated = 1, isPredicatedFalse = 1, isPredicatedNew = 1,
4151 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
4153 class CJInst_Rn1<string px, string op, bit np, string tnt>
4154 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
4155 ""#px#" = cmp."#op#"($Rs,#-1); if ("
4156 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
4157 [], "", COMPOUND, TypeCOMPOUND>, OpcodeHexagon {
4162 let isPredicatedFalse = np;
4163 // tnt: Taken/Not Taken
4164 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
4165 let isTaken = !if (!eq(tnt, "t"), 1, 0);
4167 let IClass = 0b0001;
4168 let Inst{27-26} = 0b00;
4169 let Inst{25} = !if (!eq(px, "!p1"), 1,
4170 !if (!eq(px, "p1"), 1, 0));
4172 let Inst{24-23} = 0b11;
4174 let Inst{21-20} = r9_2{10-9};
4175 let Inst{19-16} = Rs;
4176 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
4177 let Inst{9-8} = !if (!eq(op, "eq"), 0b00,
4178 !if (!eq(op, "gt"), 0b01, 0));
4179 let Inst{7-1} = r9_2{8-2};
4182 // P[10] taken/not taken.
4183 multiclass T_tnt_CJInst_Rn1<string op, bit np> {
4184 let Defs = [PC, P0], Uses = [P0] in {
4185 def NAME#p0_jump_nt : CJInst_Rn1<"p0", op, np, "nt">;
4186 def NAME#p0_jump_t : CJInst_Rn1<"p0", op, np, "t">;
4188 let Defs = [PC, P1], Uses = [P1] in {
4189 def NAME#p1_jump_nt : CJInst_Rn1<"p1", op, np, "nt">;
4190 def NAME#p1_jump_t : CJInst_Rn1<"p1", op, np, "t">;
4193 // Predicate / !Predicate
4194 multiclass T_pnp_CJInst_Rn1<string op>{
4195 defm J4_cmp#NAME#n1_t : T_tnt_CJInst_Rn1<op, 0>;
4196 defm J4_cmp#NAME#n1_f : T_tnt_CJInst_Rn1<op, 1>;
4198 // TypeCJ Instructions compare -1 and jump
4199 defm eq : T_pnp_CJInst_Rn1<"eq">;
4200 defm gt : T_pnp_CJInst_Rn1<"gt">;
4202 // J4_jumpseti: Direct unconditional jump and set register to immediate.
4203 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4204 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4205 opExtentAlign = 2, opExtendable = 2 in
4206 def J4_jumpseti: CJInst <
4208 (ins u6Imm:$U6, brtarget:$r9_2),
4209 "$Rd = #$U6 ; jump $r9_2"> {
4214 let IClass = 0b0001;
4215 let Inst{27-24} = 0b0110;
4216 let Inst{21-20} = r9_2{10-9};
4217 let Inst{19-16} = Rd;
4218 let Inst{13-8} = U6;
4219 let Inst{7-1} = r9_2{8-2};
4222 // J4_jumpsetr: Direct unconditional jump and transfer register.
4223 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
4224 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
4225 opExtentAlign = 2, opExtendable = 2 in
4226 def J4_jumpsetr: CJInst <
4228 (ins IntRegs:$Rs, brtarget:$r9_2),
4229 "$Rd = $Rs ; jump $r9_2"> {
4234 let IClass = 0b0001;
4235 let Inst{27-24} = 0b0111;
4236 let Inst{21-20} = r9_2{10-9};
4237 let Inst{11-8} = Rd;
4238 let Inst{19-16} = Rs;
4239 let Inst{7-1} = r9_2{8-2};