af67481e4f47d2b5d3d74049f7620655004ebd51
[oota-llvm.git] / lib / Target / Hexagon / MCTargetDesc / HexagonBaseInfo.h
1 //===-- HexagonBaseInfo.h - Top level definitions for Hexagon --*- C++ -*--===//
2 //
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
17 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
18 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONBASEINFO_H
19
20 #include "HexagonMCTargetDesc.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include <stdint.h>
23
24 namespace llvm {
25
26 /// HexagonII - This namespace holds all of the target specific flags that
27 /// instruction info tracks.
28 ///
29 namespace HexagonII {
30   // *** The code below must match HexagonInstrFormat*.td *** //
31
32   // Insn types.
33   // *** Must match HexagonInstrFormat*.td ***
34   enum Type {
35     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,
46     TypeDUPLEX  = 11,
47     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,
66     TypePREFIX  = 30, // Such as extenders.
67     TypeENDLOOP = 31  // Such as end of a HW loop.
68   };
69
70   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   };
82
83   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
89     BaseRegOffset  = 5,  // Indirect with register offset
90     PostInc        = 6   // Post increment addressing mode
91   };
92
93   enum class MemAccessSize {
94     NoMemAccess = 0,            // Not a memory acces instruction.
95     ByteAccess = 1,             // Byte access instruction (memb).
96     HalfWordAccess = 2,         // Half word access instruction (memh).
97     WordAccess = 3,             // Word access instruction (memw).
98     DoubleWordAccess = 4        // Double word access instruction (memd)
99   };
100
101   // MCInstrDesc TSFlags
102   // *** Must match HexagonInstrFormat*.td ***
103   enum {
104     // This 5-bit field describes the insn type.
105     TypePos  = 0,
106     TypeMask = 0x1f,
107
108     // Solo instructions.
109     SoloPos  = 5,
110     SoloMask = 0x1,
111     // Packed only with A or X-type instructions.
112     SoloAXPos  = 6,
113     SoloAXMask = 0x1,
114     // Only A-type instruction in first slot or nothing.
115     SoloAin1Pos  = 7,
116     SoloAin1Mask = 0x1,
117
118     // Predicated instructions.
119     PredicatedPos  = 8,
120     PredicatedMask = 0x1,
121     PredicatedFalsePos  = 9,
122     PredicatedFalseMask = 0x1,
123     PredicatedNewPos  = 10,
124     PredicatedNewMask = 0x1,
125     PredicateLatePos  = 11,
126     PredicateLateMask = 0x1,
127
128     // New-Value consumer instructions.
129     NewValuePos  = 12,
130     NewValueMask = 0x1,
131     // New-Value producer instructions.
132     hasNewValuePos  = 13,
133     hasNewValueMask = 0x1,
134     // Which operand consumes or produces a new value.
135     NewValueOpPos  = 14,
136     NewValueOpMask = 0x7,
137     // Stores that can become new-value stores.
138     mayNVStorePos  = 17,
139     mayNVStoreMask = 0x1,
140     // New-value store instructions.
141     NVStorePos  = 18,
142     NVStoreMask = 0x1,
143     // Loads that can become current-value loads.
144     mayCVLoadPos  = 19,
145     mayCVLoadMask = 0x1,
146     // Current-value load instructions.
147     CVLoadPos  = 20,
148     CVLoadMask = 0x1,
149
150     // Extendable insns.
151     ExtendablePos  = 21,
152     ExtendableMask = 0x1,
153     // Insns must be extended.
154     ExtendedPos  = 22,
155     ExtendedMask = 0x1,
156     // Which operand may be extended.
157     ExtendableOpPos  = 23,
158     ExtendableOpMask = 0x7,
159     // Signed or unsigned range.
160     ExtentSignedPos  = 26,
161     ExtentSignedMask = 0x1,
162     // Number of bits of range before extending operand.
163     ExtentBitsPos  = 27,
164     ExtentBitsMask = 0x1f,
165     // Alignment power-of-two before extending operand.
166     ExtentAlignPos  = 32,
167     ExtentAlignMask = 0x3,
168
169     // Valid subtargets
170     validSubTargetPos  = 34,
171     validSubTargetMask = 0xf,
172
173     // Addressing mode for load/store instructions.
174     AddrModePos  = 40,
175     AddrModeMask = 0x7,
176     // Access size for load/store instructions.
177     MemAccessSizePos = 43,
178     MemAccesSizeMask = 0x7,
179
180     // Branch predicted taken.
181     TakenPos = 47,
182     TakenMask = 0x1,
183
184     // Floating-point instructions.
185     FPPos  = 48,
186     FPMask = 0x1,
187
188     // New-Value producer-2 instructions.
189     hasNewValuePos2  = 50,
190     hasNewValueMask2 = 0x1,
191
192     // Which operand consumes or produces a new value.
193     NewValueOpPos2  = 51,
194     NewValueOpMask2 = 0x7,
195
196     // Accumulator instructions.
197     AccumulatorPos = 54,
198     AccumulatorMask = 0x1,
199
200     // Complex XU, prevent xu competition by prefering slot3
201     PrefersSlot3Pos = 55,
202     PrefersSlot3Mask = 0x1,
203   };
204
205   // *** The code above must match HexagonInstrFormat*.td *** //
206
207   // Hexagon specific MO operand flag mask.
208   enum HexagonMOTargetFlagVal {
209     //===------------------------------------------------------------------===//
210     // Hexagon Specific MachineOperand flags.
211     MO_NO_FLAG,
212
213     HMOTF_ConstExtended = 1,
214
215     /// MO_PCREL - On a symbol operand, indicates a PC-relative relocation
216     /// Used for computing a global address for PIC compilations
217     MO_PCREL,
218
219     /// MO_GOT - Indicates a GOT-relative relocation
220     MO_GOT,
221
222     // Low or high part of a symbol.
223     MO_LO16, MO_HI16,
224
225     // Offset from the base of the SDA.
226     MO_GPREL
227   };
228
229   // Hexagon Sub-instruction classes.
230   enum SubInstructionGroup {
231     HSIG_None = 0,
232     HSIG_L1,
233     HSIG_L2,
234     HSIG_S1,
235     HSIG_S2,
236     HSIG_A,
237     HSIG_Compound
238   };
239
240   // Hexagon Compound classes.
241   enum CompoundGroup {
242     HCG_None = 0,
243     HCG_A,
244     HCG_B,
245     HCG_C
246   };
247
248   enum InstParseBits {
249     INST_PARSE_MASK       = 0x0000c000,
250     INST_PARSE_PACKET_END = 0x0000c000,
251     INST_PARSE_LOOP_END   = 0x00008000,
252     INST_PARSE_NOT_END    = 0x00004000,
253     INST_PARSE_DUPLEX     = 0x00000000,
254     INST_PARSE_EXTENDER   = 0x00000000
255   };
256
257   enum InstIClassBits : unsigned {
258     INST_ICLASS_MASK      = 0xf0000000,
259     INST_ICLASS_EXTENDER  = 0x00000000,
260     INST_ICLASS_J_1       = 0x10000000,
261     INST_ICLASS_J_2       = 0x20000000,
262     INST_ICLASS_LD_ST_1   = 0x30000000,
263     INST_ICLASS_LD_ST_2   = 0x40000000,
264     INST_ICLASS_J_3       = 0x50000000,
265     INST_ICLASS_CR        = 0x60000000,
266     INST_ICLASS_ALU32_1   = 0x70000000,
267     INST_ICLASS_XTYPE_1   = 0x80000000,
268     INST_ICLASS_LD        = 0x90000000,
269     INST_ICLASS_ST        = 0xa0000000,
270     INST_ICLASS_ALU32_2   = 0xb0000000,
271     INST_ICLASS_XTYPE_2   = 0xc0000000,
272     INST_ICLASS_XTYPE_3   = 0xd0000000,
273     INST_ICLASS_XTYPE_4   = 0xe0000000,
274     INST_ICLASS_ALU32_3   = 0xf0000000
275   };
276
277 } // End namespace HexagonII.
278
279 } // End namespace llvm.
280
281 #endif