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
174 // New-Value producer-2 instructions.
177 // Which operand consumes or produces a new value.
180
181 // Accumulator instructions.
184
185 // Complex XU, prevent xu competition by preferring slot3
188
190
193
196
199
202
205
208 };
209
210 inline bool getTSFlag(const MCInstrDesc &MID, HexagonTSFlagsVal Pos) {
211 return (MID.TSFlags >> Pos) & 1;
212 }
213
214 // *** The code above must match HexagonInstrFormat*.td *** //
215
216 // Hexagon specific MO operand flag mask.
218 // Hexagon-specific MachineOperand target flags.
219 //
220 // When changing these, make sure to update
221 // getSerializableDirectMachineOperandTargetFlags and
222 // getSerializableBitmaskMachineOperandTargetFlags if needed.
224
225 /// MO_PCREL - On a symbol operand, indicates a PC-relative relocation
226 /// Used for computing a global address for PIC compilations
228
229 /// MO_GOT - Indicates a GOT-relative relocation
231
232 // Low or high part of a symbol.
235
236 // Offset from the base of the SDA.
238
239 // MO_GDGOT - indicates GOT relative relocation for TLS
240 // GeneralDynamic method
242
243 // MO_GDPLT - indicates PLT relative relocation for TLS
244 // GeneralDynamic method
246
247 // MO_IE - indicates non PIC relocation for TLS
248 // Initial Executable method
250
251 // MO_IEGOT - indicates PIC relocation for TLS
252 // Initial Executable method
254
255 // MO_TPREL - indicates relocation for TLS
256 // local Executable method
258
259 // HMOTF_ConstExtended
260 // Addendum to above, indicates a const extended op
261 // Can be used as a mask.
263
264 // Union of all bitmasks (currently only HMOTF_ConstExtended).
266 };
267
268 // Hexagon Sub-instruction classes.
278
279 // Hexagon Compound classes.
286
288 INST_PARSE_MASK = 0x0000c000,
291 INST_PARSE_NOT_END = 0x00004000,
292 INST_PARSE_DUPLEX = 0x00000000,
294 };
295
296 enum InstIClassBits : unsigned {
297 INST_ICLASS_MASK = 0xf0000000,
299 INST_ICLASS_J_1 = 0x10000000,
300 INST_ICLASS_J_2 = 0x20000000,
303 INST_ICLASS_J_3 = 0x50000000,
304 INST_ICLASS_CR = 0x60000000,
307 INST_ICLASS_LD = 0x90000000,
308 INST_ICLASS_ST = 0xa0000000,
314 };
315
316 [[maybe_unused]]
318 switch (S) {
319 case ByteAccess: return 1;
320 case HalfWordAccess: return 2;
321 case WordAccess: return 4;
322 case DoubleWordAccess: return 8;
323 default: return 0;
324 }
325 }
326} // end namespace HexagonII
327
328} // end namespace llvm
329
330#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.