1 //==- HexagonInstrFormats.td - Hexagon Instruction Formats --*- 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 // Maintain list of valid subtargets for each instruction.
11 class SubTarget<bits<6> value> {
12 bits<6> Value = value;
15 def HasAnySubT : SubTarget<0x3f>; // 111111
16 def HasV5SubT : SubTarget<0x3e>; // 111110
17 def HasV55SubT : SubTarget<0x3c>; // 111100
18 def HasV60SubT : SubTarget<0x38>; // 111000
20 // Addressing modes for load/store instructions
21 class AddrModeType<bits<3> value> {
22 bits<3> Value = value;
25 def NoAddrMode : AddrModeType<0>; // No addressing mode
26 def Absolute : AddrModeType<1>; // Absolute addressing mode
27 def AbsoluteSet : AddrModeType<2>; // Absolute set addressing mode
28 def BaseImmOffset : AddrModeType<3>; // Indirect with offset
29 def BaseLongOffset : AddrModeType<4>; // Indirect with long offset
30 def BaseRegOffset : AddrModeType<5>; // Indirect with register offset
31 def PostInc : AddrModeType<6>; // Post increment addressing mode
33 class MemAccessSize<bits<4> value> {
34 bits<4> Value = value;
37 // MemAccessSize is represented as 1+log2(N) where N is size in bits.
38 def NoMemAccess : MemAccessSize<0>;// Not a memory access instruction.
39 def ByteAccess : MemAccessSize<1>;// Byte access instruction (memb).
40 def HalfWordAccess : MemAccessSize<2>;// Half word access instruction (memh).
41 def WordAccess : MemAccessSize<3>;// Word access instruction (memw).
42 def DoubleWordAccess : MemAccessSize<4>;// Double word access instruction (memd)
43 def Vector64Access : MemAccessSize<7>;// Vector access instruction (memv)
44 def Vector128Access : MemAccessSize<8>;// Vector access instruction (memv)
47 //===----------------------------------------------------------------------===//
48 // Instruction Class Declaration +
49 //===----------------------------------------------------------------------===//
52 field bits<32> Inst = ?; // Default to an invalid insn.
53 bits<4> IClass = 0; // ICLASS
56 let Inst{31-28} = IClass;
59 class InstHexagon<dag outs, dag ins, string asmstr, list<dag> pattern,
60 string cstr, InstrItinClass itin, IType type>
62 let Namespace = "Hexagon";
64 dag OutOperandList = outs;
65 dag InOperandList = ins;
66 let AsmString = asmstr;
67 let Pattern = pattern;
68 let Constraints = cstr;
72 // SoftFail is a field the disassembler can use to provide a way for
73 // instructions to not match without killing the whole decode process. It is
74 // mainly used for ARM, but Tablegen expects this field to exist or it fails
75 // to build the decode table.
76 field bits<32> SoftFail = 0;
78 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
80 // Instruction type according to the ISA.
82 let TSFlags{5-0} = Type.Value;
84 // Solo instructions, i.e., those that cannot be in a packet with others.
86 let TSFlags{6} = isSolo;
87 // Packed only with A or X-type instructions.
89 let TSFlags{7} = isSoloAX;
90 // Only A-type instruction in first slot or nothing.
91 bits<1> isSoloAin1 = 0;
92 let TSFlags{8} = isSoloAin1;
94 // Predicated instructions.
95 bits<1> isPredicated = 0;
96 let TSFlags{9} = isPredicated;
97 bits<1> isPredicatedFalse = 0;
98 let TSFlags{10} = isPredicatedFalse;
99 bits<1> isPredicatedNew = 0;
100 let TSFlags{11} = isPredicatedNew;
101 bits<1> isPredicateLate = 0;
102 let TSFlags{12} = isPredicateLate; // Late predicate producer insn.
104 // New-value insn helper fields.
105 bits<1> isNewValue = 0;
106 let TSFlags{13} = isNewValue; // New-value consumer insn.
107 bits<1> hasNewValue = 0;
108 let TSFlags{14} = hasNewValue; // New-value producer insn.
109 bits<3> opNewValue = 0;
110 let TSFlags{17-15} = opNewValue; // New-value produced operand.
111 bits<1> isNVStorable = 0;
112 let TSFlags{18} = isNVStorable; // Store that can become new-value store.
113 bits<1> isNVStore = 0;
114 let TSFlags{19} = isNVStore; // New-value store insn.
115 bits<1> isCVLoadable = 0;
116 let TSFlags{20} = isCVLoadable; // Load that can become cur-value load.
117 bits<1> isCVLoad = 0;
118 let TSFlags{21} = isCVLoad; // Cur-value load insn.
120 // Immediate extender helper fields.
121 bits<1> isExtendable = 0;
122 let TSFlags{22} = isExtendable; // Insn may be extended.
123 bits<1> isExtended = 0;
124 let TSFlags{23} = isExtended; // Insn must be extended.
125 bits<3> opExtendable = 0;
126 let TSFlags{26-24} = opExtendable; // Which operand may be extended.
127 bits<1> isExtentSigned = 0;
128 let TSFlags{27} = isExtentSigned; // Signed or unsigned range.
129 bits<5> opExtentBits = 0;
130 let TSFlags{32-28} = opExtentBits; //Number of bits of range before extending.
131 bits<2> opExtentAlign = 0;
132 let TSFlags{34-33} = opExtentAlign; // Alignment exponent before extending.
134 // If an instruction is valid on a subtarget, set the corresponding
135 // bit from validSubTargets.
136 // By default, instruction is valid on all subtargets.
137 SubTarget validSubTargets = HasAnySubT;
138 let TSFlags{40-35} = validSubTargets.Value;
140 // Addressing mode for load/store instructions.
141 AddrModeType addrMode = NoAddrMode;
142 let TSFlags{43-41} = addrMode.Value;
144 // Memory access size for mem access instructions (load/store)
145 MemAccessSize accessSize = NoMemAccess;
146 let TSFlags{47-44} = accessSize.Value;
149 let TSFlags {48} = isTaken; // Branch prediction.
152 let TSFlags {49} = isFP; // Floating-point.
154 bits<1> hasNewValue2 = 0;
155 let TSFlags{51} = hasNewValue2; // Second New-value producer insn.
156 bits<3> opNewValue2 = 0;
157 let TSFlags{54-52} = opNewValue2; // Second New-value produced operand.
159 bits<1> isAccumulator = 0;
160 let TSFlags{55} = isAccumulator;
162 bits<1> prefersSlot3 = 0;
163 let TSFlags{56} = prefersSlot3; // Complex XU
166 let TSFlags{60} = cofMax1;
168 // Fields used for relation models.
169 bit isNonTemporal = 0;
170 string isNT = ""; // set to "true" for non-temporal vector stores.
171 string BaseOpcode = "";
172 string CextOpcode = "";
173 string PredSense = "";
174 string PNewValue = "";
175 string NValueST = ""; // Set to "true" for new-value stores.
176 string InputType = ""; // Input is "imm" or "reg" type.
177 string isFloat = "false"; // Set to "true" for the floating-point load/store.
178 string isBrTaken = !if(isTaken, "true", "false"); // Set to "true"/"false" for jump instructions
180 let PredSense = !if(isPredicated, !if(isPredicatedFalse, "false", "true"),
182 let PNewValue = !if(isPredicatedNew, "new", "");
183 let NValueST = !if(isNVStore, "true", "false");
184 let isNT = !if(isNonTemporal, "true", "false");
186 let hasSideEffects = 0;
187 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
190 class HInst<dag outs, dag ins, string asmstr, InstrItinClass itin, IType type> :
191 InstHexagon<outs, ins, asmstr, [], "", itin, type>;
193 //===----------------------------------------------------------------------===//
194 // Instruction Classes Definitions +
195 //===----------------------------------------------------------------------===//
197 // LD Instruction Class in V2/V3/V4.
198 // Definition of the instruction class NOT CHANGED.
200 class LDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
201 string cstr = "", InstrItinClass itin = LD_tc_ld_SLOT01>
202 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
204 class PseudoLDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
205 string cstr = "", InstrItinClass itin = LD_tc_ld_SLOT01>
206 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
208 class CONSTLDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
210 : PseudoLDInst<outs, ins, asmstr, pattern, cstr>;
212 // LD Instruction Class in V2/V3/V4.
213 // Definition of the instruction class NOT CHANGED.
214 class LDInstPost<dag outs, dag ins, string asmstr, list<dag> pattern = [],
216 : LDInst<outs, ins, asmstr, pattern, cstr>;
219 class LD0Inst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
220 string cstr = "", InstrItinClass itin=LD_tc_ld_SLOT0>
221 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
224 class LD1Inst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
225 string cstr = "", InstrItinClass itin=LD_tc_ld_SLOT0>
226 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>;
228 // ST Instruction Class in V2/V3 can take SLOT0 only.
229 // ST Instruction Class in V4 can take SLOT0 & SLOT1.
230 // Definition of the instruction class CHANGED from V2/V3 to V4.
232 class STInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
233 string cstr = "", InstrItinClass itin = ST_tc_st_SLOT01>
234 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeST>, OpcodeHexagon;
237 class STInst_NoOpcode<dag outs, dag ins, string asmstr, list<dag> pattern = [],
238 string cstr = "", InstrItinClass itin = ST_tc_st_SLOT01>
239 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeST>;
241 class STInst2<dag outs, dag ins, string asmstr, list<dag> pattern = [],
243 : STInst<outs, ins, asmstr, pattern, cstr>;
246 class ST0Inst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
247 string cstr = "", InstrItinClass itin = ST_tc_ld_SLOT0>
248 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeST>, OpcodeHexagon;
250 // Same as ST0Inst but doesn't derive from OpcodeHexagon.
252 class ST1Inst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
253 string cstr = "", InstrItinClass itin = ST_tc_st_SLOT0>
254 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeST>;
256 // ST Instruction Class in V2/V3 can take SLOT0 only.
257 // ST Instruction Class in V4 can take SLOT0 & SLOT1.
258 // Definition of the instruction class CHANGED from V2/V3 to V4.
259 class STInstPost<dag outs, dag ins, string asmstr, list<dag> pattern = [],
260 string cstr = "", InstrItinClass itin = ST_tc_st_SLOT01>
261 : STInst<outs, ins, asmstr, pattern, cstr, itin>;
263 // ALU64 Instruction Class in V2/V3.
264 // XTYPE Instruction Class in V4.
265 // Definition of the instruction class NOT CHANGED.
266 // Name of the Instruction Class changed from ALU64 to XTYPE from V2/V3 to V4.
267 class ALU64Inst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
268 string cstr = "", InstrItinClass itin = ALU64_tc_2_SLOT23>
269 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeALU64>,
272 // ALU64 Instruction Class in V2/V3.
273 // XTYPE Instruction Class in V4.
274 // Definition of the instruction class NOT CHANGED.
275 // Name of the Instruction Class changed from ALU64 to XTYPE from V2/V3 to V4.
276 class ALU64Inst_NoOpcode<dag outs, dag ins, string asmstr, list<dag> pattern = [],
277 string cstr = "", InstrItinClass itin = ALU64_tc_2_SLOT23>
278 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeALU64>;
281 class ALU64_acc<dag outs, dag ins, string asmstr, list<dag> pattern = [],
282 string cstr = "", InstrItinClass itin = ALU64_tc_2_SLOT23>
283 : ALU64Inst<outs, ins, asmstr, pattern, cstr, itin>;
286 // M Instruction Class in V2/V3.
287 // XTYPE Instruction Class in V4.
288 // Definition of the instruction class NOT CHANGED.
289 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
290 class MInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
291 string cstr = "", InstrItinClass itin = M_tc_3x_SLOT23>
292 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeM>,
295 // Same as above but doesn't derive from OpcodeHexagon
296 class MInst2<dag outs, dag ins, string asmstr, list<dag> pattern = [],
297 string cstr = "", InstrItinClass itin = M_tc_3x_SLOT23>
298 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeM>;
300 // M Instruction Class in V2/V3.
301 // XTYPE Instruction Class in V4.
302 // Definition of the instruction class NOT CHANGED.
303 // Name of the Instruction Class changed from M to XTYPE from V2/V3 to V4.
304 class MInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern = [],
305 string cstr = "", InstrItinClass itin = M_tc_2_SLOT23>
306 : MInst<outs, ins, asmstr, pattern, cstr, itin>;
308 // S Instruction Class in V2/V3.
309 // XTYPE Instruction Class in V4.
310 // Definition of the instruction class NOT CHANGED.
311 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
312 class SInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
313 string cstr = "", InstrItinClass itin = S_2op_tc_1_SLOT23>
314 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeS_2op>,
317 class SInst_NoOpcode<dag outs, dag ins, string asmstr, list<dag> pattern = [],
318 string cstr = "", InstrItinClass itin = S_2op_tc_1_SLOT23>
319 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeS_2op>;
321 class SInst2<dag outs, dag ins, string asmstr, list<dag> pattern = [],
322 string cstr = "", InstrItinClass itin = S_2op_tc_1_SLOT23>
323 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeS_2op>;
325 // S Instruction Class in V2/V3.
326 // XTYPE Instruction Class in V4.
327 // Definition of the instruction class NOT CHANGED.
328 // Name of the Instruction Class changed from S to XTYPE from V2/V3 to V4.
329 class SInst_acc<dag outs, dag ins, string asmstr, list<dag> pattern = [],
330 string cstr = "", InstrItinClass itin = S_3op_tc_1_SLOT23>
331 : SInst<outs, ins, asmstr, pattern, cstr, itin> {
332 let Type = TypeS_3op;
335 // J Instruction Class in V2/V3/V4.
336 // Definition of the instruction class NOT CHANGED.
337 class JInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
338 string cstr = "", InstrItinClass itin = J_tc_2early_SLOT23>
339 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeJ>, OpcodeHexagon;
341 class JInst_CJUMP_UCJUMP<dag outs, dag ins, string asmstr, list<dag> pattern = [],
342 string cstr = "", InstrItinClass itin = J_tc_2early_CJUMP_UCJUMP_ARCHDEPSLOT>
343 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeJ>, OpcodeHexagon;
345 // CR Instruction Class in V2/V3/V4.
346 // Definition of the instruction class NOT CHANGED.
347 class CRInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
348 string cstr = "", InstrItinClass itin = CR_tc_2early_SLOT3>
349 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeCR>, OpcodeHexagon;
351 let isCodeGenOnly = 1, isPseudo = 1 in
352 class Endloop<dag outs, dag ins, string asmstr, list<dag> pattern = [],
353 string cstr = "", InstrItinClass itin = J_tc_2early_SLOT0123>
354 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeENDLOOP>,
357 let isCodeGenOnly = 1, isPseudo = 1 in
358 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern = [],
360 : InstHexagon<outs, ins, asmstr, pattern, cstr, PSEUDO, TypePSEUDO>,
363 let isCodeGenOnly = 1, isPseudo = 1 in
364 class PseudoM<dag outs, dag ins, string asmstr, list<dag> pattern = [],
366 : InstHexagon<outs, ins, asmstr, pattern, cstr, PSEUDOM, TypePSEUDO>,
369 //===----------------------------------------------------------------------===//
370 // Instruction Classes Definitions -
371 //===----------------------------------------------------------------------===//
376 class ALU64_rr<dag outs, dag ins, string asmstr, list<dag> pattern = [],
377 string cstr = "", InstrItinClass itin = ALU64_tc_1_SLOT23>
378 : ALU64Inst<outs, ins, asmstr, pattern, cstr, itin>;
380 class ALU64_ri<dag outs, dag ins, string asmstr, list<dag> pattern = [],
381 string cstr = "", InstrItinClass itin = ALU64_tc_1_SLOT23>
382 : ALU64Inst<outs, ins, asmstr, pattern, cstr, itin>;
384 // Post increment ST Instruction.
385 class STInstPI<dag outs, dag ins, string asmstr, list<dag> pattern = [],
387 : STInst<outs, ins, asmstr, pattern, cstr>;
389 // Post increment LD Instruction.
390 class LDInstPI<dag outs, dag ins, string asmstr, list<dag> pattern = [],
392 : LDInst<outs, ins, asmstr, pattern, cstr>;
394 //===----------------------------------------------------------------------===//
395 // V4 Instruction Format Definitions +
396 //===----------------------------------------------------------------------===//
398 include "HexagonInstrFormatsV4.td"
400 //===----------------------------------------------------------------------===//
401 // V4 Instruction Format Definitions +
402 //===----------------------------------------------------------------------===//
404 //===----------------------------------------------------------------------===//
405 // V60 Instruction Format Definitions +
406 //===----------------------------------------------------------------------===//
408 include "HexagonInstrFormatsV60.td"
410 //===----------------------------------------------------------------------===//
411 // V60 Instruction Format Definitions +
412 //===----------------------------------------------------------------------===//