1 //==- HexagonInstrFormats.td - Hexagon 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 // Addressing modes for load/store instructions
10 class AddrModeType<bits<3> value> {
11 bits<3> Value = value;
14 def NoAddrMode : AddrModeType<0>; // No addressing mode
15 def Absolute : AddrModeType<1>; // Absolute addressing mode
16 def AbsoluteSet : AddrModeType<2>; // Absolute set addressing mode
17 def BaseImmOffset : AddrModeType<3>; // Indirect with offset
18 def BaseLongOffset : AddrModeType<4>; // Indirect with long offset
19 def BaseRegOffset : AddrModeType<5>; // Indirect with register offset
20 def PostInc : AddrModeType<6>; // Post increment addressing mode
22 class MemAccessSize<bits<4> value> {
23 bits<4> Value = value;
26 // These numbers must match the MemAccessSize enumeration values in
28 def NoMemAccess : MemAccessSize<0>;
29 def ByteAccess : MemAccessSize<1>;
30 def HalfWordAccess : MemAccessSize<2>;
31 def WordAccess : MemAccessSize<3>;
32 def DoubleWordAccess : MemAccessSize<4>;
33 def HVXVectorAccess : MemAccessSize<5>;
36 //===----------------------------------------------------------------------===//
37 // Instruction Class Declaration +
38 //===----------------------------------------------------------------------===//
40 // "Parse" bits are explicitly NOT defined in the opcode space to prevent
41 // TableGen from using them for generation of the decoder tables.
43 field bits<32> Inst = ?; // Default to an invalid insn.
44 bits<4> IClass = 0; // ICLASS
47 let Inst{31-28} = IClass;
50 class InstHexagon<dag outs, dag ins, string asmstr, list<dag> pattern,
51 string cstr, InstrItinClass itin, IType type>
53 let Namespace = "Hexagon";
55 dag OutOperandList = outs;
56 dag InOperandList = ins;
57 let AsmString = asmstr;
58 let Pattern = pattern;
59 let Constraints = cstr;
63 // SoftFail is a field the disassembler can use to provide a way for
64 // instructions to not match without killing the whole decode process. It is
65 // mainly used for ARM, but Tablegen expects this field to exist or it fails
66 // to build the decode table.
67 field bits<32> SoftFail = 0;
69 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
71 // Instruction type according to the ISA.
73 let TSFlags{6-0} = Type.Value;
75 // Solo instructions, i.e., those that cannot be in a packet with others.
77 let TSFlags{7} = isSolo;
78 // Packed only with A or X-type instructions.
80 let TSFlags{8} = isSoloAX;
81 // Restricts slot 1 to ALU-only instructions.
82 bits<1> isRestrictSlot1AOK = 0;
83 let TSFlags{9} = isRestrictSlot1AOK;
85 // Predicated instructions.
86 bits<1> isPredicated = 0;
87 let TSFlags{10} = isPredicated;
88 bits<1> isPredicatedFalse = 0;
89 let TSFlags{11} = isPredicatedFalse;
90 bits<1> isPredicatedNew = 0;
91 let TSFlags{12} = isPredicatedNew;
92 bits<1> isPredicateLate = 0;
93 let TSFlags{13} = isPredicateLate; // Late predicate producer insn.
95 // New-value insn helper fields.
96 bits<1> isNewValue = 0;
97 let TSFlags{14} = isNewValue; // New-value consumer insn.
98 bits<1> hasNewValue = 0;
99 let TSFlags{15} = hasNewValue; // New-value producer insn.
100 bits<3> opNewValue = 0;
101 let TSFlags{18-16} = opNewValue; // New-value produced operand.
102 bits<1> isNVStorable = 0;
103 let TSFlags{19} = isNVStorable; // Store that can become new-value store.
104 bits<1> isNVStore = 0;
105 let TSFlags{20} = isNVStore; // New-value store insn.
106 bits<1> isCVLoadable = 0;
107 let TSFlags{21} = isCVLoadable; // Load that can become cur-value load.
108 bits<1> isCVLoad = 0;
109 let TSFlags{22} = isCVLoad; // Cur-value load insn.
111 // Immediate extender helper fields.
112 bits<1> isExtendable = 0;
113 let TSFlags{23} = isExtendable; // Insn may be extended.
114 bits<1> isExtended = 0;
115 let TSFlags{24} = isExtended; // Insn must be extended.
116 bits<3> opExtendable = 0;
117 let TSFlags{27-25} = opExtendable; // Which operand may be extended.
118 bits<1> isExtentSigned = 0;
119 let TSFlags{28} = isExtentSigned; // Signed or unsigned range.
120 bits<5> opExtentBits = 0;
121 let TSFlags{33-29} = opExtentBits; //Number of bits of range before extending.
122 bits<2> opExtentAlign = 0;
123 let TSFlags{35-34} = opExtentAlign; // Alignment exponent before extending.
126 let TSFlags{36} = cofMax1;
128 let TSFlags{37} = cofRelax1;
130 let TSFlags{38} = cofRelax2;
132 bit isRestrictNoSlot1Store = 0;
133 let TSFlags{39} = isRestrictNoSlot1Store;
135 // Addressing mode for load/store instructions.
136 AddrModeType addrMode = NoAddrMode;
137 let TSFlags{42-40} = addrMode.Value;
139 // Memory access size for mem access instructions (load/store)
140 MemAccessSize accessSize = NoMemAccess;
141 let TSFlags{46-43} = accessSize.Value;
144 let TSFlags {47} = isTaken; // Branch prediction.
147 let TSFlags {48} = isFP; // Floating-point.
149 bits<1> hasNewValue2 = 0;
150 let TSFlags{50} = hasNewValue2; // Second New-value producer insn.
151 bits<3> opNewValue2 = 0;
152 let TSFlags{53-51} = opNewValue2; // Second New-value produced operand.
154 bits<1> isAccumulator = 0;
155 let TSFlags{54} = isAccumulator;
157 bits<1> prefersSlot3 = 0;
158 let TSFlags{55} = prefersSlot3; // Complex XU
160 bits<1> hasHvxTmp = 0;
161 let TSFlags{56} = hasHvxTmp; // vector register vX.tmp false-write
164 let TSFlags{58} = CVINew;
167 let TSFlags{59} = isCVI;
170 let TSFlags{60} = isHVXALU;
172 bit isHVXALU2SRC = 0;
173 let TSFlags{61} = isHVXALU2SRC;
175 bit hasUnaryRestriction = 0;
176 let TSFlags{62} = hasUnaryRestriction;
178 // Fields used for relation models.
179 bit isNonTemporal = 0;
180 string isNT = ""; // set to "true" for non-temporal vector stores.
181 string BaseOpcode = "";
182 string CextOpcode = "";
183 string PredSense = "";
184 string PNewValue = "";
185 string NValueST = ""; // Set to "true" for new-value stores.
186 string InputType = ""; // Input is "imm" or "reg" type.
187 string isFloat = "false"; // Set to "true" for the floating-point load/store.
188 string isBrTaken = !if(isTaken, "true", "false"); // Set to "true"/"false" for jump instructions
190 let PredSense = !if(isPredicated, !if(isPredicatedFalse, "false", "true"),
192 let PNewValue = !if(isPredicatedNew, "new", "");
193 let NValueST = !if(isNVStore, "true", "false");
194 let isNT = !if(isNonTemporal, "true", "false");
196 let hasSideEffects = 0;
197 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
200 class HInst<dag outs, dag ins, string asmstr, InstrItinClass itin, IType type> :
201 InstHexagon<outs, ins, asmstr, [], "", itin, type>;
203 //===----------------------------------------------------------------------===//
204 // Instruction Classes Definitions +
205 //===----------------------------------------------------------------------===//
208 class LDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
209 string cstr = "", InstrItinClass itin = LD_tc_ld_SLOT01>
210 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
212 class CONSTLDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
213 string cstr = "", InstrItinClass itin = LD_tc_ld_SLOT01>
214 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
217 class STInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
218 string cstr = "", InstrItinClass itin = ST_tc_st_SLOT01>
219 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeST>, OpcodeHexagon;
221 let isCodeGenOnly = 1, isPseudo = 1 in
222 class Endloop<dag outs, dag ins, string asmstr, list<dag> pattern = [],
223 string cstr = "", InstrItinClass itin = tc_ENDLOOP>
224 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeENDLOOP>,
227 let isCodeGenOnly = 1, isPseudo = 1 in
228 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern = [],
230 : InstHexagon<outs, ins, asmstr, pattern, cstr, PSEUDO, TypePSEUDO>,
233 let isCodeGenOnly = 1, isPseudo = 1 in
234 class PseudoM<dag outs, dag ins, string asmstr, list<dag> pattern = [],
236 : InstHexagon<outs, ins, asmstr, pattern, cstr, PSEUDOM, TypePSEUDO>,
239 //===----------------------------------------------------------------------===//
240 // Special Instructions -
241 //===----------------------------------------------------------------------===//
243 // The 'invalid_decode' instruction is used by the disassembler to
244 // show an instruction that didn't decode correctly. This feature
245 // is only leveraged in a special disassembler mode that's activated
246 // by a command line flag.
247 def tc_invalid : InstrItinClass;
248 class Enc_invalid : OpcodeHexagon {
250 def invalid_decode : HInst<
254 tc_invalid, TypeALU32_2op>, Enc_invalid {
255 let Inst{13-0} = 0b00000000000000;
256 let Inst{31-16} = 0b0000000000000000;
257 let isCodeGenOnly = 1;
260 //===----------------------------------------------------------------------===//
261 // Duplex Instruction Class Declaration
262 //===----------------------------------------------------------------------===//
265 field bits<32> Inst = ?; // Default to an invalid insn.
266 bits<4> IClass = 0; // ICLASS
267 bits<13> ISubHi = 0; // Low sub-insn
268 bits<13> ISubLo = 0; // High sub-insn
270 let Inst{31-29} = IClass{3-1};
271 let Inst{13} = IClass{0};
273 let Inst{28-16} = ISubHi;
274 let Inst{12-0} = ISubLo;
277 class InstDuplex<bits<4> iClass, string cstr = ""> : Instruction,
279 let Namespace = "Hexagon";
280 IType Type = TypeDUPLEX; // uses slot 0,1
281 let isCodeGenOnly = 1;
282 let hasSideEffects = 0;
283 dag OutOperandList = (outs);
284 dag InOperandList = (ins);
286 let Constraints = cstr;
287 let Itinerary = DUPLEX;
290 // SoftFail is a field the disassembler can use to provide a way for
291 // instructions to not match without killing the whole decode process. It is
292 // mainly used for ARM, but Tablegen expects this field to exist or it fails
293 // to build the decode table.
294 field bits<32> SoftFail = 0;
296 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
298 let TSFlags{6-0} = Type.Value;
300 // Predicated instructions.
301 bits<1> isPredicated = 0;
302 let TSFlags{7} = isPredicated;
303 bits<1> isPredicatedFalse = 0;
304 let TSFlags{8} = isPredicatedFalse;
305 bits<1> isPredicatedNew = 0;
306 let TSFlags{9} = isPredicatedNew;
308 // New-value insn helper fields.
309 bits<1> isNewValue = 0;
310 let TSFlags{10} = isNewValue; // New-value consumer insn.
311 bits<1> hasNewValue = 0;
312 let TSFlags{11} = hasNewValue; // New-value producer insn.
313 bits<3> opNewValue = 0;
314 let TSFlags{14-12} = opNewValue; // New-value produced operand.
315 bits<1> isNVStorable = 0;
316 let TSFlags{15} = isNVStorable; // Store that can become new-value store.
317 bits<1> isNVStore = 0;
318 let TSFlags{16} = isNVStore; // New-value store insn.
320 // Immediate extender helper fields.
321 bits<1> isExtendable = 0;
322 let TSFlags{17} = isExtendable; // Insn may be extended.
323 bits<1> isExtended = 0;
324 let TSFlags{18} = isExtended; // Insn must be extended.
325 bits<3> opExtendable = 0;
326 let TSFlags{21-19} = opExtendable; // Which operand may be extended.
327 bits<1> isExtentSigned = 0;
328 let TSFlags{22} = isExtentSigned; // Signed or unsigned range.
329 bits<5> opExtentBits = 0;
330 let TSFlags{27-23} = opExtentBits; //Number of bits of range before extending.
331 bits<2> opExtentAlign = 0;
332 let TSFlags{29-28} = opExtentAlign; // Alignment exponent before extending.
335 //===----------------------------------------------------------------------===//
336 // Instruction Classes Definitions -
337 //===----------------------------------------------------------------------===//
339 include "HexagonInstrFormatsV60.td"
340 include "HexagonInstrFormatsV65.td"