1 //===- ARCInstrFormats.td - ARC Instruction Formats --------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
10 // Instruction format superclass
11 //===----------------------------------------------------------------------===//
15 field bits<64> SoftFail = 0;
20 class immU<int BSz> : Operand<i32>, PatLeaf<(imm),
21 "\n return isUInt<"#BSz#">(N->getSExtValue());"> {
26 class immS<int BSz> : Operand<i32>, PatLeaf<(imm),
27 "\n return isInt<"#BSz#">(N->getSExtValue());"> {
28 let DecoderMethod = "DecodeSignedOperand<"#BSz#">";
31 // e.g. s3 field may encode the signed integers values -1 .. 6
32 // using binary codes 111, 000, 001, 010, 011, 100, 101, and 110, respectively
33 class immC<int BSz> : Operand<i32>, PatLeaf<(imm),
34 "\n return isInt<"#BSz#">(N->getSExtValue());"> {
35 let DecoderMethod = "DecodeFromCyclicRange<"#BSz#">";
38 def MEMii : Operand<i32> {
39 let MIOperandInfo = (ops i32imm, i32imm);
42 def MEMrs9 : Operand<iAny> {
43 let MIOperandInfo = (ops GPR32:$B, immS<9>:$S9);
44 let PrintMethod = "printMemOperandRI";
45 let DecoderMethod = "DecodeMEMrs9";
48 def MEMrlimm : Operand<iAny> {
49 let MIOperandInfo = (ops GPR32:$B, i32imm:$LImm);
50 let PrintMethod = "printMemOperandRI";
51 let DecoderMethod = "DecodeMEMrlimm";
54 def GPR32Reduced : Operand<iAny> {
55 let DecoderMethod = "DecodeGBR32ShortRegister";
58 // Helper classes for load/store instructions
59 class DataSizeMode<bits<2> mode, string instSfx, string asmSfx> {
61 string InstSuffix = instSfx;
62 string AsmSuffix = asmSfx;
64 class ExtMode<bit mode, string instSfx, string asmSfx> {
66 string InstSuffix = instSfx;
67 string AsmSuffix = asmSfx;
70 class AddrMode<bits<2> mode, string instSfx, string asmSfx> {
72 string InstSuffix = instSfx;
73 string AsmSuffix = asmSfx;
76 class CacheMode<bit mode, string instSfx, string asmSfx> {
78 string InstSuffix = instSfx;
79 string AsmSuffix = asmSfx;
82 def ByteSM : DataSizeMode<0b01, "B", "b">;
83 def HalfSM : DataSizeMode<0b10, "H", "h">;
84 def WordSM : DataSizeMode<0b00, "", "">;
86 def NoEM : ExtMode<0, "", "">;
87 def SignedEM : ExtMode<1, "_X", ".x">;
89 def NoAM : AddrMode<0b00, "", "">;
90 def PreIncAM : AddrMode<0b01, "_AW", ".aw">;
91 def PostIncAM : AddrMode<0b10, "_AB", ".ab">;
93 def NoCC : CacheMode<0b0, "", "">;
94 def UncachedCC : CacheMode<0b1, "_DI", ".di">;
96 class InstARC<int sz, dag outs, dag ins, string asmstr, list<dag> pattern>
97 : Instruction, Encoding64 {
99 let Namespace = "ARC";
100 dag OutOperandList = outs;
101 dag InOperandList = ins;
102 let AsmString = asmstr;
103 let Pattern = pattern;
106 // Load/Store instruction properties
107 DataSizeMode ZZ = WordSM;
112 // Field used for relation models
113 string BaseOpcode = "";
116 let TSFlags{1-0} = AA.Value;
119 // ARC pseudo instructions format
120 class PseudoInstARC<dag outs, dag ins, string asmstr, list<dag> pattern>
121 : InstARC<0, outs, ins, asmstr, pattern> {
125 //===----------------------------------------------------------------------===//
126 // Instruction formats
127 //===----------------------------------------------------------------------===//
129 // All 32-bit ARC instructions have a 5-bit "major" opcode class designator
132 // Some general naming conventions:
133 // N - Delay Slot bit. ARC v2 branch instructions have an optional delay slot
134 // which is encoded with this bit. When set, a delay slot exists.
135 // cc - Condition code.
136 // SX - Signed X-bit immediate.
137 // UX - Unsigned X-bit immediate.
139 // [ABC] - 32-bit register operand. These are 6-bit fields. This encodes the
140 // standard 32 general purpose registers, and allows use of additional
141 // (extension) registers. This also encodes an instruction that uses
142 // a 32-bit Long Immediate (LImm), using 0x3e==62 as the field value.
143 // This makes 32-bit format instructions with Long Immediates
144 // 64-bit instructions, with the Long Immediate in bits 32-63.
145 // A - Inst[5-0] = A[5-0], when the format has A. A is always a register.
146 // B - Inst[14-12] = B[5-3], Inst[26-24] = B[2-0], when the format has B.
147 // B is always a register.
148 // C - Inst[11-6] = C[5-0], when the format has C. C can either be a register,
149 // or a 6-bit unsigned immediate (immU6), depending on the format.
150 // F - Many instructions specify a flag bit. When set, the result of these
151 // instructions will set the ZNCV flags of the STATUS32 register
152 // (Zero/Negative/Carry/oVerflow).
154 // Branch Instructions.
155 class F32_BR<bits<5> major, dag outs, dag ins, bit b16, string asmstr,
157 InstARC<4, outs, ins, asmstr, pattern> {
160 let Inst{31-27} = major;
165 class F32_BR_COND<bits<5> major, dag outs, dag ins, bit b16, string asmstr,
167 F32_BR<major, outs, ins, b16, asmstr, pattern> {
168 bits<21> S21; // 2-byte aligned 21-bit byte-offset.
170 let Inst{26-18} = S21{10-2};
171 let Inst{15-6} = S21{20-11};
175 class F32_BR_UCOND_FAR<bits<5> major, dag outs, dag ins, bit b16, string asmstr,
177 F32_BR<major, outs, ins, b16, asmstr, pattern> {
178 bits<25> S25; // 2-byte aligned 25-bit byte-offset.
179 let Inst{26-18} = S25{10-2};
180 let Inst{15-6} = S25{20-11};
182 let Inst{3-0} = S25{24-21};
185 class F32_BR0_COND<dag outs, dag ins, string asmstr, list<dag> pat> :
186 F32_BR_COND<0b00000, outs, ins, 0, asmstr, pat> {
187 let Inst{17} = S21{1};
190 // Branch targets are 2-byte aligned, so S25[0] is implied 0.
191 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0 |
192 // |S25[10-1] | 1|S25[20-11] |N|0|S25[24-21]|
193 class F32_BR0_UCOND_FAR<dag outs, dag ins, string asmstr, list<dag> pat> :
194 F32_BR_UCOND_FAR<0b00000, outs, ins, 1, asmstr, pat> {
195 let Inst{17} = S25{1};
198 // BL targets (functions) are 4-byte aligned, so S25[1-0] = 0b00
199 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0 |
200 // |S25[10-2] | 1| 0|S25[20-11] |N|0|S25[24-21]|
201 class F32_BR1_BL_UCOND_FAR<dag outs, dag ins, string asmstr, list<dag> pat> :
202 F32_BR_UCOND_FAR<0b00001, outs, ins, 0, asmstr, pat> {
206 // BLcc targets have 21 bit range, and are 4-byte aligned.
207 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
208 // |S25[10-2] | 0| 0|S25[20-11] |N|0|cc |
209 class F32_BR1_BL_COND<dag outs, dag ins, string asmstr, list<dag> pat> :
210 F32_BR_COND<0b00001, outs, ins, 0, asmstr, pat> {
214 // BRcc targets have limited 9-bit range. These are for compare and branch
215 // in single instruction. Their targets are 2-byte aligned. They also use
216 // a different (3-bit) set of condition codes.
217 // |26|25|24|23|22|21|20|19|18|17|16|15 |14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
218 // |B[2-0] |S9[7-1] | 1|S9[8]|B[5-3] |C |N|u|0|cc |
219 class F32_BR1_BCC<dag outs, dag ins, string asmstr, bit IsU6,
221 InstARC<4, outs, ins, asmstr, pattern> {
227 bits<9> S9; // 2-byte aligned 9-bit byte-offset.
229 let Inst{31-27} = 0b00001;
230 let Inst{26-24} = B{2-0};
231 let Inst{23-17} = S9{7-1};
233 let Inst{15} = S9{8};
234 let Inst{14-12} = B{5-3};
242 // General operations instructions.
243 // Single Operand Instructions. Inst[5-0] specifies the specific operation
245 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
246 // |B[2-0] | 0| 0| 1| 0| 1| 1| 1| 1| F|B[5-3] |C |subop |
247 class F32_SOP_RR<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
248 string asmstr, list<dag> pattern> :
249 InstARC<4, outs, ins, asmstr, pattern> {
254 let Inst{31-27} = major;
255 let Inst{26-24} = B{2-0};
256 let Inst{23-22} = 0b00;
257 let Inst{21-16} = 0b101111;
259 let Inst{14-12} = B{5-3};
261 let Inst{5-0} = subop;
264 // Dual Operand Instructions. Inst[21-16] specifies the specific operation
267 // 3-register Dual Operand instruction.
268 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
269 // |B[2-0] | 0| 0| subop| F|B[5-3] |C |A |
270 class F32_DOP_RR<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
271 string asmstr, list<dag> pattern> :
272 InstARC<4, outs, ins, asmstr, pattern> {
277 let Inst{31-27} = major;
278 let Inst{26-24} = B{2-0};
279 let Inst{23-22} = 0b00;
280 let Inst{21-16} = subop;
282 let Inst{14-12} = B{5-3};
287 // Conditional Dual Operand instruction. This instruction uses B as the
288 // first 2 operands (i.e, add.cc B, B, C).
289 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
290 // |B[2-0] | 1| 1| subop| F|B[5-3] |C |A |
291 class F32_DOP_CC_RR<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
292 string asmstr, list<dag> pattern> :
293 InstARC<4, outs, ins, asmstr, pattern> {
298 let Inst{31-27} = major;
299 let Inst{26-24} = B{2-0};
300 let Inst{23-22} = 0b11;
301 let Inst{21-16} = subop;
303 let Inst{14-12} = B{5-3};
310 // 2-register, unsigned 6-bit immediate Dual Operand instruction.
311 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
312 // |B[2-0] | 0| 1| subop| F|B[5-3] |U6 |A |
313 class F32_DOP_RU6<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
314 string asmstr, list<dag> pattern> :
315 InstARC<4, outs, ins, asmstr, pattern> {
320 let Inst{31-27} = major;
321 let Inst{26-24} = B{2-0};
322 let Inst{23-22} = 0b01;
323 let Inst{21-16} = subop;
325 let Inst{14-12} = B{5-3};
330 // 1-register, unsigned 6-bit, immediate Dual Operand instruction with
332 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
333 // |B[2-0] | 1| 1| subop| F|B[5-3] |U6 |1|cc |
334 class F32_DOP_CC_RU6<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
335 string asmstr, list<dag> pattern> :
336 InstARC<4, outs, ins, asmstr, pattern> {
342 let Inst{31-27} = major;
343 let Inst{26-24} = B{2-0};
344 let Inst{23-22} = 0b11;
345 let Inst{21-16} = subop;
347 let Inst{14-12} = B{5-3};
352 let DecoderMethod = "DecodeCCRU6Instruction";
355 // 2-register, unsigned 6-bit immediate Dual Operand instruction with
356 // condition code. This instruction uses B as the first 2 operands
357 // (i.e, add.cc B, B, u6).
358 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
359 // |B[2-0] | 1| 1| subop| F|B[5-3] |U6 |1|cc |
360 class F32_DOP_CC_RRU6<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
361 string asmstr, list<dag> pattern> :
362 InstARC<4, outs, ins, asmstr, pattern> {
367 let Inst{31-27} = major;
368 let Inst{26-24} = B{2-0};
369 let Inst{23-22} = 0b11;
370 let Inst{21-16} = subop;
372 let Inst{14-12} = B{5-3};
378 // 2-register, signed 12-bit immediate Dual Operand instruction.
379 // This instruction uses B as the first 2 operands (i.e., add B, B, -128).
380 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
381 // |B[2-0] | 1| 0| subop| F|B[5-3] |S12[5-0] |S12[11-6] |
382 class F32_DOP_RS12<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
383 string asmstr, list<dag> pattern> :
384 InstARC<4, outs, ins, asmstr, pattern> {
388 let Inst{31-27} = major;
389 let Inst{26-24} = B{2-0};
390 let Inst{23-22} = 0b10;
391 let Inst{21-16} = subop;
393 let Inst{14-12} = B{5-3};
394 let Inst{11-6} = S12{5-0};
395 let Inst{5-0} = S12{11-6};
398 // 1-register, signed 12-bit immediate Dual Operand instruction.
399 // This instruction uses B as the first operand (i.e., lr B, [%count0]).
400 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
401 // |B[2-0] | 1| 0| subop| F|B[5-3] |S12[5-0] |S12[11-6] |
402 class F32_SOP_RS12<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
403 string asmstr, list<dag> pattern> :
404 InstARC<4, outs, ins, asmstr, pattern> {
408 let Inst{31-27} = major;
409 let Inst{26-24} = B{2-0};
410 let Inst{23-22} = 0b10;
411 let Inst{21-16} = subop;
413 let Inst{14-12} = B{5-3};
414 let Inst{11-6} = S12{5-0};
415 let Inst{5-0} = S12{11-6};
417 let DecoderMethod = "DecodeSOPwithRS12";
420 // 1-register, unsigned 6-bit immediate Dual Operand instruction.
421 // This instruction uses B as the first operand.
422 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
423 // |B[2-0] | 0| 1| subop| F|B[5-3] |U6 |0|0|0|0|0|0|
424 class F32_SOP_RU6<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
425 string asmstr, list<dag> pattern> :
426 InstARC<4, outs, ins, asmstr, pattern> {
430 let Inst{31-27} = major;
431 let Inst{26-24} = B{2-0};
432 let Inst{23-22} = 0b01;
433 let Inst{21-16} = subop;
435 let Inst{14-12} = B{5-3};
439 let DecoderMethod = "DecodeSOPwithRU6";
442 // 2-register, 32-bit immediate (LImm) Dual Operand instruction.
443 // This instruction has the 32-bit immediate in bits 32-63, and
444 // 62 in the C register operand slot, but is otherwise F32_DOP_RR.
445 class F32_DOP_RLIMM<bits<5> major, bits<6> subop, bit F, dag outs, dag ins,
446 string asmstr, list<dag> pattern> :
447 InstARC<8, outs, ins, asmstr, pattern> {
452 let Inst{63-32} = LImm;
453 let Inst{31-27} = major;
454 let Inst{26-24} = B{2-0};
455 let Inst{23-22} = 0b00;
456 let Inst{21-16} = subop;
458 let Inst{14-12} = B{5-3};
459 let Inst{11-6} = 0b111110;
464 // Load and store instructions.
465 // In addition to the previous naming conventions, load and store instructions
467 // di - Uncached bit. When set, loads/stores bypass the cache and access
469 // aa - Incrementing mode. Loads and stores can write-back address pre- or
470 // post- memory operation.
471 // zz - Memory size (can be 8/16/32 bit load/store).
472 // x - Sign-extending. When set, short loads can be sign-extended to 32-bits.
473 // Loads and Stores support different memory addressing modes:
474 // Base Register + Signed 9-bit Immediate: Both Load/Store.
475 // LImm: Both Load/Store (Load/Store from a fixed 32-bit address).
476 // Register + Register: Load Only.
477 // Register + LImm: Load Only.
479 // Register + S9 Load. (B + S9)
480 // |26|25|24|23|22|21|20|19|18|17|16|15 |14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
481 // |B[2-0] |S9[7-0] |S9[8]|B[5-3] |di|aa |zz |x|A |
482 class F32_LD_RS9<bit x, bits<2> aa, bit di, bits<2> zz, dag outs, dag ins,
483 string asmstr, list<dag> pattern> :
484 InstARC<4, outs, ins, asmstr, pattern> {
489 let Inst{31-27} = 0b00010;
490 let Inst{26-24} = B{2-0};
491 let Inst{23-16} = S9{7-0};
492 let Inst{15} = S9{8};
493 let Inst{14-12} = B{5-3};
500 let BaseOpcode = "ld_rs9";
503 class F32_LD_ADDR<bit x, bits<2> aa, bit di, bits<2> zz, dag outs, dag ins,
504 string asmstr, list<dag> pattern> :
505 F32_LD_RS9<x, aa, di, zz, outs, ins, asmstr, pattern> {
511 let BaseOpcode = "ld_rs9";
515 // LImm Load. The 32-bit immediate address is in Inst[63-32].
516 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
517 // | 1| 1| 0| 0 | 1| 1| 1|di| 0|0|zz |x|A |
518 class F32_LD_LIMM<bit x, bit di, bits<2> zz, dag outs, dag ins,
519 string asmstr, list<dag> pattern> :
520 InstARC<8, outs, ins, asmstr, pattern> {
521 bits<6> LImmReg = 0b111110;
525 let Inst{63-32} = LImm;
526 let Inst{31-27} = 0b00010;
527 let Inst{26-24} = LImmReg{2-0};
529 let Inst{14-12} = LImmReg{5-3};
535 let DecoderMethod = "DecodeLdLImmInstruction";
537 let BaseOpcode = "ld_limm";
540 // Register + LImm load. The 32-bit immediate address is in Inst[63-32].
541 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0|
542 // |B[2-0] |aa | 1| 1| 0|zz | x|di|B[5-3] | 1| 1|1|1|1|0|A |
543 class F32_LD_RLIMM<bit x, bits<2> aa, bit di, bits<2> zz, dag outs, dag ins,
544 string asmstr, list<dag> pattern> :
545 InstARC<8, outs, ins, asmstr, pattern> {
546 bits<6> LImmReg = 0b111110;
552 let LImm = addr{31-0};
554 let Inst{63-32} = LImm;
555 let Inst{31-27} = 0b00100;
556 let Inst{26-24} = B{2-0};
557 let Inst{23-22} = aa;
558 let Inst{21-19} = 0b110;
559 let Inst{18-17} = zz;
562 let Inst{14-12} = B{5-3};
563 let Inst{11-6} = LImmReg;
565 let DecoderMethod = "DecodeLdRLImmInstruction";
567 let BaseOpcode = "ld_rlimm";
570 // Register + S9 Store. (B + S9)
571 // |26|25|24|23|22|21|20|19|18|17|16|15 |14|13|12|11|10|9|8|7|6|5 |4|3|2|1|0|
572 // |B[2-0] |S9[7-0] |S9[8]|B[5-3] |C |di|aa |zz |0|
573 class F32_ST_RS9<bits<2> aa, bit di, bits<2> zz, dag outs, dag ins,
574 string asmstr, list<dag> pattern> :
575 InstARC<4, outs, ins, asmstr, pattern> {
580 let Inst{31-27} = 0b00011;
581 let Inst{26-24} = B{2-0};
582 let Inst{23-16} = S9{7-0};
583 let Inst{15} = S9{8};
584 let Inst{14-12} = B{5-3};
591 let BaseOpcode = "st_rs9";
594 class F32_ST_ADDR<bits<2> aa, bit di, bits<2> zz, dag outs, dag ins,
595 string asmstr, list<dag> pattern> :
596 F32_ST_RS9<aa, di, zz, outs, ins, asmstr, pattern> {
602 let BaseOpcode = "st_rs9";
606 // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5 |4|3|2|1|0|
607 // | 1| 1| 0| 0 | 1| 1| 1|C |di|0|0|zz |0|
608 class F32_ST_LIMM<bit di, bits<2> zz, dag outs, dag ins,
609 string asmstr, list<dag> pattern> :
610 InstARC<8, outs, ins, asmstr, pattern> {
611 bits<6> LImmReg = 0b111110;
615 let Inst{63-32} = LImm;
616 let Inst{31-27} = 0b00011;
617 let Inst{26-24} = LImmReg{2-0};
619 let Inst{14-12} = LImmReg{5-3};
625 let DecoderMethod = "DecodeStLImmInstruction";
627 let BaseOpcode = "st_limm";
630 // Compact Move/Load.
631 // |10|9|8|7|6|5|4|3|2|1|0|
633 class F16_COMPACT<bits<1> i, dag outs, dag ins,
635 InstARC<2, outs, ins, asmstr, []> {
639 let Inst{15-11} = 0b01000;
640 let Inst{7-5} = h{2-0};
642 let Inst{1-0} = h{4-3};
645 // Compact Load/Add/Sub.
646 class F16_LD_ADD_SUB<dag outs, dag ins, string asmstr> :
647 InstARC<2, outs, ins, asmstr, []> {
650 let Inst{15-11} = 0b01001;
654 class F16_LD_SUB<bit i, string asmstr> :
655 F16_LD_ADD_SUB<(outs GPR32:$a), (ins GPR32:$b, GPR32:$c),
668 F16_LD_ADD_SUB<(outs GPR32:$r), (ins GPR32:$b, immU<6>:$u6),
669 "add_s\t$r, $b, $u6"> {
675 let Inst{6-4} = u6{5-3};
677 let Inst{2-0} = u6{2-0};
680 // Compact Load/Store.
681 class F16_LD_ST_1<dag outs, dag ins, string asmstr> :
682 InstARC<2, outs, ins, asmstr, []> {
684 let Inst{15-11} = 0b01010;
687 class F16_LD_ST_s11<bit i, string asmstr> :
688 F16_LD_ST_1<(outs), (ins immS<11>:$s11), asmstr> {
692 let Inst{10-5} = s11{10-5};
695 let Inst{2-0} = s11{4-2};
700 F16_LD_ST_1<(outs GPR32:$b), (ins immU<7>:$u7),
701 "ldi_s\t$b, [$u7]"> {
707 let Inst{7-4} = u7{6-3};
709 let Inst{2-0} = u7{2-0};
712 // Indexed Jump or Execute.
713 class F16_JLI_EI<bit i, string asmstr> :
714 InstARC<2, (outs), (ins immU<10>:$u10),
715 !strconcat(asmstr, "\t$u10"), []> {
719 let Inst{15-11} = 0b01011;
724 // Load/Add Register-Register.
725 class F16_LD_ADD_RR<bits<2> i, string asmstr> :
726 InstARC<2, (outs GPR32:$a), (ins GPR32:$b, GPR32:$c),
733 let Inst{15-11} = 0b01100;
740 // Load/Add GP-Relative.
741 class F16_GP_LD_ADD<bits<2> i, dag ins, string asmstr> :
742 InstARC<2, (outs), ins, asmstr, []> {
744 let Inst{15-11} = 0b11001;
748 // Add/Sub/Shift Register-Immediate.
749 // |10|9|8|7|6|5|4|3|2|1|0|
751 class F16_ADD_IMM<bits<2> i, string asmstr> :
752 InstARC<2, (outs GPR32:$c), (ins GPR32:$b, immU<3>:$u3),
753 !strconcat(asmstr, "\t$c, $b, $u3"), []> {
759 let Inst{15-11} = 0b01101;
766 // Dual Register Operations.
767 // |10|9|8|7|6|5|4|3|2|1|0|
769 class F16_OP_HREG<bits<3> i, dag outs, dag ins, string asmstr> :
770 InstARC<2, outs, ins, asmstr, []> {
775 let Inst{15-11} = 0b01110;
776 let Inst{10-8} = b_s3;
777 let Inst{7-5} = h{2-0};
779 let Inst{1-0} = h{4-3};
782 class F16_OP_HREG30<bits<3> i, dag outs, dag ins, string asmstr> :
783 F16_OP_HREG<i, outs, ins, asmstr> {
785 bits<5> LImmReg = 0b11110;
786 let Inst{7-5} = LImmReg{2-0};
787 let Inst{1-0} = LImmReg{4-3};
790 class F16_OP_HREG_LIMM<bits<3> i, dag outs, dag ins, string asmstr> :
791 F16_OP_HREG30<i, outs, ins, asmstr> {
794 let Inst{47-16} = LImm;
798 // General compact DOP format.
799 class F16_GEN_DOP_BASE<bits<5> i, dag outs, dag ins, string asmstr> :
800 InstARC<2, outs, ins, asmstr, []> {
804 let Inst{15-11} = 0b01111;
810 class F16_GEN_DOP<bits<5> i, string asmstr> :
811 F16_GEN_DOP_BASE<i, (outs GPR32:$b), (ins GPR32:$c),
812 !strconcat(asmstr, "\t$b, $b, $c")>;
814 class F16_GEN_DOP_NODST<bits<5> i, string asmstr> :
815 F16_GEN_DOP_BASE<i, (outs), (ins GPR32:$b, GPR32:$c),
816 !strconcat(asmstr, "\t$b, $c")>;
818 class F16_GEN_DOP_SINGLESRC<bits<5> i, string asmstr> :
819 F16_GEN_DOP_BASE<i, (outs GPR32:$b), (ins GPR32:$c),
820 !strconcat(asmstr, "\t$b, $c")>;
822 class F16_GEN_SOP_BASE<bits<3> i, dag outs, dag ins, string asmstr> :
823 F16_GEN_DOP_BASE<0b00000, outs, ins, asmstr> {
828 class F16_GEN_SOP<bits<3> i, string asmstr> :
829 F16_GEN_SOP_BASE<i, (outs), (ins GPR32:$b), asmstr>;
831 class F16_GEN_ZOP<bits<3> i, string asmstr> :
832 F16_GEN_SOP_BASE<0b111, (outs), (ins), asmstr> {
837 // Compact Load/Store with Offset Format.
838 class F16_LD_ST_OFF<bits<5> opc, dag outs, dag ins, string asmstr> :
839 InstARC<2, outs, ins, !strconcat(asmstr, "\t$c, [$b, $off]"), []> {
843 let Inst{15-11} = opc;
848 class F16_LD_ST_WORD_OFF<bits<5> opc, dag outs, dag ins, string asmstr> :
849 F16_LD_ST_OFF<opc, outs, ins, asmstr> {
852 let Inst{4-0} = off{6-2};
856 class F16_LD_ST_HALF_OFF<bits<5> opc, dag outs, dag ins, string asmstr> :
857 F16_LD_ST_OFF<opc, outs, ins, asmstr> {
860 let Inst{4-0} = off{5-1};
864 class F16_LD_ST_BYTE_OFF<bits<5> opc, dag outs, dag ins, string asmstr> :
865 F16_LD_ST_OFF<opc, outs, ins, asmstr> {
871 // Shift/Subtract/Bit Immediate.
872 // |10|9|8|7|6|5|4|3|2|1|0|
874 class F16_SH_SUB_BIT<bits<3> i, string asmstr> :
875 InstARC<2, (outs), (ins GPR32:$b, immU<5>:$u5), asmstr, []> {
880 let Inst{15-11} = 0b10111;
886 class F16_SH_SUB_BIT_DST<bits<3> i, string asmstr> :
887 F16_SH_SUB_BIT<i, !strconcat(asmstr, "\t$b, $b, $u5")>;
889 // 16-bit stack-based operations.
890 // |10|9|8|7|6|5|4|3|2|1|0|
892 class F16_SP_OPS<bits<3> i,
893 dag outs, dag ins, string asmstr> :
894 InstARC<2, outs, ins, asmstr, []> {
899 let Inst{15-11} = 0b11000;
900 let Inst{10-8} = fieldB;
902 let Inst{4-0} = fieldU;
905 class F16_SP_OPS_u7_aligned<bits<3> i,
906 dag outs, dag ins, string asmstr> :
907 F16_SP_OPS<i, outs, ins, asmstr> {
913 let fieldU = u7{6-2};
917 class F16_SP_OPS_bconst<bits<3> b, string asmop> :
918 F16_SP_OPS_u7_aligned<0b101,
919 (outs), (ins immU<7>:$u7),
920 !strconcat(asmop, "\t%sp, %sp, $u7")> {
925 class F16_SP_OPS_uconst<bits<3> i,
926 dag outs, dag ins, string asmop> :
927 F16_SP_OPS_u7_aligned<i, outs, ins,
928 !strconcat(asmop, "\t$b3")> {
930 let fieldU = 0b00001;
933 class F16_SP_OPS_buconst<bits<3> i, string asmop> :
934 F16_SP_OPS_u7_aligned<i, (outs), (ins),
935 !strconcat(asmop, "\t%blink")> {
938 let fieldU = 0b10001;
941 class F16_SP_LD<bits<3> i, string asmop> : F16_SP_OPS_u7_aligned<i,
942 (outs GPR32Reduced:$b3), (ins immU<7>:$u7),
943 !strconcat(asmop, "\t$b3, [%sp, $u7]")>;
945 class F16_SP_ST<bits<3> i, string asmop> : F16_SP_OPS_u7_aligned<i,
946 (outs), (ins GPR32Reduced:$b3, immU<7>:$u7),
947 !strconcat(asmop, "\t$b3, [%sp, $u7]")>;
949 // Compact MOV/ADD/CMP Immediate Format.
950 class F16_OP_IMM<bits<5> opc, dag outs, dag ins, string asmstr> :
951 InstARC<2, outs, ins, asmstr, []> {
954 let Inst{15-11} = opc;
958 class F16_OP_U7<bit i, string asmstr> :
959 F16_OP_IMM<0b11100, (outs GPR32:$b), (ins immU<7>:$u7), asmstr> {
966 // Special types for different instruction operands.
967 def ccond : Operand<i32> {
968 let MIOperandInfo = (ops i32imm);
969 let PrintMethod = "printPredicateOperand";
972 def brccond : Operand<i32> {
973 let MIOperandInfo = (ops i32imm);
974 let PrintMethod = "printBRCCPredicateOperand";
977 // Branch/call targets of different offset sizes.
978 class BCTarget<ValueType vt> : Operand<vt> {
979 let OperandType = "OPERAND_PCREL";
982 def btarget : BCTarget<OtherVT>;
984 class BCTargetSigned<ValueType vt, int BSz> : BCTarget<vt> {
985 let DecoderMethod = "DecodeBranchTargetS<"#BSz#">";
988 class BranchTargetS<int BSz> : BCTargetSigned<OtherVT, BSz>;
989 def btargetS7 : BranchTargetS<7>;
990 def btargetS8 : BranchTargetS<8>;
991 def btargetS9 : BranchTargetS<9>;
992 def btargetS10 : BranchTargetS<10>;
993 def btargetS13 : BranchTargetS<13>;
994 def btargetS21 : BranchTargetS<21>;
995 def btargetS25 : BranchTargetS<25>;
997 class CallTargetS<int BSz> : BCTargetSigned<i32, BSz>;
998 def calltargetS25: CallTargetS<25>;
1000 // Compact Branch on Compare Register with Zero.
1001 class F16_BCC_REG<bit i, string asmstr> :
1002 InstARC<2, (outs), (ins GPR32:$b, btargetS8:$s8),
1003 !strconcat(asmstr, "\t$b, 0, $s8"), []> {
1008 let Inst{15-11} = 0b11101;
1011 let Inst{6-0} = s8{7-1};
1015 // Compact Branch Conditionally Format.
1016 class F16_BCC<bits<2> i, dag ins, string asmstr> :
1017 InstARC<2, (outs), ins, asmstr, []> {
1019 let Inst{15-11} = 0b11110;
1023 class F16_BCC_s10<bits<2> i, string asmstr> :
1024 F16_BCC<i, (ins btargetS10:$s),
1025 !strconcat(asmstr, "\t$s")> {
1028 let Inst{8-0} = s{9-1};
1032 class F16_BCC_s7<bits<3> i, string asmstr> :
1033 F16_BCC<0b11, (ins btargetS7:$s),
1034 !strconcat(asmstr, "\t$s")> {
1038 let Inst{5-0} = s{6-1};