Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / instr.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 /*****************************************************************************/
5
6 #ifndef _INSTR_H_
7 #define _INSTR_H_
8 /*****************************************************************************/
9
10 #define BAD_CODE 0x0BADC0DE // better not match a real encoding!
11
12 /*****************************************************************************/
13
14 // clang-format off
15 enum instruction : unsigned
16 {
17 #if defined(_TARGET_XARCH_)
18     #define INST0(id, nm, fp, um, rf, wf, mr                ) INS_##id,
19     #define INST1(id, nm, fp, um, rf, wf, mr                ) INS_##id,
20     #define INST2(id, nm, fp, um, rf, wf, mr, mi            ) INS_##id,
21     #define INST3(id, nm, fp, um, rf, wf, mr, mi, rm        ) INS_##id,
22     #define INST4(id, nm, fp, um, rf, wf, mr, mi, rm, a4    ) INS_##id,
23     #define INST5(id, nm, fp, um, rf, wf, mr, mi, rm, a4, rr) INS_##id,
24     #include "instrs.h"
25
26 #elif defined(_TARGET_ARM_)
27     #define INST1(id, nm, fp, ldst, fmt, e1                                ) INS_##id,
28     #define INST2(id, nm, fp, ldst, fmt, e1, e2                            ) INS_##id,
29     #define INST3(id, nm, fp, ldst, fmt, e1, e2, e3                        ) INS_##id,
30     #define INST4(id, nm, fp, ldst, fmt, e1, e2, e3, e4                    ) INS_##id,
31     #define INST5(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5                ) INS_##id,
32     #define INST6(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5, e6            ) INS_##id,
33     #define INST8(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5, e6, e7, e8    ) INS_##id,
34     #define INST9(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5, e6, e7, e8, e9) INS_##id,
35     #include "instrs.h"
36     #include "x86_instrs.h"
37
38 #elif defined(_TARGET_ARM64_)
39     #define INST1(id, nm, fp, ldst, fmt, e1                                ) INS_##id,
40     #define INST2(id, nm, fp, ldst, fmt, e1, e2                            ) INS_##id,
41     #define INST3(id, nm, fp, ldst, fmt, e1, e2, e3                        ) INS_##id,
42     #define INST4(id, nm, fp, ldst, fmt, e1, e2, e3, e4                    ) INS_##id,
43     #define INST5(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5                ) INS_##id,
44     #define INST6(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5, e6            ) INS_##id,
45     #define INST9(id, nm, fp, ldst, fmt, e1, e2, e3, e4, e5, e6, e7, e8, e9) INS_##id,
46     #include "instrs.h"
47
48     INS_lea,   // Not a real instruction. It is used for load the address of stack locals
49
50 #else
51 #error Unsupported target architecture
52 #endif
53
54     INS_none,
55     INS_count = INS_none
56 };
57
58 /*****************************************************************************/
59
60 enum insUpdateModes
61 {
62     IUM_RD,
63     IUM_WR,
64     IUM_RW,
65 };
66
67 /*****************************************************************************/
68
69 enum emitJumpKind
70 {
71     EJ_NONE,
72
73     #define JMP_SMALL(en, rev, ins)           EJ_##en,
74     #include "emitjmps.h"
75
76     EJ_COUNT
77 };
78
79 /*****************************************************************************/
80
81 enum GCtype : unsigned
82 {
83     GCT_NONE,
84     GCT_GCREF,
85     GCT_BYREF
86 };
87
88 // TODO-Cleanup:  Move 'insFlags' under _TARGET_ARM_
89 enum insFlags: unsigned
90 {
91     INS_FLAGS_NOT_SET,
92     INS_FLAGS_SET,
93     INS_FLAGS_DONT_CARE
94 };
95
96 #if defined(_TARGET_ARM_)
97 enum insOpts: unsigned
98 {
99     INS_OPTS_NONE,
100     INS_OPTS_LDST_PRE_DEC,
101     INS_OPTS_LDST_POST_INC,
102
103     INS_OPTS_RRX,
104     INS_OPTS_LSL,
105     INS_OPTS_LSR,
106     INS_OPTS_ASR,
107     INS_OPTS_ROR
108 };
109 #elif defined(_TARGET_ARM64_)
110 enum insOpts : unsigned
111 {
112     INS_OPTS_NONE,
113
114     INS_OPTS_PRE_INDEX,
115     INS_OPTS_POST_INDEX,
116
117     INS_OPTS_LSL12,
118
119     INS_OPTS_LSL = 4,
120     INS_OPTS_LSR,
121     INS_OPTS_ASR,
122     INS_OPTS_ROR,
123
124     INS_OPTS_UXTB = 8,
125     INS_OPTS_UXTH,
126     INS_OPTS_UXTW,
127     INS_OPTS_UXTX,
128     INS_OPTS_SXTB,
129     INS_OPTS_SXTH,
130     INS_OPTS_SXTW,
131     INS_OPTS_SXTX,
132
133     INS_OPTS_8B  = 16,
134     INS_OPTS_16B,
135     INS_OPTS_4H,
136     INS_OPTS_8H,
137     INS_OPTS_2S,
138     INS_OPTS_4S,
139     INS_OPTS_1D,
140     INS_OPTS_2D,
141
142     INS_OPTS_MSL,     // Vector Immediate (shifting ones variant)
143
144     INS_OPTS_S_TO_4BYTE,  // Single to INT32
145     INS_OPTS_D_TO_4BYTE,  // Double to INT32
146
147     INS_OPTS_S_TO_8BYTE,  // Single to INT64
148     INS_OPTS_D_TO_8BYTE,  // Double to INT64
149
150     INS_OPTS_4BYTE_TO_S,  // INT32 to Single
151     INS_OPTS_4BYTE_TO_D,  // INT32 to Double
152
153     INS_OPTS_8BYTE_TO_S,  // INT64 to Single
154     INS_OPTS_8BYTE_TO_D,  // INT64 to Double
155
156     INS_OPTS_S_TO_D,      // Single to Double
157     INS_OPTS_D_TO_S,      // Double to Single
158
159     INS_OPTS_H_TO_S,      // Half to Single
160     INS_OPTS_H_TO_D,      // Half to Double
161
162     INS_OPTS_S_TO_H,      // Single to Half
163     INS_OPTS_D_TO_H,      // Double to Half
164 };
165
166 enum insCond : unsigned
167 {
168     INS_COND_EQ,
169     INS_COND_NE,
170     INS_COND_HS,
171     INS_COND_LO,
172
173     INS_COND_MI,
174     INS_COND_PL,
175     INS_COND_VS,
176     INS_COND_VC,
177
178     INS_COND_HI,
179     INS_COND_LS,
180     INS_COND_GE,
181     INS_COND_LT,
182
183     INS_COND_GT,
184     INS_COND_LE,
185 };
186
187 enum insCflags : unsigned
188 {
189     INS_FLAGS_NONE,
190     INS_FLAGS_V,
191     INS_FLAGS_C,
192     INS_FLAGS_CV,
193
194     INS_FLAGS_Z,
195     INS_FLAGS_ZV,
196     INS_FLAGS_ZC,
197     INS_FLAGS_ZCV,
198
199     INS_FLAGS_N,
200     INS_FLAGS_NV,
201     INS_FLAGS_NC,
202     INS_FLAGS_NCV,
203
204     INS_FLAGS_NZ,
205     INS_FLAGS_NZV,
206     INS_FLAGS_NZC,
207     INS_FLAGS_NZCV,
208 };
209
210 enum insBarrier : unsigned
211 {
212     INS_BARRIER_OSHLD =  1,
213     INS_BARRIER_OSHST =  2,
214     INS_BARRIER_OSH   =  3,
215
216     INS_BARRIER_NSHLD =  5,
217     INS_BARRIER_NSHST =  6,
218     INS_BARRIER_NSH   =  7,
219
220     INS_BARRIER_ISHLD =  9,
221     INS_BARRIER_ISHST = 10,
222     INS_BARRIER_ISH   = 11,
223
224     INS_BARRIER_LD    = 13,
225     INS_BARRIER_ST    = 14,
226     INS_BARRIER_SY    = 15,
227 };
228 #endif
229
230 #undef EA_UNKNOWN
231 enum emitAttr : unsigned
232 {
233                 EA_UNKNOWN       = 0x000,
234                 EA_1BYTE         = 0x001,
235                 EA_2BYTE         = 0x002,
236                 EA_4BYTE         = 0x004,
237                 EA_8BYTE         = 0x008,
238                 EA_16BYTE        = 0x010,
239                 EA_32BYTE        = 0x020,
240                 EA_SIZE_MASK     = 0x03F,
241
242 #ifdef _TARGET_64BIT_
243                 EA_PTRSIZE       = EA_8BYTE,
244 #else
245                 EA_PTRSIZE       = EA_4BYTE,
246 #endif
247
248                 EA_OFFSET_FLG    = 0x040,
249                 EA_OFFSET        = EA_OFFSET_FLG | EA_PTRSIZE,       /* size ==  0 */
250                 EA_GCREF_FLG     = 0x080,
251                 EA_GCREF         = EA_GCREF_FLG |  EA_PTRSIZE,       /* size == -1 */
252                 EA_BYREF_FLG     = 0x100,
253                 EA_BYREF         = EA_BYREF_FLG |  EA_PTRSIZE,       /* size == -2 */
254                 EA_DSP_RELOC_FLG = 0x200,
255                 EA_CNS_RELOC_FLG = 0x400,
256 };
257
258 #define EA_ATTR(x)                  ((emitAttr)(x))
259 #define EA_SIZE(x)                  ((emitAttr)(((unsigned)(x)) &  EA_SIZE_MASK))
260 #define EA_SIZE_IN_BYTES(x)         ((UNATIVE_OFFSET)(EA_SIZE(x)))
261 #define EA_SET_SIZE(x, sz)          ((emitAttr)((((unsigned)(x)) & ~EA_SIZE_MASK) | sz))
262 #define EA_SET_FLG(x, flg)          ((emitAttr)(((unsigned)(x)) | flg))
263 #define EA_4BYTE_DSP_RELOC          (EA_SET_FLG(EA_4BYTE, EA_DSP_RELOC_FLG))
264 #define EA_PTR_DSP_RELOC            (EA_SET_FLG(EA_PTRSIZE, EA_DSP_RELOC_FLG))
265 #define EA_HANDLE_CNS_RELOC         (EA_SET_FLG(EA_PTRSIZE, EA_CNS_RELOC_FLG))
266 #define EA_IS_OFFSET(x)             ((((unsigned)(x)) & ((unsigned)EA_OFFSET_FLG)) != 0)
267 #define EA_IS_GCREF(x)              ((((unsigned)(x)) & ((unsigned)EA_GCREF_FLG)) != 0)
268 #define EA_IS_BYREF(x)              ((((unsigned)(x)) & ((unsigned)EA_BYREF_FLG)) != 0)
269 #define EA_IS_GCREF_OR_BYREF(x)     ((((unsigned)(x)) & ((unsigned)(EA_BYREF_FLG | EA_GCREF_FLG))) != 0)
270 #define EA_IS_DSP_RELOC(x)          ((((unsigned)(x)) & ((unsigned)EA_DSP_RELOC_FLG)) != 0)
271 #define EA_IS_CNS_RELOC(x)          ((((unsigned)(x)) & ((unsigned)EA_CNS_RELOC_FLG)) != 0)
272 #define EA_IS_RELOC(x)              (EA_IS_DSP_RELOC(x) || EA_IS_CNS_RELOC(x))
273 #define EA_TYPE(x)                  ((emitAttr)(((unsigned)(x)) & ~(EA_OFFSET_FLG | EA_DSP_RELOC_FLG | EA_CNS_RELOC_FLG)))
274
275 #define EmitSize(x)                 (EA_ATTR(genTypeSize(TypeGet(x))))
276
277 enum InstructionSet
278 {
279     InstructionSet_ILLEGAL = 0,
280 #ifdef _TARGET_XARCH_
281     // Start linear order SIMD instruction sets
282     // These ISAs have strictly generation to generation order.
283     InstructionSet_SSE     = 1,
284     InstructionSet_SSE2    = 2,
285     InstructionSet_SSE3    = 3,
286     InstructionSet_SSSE3   = 4,
287     InstructionSet_SSE41   = 5,
288     InstructionSet_SSE42   = 6,
289     InstructionSet_AVX     = 7,
290     InstructionSet_AVX2    = 8,
291     // Reserve values <32 for future SIMD instruction sets (i.e., AVX512),
292     // End linear order SIMD instruction sets.
293
294     InstructionSet_AES     = 32,
295     InstructionSet_BMI1    = 33,
296     InstructionSet_BMI2    = 34,
297     InstructionSet_FMA     = 35,
298     InstructionSet_LZCNT   = 36,
299     InstructionSet_PCLMULQDQ  = 37,
300     InstructionSet_POPCNT  = 38,
301 #elif defined(_TARGET_ARM_)
302     InstructionSet_NEON,
303 #elif defined(_TARGET_ARM64_)
304     InstructionSet_Base,      // Base instructions available on all Arm64 platforms
305     InstructionSet_Aes,       // ID_AA64ISAR0_EL1.AES is 1 or better
306     InstructionSet_Atomics,   // ID_AA64ISAR0_EL1.Atomic is 2 or better
307     InstructionSet_Crc32,     // ID_AA64ISAR0_EL1.CRC32 is 1 or better
308     InstructionSet_Dcpop,     // ID_AA64ISAR1_EL1.DPB is 1 or better
309     InstructionSet_Dp,        // ID_AA64ISAR0_EL1.DP is 1 or better
310     InstructionSet_Fcma,      // ID_AA64ISAR1_EL1.FCMA is 1 or better
311     InstructionSet_Fp,        // ID_AA64PFR0_EL1.FP is 0 or better
312     InstructionSet_Fp16,      // ID_AA64PFR0_EL1.FP is 1 or better
313     InstructionSet_Jscvt,     // ID_AA64ISAR1_EL1.JSCVT is 1 or better
314     InstructionSet_Lrcpc,     // ID_AA64ISAR1_EL1.LRCPC is 1 or better
315     InstructionSet_Pmull,     // ID_AA64ISAR0_EL1.AES is 2 or better
316     InstructionSet_Sha1,      // ID_AA64ISAR0_EL1.SHA1 is 1 or better
317     InstructionSet_Sha256,    // ID_AA64ISAR0_EL1.SHA2 is 1 or better
318     InstructionSet_Sha512,    // ID_AA64ISAR0_EL1.SHA2 is 2 or better
319     InstructionSet_Sha3,      // ID_AA64ISAR0_EL1.SHA3 is 1 or better
320     InstructionSet_Simd,      // ID_AA64PFR0_EL1.AdvSIMD is 0 or better
321     InstructionSet_Simd_v81,  // ID_AA64ISAR0_EL1.RDM is 1 or better
322     InstructionSet_Simd_fp16, // ID_AA64PFR0_EL1.AdvSIMD is 1 or better
323     InstructionSet_Sm3,       // ID_AA64ISAR0_EL1.SM3 is 1 or better
324     InstructionSet_Sm4,       // ID_AA64ISAR0_EL1.SM4 is 1 or better
325     InstructionSet_Sve,       // ID_AA64PFR0_EL1.SVE is 1 or better
326 #endif
327     InstructionSet_NONE       // No instruction set is available indicating an invalid value
328 };
329 // clang-format on
330
331 /*****************************************************************************/
332 #endif //_INSTR_H_
333 /*****************************************************************************/