/src/capstonenext/arch/AArch64/AArch64Disassembler.c
Line  | Count  | Source  | 
1  |  | /* Capstone Disassembly Engine, http://www.capstone-engine.org */  | 
2  |  | /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2022, */  | 
3  |  | /*    Rot127 <unisono@quyllur.org> 2022-2023 */  | 
4  |  | /* Automatically translated source file from LLVM. */  | 
5  |  |  | 
6  |  | /* LLVM-commit: <commit> */  | 
7  |  | /* LLVM-tag: <tag> */  | 
8  |  |  | 
9  |  | /* Only small edits allowed. */  | 
10  |  | /* For multiple similar edits, please create a Patch for the translator. */  | 
11  |  |  | 
12  |  | /* Capstone's C++ file translator: */  | 
13  |  | /* https://github.com/capstone-engine/capstone/tree/next/suite/auto-sync */  | 
14  |  |  | 
15  |  | //===- AArch64Disassembler.cpp - Disassembler for AArch64 -----------------===//  | 
16  |  | //  | 
17  |  | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.  | 
18  |  | // See https://llvm.org/LICENSE.txt for license information.  | 
19  |  | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception  | 
20  |  | //  | 
21  |  | //===----------------------------------------------------------------------===//  | 
22  |  | //  | 
23  |  | //  | 
24  |  | //===----------------------------------------------------------------------===//  | 
25  |  |  | 
26  |  | #include <stdio.h>  | 
27  |  | #include <string.h>  | 
28  |  | #include <stdlib.h>  | 
29  |  | #include <capstone/platform.h>  | 
30  |  |  | 
31  |  | #include "../../MCFixedLenDisassembler.h"  | 
32  |  | #include "../../MCInst.h"  | 
33  |  | #include "../../MCInstrDesc.h"  | 
34  |  | #include "../../MCRegisterInfo.h"  | 
35  |  | #include "../../LEB128.h"  | 
36  |  | #include "../../MCDisassembler.h"  | 
37  |  | #include "../../cs_priv.h"  | 
38  |  | #include "../../utils.h"  | 
39  |  | #include "AArch64AddressingModes.h"  | 
40  |  | #include "AArch64BaseInfo.h"  | 
41  |  | #include "AArch64DisassemblerExtension.h"  | 
42  |  | #include "AArch64Linkage.h"  | 
43  |  | #include "AArch64Mapping.h"  | 
44  |  |  | 
45  |  | #define GET_INSTRINFO_MC_DESC  | 
46  |  | #include "AArch64GenInstrInfo.inc"  | 
47  |  |  | 
48  | 1.41k  | #define CONCAT(a, b) CONCAT_(a, b)  | 
49  | 1.41k  | #define CONCAT_(a, b) a##_##b  | 
50  |  |  | 
51  |  | #define DEBUG_TYPE "aarch64-disassembler"  | 
52  |  |  | 
53  |  | // Pull DecodeStatus and its enum values into the global namespace.  | 
54  |  |  | 
55  |  | // Forward declare these because the autogenerated code will reference them.  | 
56  |  | // Definitions are further down.  | 
57  |  | static DecodeStatus DecodeFPR128RegisterClass(MCInst *Inst, unsigned RegNo,  | 
58  |  |                 uint64_t Address,  | 
59  |  |                 const void *Decoder);  | 
60  |  | static DecodeStatus DecodeFPR128_loRegisterClass(MCInst *Inst, unsigned RegNo,  | 
61  |  |              uint64_t Address,  | 
62  |  |              const void *Decoder);  | 
63  |  | static DecodeStatus DecodeFPR128_0to7RegisterClass(MCInst *Inst, unsigned RegNo,  | 
64  |  |                uint64_t Address,  | 
65  |  |                const void *Decoder);  | 
66  |  | static DecodeStatus DecodeFPR64RegisterClass(MCInst *Inst, unsigned RegNo,  | 
67  |  |                uint64_t Address,  | 
68  |  |                const void *Decoder);  | 
69  |  | static DecodeStatus DecodeFPR32RegisterClass(MCInst *Inst, unsigned RegNo,  | 
70  |  |                uint64_t Address,  | 
71  |  |                const void *Decoder);  | 
72  |  | static DecodeStatus DecodeFPR16RegisterClass(MCInst *Inst, unsigned RegNo,  | 
73  |  |                uint64_t Address,  | 
74  |  |                const void *Decoder);  | 
75  |  | static DecodeStatus DecodeFPR8RegisterClass(MCInst *Inst, unsigned RegNo,  | 
76  |  |               uint64_t Address,  | 
77  |  |               const void *Decoder);  | 
78  |  | static DecodeStatus DecodeGPR64commonRegisterClass(MCInst *Inst, unsigned RegNo,  | 
79  |  |                uint64_t Address,  | 
80  |  |                const void *Decoder);  | 
81  |  | static DecodeStatus DecodeGPR64RegisterClass(MCInst *Inst, unsigned RegNo,  | 
82  |  |                uint64_t Address,  | 
83  |  |                const void *Decoder);  | 
84  |  | static DecodeStatus DecodeGPR64x8ClassRegisterClass(MCInst *Inst,  | 
85  |  |                 unsigned RegNo,  | 
86  |  |                 uint64_t Address,  | 
87  |  |                 const void *Decoder);  | 
88  |  | static DecodeStatus DecodeGPR64spRegisterClass(MCInst *Inst, unsigned RegNo,  | 
89  |  |                  uint64_t Address,  | 
90  |  |                  const void *Decoder);  | 
91  |  | static DecodeStatus  | 
92  |  | DecodeMatrixIndexGPR32_8_11RegisterClass(MCInst *Inst, unsigned RegNo,  | 
93  |  |            uint64_t Address, const void *Decoder);  | 
94  |  | static DecodeStatus DecodeMatrixIndexGPR32_12_15RegisterClass(  | 
95  |  |   MCInst *Inst, unsigned RegNo, uint64_t Address, const void *Decoder);  | 
96  |  | static DecodeStatus DecodeGPR32RegisterClass(MCInst *Inst, unsigned RegNo,  | 
97  |  |                uint64_t Address,  | 
98  |  |                const void *Decoder);  | 
99  |  | static DecodeStatus DecodeGPR32spRegisterClass(MCInst *Inst, unsigned RegNo,  | 
100  |  |                  uint64_t Address,  | 
101  |  |                  const void *Decoder);  | 
102  |  | static DecodeStatus DecodeQQRegisterClass(MCInst *Inst, unsigned RegNo,  | 
103  |  |             uint64_t Address,  | 
104  |  |             const void *Decoder);  | 
105  |  | static DecodeStatus DecodeQQQRegisterClass(MCInst *Inst, unsigned RegNo,  | 
106  |  |              uint64_t Address,  | 
107  |  |              const void *Decoder);  | 
108  |  | static DecodeStatus DecodeQQQQRegisterClass(MCInst *Inst, unsigned RegNo,  | 
109  |  |               uint64_t Address,  | 
110  |  |               const void *Decoder);  | 
111  |  | static DecodeStatus DecodeDDRegisterClass(MCInst *Inst, unsigned RegNo,  | 
112  |  |             uint64_t Address,  | 
113  |  |             const void *Decoder);  | 
114  |  | static DecodeStatus DecodeDDDRegisterClass(MCInst *Inst, unsigned RegNo,  | 
115  |  |              uint64_t Address,  | 
116  |  |              const void *Decoder);  | 
117  |  | static DecodeStatus DecodeDDDDRegisterClass(MCInst *Inst, unsigned RegNo,  | 
118  |  |               uint64_t Address,  | 
119  |  |               const void *Decoder);  | 
120  |  | static DecodeStatus DecodeZPRRegisterClass(MCInst *Inst, unsigned RegNo,  | 
121  |  |              uint64_t Address,  | 
122  |  |              const void *Decoder);  | 
123  |  | static DecodeStatus DecodeZPR_4bRegisterClass(MCInst *Inst, unsigned RegNo,  | 
124  |  |                 uint64_t Address,  | 
125  |  |                 const void *Decoder);  | 
126  |  | static DecodeStatus DecodeZPR_3bRegisterClass(MCInst *Inst, unsigned RegNo,  | 
127  |  |                 uint64_t Address,  | 
128  |  |                 const void *Decoder);  | 
129  |  | static DecodeStatus DecodeZPR2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
130  |  |               uint64_t Address,  | 
131  |  |               const void *Decoder);  | 
132  |  | static DecodeStatus DecodeZPR3RegisterClass(MCInst *Inst, unsigned RegNo,  | 
133  |  |               uint64_t Address,  | 
134  |  |               const void *Decoder);  | 
135  |  | static DecodeStatus DecodeZPR4RegisterClass(MCInst *Inst, unsigned RegNo,  | 
136  |  |               uint64_t Address,  | 
137  |  |               const void *Decoder);  | 
138  |  | static DecodeStatus DecodeZPR2Mul2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
139  |  |             uint64_t Address,  | 
140  |  |             const void *Decoder);  | 
141  |  | static DecodeStatus DecodeZPR4Mul4RegisterClass(MCInst *Inst, unsigned RegNo,  | 
142  |  |             uint64_t Address,  | 
143  |  |             const void *Decoder);  | 
144  |  | static DecodeStatus DecodeZPR2StridedRegisterClass(MCInst *Inst, unsigned RegNo,  | 
145  |  |                uint64_t Address,  | 
146  |  |                const void *Decoder);  | 
147  |  | static DecodeStatus DecodeZPR4StridedRegisterClass(MCInst *Inst, unsigned RegNo,  | 
148  |  |                uint64_t Address,  | 
149  |  |                const void *Decoder);  | 
150  |  | #define DECLARE_DecodeMatrixTile(NumBitsForTile) \  | 
151  |  |   static DecodeStatus CONCAT(DecodeMatrixTile, NumBitsForTile)( \  | 
152  |  |     MCInst * Inst, unsigned RegNo, uint64_t Address, \  | 
153  |  |     const void *Decoder);  | 
154  |  | DECLARE_DecodeMatrixTile(2);  | 
155  |  | DECLARE_DecodeMatrixTile(1);  | 
156  |  | DECLARE_DecodeMatrixTile(3);  | 
157  |  | DECLARE_DecodeMatrixTile(4);  | 
158  |  |  | 
159  |  | static DecodeStatus DecodeMatrixTileListRegisterClass(MCInst *Inst,  | 
160  |  |                   unsigned RegMask,  | 
161  |  |                   uint64_t Address,  | 
162  |  |                   const void *Decoder);  | 
163  |  | static DecodeStatus DecodePPRRegisterClass(MCInst *Inst, unsigned RegNo,  | 
164  |  |              uint64_t Address,  | 
165  |  |              const void *Decoder);  | 
166  |  | static DecodeStatus DecodePNRRegisterClass(MCInst *Inst, unsigned RegNo,  | 
167  |  |              uint64_t Address,  | 
168  |  |              const void *Decoder);  | 
169  |  | static DecodeStatus DecodePPR_3bRegisterClass(MCInst *Inst, unsigned RegNo,  | 
170  |  |                 uint64_t Address,  | 
171  |  |                 const void *Decoder);  | 
172  |  | static DecodeStatus DecodePNR_p8to15RegisterClass(MCInst *Inst, unsigned RegNo,  | 
173  |  |               uint64_t Address,  | 
174  |  |               const void *Decoder);  | 
175  |  | static DecodeStatus DecodePPR2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
176  |  |               uint64_t Address,  | 
177  |  |               const void *Decoder);  | 
178  |  | static DecodeStatus DecodePPR2Mul2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
179  |  |             uint64_t Address,  | 
180  |  |             const void *Decoder);  | 
181  |  |  | 
182  |  | static DecodeStatus DecodeFixedPointScaleImm32(MCInst *Inst, unsigned Imm,  | 
183  |  |                  uint64_t Address,  | 
184  |  |                  const void *Decoder);  | 
185  |  | static DecodeStatus DecodeFixedPointScaleImm64(MCInst *Inst, unsigned Imm,  | 
186  |  |                  uint64_t Address,  | 
187  |  |                  const void *Decoder);  | 
188  |  | static DecodeStatus DecodePCRelLabel16(MCInst *Inst, unsigned Imm,  | 
189  |  |                uint64_t Address, const void *Decoder);  | 
190  |  | static DecodeStatus DecodePCRelLabel19(MCInst *Inst, unsigned Imm,  | 
191  |  |                uint64_t Address, const void *Decoder);  | 
192  |  | static DecodeStatus DecodeMemExtend(MCInst *Inst, unsigned Imm,  | 
193  |  |             uint64_t Address, const void *Decoder);  | 
194  |  | static DecodeStatus DecodeMRSSystemRegister(MCInst *Inst, unsigned Imm,  | 
195  |  |               uint64_t Address,  | 
196  |  |               const void *Decoder);  | 
197  |  | static DecodeStatus DecodeMSRSystemRegister(MCInst *Inst, unsigned Imm,  | 
198  |  |               uint64_t Address,  | 
199  |  |               const void *Decoder);  | 
200  |  | static DecodeStatus DecodeThreeAddrSRegInstruction(MCInst *Inst, uint32_t insn,  | 
201  |  |                uint64_t Address,  | 
202  |  |                const void *Decoder);  | 
203  |  | static DecodeStatus DecodeMoveImmInstruction(MCInst *Inst, uint32_t insn,  | 
204  |  |                uint64_t Address,  | 
205  |  |                const void *Decoder);  | 
206  |  | static DecodeStatus DecodeUnsignedLdStInstruction(MCInst *Inst, uint32_t insn,  | 
207  |  |               uint64_t Address,  | 
208  |  |               const void *Decoder);  | 
209  |  | static DecodeStatus DecodeSignedLdStInstruction(MCInst *Inst, uint32_t insn,  | 
210  |  |             uint64_t Address,  | 
211  |  |             const void *Decoder);  | 
212  |  | static DecodeStatus DecodeExclusiveLdStInstruction(MCInst *Inst, uint32_t insn,  | 
213  |  |                uint64_t Address,  | 
214  |  |                const void *Decoder);  | 
215  |  | static DecodeStatus DecodePairLdStInstruction(MCInst *Inst, uint32_t insn,  | 
216  |  |                 uint64_t Address,  | 
217  |  |                 const void *Decoder);  | 
218  |  | static DecodeStatus DecodeAuthLoadInstruction(MCInst *Inst, uint32_t insn,  | 
219  |  |                 uint64_t Address,  | 
220  |  |                 const void *Decoder);  | 
221  |  | static DecodeStatus DecodeAddSubERegInstruction(MCInst *Inst, uint32_t insn,  | 
222  |  |             uint64_t Address,  | 
223  |  |             const void *Decoder);  | 
224  |  | static DecodeStatus DecodeLogicalImmInstruction(MCInst *Inst, uint32_t insn,  | 
225  |  |             uint64_t Address,  | 
226  |  |             const void *Decoder);  | 
227  |  | static DecodeStatus DecodeModImmInstruction(MCInst *Inst, uint32_t insn,  | 
228  |  |               uint64_t Address,  | 
229  |  |               const void *Decoder);  | 
230  |  | static DecodeStatus DecodeModImmTiedInstruction(MCInst *Inst, uint32_t insn,  | 
231  |  |             uint64_t Address,  | 
232  |  |             const void *Decoder);  | 
233  |  | static DecodeStatus DecodeAdrInstruction(MCInst *Inst, uint32_t insn,  | 
234  |  |            uint64_t Address, const void *Decoder);  | 
235  |  | static DecodeStatus DecodeAddSubImmShift(MCInst *Inst, uint32_t insn,  | 
236  |  |            uint64_t Address, const void *Decoder);  | 
237  |  | static DecodeStatus DecodeUnconditionalBranch(MCInst *Inst, uint32_t insn,  | 
238  |  |                 uint64_t Address,  | 
239  |  |                 const void *Decoder);  | 
240  |  | static DecodeStatus DecodeSystemPStateImm0_15Instruction(MCInst *Inst,  | 
241  |  |                uint32_t insn,  | 
242  |  |                uint64_t Address,  | 
243  |  |                const void *Decoder);  | 
244  |  | static DecodeStatus DecodeSystemPStateImm0_1Instruction(MCInst *Inst,  | 
245  |  |               uint32_t insn,  | 
246  |  |               uint64_t Address,  | 
247  |  |               const void *Decoder);  | 
248  |  | static DecodeStatus DecodeTestAndBranch(MCInst *Inst, uint32_t insn,  | 
249  |  |           uint64_t Address, const void *Decoder);  | 
250  |  |  | 
251  |  | static DecodeStatus DecodeFMOVLaneInstruction(MCInst *Inst, unsigned Insn,  | 
252  |  |                 uint64_t Address,  | 
253  |  |                 const void *Decoder);  | 
254  |  | static DecodeStatus DecodeVecShiftR64Imm(MCInst *Inst, unsigned Imm,  | 
255  |  |            uint64_t Addr, const void *Decoder);  | 
256  |  | static DecodeStatus DecodeVecShiftR64ImmNarrow(MCInst *Inst, unsigned Imm,  | 
257  |  |                  uint64_t Addr,  | 
258  |  |                  const void *Decoder);  | 
259  |  | static DecodeStatus DecodeVecShiftR32Imm(MCInst *Inst, unsigned Imm,  | 
260  |  |            uint64_t Addr, const void *Decoder);  | 
261  |  | static DecodeStatus DecodeVecShiftR32ImmNarrow(MCInst *Inst, unsigned Imm,  | 
262  |  |                  uint64_t Addr,  | 
263  |  |                  const void *Decoder);  | 
264  |  | static DecodeStatus DecodeVecShiftR16Imm(MCInst *Inst, unsigned Imm,  | 
265  |  |            uint64_t Addr, const void *Decoder);  | 
266  |  | static DecodeStatus DecodeVecShiftR16ImmNarrow(MCInst *Inst, unsigned Imm,  | 
267  |  |                  uint64_t Addr,  | 
268  |  |                  const void *Decoder);  | 
269  |  | static DecodeStatus DecodeVecShiftR8Imm(MCInst *Inst, unsigned Imm,  | 
270  |  |           uint64_t Addr, const void *Decoder);  | 
271  |  | static DecodeStatus DecodeVecShiftL64Imm(MCInst *Inst, unsigned Imm,  | 
272  |  |            uint64_t Addr, const void *Decoder);  | 
273  |  | static DecodeStatus DecodeVecShiftL32Imm(MCInst *Inst, unsigned Imm,  | 
274  |  |            uint64_t Addr, const void *Decoder);  | 
275  |  | static DecodeStatus DecodeVecShiftL16Imm(MCInst *Inst, unsigned Imm,  | 
276  |  |            uint64_t Addr, const void *Decoder);  | 
277  |  | static DecodeStatus DecodeVecShiftL8Imm(MCInst *Inst, unsigned Imm,  | 
278  |  |           uint64_t Addr, const void *Decoder);  | 
279  |  | static DecodeStatus DecodeWSeqPairsClassRegisterClass(MCInst *Inst,  | 
280  |  |                   unsigned RegNo,  | 
281  |  |                   uint64_t Addr,  | 
282  |  |                   const void *Decoder);  | 
283  |  | static DecodeStatus DecodeXSeqPairsClassRegisterClass(MCInst *Inst,  | 
284  |  |                   unsigned RegNo,  | 
285  |  |                   uint64_t Addr,  | 
286  |  |                   const void *Decoder);  | 
287  |  | static DecodeStatus DecodeSyspXzrInstruction(MCInst *Inst, uint32_t insn,  | 
288  |  |                uint64_t Addr,  | 
289  |  |                const void *Decoder);  | 
290  |  | static DecodeStatus DecodeSVELogicalImmInstruction(MCInst *Inst, uint32_t insn,  | 
291  |  |                uint64_t Address,  | 
292  |  |                const void *Decoder);  | 
293  |  | #define DECLARE_DecodeSImm(Bits) \  | 
294  |  |   static DecodeStatus CONCAT(DecodeSImm, Bits)(MCInst * Inst, \  | 
295  |  |                  uint64_t Imm, \  | 
296  |  |                  uint64_t Address, \  | 
297  |  |                  const void *Decoder);  | 
298  |  | DECLARE_DecodeSImm(4);  | 
299  |  | DECLARE_DecodeSImm(5);  | 
300  |  | DECLARE_DecodeSImm(6);  | 
301  |  | DECLARE_DecodeSImm(8);  | 
302  |  | DECLARE_DecodeSImm(9);  | 
303  |  | DECLARE_DecodeSImm(10);  | 
304  |  |  | 
305  |  | #define DECLARE_DecodeImm8OptLsl(ElementWidth) \  | 
306  |  |   static DecodeStatus CONCAT(DecodeImm8OptLsl, ElementWidth)( \  | 
307  |  |     MCInst * Inst, unsigned Imm, uint64_t Addr, \  | 
308  |  |     const void *Decoder);  | 
309  |  | DECLARE_DecodeImm8OptLsl(8);  | 
310  |  | DECLARE_DecodeImm8OptLsl(16);  | 
311  |  | DECLARE_DecodeImm8OptLsl(32);  | 
312  |  | DECLARE_DecodeImm8OptLsl(64);  | 
313  |  |  | 
314  |  | static DecodeStatus DecodeSVEIncDecImm(MCInst *Inst, unsigned Imm,  | 
315  |  |                uint64_t Addr, const void *Decoder);  | 
316  |  | static DecodeStatus DecodeSVCROp(MCInst *Inst, unsigned Imm, uint64_t Address,  | 
317  |  |          const void *Decoder);  | 
318  |  | static DecodeStatus DecodeCPYMemOpInstruction(MCInst *Inst, uint32_t insn,  | 
319  |  |                 uint64_t Addr,  | 
320  |  |                 const void *Decoder);  | 
321  |  | static DecodeStatus DecodeSETMemOpInstruction(MCInst *Inst, uint32_t insn,  | 
322  |  |                 uint64_t Addr,  | 
323  |  |                 const void *Decoder);  | 
324  |  | static DecodeStatus DecodePRFMRegInstruction(MCInst *Inst, uint32_t insn,  | 
325  |  |                uint64_t Address,  | 
326  |  |                const void *Decoder);  | 
327  |  |  | 
328  |  | #include "AArch64GenDisassemblerTables.inc"  | 
329  |  |  | 
330  | 1.14M  | #define Success MCDisassembler_Success  | 
331  | 10.8k  | #define Fail MCDisassembler_Fail  | 
332  | 1.99k  | #define SoftFail MCDisassembler_SoftFail  | 
333  |  |  | 
334  |  | static DecodeStatus getInstruction(csh handle, const uint8_t *Bytes,  | 
335  |  |            size_t ByteLen, MCInst *MI, uint16_t *Size,  | 
336  |  |            uint64_t Address, void *Info)  | 
337  | 392k  | { | 
338  | 392k  |   *Size = 0;  | 
339  |  |   // We want to read exactly 4 bytes of data.  | 
340  | 392k  |   if (ByteLen < 4)  | 
341  | 4.08k  |     return Fail;  | 
342  | 388k  |   *Size = 4;  | 
343  |  |  | 
344  |  |   // Encoded as a small-endian 32-bit word in the stream.  | 
345  | 388k  |   uint32_t Insn = readBytes32(MI, Bytes);  | 
346  |  |  | 
347  | 388k  |   const uint8_t *Tables[] = { DecoderTable32, DecoderTableFallback32 }; | 
348  |  |  | 
349  | 403k  |   for (int i = 0; i < (sizeof(Tables) / sizeof(Tables[0])); ++i) { | 
350  | 401k  |     void *Decoder = NULL;  | 
351  | 401k  |     DecodeStatus Result = decodeInstruction_4(Tables[i], MI, Insn,  | 
352  | 401k  |                 Address, Decoder);  | 
353  |  |  | 
354  |  |     // Table is indexed backwards  | 
355  | 401k  |     const MCInstrDesc Desc =  | 
356  | 401k  |       AArch64Descs.Insts[ARR_SIZE(AArch64Descs.Insts) - 1 -  | 
357  | 401k  |              MCInst_getOpcode(MI)];  | 
358  |  |  | 
359  |  |     // For Scalable Matrix Extension (SME) instructions that have an  | 
360  |  |     // implicit operand for the accumulator (ZA) or implicit immediate zero  | 
361  |  |     // which isn't encoded, manually insert operand.  | 
362  | 1.78M  |     for (unsigned j = 0; j < Desc.NumOperands; j++) { | 
363  | 1.38M  |       if (Desc.OpInfo[j].OperandType ==  | 
364  | 1.38M  |           MCOI_OPERAND_REGISTER) { | 
365  | 988k  |         switch (Desc.OpInfo[j].RegClass) { | 
366  | 962k  |         default:  | 
367  | 962k  |           break;  | 
368  | 962k  |         case AArch64_MPRRegClassID:  | 
369  | 19.1k  |           MCInst_insert0(MI, j,  | 
370  | 19.1k  |                    MCOperand_CreateReg1(  | 
371  | 19.1k  |                      MI, AArch64_ZA));  | 
372  | 19.1k  |           break;  | 
373  | 4.71k  |         case AArch64_MPR8RegClassID:  | 
374  | 4.71k  |           MCInst_insert0(MI, j,  | 
375  | 4.71k  |                    MCOperand_CreateReg1(  | 
376  | 4.71k  |                      MI,  | 
377  | 4.71k  |                      AArch64_ZAB0));  | 
378  | 4.71k  |           break;  | 
379  | 2.33k  |         case AArch64_ZTRRegClassID:  | 
380  | 2.33k  |           MCInst_insert0(MI, j,  | 
381  | 2.33k  |                    MCOperand_CreateReg1(  | 
382  | 2.33k  |                      MI,  | 
383  | 2.33k  |                      AArch64_ZT0));  | 
384  | 2.33k  |           break;  | 
385  | 988k  |         }  | 
386  | 988k  |       } else if (Desc.OpInfo[j].OperandType ==  | 
387  | 399k  |            AARCH64_OP_IMPLICIT_IMM_0) { | 
388  | 2.59k  |         MCInst_insert0(MI, j,  | 
389  | 2.59k  |                  MCOperand_CreateImm1(MI, 0));  | 
390  | 2.59k  |       }  | 
391  | 1.38M  |     }  | 
392  |  |  | 
393  | 401k  |     if (MCInst_getOpcode(MI) == AArch64_LDR_ZA ||  | 
394  | 401k  |         MCInst_getOpcode(MI) == AArch64_STR_ZA) { | 
395  |  |       // Spill and fill instructions have a single immediate used for both  | 
396  |  |       // the vector select offset and optional memory offset. Replicate  | 
397  |  |       // the decoded immediate.  | 
398  | 277  |       MCOperand *Imm4Op = MCInst_getOperand(MI, (2));  | 
399  |  |  | 
400  | 277  |       MCInst_addOperand2(MI, (Imm4Op));  | 
401  | 277  |     }  | 
402  |  |  | 
403  | 401k  |     if (Result != MCDisassembler_Fail)  | 
404  | 386k  |       return Result;  | 
405  | 401k  |   }  | 
406  |  |  | 
407  | 2.42k  |   return MCDisassembler_Fail;  | 
408  | 388k  | }  | 
409  |  |  | 
410  |  | DecodeStatus AArch64_LLVM_getInstruction(csh handle, const uint8_t *Bytes,  | 
411  |  |            size_t ByteLen, MCInst *MI,  | 
412  |  |            uint16_t *Size, uint64_t Address,  | 
413  |  |            void *Info)  | 
414  | 392k  | { | 
415  | 392k  |   DecodeStatus Result = MCDisassembler_Fail;  | 
416  | 392k  |   Result =  | 
417  | 392k  |     getInstruction(handle, Bytes, ByteLen, MI, Size, Address, Info);  | 
418  | 392k  |   MCInst_handleWriteback(MI, AArch64Descs.Insts,  | 
419  | 392k  |              ARR_SIZE(AArch64Descs.Insts));  | 
420  | 392k  |   return Result;  | 
421  | 392k  | }  | 
422  |  |  | 
423  |  | uint64_t suggestBytesToSkip(const uint8_t *Bytes, uint64_t Address)  | 
424  | 0  | { | 
425  |  |   // AArch64 instructions are always 4 bytes wide, so there's no point  | 
426  |  |   // in skipping any smaller number of bytes if an instruction can't  | 
427  |  |   // be decoded.  | 
428  | 0  |   return 4;  | 
429  | 0  | }  | 
430  |  |  | 
431  |  | static DecodeStatus DecodeFPR128RegisterClass(MCInst *Inst, unsigned RegNo,  | 
432  |  |                 uint64_t Addr,  | 
433  |  |                 const void *Decoder)  | 
434  | 84.3k  | { | 
435  | 84.3k  |   if (RegNo > 31)  | 
436  | 0  |     return Fail;  | 
437  |  |  | 
438  | 84.3k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_FPR128RegClassID]  | 
439  | 84.3k  |             .RegsBegin[RegNo];  | 
440  | 84.3k  |   MCOperand_CreateReg0(Inst, (Register));  | 
441  | 84.3k  |   return Success;  | 
442  | 84.3k  | }  | 
443  |  |  | 
444  |  | static DecodeStatus DecodeFPR128_loRegisterClass(MCInst *Inst, unsigned RegNo,  | 
445  |  |              uint64_t Addr,  | 
446  |  |              const void *Decoder)  | 
447  | 1.33k  | { | 
448  | 1.33k  |   if (RegNo > 15)  | 
449  | 0  |     return Fail;  | 
450  | 1.33k  |   return DecodeFPR128RegisterClass(Inst, RegNo, Addr, Decoder);  | 
451  | 1.33k  | }  | 
452  |  |  | 
453  |  | static DecodeStatus DecodeFPR128_0to7RegisterClass(MCInst *Inst, unsigned RegNo,  | 
454  |  |                uint64_t Addr,  | 
455  |  |                const void *Decoder)  | 
456  | 93  | { | 
457  | 93  |   if (RegNo > 7)  | 
458  | 0  |     return Fail;  | 
459  | 93  |   return DecodeFPR128RegisterClass(Inst, RegNo, Addr, Decoder);  | 
460  | 93  | }  | 
461  |  |  | 
462  |  | static DecodeStatus DecodeFPR64RegisterClass(MCInst *Inst, unsigned RegNo,  | 
463  |  |                uint64_t Addr, const void *Decoder)  | 
464  | 49.9k  | { | 
465  | 49.9k  |   if (RegNo > 31)  | 
466  | 0  |     return Fail;  | 
467  |  |  | 
468  | 49.9k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_FPR64RegClassID]  | 
469  | 49.9k  |             .RegsBegin[RegNo];  | 
470  | 49.9k  |   MCOperand_CreateReg0(Inst, (Register));  | 
471  | 49.9k  |   return Success;  | 
472  | 49.9k  | }  | 
473  |  |  | 
474  |  | static DecodeStatus DecodeFPR32RegisterClass(MCInst *Inst, unsigned RegNo,  | 
475  |  |                uint64_t Addr, const void *Decoder)  | 
476  | 17.8k  | { | 
477  | 17.8k  |   if (RegNo > 31)  | 
478  | 0  |     return Fail;  | 
479  |  |  | 
480  | 17.8k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_FPR32RegClassID]  | 
481  | 17.8k  |             .RegsBegin[RegNo];  | 
482  | 17.8k  |   MCOperand_CreateReg0(Inst, (Register));  | 
483  | 17.8k  |   return Success;  | 
484  | 17.8k  | }  | 
485  |  |  | 
486  |  | static DecodeStatus DecodeFPR16RegisterClass(MCInst *Inst, unsigned RegNo,  | 
487  |  |                uint64_t Addr, const void *Decoder)  | 
488  | 14.0k  | { | 
489  | 14.0k  |   if (RegNo > 31)  | 
490  | 0  |     return Fail;  | 
491  |  |  | 
492  | 14.0k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_FPR16RegClassID]  | 
493  | 14.0k  |             .RegsBegin[RegNo];  | 
494  | 14.0k  |   MCOperand_CreateReg0(Inst, (Register));  | 
495  | 14.0k  |   return Success;  | 
496  | 14.0k  | }  | 
497  |  |  | 
498  |  | static DecodeStatus DecodeFPR8RegisterClass(MCInst *Inst, unsigned RegNo,  | 
499  |  |               uint64_t Addr, const void *Decoder)  | 
500  | 4.23k  | { | 
501  | 4.23k  |   if (RegNo > 31)  | 
502  | 0  |     return Fail;  | 
503  |  |  | 
504  | 4.23k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_FPR8RegClassID]  | 
505  | 4.23k  |             .RegsBegin[RegNo];  | 
506  | 4.23k  |   MCOperand_CreateReg0(Inst, (Register));  | 
507  | 4.23k  |   return Success;  | 
508  | 4.23k  | }  | 
509  |  |  | 
510  |  | static DecodeStatus DecodeGPR64commonRegisterClass(MCInst *Inst, unsigned RegNo,  | 
511  |  |                uint64_t Addr,  | 
512  |  |                const void *Decoder)  | 
513  | 7.14k  | { | 
514  | 7.14k  |   if (RegNo > 30)  | 
515  | 10  |     return Fail;  | 
516  |  |  | 
517  | 7.13k  |   unsigned Register =  | 
518  | 7.13k  |     AArch64MCRegisterClasses[AArch64_GPR64commonRegClassID]  | 
519  | 7.13k  |       .RegsBegin[RegNo];  | 
520  | 7.13k  |   MCOperand_CreateReg0(Inst, (Register));  | 
521  | 7.13k  |   return Success;  | 
522  | 7.14k  | }  | 
523  |  |  | 
524  |  | static DecodeStatus DecodeGPR64RegisterClass(MCInst *Inst, unsigned RegNo,  | 
525  |  |                uint64_t Addr, const void *Decoder)  | 
526  | 164k  | { | 
527  | 164k  |   if (RegNo > 31)  | 
528  | 0  |     return Fail;  | 
529  |  |  | 
530  | 164k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_GPR64RegClassID]  | 
531  | 164k  |             .RegsBegin[RegNo];  | 
532  | 164k  |   MCOperand_CreateReg0(Inst, (Register));  | 
533  | 164k  |   return Success;  | 
534  | 164k  | }  | 
535  |  |  | 
536  |  | static DecodeStatus DecodeGPR64x8ClassRegisterClass(MCInst *Inst,  | 
537  |  |                 unsigned RegNo,  | 
538  |  |                 uint64_t Address,  | 
539  |  |                 const void *Decoder)  | 
540  | 142  | { | 
541  | 142  |   if (RegNo > 22)  | 
542  | 2  |     return Fail;  | 
543  | 140  |   if (RegNo & 1)  | 
544  | 2  |     return Fail;  | 
545  |  |  | 
546  | 138  |   unsigned Register =  | 
547  | 138  |     AArch64MCRegisterClasses[AArch64_GPR64x8ClassRegClassID]  | 
548  | 138  |       .RegsBegin[RegNo >> 1];  | 
549  | 138  |   MCOperand_CreateReg0(Inst, (Register));  | 
550  | 138  |   return Success;  | 
551  | 140  | }  | 
552  |  |  | 
553  |  | static DecodeStatus DecodeGPR64spRegisterClass(MCInst *Inst, unsigned RegNo,  | 
554  |  |                  uint64_t Addr,  | 
555  |  |                  const void *Decoder)  | 
556  | 169k  | { | 
557  | 169k  |   if (RegNo > 31)  | 
558  | 0  |     return Fail;  | 
559  | 169k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_GPR64spRegClassID]  | 
560  | 169k  |             .RegsBegin[RegNo];  | 
561  | 169k  |   MCOperand_CreateReg0(Inst, (Register));  | 
562  | 169k  |   return Success;  | 
563  | 169k  | }  | 
564  |  |  | 
565  |  | static DecodeStatus  | 
566  |  | DecodeMatrixIndexGPR32_8_11RegisterClass(MCInst *Inst, unsigned RegNo,  | 
567  |  |            uint64_t Addr, const void *Decoder)  | 
568  | 9.85k  | { | 
569  | 9.85k  |   if (RegNo > 3)  | 
570  | 0  |     return Fail;  | 
571  |  |  | 
572  | 9.85k  |   unsigned Register =  | 
573  | 9.85k  |     AArch64MCRegisterClasses[AArch64_MatrixIndexGPR32_8_11RegClassID]  | 
574  | 9.85k  |       .RegsBegin[RegNo];  | 
575  | 9.85k  |   MCOperand_CreateReg0(Inst, (Register));  | 
576  | 9.85k  |   return Success;  | 
577  | 9.85k  | }  | 
578  |  |  | 
579  |  | static DecodeStatus  | 
580  |  | DecodeMatrixIndexGPR32_12_15RegisterClass(MCInst *Inst, unsigned RegNo,  | 
581  |  |             uint64_t Addr, const void *Decoder)  | 
582  | 9.89k  | { | 
583  | 9.89k  |   if (RegNo > 3)  | 
584  | 0  |     return Fail;  | 
585  |  |  | 
586  | 9.89k  |   unsigned Register =  | 
587  | 9.89k  |     AArch64MCRegisterClasses[AArch64_MatrixIndexGPR32_12_15RegClassID]  | 
588  | 9.89k  |       .RegsBegin[RegNo];  | 
589  | 9.89k  |   MCOperand_CreateReg0(Inst, (Register));  | 
590  | 9.89k  |   return Success;  | 
591  | 9.89k  | }  | 
592  |  |  | 
593  |  | static DecodeStatus DecodeGPR32RegisterClass(MCInst *Inst, unsigned RegNo,  | 
594  |  |                uint64_t Addr, const void *Decoder)  | 
595  | 69.4k  | { | 
596  | 69.4k  |   if (RegNo > 31)  | 
597  | 0  |     return Fail;  | 
598  |  |  | 
599  | 69.4k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_GPR32RegClassID]  | 
600  | 69.4k  |             .RegsBegin[RegNo];  | 
601  | 69.4k  |   MCOperand_CreateReg0(Inst, (Register));  | 
602  | 69.4k  |   return Success;  | 
603  | 69.4k  | }  | 
604  |  |  | 
605  |  | static DecodeStatus DecodeGPR32spRegisterClass(MCInst *Inst, unsigned RegNo,  | 
606  |  |                  uint64_t Addr,  | 
607  |  |                  const void *Decoder)  | 
608  | 11.5k  | { | 
609  | 11.5k  |   if (RegNo > 31)  | 
610  | 0  |     return Fail;  | 
611  |  |  | 
612  | 11.5k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_GPR32spRegClassID]  | 
613  | 11.5k  |             .RegsBegin[RegNo];  | 
614  | 11.5k  |   MCOperand_CreateReg0(Inst, (Register));  | 
615  | 11.5k  |   return Success;  | 
616  | 11.5k  | }  | 
617  |  |  | 
618  |  | static DecodeStatus DecodeZPRRegisterClass(MCInst *Inst, unsigned RegNo,  | 
619  |  |              uint64_t Address,  | 
620  |  |              const void *Decoder)  | 
621  | 171k  | { | 
622  | 171k  |   if (RegNo > 31)  | 
623  | 0  |     return Fail;  | 
624  |  |  | 
625  | 171k  |   unsigned Register =  | 
626  | 171k  |     AArch64MCRegisterClasses[AArch64_ZPRRegClassID].RegsBegin[RegNo];  | 
627  | 171k  |   MCOperand_CreateReg0(Inst, (Register));  | 
628  | 171k  |   return Success;  | 
629  | 171k  | }  | 
630  |  |  | 
631  |  | static DecodeStatus DecodeZPR_4bRegisterClass(MCInst *Inst, unsigned RegNo,  | 
632  |  |                 uint64_t Address,  | 
633  |  |                 const void *Decoder)  | 
634  | 7.93k  | { | 
635  | 7.93k  |   if (RegNo > 15)  | 
636  | 0  |     return Fail;  | 
637  | 7.93k  |   return DecodeZPRRegisterClass(Inst, RegNo, Address, Decoder);  | 
638  | 7.93k  | }  | 
639  |  |  | 
640  |  | static DecodeStatus DecodeZPR_3bRegisterClass(MCInst *Inst, unsigned RegNo,  | 
641  |  |                 uint64_t Address,  | 
642  |  |                 const void *Decoder)  | 
643  | 906  | { | 
644  | 906  |   if (RegNo > 7)  | 
645  | 0  |     return Fail;  | 
646  | 906  |   return DecodeZPRRegisterClass(Inst, RegNo, Address, Decoder);  | 
647  | 906  | }  | 
648  |  |  | 
649  |  | static DecodeStatus DecodeZPR2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
650  |  |               uint64_t Address,  | 
651  |  |               const void *Decoder)  | 
652  | 2.74k  | { | 
653  | 2.74k  |   if (RegNo > 31)  | 
654  | 0  |     return Fail;  | 
655  | 2.74k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_ZPR2RegClassID]  | 
656  | 2.74k  |             .RegsBegin[RegNo];  | 
657  | 2.74k  |   MCOperand_CreateReg0(Inst, (Register));  | 
658  | 2.74k  |   return Success;  | 
659  | 2.74k  | }  | 
660  |  |  | 
661  |  | static DecodeStatus DecodeZPR3RegisterClass(MCInst *Inst, unsigned RegNo,  | 
662  |  |               uint64_t Address,  | 
663  |  |               const void *Decoder)  | 
664  | 302  | { | 
665  | 302  |   if (RegNo > 31)  | 
666  | 0  |     return Fail;  | 
667  | 302  |   unsigned Register = AArch64MCRegisterClasses[AArch64_ZPR3RegClassID]  | 
668  | 302  |             .RegsBegin[RegNo];  | 
669  | 302  |   MCOperand_CreateReg0(Inst, (Register));  | 
670  | 302  |   return Success;  | 
671  | 302  | }  | 
672  |  |  | 
673  |  | static DecodeStatus DecodeZPR4RegisterClass(MCInst *Inst, unsigned RegNo,  | 
674  |  |               uint64_t Address,  | 
675  |  |               const void *Decoder)  | 
676  | 1.96k  | { | 
677  | 1.96k  |   if (RegNo > 31)  | 
678  | 0  |     return Fail;  | 
679  | 1.96k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_ZPR4RegClassID]  | 
680  | 1.96k  |             .RegsBegin[RegNo];  | 
681  | 1.96k  |   MCOperand_CreateReg0(Inst, (Register));  | 
682  | 1.96k  |   return Success;  | 
683  | 1.96k  | }  | 
684  |  |  | 
685  |  | static DecodeStatus DecodeZPR2Mul2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
686  |  |             uint64_t Address,  | 
687  |  |             const void *Decoder)  | 
688  | 13.3k  | { | 
689  | 13.3k  |   if (RegNo * 2 > 30)  | 
690  | 0  |     return Fail;  | 
691  | 13.3k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_ZPR2RegClassID]  | 
692  | 13.3k  |             .RegsBegin[RegNo * 2];  | 
693  | 13.3k  |   MCOperand_CreateReg0(Inst, (Register));  | 
694  | 13.3k  |   return Success;  | 
695  | 13.3k  | }  | 
696  |  |  | 
697  |  | static DecodeStatus DecodeZPR4Mul4RegisterClass(MCInst *Inst, unsigned RegNo,  | 
698  |  |             uint64_t Address,  | 
699  |  |             const void *Decoder)  | 
700  | 11.9k  | { | 
701  | 11.9k  |   if (RegNo * 4 > 28)  | 
702  | 0  |     return Fail;  | 
703  | 11.9k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_ZPR4RegClassID]  | 
704  | 11.9k  |             .RegsBegin[RegNo * 4];  | 
705  | 11.9k  |   MCOperand_CreateReg0(Inst, (Register));  | 
706  | 11.9k  |   return Success;  | 
707  | 11.9k  | }  | 
708  |  |  | 
709  |  | static DecodeStatus DecodeZPR2StridedRegisterClass(MCInst *Inst, unsigned RegNo,  | 
710  |  |                uint64_t Address,  | 
711  |  |                const void *Decoder)  | 
712  | 6.24k  | { | 
713  | 6.24k  |   if (RegNo > 15)  | 
714  | 0  |     return Fail;  | 
715  | 6.24k  |   unsigned Register =  | 
716  | 6.24k  |     AArch64MCRegisterClasses[AArch64_ZPR2StridedRegClassID]  | 
717  | 6.24k  |       .RegsBegin[RegNo];  | 
718  | 6.24k  |   MCOperand_CreateReg0(Inst, (Register));  | 
719  | 6.24k  |   return Success;  | 
720  | 6.24k  | }  | 
721  |  |  | 
722  |  | static DecodeStatus DecodeZPR4StridedRegisterClass(MCInst *Inst, unsigned RegNo,  | 
723  |  |                uint64_t Address,  | 
724  |  |                const void *Decoder)  | 
725  | 1.68k  | { | 
726  | 1.68k  |   if (RegNo > 7)  | 
727  | 0  |     return Fail;  | 
728  | 1.68k  |   unsigned Register =  | 
729  | 1.68k  |     AArch64MCRegisterClasses[AArch64_ZPR4StridedRegClassID]  | 
730  | 1.68k  |       .RegsBegin[RegNo];  | 
731  | 1.68k  |   MCOperand_CreateReg0(Inst, (Register));  | 
732  | 1.68k  |   return Success;  | 
733  | 1.68k  | }  | 
734  |  |  | 
735  |  | static DecodeStatus DecodeMatrixTileListRegisterClass(MCInst *Inst,  | 
736  |  |                   unsigned RegMask,  | 
737  |  |                   uint64_t Address,  | 
738  |  |                   const void *Decoder)  | 
739  | 2.56k  | { | 
740  | 2.56k  |   if (RegMask > 0xFF)  | 
741  | 0  |     return Fail;  | 
742  | 2.56k  |   MCOperand_CreateImm0(Inst, (RegMask));  | 
743  | 2.56k  |   return Success;  | 
744  | 2.56k  | }  | 
745  |  |  | 
746  |  | static const MCPhysReg MatrixZATileDecoderTable[5][16] = { | 
747  |  |   { AArch64_ZAB0 }, | 
748  |  |   { AArch64_ZAH0, AArch64_ZAH1 }, | 
749  |  |   { AArch64_ZAS0, AArch64_ZAS1, AArch64_ZAS2, AArch64_ZAS3 }, | 
750  |  |   { AArch64_ZAD0, AArch64_ZAD1, AArch64_ZAD2, AArch64_ZAD3, AArch64_ZAD4, | 
751  |  |     AArch64_ZAD5, AArch64_ZAD6, AArch64_ZAD7 },  | 
752  |  |   { AArch64_ZAQ0, AArch64_ZAQ1, AArch64_ZAQ2, AArch64_ZAQ3, AArch64_ZAQ4, | 
753  |  |     AArch64_ZAQ5, AArch64_ZAQ6, AArch64_ZAQ7, AArch64_ZAQ8, AArch64_ZAQ9,  | 
754  |  |     AArch64_ZAQ10, AArch64_ZAQ11, AArch64_ZAQ12, AArch64_ZAQ13,  | 
755  |  |     AArch64_ZAQ14, AArch64_ZAQ15 }  | 
756  |  | };  | 
757  |  |  | 
758  |  | #define DEFINE_DecodeMatrixTile(NumBitsForTile) \  | 
759  |  |   static DecodeStatus CONCAT(DecodeMatrixTile, NumBitsForTile)( \  | 
760  |  |     MCInst * Inst, unsigned RegNo, uint64_t Address, \  | 
761  |  |     const void *Decoder) \  | 
762  | 14.4k  |   { \ | 
763  | 14.4k  |     unsigned LastReg = (1 << NumBitsForTile) - 1; \  | 
764  | 14.4k  |     if (RegNo > LastReg) \  | 
765  | 14.4k  |       return Fail; \  | 
766  | 14.4k  |     MCOperand_CreateReg0( \  | 
767  | 14.4k  |       Inst, \  | 
768  | 14.4k  |       (MatrixZATileDecoderTable[NumBitsForTile][RegNo])); \  | 
769  | 14.4k  |     return Success; \  | 
770  | 14.4k  |   } AArch64Disassembler.c:DecodeMatrixTile_2 Line  | Count  | Source  |  762  | 5.07k  |   { \ |  763  | 5.07k  |     unsigned LastReg = (1 << NumBitsForTile) - 1; \  |  764  | 5.07k  |     if (RegNo > LastReg) \  |  765  | 5.07k  |       return Fail; \  |  766  | 5.07k  |     MCOperand_CreateReg0( \  |  767  | 5.07k  |       Inst, \  |  768  | 5.07k  |       (MatrixZATileDecoderTable[NumBitsForTile][RegNo])); \  |  769  | 5.07k  |     return Success; \  |  770  | 5.07k  |   }  |  
 AArch64Disassembler.c:DecodeMatrixTile_1 Line  | Count  | Source  |  762  | 2.33k  |   { \ |  763  | 2.33k  |     unsigned LastReg = (1 << NumBitsForTile) - 1; \  |  764  | 2.33k  |     if (RegNo > LastReg) \  |  765  | 2.33k  |       return Fail; \  |  766  | 2.33k  |     MCOperand_CreateReg0( \  |  767  | 2.33k  |       Inst, \  |  768  | 2.33k  |       (MatrixZATileDecoderTable[NumBitsForTile][RegNo])); \  |  769  | 2.33k  |     return Success; \  |  770  | 2.33k  |   }  |  
 AArch64Disassembler.c:DecodeMatrixTile_3 Line  | Count  | Source  |  762  | 5.50k  |   { \ |  763  | 5.50k  |     unsigned LastReg = (1 << NumBitsForTile) - 1; \  |  764  | 5.50k  |     if (RegNo > LastReg) \  |  765  | 5.50k  |       return Fail; \  |  766  | 5.50k  |     MCOperand_CreateReg0( \  |  767  | 5.50k  |       Inst, \  |  768  | 5.50k  |       (MatrixZATileDecoderTable[NumBitsForTile][RegNo])); \  |  769  | 5.50k  |     return Success; \  |  770  | 5.50k  |   }  |  
 AArch64Disassembler.c:DecodeMatrixTile_4 Line  | Count  | Source  |  762  | 1.54k  |   { \ |  763  | 1.54k  |     unsigned LastReg = (1 << NumBitsForTile) - 1; \  |  764  | 1.54k  |     if (RegNo > LastReg) \  |  765  | 1.54k  |       return Fail; \  |  766  | 1.54k  |     MCOperand_CreateReg0( \  |  767  | 1.54k  |       Inst, \  |  768  | 1.54k  |       (MatrixZATileDecoderTable[NumBitsForTile][RegNo])); \  |  769  | 1.54k  |     return Success; \  |  770  | 1.54k  |   }  |  
  | 
771  |  | DEFINE_DecodeMatrixTile(2);  | 
772  |  | DEFINE_DecodeMatrixTile(1);  | 
773  |  | DEFINE_DecodeMatrixTile(3);  | 
774  |  | DEFINE_DecodeMatrixTile(4);  | 
775  |  |  | 
776  |  | static DecodeStatus DecodePPRRegisterClass(MCInst *Inst, unsigned RegNo,  | 
777  |  |              uint64_t Addr, const void *Decoder)  | 
778  | 76.5k  | { | 
779  | 76.5k  |   if (RegNo > 15)  | 
780  | 0  |     return Fail;  | 
781  |  |  | 
782  | 76.5k  |   unsigned Register =  | 
783  | 76.5k  |     AArch64MCRegisterClasses[AArch64_PPRRegClassID].RegsBegin[RegNo];  | 
784  | 76.5k  |   MCOperand_CreateReg0(Inst, (Register));  | 
785  | 76.5k  |   return Success;  | 
786  | 76.5k  | }  | 
787  |  |  | 
788  |  | static DecodeStatus DecodePNRRegisterClass(MCInst *Inst, unsigned RegNo,  | 
789  |  |              uint64_t Addr, const void *Decoder)  | 
790  | 14.8k  | { | 
791  | 14.8k  |   if (RegNo > 15)  | 
792  | 0  |     return Fail;  | 
793  |  |  | 
794  | 14.8k  |   unsigned Register =  | 
795  | 14.8k  |     AArch64MCRegisterClasses[AArch64_PNRRegClassID].RegsBegin[RegNo];  | 
796  | 14.8k  |   MCOperand_CreateReg0(Inst, (Register));  | 
797  | 14.8k  |   return Success;  | 
798  | 14.8k  | }  | 
799  |  |  | 
800  |  | static DecodeStatus DecodePPR_3bRegisterClass(MCInst *Inst, unsigned RegNo,  | 
801  |  |                 uint64_t Addr,  | 
802  |  |                 const void *Decoder)  | 
803  | 54.6k  | { | 
804  | 54.6k  |   if (RegNo > 7)  | 
805  | 0  |     return Fail;  | 
806  |  |  | 
807  |  |   // Just reuse the PPR decode table  | 
808  | 54.6k  |   return DecodePPRRegisterClass(Inst, RegNo, Addr, Decoder);  | 
809  | 54.6k  | }  | 
810  |  |  | 
811  |  | static DecodeStatus DecodePNR_p8to15RegisterClass(MCInst *Inst, unsigned RegNo,  | 
812  |  |               uint64_t Addr,  | 
813  |  |               const void *Decoder)  | 
814  | 14.3k  | { | 
815  | 14.3k  |   if (RegNo > 7)  | 
816  | 0  |     return Fail;  | 
817  |  |  | 
818  |  |   // Just reuse the PPR decode table  | 
819  | 14.3k  |   return DecodePNRRegisterClass(Inst, RegNo + 8, Addr, Decoder);  | 
820  | 14.3k  | }  | 
821  |  |  | 
822  |  | static DecodeStatus DecodePPR2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
823  |  |               uint64_t Address,  | 
824  |  |               const void *Decoder)  | 
825  | 2.14k  | { | 
826  | 2.14k  |   if (RegNo > 15)  | 
827  | 0  |     return Fail;  | 
828  |  |  | 
829  | 2.14k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_PPR2RegClassID]  | 
830  | 2.14k  |             .RegsBegin[RegNo];  | 
831  | 2.14k  |   MCOperand_CreateReg0(Inst, (Register));  | 
832  | 2.14k  |   return Success;  | 
833  | 2.14k  | }  | 
834  |  |  | 
835  |  | static DecodeStatus DecodePPR2Mul2RegisterClass(MCInst *Inst, unsigned RegNo,  | 
836  |  |             uint64_t Address,  | 
837  |  |             const void *Decoder)  | 
838  | 1.12k  | { | 
839  | 1.12k  |   if ((RegNo * 2) > 14)  | 
840  | 0  |     return Fail;  | 
841  | 1.12k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_PPR2RegClassID]  | 
842  | 1.12k  |             .RegsBegin[RegNo * 2];  | 
843  | 1.12k  |   MCOperand_CreateReg0(Inst, (Register));  | 
844  | 1.12k  |   return Success;  | 
845  | 1.12k  | }  | 
846  |  |  | 
847  |  | static DecodeStatus DecodeQQRegisterClass(MCInst *Inst, unsigned RegNo,  | 
848  |  |             uint64_t Addr, const void *Decoder)  | 
849  | 12.1k  | { | 
850  | 12.1k  |   if (RegNo > 31)  | 
851  | 0  |     return Fail;  | 
852  | 12.1k  |   unsigned Register =  | 
853  | 12.1k  |     AArch64MCRegisterClasses[AArch64_QQRegClassID].RegsBegin[RegNo];  | 
854  | 12.1k  |   MCOperand_CreateReg0(Inst, (Register));  | 
855  | 12.1k  |   return Success;  | 
856  | 12.1k  | }  | 
857  |  |  | 
858  |  | static DecodeStatus DecodeQQQRegisterClass(MCInst *Inst, unsigned RegNo,  | 
859  |  |              uint64_t Addr, const void *Decoder)  | 
860  | 8.31k  | { | 
861  | 8.31k  |   if (RegNo > 31)  | 
862  | 0  |     return Fail;  | 
863  | 8.31k  |   unsigned Register =  | 
864  | 8.31k  |     AArch64MCRegisterClasses[AArch64_QQQRegClassID].RegsBegin[RegNo];  | 
865  | 8.31k  |   MCOperand_CreateReg0(Inst, (Register));  | 
866  | 8.31k  |   return Success;  | 
867  | 8.31k  | }  | 
868  |  |  | 
869  |  | static DecodeStatus DecodeQQQQRegisterClass(MCInst *Inst, unsigned RegNo,  | 
870  |  |               uint64_t Addr, const void *Decoder)  | 
871  | 13.0k  | { | 
872  | 13.0k  |   if (RegNo > 31)  | 
873  | 0  |     return Fail;  | 
874  | 13.0k  |   unsigned Register = AArch64MCRegisterClasses[AArch64_QQQQRegClassID]  | 
875  | 13.0k  |             .RegsBegin[RegNo];  | 
876  | 13.0k  |   MCOperand_CreateReg0(Inst, (Register));  | 
877  | 13.0k  |   return Success;  | 
878  | 13.0k  | }  | 
879  |  |  | 
880  |  | static DecodeStatus DecodeDDRegisterClass(MCInst *Inst, unsigned RegNo,  | 
881  |  |             uint64_t Addr, const void *Decoder)  | 
882  | 1.33k  | { | 
883  | 1.33k  |   if (RegNo > 31)  | 
884  | 0  |     return Fail;  | 
885  | 1.33k  |   unsigned Register =  | 
886  | 1.33k  |     AArch64MCRegisterClasses[AArch64_DDRegClassID].RegsBegin[RegNo];  | 
887  | 1.33k  |   MCOperand_CreateReg0(Inst, (Register));  | 
888  | 1.33k  |   return Success;  | 
889  | 1.33k  | }  | 
890  |  |  | 
891  |  | static DecodeStatus DecodeDDDRegisterClass(MCInst *Inst, unsigned RegNo,  | 
892  |  |              uint64_t Addr, const void *Decoder)  | 
893  | 1.03k  | { | 
894  | 1.03k  |   if (RegNo > 31)  | 
895  | 0  |     return Fail;  | 
896  | 1.03k  |   unsigned Register =  | 
897  | 1.03k  |     AArch64MCRegisterClasses[AArch64_DDDRegClassID].RegsBegin[RegNo];  | 
898  | 1.03k  |   MCOperand_CreateReg0(Inst, (Register));  | 
899  | 1.03k  |   return Success;  | 
900  | 1.03k  | }  | 
901  |  |  | 
902  |  | static DecodeStatus DecodeDDDDRegisterClass(MCInst *Inst, unsigned RegNo,  | 
903  |  |               uint64_t Addr, const void *Decoder)  | 
904  | 913  | { | 
905  | 913  |   if (RegNo > 31)  | 
906  | 0  |     return Fail;  | 
907  | 913  |   unsigned Register = AArch64MCRegisterClasses[AArch64_DDDDRegClassID]  | 
908  | 913  |             .RegsBegin[RegNo];  | 
909  | 913  |   MCOperand_CreateReg0(Inst, (Register));  | 
910  | 913  |   return Success;  | 
911  | 913  | }  | 
912  |  |  | 
913  |  | static DecodeStatus DecodeFixedPointScaleImm32(MCInst *Inst, unsigned Imm,  | 
914  |  |                  uint64_t Addr,  | 
915  |  |                  const void *Decoder)  | 
916  | 281  | { | 
917  |  |   // scale{5} is asserted as 1 in tblgen. | 
918  | 281  |   Imm |= 0x20;  | 
919  | 281  |   MCOperand_CreateImm0(Inst, (64 - Imm));  | 
920  | 281  |   return Success;  | 
921  | 281  | }  | 
922  |  |  | 
923  |  | static DecodeStatus DecodeFixedPointScaleImm64(MCInst *Inst, unsigned Imm,  | 
924  |  |                  uint64_t Addr,  | 
925  |  |                  const void *Decoder)  | 
926  | 644  | { | 
927  | 644  |   MCOperand_CreateImm0(Inst, (64 - Imm));  | 
928  | 644  |   return Success;  | 
929  | 644  | }  | 
930  |  |  | 
931  |  | static DecodeStatus DecodePCRelLabel16(MCInst *Inst, unsigned Imm,  | 
932  |  |                uint64_t Addr, const void *Decoder)  | 
933  | 211  | { | 
934  |  |   // Immediate is encoded as the top 16-bits of an unsigned 18-bit negative  | 
935  |  |   // PC-relative offset.  | 
936  | 211  |   uint64_t ImmVal = Imm;  | 
937  | 211  |   if (ImmVal > (1 << 16))  | 
938  | 0  |     return Fail;  | 
939  |  |   // Symbols are not supported by Capstone  | 
940  | 211  |   return Success;  | 
941  | 211  | }  | 
942  |  |  | 
943  |  | static DecodeStatus DecodePCRelLabel19(MCInst *Inst, unsigned Imm,  | 
944  |  |                uint64_t Addr, const void *Decoder)  | 
945  | 7.15k  | { | 
946  | 7.15k  |   int64_t ImmVal = Imm;  | 
947  |  |  | 
948  |  |   // Sign-extend 19-bit immediate.  | 
949  | 7.15k  |   if (ImmVal & (1 << (19 - 1)))  | 
950  | 2.96k  |     ImmVal |= ~((1LL << 19) - 1);  | 
951  |  |  | 
952  |  |   // No symbols supported in Capstone  | 
953  |  |   // if (!Decoder->tryAddingSymbolicOperand(  | 
954  |  |   //    Inst, ImmVal * 4, Addr, MCInst_getOpcode(Inst) != AArch64_LDRXl, 0,  | 
955  |  |   //    0, 4))  | 
956  | 7.15k  |   MCOperand_CreateImm0(Inst, (ImmVal));  | 
957  | 7.15k  |   return Success;  | 
958  | 7.15k  | }  | 
959  |  |  | 
960  |  | static DecodeStatus DecodeMemExtend(MCInst *Inst, unsigned Imm,  | 
961  |  |             uint64_t Address, const void *Decoder)  | 
962  | 3.35k  | { | 
963  | 3.35k  |   MCOperand_CreateImm0(Inst, ((Imm >> 1) & 1));  | 
964  | 3.35k  |   MCOperand_CreateImm0(Inst, (Imm & 1));  | 
965  | 3.35k  |   return Success;  | 
966  | 3.35k  | }  | 
967  |  |  | 
968  |  | static DecodeStatus DecodeMRSSystemRegister(MCInst *Inst, unsigned Imm,  | 
969  |  |               uint64_t Address,  | 
970  |  |               const void *Decoder)  | 
971  | 3.11k  | { | 
972  | 3.11k  |   MCOperand_CreateImm0(Inst, (Imm));  | 
973  |  |  | 
974  |  |   // Every system register in the encoding space is valid with the syntax  | 
975  |  |   // S<op0>_<op1>_<Cn>_<Cm>_<op2>, so decoding system registers always  | 
976  |  |   // succeeds.  | 
977  | 3.11k  |   return Success;  | 
978  | 3.11k  | }  | 
979  |  |  | 
980  |  | static DecodeStatus DecodeMSRSystemRegister(MCInst *Inst, unsigned Imm,  | 
981  |  |               uint64_t Address,  | 
982  |  |               const void *Decoder)  | 
983  | 6.38k  | { | 
984  | 6.38k  |   MCOperand_CreateImm0(Inst, (Imm));  | 
985  |  |  | 
986  | 6.38k  |   return Success;  | 
987  | 6.38k  | }  | 
988  |  |  | 
989  |  | static DecodeStatus DecodeFMOVLaneInstruction(MCInst *Inst, unsigned Insn,  | 
990  |  |                 uint64_t Address,  | 
991  |  |                 const void *Decoder)  | 
992  | 101  | { | 
993  |  |   // This decoder exists to add the dummy Lane operand to the MCInst, which  | 
994  |  |   // must be 1 in assembly but has no other real manifestation.  | 
995  | 101  |   unsigned Rd = fieldFromInstruction_4(Insn, 0, 5);  | 
996  | 101  |   unsigned Rn = fieldFromInstruction_4(Insn, 5, 5);  | 
997  | 101  |   unsigned IsToVec = fieldFromInstruction_4(Insn, 16, 1);  | 
998  |  |  | 
999  | 101  |   if (IsToVec) { | 
1000  | 66  |     DecodeFPR128RegisterClass(Inst, Rd, Address, Decoder);  | 
1001  | 66  |     DecodeGPR64RegisterClass(Inst, Rn, Address, Decoder);  | 
1002  | 66  |   } else { | 
1003  | 35  |     DecodeGPR64RegisterClass(Inst, Rd, Address, Decoder);  | 
1004  | 35  |     DecodeFPR128RegisterClass(Inst, Rn, Address, Decoder);  | 
1005  | 35  |   }  | 
1006  |  |  | 
1007  |  |   // Add the lane  | 
1008  | 101  |   MCOperand_CreateImm0(Inst, (1));  | 
1009  |  |  | 
1010  | 101  |   return Success;  | 
1011  | 101  | }  | 
1012  |  |  | 
1013  |  | static DecodeStatus DecodeVecShiftRImm(MCInst *Inst, unsigned Imm, unsigned Add)  | 
1014  | 5.56k  | { | 
1015  | 5.56k  |   MCOperand_CreateImm0(Inst, (Add - Imm));  | 
1016  | 5.56k  |   return Success;  | 
1017  | 5.56k  | }  | 
1018  |  |  | 
1019  |  | static DecodeStatus DecodeVecShiftLImm(MCInst *Inst, unsigned Imm, unsigned Add)  | 
1020  | 6.16k  | { | 
1021  | 6.16k  |   MCOperand_CreateImm0(Inst, ((Imm + Add) & (Add - 1)));  | 
1022  | 6.16k  |   return Success;  | 
1023  | 6.16k  | }  | 
1024  |  |  | 
1025  |  | static DecodeStatus DecodeVecShiftR64Imm(MCInst *Inst, unsigned Imm,  | 
1026  |  |            uint64_t Addr, const void *Decoder)  | 
1027  | 1.60k  | { | 
1028  | 1.60k  |   return DecodeVecShiftRImm(Inst, Imm, 64);  | 
1029  | 1.60k  | }  | 
1030  |  |  | 
1031  |  | static DecodeStatus DecodeVecShiftR64ImmNarrow(MCInst *Inst, unsigned Imm,  | 
1032  |  |                  uint64_t Addr,  | 
1033  |  |                  const void *Decoder)  | 
1034  | 149  | { | 
1035  | 149  |   return DecodeVecShiftRImm(Inst, Imm | 0x20, 64);  | 
1036  | 149  | }  | 
1037  |  |  | 
1038  |  | static DecodeStatus DecodeVecShiftR32Imm(MCInst *Inst, unsigned Imm,  | 
1039  |  |            uint64_t Addr, const void *Decoder)  | 
1040  | 1.15k  | { | 
1041  | 1.15k  |   return DecodeVecShiftRImm(Inst, Imm, 32);  | 
1042  | 1.15k  | }  | 
1043  |  |  | 
1044  |  | static DecodeStatus DecodeVecShiftR32ImmNarrow(MCInst *Inst, unsigned Imm,  | 
1045  |  |                  uint64_t Addr,  | 
1046  |  |                  const void *Decoder)  | 
1047  | 110  | { | 
1048  | 110  |   return DecodeVecShiftRImm(Inst, Imm | 0x10, 32);  | 
1049  | 110  | }  | 
1050  |  |  | 
1051  |  | static DecodeStatus DecodeVecShiftR16Imm(MCInst *Inst, unsigned Imm,  | 
1052  |  |            uint64_t Addr, const void *Decoder)  | 
1053  | 1.26k  | { | 
1054  | 1.26k  |   return DecodeVecShiftRImm(Inst, Imm, 16);  | 
1055  | 1.26k  | }  | 
1056  |  |  | 
1057  |  | static DecodeStatus DecodeVecShiftR16ImmNarrow(MCInst *Inst, unsigned Imm,  | 
1058  |  |                  uint64_t Addr,  | 
1059  |  |                  const void *Decoder)  | 
1060  | 182  | { | 
1061  | 182  |   return DecodeVecShiftRImm(Inst, Imm | 0x8, 16);  | 
1062  | 182  | }  | 
1063  |  |  | 
1064  |  | static DecodeStatus DecodeVecShiftR8Imm(MCInst *Inst, unsigned Imm,  | 
1065  |  |           uint64_t Addr, const void *Decoder)  | 
1066  | 1.10k  | { | 
1067  | 1.10k  |   return DecodeVecShiftRImm(Inst, Imm, 8);  | 
1068  | 1.10k  | }  | 
1069  |  |  | 
1070  |  | static DecodeStatus DecodeVecShiftL64Imm(MCInst *Inst, unsigned Imm,  | 
1071  |  |            uint64_t Addr, const void *Decoder)  | 
1072  | 1.39k  | { | 
1073  | 1.39k  |   return DecodeVecShiftLImm(Inst, Imm, 64);  | 
1074  | 1.39k  | }  | 
1075  |  |  | 
1076  |  | static DecodeStatus DecodeVecShiftL32Imm(MCInst *Inst, unsigned Imm,  | 
1077  |  |            uint64_t Addr, const void *Decoder)  | 
1078  | 613  | { | 
1079  | 613  |   return DecodeVecShiftLImm(Inst, Imm, 32);  | 
1080  | 613  | }  | 
1081  |  |  | 
1082  |  | static DecodeStatus DecodeVecShiftL16Imm(MCInst *Inst, unsigned Imm,  | 
1083  |  |            uint64_t Addr, const void *Decoder)  | 
1084  | 1.67k  | { | 
1085  | 1.67k  |   return DecodeVecShiftLImm(Inst, Imm, 16);  | 
1086  | 1.67k  | }  | 
1087  |  |  | 
1088  |  | static DecodeStatus DecodeVecShiftL8Imm(MCInst *Inst, unsigned Imm,  | 
1089  |  |           uint64_t Addr, const void *Decoder)  | 
1090  | 2.47k  | { | 
1091  | 2.47k  |   return DecodeVecShiftLImm(Inst, Imm, 8);  | 
1092  | 2.47k  | }  | 
1093  |  |  | 
1094  |  | static DecodeStatus DecodeThreeAddrSRegInstruction(MCInst *Inst, uint32_t insn,  | 
1095  |  |                uint64_t Addr,  | 
1096  |  |                const void *Decoder)  | 
1097  | 7.07k  | { | 
1098  | 7.07k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1099  | 7.07k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1100  | 7.07k  |   unsigned Rm = fieldFromInstruction_4(insn, 16, 5);  | 
1101  | 7.07k  |   unsigned shiftHi = fieldFromInstruction_4(insn, 22, 2);  | 
1102  | 7.07k  |   unsigned shiftLo = fieldFromInstruction_4(insn, 10, 6);  | 
1103  | 7.07k  |   unsigned shift = (shiftHi << 6) | shiftLo;  | 
1104  | 7.07k  |   switch (MCInst_getOpcode(Inst)) { | 
1105  | 0  |   default:  | 
1106  | 0  |     return Fail;  | 
1107  | 761  |   case AArch64_ADDWrs:  | 
1108  | 915  |   case AArch64_ADDSWrs:  | 
1109  | 1.29k  |   case AArch64_SUBWrs:  | 
1110  | 1.37k  |   case AArch64_SUBSWrs:  | 
1111  |  |     // if shift == '11' then ReservedValue()  | 
1112  | 1.37k  |     if (shiftHi == 0x3)  | 
1113  | 4  |       return Fail;  | 
1114  |  |     // fall through  | 
1115  | 1.61k  |   case AArch64_ANDWrs:  | 
1116  | 1.69k  |   case AArch64_ANDSWrs:  | 
1117  | 1.91k  |   case AArch64_BICWrs:  | 
1118  | 2.14k  |   case AArch64_BICSWrs:  | 
1119  | 2.42k  |   case AArch64_ORRWrs:  | 
1120  | 2.85k  |   case AArch64_ORNWrs:  | 
1121  | 3.24k  |   case AArch64_EORWrs:  | 
1122  | 3.34k  |   case AArch64_EONWrs: { | 
1123  |  |     // if sf == '0' and imm6<5> == '1' then ReservedValue()  | 
1124  | 3.34k  |     if (shiftLo >> 5 == 1)  | 
1125  | 34  |       return Fail;  | 
1126  | 3.30k  |     DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);  | 
1127  | 3.30k  |     DecodeGPR32RegisterClass(Inst, Rn, Addr, Decoder);  | 
1128  | 3.30k  |     DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);  | 
1129  | 3.30k  |     break;  | 
1130  | 3.34k  |   }  | 
1131  | 427  |   case AArch64_ADDXrs:  | 
1132  | 976  |   case AArch64_ADDSXrs:  | 
1133  | 1.05k  |   case AArch64_SUBXrs:  | 
1134  | 1.32k  |   case AArch64_SUBSXrs:  | 
1135  |  |     // if shift == '11' then ReservedValue()  | 
1136  | 1.32k  |     if (shiftHi == 0x3)  | 
1137  | 2  |       return Fail;  | 
1138  |  |     // fall through  | 
1139  | 1.69k  |   case AArch64_ANDXrs:  | 
1140  | 2.04k  |   case AArch64_ANDSXrs:  | 
1141  | 2.16k  |   case AArch64_BICXrs:  | 
1142  | 2.47k  |   case AArch64_BICSXrs:  | 
1143  | 2.63k  |   case AArch64_ORRXrs:  | 
1144  | 2.85k  |   case AArch64_ORNXrs:  | 
1145  | 3.38k  |   case AArch64_EORXrs:  | 
1146  | 3.72k  |   case AArch64_EONXrs:  | 
1147  | 3.72k  |     DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1148  | 3.72k  |     DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder);  | 
1149  | 3.72k  |     DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);  | 
1150  | 3.72k  |     break;  | 
1151  | 7.07k  |   }  | 
1152  |  |  | 
1153  | 7.03k  |   MCOperand_CreateImm0(Inst, (shift));  | 
1154  | 7.03k  |   return Success;  | 
1155  | 7.07k  | }  | 
1156  |  |  | 
1157  |  | static DecodeStatus DecodeMoveImmInstruction(MCInst *Inst, uint32_t insn,  | 
1158  |  |                uint64_t Addr, const void *Decoder)  | 
1159  | 4.42k  | { | 
1160  | 4.42k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1161  | 4.42k  |   unsigned imm = fieldFromInstruction_4(insn, 5, 16);  | 
1162  | 4.42k  |   unsigned shift = fieldFromInstruction_4(insn, 21, 2);  | 
1163  | 4.42k  |   shift <<= 4;  | 
1164  | 4.42k  |   switch (MCInst_getOpcode(Inst)) { | 
1165  | 0  |   default:  | 
1166  | 0  |     return Fail;  | 
1167  | 1.10k  |   case AArch64_MOVZWi:  | 
1168  | 1.27k  |   case AArch64_MOVNWi:  | 
1169  | 1.91k  |   case AArch64_MOVKWi:  | 
1170  | 1.91k  |     if (shift & (1U << 5))  | 
1171  | 2  |       return Fail;  | 
1172  | 1.91k  |     DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);  | 
1173  | 1.91k  |     break;  | 
1174  | 893  |   case AArch64_MOVZXi:  | 
1175  | 1.48k  |   case AArch64_MOVNXi:  | 
1176  | 2.50k  |   case AArch64_MOVKXi:  | 
1177  | 2.50k  |     DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1178  | 2.50k  |     break;  | 
1179  | 4.42k  |   }  | 
1180  |  |  | 
1181  | 4.42k  |   if (MCInst_getOpcode(Inst) == AArch64_MOVKWi ||  | 
1182  | 3.78k  |       MCInst_getOpcode(Inst) == AArch64_MOVKXi)  | 
1183  | 1.66k  |     MCInst_addOperand2(Inst, (MCInst_getOperand(Inst, (0))));  | 
1184  |  |  | 
1185  | 4.42k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1186  | 4.42k  |   MCOperand_CreateImm0(Inst, (shift));  | 
1187  | 4.42k  |   return Success;  | 
1188  | 4.42k  | }  | 
1189  |  |  | 
1190  |  | static DecodeStatus DecodeUnsignedLdStInstruction(MCInst *Inst, uint32_t insn,  | 
1191  |  |               uint64_t Addr,  | 
1192  |  |               const void *Decoder)  | 
1193  | 7.02k  | { | 
1194  | 7.02k  |   unsigned Rt = fieldFromInstruction_4(insn, 0, 5);  | 
1195  | 7.02k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1196  | 7.02k  |   unsigned offset = fieldFromInstruction_4(insn, 10, 12);  | 
1197  |  |  | 
1198  | 7.02k  |   switch (MCInst_getOpcode(Inst)) { | 
1199  | 0  |   default:  | 
1200  | 0  |     return Fail;  | 
1201  | 234  |   case AArch64_PRFMui:  | 
1202  |  |     // Rt is an immediate in prefetch.  | 
1203  | 234  |     MCOperand_CreateImm0(Inst, (Rt));  | 
1204  | 234  |     break;  | 
1205  | 1.22k  |   case AArch64_STRBBui:  | 
1206  | 1.44k  |   case AArch64_LDRBBui:  | 
1207  | 1.52k  |   case AArch64_LDRSBWui:  | 
1208  | 1.73k  |   case AArch64_STRHHui:  | 
1209  | 2.00k  |   case AArch64_LDRHHui:  | 
1210  | 2.18k  |   case AArch64_LDRSHWui:  | 
1211  | 2.42k  |   case AArch64_STRWui:  | 
1212  | 2.64k  |   case AArch64_LDRWui:  | 
1213  | 2.64k  |     DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1214  | 2.64k  |     break;  | 
1215  | 76  |   case AArch64_LDRSBXui:  | 
1216  | 196  |   case AArch64_LDRSHXui:  | 
1217  | 481  |   case AArch64_LDRSWui:  | 
1218  | 1.01k  |   case AArch64_STRXui:  | 
1219  | 1.10k  |   case AArch64_LDRXui:  | 
1220  | 1.10k  |     DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1221  | 1.10k  |     break;  | 
1222  | 223  |   case AArch64_LDRQui:  | 
1223  | 446  |   case AArch64_STRQui:  | 
1224  | 446  |     DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);  | 
1225  | 446  |     break;  | 
1226  | 200  |   case AArch64_LDRDui:  | 
1227  | 298  |   case AArch64_STRDui:  | 
1228  | 298  |     DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1229  | 298  |     break;  | 
1230  | 77  |   case AArch64_LDRSui:  | 
1231  | 979  |   case AArch64_STRSui:  | 
1232  | 979  |     DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1233  | 979  |     break;  | 
1234  | 488  |   case AArch64_LDRHui:  | 
1235  | 939  |   case AArch64_STRHui:  | 
1236  | 939  |     DecodeFPR16RegisterClass(Inst, Rt, Addr, Decoder);  | 
1237  | 939  |     break;  | 
1238  | 94  |   case AArch64_LDRBui:  | 
1239  | 376  |   case AArch64_STRBui:  | 
1240  | 376  |     DecodeFPR8RegisterClass(Inst, Rt, Addr, Decoder);  | 
1241  | 376  |     break;  | 
1242  | 7.02k  |   }  | 
1243  |  |  | 
1244  | 7.02k  |   DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1245  |  |   // No symbols supported in Capstone  | 
1246  |  |   // if (!Decoder->tryAddingSymbolicOperand(Inst, offset, Addr, Fail, 0, 0, 4))  | 
1247  | 7.02k  |   MCOperand_CreateImm0(Inst, (offset));  | 
1248  | 7.02k  |   return Success;  | 
1249  | 7.02k  | }  | 
1250  |  |  | 
1251  |  | static DecodeStatus DecodeSignedLdStInstruction(MCInst *Inst, uint32_t insn,  | 
1252  |  |             uint64_t Addr,  | 
1253  |  |             const void *Decoder)  | 
1254  | 14.2k  | { | 
1255  | 14.2k  |   unsigned Rt = fieldFromInstruction_4(insn, 0, 5);  | 
1256  | 14.2k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1257  | 14.2k  |   int64_t offset = fieldFromInstruction_4(insn, 12, 9);  | 
1258  |  |  | 
1259  |  |   // offset is a 9-bit signed immediate, so sign extend it to  | 
1260  |  |   // fill the unsigned.  | 
1261  | 14.2k  |   if (offset & (1 << (9 - 1)))  | 
1262  | 4.34k  |     offset |= ~((1LL << 9) - 1);  | 
1263  |  |  | 
1264  |  |   // First operand is always the writeback to the address register, if needed.  | 
1265  | 14.2k  |   switch (MCInst_getOpcode(Inst)) { | 
1266  | 7.39k  |   default:  | 
1267  | 7.39k  |     break;  | 
1268  | 7.39k  |   case AArch64_LDRSBWpre:  | 
1269  | 314  |   case AArch64_LDRSHWpre:  | 
1270  | 353  |   case AArch64_STRBBpre:  | 
1271  | 396  |   case AArch64_LDRBBpre:  | 
1272  | 508  |   case AArch64_STRHHpre:  | 
1273  | 625  |   case AArch64_LDRHHpre:  | 
1274  | 714  |   case AArch64_STRWpre:  | 
1275  | 801  |   case AArch64_LDRWpre:  | 
1276  | 1.15k  |   case AArch64_LDRSBWpost:  | 
1277  | 1.27k  |   case AArch64_LDRSHWpost:  | 
1278  | 1.36k  |   case AArch64_STRBBpost:  | 
1279  | 1.44k  |   case AArch64_LDRBBpost:  | 
1280  | 1.58k  |   case AArch64_STRHHpost:  | 
1281  | 1.66k  |   case AArch64_LDRHHpost:  | 
1282  | 1.86k  |   case AArch64_STRWpost:  | 
1283  | 1.94k  |   case AArch64_LDRWpost:  | 
1284  | 2.01k  |   case AArch64_LDRSBXpre:  | 
1285  | 2.06k  |   case AArch64_LDRSHXpre:  | 
1286  | 2.30k  |   case AArch64_STRXpre:  | 
1287  | 2.34k  |   case AArch64_LDRSWpre:  | 
1288  | 2.74k  |   case AArch64_LDRXpre:  | 
1289  | 2.81k  |   case AArch64_LDRSBXpost:  | 
1290  | 2.88k  |   case AArch64_LDRSHXpost:  | 
1291  | 3.41k  |   case AArch64_STRXpost:  | 
1292  | 3.48k  |   case AArch64_LDRSWpost:  | 
1293  | 3.69k  |   case AArch64_LDRXpost:  | 
1294  | 3.86k  |   case AArch64_LDRQpre:  | 
1295  | 4.10k  |   case AArch64_STRQpre:  | 
1296  | 4.15k  |   case AArch64_LDRQpost:  | 
1297  | 4.42k  |   case AArch64_STRQpost:  | 
1298  | 4.63k  |   case AArch64_LDRDpre:  | 
1299  | 4.70k  |   case AArch64_STRDpre:  | 
1300  | 4.77k  |   case AArch64_LDRDpost:  | 
1301  | 4.85k  |   case AArch64_STRDpost:  | 
1302  | 4.93k  |   case AArch64_LDRSpre:  | 
1303  | 5.06k  |   case AArch64_STRSpre:  | 
1304  | 5.17k  |   case AArch64_LDRSpost:  | 
1305  | 5.24k  |   case AArch64_STRSpost:  | 
1306  | 5.31k  |   case AArch64_LDRHpre:  | 
1307  | 5.55k  |   case AArch64_STRHpre:  | 
1308  | 5.62k  |   case AArch64_LDRHpost:  | 
1309  | 5.70k  |   case AArch64_STRHpost:  | 
1310  | 5.91k  |   case AArch64_LDRBpre:  | 
1311  | 6.65k  |   case AArch64_STRBpre:  | 
1312  | 6.73k  |   case AArch64_LDRBpost:  | 
1313  | 6.87k  |   case AArch64_STRBpost:  | 
1314  | 6.87k  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1315  | 6.87k  |     break;  | 
1316  | 14.2k  |   }  | 
1317  |  |  | 
1318  | 14.2k  |   switch (MCInst_getOpcode(Inst)) { | 
1319  | 0  |   default:  | 
1320  | 0  |     return Fail;  | 
1321  | 72  |   case AArch64_PRFUMi:  | 
1322  |  |     // Rt is an immediate in prefetch.  | 
1323  | 72  |     MCOperand_CreateImm0(Inst, (Rt));  | 
1324  | 72  |     break;  | 
1325  | 45  |   case AArch64_STURBBi:  | 
1326  | 148  |   case AArch64_LDURBBi:  | 
1327  | 189  |   case AArch64_LDURSBWi:  | 
1328  | 453  |   case AArch64_STURHHi:  | 
1329  | 561  |   case AArch64_LDURHHi:  | 
1330  | 729  |   case AArch64_LDURSHWi:  | 
1331  | 834  |   case AArch64_STURWi:  | 
1332  | 911  |   case AArch64_LDURWi:  | 
1333  | 1.11k  |   case AArch64_LDTRSBWi:  | 
1334  | 1.18k  |   case AArch64_LDTRSHWi:  | 
1335  | 1.39k  |   case AArch64_STTRWi:  | 
1336  | 1.48k  |   case AArch64_LDTRWi:  | 
1337  | 1.73k  |   case AArch64_STTRHi:  | 
1338  | 1.85k  |   case AArch64_LDTRHi:  | 
1339  | 2.05k  |   case AArch64_LDTRBi:  | 
1340  | 2.12k  |   case AArch64_STTRBi:  | 
1341  | 2.21k  |   case AArch64_LDRSBWpre:  | 
1342  | 2.44k  |   case AArch64_LDRSHWpre:  | 
1343  | 2.48k  |   case AArch64_STRBBpre:  | 
1344  | 2.52k  |   case AArch64_LDRBBpre:  | 
1345  | 2.63k  |   case AArch64_STRHHpre:  | 
1346  | 2.75k  |   case AArch64_LDRHHpre:  | 
1347  | 2.84k  |   case AArch64_STRWpre:  | 
1348  | 2.92k  |   case AArch64_LDRWpre:  | 
1349  | 3.28k  |   case AArch64_LDRSBWpost:  | 
1350  | 3.40k  |   case AArch64_LDRSHWpost:  | 
1351  | 3.49k  |   case AArch64_STRBBpost:  | 
1352  | 3.57k  |   case AArch64_LDRBBpost:  | 
1353  | 3.70k  |   case AArch64_STRHHpost:  | 
1354  | 3.78k  |   case AArch64_LDRHHpost:  | 
1355  | 3.99k  |   case AArch64_STRWpost:  | 
1356  | 4.06k  |   case AArch64_LDRWpost:  | 
1357  | 4.30k  |   case AArch64_STLURBi:  | 
1358  | 4.36k  |   case AArch64_STLURHi:  | 
1359  | 4.68k  |   case AArch64_STLURWi:  | 
1360  | 4.76k  |   case AArch64_LDAPURBi:  | 
1361  | 4.83k  |   case AArch64_LDAPURSBWi:  | 
1362  | 4.91k  |   case AArch64_LDAPURHi:  | 
1363  | 4.98k  |   case AArch64_LDAPURSHWi:  | 
1364  | 5.05k  |   case AArch64_LDAPURi:  | 
1365  | 5.05k  |     DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1366  | 5.05k  |     break;  | 
1367  | 66  |   case AArch64_LDURSBXi:  | 
1368  | 176  |   case AArch64_LDURSHXi:  | 
1369  | 378  |   case AArch64_LDURSWi:  | 
1370  | 597  |   case AArch64_STURXi:  | 
1371  | 671  |   case AArch64_LDURXi:  | 
1372  | 1.06k  |   case AArch64_LDTRSBXi:  | 
1373  | 1.35k  |   case AArch64_LDTRSHXi:  | 
1374  | 1.42k  |   case AArch64_LDTRSWi:  | 
1375  | 1.52k  |   case AArch64_STTRXi:  | 
1376  | 1.59k  |   case AArch64_LDTRXi:  | 
1377  | 1.66k  |   case AArch64_LDRSBXpre:  | 
1378  | 1.72k  |   case AArch64_LDRSHXpre:  | 
1379  | 1.96k  |   case AArch64_STRXpre:  | 
1380  | 1.99k  |   case AArch64_LDRSWpre:  | 
1381  | 2.39k  |   case AArch64_LDRXpre:  | 
1382  | 2.47k  |   case AArch64_LDRSBXpost:  | 
1383  | 2.54k  |   case AArch64_LDRSHXpost:  | 
1384  | 3.06k  |   case AArch64_STRXpost:  | 
1385  | 3.13k  |   case AArch64_LDRSWpost:  | 
1386  | 3.35k  |   case AArch64_LDRXpost:  | 
1387  | 3.41k  |   case AArch64_LDAPURSWi:  | 
1388  | 3.46k  |   case AArch64_LDAPURSHXi:  | 
1389  | 3.49k  |   case AArch64_LDAPURSBXi:  | 
1390  | 4.12k  |   case AArch64_STLURXi:  | 
1391  | 4.19k  |   case AArch64_LDAPURXi:  | 
1392  | 4.19k  |     DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1393  | 4.19k  |     break;  | 
1394  | 234  |   case AArch64_LDURQi:  | 
1395  | 302  |   case AArch64_STURQi:  | 
1396  | 470  |   case AArch64_LDRQpre:  | 
1397  | 710  |   case AArch64_STRQpre:  | 
1398  | 759  |   case AArch64_LDRQpost:  | 
1399  | 1.03k  |   case AArch64_STRQpost:  | 
1400  | 1.03k  |     DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);  | 
1401  | 1.03k  |     break;  | 
1402  | 382  |   case AArch64_LDURDi:  | 
1403  | 585  |   case AArch64_STURDi:  | 
1404  | 797  |   case AArch64_LDRDpre:  | 
1405  | 866  |   case AArch64_STRDpre:  | 
1406  | 935  |   case AArch64_LDRDpost:  | 
1407  | 1.01k  |   case AArch64_STRDpost:  | 
1408  | 1.01k  |     DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1409  | 1.01k  |     break;  | 
1410  | 68  |   case AArch64_LDURSi:  | 
1411  | 152  |   case AArch64_STURSi:  | 
1412  | 236  |   case AArch64_LDRSpre:  | 
1413  | 358  |   case AArch64_STRSpre:  | 
1414  | 475  |   case AArch64_LDRSpost:  | 
1415  | 543  |   case AArch64_STRSpost:  | 
1416  | 543  |     DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1417  | 543  |     break;  | 
1418  | 183  |   case AArch64_LDURHi:  | 
1419  | 330  |   case AArch64_STURHi:  | 
1420  | 404  |   case AArch64_LDRHpre:  | 
1421  | 641  |   case AArch64_STRHpre:  | 
1422  | 710  |   case AArch64_LDRHpost:  | 
1423  | 793  |   case AArch64_STRHpost:  | 
1424  | 793  |     DecodeFPR16RegisterClass(Inst, Rt, Addr, Decoder);  | 
1425  | 793  |     break;  | 
1426  | 122  |   case AArch64_LDURBi:  | 
1427  | 398  |   case AArch64_STURBi:  | 
1428  | 600  |   case AArch64_LDRBpre:  | 
1429  | 1.34k  |   case AArch64_STRBpre:  | 
1430  | 1.42k  |   case AArch64_LDRBpost:  | 
1431  | 1.56k  |   case AArch64_STRBpost:  | 
1432  | 1.56k  |     DecodeFPR8RegisterClass(Inst, Rt, Addr, Decoder);  | 
1433  | 1.56k  |     break;  | 
1434  | 14.2k  |   }  | 
1435  |  |  | 
1436  | 14.2k  |   DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1437  | 14.2k  |   MCOperand_CreateImm0(Inst, (offset));  | 
1438  |  |  | 
1439  | 14.2k  |   bool IsLoad = fieldFromInstruction_4(insn, 22, 1);  | 
1440  | 14.2k  |   bool IsIndexed = fieldFromInstruction_4(insn, 10, 2) != 0;  | 
1441  | 14.2k  |   bool IsFP = fieldFromInstruction_4(insn, 26, 1);  | 
1442  |  |  | 
1443  |  |   // Cannot write back to a transfer register (but xzr != sp).  | 
1444  | 14.2k  |   if (IsLoad && IsIndexed && !IsFP && Rn != 31 && Rt == Rn)  | 
1445  | 219  |     return SoftFail;  | 
1446  |  |  | 
1447  | 14.0k  |   return Success;  | 
1448  | 14.2k  | }  | 
1449  |  |  | 
1450  |  | static DecodeStatus DecodeExclusiveLdStInstruction(MCInst *Inst, uint32_t insn,  | 
1451  |  |                uint64_t Addr,  | 
1452  |  |                const void *Decoder)  | 
1453  | 7.71k  | { | 
1454  | 7.71k  |   unsigned Rt = fieldFromInstruction_4(insn, 0, 5);  | 
1455  | 7.71k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1456  | 7.71k  |   unsigned Rt2 = fieldFromInstruction_4(insn, 10, 5);  | 
1457  | 7.71k  |   unsigned Rs = fieldFromInstruction_4(insn, 16, 5);  | 
1458  |  |  | 
1459  | 7.71k  |   unsigned Opcode = MCInst_getOpcode(Inst);  | 
1460  | 7.71k  |   switch (Opcode) { | 
1461  | 0  |   default:  | 
1462  | 0  |     return Fail;  | 
1463  | 211  |   case AArch64_STLXRW:  | 
1464  | 439  |   case AArch64_STLXRB:  | 
1465  | 595  |   case AArch64_STLXRH:  | 
1466  | 687  |   case AArch64_STXRW:  | 
1467  | 1.11k  |   case AArch64_STXRB:  | 
1468  | 1.31k  |   case AArch64_STXRH:  | 
1469  | 1.31k  |     DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);  | 
1470  |  |     // fall through  | 
1471  | 1.55k  |   case AArch64_LDARW:  | 
1472  | 1.64k  |   case AArch64_LDARB:  | 
1473  | 1.94k  |   case AArch64_LDARH:  | 
1474  | 2.03k  |   case AArch64_LDAXRW:  | 
1475  | 2.27k  |   case AArch64_LDAXRB:  | 
1476  | 2.38k  |   case AArch64_LDAXRH:  | 
1477  | 2.50k  |   case AArch64_LDXRW:  | 
1478  | 2.73k  |   case AArch64_LDXRB:  | 
1479  | 3.03k  |   case AArch64_LDXRH:  | 
1480  | 3.59k  |   case AArch64_STLRW:  | 
1481  | 4.44k  |   case AArch64_STLRB:  | 
1482  | 4.63k  |   case AArch64_STLRH:  | 
1483  | 5.00k  |   case AArch64_STLLRW:  | 
1484  | 5.08k  |   case AArch64_STLLRB:  | 
1485  | 5.17k  |   case AArch64_STLLRH:  | 
1486  | 5.26k  |   case AArch64_LDLARW:  | 
1487  | 5.31k  |   case AArch64_LDLARB:  | 
1488  | 5.35k  |   case AArch64_LDLARH:  | 
1489  | 5.35k  |     DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1490  | 5.35k  |     break;  | 
1491  | 68  |   case AArch64_STLXRX:  | 
1492  | 185  |   case AArch64_STXRX:  | 
1493  | 185  |     DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);  | 
1494  |  |     // fall through  | 
1495  | 438  |   case AArch64_LDARX:  | 
1496  | 656  |   case AArch64_LDAXRX:  | 
1497  | 701  |   case AArch64_LDXRX:  | 
1498  | 780  |   case AArch64_STLRX:  | 
1499  | 1.03k  |   case AArch64_LDLARX:  | 
1500  | 1.11k  |   case AArch64_STLLRX:  | 
1501  | 1.11k  |     DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1502  | 1.11k  |     break;  | 
1503  | 113  |   case AArch64_STLXPW:  | 
1504  | 233  |   case AArch64_STXPW:  | 
1505  | 233  |     DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);  | 
1506  |  |     // fall through  | 
1507  | 553  |   case AArch64_LDAXPW:  | 
1508  | 696  |   case AArch64_LDXPW:  | 
1509  | 696  |     DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1510  | 696  |     DecodeGPR32RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1511  | 696  |     break;  | 
1512  | 96  |   case AArch64_STLXPX:  | 
1513  | 287  |   case AArch64_STXPX:  | 
1514  | 287  |     DecodeGPR32RegisterClass(Inst, Rs, Addr, Decoder);  | 
1515  |  |     // fall through  | 
1516  | 442  |   case AArch64_LDAXPX:  | 
1517  | 552  |   case AArch64_LDXPX:  | 
1518  | 552  |     DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1519  | 552  |     DecodeGPR64RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1520  | 552  |     break;  | 
1521  | 7.71k  |   }  | 
1522  |  |  | 
1523  | 7.71k  |   DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1524  |  |  | 
1525  |  |   // You shouldn't load to the same register twice in an instruction...  | 
1526  | 7.71k  |   if ((Opcode == AArch64_LDAXPW || Opcode == AArch64_LDXPW ||  | 
1527  | 7.25k  |        Opcode == AArch64_LDAXPX || Opcode == AArch64_LDXPX) &&  | 
1528  | 728  |       Rt == Rt2)  | 
1529  | 116  |     return SoftFail;  | 
1530  |  |  | 
1531  | 7.60k  |   return Success;  | 
1532  | 7.71k  | }  | 
1533  |  |  | 
1534  |  | static DecodeStatus DecodePairLdStInstruction(MCInst *Inst, uint32_t insn,  | 
1535  |  |                 uint64_t Addr,  | 
1536  |  |                 const void *Decoder)  | 
1537  | 16.9k  | { | 
1538  | 16.9k  |   unsigned Rt = fieldFromInstruction_4(insn, 0, 5);  | 
1539  | 16.9k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1540  | 16.9k  |   unsigned Rt2 = fieldFromInstruction_4(insn, 10, 5);  | 
1541  | 16.9k  |   int64_t offset = fieldFromInstruction_4(insn, 15, 7);  | 
1542  | 16.9k  |   bool IsLoad = fieldFromInstruction_4(insn, 22, 1);  | 
1543  |  |  | 
1544  |  |   // offset is a 7-bit signed immediate, so sign extend it to  | 
1545  |  |   // fill the unsigned.  | 
1546  | 16.9k  |   if (offset & (1 << (7 - 1)))  | 
1547  | 10.4k  |     offset |= ~((1LL << 7) - 1);  | 
1548  |  |  | 
1549  | 16.9k  |   unsigned Opcode = MCInst_getOpcode(Inst);  | 
1550  | 16.9k  |   bool NeedsDisjointWritebackTransfer = false;  | 
1551  |  |  | 
1552  |  |   // First operand is always writeback of base register.  | 
1553  | 16.9k  |   switch (Opcode) { | 
1554  | 8.58k  |   default:  | 
1555  | 8.58k  |     break;  | 
1556  | 8.58k  |   case AArch64_LDPXpost:  | 
1557  | 697  |   case AArch64_STPXpost:  | 
1558  | 979  |   case AArch64_LDPSWpost:  | 
1559  | 1.06k  |   case AArch64_LDPXpre:  | 
1560  | 1.41k  |   case AArch64_STPXpre:  | 
1561  | 1.55k  |   case AArch64_LDPSWpre:  | 
1562  | 1.86k  |   case AArch64_LDPWpost:  | 
1563  | 2.25k  |   case AArch64_STPWpost:  | 
1564  | 2.77k  |   case AArch64_LDPWpre:  | 
1565  | 2.98k  |   case AArch64_STPWpre:  | 
1566  | 3.19k  |   case AArch64_LDPQpost:  | 
1567  | 3.46k  |   case AArch64_STPQpost:  | 
1568  | 3.55k  |   case AArch64_LDPQpre:  | 
1569  | 4.77k  |   case AArch64_STPQpre:  | 
1570  | 5.20k  |   case AArch64_LDPDpost:  | 
1571  | 5.33k  |   case AArch64_STPDpost:  | 
1572  | 5.84k  |   case AArch64_LDPDpre:  | 
1573  | 6.09k  |   case AArch64_STPDpre:  | 
1574  | 6.47k  |   case AArch64_LDPSpost:  | 
1575  | 7.00k  |   case AArch64_STPSpost:  | 
1576  | 7.44k  |   case AArch64_LDPSpre:  | 
1577  | 7.54k  |   case AArch64_STPSpre:  | 
1578  | 7.77k  |   case AArch64_STGPpre:  | 
1579  | 8.31k  |   case AArch64_STGPpost:  | 
1580  | 8.31k  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1581  | 8.31k  |     break;  | 
1582  | 16.9k  |   }  | 
1583  |  |  | 
1584  | 16.9k  |   switch (Opcode) { | 
1585  | 0  |   default:  | 
1586  | 0  |     return Fail;  | 
1587  | 80  |   case AArch64_LDPXpost:  | 
1588  | 697  |   case AArch64_STPXpost:  | 
1589  | 979  |   case AArch64_LDPSWpost:  | 
1590  | 1.06k  |   case AArch64_LDPXpre:  | 
1591  | 1.41k  |   case AArch64_STPXpre:  | 
1592  | 1.55k  |   case AArch64_LDPSWpre:  | 
1593  | 1.78k  |   case AArch64_STGPpre:  | 
1594  | 2.32k  |   case AArch64_STGPpost:  | 
1595  | 2.32k  |     NeedsDisjointWritebackTransfer = true;  | 
1596  |  |     // fall through  | 
1597  | 2.42k  |   case AArch64_LDNPXi:  | 
1598  | 2.50k  |   case AArch64_STNPXi:  | 
1599  | 2.64k  |   case AArch64_LDPXi:  | 
1600  | 2.82k  |   case AArch64_STPXi:  | 
1601  | 4.05k  |   case AArch64_LDPSWi:  | 
1602  | 4.31k  |   case AArch64_STGPi:  | 
1603  | 4.31k  |     DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1604  | 4.31k  |     DecodeGPR64RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1605  | 4.31k  |     break;  | 
1606  | 306  |   case AArch64_LDPWpost:  | 
1607  | 694  |   case AArch64_STPWpost:  | 
1608  | 1.22k  |   case AArch64_LDPWpre:  | 
1609  | 1.42k  |   case AArch64_STPWpre:  | 
1610  | 1.42k  |     NeedsDisjointWritebackTransfer = true;  | 
1611  |  |     // fall through  | 
1612  | 1.73k  |   case AArch64_LDNPWi:  | 
1613  | 2.05k  |   case AArch64_STNPWi:  | 
1614  | 2.19k  |   case AArch64_LDPWi:  | 
1615  | 2.57k  |   case AArch64_STPWi:  | 
1616  | 2.57k  |     DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1617  | 2.57k  |     DecodeGPR32RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1618  | 2.57k  |     break;  | 
1619  | 100  |   case AArch64_LDNPQi:  | 
1620  | 329  |   case AArch64_STNPQi:  | 
1621  | 535  |   case AArch64_LDPQpost:  | 
1622  | 804  |   case AArch64_STPQpost:  | 
1623  | 1.01k  |   case AArch64_LDPQi:  | 
1624  | 1.22k  |   case AArch64_STPQi:  | 
1625  | 1.32k  |   case AArch64_LDPQpre:  | 
1626  | 2.53k  |   case AArch64_STPQpre:  | 
1627  | 2.53k  |     DecodeFPR128RegisterClass(Inst, Rt, Addr, Decoder);  | 
1628  | 2.53k  |     DecodeFPR128RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1629  | 2.53k  |     break;  | 
1630  | 1.02k  |   case AArch64_LDNPDi:  | 
1631  | 1.22k  |   case AArch64_STNPDi:  | 
1632  | 1.65k  |   case AArch64_LDPDpost:  | 
1633  | 1.78k  |   case AArch64_STPDpost:  | 
1634  | 2.52k  |   case AArch64_LDPDi:  | 
1635  | 2.80k  |   case AArch64_STPDi:  | 
1636  | 3.31k  |   case AArch64_LDPDpre:  | 
1637  | 3.56k  |   case AArch64_STPDpre:  | 
1638  | 3.56k  |     DecodeFPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1639  | 3.56k  |     DecodeFPR64RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1640  | 3.56k  |     break;  | 
1641  | 888  |   case AArch64_LDNPSi:  | 
1642  | 1.41k  |   case AArch64_STNPSi:  | 
1643  | 1.78k  |   case AArch64_LDPSpost:  | 
1644  | 2.31k  |   case AArch64_STPSpost:  | 
1645  | 2.72k  |   case AArch64_LDPSi:  | 
1646  | 3.36k  |   case AArch64_STPSi:  | 
1647  | 3.80k  |   case AArch64_LDPSpre:  | 
1648  | 3.91k  |   case AArch64_STPSpre:  | 
1649  | 3.91k  |     DecodeFPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1650  | 3.91k  |     DecodeFPR32RegisterClass(Inst, Rt2, Addr, Decoder);  | 
1651  | 3.91k  |     break;  | 
1652  | 16.9k  |   }  | 
1653  |  |  | 
1654  | 16.9k  |   DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1655  | 16.9k  |   MCOperand_CreateImm0(Inst, (offset));  | 
1656  |  |  | 
1657  |  |   // You shouldn't load to the same register twice in an instruction...  | 
1658  | 16.9k  |   if (IsLoad && Rt == Rt2)  | 
1659  | 253  |     return SoftFail;  | 
1660  |  |  | 
1661  |  |   // ... or do any operation that writes-back to a transfer register. But note  | 
1662  |  |   // that "stp xzr, xzr, [sp], #4" is fine because xzr and sp are different.  | 
1663  | 16.6k  |   if (NeedsDisjointWritebackTransfer && Rn != 31 &&  | 
1664  | 3.60k  |       (Rt == Rn || Rt2 == Rn))  | 
1665  | 724  |     return SoftFail;  | 
1666  |  |  | 
1667  | 15.9k  |   return Success;  | 
1668  | 16.6k  | }  | 
1669  |  |  | 
1670  |  | static DecodeStatus DecodeAuthLoadInstruction(MCInst *Inst, uint32_t insn,  | 
1671  |  |                 uint64_t Addr,  | 
1672  |  |                 const void *Decoder)  | 
1673  | 1.41k  | { | 
1674  | 1.41k  |   unsigned Rt = fieldFromInstruction_4(insn, 0, 5);  | 
1675  | 1.41k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1676  | 1.41k  |   uint64_t offset = fieldFromInstruction_4(insn, 22, 1) << 9 |  | 
1677  | 1.41k  |         fieldFromInstruction_4(insn, 12, 9);  | 
1678  | 1.41k  |   unsigned writeback = fieldFromInstruction_4(insn, 11, 1);  | 
1679  |  |  | 
1680  | 1.41k  |   switch (MCInst_getOpcode(Inst)) { | 
1681  | 0  |   default:  | 
1682  | 0  |     return Fail;  | 
1683  | 844  |   case AArch64_LDRAAwriteback:  | 
1684  | 1.06k  |   case AArch64_LDRABwriteback:  | 
1685  | 1.06k  |     DecodeGPR64spRegisterClass(Inst, Rn /* writeback register */,  | 
1686  | 1.06k  |              Addr, Decoder);  | 
1687  | 1.06k  |     break;  | 
1688  | 83  |   case AArch64_LDRAAindexed:  | 
1689  | 341  |   case AArch64_LDRABindexed:  | 
1690  | 341  |     break;  | 
1691  | 1.41k  |   }  | 
1692  |  |  | 
1693  | 1.41k  |   DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1694  | 1.41k  |   DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1695  | 1.41k  |   CONCAT(DecodeSImm, 10)(Inst, offset, Addr, Decoder);  | 
1696  |  |  | 
1697  | 1.41k  |   if (writeback && Rt == Rn && Rn != 31) { | 
1698  | 680  |     return SoftFail;  | 
1699  | 680  |   }  | 
1700  |  |  | 
1701  | 730  |   return Success;  | 
1702  | 1.41k  | }  | 
1703  |  |  | 
1704  |  | static DecodeStatus DecodeAddSubERegInstruction(MCInst *Inst, uint32_t insn,  | 
1705  |  |             uint64_t Addr,  | 
1706  |  |             const void *Decoder)  | 
1707  | 7.12k  | { | 
1708  | 7.12k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1709  | 7.12k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1710  | 7.12k  |   unsigned Rm = fieldFromInstruction_4(insn, 16, 5);  | 
1711  | 7.12k  |   unsigned extend = fieldFromInstruction_4(insn, 10, 6);  | 
1712  |  |  | 
1713  | 7.12k  |   unsigned shift = extend & 0x7;  | 
1714  | 7.12k  |   if (shift > 4)  | 
1715  | 5  |     return Fail;  | 
1716  |  |  | 
1717  | 7.11k  |   switch (MCInst_getOpcode(Inst)) { | 
1718  | 0  |   default:  | 
1719  | 0  |     return Fail;  | 
1720  | 237  |   case AArch64_ADDWrx:  | 
1721  | 3.01k  |   case AArch64_SUBWrx:  | 
1722  | 3.01k  |     DecodeGPR32spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1723  | 3.01k  |     DecodeGPR32spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1724  | 3.01k  |     DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);  | 
1725  | 3.01k  |     break;  | 
1726  | 1.95k  |   case AArch64_ADDSWrx:  | 
1727  | 2.05k  |   case AArch64_SUBSWrx:  | 
1728  | 2.05k  |     DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);  | 
1729  | 2.05k  |     DecodeGPR32spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1730  | 2.05k  |     DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);  | 
1731  | 2.05k  |     break;  | 
1732  | 42  |   case AArch64_ADDXrx:  | 
1733  | 87  |   case AArch64_SUBXrx:  | 
1734  | 87  |     DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1735  | 87  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1736  | 87  |     DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);  | 
1737  | 87  |     break;  | 
1738  | 977  |   case AArch64_ADDSXrx:  | 
1739  | 1.04k  |   case AArch64_SUBSXrx:  | 
1740  | 1.04k  |     DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1741  | 1.04k  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1742  | 1.04k  |     DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);  | 
1743  | 1.04k  |     break;  | 
1744  | 69  |   case AArch64_ADDXrx64:  | 
1745  | 170  |   case AArch64_SUBXrx64:  | 
1746  | 170  |     DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1747  | 170  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1748  | 170  |     DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);  | 
1749  | 170  |     break;  | 
1750  | 100  |   case AArch64_SUBSXrx64:  | 
1751  | 749  |   case AArch64_ADDSXrx64:  | 
1752  | 749  |     DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1753  | 749  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1754  | 749  |     DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);  | 
1755  | 749  |     break;  | 
1756  | 7.11k  |   }  | 
1757  |  |  | 
1758  | 7.11k  |   MCOperand_CreateImm0(Inst, (extend));  | 
1759  | 7.11k  |   return Success;  | 
1760  | 7.11k  | }  | 
1761  |  |  | 
1762  |  | static DecodeStatus DecodeLogicalImmInstruction(MCInst *Inst, uint32_t insn,  | 
1763  |  |             uint64_t Addr,  | 
1764  |  |             const void *Decoder)  | 
1765  | 6.81k  | { | 
1766  | 6.81k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1767  | 6.81k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1768  | 6.81k  |   unsigned Datasize = fieldFromInstruction_4(insn, 31, 1);  | 
1769  | 6.81k  |   unsigned imm;  | 
1770  |  |  | 
1771  | 6.81k  |   if (Datasize) { | 
1772  | 4.74k  |     if (MCInst_getOpcode(Inst) == AArch64_ANDSXri)  | 
1773  | 1.22k  |       DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1774  | 3.51k  |     else  | 
1775  | 3.51k  |       DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1776  | 4.74k  |     DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder);  | 
1777  | 4.74k  |     imm = fieldFromInstruction_4(insn, 10, 13);  | 
1778  | 4.74k  |     if (!AArch64_AM_isValidDecodeLogicalImmediate(imm, 64))  | 
1779  | 6  |       return Fail;  | 
1780  | 4.74k  |   } else { | 
1781  | 2.07k  |     if (MCInst_getOpcode(Inst) == AArch64_ANDSWri)  | 
1782  | 717  |       DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);  | 
1783  | 1.35k  |     else  | 
1784  | 1.35k  |       DecodeGPR32spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1785  | 2.07k  |     DecodeGPR32RegisterClass(Inst, Rn, Addr, Decoder);  | 
1786  | 2.07k  |     imm = fieldFromInstruction_4(insn, 10, 12);  | 
1787  | 2.07k  |     if (!AArch64_AM_isValidDecodeLogicalImmediate(imm, 32))  | 
1788  | 1  |       return Fail;  | 
1789  | 2.07k  |   }  | 
1790  | 6.81k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1791  | 6.81k  |   return Success;  | 
1792  | 6.81k  | }  | 
1793  |  |  | 
1794  |  | static DecodeStatus DecodeModImmInstruction(MCInst *Inst, uint32_t insn,  | 
1795  |  |               uint64_t Addr, const void *Decoder)  | 
1796  | 3.96k  | { | 
1797  | 3.96k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1798  | 3.96k  |   unsigned cmode = fieldFromInstruction_4(insn, 12, 4);  | 
1799  | 3.96k  |   unsigned imm = fieldFromInstruction_4(insn, 16, 3) << 5;  | 
1800  | 3.96k  |   imm |= fieldFromInstruction_4(insn, 5, 5);  | 
1801  |  |  | 
1802  | 3.96k  |   if (MCInst_getOpcode(Inst) == AArch64_MOVID)  | 
1803  | 298  |     DecodeFPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1804  | 3.66k  |   else  | 
1805  | 3.66k  |     DecodeFPR128RegisterClass(Inst, Rd, Addr, Decoder);  | 
1806  |  |  | 
1807  | 3.96k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1808  |  |  | 
1809  | 3.96k  |   switch (MCInst_getOpcode(Inst)) { | 
1810  | 1.16k  |   default:  | 
1811  | 1.16k  |     break;  | 
1812  | 1.16k  |   case AArch64_MOVIv4i16:  | 
1813  | 929  |   case AArch64_MOVIv8i16:  | 
1814  | 965  |   case AArch64_MVNIv4i16:  | 
1815  | 997  |   case AArch64_MVNIv8i16:  | 
1816  | 1.65k  |   case AArch64_MOVIv2i32:  | 
1817  | 1.95k  |   case AArch64_MOVIv4i32:  | 
1818  | 2.15k  |   case AArch64_MVNIv2i32:  | 
1819  | 2.20k  |   case AArch64_MVNIv4i32:  | 
1820  | 2.20k  |     MCOperand_CreateImm0(Inst, ((cmode & 6) << 2));  | 
1821  | 2.20k  |     break;  | 
1822  | 34  |   case AArch64_MOVIv2s_msl:  | 
1823  | 124  |   case AArch64_MOVIv4s_msl:  | 
1824  | 451  |   case AArch64_MVNIv2s_msl:  | 
1825  | 596  |   case AArch64_MVNIv4s_msl:  | 
1826  | 596  |     MCOperand_CreateImm0(Inst, ((cmode & 1) ? 0x110 : 0x108));  | 
1827  | 596  |     break;  | 
1828  | 3.96k  |   }  | 
1829  |  |  | 
1830  | 3.96k  |   return Success;  | 
1831  | 3.96k  | }  | 
1832  |  |  | 
1833  |  | static DecodeStatus DecodeModImmTiedInstruction(MCInst *Inst, uint32_t insn,  | 
1834  |  |             uint64_t Addr,  | 
1835  |  |             const void *Decoder)  | 
1836  | 600  | { | 
1837  | 600  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1838  | 600  |   unsigned cmode = fieldFromInstruction_4(insn, 12, 4);  | 
1839  | 600  |   unsigned imm = fieldFromInstruction_4(insn, 16, 3) << 5;  | 
1840  | 600  |   imm |= fieldFromInstruction_4(insn, 5, 5);  | 
1841  |  |  | 
1842  |  |   // Tied operands added twice.  | 
1843  | 600  |   DecodeFPR128RegisterClass(Inst, Rd, Addr, Decoder);  | 
1844  | 600  |   DecodeFPR128RegisterClass(Inst, Rd, Addr, Decoder);  | 
1845  |  |  | 
1846  | 600  |   MCOperand_CreateImm0(Inst, (imm));  | 
1847  | 600  |   MCOperand_CreateImm0(Inst, ((cmode & 6) << 2));  | 
1848  |  |  | 
1849  | 600  |   return Success;  | 
1850  | 600  | }  | 
1851  |  |  | 
1852  |  | static DecodeStatus DecodeAdrInstruction(MCInst *Inst, uint32_t insn,  | 
1853  |  |            uint64_t Addr, const void *Decoder)  | 
1854  | 4.87k  | { | 
1855  | 4.87k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1856  | 4.87k  |   int64_t imm = fieldFromInstruction_4(insn, 5, 19) << 2;  | 
1857  | 4.87k  |   imm |= fieldFromInstruction_4(insn, 29, 2);  | 
1858  |  |  | 
1859  |  |   // Sign-extend the 21-bit immediate.  | 
1860  | 4.87k  |   if (imm & (1 << (21 - 1)))  | 
1861  | 2.33k  |     imm |= ~((1LL << 21) - 1);  | 
1862  |  |  | 
1863  | 4.87k  |   DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1864  |  |   // No symbols supported in Capstone  | 
1865  |  |   // if (!Decoder->tryAddingSymbolicOperand(Inst, imm, Addr, Fail, 0, 0, 4))  | 
1866  | 4.87k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1867  |  |  | 
1868  | 4.87k  |   return Success;  | 
1869  | 4.87k  | }  | 
1870  |  |  | 
1871  |  | static DecodeStatus DecodeAddSubImmShift(MCInst *Inst, uint32_t insn,  | 
1872  |  |            uint64_t Addr, const void *Decoder)  | 
1873  | 2.87k  | { | 
1874  | 2.87k  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
1875  | 2.87k  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
1876  | 2.87k  |   unsigned Imm = fieldFromInstruction_4(insn, 10, 14);  | 
1877  | 2.87k  |   unsigned S = fieldFromInstruction_4(insn, 29, 1);  | 
1878  | 2.87k  |   unsigned Datasize = fieldFromInstruction_4(insn, 31, 1);  | 
1879  |  |  | 
1880  | 2.87k  |   unsigned ShifterVal = (Imm >> 12) & 3;  | 
1881  | 2.87k  |   unsigned ImmVal = Imm & 0xFFF;  | 
1882  |  |  | 
1883  | 2.87k  |   if (ShifterVal != 0 && ShifterVal != 1)  | 
1884  | 26  |     return Fail;  | 
1885  |  |  | 
1886  | 2.84k  |   if (Datasize) { | 
1887  | 1.06k  |     if (Rd == 31 && !S)  | 
1888  | 133  |       DecodeGPR64spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1889  | 928  |     else  | 
1890  | 928  |       DecodeGPR64RegisterClass(Inst, Rd, Addr, Decoder);  | 
1891  | 1.06k  |     DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1892  | 1.78k  |   } else { | 
1893  | 1.78k  |     if (Rd == 31 && !S)  | 
1894  | 91  |       DecodeGPR32spRegisterClass(Inst, Rd, Addr, Decoder);  | 
1895  | 1.69k  |     else  | 
1896  | 1.69k  |       DecodeGPR32RegisterClass(Inst, Rd, Addr, Decoder);  | 
1897  | 1.78k  |     DecodeGPR32spRegisterClass(Inst, Rn, Addr, Decoder);  | 
1898  | 1.78k  |   }  | 
1899  |  |  | 
1900  |  |   // No symbols supported in Capstone  | 
1901  |  |   // if (!Decoder->tryAddingSymbolicOperand(Inst, Imm, Addr, Fail, 0, 0, 4))  | 
1902  | 2.84k  |   MCOperand_CreateImm0(Inst, (ImmVal));  | 
1903  | 2.84k  |   MCOperand_CreateImm0(Inst, (12 * ShifterVal));  | 
1904  | 2.84k  |   return Success;  | 
1905  | 2.87k  | }  | 
1906  |  |  | 
1907  |  | static DecodeStatus DecodeUnconditionalBranch(MCInst *Inst, uint32_t insn,  | 
1908  |  |                 uint64_t Addr,  | 
1909  |  |                 const void *Decoder)  | 
1910  | 2.58k  | { | 
1911  | 2.58k  |   int64_t imm = fieldFromInstruction_4(insn, 0, 26);  | 
1912  |  |  | 
1913  |  |   // Sign-extend the 26-bit immediate.  | 
1914  | 2.58k  |   if (imm & (1 << (26 - 1)))  | 
1915  | 947  |     imm |= ~((1LL << 26) - 1);  | 
1916  |  |  | 
1917  |  |   // No symbols supported in Capstone  | 
1918  |  |   // if (!Decoder->tryAddingSymbolicOperand(Inst, imm * 4, Addr, true, 0, 0, 4))  | 
1919  | 2.58k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1920  |  |  | 
1921  | 2.58k  |   return Success;  | 
1922  | 2.58k  | }  | 
1923  |  |  | 
1924  |  | static bool isInvalidPState(uint64_t Op1, uint64_t Op2)  | 
1925  | 5.59k  | { | 
1926  | 5.59k  |   return Op1 == 0 && (Op2 == 0 || // CFINV  | 
1927  | 2.88k  |           Op2 == 1 || // XAFlag  | 
1928  | 2.88k  |           Op2 == 2); // AXFlag  | 
1929  | 5.59k  | }  | 
1930  |  |  | 
1931  |  | static DecodeStatus DecodeSystemPStateImm0_15Instruction(MCInst *Inst,  | 
1932  |  |                uint32_t insn,  | 
1933  |  |                uint64_t Addr,  | 
1934  |  |                const void *Decoder)  | 
1935  | 2.69k  | { | 
1936  | 2.69k  |   uint64_t op1 = fieldFromInstruction_4(insn, 16, 3);  | 
1937  | 2.69k  |   uint64_t op2 = fieldFromInstruction_4(insn, 5, 3);  | 
1938  | 2.69k  |   uint64_t imm = fieldFromInstruction_4(insn, 8, 4);  | 
1939  | 2.69k  |   uint64_t pstate_field = (op1 << 3) | op2;  | 
1940  |  |  | 
1941  | 2.69k  |   if (isInvalidPState(op1, op2))  | 
1942  | 177  |     return Fail;  | 
1943  |  |  | 
1944  | 2.51k  |   MCOperand_CreateImm0(Inst, (pstate_field));  | 
1945  | 2.51k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1946  |  |  | 
1947  | 2.51k  |   const AArch64PState_PStateImm0_15 *PState =  | 
1948  | 2.51k  |     AArch64PState_lookupPStateImm0_15ByEncoding(pstate_field);  | 
1949  | 2.51k  |   if (PState &&  | 
1950  | 1.45k  |       AArch64_testFeatureList(Inst->csh->mode, PState->FeaturesRequired))  | 
1951  | 1.45k  |     return Success;  | 
1952  | 1.05k  |   return Fail;  | 
1953  | 2.51k  | }  | 
1954  |  |  | 
1955  |  | static DecodeStatus DecodeSystemPStateImm0_1Instruction(MCInst *Inst,  | 
1956  |  |               uint32_t insn,  | 
1957  |  |               uint64_t Addr,  | 
1958  |  |               const void *Decoder)  | 
1959  | 2.90k  | { | 
1960  | 2.90k  |   uint64_t op1 = fieldFromInstruction_4(insn, 16, 3);  | 
1961  | 2.90k  |   uint64_t op2 = fieldFromInstruction_4(insn, 5, 3);  | 
1962  | 2.90k  |   uint64_t crm_high = fieldFromInstruction_4(insn, 9, 3);  | 
1963  | 2.90k  |   uint64_t imm = fieldFromInstruction_4(insn, 8, 1);  | 
1964  | 2.90k  |   uint64_t pstate_field = (crm_high << 6) | (op1 << 3) | op2;  | 
1965  |  |  | 
1966  | 2.90k  |   if (isInvalidPState(op1, op2))  | 
1967  | 177  |     return Fail;  | 
1968  |  |  | 
1969  | 2.72k  |   MCOperand_CreateImm0(Inst, (pstate_field));  | 
1970  | 2.72k  |   MCOperand_CreateImm0(Inst, (imm));  | 
1971  |  |  | 
1972  | 2.72k  |   const AArch64PState_PStateImm0_1 *PState =  | 
1973  | 2.72k  |     AArch64PState_lookupPStateImm0_1ByEncoding(pstate_field);  | 
1974  | 2.72k  |   if (PState &&  | 
1975  | 179  |       AArch64_testFeatureList(Inst->csh->mode, PState->FeaturesRequired))  | 
1976  | 179  |     return Success;  | 
1977  | 2.54k  |   return Fail;  | 
1978  | 2.72k  | }  | 
1979  |  |  | 
1980  |  | static DecodeStatus DecodeTestAndBranch(MCInst *Inst, uint32_t insn,  | 
1981  |  |           uint64_t Addr, const void *Decoder)  | 
1982  | 1.88k  | { | 
1983  | 1.88k  |   uint64_t Rt = fieldFromInstruction_4(insn, 0, 5);  | 
1984  | 1.88k  |   uint64_t bit = fieldFromInstruction_4(insn, 31, 1) << 5;  | 
1985  | 1.88k  |   bit |= fieldFromInstruction_4(insn, 19, 5);  | 
1986  | 1.88k  |   int64_t dst = fieldFromInstruction_4(insn, 5, 14);  | 
1987  |  |  | 
1988  |  |   // Sign-extend 14-bit immediate.  | 
1989  | 1.88k  |   if (dst & (1 << (14 - 1)))  | 
1990  | 1.26k  |     dst |= ~((1LL << 14) - 1);  | 
1991  |  |  | 
1992  | 1.88k  |   if (fieldFromInstruction_4(insn, 31, 1) == 0)  | 
1993  | 967  |     DecodeGPR32RegisterClass(Inst, Rt, Addr, Decoder);  | 
1994  | 920  |   else  | 
1995  | 920  |     DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
1996  | 1.88k  |   MCOperand_CreateImm0(Inst, (bit));  | 
1997  |  |   // No symbols supported in Capstone  | 
1998  |  |   // if (!Decoder->tryAddingSymbolicOperand(Inst, dst * 4, Addr, true, 0, 0, 4))  | 
1999  | 1.88k  |   MCOperand_CreateImm0(Inst, (dst));  | 
2000  |  |  | 
2001  | 1.88k  |   return Success;  | 
2002  | 1.88k  | }  | 
2003  |  |  | 
2004  |  | static DecodeStatus DecodeGPRSeqPairsClassRegisterClass(MCInst *Inst,  | 
2005  |  |               unsigned RegClassID,  | 
2006  |  |               unsigned RegNo,  | 
2007  |  |               uint64_t Addr,  | 
2008  |  |               const void *Decoder)  | 
2009  | 3.15k  | { | 
2010  |  |   // Register number must be even (see CASP instruction)  | 
2011  | 3.15k  |   if (RegNo & 0x1)  | 
2012  | 12  |     return Fail;  | 
2013  |  |  | 
2014  | 3.14k  |   unsigned Reg =  | 
2015  | 3.14k  |     AArch64MCRegisterClasses[RegClassID].RegsBegin[RegNo / 2];  | 
2016  | 3.14k  |   MCOperand_CreateReg0(Inst, (Reg));  | 
2017  | 3.14k  |   return Success;  | 
2018  | 3.15k  | }  | 
2019  |  |  | 
2020  |  | static DecodeStatus DecodeWSeqPairsClassRegisterClass(MCInst *Inst,  | 
2021  |  |                   unsigned RegNo,  | 
2022  |  |                   uint64_t Addr,  | 
2023  |  |                   const void *Decoder)  | 
2024  | 926  | { | 
2025  | 926  |   return DecodeGPRSeqPairsClassRegisterClass(  | 
2026  | 926  |     Inst, AArch64_WSeqPairsClassRegClassID, RegNo, Addr, Decoder);  | 
2027  | 926  | }  | 
2028  |  |  | 
2029  |  | static DecodeStatus DecodeXSeqPairsClassRegisterClass(MCInst *Inst,  | 
2030  |  |                   unsigned RegNo,  | 
2031  |  |                   uint64_t Addr,  | 
2032  |  |                   const void *Decoder)  | 
2033  | 2.23k  | { | 
2034  | 2.23k  |   return DecodeGPRSeqPairsClassRegisterClass(  | 
2035  | 2.23k  |     Inst, AArch64_XSeqPairsClassRegClassID, RegNo, Addr, Decoder);  | 
2036  | 2.23k  | }  | 
2037  |  |  | 
2038  |  | static DecodeStatus DecodeSyspXzrInstruction(MCInst *Inst, uint32_t insn,  | 
2039  |  |                uint64_t Addr, const void *Decoder)  | 
2040  | 3.32k  | { | 
2041  | 3.32k  |   unsigned op1 = fieldFromInstruction_4(insn, 16, 3);  | 
2042  | 3.32k  |   unsigned CRn = fieldFromInstruction_4(insn, 12, 4);  | 
2043  | 3.32k  |   unsigned CRm = fieldFromInstruction_4(insn, 8, 4);  | 
2044  | 3.32k  |   unsigned op2 = fieldFromInstruction_4(insn, 5, 3);  | 
2045  | 3.32k  |   unsigned Rt = fieldFromInstruction_4(insn, 0, 5);  | 
2046  | 3.32k  |   if (Rt != 0x1f)  | 
2047  | 0  |     return Fail;  | 
2048  |  |  | 
2049  | 3.32k  |   MCOperand_CreateImm0(Inst, (op1));  | 
2050  | 3.32k  |   MCOperand_CreateImm0(Inst, (CRn));  | 
2051  | 3.32k  |   MCOperand_CreateImm0(Inst, (CRm));  | 
2052  | 3.32k  |   MCOperand_CreateImm0(Inst, (op2));  | 
2053  | 3.32k  |   DecodeGPR64RegisterClass(Inst, Rt, Addr, Decoder);  | 
2054  |  |  | 
2055  | 3.32k  |   return Success;  | 
2056  | 3.32k  | }  | 
2057  |  |  | 
2058  |  | static DecodeStatus DecodeSVELogicalImmInstruction(MCInst *Inst, uint32_t insn,  | 
2059  |  |                uint64_t Addr,  | 
2060  |  |                const void *Decoder)  | 
2061  | 9.77k  | { | 
2062  | 9.77k  |   unsigned Zdn = fieldFromInstruction_4(insn, 0, 5);  | 
2063  | 9.77k  |   unsigned imm = fieldFromInstruction_4(insn, 5, 13);  | 
2064  | 9.77k  |   if (!AArch64_AM_isValidDecodeLogicalImmediate(imm, 64))  | 
2065  | 5  |     return Fail;  | 
2066  |  |  | 
2067  |  |   // The same (tied) operand is added twice to the instruction.  | 
2068  | 9.76k  |   DecodeZPRRegisterClass(Inst, Zdn, Addr, Decoder);  | 
2069  | 9.76k  |   if (MCInst_getOpcode(Inst) != AArch64_DUPM_ZI)  | 
2070  | 1.18k  |     DecodeZPRRegisterClass(Inst, Zdn, Addr, Decoder);  | 
2071  | 9.76k  |   MCOperand_CreateImm0(Inst, (imm));  | 
2072  | 9.76k  |   return Success;  | 
2073  | 9.77k  | }  | 
2074  |  |  | 
2075  |  | #define DEFINE_DecodeSImm(Bits) \  | 
2076  |  |   static DecodeStatus CONCAT(DecodeSImm, Bits)(MCInst * Inst, \  | 
2077  |  |                  uint64_t Imm, \  | 
2078  |  |                  uint64_t Address, \  | 
2079  |  |                  const void *Decoder) \  | 
2080  | 17.5k  |   { \ | 
2081  | 17.5k  |     if (Imm & ~((1LL << Bits) - 1)) \  | 
2082  | 17.5k  |       return Fail; \  | 
2083  | 17.5k  | \  | 
2084  | 17.5k  |     if (Imm & (1 << (Bits - 1))) \  | 
2085  | 17.5k  |       Imm |= ~((1LL << Bits) - 1); \  | 
2086  | 17.5k  | \  | 
2087  | 17.5k  |     MCOperand_CreateImm0(Inst, (Imm)); \  | 
2088  | 17.5k  |     return Success; \  | 
2089  | 17.5k  |   } AArch64Disassembler.c:DecodeSImm_5 Line  | Count  | Source  |  2080  | 3.07k  |   { \ |  2081  | 3.07k  |     if (Imm & ~((1LL << Bits) - 1)) \  |  2082  | 3.07k  |       return Fail; \  |  2083  | 3.07k  | \  |  2084  | 3.07k  |     if (Imm & (1 << (Bits - 1))) \  |  2085  | 3.07k  |       Imm |= ~((1LL << Bits) - 1); \  |  2086  | 3.07k  | \  |  2087  | 3.07k  |     MCOperand_CreateImm0(Inst, (Imm)); \  |  2088  | 3.07k  |     return Success; \  |  2089  | 3.07k  |   }  |  
 AArch64Disassembler.c:DecodeSImm_4 Line  | Count  | Source  |  2080  | 9.20k  |   { \ |  2081  | 9.20k  |     if (Imm & ~((1LL << Bits) - 1)) \  |  2082  | 9.20k  |       return Fail; \  |  2083  | 9.20k  | \  |  2084  | 9.20k  |     if (Imm & (1 << (Bits - 1))) \  |  2085  | 9.20k  |       Imm |= ~((1LL << Bits) - 1); \  |  2086  | 9.20k  | \  |  2087  | 9.20k  |     MCOperand_CreateImm0(Inst, (Imm)); \  |  2088  | 9.20k  |     return Success; \  |  2089  | 9.20k  |   }  |  
 AArch64Disassembler.c:DecodeSImm_6 Line  | Count  | Source  |  2080  | 811  |   { \ |  2081  | 811  |     if (Imm & ~((1LL << Bits) - 1)) \  |  2082  | 811  |       return Fail; \  |  2083  | 811  | \  |  2084  | 811  |     if (Imm & (1 << (Bits - 1))) \  |  2085  | 811  |       Imm |= ~((1LL << Bits) - 1); \  |  2086  | 811  | \  |  2087  | 811  |     MCOperand_CreateImm0(Inst, (Imm)); \  |  2088  | 811  |     return Success; \  |  2089  | 811  |   }  |  
 AArch64Disassembler.c:DecodeSImm_8 Line  | Count  | Source  |  2080  | 669  |   { \ |  2081  | 669  |     if (Imm & ~((1LL << Bits) - 1)) \  |  2082  | 669  |       return Fail; \  |  2083  | 669  | \  |  2084  | 669  |     if (Imm & (1 << (Bits - 1))) \  |  2085  | 669  |       Imm |= ~((1LL << Bits) - 1); \  |  2086  | 669  | \  |  2087  | 669  |     MCOperand_CreateImm0(Inst, (Imm)); \  |  2088  | 669  |     return Success; \  |  2089  | 669  |   }  |  
 AArch64Disassembler.c:DecodeSImm_9 Line  | Count  | Source  |  2080  | 2.36k  |   { \ |  2081  | 2.36k  |     if (Imm & ~((1LL << Bits) - 1)) \  |  2082  | 2.36k  |       return Fail; \  |  2083  | 2.36k  | \  |  2084  | 2.36k  |     if (Imm & (1 << (Bits - 1))) \  |  2085  | 2.36k  |       Imm |= ~((1LL << Bits) - 1); \  |  2086  | 2.36k  | \  |  2087  | 2.36k  |     MCOperand_CreateImm0(Inst, (Imm)); \  |  2088  | 2.36k  |     return Success; \  |  2089  | 2.36k  |   }  |  
 AArch64Disassembler.c:DecodeSImm_10 Line  | Count  | Source  |  2080  | 1.41k  |   { \ |  2081  | 1.41k  |     if (Imm & ~((1LL << Bits) - 1)) \  |  2082  | 1.41k  |       return Fail; \  |  2083  | 1.41k  | \  |  2084  | 1.41k  |     if (Imm & (1 << (Bits - 1))) \  |  2085  | 1.41k  |       Imm |= ~((1LL << Bits) - 1); \  |  2086  | 1.41k  | \  |  2087  | 1.41k  |     MCOperand_CreateImm0(Inst, (Imm)); \  |  2088  | 1.41k  |     return Success; \  |  2089  | 1.41k  |   }  |  
  | 
2090  |  | DEFINE_DecodeSImm(4);  | 
2091  |  | DEFINE_DecodeSImm(5);  | 
2092  |  | DEFINE_DecodeSImm(6);  | 
2093  |  | DEFINE_DecodeSImm(8);  | 
2094  |  | DEFINE_DecodeSImm(9);  | 
2095  |  | DEFINE_DecodeSImm(10);  | 
2096  |  |  | 
2097  |  | // Decode 8-bit signed/unsigned immediate for a given element width.  | 
2098  |  | #define DEFINE_DecodeImm8OptLsl(ElementWidth) \  | 
2099  |  |   static DecodeStatus CONCAT(DecodeImm8OptLsl, ElementWidth)( \  | 
2100  |  |     MCInst * Inst, unsigned Imm, uint64_t Addr, \  | 
2101  |  |     const void *Decoder) \  | 
2102  | 4.03k  |   { \ | 
2103  | 4.03k  |     unsigned Val = (uint8_t)Imm; \  | 
2104  | 4.03k  |     unsigned Shift = (Imm & 0x100) ? 8 : 0; \  | 
2105  | 4.03k  |     if (ElementWidth == 8 && Shift) \  | 
2106  | 4.03k  |       return Fail; \  | 
2107  | 4.03k  |     MCOperand_CreateImm0(Inst, (Val)); \  | 
2108  | 4.02k  |     MCOperand_CreateImm0(Inst, (Shift)); \  | 
2109  | 4.02k  |     return Success; \  | 
2110  | 4.03k  |   } AArch64Disassembler.c:DecodeImm8OptLsl_8 Line  | Count  | Source  |  2102  | 1.09k  |   { \ |  2103  | 1.09k  |     unsigned Val = (uint8_t)Imm; \  |  2104  | 1.09k  |     unsigned Shift = (Imm & 0x100) ? 8 : 0; \  |  2105  | 1.09k  |     if (ElementWidth == 8 && Shift) \  |  2106  | 1.09k  |       return Fail; \  |  2107  | 1.09k  |     MCOperand_CreateImm0(Inst, (Val)); \  |  2108  | 1.09k  |     MCOperand_CreateImm0(Inst, (Shift)); \  |  2109  | 1.09k  |     return Success; \  |  2110  | 1.09k  |   }  |  
 AArch64Disassembler.c:DecodeImm8OptLsl_16 Line  | Count  | Source  |  2102  | 758  |   { \ |  2103  | 758  |     unsigned Val = (uint8_t)Imm; \  |  2104  | 758  |     unsigned Shift = (Imm & 0x100) ? 8 : 0; \  |  2105  | 758  |     if (ElementWidth == 8 && Shift) \  |  2106  | 758  |       return Fail; \  |  2107  | 758  |     MCOperand_CreateImm0(Inst, (Val)); \  |  2108  | 758  |     MCOperand_CreateImm0(Inst, (Shift)); \  |  2109  | 758  |     return Success; \  |  2110  | 758  |   }  |  
 AArch64Disassembler.c:DecodeImm8OptLsl_32 Line  | Count  | Source  |  2102  | 710  |   { \ |  2103  | 710  |     unsigned Val = (uint8_t)Imm; \  |  2104  | 710  |     unsigned Shift = (Imm & 0x100) ? 8 : 0; \  |  2105  | 710  |     if (ElementWidth == 8 && Shift) \  |  2106  | 710  |       return Fail; \  |  2107  | 710  |     MCOperand_CreateImm0(Inst, (Val)); \  |  2108  | 710  |     MCOperand_CreateImm0(Inst, (Shift)); \  |  2109  | 710  |     return Success; \  |  2110  | 710  |   }  |  
 AArch64Disassembler.c:DecodeImm8OptLsl_64 Line  | Count  | Source  |  2102  | 1.46k  |   { \ |  2103  | 1.46k  |     unsigned Val = (uint8_t)Imm; \  |  2104  | 1.46k  |     unsigned Shift = (Imm & 0x100) ? 8 : 0; \  |  2105  | 1.46k  |     if (ElementWidth == 8 && Shift) \  |  2106  | 1.46k  |       return Fail; \  |  2107  | 1.46k  |     MCOperand_CreateImm0(Inst, (Val)); \  |  2108  | 1.46k  |     MCOperand_CreateImm0(Inst, (Shift)); \  |  2109  | 1.46k  |     return Success; \  |  2110  | 1.46k  |   }  |  
  | 
2111  |  | DEFINE_DecodeImm8OptLsl(8);  | 
2112  |  | DEFINE_DecodeImm8OptLsl(16);  | 
2113  |  | DEFINE_DecodeImm8OptLsl(32);  | 
2114  |  | DEFINE_DecodeImm8OptLsl(64);  | 
2115  |  |  | 
2116  |  | // Decode uimm4 ranged from 1-16.  | 
2117  |  | static DecodeStatus DecodeSVEIncDecImm(MCInst *Inst, unsigned Imm,  | 
2118  |  |                uint64_t Addr, const void *Decoder)  | 
2119  | 10.7k  | { | 
2120  | 10.7k  |   MCOperand_CreateImm0(Inst, (Imm + 1));  | 
2121  | 10.7k  |   return Success;  | 
2122  | 10.7k  | }  | 
2123  |  |  | 
2124  |  | static DecodeStatus DecodeSVCROp(MCInst *Inst, unsigned Imm, uint64_t Address,  | 
2125  |  |          const void *Decoder)  | 
2126  | 1.98k  | { | 
2127  | 1.98k  |   if (AArch64SVCR_lookupSVCRByEncoding(Imm)) { | 
2128  | 319  |     MCOperand_CreateImm0(Inst, (Imm));  | 
2129  | 319  |     return Success;  | 
2130  | 319  |   }  | 
2131  | 1.66k  |   return Fail;  | 
2132  | 1.98k  | }  | 
2133  |  |  | 
2134  |  | static DecodeStatus DecodeCPYMemOpInstruction(MCInst *Inst, uint32_t insn,  | 
2135  |  |                 uint64_t Addr,  | 
2136  |  |                 const void *Decoder)  | 
2137  | 405  | { | 
2138  | 405  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
2139  | 405  |   unsigned Rs = fieldFromInstruction_4(insn, 16, 5);  | 
2140  | 405  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
2141  |  |  | 
2142  |  |   // None of the registers may alias: if they do, then the instruction is not  | 
2143  |  |   // merely unpredictable but actually entirely unallocated.  | 
2144  | 405  |   if (Rd == Rs || Rs == Rn || Rd == Rn)  | 
2145  | 4  |     return MCDisassembler_Fail;  | 
2146  |  |  | 
2147  |  |   // All three register operands are written back, so they all appear  | 
2148  |  |   // twice in the operand list, once as outputs and once as inputs.  | 
2149  | 401  |   if (!DecodeGPR64commonRegisterClass(Inst, Rd, Addr, Decoder) ||  | 
2150  | 400  |       !DecodeGPR64commonRegisterClass(Inst, Rs, Addr, Decoder) ||  | 
2151  | 399  |       !DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder) ||  | 
2152  | 399  |       !DecodeGPR64commonRegisterClass(Inst, Rd, Addr, Decoder) ||  | 
2153  | 399  |       !DecodeGPR64commonRegisterClass(Inst, Rs, Addr, Decoder) ||  | 
2154  | 399  |       !DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder))  | 
2155  | 2  |     return MCDisassembler_Fail;  | 
2156  |  |  | 
2157  | 399  |   return MCDisassembler_Success;  | 
2158  | 401  | }  | 
2159  |  |  | 
2160  |  | static DecodeStatus DecodeSETMemOpInstruction(MCInst *Inst, uint32_t insn,  | 
2161  |  |                 uint64_t Addr,  | 
2162  |  |                 const void *Decoder)  | 
2163  | 263  | { | 
2164  | 263  |   unsigned Rd = fieldFromInstruction_4(insn, 0, 5);  | 
2165  | 263  |   unsigned Rm = fieldFromInstruction_4(insn, 16, 5);  | 
2166  | 263  |   unsigned Rn = fieldFromInstruction_4(insn, 5, 5);  | 
2167  |  |  | 
2168  |  |   // None of the registers may alias: if they do, then the instruction is not  | 
2169  |  |   // merely unpredictable but actually entirely unallocated.  | 
2170  | 263  |   if (Rd == Rm || Rm == Rn || Rd == Rn)  | 
2171  | 3  |     return MCDisassembler_Fail;  | 
2172  |  |  | 
2173  |  |   // Rd and Rn (not Rm) register operands are written back, so they appear  | 
2174  |  |   // twice in the operand list, once as outputs and once as inputs.  | 
2175  | 260  |   if (!DecodeGPR64commonRegisterClass(Inst, Rd, Addr, Decoder) ||  | 
2176  | 259  |       !DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder) ||  | 
2177  | 259  |       !DecodeGPR64commonRegisterClass(Inst, Rd, Addr, Decoder) ||  | 
2178  | 259  |       !DecodeGPR64RegisterClass(Inst, Rn, Addr, Decoder) ||  | 
2179  | 259  |       !DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder))  | 
2180  | 1  |     return MCDisassembler_Fail;  | 
2181  |  |  | 
2182  | 259  |   return MCDisassembler_Success;  | 
2183  | 260  | }  | 
2184  |  |  | 
2185  |  | static DecodeStatus DecodePRFMRegInstruction(MCInst *Inst, uint32_t insn,  | 
2186  |  |                uint64_t Addr, const void *Decoder)  | 
2187  | 1.36k  | { | 
2188  |  |   // PRFM with Rt = '11xxx' should be decoded as RPRFM.  | 
2189  |  |   // Fail to decode and defer to fallback decoder table to decode RPRFM.  | 
2190  | 1.36k  |   unsigned Mask = 0x18;  | 
2191  | 1.36k  |   uint64_t Rt = fieldFromInstruction_4(insn, 0, 5);  | 
2192  | 1.36k  |   if ((Rt & Mask) == Mask)  | 
2193  | 975  |     return Fail;  | 
2194  |  |  | 
2195  | 394  |   uint64_t Rn = fieldFromInstruction_4(insn, 5, 5);  | 
2196  | 394  |   uint64_t Shift = fieldFromInstruction_4(insn, 12, 1);  | 
2197  | 394  |   uint64_t Extend = fieldFromInstruction_4(insn, 15, 1);  | 
2198  | 394  |   uint64_t Rm = fieldFromInstruction_4(insn, 16, 5);  | 
2199  |  |  | 
2200  | 394  |   MCOperand_CreateImm0(Inst, (Rt));  | 
2201  | 394  |   DecodeGPR64spRegisterClass(Inst, Rn, Addr, Decoder);  | 
2202  |  |  | 
2203  | 394  |   switch (MCInst_getOpcode(Inst)) { | 
2204  | 0  |   default:  | 
2205  | 0  |     return Fail;  | 
2206  | 153  |   case AArch64_PRFMroW:  | 
2207  | 153  |     DecodeGPR32RegisterClass(Inst, Rm, Addr, Decoder);  | 
2208  | 153  |     break;  | 
2209  | 241  |   case AArch64_PRFMroX:  | 
2210  | 241  |     DecodeGPR64RegisterClass(Inst, Rm, Addr, Decoder);  | 
2211  | 241  |     break;  | 
2212  | 394  |   }  | 
2213  |  |  | 
2214  | 394  |   DecodeMemExtend(Inst, (Extend << 1) | Shift, Addr, Decoder);  | 
2215  |  |  | 
2216  | 394  |   return Success;  | 
2217  | 394  | }  |