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// clang-format off
7#if !defined(_TARGET_ARM64_)
8#error Unexpected target type
9#endif
10
11#ifdef DEFINE_ID_OPS
12//////////////////////////////////////////////////////////////////////////////
13
14#undef DEFINE_ID_OPS
15
16enum ID_OPS
17{
18 ID_OP_NONE, // no additional arguments
19 ID_OP_SCNS, // small const operand (21-bits or less, no reloc)
20 ID_OP_JMP, // local jump
21 ID_OP_CALL, // method call
22 ID_OP_SPEC, // special handling required
23};
24
25//////////////////////////////////////////////////////////////////////////////
26#else // !DEFINE_ID_OPS
27//////////////////////////////////////////////////////////////////////////////
28
29#ifndef IF_DEF
30#error Must define IF_DEF macro before including this file
31#endif
32
33//////////////////////////////////////////////////////////////////////////////
34//
35// enum insFormat instruction enum ID_OPS
36// scheduling
37// (unused)
38//////////////////////////////////////////////////////////////////////////////
39
40IF_DEF(NONE, IS_NONE, NONE) //
41
42IF_DEF(LABEL, IS_NONE, JMP) // label
43IF_DEF(LARGEJMP, IS_NONE, JMP) // large conditional branch pseudo-op (cond branch + uncond branch)
44IF_DEF(LARGEADR, IS_NONE, JMP) // large address pseudo-op (adrp + add)
45IF_DEF(LARGELDC, IS_NONE, JMP) // large constant pseudo-op (adrp + ldr)
46
47/////////////////////////////////////////////////////////////////////////////////////////////////////////
48
49IF_DEF(EN9, IS_NONE, NONE) // Instruction has 9 possible encoding types
50IF_DEF(EN6A, IS_NONE, NONE) // Instruction has 6 possible encoding types, type A
51IF_DEF(EN5A, IS_NONE, NONE) // Instruction has 5 possible encoding types, type A
52IF_DEF(EN5B, IS_NONE, NONE) // Instruction has 5 possible encoding types, type B
53IF_DEF(EN5C, IS_NONE, NONE) // Instruction has 5 possible encoding types, type C
54IF_DEF(EN4A, IS_NONE, NONE) // Instruction has 4 possible encoding types, type A
55IF_DEF(EN4B, IS_NONE, NONE) // Instruction has 4 possible encoding types, type B
56IF_DEF(EN4C, IS_NONE, NONE) // Instruction has 4 possible encoding types, type C
57IF_DEF(EN4D, IS_NONE, NONE) // Instruction has 4 possible encoding types, type D
58IF_DEF(EN4E, IS_NONE, NONE) // Instruction has 4 possible encoding types, type E
59IF_DEF(EN4F, IS_NONE, NONE) // Instruction has 4 possible encoding types, type F
60IF_DEF(EN4G, IS_NONE, NONE) // Instruction has 4 possible encoding types, type G
61IF_DEF(EN4H, IS_NONE, NONE) // Instruction has 4 possible encoding types, type H
62IF_DEF(EN4I, IS_NONE, NONE) // Instruction has 4 possible encoding types, type I
63IF_DEF(EN3A, IS_NONE, NONE) // Instruction has 3 possible encoding types, type A
64IF_DEF(EN3B, IS_NONE, NONE) // Instruction has 3 possible encoding types, type B
65IF_DEF(EN3C, IS_NONE, NONE) // Instruction has 3 possible encoding types, type C
66IF_DEF(EN3D, IS_NONE, NONE) // Instruction has 3 possible encoding types, type D
67IF_DEF(EN3E, IS_NONE, NONE) // Instruction has 3 possible encoding types, type E
68IF_DEF(EN3F, IS_NONE, NONE) // Instruction has 3 possible encoding types, type F
69IF_DEF(EN3G, IS_NONE, NONE) // Instruction has 3 possible encoding types, type G
70IF_DEF(EN3H, IS_NONE, NONE) // Instruction has 3 possible encoding types, type H
71IF_DEF(EN3I, IS_NONE, NONE) // Instruction has 3 possible encoding types, type I
72IF_DEF(EN2A, IS_NONE, NONE) // Instruction has 2 possible encoding types, type A
73IF_DEF(EN2B, IS_NONE, NONE) // Instruction has 2 possible encoding types, type B
74IF_DEF(EN2C, IS_NONE, NONE) // Instruction has 2 possible encoding types, type C
75IF_DEF(EN2D, IS_NONE, NONE) // Instruction has 2 possible encoding types, type D
76IF_DEF(EN2E, IS_NONE, NONE) // Instruction has 2 possible encoding types, type E
77IF_DEF(EN2F, IS_NONE, NONE) // Instruction has 2 possible encoding types, type F
78IF_DEF(EN2G, IS_NONE, NONE) // Instruction has 2 possible encoding types, type G
79IF_DEF(EN2H, IS_NONE, NONE) // Instruction has 2 possible encoding types, type H
80IF_DEF(EN2I, IS_NONE, NONE) // Instruction has 2 possible encoding types, type I
81IF_DEF(EN2J, IS_NONE, NONE) // Instruction has 2 possible encoding types, type J
82IF_DEF(EN2K, IS_NONE, NONE) // Instruction has 2 possible encoding types, type K
83IF_DEF(EN2L, IS_NONE, NONE) // Instruction has 2 possible encoding types, type L
84IF_DEF(EN2M, IS_NONE, NONE) // Instruction has 2 possible encoding types, type M
85IF_DEF(EN2N, IS_NONE, NONE) // Instruction has 2 possible encoding types, type N
86IF_DEF(EN2O, IS_NONE, NONE) // Instruction has 2 possible encoding types, type O
87IF_DEF(EN2P, IS_NONE, NONE) // Instruction has 2 possible encoding types, type P
88
89/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
90//
91// Key for insFormat names:
92//
93// Above (Specifies multiple encodings)
94//
95// EN#? :: (count of the number of encodings)
96// (? is a unique letter A,B,C...)
97//
98// Below (Specifies an exact instruction encoding)
99//
100// -- the first two characters are
101//
102// DI :: Data Processing - Immediate
103// DR :: Data Processing - Register
104// DV :: Data Processing - Vector Register
105// LS :: Loads and Stores
106// BI :: Branches - Immediate
107// BR :: Branches - Register
108// SN :: System - No Registers or Immediates
109// SI :: System - Immediate
110//
111// _ :: a separator char '_'
112//
113// -- the next two characters are
114//
115// # :: number of registers in the encoding
116// ? :: A unique letter A,B,C,...
117// -- optional third character
118// I :: by elem immediate
119//
120/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
121
122IF_DEF(BI_0A, IS_NONE, JMP) // BI_0A ......iiiiiiiiii iiiiiiiiiiiiiiii simm26:00 b
123IF_DEF(BI_0B, IS_NONE, JMP) // BI_0B ......iiiiiiiiii iiiiiiiiiii..... simm19:00 b<cond>
124IF_DEF(BI_0C, IS_NONE, CALL) // BI_0C ......iiiiiiiiii iiiiiiiiiiiiiiii simm26:00 bl
125IF_DEF(BI_1A, IS_NONE, JMP) // BI_1A X.......iiiiiiii iiiiiiiiiiittttt Rt simm19:00 cbz cbnz
126IF_DEF(BI_1B, IS_NONE, JMP) // BI_1B B.......bbbbbiii iiiiiiiiiiittttt Rt imm6 simm14:00 tbz tbnz
127IF_DEF(BR_1A, IS_NONE, CALL) // BR_1A ................ ......nnnnn..... Rn ret
128IF_DEF(BR_1B, IS_NONE, CALL) // BR_1B ................ ......nnnnn..... Rn br blr
129
130IF_DEF(LS_1A, IS_NONE, JMP) // LS_1A XX...V..iiiiiiii iiiiiiiiiiittttt Rt PC imm(1MB)
131IF_DEF(LS_2A, IS_NONE, NONE) // LS_2A .X.......X...... ......nnnnnttttt Rt Rn
132IF_DEF(LS_2B, IS_NONE, NONE) // LS_2B .X.......Xiiiiii iiiiiinnnnnttttt Rt Rn imm(0-4095)
133IF_DEF(LS_2C, IS_NONE, NONE) // LS_2C .X.......X.iiiii iiiiP.nnnnnttttt Rt Rn imm(-256..+255) pre/post inc
134IF_DEF(LS_3A, IS_NONE, NONE) // LS_3A .X.......X.mmmmm xxxS..nnnnnttttt Rt Rn Rm ext(Rm) LSL {}
135IF_DEF(LS_3B, IS_NONE, NONE) // LS_3B X............... .aaaaannnnnddddd Rd Ra Rn
136IF_DEF(LS_3C, IS_NONE, NONE) // LS_3C X.........iiiiii iaaaaannnnnddddd Rd Ra Rn imm(im7,sh)
137IF_DEF(LS_3D, IS_NONE, NONE) // LS_3D .X.......X.mmmmm ......nnnnnttttt Wm Rt Rn
138IF_DEF(LS_3E, IS_NONE, NONE) // LS_3E .X.........mmmmm ......nnnnnttttt Rm Rt Rn ARMv8.1 LSE Atomics
139
140IF_DEF(DI_1A, IS_NONE, NONE) // DI_1A X.......shiiiiii iiiiiinnnnn..... Rn imm(i12,sh)
141IF_DEF(DI_1B, IS_NONE, NONE) // DI_1B X........hwiiiii iiiiiiiiiiiddddd Rd imm(i16,hw)
142IF_DEF(DI_1C, IS_NONE, NONE) // DI_1C X........Nrrrrrr ssssssnnnnn..... Rn imm(N,r,s)
143IF_DEF(DI_1D, IS_NONE, NONE) // DI_1D X........Nrrrrrr ssssss.....ddddd Rd imm(N,r,s)
144IF_DEF(DI_1E, IS_NONE, JMP) // DI_1E .ii.....iiiiiiii iiiiiiiiiiiddddd Rd simm21
145IF_DEF(DI_1F, IS_NONE, NONE) // DI_1F X..........iiiii cccc..nnnnn.nzcv Rn imm5 nzcv cond
146
147IF_DEF(DI_2A, IS_NONE, NONE) // DI_2A X.......shiiiiii iiiiiinnnnnddddd Rd Rn imm(i12,sh)
148IF_DEF(DI_2B, IS_NONE, NONE) // DI_2B X.........Xnnnnn ssssssnnnnnddddd Rd Rn imm(0-63)
149IF_DEF(DI_2C, IS_NONE, NONE) // DI_2C X........Nrrrrrr ssssssnnnnnddddd Rd Rn imm(N,r,s)
150IF_DEF(DI_2D, IS_NONE, NONE) // DI_2D X........Nrrrrrr ssssssnnnnnddddd Rd Rn imr, imms (N,r,s)
151
152IF_DEF(DR_1D, IS_NONE, NONE) // DR_1D X............... cccc.......ddddd Rd cond
153
154IF_DEF(DR_2A, IS_NONE, NONE) // DR_2A X..........mmmmm ......nnnnn..... Rn Rm
155IF_DEF(DR_2B, IS_NONE, NONE) // DR_2B X.......sh.mmmmm ssssssnnnnn..... Rn Rm {LSL,LSR,ASR} imm(0-63)
156IF_DEF(DR_2C, IS_NONE, NONE) // DR_2C X..........mmmmm xxxsssnnnnn..... Rn Rm ext(Rm) LSL imm(0-4)
157IF_DEF(DR_2D, IS_NONE, NONE) // DR_2D X..........nnnnn cccc..nnnnnddddd Rd Rn cond
158IF_DEF(DR_2E, IS_NONE, NONE) // DR_2E X..........mmmmm ...........ddddd Rd Rm
159IF_DEF(DR_2F, IS_NONE, NONE) // DR_2F X.......sh.mmmmm ssssss.....ddddd Rd Rm {LSL,LSR,ASR} imm(0-63)
160IF_DEF(DR_2G, IS_NONE, NONE) // DR_2G X............... ......nnnnnddddd Rd Rn
161IF_DEF(DR_2H, IS_NONE, NONE) // DR_2H X........X...... ......nnnnnddddd Rd Rn
162IF_DEF(DR_2I, IS_NONE, NONE) // DR_2I X..........mmmmm cccc..nnnnn.nzcv Rn Rm nzcv cond
163IF_DEF(DR_2J, IS_NONE, NONE) // DR_2J ................ ......nnnnnddddd Sd Sn
164
165IF_DEF(DR_3A, IS_NONE, NONE) // DR_3A X..........mmmmm ......nnnnnddddd Rd Rn Rm
166IF_DEF(DR_3B, IS_NONE, NONE) // DR_3B X.......sh.mmmmm ssssssnnnnnddddd Rd Rn Rm {LSL,LSR,ASR} imm(0-63)
167IF_DEF(DR_3C, IS_NONE, NONE) // DR_3C X..........mmmmm xxxsssnnnnnddddd Rd Rn Rm ext(Rm) LSL imm(0-4)
168IF_DEF(DR_3D, IS_NONE, NONE) // DR_3D X..........mmmmm cccc..nnnnnddddd Rd Rn Rm cond
169IF_DEF(DR_3E, IS_NONE, NONE) // DR_3E X........X.mmmmm ssssssnnnnnddddd Rd Rn Rm imm(0-63)
170
171IF_DEF(DR_4A, IS_NONE, NONE) // DR_4A X..........mmmmm .aaaaannnnnddddd Rd Rn Rm Ra
172
173IF_DEF(DV_1A, IS_NONE, NONE) // DV_1A .........X.iiiii iii........ddddd Vd imm8 (fmov - immediate scalar)
174IF_DEF(DV_1B, IS_NONE, NONE) // DV_1B .QX..........iii jjjj..iiiiiddddd Vd imm8 (fmov/movi - immediate vector)
175IF_DEF(DV_1C, IS_NONE, NONE) // DV_1C .........X...... ......nnnnn..... Vn #0.0 (fcmp - with zero)
176
177IF_DEF(DV_2A, IS_NONE, NONE) // DV_2A .Q.......X...... ......nnnnnddddd Vd Vn (fabs, fcvtXX - vector)
178IF_DEF(DV_2B, IS_NONE, NONE) // DV_2B .Q.........iiiii ......nnnnnddddd Rd Vn[] (umov/smov - to general)
179IF_DEF(DV_2C, IS_NONE, NONE) // DV_2C .Q.........iiiii ......nnnnnddddd Vd Rn (dup/ins - vector from
180 // general)
181IF_DEF(DV_2D, IS_NONE, NONE) // DV_2D .Q.........iiiii ......nnnnnddddd Vd Vn[] (dup - vector)
182IF_DEF(DV_2E, IS_NONE, NONE) // DV_2E ...........iiiii ......nnnnnddddd Vd Vn[] (dup - scalar)
183IF_DEF(DV_2F, IS_NONE, NONE) // DV_2F ...........iiiii .jjjj.nnnnnddddd Vd[] Vn[] (ins - element)
184IF_DEF(DV_2G, IS_NONE, NONE) // DV_2G .........X...... ......nnnnnddddd Vd Vn (fmov, fcvtXX - register)
185IF_DEF(DV_2H, IS_NONE, NONE) // DV_2H X........X...... ......nnnnnddddd Rd Vn (fmov, fcvtXX - to general)
186IF_DEF(DV_2I, IS_NONE, NONE) // DV_2I X........X...... ......nnnnnddddd Vd Rn (fmov, fcvtXX - from general)
187IF_DEF(DV_2J, IS_NONE, NONE) // DV_2J .........d...... D.....nnnnnddddd Vd Vn (fcvt)
188IF_DEF(DV_2K, IS_NONE, NONE) // DV_2K .........X.mmmmm ......nnnnn..... Vn Vm (fcmp)
189IF_DEF(DV_2L, IS_NONE, NONE) // DV_2L ........XX...... ......nnnnnddddd Vd Vn (abs, neg - scalar)
190IF_DEF(DV_2M, IS_NONE, NONE) // DV_2M .Q......XX...... ......nnnnnddddd Vd Vn (abs, neg - vector)
191IF_DEF(DV_2N, IS_NONE, NONE) // DV_2N .........iiiiiii ......nnnnnddddd Vd Vn imm (shift - scalar)
192IF_DEF(DV_2O, IS_NONE, NONE) // DV_2O .Q.......iiiiiii ......nnnnnddddd Vd Vn imm (shift - vector)
193IF_DEF(DV_2P, IS_NONE, NONE) // DV_2P .,.............. ......nnnnnddddd Vd Vn (Vd used as both source and destination)
194
195IF_DEF(DV_3A, IS_NONE, NONE) // DV_3A .Q......XX.mmmmm ......nnnnnddddd Vd Vn Vm (vector)
196IF_DEF(DV_3AI, IS_NONE, NONE) // DV_3AI .Q......XXLMmmmm ....H.nnnnnddddd Vd Vn Vm[] (vector by elem)
197IF_DEF(DV_3B, IS_NONE, NONE) // DV_3B .Q.......X.mmmmm ......nnnnnddddd Vd Vn Vm (vector)
198IF_DEF(DV_3BI, IS_NONE, NONE) // DV_3BI .Q.......XLmmmmm ....H.nnnnnddddd Vd Vn Vm[] (vector by elem)
199IF_DEF(DV_3C, IS_NONE, NONE) // DV_3C .Q.........mmmmm ......nnnnnddddd Vd Vn Vm (vector)
200IF_DEF(DV_3D, IS_NONE, NONE) // DV_3D .........X.mmmmm ......nnnnnddddd Vd Vn Vm (scalar)
201IF_DEF(DV_3DI, IS_NONE, NONE) // DV_3DI .........XLmmmmm ....H.nnnnnddddd Vd Vn Vm[] (scalar by elem)
202IF_DEF(DV_3E, IS_NONE, NONE) // DV_3E ...........mmmmm ......nnnnnddddd Vd Vn Vm (scalar)
203IF_DEF(DV_3F, IS_NONE, NONE) // DV_3F ...........mmmmm ......nnnnnddddd Qd Sn Vm (Qd used as both source and destination)
204
205IF_DEF(DV_4A, IS_NONE, NONE) // DV_4A .........X.mmmmm .aaaaannnnnddddd Vd Vn Vm Va (scalar)
206
207IF_DEF(SN_0A, IS_NONE, NONE) // SN_0A ................ ................
208IF_DEF(SI_0A, IS_NONE, NONE) // SI_0A ...........iiiii iiiiiiiiiii..... imm16
209IF_DEF(SI_0B, IS_NONE, NONE) // SI_0B ................ ....bbbb........ imm4 - barrier
210
211IF_DEF(INVALID, IS_NONE, NONE) //
212
213//////////////////////////////////////////////////////////////////////////////
214#undef IF_DEF
215//////////////////////////////////////////////////////////////////////////////
216
217#endif // !DEFINE_ID_OPS
218//////////////////////////////////////////////////////////////////////////////
219// clang-format on
220