blob: c63f044b7128fdf09632463f6e9b74cbb34c2e29 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- HexagonBaseInfo.h - Top level definitions for Hexagon --*- C++ -*--===//
Brendon Cahoon6f358372012-02-08 18:25:47 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains small standalone helper functions and enum definitions for
11// the Hexagon target useful for the compiler back-end and the MC libraries.
12// As such, it deliberately does not include references to LLVM core
13// code gen types, passes, etc..
14//
15//===----------------------------------------------------------------------===//
16
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000017#ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
18#define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
Brendon Cahoon6f358372012-02-08 18:25:47 +000019
NAKAMURA Takumi729be142014-10-27 12:37:26 +000020#include "HexagonMCTargetDesc.h"
21#include "llvm/Support/ErrorHandling.h"
NAKAMURA Takumi729be142014-10-27 12:37:26 +000022#include <stdint.h>
23
24namespace llvm {
25
26/// HexagonII - This namespace holds all of the target specific flags that
Brendon Cahoon6f358372012-02-08 18:25:47 +000027/// instruction info tracks.
28///
29namespace HexagonII {
Sirish Pande545983e2012-02-09 15:20:33 +000030 // *** The code below must match HexagonInstrFormat*.td *** //
Brendon Cahoon6f358372012-02-08 18:25:47 +000031
Sirish Pandef8e5e3c2012-05-03 21:52:53 +000032 // Insn types.
33 // *** Must match HexagonInstrFormat*.td ***
34 enum Type {
Jyotsna Vermae758da22013-02-19 18:18:36 +000035 TypePSEUDO = 0,
36 TypeALU32 = 1,
37 TypeCR = 2,
38 TypeJR = 3,
39 TypeJ = 4,
40 TypeLD = 5,
41 TypeST = 6,
42 TypeSYSTEM = 7,
43 TypeXTYPE = 8,
44 TypeMEMOP = 9,
45 TypeNV = 10,
Colin LeMahieube8c4532015-06-05 16:00:11 +000046 TypeDUPLEX = 11,
Colin LeMahieu7cd08922015-11-09 04:07:48 +000047 TypeCOMPOUND = 12,
48 TypeCVI_FIRST = 13,
49 TypeCVI_VA = TypeCVI_FIRST,
50 TypeCVI_VA_DV = 14,
51 TypeCVI_VX = 15,
52 TypeCVI_VX_DV = 16,
53 TypeCVI_VP = 17,
54 TypeCVI_VP_VS = 18,
55 TypeCVI_VS = 19,
56 TypeCVI_VINLANESAT= 20,
57 TypeCVI_VM_LD = 21,
58 TypeCVI_VM_TMP_LD = 22,
59 TypeCVI_VM_CUR_LD = 23,
60 TypeCVI_VM_VP_LDU = 24,
61 TypeCVI_VM_ST = 25,
62 TypeCVI_VM_NEW_ST = 26,
63 TypeCVI_VM_STU = 27,
64 TypeCVI_HIST = 28,
65 TypeCVI_LAST = TypeCVI_HIST,
Jyotsna Vermae758da22013-02-19 18:18:36 +000066 TypePREFIX = 30, // Such as extenders.
67 TypeENDLOOP = 31 // Such as end of a HW loop.
Sirish Pandef8e5e3c2012-05-03 21:52:53 +000068 };
69
Jyotsna Verma66493602012-11-14 20:38:48 +000070 enum SubTarget {
71 HasV2SubT = 0xf,
72 HasV2SubTOnly = 0x1,
73 NoV2SubT = 0x0,
74 HasV3SubT = 0xe,
75 HasV3SubTOnly = 0x2,
76 NoV3SubT = 0x1,
77 HasV4SubT = 0xc,
78 NoV4SubT = 0x3,
79 HasV5SubT = 0x8,
80 NoV5SubT = 0x7
81 };
Sirish Pandef8e5e3c2012-05-03 21:52:53 +000082
Jyotsna Verma66493602012-11-14 20:38:48 +000083 enum AddrMode {
84 NoAddrMode = 0, // No addressing mode
85 Absolute = 1, // Absolute addressing mode
86 AbsoluteSet = 2, // Absolute set addressing mode
87 BaseImmOffset = 3, // Indirect with offset
88 BaseLongOffset = 4, // Indirect with long offset
Jyotsna Vermaa03eb9b2013-05-07 15:06:29 +000089 BaseRegOffset = 5, // Indirect with register offset
90 PostInc = 6 // Post increment addressing mode
Jyotsna Verma66493602012-11-14 20:38:48 +000091 };
Sirish Pandef8e5e3c2012-05-03 21:52:53 +000092
Krzysztof Parzyszek25ddd2c2015-12-03 15:41:33 +000093 // MemAccessSize is represented as 1+log2(N) where N is size in bits.
Colin LeMahieub6625652015-05-01 21:14:21 +000094 enum class MemAccessSize {
Jyotsna Vermae758da22013-02-19 18:18:36 +000095 NoMemAccess = 0, // Not a memory acces instruction.
96 ByteAccess = 1, // Byte access instruction (memb).
97 HalfWordAccess = 2, // Half word access instruction (memh).
Robert Wilhelm2788d3e2013-09-28 13:42:22 +000098 WordAccess = 3, // Word access instruction (memw).
Krzysztof Parzyszek25ddd2c2015-12-03 15:41:33 +000099 DoubleWordAccess = 4, // Double word access instruction (memd)
100 // 5, // We do not have a 16 byte vector access.
101 Vector64Access = 7, // 64 Byte vector access instruction (vmem).
102 Vector128Access = 8 // 128 Byte vector access instruction (vmem).
Jyotsna Vermae758da22013-02-19 18:18:36 +0000103 };
104
Brendon Cahoon6f358372012-02-08 18:25:47 +0000105 // MCInstrDesc TSFlags
Sirish Pandef8e5e3c2012-05-03 21:52:53 +0000106 // *** Must match HexagonInstrFormat*.td ***
Brendon Cahoon6f358372012-02-08 18:25:47 +0000107 enum {
Sirish Pandef8e5e3c2012-05-03 21:52:53 +0000108 // This 5-bit field describes the insn type.
109 TypePos = 0,
110 TypeMask = 0x1f,
111
112 // Solo instructions.
113 SoloPos = 5,
114 SoloMask = 0x1,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000115 // Packed only with A or X-type instructions.
116 SoloAXPos = 6,
117 SoloAXMask = 0x1,
118 // Only A-type instruction in first slot or nothing.
119 SoloAin1Pos = 7,
120 SoloAin1Mask = 0x1,
Brendon Cahoon6f358372012-02-08 18:25:47 +0000121
122 // Predicated instructions.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000123 PredicatedPos = 8,
Jyotsna Verma66493602012-11-14 20:38:48 +0000124 PredicatedMask = 0x1,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000125 PredicatedFalsePos = 9,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000126 PredicatedFalseMask = 0x1,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000127 PredicatedNewPos = 10,
Jyotsna Verma66493602012-11-14 20:38:48 +0000128 PredicatedNewMask = 0x1,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000129 PredicateLatePos = 11,
130 PredicateLateMask = 0x1,
Jyotsna Verma66493602012-11-14 20:38:48 +0000131
Jyotsna Vermae758da22013-02-19 18:18:36 +0000132 // New-Value consumer instructions.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000133 NewValuePos = 12,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000134 NewValueMask = 0x1,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000135 // New-Value producer instructions.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000136 hasNewValuePos = 13,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000137 hasNewValueMask = 0x1,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000138 // Which operand consumes or produces a new value.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000139 NewValueOpPos = 14,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000140 NewValueOpMask = 0x7,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000141 // Stores that can become new-value stores.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000142 mayNVStorePos = 17,
Jyotsna Verma66493602012-11-14 20:38:48 +0000143 mayNVStoreMask = 0x1,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000144 // New-value store instructions.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000145 NVStorePos = 18,
Jyotsna Verma66493602012-11-14 20:38:48 +0000146 NVStoreMask = 0x1,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000147 // Loads that can become current-value loads.
148 mayCVLoadPos = 19,
149 mayCVLoadMask = 0x1,
150 // Current-value load instructions.
151 CVLoadPos = 20,
152 CVLoadMask = 0x1,
Jyotsna Verma66493602012-11-14 20:38:48 +0000153
154 // Extendable insns.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000155 ExtendablePos = 21,
Jyotsna Verma66493602012-11-14 20:38:48 +0000156 ExtendableMask = 0x1,
Jyotsna Verma66493602012-11-14 20:38:48 +0000157 // Insns must be extended.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000158 ExtendedPos = 22,
Jyotsna Verma66493602012-11-14 20:38:48 +0000159 ExtendedMask = 0x1,
Jyotsna Verma66493602012-11-14 20:38:48 +0000160 // Which operand may be extended.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000161 ExtendableOpPos = 23,
Jyotsna Verma66493602012-11-14 20:38:48 +0000162 ExtendableOpMask = 0x7,
Jyotsna Verma66493602012-11-14 20:38:48 +0000163 // Signed or unsigned range.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000164 ExtentSignedPos = 26,
Jyotsna Verma66493602012-11-14 20:38:48 +0000165 ExtentSignedMask = 0x1,
Jyotsna Verma66493602012-11-14 20:38:48 +0000166 // Number of bits of range before extending operand.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000167 ExtentBitsPos = 27,
Jyotsna Verma66493602012-11-14 20:38:48 +0000168 ExtentBitsMask = 0x1f,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000169 // Alignment power-of-two before extending operand.
170 ExtentAlignPos = 32,
171 ExtentAlignMask = 0x3,
Jyotsna Verma66493602012-11-14 20:38:48 +0000172
173 // Valid subtargets
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000174 validSubTargetPos = 34,
Jyotsna Verma66493602012-11-14 20:38:48 +0000175 validSubTargetMask = 0xf,
176
Jyotsna Vermae758da22013-02-19 18:18:36 +0000177 // Addressing mode for load/store instructions.
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000178 AddrModePos = 40,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000179 AddrModeMask = 0x7,
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000180 // Access size for load/store instructions.
181 MemAccessSizePos = 43,
Krzysztof Parzyszek25ddd2c2015-12-03 15:41:33 +0000182 MemAccesSizeMask = 0xf,
Jyotsna Verma66493602012-11-14 20:38:48 +0000183
Jyotsna Vermaf98a1ec2014-05-07 19:07:34 +0000184 // Branch predicted taken.
185 TakenPos = 47,
186 TakenMask = 0x1,
187
188 // Floating-point instructions.
189 FPPos = 48,
Colin LeMahieu7cd08922015-11-09 04:07:48 +0000190 FPMask = 0x1,
191
192 // New-Value producer-2 instructions.
193 hasNewValuePos2 = 50,
194 hasNewValueMask2 = 0x1,
195
196 // Which operand consumes or produces a new value.
197 NewValueOpPos2 = 51,
Krzysztof Parzyszekb9a1c3a2015-11-24 14:55:26 +0000198 NewValueOpMask2 = 0x7,
199
200 // Accumulator instructions.
201 AccumulatorPos = 54,
202 AccumulatorMask = 0x1,
203
204 // Complex XU, prevent xu competition by prefering slot3
205 PrefersSlot3Pos = 55,
206 PrefersSlot3Mask = 0x1,
Jyotsna Vermae758da22013-02-19 18:18:36 +0000207 };
Brendon Cahoon6f358372012-02-08 18:25:47 +0000208
Sirish Pande545983e2012-02-09 15:20:33 +0000209 // *** The code above must match HexagonInstrFormat*.td *** //
Brendon Cahoon6f358372012-02-08 18:25:47 +0000210
Jyotsna Verma84256432013-03-01 17:37:13 +0000211 // Hexagon specific MO operand flag mask.
212 enum HexagonMOTargetFlagVal {
213 //===------------------------------------------------------------------===//
214 // Hexagon Specific MachineOperand flags.
215 MO_NO_FLAG,
216
217 HMOTF_ConstExtended = 1,
218
219 /// MO_PCREL - On a symbol operand, indicates a PC-relative relocation
220 /// Used for computing a global address for PIC compilations
221 MO_PCREL,
222
223 /// MO_GOT - Indicates a GOT-relative relocation
224 MO_GOT,
225
226 // Low or high part of a symbol.
227 MO_LO16, MO_HI16,
228
229 // Offset from the base of the SDA.
Krzysztof Parzyszek7a737d12016-02-18 15:42:57 +0000230 MO_GPREL,
231
232 // MO_GDGOT - indicates GOT relative relocation for TLS
233 // GeneralDynamic method
234 MO_GDGOT,
235
236 // MO_GDPLT - indicates PLT relative relocation for TLS
237 // GeneralDynamic method
238 MO_GDPLT,
239
240 // MO_IE - indicates non PIC relocation for TLS
241 // Initial Executable method
242 MO_IE,
243
244 // MO_IEGOT - indicates PIC relocation for TLS
245 // Initial Executable method
246 MO_IEGOT,
247
248 // MO_TPREL - indicates relocation for TLS
249 // local Executable method
250 MO_TPREL
NAKAMURA Takumi729be142014-10-27 12:37:26 +0000251 };
252
Colin LeMahieube8c4532015-06-05 16:00:11 +0000253 // Hexagon Sub-instruction classes.
254 enum SubInstructionGroup {
255 HSIG_None = 0,
256 HSIG_L1,
257 HSIG_L2,
258 HSIG_S1,
259 HSIG_S2,
260 HSIG_A,
261 HSIG_Compound
262 };
263
Colin LeMahieu6aca6f02015-06-08 16:34:47 +0000264 // Hexagon Compound classes.
265 enum CompoundGroup {
266 HCG_None = 0,
267 HCG_A,
268 HCG_B,
269 HCG_C
270 };
271
Colin LeMahieu68d967d2015-05-29 14:44:13 +0000272 enum InstParseBits {
NAKAMURA Takumi729be142014-10-27 12:37:26 +0000273 INST_PARSE_MASK = 0x0000c000,
274 INST_PARSE_PACKET_END = 0x0000c000,
275 INST_PARSE_LOOP_END = 0x00008000,
276 INST_PARSE_NOT_END = 0x00004000,
277 INST_PARSE_DUPLEX = 0x00000000,
278 INST_PARSE_EXTENDER = 0x00000000
279 };
280
Reid Kleckner390191d2015-11-09 19:44:38 +0000281 enum InstIClassBits : unsigned {
Colin LeMahieu7cd08922015-11-09 04:07:48 +0000282 INST_ICLASS_MASK = 0xf0000000,
283 INST_ICLASS_EXTENDER = 0x00000000,
284 INST_ICLASS_J_1 = 0x10000000,
285 INST_ICLASS_J_2 = 0x20000000,
286 INST_ICLASS_LD_ST_1 = 0x30000000,
287 INST_ICLASS_LD_ST_2 = 0x40000000,
288 INST_ICLASS_J_3 = 0x50000000,
289 INST_ICLASS_CR = 0x60000000,
290 INST_ICLASS_ALU32_1 = 0x70000000,
291 INST_ICLASS_XTYPE_1 = 0x80000000,
292 INST_ICLASS_LD = 0x90000000,
293 INST_ICLASS_ST = 0xa0000000,
294 INST_ICLASS_ALU32_2 = 0xb0000000,
295 INST_ICLASS_XTYPE_2 = 0xc0000000,
296 INST_ICLASS_XTYPE_3 = 0xd0000000,
297 INST_ICLASS_XTYPE_4 = 0xe0000000,
298 INST_ICLASS_ALU32_3 = 0xf0000000
299 };
300
NAKAMURA Takumi729be142014-10-27 12:37:26 +0000301} // End namespace HexagonII.
302
303} // End namespace llvm.
Brendon Cahoon6f358372012-02-08 18:25:47 +0000304
305#endif