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 //===----------------------------------------------------------------------===//
41 field bits<32> Inst = ?; // Default to an invalid insn.
42 bits<4> IClass = 0; // ICLASS
45 let Inst{31-28} = IClass;
48 class InstHexagon<dag outs, dag ins, string asmstr, list<dag> pattern,
49 string cstr, InstrItinClass itin, IType type>
51 let Namespace = "Hexagon";
53 dag OutOperandList = outs;
54 dag InOperandList = ins;
55 let AsmString = asmstr;
56 let Pattern = pattern;
57 let Constraints = cstr;
61 // SoftFail is a field the disassembler can use to provide a way for
62 // instructions to not match without killing the whole decode process. It is
63 // mainly used for ARM, but Tablegen expects this field to exist or it fails
64 // to build the decode table.
65 field bits<32> SoftFail = 0;
67 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
69 // Instruction type according to the ISA.
71 let TSFlags{6-0} = Type.Value;
73 // Solo instructions, i.e., those that cannot be in a packet with others.
75 let TSFlags{7} = isSolo;
76 // Packed only with A or X-type instructions.
78 let TSFlags{8} = isSoloAX;
79 // Restricts slot 1 to ALU-only instructions.
80 bits<1> isRestrictSlot1AOK = 0;
81 let TSFlags{9} = isRestrictSlot1AOK;
83 // Predicated instructions.
84 bits<1> isPredicated = 0;
85 let TSFlags{10} = isPredicated;
86 bits<1> isPredicatedFalse = 0;
87 let TSFlags{11} = isPredicatedFalse;
88 bits<1> isPredicatedNew = 0;
89 let TSFlags{12} = isPredicatedNew;
90 bits<1> isPredicateLate = 0;
91 let TSFlags{13} = isPredicateLate; // Late predicate producer insn.
93 // New-value insn helper fields.
94 bits<1> isNewValue = 0;
95 let TSFlags{14} = isNewValue; // New-value consumer insn.
96 bits<1> hasNewValue = 0;
97 let TSFlags{15} = hasNewValue; // New-value producer insn.
98 bits<3> opNewValue = 0;
99 let TSFlags{18-16} = opNewValue; // New-value produced operand.
100 bits<1> isNVStorable = 0;
101 let TSFlags{19} = isNVStorable; // Store that can become new-value store.
102 bits<1> isNVStore = 0;
103 let TSFlags{20} = isNVStore; // New-value store insn.
104 bits<1> isCVLoadable = 0;
105 let TSFlags{21} = isCVLoadable; // Load that can become cur-value load.
106 bits<1> isCVLoad = 0;
107 let TSFlags{22} = isCVLoad; // Cur-value load insn.
109 // Immediate extender helper fields.
110 bits<1> isExtendable = 0;
111 let TSFlags{23} = isExtendable; // Insn may be extended.
112 bits<1> isExtended = 0;
113 let TSFlags{24} = isExtended; // Insn must be extended.
114 bits<3> opExtendable = 0;
115 let TSFlags{27-25} = opExtendable; // Which operand may be extended.
116 bits<1> isExtentSigned = 0;
117 let TSFlags{28} = isExtentSigned; // Signed or unsigned range.
118 bits<5> opExtentBits = 0;
119 let TSFlags{33-29} = opExtentBits; //Number of bits of range before extending.
120 bits<2> opExtentAlign = 0;
121 let TSFlags{35-34} = opExtentAlign; // Alignment exponent before extending.
124 let TSFlags{36} = cofMax1;
126 let TSFlags{37} = cofRelax1;
128 let TSFlags{38} = cofRelax2;
130 bit isRestrictNoSlot1Store = 0;
131 let TSFlags{39} = isRestrictNoSlot1Store;
133 // Addressing mode for load/store instructions.
134 AddrModeType addrMode = NoAddrMode;
135 let TSFlags{44-42} = addrMode.Value;
137 // Memory access size for mem access instructions (load/store)
138 MemAccessSize accessSize = NoMemAccess;
139 let TSFlags{48-45} = accessSize.Value;
142 let TSFlags {49} = isTaken; // Branch prediction.
145 let TSFlags {50} = isFP; // Floating-point.
147 bits<1> isSomeOK = 0;
148 let TSFlags {51} = isSomeOK; // Relax some grouping constraints.
150 bits<1> hasNewValue2 = 0;
151 let TSFlags{52} = hasNewValue2; // Second New-value producer insn.
152 bits<3> opNewValue2 = 0;
153 let TSFlags{55-53} = opNewValue2; // Second New-value produced operand.
155 bits<1> isAccumulator = 0;
156 let TSFlags{56} = isAccumulator;
158 bits<1> prefersSlot3 = 0;
159 let TSFlags{57} = prefersSlot3; // Complex XU
161 bits<1> hasTmpDst = 0;
162 let TSFlags{60} = hasTmpDst; // v65 : 'fake" register VTMP is set
165 let TSFlags{62} = CVINew;
167 // Fields used for relation models.
168 bit isNonTemporal = 0;
169 string isNT = ""; // set to "true" for non-temporal vector stores.
170 string BaseOpcode = "";
171 string CextOpcode = "";
172 string PredSense = "";
173 string PNewValue = "";
174 string NValueST = ""; // Set to "true" for new-value stores.
175 string InputType = ""; // Input is "imm" or "reg" type.
176 string isFloat = "false"; // Set to "true" for the floating-point load/store.
177 string isBrTaken = !if(isTaken, "true", "false"); // Set to "true"/"false" for jump instructions
179 let PredSense = !if(isPredicated, !if(isPredicatedFalse, "false", "true"),
181 let PNewValue = !if(isPredicatedNew, "new", "");
182 let NValueST = !if(isNVStore, "true", "false");
183 let isNT = !if(isNonTemporal, "true", "false");
185 let hasSideEffects = 0;
186 // *** Must match MCTargetDesc/HexagonBaseInfo.h ***
189 class HInst<dag outs, dag ins, string asmstr, InstrItinClass itin, IType type> :
190 InstHexagon<outs, ins, asmstr, [], "", itin, type>;
192 //===----------------------------------------------------------------------===//
193 // Instruction Classes Definitions +
194 //===----------------------------------------------------------------------===//
197 class LDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
198 string cstr = "", InstrItinClass itin = LD_tc_ld_SLOT01>
199 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
201 class CONSTLDInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
202 string cstr = "", InstrItinClass itin = LD_tc_ld_SLOT01>
203 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeLD>, OpcodeHexagon;
206 class STInst<dag outs, dag ins, string asmstr, list<dag> pattern = [],
207 string cstr = "", InstrItinClass itin = ST_tc_st_SLOT01>
208 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeST>, OpcodeHexagon;
210 let isCodeGenOnly = 1, isPseudo = 1 in
211 class Endloop<dag outs, dag ins, string asmstr, list<dag> pattern = [],
212 string cstr = "", InstrItinClass itin = tc_ENDLOOP>
213 : InstHexagon<outs, ins, asmstr, pattern, cstr, itin, TypeENDLOOP>,
216 let isCodeGenOnly = 1, isPseudo = 1 in
217 class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern = [],
219 : InstHexagon<outs, ins, asmstr, pattern, cstr, PSEUDO, TypePSEUDO>,
222 let isCodeGenOnly = 1, isPseudo = 1 in
223 class PseudoM<dag outs, dag ins, string asmstr, list<dag> pattern = [],
225 : InstHexagon<outs, ins, asmstr, pattern, cstr, PSEUDOM, TypePSEUDO>,
228 //===----------------------------------------------------------------------===//
229 // Instruction Classes Definitions -
230 //===----------------------------------------------------------------------===//
232 include "HexagonInstrFormatsV5.td"
233 include "HexagonInstrFormatsV60.td"
234 include "HexagonInstrFormatsV65.td"