LLVM 23.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
24namespace llvm {
25
26/// HexagonII - This namespace holds all of the target specific flags that
27/// instruction info tracks.
28namespace HexagonII {
30 unsigned const TypeCVI_LAST = TypeCVI_ZW;
31
32 enum AddrMode {
33 NoAddrMode = 0, // No addressing mode
34 Absolute = 1, // Absolute addressing mode
35 AbsoluteSet = 2, // Absolute set addressing mode
36 BaseImmOffset = 3, // Indirect with offset
37 BaseLongOffset = 4, // Indirect with long offset
38 BaseRegOffset = 5, // Indirect with register offset
39 PostInc = 6 // Post increment addressing mode
40 };
41
50
51 enum class RegType : uint8_t {
55 };
56
63
64 RegTypeInfo getRegTypeInfo(unsigned Opcode);
65
66 inline RegType getOpRegType(unsigned Opcode) {
67 return getRegTypeInfo(Opcode).Output;
68 }
69 inline RegType getInp1RegType(unsigned Opcode) {
70 return getRegTypeInfo(Opcode).Input1;
71 }
72 inline RegType getInp2RegType(unsigned Opcode) {
73 return getRegTypeInfo(Opcode).Input2;
74 }
75 inline RegType getInp3RegType(unsigned Opcode) {
76 return getRegTypeInfo(Opcode).Input3;
77 }
78
79 // MCInstrDesc TSFlags
80 // *** Must match HexagonInstrFormat*.td ***
81 enum {
82 // This 7-bit field describes the insn type.
84 TypeMask = 0x7f,
85
86 // Solo instructions.
88 SoloMask = 0x1,
89 // Packed only with A or X-type instructions.
92 // Only A-type instruction in first slot or nothing.
95
96 // Predicated instructions.
105
106 // New-Value consumer instructions.
109 // New-Value producer instructions.
112 // Which operand consumes or produces a new value.
115 // Stores that can become new-value stores.
118 // New-value store instructions.
121 // Loads that can become current-value loads.
124 // Current-value load instructions.
127
128 // Extendable insns.
131 // Insns must be extended.
134 // Which operand may be extended.
137 // Signed or unsigned range.
140 // Number of bits of range before extending operand.
143 // Alignment power-of-two before extending operand.
146
153
156
157 // Addressing mode for load/store instructions.
160 // Access size for load/store instructions.
163
164 // Branch predicted taken.
167
168 // Floating-point instructions.
169 FPPos = 48,
170 FPMask = 0x1,
171
172 // New-Value producer-2 instructions.
175 // Which operand consumes or produces a new value.
178
179 // Accumulator instructions.
182
183 // Complex XU, prevent xu competition by preferring slot3
186
189
192
195
198
201
204 };
205
206 // *** The code above must match HexagonInstrFormat*.td *** //
207
208 // Hexagon specific MO operand flag mask.
210 // Hexagon-specific MachineOperand target flags.
211 //
212 // When changing these, make sure to update
213 // getSerializableDirectMachineOperandTargetFlags and
214 // getSerializableBitmaskMachineOperandTargetFlags if needed.
216
217 /// MO_PCREL - On a symbol operand, indicates a PC-relative relocation
218 /// Used for computing a global address for PIC compilations
220
221 /// MO_GOT - Indicates a GOT-relative relocation
223
224 // Low or high part of a symbol.
227
228 // Offset from the base of the SDA.
230
231 // MO_GDGOT - indicates GOT relative relocation for TLS
232 // GeneralDynamic method
234
235 // MO_GDPLT - indicates PLT relative relocation for TLS
236 // GeneralDynamic method
238
239 // MO_IE - indicates non PIC relocation for TLS
240 // Initial Executable method
242
243 // MO_IEGOT - indicates PIC relocation for TLS
244 // Initial Executable method
246
247 // MO_TPREL - indicates relocation for TLS
248 // local Executable method
250
251 // HMOTF_ConstExtended
252 // Addendum to above, indicates a const extended op
253 // Can be used as a mask.
255
256 // Union of all bitmasks (currently only HMOTF_ConstExtended).
258 };
259
260 // Hexagon Sub-instruction classes.
270
271 // Hexagon Compound classes.
278
280 INST_PARSE_MASK = 0x0000c000,
283 INST_PARSE_NOT_END = 0x00004000,
284 INST_PARSE_DUPLEX = 0x00000000,
286 };
287
288 enum InstIClassBits : unsigned {
289 INST_ICLASS_MASK = 0xf0000000,
291 INST_ICLASS_J_1 = 0x10000000,
292 INST_ICLASS_J_2 = 0x20000000,
295 INST_ICLASS_J_3 = 0x50000000,
296 INST_ICLASS_CR = 0x60000000,
299 INST_ICLASS_LD = 0x90000000,
300 INST_ICLASS_ST = 0xa0000000,
306 };
307
308 [[maybe_unused]]
310 switch (S) {
311 case ByteAccess: return 1;
312 case HalfWordAccess: return 2;
313 case WordAccess: return 4;
314 case DoubleWordAccess: return 8;
315 default: return 0;
316 }
317 }
318} // end namespace HexagonII
319
320} // end namespace llvm
321
322#endif // LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
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.
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26