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 let hasSideEffects = 0 in
34 class T_Immext<Operand ImmType>
35 : EXTENDERInst<(outs), (ins ImmType:$imm),
36 "immext(#$imm)", []> {
40 let Inst{27-16} = imm{31-20};
41 let Inst{13-0} = imm{19-6};
44 def A4_ext : T_Immext<u26_6Imm>;
45 let isCodeGenOnly = 1 in {
47 def A4_ext_b : T_Immext<brtarget>;
49 def A4_ext_c : T_Immext<calltarget>;
50 def A4_ext_g : T_Immext<globaladdress>;
53 // Hexagon V4 Architecture spec defines 8 instruction classes:
54 // LD ST ALU32 XTYPE J JR MEMOP NV CR SYSTEM(system is not implemented in the
58 // ========================================
59 // Loads (8/16/32/64 bit)
63 // ========================================
64 // Stores (8/16/32/64 bit)
67 // ALU32 Instructions:
68 // ========================================
69 // Arithmetic / Logical (32 bit)
72 // XTYPE Instructions (32/64 bit):
73 // ========================================
74 // Arithmetic, Logical, Bit Manipulation
75 // Multiply (Integer, Fractional, Complex)
76 // Permute / Vector Permute Operations
77 // Predicate Operations
78 // Shift / Shift with Add/Sub/Logical
80 // Vector Halfword (ALU, Shift, Multiply)
81 // Vector Word (ALU, Shift)
84 // ========================================
85 // Jump/Call PC-relative
88 // ========================================
91 // MEMOP Instructions:
92 // ========================================
93 // Operation on memory (8/16/32 bit)
96 // ========================================
101 // ========================================
102 // Control-Register Transfers
103 // Hardware Loop Setup
104 // Predicate Logicals & Reductions
106 // SYSTEM Instructions (not implemented in the compiler):
107 // ========================================
113 //===----------------------------------------------------------------------===//
115 //===----------------------------------------------------------------------===//
117 class T_ALU32_3op_not<string mnemonic, bits<3> MajOp, bits<3> MinOp,
119 : T_ALU32_3op<mnemonic, MajOp, MinOp, OpsRev, 0> {
120 let AsmString = "$Rd = "#mnemonic#"($Rs, ~$Rt)";
123 let BaseOpcode = "andn_rr", CextOpcode = "andn" in
124 def A4_andn : T_ALU32_3op_not<"and", 0b001, 0b100, 1>;
125 let BaseOpcode = "orn_rr", CextOpcode = "orn" in
126 def A4_orn : T_ALU32_3op_not<"or", 0b001, 0b101, 1>;
128 let CextOpcode = "rcmp.eq" in
129 def A4_rcmpeq : T_ALU32_3op<"cmp.eq", 0b011, 0b010, 0, 1>;
130 let CextOpcode = "!rcmp.eq" in
131 def A4_rcmpneq : T_ALU32_3op<"!cmp.eq", 0b011, 0b011, 0, 1>;
133 def C4_cmpneq : T_ALU32_3op_cmp<"!cmp.eq", 0b00, 1, 1>;
134 def C4_cmplte : T_ALU32_3op_cmp<"!cmp.gt", 0b10, 1, 0>;
135 def C4_cmplteu : T_ALU32_3op_cmp<"!cmp.gtu", 0b11, 1, 0>;
137 class T_CMP_rrbh<string mnemonic, bits<3> MinOp, bit IsComm>
138 : SInst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, IntRegs:$Rt),
139 "$Pd = "#mnemonic#"($Rs, $Rt)", [], "", S_3op_tc_2early_SLOT23>,
141 let InputType = "reg";
142 let CextOpcode = mnemonic;
144 let isCommutable = IsComm;
145 let hasSideEffects = 0;
152 let Inst{27-21} = 0b0111110;
153 let Inst{20-16} = Rs;
155 let Inst{7-5} = MinOp;
159 def A4_cmpbeq : T_CMP_rrbh<"cmpb.eq", 0b110, 1>;
160 def A4_cmpbgt : T_CMP_rrbh<"cmpb.gt", 0b010, 0>;
161 def A4_cmpbgtu : T_CMP_rrbh<"cmpb.gtu", 0b111, 0>;
162 def A4_cmpheq : T_CMP_rrbh<"cmph.eq", 0b011, 1>;
163 def A4_cmphgt : T_CMP_rrbh<"cmph.gt", 0b100, 0>;
164 def A4_cmphgtu : T_CMP_rrbh<"cmph.gtu", 0b101, 0>;
166 class T_CMP_ribh<string mnemonic, bits<2> MajOp, bit IsHalf, bit IsComm,
167 Operand ImmType, bit IsImmExt, bit IsImmSigned, int ImmBits>
168 : ALU64Inst<(outs PredRegs:$Pd), (ins IntRegs:$Rs, ImmType:$Imm),
169 "$Pd = "#mnemonic#"($Rs, #$Imm)", [], "", ALU64_tc_2early_SLOT23>,
171 let InputType = "imm";
172 let CextOpcode = mnemonic;
174 let isCommutable = IsComm;
175 let hasSideEffects = 0;
176 let isExtendable = IsImmExt;
177 let opExtendable = !if (IsImmExt, 2, 0);
178 let isExtentSigned = IsImmSigned;
179 let opExtentBits = ImmBits;
186 let Inst{27-24} = 0b1101;
187 let Inst{22-21} = MajOp;
188 let Inst{20-16} = Rs;
189 let Inst{12-5} = Imm;
191 let Inst{3} = IsHalf;
195 def A4_cmpbeqi : T_CMP_ribh<"cmpb.eq", 0b00, 0, 1, u8_0Imm, 0, 0, 8>;
196 def A4_cmpbgti : T_CMP_ribh<"cmpb.gt", 0b01, 0, 0, s8_0Imm, 0, 1, 8>;
197 def A4_cmpbgtui : T_CMP_ribh<"cmpb.gtu", 0b10, 0, 0, u7_0Ext, 1, 0, 7>;
198 def A4_cmpheqi : T_CMP_ribh<"cmph.eq", 0b00, 1, 1, s8_0Ext, 1, 1, 8>;
199 def A4_cmphgti : T_CMP_ribh<"cmph.gt", 0b01, 1, 0, s8_0Ext, 1, 1, 8>;
200 def A4_cmphgtui : T_CMP_ribh<"cmph.gtu", 0b10, 1, 0, u7_0Ext, 1, 0, 7>;
202 class T_RCMP_EQ_ri<string mnemonic, bit IsNeg>
203 : ALU32_ri<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s8_0Ext:$s8),
204 "$Rd = "#mnemonic#"($Rs, #$s8)", [], "", ALU32_2op_tc_1_SLOT0123>,
206 let InputType = "imm";
207 let CextOpcode = !if (IsNeg, "!rcmp.eq", "rcmp.eq");
208 let isExtendable = 1;
209 let opExtendable = 2;
210 let isExtentSigned = 1;
211 let opExtentBits = 8;
219 let Inst{27-24} = 0b0011;
221 let Inst{21} = IsNeg;
222 let Inst{20-16} = Rs;
228 def A4_rcmpeqi : T_RCMP_EQ_ri<"cmp.eq", 0>;
229 def A4_rcmpneqi : T_RCMP_EQ_ri<"!cmp.eq", 1>;
231 //===----------------------------------------------------------------------===//
233 //===----------------------------------------------------------------------===//
236 //===----------------------------------------------------------------------===//
238 //===----------------------------------------------------------------------===//
240 // Combine a word and an immediate into a register pair.
241 let hasSideEffects = 0, isExtentSigned = 1, isExtendable = 1,
243 class T_Combine1 <bits<2> MajOp, dag ins, string AsmStr>
244 : ALU32Inst <(outs DoubleRegs:$Rdd), ins, AsmStr> {
250 let Inst{27-24} = 0b0011;
251 let Inst{22-21} = MajOp;
252 let Inst{20-16} = Rs;
258 let opExtendable = 2 in
259 def A4_combineri : T_Combine1<0b00, (ins IntRegs:$Rs, s8_0Ext:$s8),
260 "$Rdd = combine($Rs, #$s8)">;
262 let opExtendable = 1 in
263 def A4_combineir : T_Combine1<0b01, (ins s8_0Ext:$s8, IntRegs:$Rs),
264 "$Rdd = combine(#$s8, $Rs)">;
266 // A4_combineii: Set two small immediates.
267 let hasSideEffects = 0, isExtendable = 1, opExtentBits = 6, opExtendable = 2 in
268 def A4_combineii: ALU32Inst<(outs DoubleRegs:$Rdd), (ins s8_0Imm:$s8, u6_0Ext:$U6),
269 "$Rdd = combine(#$s8, #$U6)"> {
275 let Inst{27-23} = 0b11001;
276 let Inst{20-16} = U6{5-1};
277 let Inst{13} = U6{0};
282 //===----------------------------------------------------------------------===//
284 //===----------------------------------------------------------------------===//
286 //===----------------------------------------------------------------------===//
288 //===----------------------------------------------------------------------===//
290 //===----------------------------------------------------------------------===//
291 // Template class for load instructions with Absolute set addressing mode.
292 //===----------------------------------------------------------------------===//
293 let isExtended = 1, opExtendable = 2, opExtentBits = 6, addrMode = AbsoluteSet,
294 hasSideEffects = 0 in
295 class T_LD_abs_set<string mnemonic, RegisterClass RC, bits<4>MajOp>:
296 LDInst<(outs RC:$dst1, IntRegs:$dst2),
298 "$dst1 = "#mnemonic#"($dst2 = #$addr)",
306 let Inst{27-25} = 0b101;
307 let Inst{24-21} = MajOp;
308 let Inst{13-12} = 0b01;
309 let Inst{4-0} = dst1;
310 let Inst{20-16} = dst2;
311 let Inst{11-8} = addr{5-2};
312 let Inst{6-5} = addr{1-0};
315 let accessSize = ByteAccess, hasNewValue = 1 in {
316 def L4_loadrb_ap : T_LD_abs_set <"memb", IntRegs, 0b1000>;
317 def L4_loadrub_ap : T_LD_abs_set <"memub", IntRegs, 0b1001>;
320 let accessSize = HalfWordAccess, hasNewValue = 1 in {
321 def L4_loadrh_ap : T_LD_abs_set <"memh", IntRegs, 0b1010>;
322 def L4_loadruh_ap : T_LD_abs_set <"memuh", IntRegs, 0b1011>;
323 def L4_loadbsw2_ap : T_LD_abs_set <"membh", IntRegs, 0b0001>;
324 def L4_loadbzw2_ap : T_LD_abs_set <"memubh", IntRegs, 0b0011>;
327 let accessSize = WordAccess, hasNewValue = 1 in
328 def L4_loadri_ap : T_LD_abs_set <"memw", IntRegs, 0b1100>;
330 let accessSize = WordAccess in {
331 def L4_loadbzw4_ap : T_LD_abs_set <"memubh", DoubleRegs, 0b0101>;
332 def L4_loadbsw4_ap : T_LD_abs_set <"membh", DoubleRegs, 0b0111>;
335 let accessSize = DoubleWordAccess in
336 def L4_loadrd_ap : T_LD_abs_set <"memd", DoubleRegs, 0b1110>;
338 let accessSize = ByteAccess in
339 def L4_loadalignb_ap : T_LD_abs_set <"memb_fifo", DoubleRegs, 0b0100>;
341 let accessSize = HalfWordAccess in
342 def L4_loadalignh_ap : T_LD_abs_set <"memh_fifo", DoubleRegs, 0b0010>;
344 // Load - Indirect with long offset
345 let InputType = "imm", addrMode = BaseLongOffset, isExtended = 1,
346 opExtentBits = 6, opExtendable = 3 in
347 class T_LoadAbsReg <string mnemonic, string CextOp, RegisterClass RC,
349 : LDInst <(outs RC:$dst), (ins IntRegs:$src1, u2_0Imm:$src2, u6_0Ext:$src3),
350 "$dst = "#mnemonic#"($src1<<#$src2 + #$src3)",
356 let CextOpcode = CextOp;
357 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
360 let Inst{27-25} = 0b110;
361 let Inst{24-21} = MajOp;
362 let Inst{20-16} = src1;
363 let Inst{13} = src2{1};
365 let Inst{11-8} = src3{5-2};
366 let Inst{7} = src2{0};
367 let Inst{6-5} = src3{1-0};
371 let accessSize = ByteAccess in {
372 def L4_loadrb_ur : T_LoadAbsReg<"memb", "LDrib", IntRegs, 0b1000>;
373 def L4_loadrub_ur : T_LoadAbsReg<"memub", "LDriub", IntRegs, 0b1001>;
374 def L4_loadalignb_ur : T_LoadAbsReg<"memb_fifo", "LDrib_fifo",
378 let accessSize = HalfWordAccess in {
379 def L4_loadrh_ur : T_LoadAbsReg<"memh", "LDrih", IntRegs, 0b1010>;
380 def L4_loadruh_ur : T_LoadAbsReg<"memuh", "LDriuh", IntRegs, 0b1011>;
381 def L4_loadbsw2_ur : T_LoadAbsReg<"membh", "LDribh2", IntRegs, 0b0001>;
382 def L4_loadbzw2_ur : T_LoadAbsReg<"memubh", "LDriubh2", IntRegs, 0b0011>;
383 def L4_loadalignh_ur : T_LoadAbsReg<"memh_fifo", "LDrih_fifo",
387 let accessSize = WordAccess in {
388 def L4_loadri_ur : T_LoadAbsReg<"memw", "LDriw", IntRegs, 0b1100>;
389 def L4_loadbsw4_ur : T_LoadAbsReg<"membh", "LDribh4", DoubleRegs, 0b0111>;
390 def L4_loadbzw4_ur : T_LoadAbsReg<"memubh", "LDriubh4", DoubleRegs, 0b0101>;
393 let accessSize = DoubleWordAccess in
394 def L4_loadrd_ur : T_LoadAbsReg<"memd", "LDrid", DoubleRegs, 0b1110>;
397 //===----------------------------------------------------------------------===//
398 // Template classes for the non-predicated load instructions with
399 // base + register offset addressing mode
400 //===----------------------------------------------------------------------===//
401 class T_load_rr <string mnemonic, RegisterClass RC, bits<3> MajOp>:
402 LDInst<(outs RC:$dst), (ins IntRegs:$src1, IntRegs:$src2, u2_0Imm:$u2),
403 "$dst = "#mnemonic#"($src1 + $src2<<#$u2)",
404 [], "", V4LDST_tc_ld_SLOT01>, ImmRegShl, AddrModeRel {
412 let Inst{27-24} = 0b1010;
413 let Inst{23-21} = MajOp;
414 let Inst{20-16} = src1;
415 let Inst{12-8} = src2;
416 let Inst{13} = u2{1};
421 //===----------------------------------------------------------------------===//
422 // Template classes for the predicated load instructions with
423 // base + register offset addressing mode
424 //===----------------------------------------------------------------------===//
425 let isPredicated = 1 in
426 class T_pload_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
427 bit isNot, bit isPredNew>:
428 LDInst <(outs RC:$dst),
429 (ins PredRegs:$src1, IntRegs:$src2, IntRegs:$src3, u2_0Imm:$u2),
430 !if(isNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
431 ") ")#"$dst = "#mnemonic#"($src2+$src3<<#$u2)",
432 [], "", V4LDST_tc_ld_SLOT01>, AddrModeRel {
439 let isPredicatedFalse = isNot;
440 let isPredicatedNew = isPredNew;
444 let Inst{27-26} = 0b00;
445 let Inst{25} = isPredNew;
446 let Inst{24} = isNot;
447 let Inst{23-21} = MajOp;
448 let Inst{20-16} = src2;
449 let Inst{12-8} = src3;
450 let Inst{13} = u2{1};
452 let Inst{6-5} = src1;
456 //===----------------------------------------------------------------------===//
457 // multiclass for load instructions with base + register offset
459 //===----------------------------------------------------------------------===//
460 let hasSideEffects = 0, addrMode = BaseRegOffset in
461 multiclass ld_idxd_shl <string mnemonic, string CextOp, RegisterClass RC,
463 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl,
464 InputType = "reg" in {
465 let isPredicable = 1 in
466 def L4_#NAME#_rr : T_load_rr <mnemonic, RC, MajOp>;
469 def L4_p#NAME#t_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 0>;
470 def L4_p#NAME#f_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 0>;
473 def L4_p#NAME#tnew_rr : T_pload_rr <mnemonic, RC, MajOp, 0, 1>;
474 def L4_p#NAME#fnew_rr : T_pload_rr <mnemonic, RC, MajOp, 1, 1>;
478 let hasNewValue = 1, accessSize = ByteAccess in {
479 defm loadrb : ld_idxd_shl<"memb", "LDrib", IntRegs, 0b000>;
480 defm loadrub : ld_idxd_shl<"memub", "LDriub", IntRegs, 0b001>;
483 let hasNewValue = 1, accessSize = HalfWordAccess in {
484 defm loadrh : ld_idxd_shl<"memh", "LDrih", IntRegs, 0b010>;
485 defm loadruh : ld_idxd_shl<"memuh", "LDriuh", IntRegs, 0b011>;
488 let hasNewValue = 1, accessSize = WordAccess in
489 defm loadri : ld_idxd_shl<"memw", "LDriw", IntRegs, 0b100>;
491 let accessSize = DoubleWordAccess in
492 defm loadrd : ld_idxd_shl<"memd", "LDrid", DoubleRegs, 0b110>;
494 //===----------------------------------------------------------------------===//
496 //===----------------------------------------------------------------------===//
498 //===----------------------------------------------------------------------===//
500 //===----------------------------------------------------------------------===//
502 //===----------------------------------------------------------------------===//
503 // Template class for store instructions with Absolute set addressing mode.
504 //===----------------------------------------------------------------------===//
505 let isExtended = 1, opExtendable = 1, opExtentBits = 6,
506 addrMode = AbsoluteSet in
507 class T_ST_absset <string mnemonic, string BaseOp, RegisterClass RC,
508 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
509 : STInst<(outs IntRegs:$dst),
510 (ins u6_0Ext:$addr, RC:$src),
511 mnemonic#"($dst = #$addr) = $src"#!if(isHalf, ".h","")>, NewValueRel {
515 let accessSize = AccessSz;
516 let BaseOpcode = BaseOp#"_AbsSet";
518 // Store upper-half and store doubleword cannot be NV.
519 let isNVStorable = !if (!eq(mnemonic, "memd"), 0, !if(isHalf,0,1));
523 let Inst{27-24} = 0b1011;
524 let Inst{23-21} = MajOp;
525 let Inst{20-16} = dst;
527 let Inst{12-8} = src;
529 let Inst{5-0} = addr;
532 def S4_storerb_ap : T_ST_absset <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
533 def S4_storerh_ap : T_ST_absset <"memh", "STrih", IntRegs, 0b010,
535 def S4_storeri_ap : T_ST_absset <"memw", "STriw", IntRegs, 0b100, WordAccess>;
537 let isNVStorable = 0 in {
538 def S4_storerf_ap : T_ST_absset <"memh", "STrif", IntRegs,
539 0b011, HalfWordAccess, 1>;
540 def S4_storerd_ap : T_ST_absset <"memd", "STrid", DoubleRegs,
541 0b110, DoubleWordAccess>;
544 let opExtendable = 1, isNewValue = 1, isNVStore = 1, opNewValue = 2,
545 isExtended = 1, opExtentBits= 6 in
546 class T_ST_absset_nv <string mnemonic, string BaseOp, bits<2> MajOp,
547 MemAccessSize AccessSz >
548 : NVInst <(outs IntRegs:$dst),
549 (ins u6_0Ext:$addr, IntRegs:$src),
550 mnemonic#"($dst = #$addr) = $src.new">, NewValueRel {
554 let accessSize = AccessSz;
555 let BaseOpcode = BaseOp#"_AbsSet";
559 let Inst{27-21} = 0b1011101;
560 let Inst{20-16} = dst;
561 let Inst{13-11} = 0b000;
562 let Inst{12-11} = MajOp;
563 let Inst{10-8} = src;
565 let Inst{5-0} = addr;
568 let mayStore = 1, addrMode = AbsoluteSet in {
569 def S4_storerbnew_ap : T_ST_absset_nv <"memb", "STrib", 0b00, ByteAccess>;
570 def S4_storerhnew_ap : T_ST_absset_nv <"memh", "STrih", 0b01, HalfWordAccess>;
571 def S4_storerinew_ap : T_ST_absset_nv <"memw", "STriw", 0b10, WordAccess>;
574 let isExtended = 1, opExtendable = 2, opExtentBits = 6, InputType = "imm",
575 addrMode = BaseLongOffset, AddedComplexity = 40 in
576 class T_StoreAbsReg <string mnemonic, string CextOp, RegisterClass RC,
577 bits<3> MajOp, MemAccessSize AccessSz, bit isHalf = 0>
579 (ins IntRegs:$src1, u2_0Imm:$src2, u6_0Ext:$src3, RC:$src4),
580 mnemonic#"($src1<<#$src2 + #$src3) = $src4"#!if(isHalf, ".h",""),
581 []>, ImmRegShl, NewValueRel {
588 let accessSize = AccessSz;
589 let CextOpcode = CextOp;
590 let BaseOpcode = CextOp#"_shl";
592 // Store upper-half and store doubleword cannot be NV.
593 let isNVStorable = !if (!eq(mnemonic, "memd"), 0, !if(isHalf,0,1));
597 let Inst{27-24} =0b1101;
598 let Inst{23-21} = MajOp;
599 let Inst{20-16} = src1;
600 let Inst{13} = src2{1};
601 let Inst{12-8} = src4;
603 let Inst{6} = src2{0};
604 let Inst{5-0} = src3;
607 def S4_storerb_ur : T_StoreAbsReg <"memb", "STrib", IntRegs, 0b000, ByteAccess>;
608 def S4_storerh_ur : T_StoreAbsReg <"memh", "STrih", IntRegs, 0b010,
610 def S4_storerf_ur : T_StoreAbsReg <"memh", "STrif", IntRegs, 0b011,
612 def S4_storeri_ur : T_StoreAbsReg <"memw", "STriw", IntRegs, 0b100, WordAccess>;
613 def S4_storerd_ur : T_StoreAbsReg <"memd", "STrid", DoubleRegs, 0b110,
616 let mayStore = 1, isNVStore = 1, isExtended = 1, addrMode = BaseLongOffset,
617 opExtentBits = 6, isNewValue = 1, opNewValue = 3, opExtendable = 2 in
618 class T_StoreAbsRegNV <string mnemonic, string CextOp, bits<2> MajOp,
619 MemAccessSize AccessSz>
621 (ins IntRegs:$src1, u2_0Imm:$src2, u6_0Ext:$src3, IntRegs:$src4),
622 mnemonic#"($src1<<#$src2 + #$src3) = $src4.new">, NewValueRel {
628 let CextOpcode = CextOp;
629 let BaseOpcode = CextOp#"_shl";
632 let Inst{27-21} = 0b1101101;
633 let Inst{12-11} = 0b00;
635 let Inst{20-16} = src1;
636 let Inst{13} = src2{1};
637 let Inst{12-11} = MajOp;
638 let Inst{10-8} = src4;
639 let Inst{6} = src2{0};
640 let Inst{5-0} = src3;
643 def S4_storerbnew_ur : T_StoreAbsRegNV <"memb", "STrib", 0b00, ByteAccess>;
644 def S4_storerhnew_ur : T_StoreAbsRegNV <"memh", "STrih", 0b01, HalfWordAccess>;
645 def S4_storerinew_ur : T_StoreAbsRegNV <"memw", "STriw", 0b10, WordAccess>;
647 //===----------------------------------------------------------------------===//
648 // Template classes for the non-predicated store instructions with
649 // base + register offset addressing mode
650 //===----------------------------------------------------------------------===//
651 let isPredicable = 1 in
652 class T_store_rr <string mnemonic, RegisterClass RC, bits<3> MajOp, bit isH>
653 : STInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2_0Imm:$u2, RC:$Rt),
654 mnemonic#"($Rs + $Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
655 [],"",V4LDST_tc_st_SLOT01>, ImmRegShl, AddrModeRel {
662 // Store upper-half and store doubleword cannot be NV.
663 let isNVStorable = !if (!eq(mnemonic, "memd"), 0, !if(isH,0,1));
667 let Inst{27-24} = 0b1011;
668 let Inst{23-21} = MajOp;
669 let Inst{20-16} = Rs;
671 let Inst{13} = u2{1};
676 //===----------------------------------------------------------------------===//
677 // Template classes for the predicated store instructions with
678 // base + register offset addressing mode
679 //===----------------------------------------------------------------------===//
680 let isPredicated = 1 in
681 class T_pstore_rr <string mnemonic, RegisterClass RC, bits<3> MajOp,
682 bit isNot, bit isPredNew, bit isH>
684 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2_0Imm:$u2, RC:$Rt),
686 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
687 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Rt"#!if(isH, ".h",""),
688 [], "", V4LDST_tc_st_SLOT01> , AddrModeRel{
695 let isPredicatedFalse = isNot;
696 let isPredicatedNew = isPredNew;
697 // Store upper-half and store doubleword cannot be NV.
698 let isNVStorable = !if (!eq(mnemonic, "memd"), 0, !if(isH,0,1));
702 let Inst{27-26} = 0b01;
703 let Inst{25} = isPredNew;
704 let Inst{24} = isNot;
705 let Inst{23-21} = MajOp;
706 let Inst{20-16} = Rs;
708 let Inst{13} = u2{1};
714 //===----------------------------------------------------------------------===//
715 // Template classes for the new-value store instructions with
716 // base + register offset addressing mode
717 //===----------------------------------------------------------------------===//
718 let isPredicable = 1, isNewValue = 1, opNewValue = 3 in
719 class T_store_new_rr <string mnemonic, bits<2> MajOp> :
720 NVInst < (outs ), (ins IntRegs:$Rs, IntRegs:$Ru, u2_0Imm:$u2, IntRegs:$Nt),
721 mnemonic#"($Rs + $Ru<<#$u2) = $Nt.new",
722 [],"",V4LDST_tc_st_SLOT0>, ImmRegShl, AddrModeRel {
731 let Inst{27-21} = 0b1011101;
732 let Inst{20-16} = Rs;
734 let Inst{13} = u2{1};
736 let Inst{4-3} = MajOp;
740 //===----------------------------------------------------------------------===//
741 // Template classes for the predicated new-value store instructions with
742 // base + register offset addressing mode
743 //===----------------------------------------------------------------------===//
744 let isPredicated = 1, isNewValue = 1, opNewValue = 4 in
745 class T_pstore_new_rr <string mnemonic, bits<2> MajOp, bit isNot, bit isPredNew>
747 (ins PredRegs:$Pv, IntRegs:$Rs, IntRegs:$Ru, u2_0Imm:$u2, IntRegs:$Nt),
748 !if(isNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
749 ") ")#mnemonic#"($Rs+$Ru<<#$u2) = $Nt.new",
750 [], "", V4LDST_tc_st_SLOT0>, AddrModeRel {
757 let isPredicatedFalse = isNot;
758 let isPredicatedNew = isPredNew;
761 let Inst{27-26} = 0b01;
762 let Inst{25} = isPredNew;
763 let Inst{24} = isNot;
764 let Inst{23-21} = 0b101;
765 let Inst{20-16} = Rs;
767 let Inst{13} = u2{1};
770 let Inst{4-3} = MajOp;
774 //===----------------------------------------------------------------------===//
775 // multiclass for store instructions with base + register offset addressing
777 //===----------------------------------------------------------------------===//
778 let isNVStorable = 1 in
779 multiclass ST_Idxd_shl<string mnemonic, string CextOp, RegisterClass RC,
780 bits<3> MajOp, bit isH = 0> {
781 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
782 def S4_#NAME#_rr : T_store_rr <mnemonic, RC, MajOp, isH>;
785 def S4_p#NAME#t_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 0, isH>;
786 def S4_p#NAME#f_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 0, isH>;
789 def S4_p#NAME#tnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 0, 1, isH>;
790 def S4_p#NAME#fnew_rr : T_pstore_rr <mnemonic, RC, MajOp, 1, 1, isH>;
794 //===----------------------------------------------------------------------===//
795 // multiclass for new-value store instructions with base + register offset
797 //===----------------------------------------------------------------------===//
798 let mayStore = 1, isNVStore = 1 in
799 multiclass ST_Idxd_shl_nv <string mnemonic, string CextOp, RegisterClass RC,
801 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed_shl in {
802 def S4_#NAME#new_rr : T_store_new_rr<mnemonic, MajOp>;
805 def S4_p#NAME#newt_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 0>;
806 def S4_p#NAME#newf_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 0>;
809 def S4_p#NAME#newtnew_rr : T_pstore_new_rr <mnemonic, MajOp, 0, 1>;
810 def S4_p#NAME#newfnew_rr : T_pstore_new_rr <mnemonic, MajOp, 1, 1>;
814 let addrMode = BaseRegOffset, InputType = "reg", hasSideEffects = 0 in {
815 let accessSize = ByteAccess in
816 defm storerb: ST_Idxd_shl<"memb", "STrib", IntRegs, 0b000>,
817 ST_Idxd_shl_nv<"memb", "STrib", IntRegs, 0b00>;
819 let accessSize = HalfWordAccess in
820 defm storerh: ST_Idxd_shl<"memh", "STrih", IntRegs, 0b010>,
821 ST_Idxd_shl_nv<"memh", "STrih", IntRegs, 0b01>;
823 let accessSize = WordAccess in
824 defm storeri: ST_Idxd_shl<"memw", "STriw", IntRegs, 0b100>,
825 ST_Idxd_shl_nv<"memw", "STriw", IntRegs, 0b10>;
827 let isNVStorable = 0, accessSize = DoubleWordAccess in
828 defm storerd: ST_Idxd_shl<"memd", "STrid", DoubleRegs, 0b110>;
830 let isNVStorable = 0, accessSize = HalfWordAccess in
831 defm storerf: ST_Idxd_shl<"memh", "STrif", IntRegs, 0b011, 1>;
834 //===----------------------------------------------------------------------===//
836 //===----------------------------------------------------------------------===//
837 let isPredicable = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 8,
839 class T_StoreImm <string mnemonic, Operand OffsetOp, bits<2> MajOp >
840 : STInst <(outs ), (ins IntRegs:$Rs, OffsetOp:$offset, s8_0Ext:$S8),
841 mnemonic#"($Rs+#$offset)=#$S8",
842 [], "", V4LDST_tc_st_SLOT01>,
843 ImmRegRel, PredNewRel {
849 string OffsetOpStr = !cast<string>(OffsetOp);
850 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
851 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
852 /* u6_0Imm */ offset{5-0}));
856 let Inst{27-25} = 0b110;
857 let Inst{22-21} = MajOp;
858 let Inst{20-16} = Rs;
859 let Inst{12-7} = offsetBits;
860 let Inst{13} = S8{7};
861 let Inst{6-0} = S8{6-0};
864 let isPredicated = 1, isExtendable = 1, isExtentSigned = 1, opExtentBits = 6,
866 class T_StoreImm_pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
867 bit isPredNot, bit isPredNew >
869 (ins PredRegs:$Pv, IntRegs:$Rs, OffsetOp:$offset, s6_0Ext:$S6),
870 !if(isPredNot, "if (!$Pv", "if ($Pv")#!if(isPredNew, ".new) ",
871 ") ")#mnemonic#"($Rs+#$offset)=#$S6",
872 [], "", V4LDST_tc_st_SLOT01>,
873 ImmRegRel, PredNewRel {
880 string OffsetOpStr = !cast<string>(OffsetOp);
881 let offsetBits = !if (!eq(OffsetOpStr, "u6_2Imm"), offset{7-2},
882 !if (!eq(OffsetOpStr, "u6_1Imm"), offset{6-1},
883 /* u6_0Imm */ offset{5-0}));
884 let isPredicatedNew = isPredNew;
885 let isPredicatedFalse = isPredNot;
889 let Inst{27-25} = 0b100;
890 let Inst{24} = isPredNew;
891 let Inst{23} = isPredNot;
892 let Inst{22-21} = MajOp;
893 let Inst{20-16} = Rs;
894 let Inst{13} = S6{5};
895 let Inst{12-7} = offsetBits;
897 let Inst{4-0} = S6{4-0};
901 //===----------------------------------------------------------------------===//
902 // multiclass for store instructions with base + immediate offset
903 // addressing mode and immediate stored value.
904 // mem[bhw](Rx++#s4:3)=#s8
905 // if ([!]Pv[.new]) mem[bhw](Rx++#s4:3)=#s6
906 //===----------------------------------------------------------------------===//
908 multiclass ST_Imm_Pred <string mnemonic, Operand OffsetOp, bits<2> MajOp,
910 def _io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 0>;
912 def new_io : T_StoreImm_pred <mnemonic, OffsetOp, MajOp, PredNot, 1>;
915 multiclass ST_Imm <string mnemonic, string CextOp, Operand OffsetOp,
917 let CextOpcode = CextOp, BaseOpcode = CextOp#_imm in {
918 def _io : T_StoreImm <mnemonic, OffsetOp, MajOp>;
920 defm t : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 0>;
921 defm f : ST_Imm_Pred <mnemonic, OffsetOp, MajOp, 1>;
925 let hasSideEffects = 0, addrMode = BaseImmOffset,
926 InputType = "imm" in {
927 let accessSize = ByteAccess in
928 defm S4_storeirb : ST_Imm<"memb", "STrib", u6_0Imm, 0b00>;
930 let accessSize = HalfWordAccess in
931 defm S4_storeirh : ST_Imm<"memh", "STrih", u6_1Imm, 0b01>;
933 let accessSize = WordAccess in
934 defm S4_storeiri : ST_Imm<"memw", "STriw", u6_2Imm, 0b10>;
937 //===----------------------------------------------------------------------===
939 //===----------------------------------------------------------------------===
942 //===----------------------------------------------------------------------===//
944 //===----------------------------------------------------------------------===//
946 let opNewValue = 2, opExtendable = 1, isExtentSigned = 1, isPredicable = 1 in
947 class T_store_io_nv <string mnemonic, RegisterClass RC,
948 Operand ImmOp, bits<2>MajOp>
950 (ins IntRegs:$src1, ImmOp:$src2, RC:$src3),
951 mnemonic#"($src1+#$src2) = $src3.new",
952 [],"",ST_tc_st_SLOT0> {
954 bits<13> src2; // Actual address offset
956 bits<11> offsetBits; // Represents offset encoding
958 let opExtentBits = !if (!eq(mnemonic, "memb"), 11,
959 !if (!eq(mnemonic, "memh"), 12,
960 !if (!eq(mnemonic, "memw"), 13, 0)));
962 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
963 !if (!eq(mnemonic, "memh"), 1,
964 !if (!eq(mnemonic, "memw"), 2, 0)));
966 let offsetBits = !if (!eq(mnemonic, "memb"), src2{10-0},
967 !if (!eq(mnemonic, "memh"), src2{11-1},
968 !if (!eq(mnemonic, "memw"), src2{12-2}, 0)));
973 let Inst{26-25} = offsetBits{10-9};
974 let Inst{24-21} = 0b1101;
975 let Inst{20-16} = src1;
976 let Inst{13} = offsetBits{8};
977 let Inst{12-11} = MajOp;
978 let Inst{10-8} = src3;
979 let Inst{7-0} = offsetBits{7-0};
982 let opExtendable = 2, opNewValue = 3, isPredicated = 1 in
983 class T_pstore_io_nv <string mnemonic, RegisterClass RC, Operand predImmOp,
984 bits<2>MajOp, bit PredNot, bit isPredNew>
986 (ins PredRegs:$src1, IntRegs:$src2, predImmOp:$src3, RC:$src4),
987 !if(PredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
988 ") ")#mnemonic#"($src2+#$src3) = $src4.new",
989 [],"",V2LDST_tc_st_SLOT0> {
994 bits<6> offsetBits; // Represents offset encoding
996 let isPredicatedNew = isPredNew;
997 let isPredicatedFalse = PredNot;
998 let opExtentBits = !if (!eq(mnemonic, "memb"), 6,
999 !if (!eq(mnemonic, "memh"), 7,
1000 !if (!eq(mnemonic, "memw"), 8, 0)));
1002 let opExtentAlign = !if (!eq(mnemonic, "memb"), 0,
1003 !if (!eq(mnemonic, "memh"), 1,
1004 !if (!eq(mnemonic, "memw"), 2, 0)));
1006 let offsetBits = !if (!eq(mnemonic, "memb"), src3{5-0},
1007 !if (!eq(mnemonic, "memh"), src3{6-1},
1008 !if (!eq(mnemonic, "memw"), src3{7-2}, 0)));
1010 let IClass = 0b0100;
1013 let Inst{26} = PredNot;
1014 let Inst{25} = isPredNew;
1015 let Inst{24-21} = 0b0101;
1016 let Inst{20-16} = src2;
1017 let Inst{13} = offsetBits{5};
1018 let Inst{12-11} = MajOp;
1019 let Inst{10-8} = src4;
1020 let Inst{7-3} = offsetBits{4-0};
1022 let Inst{1-0} = src1;
1025 // multiclass for new-value store instructions with base + immediate offset.
1027 let mayStore = 1, isNVStore = 1, isNewValue = 1, hasSideEffects = 0,
1029 multiclass ST_Idxd_nv<string mnemonic, string CextOp, RegisterClass RC,
1030 Operand ImmOp, Operand predImmOp, bits<2> MajOp> {
1032 let CextOpcode = CextOp, BaseOpcode = CextOp#_indexed in {
1033 def S2_#NAME#new_io : T_store_io_nv <mnemonic, RC, ImmOp, MajOp>;
1035 def S2_p#NAME#newt_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 0, 0>;
1036 def S2_p#NAME#newf_io :T_pstore_io_nv <mnemonic, RC, predImmOp, MajOp, 1, 0>;
1038 def S4_p#NAME#newtnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1040 def S4_p#NAME#newfnew_io :T_pstore_io_nv <mnemonic, RC, predImmOp,
1045 let addrMode = BaseImmOffset, InputType = "imm" in {
1046 let accessSize = ByteAccess in
1047 defm storerb: ST_Idxd_nv<"memb", "STrib", IntRegs, s11_0Ext,
1048 u6_0Ext, 0b00>, AddrModeRel;
1050 let accessSize = HalfWordAccess, opExtentAlign = 1 in
1051 defm storerh: ST_Idxd_nv<"memh", "STrih", IntRegs, s11_1Ext,
1052 u6_1Ext, 0b01>, AddrModeRel;
1054 let accessSize = WordAccess, opExtentAlign = 2 in
1055 defm storeri: ST_Idxd_nv<"memw", "STriw", IntRegs, s11_2Ext,
1056 u6_2Ext, 0b10>, AddrModeRel;
1059 //===----------------------------------------------------------------------===//
1060 // Post increment loads with register offset.
1061 //===----------------------------------------------------------------------===//
1063 let hasNewValue = 1 in
1064 def L2_loadbsw2_pr : T_load_pr <"membh", IntRegs, 0b0001, HalfWordAccess>;
1066 def L2_loadbsw4_pr : T_load_pr <"membh", DoubleRegs, 0b0111, WordAccess>;
1068 let hasSideEffects = 0, addrMode = PostInc in
1069 class T_loadalign_pr <string mnemonic, bits<4> MajOp, MemAccessSize AccessSz>
1070 : LDInstPI <(outs DoubleRegs:$dst, IntRegs:$_dst_),
1071 (ins DoubleRegs:$src1, IntRegs:$src2, ModRegs:$src3),
1072 "$dst = "#mnemonic#"($src2++$src3)", [],
1073 "$src1 = $dst, $src2 = $_dst_"> {
1078 let accessSize = AccessSz;
1079 let IClass = 0b1001;
1081 let Inst{27-25} = 0b110;
1082 let Inst{24-21} = MajOp;
1083 let Inst{20-16} = src2;
1084 let Inst{13} = src3;
1087 let Inst{4-0} = dst;
1090 def L2_loadalignb_pr : T_loadalign_pr <"memb_fifo", 0b0100, ByteAccess>;
1091 def L2_loadalignh_pr : T_loadalign_pr <"memh_fifo", 0b0010, HalfWordAccess>;
1093 //===----------------------------------------------------------------------===//
1094 // Template class for non-predicated post increment .new stores
1095 // mem[bhwd](Rx++#s4:[0123])=Nt.new
1096 //===----------------------------------------------------------------------===//
1097 let isPredicable = 1, hasSideEffects = 0, addrMode = PostInc, isNVStore = 1,
1098 isNewValue = 1, opNewValue = 3 in
1099 class T_StorePI_nv <string mnemonic, Operand ImmOp, bits<2> MajOp >
1100 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1101 (ins IntRegs:$src1, ImmOp:$offset, IntRegs:$src2),
1102 mnemonic#"($src1++#$offset) = $src2.new",
1103 [], "$src1 = $_dst_">,
1110 string ImmOpStr = !cast<string>(ImmOp);
1111 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1112 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1113 /* s4_0Imm */ offset{3-0}));
1114 let IClass = 0b1010;
1116 let Inst{27-21} = 0b1011101;
1117 let Inst{20-16} = src1;
1119 let Inst{12-11} = MajOp;
1120 let Inst{10-8} = src2;
1122 let Inst{6-3} = offsetBits;
1126 //===----------------------------------------------------------------------===//
1127 // Template class for predicated post increment .new stores
1128 // if([!]Pv[.new]) mem[bhwd](Rx++#s4:[0123])=Nt.new
1129 //===----------------------------------------------------------------------===//
1130 let isPredicated = 1, hasSideEffects = 0, addrMode = PostInc, isNVStore = 1,
1131 isNewValue = 1, opNewValue = 4 in
1132 class T_StorePI_nv_pred <string mnemonic, Operand ImmOp,
1133 bits<2> MajOp, bit isPredNot, bit isPredNew >
1134 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1135 (ins PredRegs:$src1, IntRegs:$src2,
1136 ImmOp:$offset, IntRegs:$src3),
1137 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
1138 ") ")#mnemonic#"($src2++#$offset) = $src3.new",
1139 [], "$src2 = $_dst_">,
1147 string ImmOpStr = !cast<string>(ImmOp);
1148 let offsetBits = !if (!eq(ImmOpStr, "s4_2Imm"), offset{5-2},
1149 !if (!eq(ImmOpStr, "s4_1Imm"), offset{4-1},
1150 /* s4_0Imm */ offset{3-0}));
1151 let isPredicatedNew = isPredNew;
1152 let isPredicatedFalse = isPredNot;
1154 let IClass = 0b1010;
1156 let Inst{27-21} = 0b1011101;
1157 let Inst{20-16} = src2;
1159 let Inst{12-11} = MajOp;
1160 let Inst{10-8} = src3;
1161 let Inst{7} = isPredNew;
1162 let Inst{6-3} = offsetBits;
1163 let Inst{2} = isPredNot;
1164 let Inst{1-0} = src1;
1167 multiclass ST_PostInc_Pred_nv<string mnemonic, Operand ImmOp,
1168 bits<2> MajOp, bit PredNot> {
1169 def _pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 0>;
1172 def new_pi : T_StorePI_nv_pred <mnemonic, ImmOp, MajOp, PredNot, 1>;
1175 multiclass ST_PostInc_nv<string mnemonic, string BaseOp, Operand ImmOp,
1177 let BaseOpcode = "POST_"#BaseOp in {
1178 def S2_#NAME#_pi : T_StorePI_nv <mnemonic, ImmOp, MajOp>;
1181 defm S2_p#NAME#t : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 0>;
1182 defm S2_p#NAME#f : ST_PostInc_Pred_nv <mnemonic, ImmOp, MajOp, 1>;
1186 let accessSize = ByteAccess in
1187 defm storerbnew: ST_PostInc_nv <"memb", "STrib", s4_0Imm, 0b00>;
1189 let accessSize = HalfWordAccess in
1190 defm storerhnew: ST_PostInc_nv <"memh", "STrih", s4_1Imm, 0b01>;
1192 let accessSize = WordAccess in
1193 defm storerinew: ST_PostInc_nv <"memw", "STriw", s4_2Imm, 0b10>;
1195 //===----------------------------------------------------------------------===//
1196 // Template class for post increment .new stores with register offset
1197 //===----------------------------------------------------------------------===//
1198 let isNewValue = 1, mayStore = 1, isNVStore = 1, opNewValue = 3 in
1199 class T_StorePI_RegNV <string mnemonic, bits<2> MajOp, MemAccessSize AccessSz>
1200 : NVInstPI_V4 <(outs IntRegs:$_dst_),
1201 (ins IntRegs:$src1, ModRegs:$src2, IntRegs:$src3),
1202 #mnemonic#"($src1++$src2) = $src3.new",
1203 [], "$src1 = $_dst_"> {
1207 let accessSize = AccessSz;
1209 let IClass = 0b1010;
1211 let Inst{27-21} = 0b1101101;
1212 let Inst{20-16} = src1;
1213 let Inst{13} = src2;
1214 let Inst{12-11} = MajOp;
1215 let Inst{10-8} = src3;
1219 def S2_storerbnew_pr : T_StorePI_RegNV<"memb", 0b00, ByteAccess>;
1220 def S2_storerhnew_pr : T_StorePI_RegNV<"memh", 0b01, HalfWordAccess>;
1221 def S2_storerinew_pr : T_StorePI_RegNV<"memw", 0b10, WordAccess>;
1223 // memb(Rx++#s4:0:circ(Mu))=Nt.new
1224 // memb(Rx++I:circ(Mu))=Nt.new
1225 // memb(Rx++Mu:brev)=Nt.new
1226 // memh(Rx++#s4:1:circ(Mu))=Nt.new
1227 // memh(Rx++I:circ(Mu))=Nt.new
1228 // memh(Rx++Mu)=Nt.new
1229 // memh(Rx++Mu:brev)=Nt.new
1231 // memw(Rx++#s4:2:circ(Mu))=Nt.new
1232 // memw(Rx++I:circ(Mu))=Nt.new
1233 // memw(Rx++Mu)=Nt.new
1234 // memw(Rx++Mu:brev)=Nt.new
1236 //===----------------------------------------------------------------------===//
1238 //===----------------------------------------------------------------------===//
1240 //===----------------------------------------------------------------------===//
1242 //===----------------------------------------------------------------------===//
1244 //===----------------------------------------------------------------------===//
1245 // multiclass/template class for the new-value compare jumps with the register
1247 //===----------------------------------------------------------------------===//
1249 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1250 opExtentAlign = 2 in
1251 class NVJrr_template<string mnemonic, bits<3> majOp, bit NvOpNum,
1252 bit isNegCond, bit isTak>
1254 (ins IntRegs:$src1, IntRegs:$src2, brtarget:$offset),
1255 "if ("#!if(isNegCond, "!","")#mnemonic#
1256 "($src1"#!if(!eq(NvOpNum, 0),".new, ",", ")#
1257 "$src2"#!if(!eq(NvOpNum, 1),".new))","))")#" jump:"
1258 #!if(isTak, "t","nt")#" $offset", []> {
1262 bits<3> Ns; // New-Value Operand
1263 bits<5> RegOp; // Non-New-Value Operand
1266 let isTaken = isTak;
1267 let isPredicatedFalse = isNegCond;
1268 let opNewValue{0} = NvOpNum;
1270 let Ns = !if(!eq(NvOpNum, 0), src1{2-0}, src2{2-0});
1271 let RegOp = !if(!eq(NvOpNum, 0), src2, src1);
1273 let IClass = 0b0010;
1274 let Inst{27-26} = 0b00;
1275 let Inst{25-23} = majOp;
1276 let Inst{22} = isNegCond;
1277 let Inst{18-16} = Ns;
1278 let Inst{13} = isTak;
1279 let Inst{12-8} = RegOp;
1280 let Inst{21-20} = offset{10-9};
1281 let Inst{7-1} = offset{8-2};
1285 multiclass NVJrr_cond<string mnemonic, bits<3> majOp, bit NvOpNum,
1287 // Branch not taken:
1288 def _nt: NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 0>;
1290 def _t : NVJrr_template<mnemonic, majOp, NvOpNum, isNegCond, 1>;
1293 // NvOpNum = 0 -> First Operand is a new-value Register
1294 // NvOpNum = 1 -> Second Operand is a new-value Register
1296 multiclass NVJrr_base<string mnemonic, string BaseOp, bits<3> majOp,
1298 let BaseOpcode = BaseOp#_NVJ in {
1299 defm _t_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 0>; // True cond
1300 defm _f_jumpnv : NVJrr_cond<mnemonic, majOp, NvOpNum, 1>; // False cond
1304 // if ([!]cmp.eq(Ns.new,Rt)) jump:[n]t #r9:2
1305 // if ([!]cmp.gt(Ns.new,Rt)) jump:[n]t #r9:2
1306 // if ([!]cmp.gtu(Ns.new,Rt)) jump:[n]t #r9:2
1307 // if ([!]cmp.gt(Rt,Ns.new)) jump:[n]t #r9:2
1308 // if ([!]cmp.gtu(Rt,Ns.new)) jump:[n]t #r9:2
1310 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1311 Defs = [PC], hasSideEffects = 0 in {
1312 defm J4_cmpeq : NVJrr_base<"cmp.eq", "CMPEQ", 0b000, 0>, PredRel;
1313 defm J4_cmpgt : NVJrr_base<"cmp.gt", "CMPGT", 0b001, 0>, PredRel;
1314 defm J4_cmpgtu : NVJrr_base<"cmp.gtu", "CMPGTU", 0b010, 0>, PredRel;
1315 defm J4_cmplt : NVJrr_base<"cmp.gt", "CMPLT", 0b011, 1>, PredRel;
1316 defm J4_cmpltu : NVJrr_base<"cmp.gtu", "CMPLTU", 0b100, 1>, PredRel;
1319 //===----------------------------------------------------------------------===//
1320 // multiclass/template class for the new-value compare jumps instruction
1321 // with a register and an unsigned immediate (U5) operand.
1322 //===----------------------------------------------------------------------===//
1324 let isExtendable = 1, opExtendable = 2, isExtentSigned = 1, opExtentBits = 11,
1325 opExtentAlign = 2 in
1326 class NVJri_template<string mnemonic, bits<3> majOp, bit isNegCond,
1329 (ins IntRegs:$src1, u5_0Imm:$src2, brtarget:$offset),
1330 "if ("#!if(isNegCond, "!","")#mnemonic#"($src1.new, #$src2)) jump:"
1331 #!if(isTak, "t","nt")#" $offset", []> {
1333 let isTaken = isTak;
1334 let isPredicatedFalse = isNegCond;
1335 let isTaken = isTak;
1341 let IClass = 0b0010;
1343 let Inst{25-23} = majOp;
1344 let Inst{22} = isNegCond;
1345 let Inst{18-16} = src1;
1346 let Inst{13} = isTak;
1347 let Inst{12-8} = src2;
1348 let Inst{21-20} = offset{10-9};
1349 let Inst{7-1} = offset{8-2};
1352 multiclass NVJri_cond<string mnemonic, bits<3> majOp, bit isNegCond> {
1353 // Branch not taken:
1354 def _nt: NVJri_template<mnemonic, majOp, isNegCond, 0>;
1356 def _t : NVJri_template<mnemonic, majOp, isNegCond, 1>;
1359 multiclass NVJri_base<string mnemonic, string BaseOp, bits<3> majOp> {
1360 let BaseOpcode = BaseOp#_NVJri in {
1361 defm _t_jumpnv : NVJri_cond<mnemonic, majOp, 0>; // True Cond
1362 defm _f_jumpnv : NVJri_cond<mnemonic, majOp, 1>; // False cond
1366 // if ([!]cmp.eq(Ns.new,#U5)) jump:[n]t #r9:2
1367 // if ([!]cmp.gt(Ns.new,#U5)) jump:[n]t #r9:2
1368 // if ([!]cmp.gtu(Ns.new,#U5)) jump:[n]t #r9:2
1370 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator = 1,
1371 Defs = [PC], hasSideEffects = 0 in {
1372 defm J4_cmpeqi : NVJri_base<"cmp.eq", "CMPEQ", 0b000>, PredRel;
1373 defm J4_cmpgti : NVJri_base<"cmp.gt", "CMPGT", 0b001>, PredRel;
1374 defm J4_cmpgtui : NVJri_base<"cmp.gtu", "CMPGTU", 0b010>, PredRel;
1377 //===----------------------------------------------------------------------===//
1378 // multiclass/template class for the new-value compare jumps instruction
1379 // with a register and an hardcoded 0/-1 immediate value.
1380 //===----------------------------------------------------------------------===//
1382 let isExtendable = 1, isExtentSigned = 1, opExtentBits = 11,
1383 opExtentAlign = 2 in
1384 class NVJ_ConstImm_template<string mnemonic, bits<3> majOp, string ImmVal,
1385 bit isNegCond, bit isTak>
1387 !if(!eq(ImmVal, "{-1}"),
1388 (ins IntRegs:$src1, n1Const:$n1, brtarget:$offset),
1389 (ins IntRegs:$src1, brtarget:$offset)),
1390 "if ("#!if(isNegCond, "!","")#mnemonic
1391 #"($src1.new, #" # !if(!eq(ImmVal, "{-1}"), "$n1", ImmVal) # ")) jump:"
1392 #!if(isTak, "t","nt")#" $offset", []> {
1394 let isTaken = isTak;
1395 let isPredicatedFalse = isNegCond;
1396 let isTaken = isTak;
1397 let opExtendable = !if(!eq(ImmVal, "{-1}"), 2, 1);
1401 let IClass = 0b0010;
1403 let Inst{25-23} = majOp;
1404 let Inst{22} = isNegCond;
1405 let Inst{18-16} = src1;
1406 let Inst{13} = isTak;
1407 let Inst{21-20} = offset{10-9};
1408 let Inst{7-1} = offset{8-2};
1411 multiclass NVJ_ConstImm_cond<string mnemonic, bits<3> majOp, string ImmVal,
1413 // Branch not taken:
1414 def _nt: NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 0>;
1416 def _t : NVJ_ConstImm_template<mnemonic, majOp, ImmVal, isNegCond, 1>;
1419 multiclass NVJ_ConstImm_base<string mnemonic, string BaseOp, bits<3> majOp,
1421 let BaseOpcode = BaseOp#_NVJ_ConstImm in {
1422 defm _t_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 0>; // True
1423 defm _f_jumpnv : NVJ_ConstImm_cond<mnemonic, majOp, ImmVal, 1>; // False
1427 // if ([!]tstbit(Ns.new,#0)) jump:[n]t #r9:2
1428 // if ([!]cmp.eq(Ns.new,#-1)) jump:[n]t #r9:2
1429 // if ([!]cmp.gt(Ns.new,#-1)) jump:[n]t #r9:2
1431 let isPredicated = 1, isBranch = 1, isNewValue = 1, isTerminator=1,
1432 Defs = [PC], hasSideEffects = 0 in {
1433 defm J4_tstbit0 : NVJ_ConstImm_base<"tstbit", "TSTBIT", 0b011, "0">, PredRel;
1434 defm J4_cmpeqn1 : NVJ_ConstImm_base<"cmp.eq", "CMPEQ", 0b100, "{-1}">, PredRel;
1435 defm J4_cmpgtn1 : NVJ_ConstImm_base<"cmp.gt", "CMPGT", 0b101, "{-1}">, PredRel;
1438 // J4_hintjumpr: Hint indirect conditional jump.
1439 let isBranch = 1, isIndirectBranch = 1, hasSideEffects = 0 in
1440 def J4_hintjumpr: JRInst <
1445 let IClass = 0b0101;
1446 let Inst{27-21} = 0b0010101;
1447 let Inst{20-16} = Rs;
1450 //===----------------------------------------------------------------------===//
1452 //===----------------------------------------------------------------------===//
1454 //===----------------------------------------------------------------------===//
1456 //===----------------------------------------------------------------------===//
1459 let hasNewValue = 1, isExtendable = 1, opExtendable = 1,
1460 isExtentSigned = 0, opExtentBits = 6, hasSideEffects = 0, Uses = [PC] in
1461 def C4_addipc : CRInst <(outs IntRegs:$Rd), (ins u6_0Ext:$u6),
1462 "$Rd = add(pc, #$u6)", [], "", CR_tc_2_SLOT3 > {
1466 let IClass = 0b0110;
1467 let Inst{27-16} = 0b101001001001;
1468 let Inst{12-7} = u6;
1474 let hasSideEffects = 0 in
1475 class T_LOGICAL_3OP<string MnOp1, string MnOp2, bits<2> OpBits, bit IsNeg>
1476 : CRInst<(outs PredRegs:$Pd),
1477 (ins PredRegs:$Ps, PredRegs:$Pt, PredRegs:$Pu),
1478 "$Pd = " # MnOp1 # "($Ps, " # MnOp2 # "($Pt, " #
1479 !if (IsNeg,"!","") # "$Pu))",
1480 [], "", CR_tc_2early_SLOT23> {
1486 let IClass = 0b0110;
1487 let Inst{27-24} = 0b1011;
1488 let Inst{23} = IsNeg;
1489 let Inst{22-21} = OpBits;
1491 let Inst{17-16} = Ps;
1498 def C4_and_and : T_LOGICAL_3OP<"and", "and", 0b00, 0>;
1499 def C4_and_or : T_LOGICAL_3OP<"and", "or", 0b01, 0>;
1500 def C4_or_and : T_LOGICAL_3OP<"or", "and", 0b10, 0>;
1501 def C4_or_or : T_LOGICAL_3OP<"or", "or", 0b11, 0>;
1502 def C4_and_andn : T_LOGICAL_3OP<"and", "and", 0b00, 1>;
1503 def C4_and_orn : T_LOGICAL_3OP<"and", "or", 0b01, 1>;
1504 def C4_or_andn : T_LOGICAL_3OP<"or", "and", 0b10, 1>;
1505 def C4_or_orn : T_LOGICAL_3OP<"or", "or", 0b11, 1>;
1507 //===----------------------------------------------------------------------===//
1509 //===----------------------------------------------------------------------===//
1511 //===----------------------------------------------------------------------===//
1513 //===----------------------------------------------------------------------===//
1515 // Logical with-not instructions.
1516 def A4_andnp : T_ALU64_logical<"and", 0b001, 1, 0, 1>;
1517 def A4_ornp : T_ALU64_logical<"or", 0b011, 1, 0, 1>;
1519 let hasNewValue = 1, hasSideEffects = 0 in
1520 def S4_parity: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1521 "$Rd = parity($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1526 let IClass = 0b1101;
1527 let Inst{27-21} = 0b0101111;
1528 let Inst{20-16} = Rs;
1529 let Inst{12-8} = Rt;
1533 // Add and accumulate.
1534 // Rd=add(Rs,add(Ru,#s6))
1535 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 6,
1537 def S4_addaddi : ALU64Inst <(outs IntRegs:$Rd),
1538 (ins IntRegs:$Rs, IntRegs:$Ru, s6_0Ext:$s6),
1539 "$Rd = add($Rs, add($Ru, #$s6))" , [],
1540 "", ALU64_tc_2_SLOT23> {
1546 let IClass = 0b1101;
1548 let Inst{27-23} = 0b10110;
1549 let Inst{22-21} = s6{5-4};
1550 let Inst{20-16} = Rs;
1551 let Inst{13} = s6{3};
1552 let Inst{12-8} = Rd;
1553 let Inst{7-5} = s6{2-0};
1557 let isExtentSigned = 1, hasSideEffects = 0, hasNewValue = 1, isExtendable = 1,
1558 opExtentBits = 6, opExtendable = 2 in
1559 def S4_subaddi: ALU64Inst <(outs IntRegs:$Rd),
1560 (ins IntRegs:$Rs, s6_0Ext:$s6, IntRegs:$Ru),
1561 "$Rd = add($Rs, sub(#$s6, $Ru))",
1562 [], "", ALU64_tc_2_SLOT23> {
1568 let IClass = 0b1101;
1570 let Inst{27-23} = 0b10111;
1571 let Inst{22-21} = s6{5-4};
1572 let Inst{20-16} = Rs;
1573 let Inst{13} = s6{3};
1574 let Inst{12-8} = Rd;
1575 let Inst{7-5} = s6{2-0};
1579 def S4_extractp_rp : T_S3op_64 < "extract", 0b11, 0b100, 0>;
1580 def S4_extractp : T_S2op_extract <"extract", 0b1010, DoubleRegs, u6_0Imm>;
1582 let hasNewValue = 1 in {
1583 def S4_extract_rp : T_S3op_extract<"extract", 0b01>;
1584 def S4_extract : T_S2op_extract <"extract", 0b1101, IntRegs, u5_0Imm>;
1587 // Complex add/sub halfwords/words
1588 let Defs = [USR_OVF] in {
1589 def S4_vxaddsubh : T_S3op_64 < "vxaddsubh", 0b01, 0b100, 0, 1>;
1590 def S4_vxaddsubw : T_S3op_64 < "vxaddsubw", 0b01, 0b000, 0, 1>;
1591 def S4_vxsubaddh : T_S3op_64 < "vxsubaddh", 0b01, 0b110, 0, 1>;
1592 def S4_vxsubaddw : T_S3op_64 < "vxsubaddw", 0b01, 0b010, 0, 1>;
1595 let Defs = [USR_OVF] in {
1596 def S4_vxaddsubhr : T_S3op_64 < "vxaddsubh", 0b11, 0b000, 0, 1, 1, 1>;
1597 def S4_vxsubaddhr : T_S3op_64 < "vxsubaddh", 0b11, 0b010, 0, 1, 1, 1>;
1600 let Itinerary = M_tc_3x_SLOT23, Defs = [USR_OVF] in {
1601 def M4_mac_up_s1_sat: T_MType_acc_rr<"+= mpy", 0b011, 0b000, 0, [], 0, 1, 1>;
1602 def M4_nac_up_s1_sat: T_MType_acc_rr<"-= mpy", 0b011, 0b001, 0, [], 0, 1, 1>;
1605 // Logical xor with xor accumulation.
1606 // Rxx^=xor(Rss,Rtt)
1607 let hasSideEffects = 0 in
1609 : SInst <(outs DoubleRegs:$Rxx),
1610 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, DoubleRegs:$Rtt),
1611 "$Rxx ^= xor($Rss, $Rtt)", [],
1612 "$dst2 = $Rxx", S_3op_tc_1_SLOT23> {
1617 let IClass = 0b1100;
1619 let Inst{27-22} = 0b101010;
1620 let Inst{20-16} = Rss;
1621 let Inst{12-8} = Rtt;
1622 let Inst{7-5} = 0b000;
1623 let Inst{4-0} = Rxx;
1626 // Rotate and reduce bytes
1627 // Rdd=vrcrotate(Rss,Rt,#u2)
1628 let hasSideEffects = 0 in
1630 : SInst <(outs DoubleRegs:$Rdd),
1631 (ins DoubleRegs:$Rss, IntRegs:$Rt, u2_0Imm:$u2),
1632 "$Rdd = vrcrotate($Rss, $Rt, #$u2)",
1633 [], "", S_3op_tc_3x_SLOT23> {
1639 let IClass = 0b1100;
1641 let Inst{27-22} = 0b001111;
1642 let Inst{20-16} = Rss;
1643 let Inst{13} = u2{1};
1644 let Inst{12-8} = Rt;
1645 let Inst{7-6} = 0b11;
1646 let Inst{5} = u2{0};
1647 let Inst{4-0} = Rdd;
1650 // Rotate and reduce bytes with accumulation
1651 // Rxx+=vrcrotate(Rss,Rt,#u2)
1652 let hasSideEffects = 0 in
1653 def S4_vrcrotate_acc
1654 : SInst <(outs DoubleRegs:$Rxx),
1655 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt, u2_0Imm:$u2),
1656 "$Rxx += vrcrotate($Rss, $Rt, #$u2)", [],
1657 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
1663 let IClass = 0b1100;
1665 let Inst{27-21} = 0b1011101;
1666 let Inst{20-16} = Rss;
1667 let Inst{13} = u2{1};
1668 let Inst{12-8} = Rt;
1669 let Inst{5} = u2{0};
1670 let Inst{4-0} = Rxx;
1673 // Vector reduce conditional negate halfwords
1674 let hasSideEffects = 0 in
1676 : SInst <(outs DoubleRegs:$Rxx),
1677 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Rt),
1678 "$Rxx += vrcnegh($Rss, $Rt)", [],
1679 "$dst2 = $Rxx", S_3op_tc_3x_SLOT23> {
1684 let IClass = 0b1100;
1686 let Inst{27-21} = 0b1011001;
1687 let Inst{20-16} = Rss;
1689 let Inst{12-8} = Rt;
1690 let Inst{7-5} = 0b111;
1691 let Inst{4-0} = Rxx;
1695 def A4_bitspliti : T_S2op_2_di <"bitsplit", 0b110, 0b100>;
1697 // Arithmetic/Convergent round
1698 def A4_cround_ri : T_S2op_2_ii <"cround", 0b111, 0b000>;
1700 def A4_round_ri : T_S2op_2_ii <"round", 0b111, 0b100>;
1702 let Defs = [USR_OVF] in
1703 def A4_round_ri_sat : T_S2op_2_ii <"round", 0b111, 0b110, 1>;
1705 // Logical-logical words.
1706 // Compound or-and -- Rx=or(Ru,and(Rx,#s10))
1707 let isExtentSigned = 1, hasNewValue = 1, isExtendable = 1, opExtentBits = 10,
1710 ALU64Inst<(outs IntRegs:$Rx),
1711 (ins IntRegs:$Ru, IntRegs:$_src_, s10_0Ext:$s10),
1712 "$Rx = or($Ru, and($_src_, #$s10))" , [] ,
1713 "$_src_ = $Rx", ALU64_tc_2_SLOT23> {
1718 let IClass = 0b1101;
1720 let Inst{27-22} = 0b101001;
1721 let Inst{20-16} = Rx;
1722 let Inst{21} = s10{9};
1723 let Inst{13-5} = s10{8-0};
1727 // Miscellaneous ALU64 instructions.
1729 let hasNewValue = 1, hasSideEffects = 0 in
1730 def A4_modwrapu: ALU64Inst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, IntRegs:$Rt),
1731 "$Rd = modwrap($Rs, $Rt)", [], "", ALU64_tc_2_SLOT23> {
1736 let IClass = 0b1101;
1737 let Inst{27-21} = 0b0011111;
1738 let Inst{20-16} = Rs;
1739 let Inst{12-8} = Rt;
1740 let Inst{7-5} = 0b111;
1744 let hasSideEffects = 0 in
1745 def A4_bitsplit: ALU64Inst<(outs DoubleRegs:$Rd),
1746 (ins IntRegs:$Rs, IntRegs:$Rt),
1747 "$Rd = bitsplit($Rs, $Rt)", [], "", ALU64_tc_1_SLOT23> {
1752 let IClass = 0b1101;
1753 let Inst{27-24} = 0b0100;
1755 let Inst{20-16} = Rs;
1756 let Inst{12-8} = Rt;
1760 let hasSideEffects = 0 in
1761 def dep_S2_packhl: ALU64Inst<(outs DoubleRegs:$Rd),
1762 (ins IntRegs:$Rs, IntRegs:$Rt),
1763 "$Rd = packhl($Rs, $Rt):deprecated", [], "", ALU64_tc_1_SLOT23> {
1768 let IClass = 0b1101;
1769 let Inst{27-24} = 0b0100;
1771 let Inst{20-16} = Rs;
1772 let Inst{12-8} = Rt;
1776 let hasNewValue = 1, hasSideEffects = 0 in
1777 def dep_A2_addsat: ALU64Inst<(outs IntRegs:$Rd),
1778 (ins IntRegs:$Rs, IntRegs:$Rt),
1779 "$Rd = add($Rs, $Rt):sat:deprecated", [], "", ALU64_tc_2_SLOT23> {
1784 let IClass = 0b1101;
1785 let Inst{27-21} = 0b0101100;
1786 let Inst{20-16} = Rs;
1787 let Inst{12-8} = Rt;
1792 let hasNewValue = 1, hasSideEffects = 0 in
1793 def dep_A2_subsat: ALU64Inst<(outs IntRegs:$Rd),
1794 (ins IntRegs:$Rs, IntRegs:$Rt),
1795 "$Rd = sub($Rs, $Rt):sat:deprecated", [], "", ALU64_tc_2_SLOT23> {
1800 let IClass = 0b1101;
1801 let Inst{27-21} = 0b0101100;
1802 let Inst{20-16} = Rt;
1803 let Inst{12-8} = Rs;
1808 // Rx[&|]=xor(Rs,Rt)
1809 def M4_or_xor : T_MType_acc_rr < "|= xor", 0b110, 0b001, 0>;
1810 def M4_and_xor : T_MType_acc_rr < "&= xor", 0b010, 0b010, 0>;
1812 // Rx[&|^]=or(Rs,Rt)
1813 def M4_xor_or : T_MType_acc_rr < "^= or", 0b110, 0b011, 0>;
1815 let CextOpcode = "ORr_ORr" in
1816 def M4_or_or : T_MType_acc_rr < "|= or", 0b110, 0b000, 0>;
1817 def M4_and_or : T_MType_acc_rr < "&= or", 0b010, 0b001, 0>;
1819 // Rx[&|^]=and(Rs,Rt)
1820 def M4_xor_and : T_MType_acc_rr < "^= and", 0b110, 0b010, 0>;
1822 let CextOpcode = "ORr_ANDr" in
1823 def M4_or_and : T_MType_acc_rr < "|= and", 0b010, 0b011, 0>;
1824 def M4_and_and : T_MType_acc_rr < "&= and", 0b010, 0b000, 0>;
1826 // Rx[&|^]=and(Rs,~Rt)
1827 def M4_xor_andn : T_MType_acc_rr < "^= and", 0b001, 0b010, 0, [], 1>;
1828 def M4_or_andn : T_MType_acc_rr < "|= and", 0b001, 0b000, 0, [], 1>;
1829 def M4_and_andn : T_MType_acc_rr < "&= and", 0b001, 0b001, 0, [], 1>;
1831 // Compound or-or and or-and
1832 let isExtentSigned = 1, InputType = "imm", hasNewValue = 1, isExtendable = 1,
1833 opExtentBits = 10, opExtendable = 3 in
1834 class T_CompOR <string mnemonic, bits<2> MajOp, SDNode OpNode>
1835 : MInst_acc <(outs IntRegs:$Rx),
1836 (ins IntRegs:$src1, IntRegs:$Rs, s10_0Ext:$s10),
1837 "$Rx |= "#mnemonic#"($Rs, #$s10)", [],
1838 "$src1 = $Rx", ALU64_tc_2_SLOT23>, ImmRegRel {
1843 let IClass = 0b1101;
1845 let Inst{27-24} = 0b1010;
1846 let Inst{23-22} = MajOp;
1847 let Inst{20-16} = Rs;
1848 let Inst{21} = s10{9};
1849 let Inst{13-5} = s10{8-0};
1853 let CextOpcode = "ORr_ANDr" in
1854 def S4_or_andi : T_CompOR <"and", 0b00, and>;
1856 let CextOpcode = "ORr_ORr" in
1857 def S4_or_ori : T_CompOR <"or", 0b10, or>;
1860 // Rd=modwrap(Rs,Rt)
1862 // Rd=cround(Rs,#u5)
1864 // Rd=round(Rs,#u5)[:sat]
1865 // Rd=round(Rs,Rt)[:sat]
1866 // Vector reduce add unsigned halfwords
1867 // Rd=vraddh(Rss,Rtt)
1869 // Rdd=vaddb(Rss,Rtt)
1870 // Vector conditional negate
1871 // Rdd=vcnegh(Rss,Rt)
1872 // Rxx+=vrcnegh(Rss,Rt)
1873 // Vector maximum bytes
1874 // Rdd=vmaxb(Rtt,Rss)
1875 // Vector reduce maximum halfwords
1876 // Rxx=vrmaxh(Rss,Ru)
1877 // Rxx=vrmaxuh(Rss,Ru)
1878 // Vector reduce maximum words
1879 // Rxx=vrmaxuw(Rss,Ru)
1880 // Rxx=vrmaxw(Rss,Ru)
1881 // Vector minimum bytes
1882 // Rdd=vminb(Rtt,Rss)
1883 // Vector reduce minimum halfwords
1884 // Rxx=vrminh(Rss,Ru)
1885 // Rxx=vrminuh(Rss,Ru)
1886 // Vector reduce minimum words
1887 // Rxx=vrminuw(Rss,Ru)
1888 // Rxx=vrminw(Rss,Ru)
1889 // Vector subtract bytes
1890 // Rdd=vsubb(Rss,Rtt)
1892 //===----------------------------------------------------------------------===//
1894 //===----------------------------------------------------------------------===//
1896 //===----------------------------------------------------------------------===//
1898 //===----------------------------------------------------------------------===//
1901 def S2_brevp : T_S2op_3 <"brev", 0b11, 0b110>;
1904 def S2_ct0p : T_COUNT_LEADING_64<"ct0", 0b111, 0b010>;
1905 def S2_ct1p : T_COUNT_LEADING_64<"ct1", 0b111, 0b100>;
1906 def S4_clbpnorm : T_COUNT_LEADING_64<"normamt", 0b011, 0b000>;
1908 let hasSideEffects = 0, hasNewValue = 1 in
1909 def S4_clbaddi : SInst<(outs IntRegs:$Rd), (ins IntRegs:$Rs, s6_0Imm:$s6),
1910 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
1914 let IClass = 0b1000;
1915 let Inst{27-24} = 0b1100;
1916 let Inst{23-21} = 0b001;
1917 let Inst{20-16} = Rs;
1918 let Inst{13-8} = s6;
1919 let Inst{7-5} = 0b000;
1923 let hasSideEffects = 0, hasNewValue = 1 in
1924 def S4_clbpaddi : SInst<(outs IntRegs:$Rd), (ins DoubleRegs:$Rs, s6_0Imm:$s6),
1925 "$Rd = add(clb($Rs), #$s6)", [], "", S_2op_tc_2_SLOT23> {
1929 let IClass = 0b1000;
1930 let Inst{27-24} = 0b1000;
1931 let Inst{23-21} = 0b011;
1932 let Inst{20-16} = Rs;
1933 let Inst{13-8} = s6;
1934 let Inst{7-5} = 0b010;
1939 // Bit test/set/clear
1940 def S4_ntstbit_i : T_TEST_BIT_IMM<"!tstbit", 0b001>;
1941 def S4_ntstbit_r : T_TEST_BIT_REG<"!tstbit", 1>;
1943 def C4_nbitsset : T_TEST_BITS_REG<"!bitsset", 0b01, 1>;
1944 def C4_nbitsclr : T_TEST_BITS_REG<"!bitsclr", 0b10, 1>;
1945 def C4_nbitsclri : T_TEST_BITS_IMM<"!bitsclr", 0b10, 1>;
1947 //===----------------------------------------------------------------------===//
1949 //===----------------------------------------------------------------------===//
1951 //===----------------------------------------------------------------------===//
1953 //===----------------------------------------------------------------------===//
1955 // Rd=add(#u6,mpyi(Rs,#U6)) -- Multiply by immed and add immed.
1957 let hasNewValue = 1, isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
1958 def M4_mpyri_addi : MInst<(outs IntRegs:$Rd),
1959 (ins u6_0Ext:$u6, IntRegs:$Rs, u6_0Imm:$U6),
1960 "$Rd = add(#$u6, mpyi($Rs, #$U6))" , [],"",ALU64_tc_3x_SLOT23> {
1966 let IClass = 0b1101;
1968 let Inst{27-24} = 0b1000;
1969 let Inst{23} = U6{5};
1970 let Inst{22-21} = u6{5-4};
1971 let Inst{20-16} = Rs;
1972 let Inst{13} = u6{3};
1973 let Inst{12-8} = Rd;
1974 let Inst{7-5} = u6{2-0};
1975 let Inst{4-0} = U6{4-0};
1978 // Rd=add(#u6,mpyi(Rs,Rt))
1979 let CextOpcode = "ADD_MPY", InputType = "imm", hasNewValue = 1,
1980 isExtendable = 1, opExtentBits = 6, opExtendable = 1 in
1981 def M4_mpyrr_addi : MInst <(outs IntRegs:$Rd),
1982 (ins u6_0Ext:$u6, IntRegs:$Rs, IntRegs:$Rt),
1983 "$Rd = add(#$u6, mpyi($Rs, $Rt))" , [], "", ALU64_tc_3x_SLOT23>, ImmRegRel {
1989 let IClass = 0b1101;
1991 let Inst{27-23} = 0b01110;
1992 let Inst{22-21} = u6{5-4};
1993 let Inst{20-16} = Rs;
1994 let Inst{13} = u6{3};
1995 let Inst{12-8} = Rt;
1996 let Inst{7-5} = u6{2-0};
2000 let hasNewValue = 1 in
2001 class T_AddMpy <bit MajOp, PatLeaf ImmPred, dag ins>
2002 : ALU64Inst <(outs IntRegs:$dst), ins,
2003 "$dst = add($src1, mpyi("#!if(MajOp,"$src3, #$src2))",
2004 "#$src2, $src3))"), [],
2005 "", ALU64_tc_3x_SLOT23> {
2011 let IClass = 0b1101;
2013 bits<6> ImmValue = !if(MajOp, src2{5-0}, src2{7-2});
2015 let Inst{27-24} = 0b1111;
2016 let Inst{23} = MajOp;
2017 let Inst{22-21} = ImmValue{5-4};
2018 let Inst{20-16} = src3;
2019 let Inst{13} = ImmValue{3};
2020 let Inst{12-8} = dst;
2021 let Inst{7-5} = ImmValue{2-0};
2022 let Inst{4-0} = src1;
2025 def M4_mpyri_addr_u2 : T_AddMpy<0b0, u6_2ImmPred,
2026 (ins IntRegs:$src1, u6_2Imm:$src2, IntRegs:$src3)>;
2028 let isExtendable = 1, opExtentBits = 6, opExtendable = 3,
2029 CextOpcode = "ADD_MPY", InputType = "imm" in
2030 def M4_mpyri_addr : T_AddMpy<0b1, u32_0ImmPred,
2031 (ins IntRegs:$src1, IntRegs:$src3, u6_0Ext:$src2)>, ImmRegRel;
2033 // Rx=add(Ru,mpyi(Rx,Rs))
2034 let CextOpcode = "ADD_MPY", InputType = "reg", hasNewValue = 1 in
2035 def M4_mpyrr_addr: MInst_acc <(outs IntRegs:$Rx),
2036 (ins IntRegs:$Ru, IntRegs:$_src_, IntRegs:$Rs),
2037 "$Rx = add($Ru, mpyi($_src_, $Rs))", [],
2038 "$_src_ = $Rx", M_tc_3x_SLOT23>, ImmRegRel {
2043 let IClass = 0b1110;
2045 let Inst{27-21} = 0b0011000;
2046 let Inst{12-8} = Rx;
2048 let Inst{20-16} = Rs;
2052 // Vector reduce multiply word by signed half (32x16)
2053 //Rdd=vrmpyweh(Rss,Rtt)[:<<1]
2054 def M4_vrmpyeh_s0 : T_M2_vmpy<"vrmpyweh", 0b010, 0b100, 0, 0, 0>;
2055 def M4_vrmpyeh_s1 : T_M2_vmpy<"vrmpyweh", 0b110, 0b100, 1, 0, 0>;
2057 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2058 def M4_vrmpyoh_s0 : T_M2_vmpy<"vrmpywoh", 0b001, 0b010, 0, 0, 0>;
2059 def M4_vrmpyoh_s1 : T_M2_vmpy<"vrmpywoh", 0b101, 0b010, 1, 0, 0>;
2061 //Rdd+=vrmpyweh(Rss,Rtt)[:<<1]
2062 def M4_vrmpyeh_acc_s0: T_M2_vmpy_acc<"vrmpyweh", 0b001, 0b110, 0, 0>;
2063 def M4_vrmpyeh_acc_s1: T_M2_vmpy_acc<"vrmpyweh", 0b101, 0b110, 1, 0>;
2065 //Rdd=vrmpywoh(Rss,Rtt)[:<<1]
2066 def M4_vrmpyoh_acc_s0: T_M2_vmpy_acc<"vrmpywoh", 0b011, 0b110, 0, 0>;
2067 def M4_vrmpyoh_acc_s1: T_M2_vmpy_acc<"vrmpywoh", 0b111, 0b110, 1, 0>;
2069 // Vector multiply halfwords, signed by unsigned
2070 // Rdd=vmpyhsu(Rs,Rt)[:<<]:sat
2071 def M2_vmpy2su_s0 : T_XTYPE_mpy64 < "vmpyhsu", 0b000, 0b111, 1, 0, 0>;
2072 def M2_vmpy2su_s1 : T_XTYPE_mpy64 < "vmpyhsu", 0b100, 0b111, 1, 1, 0>;
2074 // Rxx+=vmpyhsu(Rs,Rt)[:<<1]:sat
2075 def M2_vmac2su_s0 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b011, 0b101, 1, 0, 0>;
2076 def M2_vmac2su_s1 : T_XTYPE_mpy64_acc < "vmpyhsu", "+", 0b111, 0b101, 1, 1, 0>;
2078 // Vector polynomial multiply halfwords
2079 // Rdd=vpmpyh(Rs,Rt)
2080 def M4_vpmpyh : T_XTYPE_mpy64 < "vpmpyh", 0b110, 0b111, 0, 0, 0>;
2082 // Rxx^=vpmpyh(Rs,Rt)
2083 def M4_vpmpyh_acc : T_XTYPE_mpy64_acc < "vpmpyh", "^", 0b101, 0b111, 0, 0, 0>;
2085 // Polynomial multiply words
2087 def M4_pmpyw : T_XTYPE_mpy64 < "pmpyw", 0b010, 0b111, 0, 0, 0>;
2089 // Rxx^=pmpyw(Rs,Rt)
2090 def M4_pmpyw_acc : T_XTYPE_mpy64_acc < "pmpyw", "^", 0b001, 0b111, 0, 0, 0>;
2092 //===----------------------------------------------------------------------===//
2094 //===----------------------------------------------------------------------===//
2096 //===----------------------------------------------------------------------===//
2097 // ALU64/Vector compare
2098 //===----------------------------------------------------------------------===//
2099 //===----------------------------------------------------------------------===//
2100 // Template class for vector compare
2101 //===----------------------------------------------------------------------===//
2103 let hasSideEffects = 0 in
2104 class T_vcmpImm <string Str, bits<2> cmpOp, bits<2> minOp, Operand ImmOprnd>
2105 : ALU64_rr <(outs PredRegs:$Pd),
2106 (ins DoubleRegs:$Rss, ImmOprnd:$Imm),
2107 "$Pd = "#Str#"($Rss, #$Imm)",
2108 [], "", ALU64_tc_2early_SLOT23> {
2113 let ImmBits{6-0} = Imm{6-0};
2114 let ImmBits{7} = !if (!eq(cmpOp,0b10), 0b0, Imm{7}); // 0 for vcmp[bhw].gtu
2116 let IClass = 0b1101;
2118 let Inst{27-24} = 0b1100;
2119 let Inst{22-21} = cmpOp;
2120 let Inst{20-16} = Rss;
2121 let Inst{12-5} = ImmBits;
2122 let Inst{4-3} = minOp;
2126 // Vector compare bytes
2127 def A4_vcmpbgt : T_vcmp <"vcmpb.gt", 0b1010>;
2129 let AsmString = "$Pd = any8(vcmpb.eq($Rss, $Rtt))" in
2130 def A4_vcmpbeq_any : T_vcmp <"any8(vcmpb.gt", 0b1000>;
2132 def A4_vcmpbeqi : T_vcmpImm <"vcmpb.eq", 0b00, 0b00, u8_0Imm>;
2133 def A4_vcmpbgti : T_vcmpImm <"vcmpb.gt", 0b01, 0b00, s8_0Imm>;
2134 def A4_vcmpbgtui : T_vcmpImm <"vcmpb.gtu", 0b10, 0b00, u7_0Imm>;
2136 // Vector compare halfwords
2137 def A4_vcmpheqi : T_vcmpImm <"vcmph.eq", 0b00, 0b01, s8_0Imm>;
2138 def A4_vcmphgti : T_vcmpImm <"vcmph.gt", 0b01, 0b01, s8_0Imm>;
2139 def A4_vcmphgtui : T_vcmpImm <"vcmph.gtu", 0b10, 0b01, u7_0Imm>;
2141 // Vector compare words
2142 def A4_vcmpweqi : T_vcmpImm <"vcmpw.eq", 0b00, 0b10, s8_0Imm>;
2143 def A4_vcmpwgti : T_vcmpImm <"vcmpw.gt", 0b01, 0b10, s8_0Imm>;
2144 def A4_vcmpwgtui : T_vcmpImm <"vcmpw.gtu", 0b10, 0b10, u7_0Imm>;
2146 //===----------------------------------------------------------------------===//
2148 //===----------------------------------------------------------------------===//
2149 // Shift by immediate and accumulate/logical.
2150 // Rx=add(#u8,asl(Rx,#U5)) Rx=add(#u8,lsr(Rx,#U5))
2151 // Rx=sub(#u8,asl(Rx,#U5)) Rx=sub(#u8,lsr(Rx,#U5))
2152 // Rx=and(#u8,asl(Rx,#U5)) Rx=and(#u8,lsr(Rx,#U5))
2153 // Rx=or(#u8,asl(Rx,#U5)) Rx=or(#u8,lsr(Rx,#U5))
2154 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0, opExtentBits = 8,
2155 hasNewValue = 1, opNewValue = 0 in
2156 class T_S4_ShiftOperate<string MnOp, string MnSh, bit asl_lsr,
2157 bits<2> MajOp, InstrItinClass Itin>
2158 : MInst_acc<(outs IntRegs:$Rd), (ins u8_0Ext:$u8, IntRegs:$Rx, u5_0Imm:$U5),
2159 "$Rd = "#MnOp#"(#$u8, "#MnSh#"($Rx, #$U5))",
2160 [], "$Rd = $Rx", Itin> {
2167 let IClass = 0b1101;
2168 let Inst{27-24} = 0b1110;
2169 let Inst{23-21} = u8{7-5};
2170 let Inst{20-16} = Rd;
2171 let Inst{13} = u8{4};
2172 let Inst{12-8} = U5;
2173 let Inst{7-5} = u8{3-1};
2174 let Inst{4} = asl_lsr;
2175 let Inst{3} = u8{0};
2176 let Inst{2-1} = MajOp;
2179 multiclass T_ShiftOperate<string mnemonic, bits<2> MajOp, InstrItinClass Itin> {
2180 def _asl_ri : T_S4_ShiftOperate<mnemonic, "asl", 0, MajOp, Itin>;
2181 def _lsr_ri : T_S4_ShiftOperate<mnemonic, "lsr", 1, MajOp, Itin>;
2184 defm S4_addi : T_ShiftOperate<"add", 0b10, ALU64_tc_2_SLOT23>;
2185 defm S4_andi : T_ShiftOperate<"and", 0b00, ALU64_tc_2_SLOT23>;
2186 defm S4_ori : T_ShiftOperate<"or", 0b01, ALU64_tc_1_SLOT23>;
2187 defm S4_subi : T_ShiftOperate<"sub", 0b11, ALU64_tc_1_SLOT23>;
2189 // Vector conditional negate
2190 // Rdd=vcnegh(Rss,Rt)
2191 let Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2192 def S2_vcnegh : T_S3op_shiftVect < "vcnegh", 0b11, 0b01>;
2194 // Rd=[cround|round](Rs,Rt)
2195 let hasNewValue = 1, Itinerary = S_3op_tc_2_SLOT23 in {
2196 def A4_cround_rr : T_S3op_3 < "cround", IntRegs, 0b11, 0b00>;
2197 def A4_round_rr : T_S3op_3 < "round", IntRegs, 0b11, 0b10>;
2200 // Rd=round(Rs,Rt):sat
2201 let hasNewValue = 1, Defs = [USR_OVF], Itinerary = S_3op_tc_2_SLOT23 in
2202 def A4_round_rr_sat : T_S3op_3 < "round", IntRegs, 0b11, 0b11, 1>;
2204 // Rd=[cmpyiwh|cmpyrwh](Rss,Rt):<<1:rnd:sat
2205 let Defs = [USR_OVF], Itinerary = S_3op_tc_3x_SLOT23 in {
2206 def M4_cmpyi_wh : T_S3op_8<"cmpyiwh", 0b100, 1, 1, 1>;
2207 def M4_cmpyr_wh : T_S3op_8<"cmpyrwh", 0b110, 1, 1, 1>;
2210 // Rdd=[add|sub](Rss,Rtt,Px):carry
2211 let isPredicateLate = 1, hasSideEffects = 0 in
2212 class T_S3op_carry <string mnemonic, bits<3> MajOp>
2213 : SInst < (outs DoubleRegs:$Rdd, PredRegs:$Px),
2214 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt, PredRegs:$Pu),
2215 "$Rdd = "#mnemonic#"($Rss, $Rtt, $Pu):carry",
2216 [], "$Px = $Pu", S_3op_tc_1_SLOT23 > {
2222 let IClass = 0b1100;
2224 let Inst{27-24} = 0b0010;
2225 let Inst{23-21} = MajOp;
2226 let Inst{20-16} = Rss;
2227 let Inst{12-8} = Rtt;
2229 let Inst{4-0} = Rdd;
2232 def A4_addp_c : T_S3op_carry < "add", 0b110 >;
2233 def A4_subp_c : T_S3op_carry < "sub", 0b111 >;
2235 let Itinerary = S_3op_tc_3_SLOT23, hasSideEffects = 0 in
2236 class T_S3op_6 <string mnemonic, bits<3> MinOp, bit isUnsigned>
2237 : SInst <(outs DoubleRegs:$Rxx),
2238 (ins DoubleRegs:$dst2, DoubleRegs:$Rss, IntRegs:$Ru),
2239 "$Rxx = "#mnemonic#"($Rss, $Ru)" ,
2240 [] , "$dst2 = $Rxx"> {
2245 let IClass = 0b1100;
2247 let Inst{27-21} = 0b1011001;
2248 let Inst{20-16} = Rss;
2249 let Inst{13} = isUnsigned;
2250 let Inst{12-8} = Rxx;
2251 let Inst{7-5} = MinOp;
2255 // Vector reduce maximum halfwords
2256 // Rxx=vrmax[u]h(Rss,Ru)
2257 def A4_vrmaxh : T_S3op_6 < "vrmaxh", 0b001, 0>;
2258 def A4_vrmaxuh : T_S3op_6 < "vrmaxuh", 0b001, 1>;
2260 // Vector reduce maximum words
2261 // Rxx=vrmax[u]w(Rss,Ru)
2262 def A4_vrmaxw : T_S3op_6 < "vrmaxw", 0b010, 0>;
2263 def A4_vrmaxuw : T_S3op_6 < "vrmaxuw", 0b010, 1>;
2265 // Vector reduce minimum halfwords
2266 // Rxx=vrmin[u]h(Rss,Ru)
2267 def A4_vrminh : T_S3op_6 < "vrminh", 0b101, 0>;
2268 def A4_vrminuh : T_S3op_6 < "vrminuh", 0b101, 1>;
2270 // Vector reduce minimum words
2271 // Rxx=vrmin[u]w(Rss,Ru)
2272 def A4_vrminw : T_S3op_6 < "vrminw", 0b110, 0>;
2273 def A4_vrminuw : T_S3op_6 < "vrminuw", 0b110, 1>;
2275 // Shift an immediate left by register amount.
2276 let hasNewValue = 1, hasSideEffects = 0 in
2277 def S4_lsli: SInst <(outs IntRegs:$Rd), (ins s6_0Imm:$s6, IntRegs:$Rt),
2278 "$Rd = lsl(#$s6, $Rt)" , [], "", S_3op_tc_1_SLOT23> {
2283 let IClass = 0b1100;
2285 let Inst{27-22} = 0b011010;
2286 let Inst{20-16} = s6{5-1};
2287 let Inst{12-8} = Rt;
2288 let Inst{7-6} = 0b11;
2290 let Inst{5} = s6{0};
2293 //===----------------------------------------------------------------------===//
2295 //===----------------------------------------------------------------------===//
2297 //===----------------------------------------------------------------------===//
2299 //===----------------------------------------------------------------------===//
2302 //===----------------------------------------------------------------------===//
2303 // Template class for MemOp instructions with the register value.
2304 //===----------------------------------------------------------------------===//
2305 class MemOp_rr_base <string opc, bits<2> opcBits, Operand ImmOp,
2306 string memOp, bits<2> memOpBits> :
2308 (ins IntRegs:$base, ImmOp:$offset, IntRegs:$delta),
2309 opc#"($base+#$offset)"#memOp#"$delta",
2311 Requires<[UseMEMOP]> {
2316 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2318 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2319 !if (!eq(opcBits, 0b01), offset{6-1},
2320 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2322 let opExtentAlign = opcBits;
2323 let IClass = 0b0011;
2324 let Inst{27-24} = 0b1110;
2325 let Inst{22-21} = opcBits;
2326 let Inst{20-16} = base;
2328 let Inst{12-7} = offsetBits;
2329 let Inst{6-5} = memOpBits;
2330 let Inst{4-0} = delta;
2333 //===----------------------------------------------------------------------===//
2334 // Template class for MemOp instructions with the immediate value.
2335 //===----------------------------------------------------------------------===//
2336 class MemOp_ri_base <string opc, bits<2> opcBits, Operand ImmOp,
2337 string memOp, bits<2> memOpBits> :
2339 (ins IntRegs:$base, ImmOp:$offset, u5_0Imm:$delta),
2340 opc#"($base+#$offset)"#memOp#"#$delta"
2341 #!if(memOpBits{1},")", ""), // clrbit, setbit - include ')'
2343 Requires<[UseMEMOP]> {
2348 bits<6> offsetBits; // memb - u6:0 , memh - u6:1, memw - u6:2
2350 let offsetBits = !if (!eq(opcBits, 0b00), offset{5-0},
2351 !if (!eq(opcBits, 0b01), offset{6-1},
2352 !if (!eq(opcBits, 0b10), offset{7-2},0)));
2354 let opExtentAlign = opcBits;
2355 let IClass = 0b0011;
2356 let Inst{27-24} = 0b1111;
2357 let Inst{22-21} = opcBits;
2358 let Inst{20-16} = base;
2360 let Inst{12-7} = offsetBits;
2361 let Inst{6-5} = memOpBits;
2362 let Inst{4-0} = delta;
2365 // multiclass to define MemOp instructions with register operand.
2366 multiclass MemOp_rr<string opc, bits<2> opcBits, Operand ImmOp> {
2367 def L4_add#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " += ", 0b00>; // add
2368 def L4_sub#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " -= ", 0b01>; // sub
2369 def L4_and#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " &= ", 0b10>; // and
2370 def L4_or#NAME : MemOp_rr_base <opc, opcBits, ImmOp, " |= ", 0b11>; // or
2373 // multiclass to define MemOp instructions with immediate Operand.
2374 multiclass MemOp_ri<string opc, bits<2> opcBits, Operand ImmOp> {
2375 def L4_iadd#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " += ", 0b00 >;
2376 def L4_isub#NAME : MemOp_ri_base <opc, opcBits, ImmOp, " -= ", 0b01 >;
2377 def L4_iand#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = clrbit(", 0b10>;
2378 def L4_ior#NAME : MemOp_ri_base<opc, opcBits, ImmOp, " = setbit(", 0b11>;
2381 multiclass MemOp_base <string opc, bits<2> opcBits, Operand ImmOp> {
2382 defm _#NAME : MemOp_rr <opc, opcBits, ImmOp>;
2383 defm _#NAME : MemOp_ri <opc, opcBits, ImmOp>;
2386 // Define MemOp instructions.
2387 let isExtendable = 1, opExtendable = 1, isExtentSigned = 0 in {
2388 let opExtentBits = 6, accessSize = ByteAccess in
2389 defm memopb_io : MemOp_base <"memb", 0b00, u6_0Ext>;
2391 let opExtentBits = 7, accessSize = HalfWordAccess in
2392 defm memoph_io : MemOp_base <"memh", 0b01, u6_1Ext>;
2394 let opExtentBits = 8, accessSize = WordAccess in
2395 defm memopw_io : MemOp_base <"memw", 0b10, u6_2Ext>;
2399 //===----------------------------------------------------------------------===//
2401 //===----------------------------------------------------------------------===//
2403 // Hexagon V4 only supports these flavors of byte/half compare instructions:
2404 // EQ/GT/GTU. Other flavors like GE/GEU/LT/LTU/LE/LEU are not supported by
2405 // hardware. However, compiler can still implement these patterns through
2406 // appropriate patterns combinations based on current implemented patterns.
2407 // The implemented patterns are: EQ/GT/GTU.
2408 // Missing patterns are: GE/GEU/LT/LTU/LE/LEU.
2410 // Following instruction is not being extended as it results into the
2411 // incorrect code for negative numbers.
2412 // Pd=cmpb.eq(Rs,#u8)
2414 // p=!cmp.eq(r1,#s10)
2415 def C4_cmpneqi : T_CMP <"cmp.eq", 0b00, 1, s10_0Ext>;
2416 def C4_cmpltei : T_CMP <"cmp.gt", 0b01, 1, s10_0Ext>;
2417 def C4_cmplteui : T_CMP <"cmp.gtu", 0b10, 1, u9_0Ext>;
2419 //===----------------------------------------------------------------------===//
2421 //===----------------------------------------------------------------------===//
2423 //===----------------------------------------------------------------------===//
2424 // Multiclass for DeallocReturn
2425 //===----------------------------------------------------------------------===//
2426 class L4_RETURN<string mnemonic, bit isNot, bit isPredNew, bit isTak>
2427 : LD0Inst<(outs), (ins PredRegs:$src),
2428 !if(isNot, "if (!$src", "if ($src")#
2429 !if(isPredNew, ".new) ", ") ")#mnemonic#
2430 !if(isPredNew, #!if(isTak,":t", ":nt"),""),
2431 [], "", LD_tc_3or4stall_SLOT0> {
2434 let BaseOpcode = "L4_RETURN";
2435 let isPredicatedFalse = isNot;
2436 let isPredicatedNew = isPredNew;
2437 let isTaken = isTak;
2438 let IClass = 0b1001;
2440 let Inst{27-16} = 0b011000011110;
2442 let Inst{13} = isNot;
2443 let Inst{12} = isTak;
2444 let Inst{11} = isPredNew;
2446 let Inst{9-8} = src;
2447 let Inst{4-0} = 0b11110;
2450 // Produce all predicated forms, p, !p, p.new, !p.new, :t, :nt
2451 multiclass L4_RETURN_PRED<string mnemonic, bit PredNot> {
2452 let isPredicated = 1 in {
2453 def _#NAME# : L4_RETURN <mnemonic, PredNot, 0, 1>;
2454 def _#NAME#new_pnt : L4_RETURN <mnemonic, PredNot, 1, 0>;
2455 def _#NAME#new_pt : L4_RETURN <mnemonic, PredNot, 1, 1>;
2459 multiclass LD_MISC_L4_RETURN<string mnemonic> {
2460 let isBarrier = 1, isPredicable = 1 in
2461 def NAME : LD0Inst <(outs), (ins), mnemonic, [], "",
2462 LD_tc_3or4stall_SLOT0> {
2463 let BaseOpcode = "L4_RETURN";
2464 let IClass = 0b1001;
2465 let Inst{27-16} = 0b011000011110;
2466 let Inst{13-10} = 0b0000;
2467 let Inst{4-0} = 0b11110;
2469 defm t : L4_RETURN_PRED<mnemonic, 0 >;
2470 defm f : L4_RETURN_PRED<mnemonic, 1 >;
2473 let isReturn = 1, isTerminator = 1,
2474 Defs = [R29, R30, R31, PC], Uses = [R30], hasSideEffects = 0 in
2475 defm L4_return: LD_MISC_L4_RETURN <"dealloc_return">, PredNewRel;
2477 // Restore registers and dealloc return function call.
2478 let isCall = 1, isBarrier = 1, isReturn = 1, isTerminator = 1,
2479 Defs = [R29, R30, R31, PC], isPredicable = 0, isAsmParserOnly = 1 in {
2480 def RESTORE_DEALLOC_RET_JMP_V4 : T_JMP<"">;
2482 let isExtended = 1, opExtendable = 0 in
2483 def RESTORE_DEALLOC_RET_JMP_V4_EXT : T_JMP<"">;
2485 let Defs = [R14, R15, R28, R29, R30, R31, PC] in {
2486 def RESTORE_DEALLOC_RET_JMP_V4_PIC : T_JMP<"">;
2488 let isExtended = 1, opExtendable = 0 in
2489 def RESTORE_DEALLOC_RET_JMP_V4_EXT_PIC : T_JMP<"">;
2493 // Restore registers and dealloc frame before a tail call.
2494 let isCall = 1, Defs = [R29, R30, R31, PC], isAsmParserOnly = 1 in {
2495 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4 : T_Call<0, "">, PredRel;
2497 let isExtended = 1, opExtendable = 0 in
2498 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4_EXT : T_Call<0, "">, PredRel;
2500 let Defs = [R14, R15, R28, R29, R30, R31, PC] in {
2501 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4_PIC : T_Call<0, "">, PredRel;
2503 let isExtended = 1, opExtendable = 0 in
2504 def RESTORE_DEALLOC_BEFORE_TAILCALL_V4_EXT_PIC : T_Call<0, "">, PredRel;
2508 // Save registers function call.
2509 let isCall = 1, Uses = [R29, R31], isAsmParserOnly = 1 in {
2510 def SAVE_REGISTERS_CALL_V4 : T_Call<0, "">, PredRel;
2512 let isExtended = 1, opExtendable = 0 in
2513 def SAVE_REGISTERS_CALL_V4_EXT : T_Call<0, "">, PredRel;
2516 def SAVE_REGISTERS_CALL_V4STK : T_Call<0, "">, PredRel;
2518 let Defs = [P0], isExtended = 1, opExtendable = 0 in
2519 def SAVE_REGISTERS_CALL_V4STK_EXT : T_Call<0, "">, PredRel;
2521 let Defs = [R14, R15, R28] in
2522 def SAVE_REGISTERS_CALL_V4_PIC : T_Call<0, "">, PredRel;
2524 let Defs = [R14, R15, R28], isExtended = 1, opExtendable = 0 in
2525 def SAVE_REGISTERS_CALL_V4_EXT_PIC : T_Call<0, "">, PredRel;
2527 let Defs = [R14, R15, R28, P0] in
2528 def SAVE_REGISTERS_CALL_V4STK_PIC : T_Call<0, "">, PredRel;
2530 let Defs = [R14, R15, R28, P0], isExtended = 1, opExtendable = 0 in
2531 def SAVE_REGISTERS_CALL_V4STK_EXT_PIC : T_Call<0, "">, PredRel;
2534 //===----------------------------------------------------------------------===//
2535 // Template class for non predicated store instructions with
2536 // GP-Relative or absolute addressing.
2537 //===----------------------------------------------------------------------===//
2538 let hasSideEffects = 0, isPredicable = 1 in
2539 class T_StoreAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
2540 bits<2>MajOp, bit isAbs, bit isHalf>
2541 : STInst<(outs), (ins ImmOp:$addr, RC:$src),
2542 mnemonic # "(#$addr) = $src"#!if(isHalf, ".h",""),
2543 [], "", V2LDST_tc_st_SLOT01> {
2546 bits<16> offsetBits;
2548 string ImmOpStr = !cast<string>(ImmOp);
2549 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
2550 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
2551 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
2552 /* u16_0Imm */ addr{15-0})));
2553 // Store upper-half and store doubleword cannot be NV.
2554 let isNVStorable = !if (!eq(mnemonic, "memd"), 0, !if(isHalf,0,1));
2555 let Uses = !if (isAbs, [], [GP]);
2557 let IClass = 0b0100;
2559 let Inst{26-25} = offsetBits{15-14};
2561 let Inst{23-22} = MajOp;
2562 let Inst{21} = isHalf;
2563 let Inst{20-16} = offsetBits{13-9};
2564 let Inst{13} = offsetBits{8};
2565 let Inst{12-8} = src;
2566 let Inst{7-0} = offsetBits{7-0};
2569 //===----------------------------------------------------------------------===//
2570 // Template class for predicated store instructions with
2571 // GP-Relative or absolute addressing.
2572 //===----------------------------------------------------------------------===//
2573 let hasSideEffects = 0, isPredicated = 1, opExtentBits = 6, opExtendable = 1 in
2574 class T_StoreAbs_Pred <string mnemonic, RegisterClass RC, bits<2> MajOp,
2575 bit isHalf, bit isNot, bit isNew>
2576 : STInst<(outs), (ins PredRegs:$src1, u32_0MustExt:$absaddr, RC: $src2),
2577 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
2578 ") ")#mnemonic#"(#$absaddr) = $src2"#!if(isHalf, ".h",""),
2579 [], "", ST_tc_st_SLOT01>, AddrModeRel {
2584 let isPredicatedNew = isNew;
2585 let isPredicatedFalse = isNot;
2586 // Store upper-half and store doubleword cannot be NV.
2587 let isNVStorable = !if (!eq(mnemonic, "memd"), 0, !if(isHalf,0,1));
2589 let IClass = 0b1010;
2591 let Inst{27-24} = 0b1111;
2592 let Inst{23-22} = MajOp;
2593 let Inst{21} = isHalf;
2594 let Inst{17-16} = absaddr{5-4};
2595 let Inst{13} = isNew;
2596 let Inst{12-8} = src2;
2598 let Inst{6-3} = absaddr{3-0};
2599 let Inst{2} = isNot;
2600 let Inst{1-0} = src1;
2603 //===----------------------------------------------------------------------===//
2604 // Template class for predicated store instructions with absolute addressing.
2605 //===----------------------------------------------------------------------===//
2606 class T_StoreAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
2607 bits<2> MajOp, bit isHalf>
2608 : T_StoreAbsGP <mnemonic, RC, u32_0MustExt, MajOp, 1, isHalf>,
2610 string ImmOpStr = !cast<string>(ImmOp);
2611 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
2612 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
2613 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
2614 /* u16_0Imm */ 16)));
2616 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
2617 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
2618 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
2619 /* u16_0Imm */ 0)));
2622 //===----------------------------------------------------------------------===//
2623 // Multiclass for store instructions with absolute addressing.
2624 //===----------------------------------------------------------------------===//
2625 let addrMode = Absolute, isExtended = 1 in
2626 multiclass ST_Abs<string mnemonic, string CextOp, RegisterClass RC,
2627 Operand ImmOp, bits<2> MajOp, bit isHalf = 0> {
2628 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
2629 let opExtendable = 0, isPredicable = 1 in
2630 def PS_#NAME#abs : T_StoreAbs <mnemonic, RC, ImmOp, MajOp, isHalf>;
2633 def S4_p#NAME#t_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 0>;
2634 def S4_p#NAME#f_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 0>;
2637 def S4_p#NAME#tnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 0, 1>;
2638 def S4_p#NAME#fnew_abs : T_StoreAbs_Pred<mnemonic, RC, MajOp, isHalf, 1, 1>;
2642 //===----------------------------------------------------------------------===//
2643 // Template class for non predicated new-value store instructions with
2644 // GP-Relative or absolute addressing.
2645 //===----------------------------------------------------------------------===//
2646 let hasSideEffects = 0, isPredicable = 1, mayStore = 1, isNVStore = 1,
2647 isNewValue = 1, opNewValue = 1 in
2648 class T_StoreAbsGP_NV <string mnemonic, Operand ImmOp, bits<2>MajOp>
2649 : NVInst_V4<(outs), (ins ImmOp:$addr, IntRegs:$src),
2650 mnemonic #"(#$addr) = $src.new",
2651 [], "", V2LDST_tc_st_SLOT0> {
2654 bits<16> offsetBits;
2656 string ImmOpStr = !cast<string>(ImmOp);
2657 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
2658 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
2659 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
2660 /* u16_0Imm */ addr{15-0})));
2661 let IClass = 0b0100;
2664 let Inst{26-25} = offsetBits{15-14};
2665 let Inst{24-21} = 0b0101;
2666 let Inst{20-16} = offsetBits{13-9};
2667 let Inst{13} = offsetBits{8};
2668 let Inst{12-11} = MajOp;
2669 let Inst{10-8} = src;
2670 let Inst{7-0} = offsetBits{7-0};
2673 //===----------------------------------------------------------------------===//
2674 // Template class for predicated new-value store instructions with
2675 // absolute addressing.
2676 //===----------------------------------------------------------------------===//
2677 let hasSideEffects = 0, isPredicated = 1, mayStore = 1, isNVStore = 1,
2678 isNewValue = 1, opNewValue = 2, opExtentBits = 6, opExtendable = 1 in
2679 class T_StoreAbs_NV_Pred <string mnemonic, bits<2> MajOp, bit isNot, bit isNew>
2680 : NVInst_V4<(outs), (ins PredRegs:$src1, u32_0MustExt:$absaddr, IntRegs:$src2),
2681 !if(isNot, "if (!$src1", "if ($src1")#!if(isNew, ".new) ",
2682 ") ")#mnemonic#"(#$absaddr) = $src2.new",
2683 [], "", ST_tc_st_SLOT0>, AddrModeRel {
2688 let isPredicatedNew = isNew;
2689 let isPredicatedFalse = isNot;
2691 let IClass = 0b1010;
2693 let Inst{27-24} = 0b1111;
2694 let Inst{23-21} = 0b101;
2695 let Inst{17-16} = absaddr{5-4};
2696 let Inst{13} = isNew;
2697 let Inst{12-11} = MajOp;
2698 let Inst{10-8} = src2;
2700 let Inst{6-3} = absaddr{3-0};
2701 let Inst{2} = isNot;
2702 let Inst{1-0} = src1;
2705 //===----------------------------------------------------------------------===//
2706 // Template class for non-predicated new-value store instructions with
2707 // absolute addressing.
2708 //===----------------------------------------------------------------------===//
2709 class T_StoreAbs_NV <string mnemonic, Operand ImmOp, bits<2> MajOp>
2710 : T_StoreAbsGP_NV <mnemonic, u32_0MustExt, MajOp>, AddrModeRel {
2712 string ImmOpStr = !cast<string>(ImmOp);
2713 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
2714 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
2715 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
2716 /* u16_0Imm */ 16)));
2718 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
2719 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
2720 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
2721 /* u16_0Imm */ 0)));
2724 //===----------------------------------------------------------------------===//
2725 // Multiclass for new-value store instructions with absolute addressing.
2726 //===----------------------------------------------------------------------===//
2727 let addrMode = Absolute, isExtended = 1 in
2728 multiclass ST_Abs_NV <string mnemonic, string CextOp, Operand ImmOp,
2730 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
2731 let opExtendable = 0, isPredicable = 1 in
2732 def PS_#NAME#newabs : T_StoreAbs_NV <mnemonic, ImmOp, MajOp>;
2735 def S4_p#NAME#newt_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 0>;
2736 def S4_p#NAME#newf_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 0>;
2739 def S4_p#NAME#newtnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 0, 1>;
2740 def S4_p#NAME#newfnew_abs : T_StoreAbs_NV_Pred <mnemonic, MajOp, 1, 1>;
2744 //===----------------------------------------------------------------------===//
2745 // Stores with absolute addressing
2746 //===----------------------------------------------------------------------===//
2747 let accessSize = ByteAccess in
2748 defm storerb : ST_Abs <"memb", "STrib", IntRegs, u16_0Imm, 0b00>,
2749 ST_Abs_NV <"memb", "STrib", u16_0Imm, 0b00>;
2751 let accessSize = HalfWordAccess in
2752 defm storerh : ST_Abs <"memh", "STrih", IntRegs, u16_1Imm, 0b01>,
2753 ST_Abs_NV <"memh", "STrih", u16_1Imm, 0b01>;
2755 let accessSize = WordAccess in
2756 defm storeri : ST_Abs <"memw", "STriw", IntRegs, u16_2Imm, 0b10>,
2757 ST_Abs_NV <"memw", "STriw", u16_2Imm, 0b10>;
2759 let isNVStorable = 0, accessSize = DoubleWordAccess in
2760 defm storerd : ST_Abs <"memd", "STrid", DoubleRegs, u16_3Imm, 0b11>;
2762 let isNVStorable = 0, accessSize = HalfWordAccess in
2763 defm storerf : ST_Abs <"memh", "STrif", IntRegs, u16_1Imm, 0b01, 1>;
2765 //===----------------------------------------------------------------------===//
2766 // GP-relative stores.
2767 // mem[bhwd](#global)=Rt
2768 // Once predicated, these instructions map to absolute addressing mode.
2769 // if ([!]Pv[.new]) mem[bhwd](##global)=Rt
2770 //===----------------------------------------------------------------------===//
2772 let Uses = [GP], isAsmParserOnly = 1 in
2773 class T_StoreGP <string mnemonic, string BaseOp, RegisterClass RC,
2774 Operand ImmOp, bits<2> MajOp, bit isHalf = 0>
2775 : T_StoreAbsGP <mnemonic, RC, ImmOp, MajOp, 0, isHalf> {
2776 // Set BaseOpcode same as absolute addressing instructions so that
2777 // non-predicated GP-Rel instructions can have relate with predicated
2778 // Absolute instruction.
2779 let BaseOpcode = BaseOp#_abs;
2782 let Uses = [GP], isAsmParserOnly = 1 in
2783 multiclass ST_GP <string mnemonic, string BaseOp, Operand ImmOp,
2784 bits<2> MajOp, bit isHalf = 0> {
2785 // Set BaseOpcode same as absolute addressing instructions so that
2786 // non-predicated GP-Rel instructions can have relate with predicated
2787 // Absolute instruction.
2788 let BaseOpcode = BaseOp#_abs in {
2789 def NAME#gp : T_StoreAbsGP <mnemonic, IntRegs, ImmOp, MajOp,
2792 def NAME#newgp : T_StoreAbsGP_NV <mnemonic, ImmOp, MajOp> ;
2796 let accessSize = ByteAccess in
2797 defm S2_storerb : ST_GP<"memb", "STrib", u16_0Imm, 0b00>, NewValueRel;
2799 let accessSize = HalfWordAccess in
2800 defm S2_storerh : ST_GP<"memh", "STrih", u16_1Imm, 0b01>, NewValueRel;
2802 let accessSize = WordAccess in
2803 defm S2_storeri : ST_GP<"memw", "STriw", u16_2Imm, 0b10>, NewValueRel;
2805 let isNVStorable = 0, accessSize = DoubleWordAccess in
2806 def S2_storerdgp : T_StoreGP <"memd", "STrid", DoubleRegs,
2807 u16_3Imm, 0b11>, PredNewRel;
2809 let isNVStorable = 0, accessSize = HalfWordAccess in
2810 def S2_storerfgp : T_StoreGP <"memh", "STrif", IntRegs,
2811 u16_1Imm, 0b01, 1>, PredNewRel;
2813 //===----------------------------------------------------------------------===//
2814 // Template class for non predicated load instructions with
2815 // absolute addressing mode.
2816 //===----------------------------------------------------------------------===//
2817 let isPredicable = 1, hasSideEffects = 0 in
2818 class T_LoadAbsGP <string mnemonic, RegisterClass RC, Operand ImmOp,
2820 : LDInst <(outs RC:$dst), (ins ImmOp:$addr),
2821 "$dst = "#mnemonic# "(#$addr)",
2822 [], "", V2LDST_tc_ld_SLOT01> {
2825 bits<16> offsetBits;
2827 string ImmOpStr = !cast<string>(ImmOp);
2828 let offsetBits = !if (!eq(ImmOpStr, "u16_3Imm"), addr{18-3},
2829 !if (!eq(ImmOpStr, "u16_2Imm"), addr{17-2},
2830 !if (!eq(ImmOpStr, "u16_1Imm"), addr{16-1},
2831 /* u16_0Imm */ addr{15-0})));
2833 let IClass = 0b0100;
2836 let Inst{26-25} = offsetBits{15-14};
2838 let Inst{23-21} = MajOp;
2839 let Inst{20-16} = offsetBits{13-9};
2840 let Inst{13-5} = offsetBits{8-0};
2841 let Inst{4-0} = dst;
2844 class T_LoadAbs <string mnemonic, RegisterClass RC, Operand ImmOp,
2846 : T_LoadAbsGP <mnemonic, RC, u32_0MustExt, MajOp>, AddrModeRel {
2848 string ImmOpStr = !cast<string>(ImmOp);
2849 let opExtentBits = !if (!eq(ImmOpStr, "u16_3Imm"), 19,
2850 !if (!eq(ImmOpStr, "u16_2Imm"), 18,
2851 !if (!eq(ImmOpStr, "u16_1Imm"), 17,
2852 /* u16_0Imm */ 16)));
2854 let opExtentAlign = !if (!eq(ImmOpStr, "u16_3Imm"), 3,
2855 !if (!eq(ImmOpStr, "u16_2Imm"), 2,
2856 !if (!eq(ImmOpStr, "u16_1Imm"), 1,
2857 /* u16_0Imm */ 0)));
2860 //===----------------------------------------------------------------------===//
2861 // Template class for predicated load instructions with
2862 // absolute addressing mode.
2863 //===----------------------------------------------------------------------===//
2864 let isPredicated = 1, hasSideEffects = 0, hasNewValue = 1, opExtentBits = 6,
2866 class T_LoadAbs_Pred <string mnemonic, RegisterClass RC, bits<3> MajOp,
2867 bit isPredNot, bit isPredNew>
2868 : LDInst <(outs RC:$dst), (ins PredRegs:$src1, u32_0MustExt:$absaddr),
2869 !if(isPredNot, "if (!$src1", "if ($src1")#!if(isPredNew, ".new) ",
2870 ") ")#"$dst = "#mnemonic#"(#$absaddr)">, AddrModeRel {
2875 let isPredicatedNew = isPredNew;
2876 let isPredicatedFalse = isPredNot;
2877 let hasNewValue = !if (!eq(!cast<string>(RC), "DoubleRegs"), 0, 1);
2879 let IClass = 0b1001;
2881 let Inst{27-24} = 0b1111;
2882 let Inst{23-21} = MajOp;
2883 let Inst{20-16} = absaddr{5-1};
2885 let Inst{12} = isPredNew;
2886 let Inst{11} = isPredNot;
2887 let Inst{10-9} = src1;
2888 let Inst{8} = absaddr{0};
2890 let Inst{4-0} = dst;
2893 //===----------------------------------------------------------------------===//
2894 // Multiclass for the load instructions with absolute addressing mode.
2895 //===----------------------------------------------------------------------===//
2896 multiclass LD_Abs_Pred<string mnemonic, RegisterClass RC, bits<3> MajOp,
2898 def _abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 0>;
2900 def new_abs : T_LoadAbs_Pred <mnemonic, RC, MajOp, PredNot, 1>;
2903 let addrMode = Absolute, isExtended = 1 in
2904 multiclass LD_Abs<string mnemonic, string CextOp, RegisterClass RC,
2905 Operand ImmOp, bits<3> MajOp> {
2906 let CextOpcode = CextOp, BaseOpcode = CextOp#_abs in {
2907 let opExtendable = 1, isPredicable = 1 in
2908 def PS_#NAME#abs: T_LoadAbs <mnemonic, RC, ImmOp, MajOp>;
2911 defm L4_p#NAME#t : LD_Abs_Pred<mnemonic, RC, MajOp, 0>;
2912 defm L4_p#NAME#f : LD_Abs_Pred<mnemonic, RC, MajOp, 1>;
2916 let accessSize = ByteAccess, hasNewValue = 1 in {
2917 defm loadrb : LD_Abs<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
2918 defm loadrub : LD_Abs<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
2921 let accessSize = HalfWordAccess, hasNewValue = 1 in {
2922 defm loadrh : LD_Abs<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
2923 defm loadruh : LD_Abs<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
2926 let accessSize = WordAccess, hasNewValue = 1 in
2927 defm loadri : LD_Abs<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
2929 let accessSize = DoubleWordAccess in
2930 defm loadrd : LD_Abs<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
2932 //===----------------------------------------------------------------------===//
2933 // multiclass for load instructions with GP-relative addressing mode.
2934 // Rx=mem[bhwd](##global)
2935 // Once predicated, these instructions map to absolute addressing mode.
2936 // if ([!]Pv[.new]) Rx=mem[bhwd](##global)
2937 //===----------------------------------------------------------------------===//
2939 let isAsmParserOnly = 1, Uses = [GP] in
2940 class T_LoadGP <string mnemonic, string BaseOp, RegisterClass RC, Operand ImmOp,
2942 : T_LoadAbsGP <mnemonic, RC, ImmOp, MajOp>, PredNewRel {
2943 let BaseOpcode = BaseOp#_abs;
2946 let accessSize = ByteAccess, hasNewValue = 1 in {
2947 def L2_loadrbgp : T_LoadGP<"memb", "LDrib", IntRegs, u16_0Imm, 0b000>;
2948 def L2_loadrubgp : T_LoadGP<"memub", "LDriub", IntRegs, u16_0Imm, 0b001>;
2951 let accessSize = HalfWordAccess, hasNewValue = 1 in {
2952 def L2_loadrhgp : T_LoadGP<"memh", "LDrih", IntRegs, u16_1Imm, 0b010>;
2953 def L2_loadruhgp : T_LoadGP<"memuh", "LDriuh", IntRegs, u16_1Imm, 0b011>;
2956 let accessSize = WordAccess, hasNewValue = 1 in
2957 def L2_loadrigp : T_LoadGP<"memw", "LDriw", IntRegs, u16_2Imm, 0b100>;
2959 let accessSize = DoubleWordAccess in
2960 def L2_loadrdgp : T_LoadGP<"memd", "LDrid", DoubleRegs, u16_3Imm, 0b110>;
2962 //===----------------------------------------------------------------------===//
2963 // :raw for of boundscheck:hi:lo insns
2964 //===----------------------------------------------------------------------===//
2966 // A4_boundscheck_lo: Detect if a register is within bounds.
2967 let hasSideEffects = 0 in
2968 def A4_boundscheck_lo: ALU64Inst <
2969 (outs PredRegs:$Pd),
2970 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2971 "$Pd = boundscheck($Rss, $Rtt):raw:lo"> {
2976 let IClass = 0b1101;
2978 let Inst{27-23} = 0b00100;
2980 let Inst{7-5} = 0b100;
2982 let Inst{20-16} = Rss;
2983 let Inst{12-8} = Rtt;
2986 // A4_boundscheck_hi: Detect if a register is within bounds.
2987 let hasSideEffects = 0 in
2988 def A4_boundscheck_hi: ALU64Inst <
2989 (outs PredRegs:$Pd),
2990 (ins DoubleRegs:$Rss, DoubleRegs:$Rtt),
2991 "$Pd = boundscheck($Rss, $Rtt):raw:hi"> {
2996 let IClass = 0b1101;
2998 let Inst{27-23} = 0b00100;
3000 let Inst{7-5} = 0b101;
3002 let Inst{20-16} = Rss;
3003 let Inst{12-8} = Rtt;
3006 let hasSideEffects = 0, isAsmParserOnly = 1 in
3007 def A4_boundscheck : MInst <
3008 (outs PredRegs:$Pd), (ins IntRegs:$Rs, DoubleRegs:$Rtt),
3009 "$Pd=boundscheck($Rs,$Rtt)">;
3011 // A4_tlbmatch: Detect if a VA/ASID matches a TLB entry.
3012 let isPredicateLate = 1, hasSideEffects = 0 in
3013 def A4_tlbmatch : ALU64Inst<(outs PredRegs:$Pd),
3014 (ins DoubleRegs:$Rs, IntRegs:$Rt),
3015 "$Pd = tlbmatch($Rs, $Rt)",
3016 [], "", ALU64_tc_2early_SLOT23> {
3021 let IClass = 0b1101;
3022 let Inst{27-23} = 0b00100;
3023 let Inst{20-16} = Rs;
3025 let Inst{12-8} = Rt;
3026 let Inst{7-5} = 0b011;
3030 // Use LD0Inst for dcfetch, but set "mayLoad" to 0 because this doesn't
3031 // really do a load.
3032 let hasSideEffects = 1, mayLoad = 0 in
3033 def Y2_dcfetchbo : LD0Inst<(outs), (ins IntRegs:$Rs, u11_3Imm:$u11_3),
3034 "dcfetch($Rs + #$u11_3)",
3035 [], "", LD_tc_ld_SLOT0> {
3039 let IClass = 0b1001;
3040 let Inst{27-21} = 0b0100000;
3041 let Inst{20-16} = Rs;
3043 let Inst{10-0} = u11_3{13-3};
3047 //===----------------------------------------------------------------------===//
3048 // Compound instructions
3049 //===----------------------------------------------------------------------===//
3051 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
3052 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1,
3053 opExtentBits = 11, opExtentAlign = 2, opExtendable = 1,
3055 class CJInst_tstbit_R0<string px, bit np, string tnt>
3056 : InstHexagon<(outs), (ins IntRegs:$Rs, brtarget:$r9_2),
3057 ""#px#" = tstbit($Rs, #0); if ("
3058 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
3059 [], "", COMPOUND_CJ_ARCHDEPSLOT, TypeCOMPOUND>, OpcodeHexagon {
3064 let isPredicatedFalse = np;
3065 // tnt: Taken/Not Taken
3066 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
3067 let isTaken = !if (!eq(tnt, "t"), 1, 0);
3069 let IClass = 0b0001;
3070 let Inst{27-26} = 0b00;
3071 let Inst{25} = !if (!eq(px, "!p1"), 1,
3072 !if (!eq(px, "p1"), 1, 0));
3073 let Inst{24-23} = 0b11;
3075 let Inst{21-20} = r9_2{10-9};
3076 let Inst{19-16} = Rs;
3077 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
3078 let Inst{9-8} = 0b11;
3079 let Inst{7-1} = r9_2{8-2};
3082 let Defs = [PC, P0], Uses = [P0] in {
3083 def J4_tstbit0_tp0_jump_nt : CJInst_tstbit_R0<"p0", 0, "nt">;
3084 def J4_tstbit0_tp0_jump_t : CJInst_tstbit_R0<"p0", 0, "t">;
3085 def J4_tstbit0_fp0_jump_nt : CJInst_tstbit_R0<"p0", 1, "nt">;
3086 def J4_tstbit0_fp0_jump_t : CJInst_tstbit_R0<"p0", 1, "t">;
3089 let Defs = [PC, P1], Uses = [P1] in {
3090 def J4_tstbit0_tp1_jump_nt : CJInst_tstbit_R0<"p1", 0, "nt">;
3091 def J4_tstbit0_tp1_jump_t : CJInst_tstbit_R0<"p1", 0, "t">;
3092 def J4_tstbit0_fp1_jump_nt : CJInst_tstbit_R0<"p1", 1, "nt">;
3093 def J4_tstbit0_fp1_jump_t : CJInst_tstbit_R0<"p1", 1, "t">;
3097 let isBranch = 1, hasSideEffects = 0,
3098 isExtentSigned = 1, isPredicated = 1, isPredicatedNew = 1,
3099 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2,
3100 opExtendable = 2, isTerminator = 1 in
3101 class CJInst_RR<string px, string op, bit np, string tnt>
3102 : InstHexagon<(outs), (ins IntRegs:$Rs, IntRegs:$Rt, brtarget:$r9_2),
3103 ""#px#" = cmp."#op#"($Rs, $Rt); if ("
3104 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
3105 [], "", COMPOUND_CJ_ARCHDEPSLOT, TypeCOMPOUND>, OpcodeHexagon {
3111 let isPredicatedFalse = np;
3112 // tnt: Taken/Not Taken
3113 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
3114 let isTaken = !if (!eq(tnt, "t"), 1, 0);
3116 let IClass = 0b0001;
3117 let Inst{27-23} = !if (!eq(op, "eq"), 0b01000,
3118 !if (!eq(op, "gt"), 0b01001,
3119 !if (!eq(op, "gtu"), 0b01010, 0)));
3121 let Inst{21-20} = r9_2{10-9};
3122 let Inst{19-16} = Rs;
3123 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
3124 // px: Predicate reg 0/1
3125 let Inst{12} = !if (!eq(px, "!p1"), 1,
3126 !if (!eq(px, "p1"), 1, 0));
3127 let Inst{11-8} = Rt;
3128 let Inst{7-1} = r9_2{8-2};
3131 // P[10] taken/not taken.
3132 multiclass T_tnt_CJInst_RR<string op, bit np> {
3133 let Defs = [PC, P0], Uses = [P0] in {
3134 def NAME#p0_jump_nt : CJInst_RR<"p0", op, np, "nt">;
3135 def NAME#p0_jump_t : CJInst_RR<"p0", op, np, "t">;
3137 let Defs = [PC, P1], Uses = [P1] in {
3138 def NAME#p1_jump_nt : CJInst_RR<"p1", op, np, "nt">;
3139 def NAME#p1_jump_t : CJInst_RR<"p1", op, np, "t">;
3142 // Predicate / !Predicate
3143 multiclass T_pnp_CJInst_RR<string op>{
3144 defm J4_cmp#NAME#_t : T_tnt_CJInst_RR<op, 0>;
3145 defm J4_cmp#NAME#_f : T_tnt_CJInst_RR<op, 1>;
3147 // TypeCJ Instructions compare RR and jump
3148 defm eq : T_pnp_CJInst_RR<"eq">;
3149 defm gt : T_pnp_CJInst_RR<"gt">;
3150 defm gtu : T_pnp_CJInst_RR<"gtu">;
3152 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
3153 isPredicated = 1, isPredicatedNew = 1, isExtendable = 1, opExtentBits = 11,
3154 opExtentAlign = 2, opExtendable = 2, isTerminator = 1 in
3155 class CJInst_RU5<string px, string op, bit np, string tnt>
3156 : InstHexagon<(outs), (ins IntRegs:$Rs, u5_0Imm:$U5, brtarget:$r9_2),
3157 ""#px#" = cmp."#op#"($Rs, #$U5); if ("
3158 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
3159 [], "", COMPOUND_CJ_ARCHDEPSLOT, TypeCOMPOUND>, OpcodeHexagon {
3165 let isPredicatedFalse = np;
3166 // tnt: Taken/Not Taken
3167 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
3168 let isTaken = !if (!eq(tnt, "t"), 1, 0);
3170 let IClass = 0b0001;
3171 let Inst{27-26} = 0b00;
3172 // px: Predicate reg 0/1
3173 let Inst{25} = !if (!eq(px, "!p1"), 1,
3174 !if (!eq(px, "p1"), 1, 0));
3175 let Inst{24-23} = !if (!eq(op, "eq"), 0b00,
3176 !if (!eq(op, "gt"), 0b01,
3177 !if (!eq(op, "gtu"), 0b10, 0)));
3179 let Inst{21-20} = r9_2{10-9};
3180 let Inst{19-16} = Rs;
3181 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
3182 let Inst{12-8} = U5;
3183 let Inst{7-1} = r9_2{8-2};
3185 // P[10] taken/not taken.
3186 multiclass T_tnt_CJInst_RU5<string op, bit np> {
3187 let Defs = [PC, P0], Uses = [P0] in {
3188 def NAME#p0_jump_nt : CJInst_RU5<"p0", op, np, "nt">;
3189 def NAME#p0_jump_t : CJInst_RU5<"p0", op, np, "t">;
3191 let Defs = [PC, P1], Uses = [P1] in {
3192 def NAME#p1_jump_nt : CJInst_RU5<"p1", op, np, "nt">;
3193 def NAME#p1_jump_t : CJInst_RU5<"p1", op, np, "t">;
3196 // Predicate / !Predicate
3197 multiclass T_pnp_CJInst_RU5<string op>{
3198 defm J4_cmp#NAME#i_t : T_tnt_CJInst_RU5<op, 0>;
3199 defm J4_cmp#NAME#i_f : T_tnt_CJInst_RU5<op, 1>;
3201 // TypeCJ Instructions compare RI and jump
3202 defm eq : T_pnp_CJInst_RU5<"eq">;
3203 defm gt : T_pnp_CJInst_RU5<"gt">;
3204 defm gtu : T_pnp_CJInst_RU5<"gtu">;
3206 let isBranch = 1, hasSideEffects = 0, isExtentSigned = 1,
3207 isPredicated = 1, isPredicatedFalse = 1, isPredicatedNew = 1,
3208 isExtendable = 1, opExtentBits = 11, opExtentAlign = 2, opExtendable = 2,
3210 class CJInst_Rn1<string px, string op, bit np, string tnt>
3211 : InstHexagon<(outs), (ins IntRegs:$Rs, n1Const:$n1, brtarget:$r9_2),
3212 ""#px#" = cmp."#op#"($Rs,#$n1); if ("
3213 #!if(np, "!","")#""#px#".new) jump:"#tnt#" $r9_2",
3214 [], "", COMPOUND_CJ_ARCHDEPSLOT, TypeCOMPOUND>, OpcodeHexagon {
3219 let isPredicatedFalse = np;
3220 // tnt: Taken/Not Taken
3221 let isBrTaken = !if (!eq(tnt, "t"), "true", "false");
3222 let isTaken = !if (!eq(tnt, "t"), 1, 0);
3224 let IClass = 0b0001;
3225 let Inst{27-26} = 0b00;
3226 let Inst{25} = !if (!eq(px, "!p1"), 1,
3227 !if (!eq(px, "p1"), 1, 0));
3229 let Inst{24-23} = 0b11;
3231 let Inst{21-20} = r9_2{10-9};
3232 let Inst{19-16} = Rs;
3233 let Inst{13} = !if (!eq(tnt, "t"), 1, 0);
3234 let Inst{9-8} = !if (!eq(op, "eq"), 0b00,
3235 !if (!eq(op, "gt"), 0b01, 0));
3236 let Inst{7-1} = r9_2{8-2};
3239 // P[10] taken/not taken.
3240 multiclass T_tnt_CJInst_Rn1<string op, bit np> {
3241 let Defs = [PC, P0], Uses = [P0] in {
3242 def NAME#p0_jump_nt : CJInst_Rn1<"p0", op, np, "nt">;
3243 def NAME#p0_jump_t : CJInst_Rn1<"p0", op, np, "t">;
3245 let Defs = [PC, P1], Uses = [P1] in {
3246 def NAME#p1_jump_nt : CJInst_Rn1<"p1", op, np, "nt">;
3247 def NAME#p1_jump_t : CJInst_Rn1<"p1", op, np, "t">;
3250 // Predicate / !Predicate
3251 multiclass T_pnp_CJInst_Rn1<string op>{
3252 defm J4_cmp#NAME#n1_t : T_tnt_CJInst_Rn1<op, 0>;
3253 defm J4_cmp#NAME#n1_f : T_tnt_CJInst_Rn1<op, 1>;
3255 // TypeCJ Instructions compare -1 and jump
3256 defm eq : T_pnp_CJInst_Rn1<"eq">;
3257 defm gt : T_pnp_CJInst_Rn1<"gt">;
3259 // J4_jumpseti: Direct unconditional jump and set register to immediate.
3260 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
3261 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
3262 opExtentAlign = 2, opExtendable = 2 in
3263 def J4_jumpseti: CJInst_JMPSET <
3265 (ins u6_0Imm:$U6, brtarget:$r9_2),
3266 "$Rd = #$U6 ; jump $r9_2"> {
3271 let IClass = 0b0001;
3272 let Inst{27-24} = 0b0110;
3273 let Inst{21-20} = r9_2{10-9};
3274 let Inst{19-16} = Rd;
3275 let Inst{13-8} = U6;
3276 let Inst{7-1} = r9_2{8-2};
3279 // J4_jumpsetr: Direct unconditional jump and transfer register.
3280 let Defs = [PC], isBranch = 1, hasSideEffects = 0, hasNewValue = 1,
3281 isExtentSigned = 1, opNewValue = 0, isExtendable = 1, opExtentBits = 11,
3282 opExtentAlign = 2, opExtendable = 2 in
3283 def J4_jumpsetr: CJInst_JMPSET <
3285 (ins IntRegs:$Rs, brtarget:$r9_2),
3286 "$Rd = $Rs ; jump $r9_2"> {
3291 let IClass = 0b0001;
3292 let Inst{27-24} = 0b0111;
3293 let Inst{21-20} = r9_2{10-9};
3294 let Inst{11-8} = Rd;
3295 let Inst{19-16} = Rs;
3296 let Inst{7-1} = r9_2{8-2};
3299 // Duplex instructions
3300 //===----------------------------------------------------------------------===//
3301 include "HexagonIsetDx.td"