LLVM 24.0.0git
HexagonBaseInfo.h
Go to the documentation of this file.
1//===- HexagonBaseInfo.h - Top level definitions for Hexagon ----*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains small standalone helper functions and enum definitions for
10// the Hexagon target useful for the compiler back-end and the MC libraries.
11// As such, it deliberately does not include references to LLVM core
12// code gen types, passes, etc..
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
17#define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
18
19#include <cstdint>
20
21#include "HexagonDepITypes.h"
23#include "llvm/MC/MCInstrDesc.h"
24
25namespace llvm {
26
27/// HexagonII - This namespace holds all of the target specific flags that
28/// instruction info tracks.
29namespace HexagonII {
31 unsigned const TypeCVI_LAST = TypeCVI_ZW;
32
33 enum AddrMode {
34 NoAddrMode = 0, // No addressing mode
35 Absolute = 1, // Absolute addressing mode
36 AbsoluteSet = 2, // Absolute set addressing mode
37 BaseImmOffset = 3, // Indirect with offset
38 BaseLongOffset = 4, // Indirect with long offset
39 BaseRegOffset = 5, // Indirect with register offset
40 PostInc = 6 // Post increment addressing mode
41 };
42
52
53 enum class RegType : uint8_t {
57 };
58
65
66 RegTypeInfo getRegTypeInfo(unsigned Opcode);
67
68 inline RegType getOpRegType(unsigned Opcode) {
69 return getRegTypeInfo(Opcode).Output;
70 }
71 inline RegType getInp1RegType(unsigned Opcode) {
72 return getRegTypeInfo(Opcode).Input1;
73 }
74 inline RegType getInp2RegType(unsigned Opcode) {
75 return getRegTypeInfo(Opcode).Input2;
76 }
77 inline RegType getInp3RegType(unsigned Opcode) {
78 return getRegTypeInfo(Opcode).Input3;
79 }
80
81 // MCInstrDesc TSFlags
82 // *** Must match HexagonInstrFormat*.td ***
84 // This 7-bit field describes the insn type.
86 TypeMask = 0x7f,
87
88 // Solo instructions.
90 SoloMask = 0x1,
91 // Packed only with A or X-type instructions.
94 // Only A-type instruction in first slot or nothing.
97
98 // Predicated instructions.
107
108 // New-Value consumer instructions.
111 // New-Value producer instructions.
114 // Which operand consumes or produces a new value.
117 // Stores that can become new-value stores.
120 // New-value store instructions.
123 // Loads that can become current-value loads.
126 // Current-value load instructions.
129
130 // Extendable insns.
133 // Insns must be extended.
136 // Which operand may be extended.
139 // Signed or unsigned range.
142 // Number of bits of range before extending operand.
145 // Alignment power-of-two before extending operand.
148
155
158
159 // Addressing mode for load/store instructions.
162 // Access size for load/store instructions.
165
166 // Branch predicted taken.
169
170 // Floating-point instructions.
171 FPPos = 48,
172 FPMask = 0x1,
173
175
176 // New-Value producer-2 instructions.
179 // Which operand consumes or produces a new value.
182
183 // Accumulator instructions.
186
187 // Complex XU, prevent xu competition by preferring slot3
190
192
194
197
200
203
206
208
211 };
212
213 inline bool getTSFlag(const MCInstrDesc &MID, HexagonTSFlagsVal Pos) {
214 return (MID.TSFlags >> Pos) & 1;
215 }
216
217 // *** The code above must match HexagonInstrFormat*.td *** //
218
219 // Hexagon specific MO operand flag mask.
221 // Hexagon-specific MachineOperand target flags.
222 //
223 // When changing these, make sure to update
224 // getSerializableDirectMachineOperandTargetFlags and
225 // getSerializableBitmaskMachineOperandTargetFlags if needed.
227
228 /// MO_PCREL - On a symbol operand, indicates a PC-relative relocation
229 /// Used for computing a global address for PIC compilations
231
232 /// MO_GOT - Indicates a GOT-relative relocation
234
235 // Low or high part of a symbol.
238
239 // Offset from the base of the SDA.
241
242 // MO_GDGOT - indicates GOT relative relocation for TLS
243 // GeneralDynamic method
245
246 // MO_GDPLT - indicates PLT relative relocation for TLS
247 // GeneralDynamic method
249
250 // MO_IE - indicates non PIC relocation for TLS
251 // Initial Executable method
253
254 // MO_IEGOT - indicates PIC relocation for TLS
255 // Initial Executable method
257
258 // MO_TPREL - indicates relocation for TLS
259 // local Executable method
261
262 // HMOTF_ConstExtended
263 // Addendum to above, indicates a const extended op
264 // Can be used as a mask.
266
267 // Union of all bitmasks (currently only HMOTF_ConstExtended).
269 };
270
271 // Hexagon Sub-instruction classes.
281
282 // Hexagon Compound classes.
289
291 INST_PARSE_MASK = 0x0000c000,
294 INST_PARSE_NOT_END = 0x00004000,
295 INST_PARSE_DUPLEX = 0x00000000,
297 };
298
299 enum InstIClassBits : unsigned {
300 INST_ICLASS_MASK = 0xf0000000,
302 INST_ICLASS_J_1 = 0x10000000,
303 INST_ICLASS_J_2 = 0x20000000,
306 INST_ICLASS_J_3 = 0x50000000,
307 INST_ICLASS_CR = 0x60000000,
310 INST_ICLASS_LD = 0x90000000,
311 INST_ICLASS_ST = 0xa0000000,
317 };
318
319 [[maybe_unused]]
321 switch (S) {
322 case ByteAccess: return 1;
323 case HalfWordAccess: return 2;
324 case WordAccess: return 4;
325 case DoubleWordAccess: return 8;
326 default: return 0;
327 }
328 }
329} // end namespace HexagonII
330
331} // end namespace llvm
332
333#endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
Describe properties that are true of each instruction in the target description file.
HexagonII - This namespace holds all of the target specific flags that instruction info tracks.
unsigned const TypeCVI_LAST
RegType getInp1RegType(unsigned Opcode)
static unsigned getMemAccessSizeInBytes(MemAccessSize S)
unsigned const TypeCVI_FIRST
RegType getInp3RegType(unsigned Opcode)
RegType getInp2RegType(unsigned Opcode)
RegType getOpRegType(unsigned Opcode)
RegTypeInfo getRegTypeInfo(unsigned Opcode)
@ MO_PCREL
MO_PCREL - On a symbol operand, indicates a PC-relative relocation Used for computing a global addres...
@ MO_GOT
MO_GOT - Indicates a GOT-relative relocation.
bool getTSFlag(const MCInstrDesc &MID, HexagonTSFlagsVal Pos)
This is an optimization pass for GlobalISel generic memory operations.