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
209
212 };
213
214 inline bool getTSFlag(const MCInstrDesc &MID, HexagonTSFlagsVal Pos) {
215 return (MID.TSFlags >> Pos) & 1;
216 }
217
218 // *** The code above must match HexagonInstrFormat*.td *** //
219
220 // Hexagon specific MO operand flag mask.
222 // Hexagon-specific MachineOperand target flags.
223 //
224 // When changing these, make sure to update
225 // getSerializableDirectMachineOperandTargetFlags and
226 // getSerializableBitmaskMachineOperandTargetFlags if needed.
228
229 /// MO_PCREL - On a symbol operand, indicates a PC-relative relocation
230 /// Used for computing a global address for PIC compilations
232
233 /// MO_GOT - Indicates a GOT-relative relocation
235
236 // Low or high part of a symbol.
239
240 // Offset from the base of the SDA.
242
243 // MO_GDGOT - indicates GOT relative relocation for TLS
244 // GeneralDynamic method
246
247 // MO_GDPLT - indicates PLT relative relocation for TLS
248 // GeneralDynamic method
250
251 // MO_IE - indicates non PIC relocation for TLS
252 // Initial Executable method
254
255 // MO_IEGOT - indicates PIC relocation for TLS
256 // Initial Executable method
258
259 // MO_TPREL - indicates relocation for TLS
260 // local Executable method
262
263 // HMOTF_ConstExtended
264 // Addendum to above, indicates a const extended op
265 // Can be used as a mask.
267
268 // Union of all bitmasks (currently only HMOTF_ConstExtended).
270 };
271
272 // Hexagon Sub-instruction classes.
282
283 // Hexagon Compound classes.
290
292 INST_PARSE_MASK = 0x0000c000,
295 INST_PARSE_NOT_END = 0x00004000,
296 INST_PARSE_DUPLEX = 0x00000000,
298 };
299
300 enum InstIClassBits : unsigned {
301 INST_ICLASS_MASK = 0xf0000000,
303 INST_ICLASS_J_1 = 0x10000000,
304 INST_ICLASS_J_2 = 0x20000000,
307 INST_ICLASS_J_3 = 0x50000000,
308 INST_ICLASS_CR = 0x60000000,
311 INST_ICLASS_LD = 0x90000000,
312 INST_ICLASS_ST = 0xa0000000,
318 };
319
320 [[maybe_unused]]
322 switch (S) {
323 case ByteAccess: return 1;
324 case HalfWordAccess: return 2;
325 case WordAccess: return 4;
326 case DoubleWordAccess: return 8;
327 default: return 0;
328 }
329 }
330} // end namespace HexagonII
331
332} // end namespace llvm
333
334#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.