/src/capstonenext/arch/AArch64/AArch64AddressingModes.h
Line | Count | Source (jump to first uncovered line) |
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 | | //===- AArch64AddressingModes.h - AArch64 Addressing Modes ------*- C++ -*-===// |
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 | | // This file contains the AArch64 addressing mode implementation stuff. |
24 | | // |
25 | | //===----------------------------------------------------------------------===// |
26 | | |
27 | | #ifndef LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64ADDRESSINGMODES_H |
28 | | #define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64ADDRESSINGMODES_H |
29 | | |
30 | | #include <stdio.h> |
31 | | #include <string.h> |
32 | | #include <stdlib.h> |
33 | | #include <capstone/platform.h> |
34 | | |
35 | | #include "../../MathExtras.h" |
36 | | #include <assert.h> |
37 | | #include "../../MathExtras.h" |
38 | | |
39 | 36.2k | #define CONCAT(a, b) CONCAT_(a, b) |
40 | 36.2k | #define CONCAT_(a, b) a##_##b |
41 | | |
42 | | /// AArch64_AM - AArch64 Addressing Mode Stuff |
43 | | // CS namespace begin: AArch64_AM |
44 | | |
45 | | //===----------------------------------------------------------------------===// |
46 | | // Shifts |
47 | | // |
48 | | typedef enum ShiftExtendType { |
49 | | AArch64_AM_InvalidShiftExtend = -1, |
50 | | AArch64_AM_LSL = 0, |
51 | | AArch64_AM_LSR, |
52 | | AArch64_AM_ASR, |
53 | | AArch64_AM_ROR, |
54 | | AArch64_AM_MSL, |
55 | | |
56 | | AArch64_AM_UXTB, |
57 | | AArch64_AM_UXTH, |
58 | | AArch64_AM_UXTW, |
59 | | AArch64_AM_UXTX, |
60 | | |
61 | | AArch64_AM_SXTB, |
62 | | AArch64_AM_SXTH, |
63 | | AArch64_AM_SXTW, |
64 | | AArch64_AM_SXTX, |
65 | | } AArch64_AM_ShiftExtendType; |
66 | | |
67 | | /// getShiftName - Get the string encoding for the shift type. |
68 | | static inline const char * |
69 | | AArch64_AM_getShiftExtendName(AArch64_AM_ShiftExtendType ST) |
70 | 8.53k | { |
71 | 8.53k | switch (ST) { |
72 | 0 | default: |
73 | 0 | CS_ASSERT_RET_VAL(0 && "unhandled shift type!", NULL); |
74 | 3.39k | case AArch64_AM_LSL: |
75 | 3.39k | return "lsl"; |
76 | 1.00k | case AArch64_AM_LSR: |
77 | 1.00k | return "lsr"; |
78 | 975 | case AArch64_AM_ASR: |
79 | 975 | return "asr"; |
80 | 1.19k | case AArch64_AM_ROR: |
81 | 1.19k | return "ror"; |
82 | 258 | case AArch64_AM_MSL: |
83 | 258 | return "msl"; |
84 | 393 | case AArch64_AM_UXTB: |
85 | 393 | return "uxtb"; |
86 | 384 | case AArch64_AM_UXTH: |
87 | 384 | return "uxth"; |
88 | 108 | case AArch64_AM_UXTW: |
89 | 108 | return "uxtw"; |
90 | 209 | case AArch64_AM_UXTX: |
91 | 209 | return "uxtx"; |
92 | 246 | case AArch64_AM_SXTB: |
93 | 246 | return "sxtb"; |
94 | 32 | case AArch64_AM_SXTH: |
95 | 32 | return "sxth"; |
96 | 21 | case AArch64_AM_SXTW: |
97 | 21 | return "sxtw"; |
98 | 321 | case AArch64_AM_SXTX: |
99 | 321 | return "sxtx"; |
100 | 8.53k | } |
101 | 0 | return NULL; |
102 | 8.53k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getShiftExtendName Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getShiftExtendName Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getShiftExtendName AArch64InstPrinter.c:AArch64_AM_getShiftExtendName Line | Count | Source | 70 | 8.53k | { | 71 | 8.53k | switch (ST) { | 72 | 0 | default: | 73 | 0 | CS_ASSERT_RET_VAL(0 && "unhandled shift type!", NULL); | 74 | 3.39k | case AArch64_AM_LSL: | 75 | 3.39k | return "lsl"; | 76 | 1.00k | case AArch64_AM_LSR: | 77 | 1.00k | return "lsr"; | 78 | 975 | case AArch64_AM_ASR: | 79 | 975 | return "asr"; | 80 | 1.19k | case AArch64_AM_ROR: | 81 | 1.19k | return "ror"; | 82 | 258 | case AArch64_AM_MSL: | 83 | 258 | return "msl"; | 84 | 393 | case AArch64_AM_UXTB: | 85 | 393 | return "uxtb"; | 86 | 384 | case AArch64_AM_UXTH: | 87 | 384 | return "uxth"; | 88 | 108 | case AArch64_AM_UXTW: | 89 | 108 | return "uxtw"; | 90 | 209 | case AArch64_AM_UXTX: | 91 | 209 | return "uxtx"; | 92 | 246 | case AArch64_AM_SXTB: | 93 | 246 | return "sxtb"; | 94 | 32 | case AArch64_AM_SXTH: | 95 | 32 | return "sxth"; | 96 | 21 | case AArch64_AM_SXTW: | 97 | 21 | return "sxtw"; | 98 | 321 | case AArch64_AM_SXTX: | 99 | 321 | return "sxtx"; | 100 | 8.53k | } | 101 | 0 | return NULL; | 102 | 8.53k | } |
|
103 | | |
104 | | /// getShiftType - Extract the shift type. |
105 | | static inline AArch64_AM_ShiftExtendType AArch64_AM_getShiftType(unsigned Imm) |
106 | 51.0k | { |
107 | 51.0k | switch ((Imm >> 6) & 0x7) { |
108 | 0 | default: |
109 | 0 | return AArch64_AM_InvalidShiftExtend; |
110 | 25.2k | case 0: |
111 | 25.2k | return AArch64_AM_LSL; |
112 | 8.06k | case 1: |
113 | 8.06k | return AArch64_AM_LSR; |
114 | 7.92k | case 2: |
115 | 7.92k | return AArch64_AM_ASR; |
116 | 8.06k | case 3: |
117 | 8.06k | return AArch64_AM_ROR; |
118 | 1.76k | case 4: |
119 | 1.76k | return AArch64_AM_MSL; |
120 | 51.0k | } |
121 | 51.0k | } AArch64Mapping.c:AArch64_AM_getShiftType Line | Count | Source | 106 | 7.32k | { | 107 | 7.32k | switch ((Imm >> 6) & 0x7) { | 108 | 0 | default: | 109 | 0 | return AArch64_AM_InvalidShiftExtend; | 110 | 3.89k | case 0: | 111 | 3.89k | return AArch64_AM_LSL; | 112 | 1.00k | case 1: | 113 | 1.00k | return AArch64_AM_LSR; | 114 | 975 | case 2: | 115 | 975 | return AArch64_AM_ASR; | 116 | 1.19k | case 3: | 117 | 1.19k | return AArch64_AM_ROR; | 118 | 258 | case 4: | 119 | 258 | return AArch64_AM_MSL; | 120 | 7.32k | } | 121 | 7.32k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getShiftType Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getShiftType AArch64InstPrinter.c:AArch64_AM_getShiftType Line | Count | Source | 106 | 43.7k | { | 107 | 43.7k | switch ((Imm >> 6) & 0x7) { | 108 | 0 | default: | 109 | 0 | return AArch64_AM_InvalidShiftExtend; | 110 | 21.3k | case 0: | 111 | 21.3k | return AArch64_AM_LSL; | 112 | 7.06k | case 1: | 113 | 7.06k | return AArch64_AM_LSR; | 114 | 6.95k | case 2: | 115 | 6.95k | return AArch64_AM_ASR; | 116 | 6.87k | case 3: | 117 | 6.87k | return AArch64_AM_ROR; | 118 | 1.50k | case 4: | 119 | 1.50k | return AArch64_AM_MSL; | 120 | 43.7k | } | 121 | 43.7k | } |
|
122 | | |
123 | | /// getShiftValue - Extract the shift value. |
124 | | static inline unsigned AArch64_AM_getShiftValue(unsigned Imm) |
125 | 56.7k | { |
126 | 56.7k | return Imm & 0x3f; |
127 | 56.7k | } AArch64Mapping.c:AArch64_AM_getShiftValue Line | Count | Source | 125 | 10.7k | { | 126 | 10.7k | return Imm & 0x3f; | 127 | 10.7k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getShiftValue Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getShiftValue AArch64InstPrinter.c:AArch64_AM_getShiftValue Line | Count | Source | 125 | 45.9k | { | 126 | 45.9k | return Imm & 0x3f; | 127 | 45.9k | } |
|
128 | | |
129 | | /// getShifterImm - Encode the shift type and amount: |
130 | | /// imm: 6-bit shift amount |
131 | | /// shifter: 000 ==> lsl |
132 | | /// 001 ==> lsr |
133 | | /// 010 ==> asr |
134 | | /// 011 ==> ror |
135 | | /// 100 ==> msl |
136 | | /// {8-6} = shifter |
137 | | /// {5-0} = imm |
138 | | static inline unsigned AArch64_AM_getShifterImm(AArch64_AM_ShiftExtendType ST, |
139 | | unsigned Imm) |
140 | 0 | { |
141 | 0 | unsigned STEnc = 0; |
142 | 0 | switch (ST) { |
143 | 0 | default: |
144 | 0 | CS_ASSERT_RET_VAL(0 && "Invalid shift requested", 0); |
145 | 0 | case AArch64_AM_LSL: |
146 | 0 | STEnc = 0; |
147 | 0 | break; |
148 | 0 | case AArch64_AM_LSR: |
149 | 0 | STEnc = 1; |
150 | 0 | break; |
151 | 0 | case AArch64_AM_ASR: |
152 | 0 | STEnc = 2; |
153 | 0 | break; |
154 | 0 | case AArch64_AM_ROR: |
155 | 0 | STEnc = 3; |
156 | 0 | break; |
157 | 0 | case AArch64_AM_MSL: |
158 | 0 | STEnc = 4; |
159 | 0 | break; |
160 | 0 | } |
161 | 0 | return (STEnc << 6) | (Imm & 0x3f); |
162 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getShifterImm Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getShifterImm Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getShifterImm Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_getShifterImm |
163 | | |
164 | | //===----------------------------------------------------------------------===// |
165 | | // Extends |
166 | | // |
167 | | /// getArithShiftValue - get the arithmetic shift value. |
168 | | static inline unsigned AArch64_AM_getArithShiftValue(unsigned Imm) |
169 | 5.72k | { |
170 | 5.72k | return Imm & 0x7; |
171 | 5.72k | } AArch64Mapping.c:AArch64_AM_getArithShiftValue Line | Count | Source | 169 | 1.79k | { | 170 | 1.79k | return Imm & 0x7; | 171 | 1.79k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getArithShiftValue Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getArithShiftValue AArch64InstPrinter.c:AArch64_AM_getArithShiftValue Line | Count | Source | 169 | 3.93k | { | 170 | 3.93k | return Imm & 0x7; | 171 | 3.93k | } |
|
172 | | |
173 | | /// getExtendType - Extract the extend type for operands of arithmetic ops. |
174 | | static inline AArch64_AM_ShiftExtendType AArch64_AM_getExtendType(unsigned Imm) |
175 | 5.72k | { |
176 | 5.72k | switch (Imm) { |
177 | 0 | default: |
178 | 0 | CS_ASSERT_RET_VAL(0 && "Compiler bug!", 0); |
179 | 986 | case 0: |
180 | 986 | return AArch64_AM_UXTB; |
181 | 1.38k | case 1: |
182 | 1.38k | return AArch64_AM_UXTH; |
183 | 410 | case 2: |
184 | 410 | return AArch64_AM_UXTW; |
185 | 1.08k | case 3: |
186 | 1.08k | return AArch64_AM_UXTX; |
187 | 604 | case 4: |
188 | 604 | return AArch64_AM_SXTB; |
189 | 266 | case 5: |
190 | 266 | return AArch64_AM_SXTH; |
191 | 227 | case 6: |
192 | 227 | return AArch64_AM_SXTW; |
193 | 758 | case 7: |
194 | 758 | return AArch64_AM_SXTX; |
195 | 5.72k | } |
196 | 5.72k | } AArch64Mapping.c:AArch64_AM_getExtendType Line | Count | Source | 175 | 1.79k | { | 176 | 1.79k | switch (Imm) { | 177 | 0 | default: | 178 | 0 | CS_ASSERT_RET_VAL(0 && "Compiler bug!", 0); | 179 | 393 | case 0: | 180 | 393 | return AArch64_AM_UXTB; | 181 | 384 | case 1: | 182 | 384 | return AArch64_AM_UXTH; | 183 | 156 | case 2: | 184 | 156 | return AArch64_AM_UXTW; | 185 | 238 | case 3: | 186 | 238 | return AArch64_AM_UXTX; | 187 | 246 | case 4: | 188 | 246 | return AArch64_AM_SXTB; | 189 | 32 | case 5: | 190 | 32 | return AArch64_AM_SXTH; | 191 | 21 | case 6: | 192 | 21 | return AArch64_AM_SXTW; | 193 | 321 | case 7: | 194 | 321 | return AArch64_AM_SXTX; | 195 | 1.79k | } | 196 | 1.79k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getExtendType Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getExtendType AArch64InstPrinter.c:AArch64_AM_getExtendType Line | Count | Source | 175 | 3.93k | { | 176 | 3.93k | switch (Imm) { | 177 | 0 | default: | 178 | 0 | CS_ASSERT_RET_VAL(0 && "Compiler bug!", 0); | 179 | 593 | case 0: | 180 | 593 | return AArch64_AM_UXTB; | 181 | 1.00k | case 1: | 182 | 1.00k | return AArch64_AM_UXTH; | 183 | 254 | case 2: | 184 | 254 | return AArch64_AM_UXTW; | 185 | 851 | case 3: | 186 | 851 | return AArch64_AM_UXTX; | 187 | 358 | case 4: | 188 | 358 | return AArch64_AM_SXTB; | 189 | 234 | case 5: | 190 | 234 | return AArch64_AM_SXTH; | 191 | 206 | case 6: | 192 | 206 | return AArch64_AM_SXTW; | 193 | 437 | case 7: | 194 | 437 | return AArch64_AM_SXTX; | 195 | 3.93k | } | 196 | 3.93k | } |
|
197 | | |
198 | | static inline AArch64_AM_ShiftExtendType |
199 | | AArch64_AM_getArithExtendType(unsigned Imm) |
200 | 5.72k | { |
201 | 5.72k | return AArch64_AM_getExtendType((Imm >> 3) & 0x7); |
202 | 5.72k | } AArch64Mapping.c:AArch64_AM_getArithExtendType Line | Count | Source | 200 | 1.79k | { | 201 | 1.79k | return AArch64_AM_getExtendType((Imm >> 3) & 0x7); | 202 | 1.79k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getArithExtendType Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getArithExtendType AArch64InstPrinter.c:AArch64_AM_getArithExtendType Line | Count | Source | 200 | 3.93k | { | 201 | 3.93k | return AArch64_AM_getExtendType((Imm >> 3) & 0x7); | 202 | 3.93k | } |
|
203 | | |
204 | | /// Mapping from extend bits to required operation: |
205 | | /// shifter: 000 ==> uxtb |
206 | | /// 001 ==> uxth |
207 | | /// 010 ==> uxtw |
208 | | /// 011 ==> uxtx |
209 | | /// 100 ==> sxtb |
210 | | /// 101 ==> sxth |
211 | | /// 110 ==> sxtw |
212 | | /// 111 ==> sxtx |
213 | | static inline unsigned |
214 | | AArch64_AM_getExtendEncoding(AArch64_AM_ShiftExtendType ET) |
215 | 0 | { |
216 | 0 | switch (ET) { |
217 | 0 | default: |
218 | 0 | CS_ASSERT_RET_VAL(0 && "Invalid extend type requested", 0); |
219 | 0 | case AArch64_AM_UXTB: |
220 | 0 | return 0; |
221 | 0 | break; |
222 | 0 | case AArch64_AM_UXTH: |
223 | 0 | return 1; |
224 | 0 | break; |
225 | 0 | case AArch64_AM_UXTW: |
226 | 0 | return 2; |
227 | 0 | break; |
228 | 0 | case AArch64_AM_UXTX: |
229 | 0 | return 3; |
230 | 0 | break; |
231 | 0 | case AArch64_AM_SXTB: |
232 | 0 | return 4; |
233 | 0 | break; |
234 | 0 | case AArch64_AM_SXTH: |
235 | 0 | return 5; |
236 | 0 | break; |
237 | 0 | case AArch64_AM_SXTW: |
238 | 0 | return 6; |
239 | 0 | break; |
240 | 0 | case AArch64_AM_SXTX: |
241 | 0 | return 7; |
242 | 0 | break; |
243 | 0 | } |
244 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getExtendEncoding Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getExtendEncoding Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getExtendEncoding Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_getExtendEncoding |
245 | | |
246 | | /// getArithExtendImm - Encode the extend type and shift amount for an |
247 | | /// arithmetic instruction: |
248 | | /// imm: 3-bit extend amount |
249 | | /// {5-3} = shifter |
250 | | /// {2-0} = imm3 |
251 | | static inline unsigned |
252 | | AArch64_AM_getArithExtendImm(AArch64_AM_ShiftExtendType ET, unsigned Imm) |
253 | 0 | { |
254 | 0 | return (AArch64_AM_getExtendEncoding(ET) << 3) | (Imm & 0x7); |
255 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getArithExtendImm Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getArithExtendImm Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getArithExtendImm Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_getArithExtendImm |
256 | | |
257 | | /// getMemDoShift - Extract the "do shift" flag value for load/store |
258 | | /// instructions. |
259 | | static inline bool AArch64_AM_getMemDoShift(unsigned Imm) |
260 | 0 | { |
261 | 0 | return (Imm & 0x1) != 0; |
262 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getMemDoShift Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getMemDoShift Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getMemDoShift Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_getMemDoShift |
263 | | |
264 | | /// getExtendType - Extract the extend type for the offset operand of |
265 | | /// loads/stores. |
266 | | static inline AArch64_AM_ShiftExtendType |
267 | | AArch64_AM_getMemExtendType(unsigned Imm) |
268 | 0 | { |
269 | 0 | return AArch64_AM_getExtendType((Imm >> 1) & 0x7); |
270 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getMemExtendType Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getMemExtendType Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getMemExtendType Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_getMemExtendType |
271 | | |
272 | | /// getExtendImm - Encode the extend type and amount for a load/store inst: |
273 | | /// doshift: should the offset be scaled by the access size |
274 | | /// shifter: 000 ==> uxtb |
275 | | /// 001 ==> uxth |
276 | | /// 010 ==> uxtw |
277 | | /// 011 ==> uxtx |
278 | | /// 100 ==> sxtb |
279 | | /// 101 ==> sxth |
280 | | /// 110 ==> sxtw |
281 | | /// 111 ==> sxtx |
282 | | /// {3-1} = shifter |
283 | | /// {0} = doshift |
284 | | static inline unsigned AArch64_AM_getMemExtendImm(AArch64_AM_ShiftExtendType ET, |
285 | | bool DoShift) |
286 | 0 | { |
287 | 0 | return (AArch64_AM_getExtendEncoding(ET) << 1) | (unsigned)DoShift; |
288 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_getMemExtendImm Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getMemExtendImm Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getMemExtendImm Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_getMemExtendImm |
289 | | |
290 | | static inline uint64_t AArch64_AM_ror(uint64_t elt, unsigned size) |
291 | 212k | { |
292 | 212k | return ((elt & 1) << (size - 1)) | (elt >> 1); |
293 | 212k | } AArch64Mapping.c:AArch64_AM_ror Line | Count | Source | 291 | 52.4k | { | 292 | 52.4k | return ((elt & 1) << (size - 1)) | (elt >> 1); | 293 | 52.4k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_ror Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_ror AArch64InstPrinter.c:AArch64_AM_ror Line | Count | Source | 291 | 160k | { | 292 | 160k | return ((elt & 1) << (size - 1)) | (elt >> 1); | 293 | 160k | } |
|
294 | | |
295 | | /// processLogicalImmediate - Determine if an immediate value can be encoded |
296 | | /// as the immediate operand of a logical instruction for the given register |
297 | | /// size. If so, return true with "encoding" set to the encoded value in |
298 | | /// the form N:immr:imms. |
299 | | static inline bool AArch64_AM_processLogicalImmediate(uint64_t Imm, |
300 | | unsigned RegSize, |
301 | | uint64_t *Encoding) |
302 | 3.21k | { |
303 | 3.21k | if (Imm == 0ULL || Imm == ~0ULL || |
304 | 3.21k | (RegSize != 64 && |
305 | 3.21k | (Imm >> RegSize != 0 || Imm == (~0ULL >> (64 - RegSize))))) |
306 | 0 | return false; |
307 | | |
308 | | // First, determine the element size. |
309 | 3.21k | unsigned Size = RegSize; |
310 | | |
311 | 6.00k | do { |
312 | 6.00k | Size /= 2; |
313 | 6.00k | uint64_t Mask = (1ULL << Size) - 1; |
314 | | |
315 | 6.00k | if ((Imm & Mask) != ((Imm >> Size) & Mask)) { |
316 | 3.21k | Size *= 2; |
317 | 3.21k | break; |
318 | 3.21k | } |
319 | 6.00k | } while (Size > 2); |
320 | | |
321 | | // Second, determine the rotation to make the element be: 0^m 1^n. |
322 | 0 | uint32_t CTO, I; |
323 | 3.21k | uint64_t Mask = ((uint64_t)-1LL) >> (64 - Size); |
324 | 3.21k | Imm &= Mask; |
325 | | |
326 | 3.21k | if (isShiftedMask_64(Imm)) { |
327 | 2.18k | I = CountTrailingZeros_64(Imm); |
328 | | |
329 | 2.18k | CTO = CountTrailingOnes_64(Imm >> I); |
330 | 2.18k | } else { |
331 | 1.03k | Imm |= ~Mask; |
332 | 1.03k | if (!isShiftedMask_64(~Imm)) |
333 | 0 | return false; |
334 | | |
335 | 1.03k | unsigned CLO = CountLeadingOnes_64(Imm); |
336 | 1.03k | I = 64 - CLO; |
337 | 1.03k | CTO = CLO + CountTrailingOnes_64(Imm) - (64 - Size); |
338 | 1.03k | } |
339 | | |
340 | | // Encode in Immr the number of RORs it would take to get *from* 0^m 1^n |
341 | | // to our target value, where I is the number of RORs to go the opposite |
342 | | // direction. |
343 | | |
344 | 3.21k | unsigned Immr = (Size - I) & (Size - 1); |
345 | | |
346 | | // If size has a 1 in the n'th bit, create a value that has zeroes in |
347 | | // bits [0, n] and ones above that. |
348 | 3.21k | uint64_t NImms = ~(Size - 1) << 1; |
349 | | |
350 | | // Or the CTO value into the low bits, which must be below the Nth bit |
351 | | // bit mentioned above. |
352 | 3.21k | NImms |= (CTO - 1); |
353 | | |
354 | | // Extract the seventh bit and toggle it to create the N field. |
355 | 3.21k | unsigned N = ((NImms >> 6) & 1) ^ 1; |
356 | | |
357 | 3.21k | *Encoding = (N << 12) | (Immr << 6) | (NImms & 0x3f); |
358 | 3.21k | return true; |
359 | 3.21k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_processLogicalImmediate Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_processLogicalImmediate Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_processLogicalImmediate AArch64InstPrinter.c:AArch64_AM_processLogicalImmediate Line | Count | Source | 302 | 3.21k | { | 303 | 3.21k | if (Imm == 0ULL || Imm == ~0ULL || | 304 | 3.21k | (RegSize != 64 && | 305 | 3.21k | (Imm >> RegSize != 0 || Imm == (~0ULL >> (64 - RegSize))))) | 306 | 0 | return false; | 307 | | | 308 | | // First, determine the element size. | 309 | 3.21k | unsigned Size = RegSize; | 310 | | | 311 | 6.00k | do { | 312 | 6.00k | Size /= 2; | 313 | 6.00k | uint64_t Mask = (1ULL << Size) - 1; | 314 | | | 315 | 6.00k | if ((Imm & Mask) != ((Imm >> Size) & Mask)) { | 316 | 3.21k | Size *= 2; | 317 | 3.21k | break; | 318 | 3.21k | } | 319 | 6.00k | } while (Size > 2); | 320 | | | 321 | | // Second, determine the rotation to make the element be: 0^m 1^n. | 322 | 0 | uint32_t CTO, I; | 323 | 3.21k | uint64_t Mask = ((uint64_t)-1LL) >> (64 - Size); | 324 | 3.21k | Imm &= Mask; | 325 | | | 326 | 3.21k | if (isShiftedMask_64(Imm)) { | 327 | 2.18k | I = CountTrailingZeros_64(Imm); | 328 | | | 329 | 2.18k | CTO = CountTrailingOnes_64(Imm >> I); | 330 | 2.18k | } else { | 331 | 1.03k | Imm |= ~Mask; | 332 | 1.03k | if (!isShiftedMask_64(~Imm)) | 333 | 0 | return false; | 334 | | | 335 | 1.03k | unsigned CLO = CountLeadingOnes_64(Imm); | 336 | 1.03k | I = 64 - CLO; | 337 | 1.03k | CTO = CLO + CountTrailingOnes_64(Imm) - (64 - Size); | 338 | 1.03k | } | 339 | | | 340 | | // Encode in Immr the number of RORs it would take to get *from* 0^m 1^n | 341 | | // to our target value, where I is the number of RORs to go the opposite | 342 | | // direction. | 343 | | | 344 | 3.21k | unsigned Immr = (Size - I) & (Size - 1); | 345 | | | 346 | | // If size has a 1 in the n'th bit, create a value that has zeroes in | 347 | | // bits [0, n] and ones above that. | 348 | 3.21k | uint64_t NImms = ~(Size - 1) << 1; | 349 | | | 350 | | // Or the CTO value into the low bits, which must be below the Nth bit | 351 | | // bit mentioned above. | 352 | 3.21k | NImms |= (CTO - 1); | 353 | | | 354 | | // Extract the seventh bit and toggle it to create the N field. | 355 | 3.21k | unsigned N = ((NImms >> 6) & 1) ^ 1; | 356 | | | 357 | 3.21k | *Encoding = (N << 12) | (Immr << 6) | (NImms & 0x3f); | 358 | 3.21k | return true; | 359 | 3.21k | } |
|
360 | | |
361 | | /// isLogicalImmediate - Return true if the immediate is valid for a logical |
362 | | /// immediate instruction of the given register size. Return false otherwise. |
363 | | static inline bool AArch64_AM_isLogicalImmediate(uint64_t imm, unsigned regSize) |
364 | 1.28k | { |
365 | 1.28k | uint64_t encoding = 0; |
366 | 1.28k | return AArch64_AM_processLogicalImmediate(imm, regSize, &encoding); |
367 | 1.28k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isLogicalImmediate Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isLogicalImmediate Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isLogicalImmediate AArch64InstPrinter.c:AArch64_AM_isLogicalImmediate Line | Count | Source | 364 | 1.28k | { | 365 | 1.28k | uint64_t encoding = 0; | 366 | 1.28k | return AArch64_AM_processLogicalImmediate(imm, regSize, &encoding); | 367 | 1.28k | } |
|
368 | | |
369 | | /// encodeLogicalImmediate - Return the encoded immediate value for a logical |
370 | | /// immediate instruction of the given register size. |
371 | | static inline uint64_t AArch64_AM_encodeLogicalImmediate(uint64_t imm, |
372 | | unsigned regSize) |
373 | 0 | { |
374 | 0 | uint64_t encoding = 0; |
375 | 0 | bool res = AArch64_AM_processLogicalImmediate(imm, regSize, &encoding); |
376 | 0 |
|
377 | 0 | (void)res; |
378 | 0 | return encoding; |
379 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeLogicalImmediate Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeLogicalImmediate Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeLogicalImmediate Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeLogicalImmediate |
380 | | |
381 | | /// decodeLogicalImmediate - Decode a logical immediate value in the form |
382 | | /// "N:immr:imms" (where the immr and imms fields are each 6 bits) into the |
383 | | /// integer value it represents with regSize bits. |
384 | | static inline uint64_t AArch64_AM_decodeLogicalImmediate(uint64_t val, |
385 | | unsigned regSize) |
386 | 29.8k | { |
387 | | // Extract the N, imms, and immr fields. |
388 | 29.8k | unsigned N = (val >> 12) & 1; |
389 | 29.8k | unsigned immr = (val >> 6) & 0x3f; |
390 | 29.8k | unsigned imms = val & 0x3f; |
391 | | |
392 | 29.8k | int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f)); |
393 | 29.8k | if (len < 1) { |
394 | 0 | CS_ASSERT(len >= 1 && "Unhandled integer type"); |
395 | 0 | return 0; |
396 | 0 | } |
397 | | |
398 | 29.8k | unsigned size = (1 << len); |
399 | 29.8k | unsigned R = immr & (size - 1); |
400 | 29.8k | unsigned S = imms & (size - 1); |
401 | | |
402 | 29.8k | uint64_t pattern = (1ULL << (S + 1)) - 1; |
403 | 242k | for (unsigned i = 0; i < R; ++i) |
404 | 212k | pattern = AArch64_AM_ror(pattern, size); |
405 | | |
406 | | // Replicate the pattern to fill the regSize. |
407 | 88.9k | while (size != regSize) { |
408 | 59.1k | pattern |= (pattern << size); |
409 | 59.1k | size *= 2; |
410 | 59.1k | } |
411 | 29.8k | return pattern; |
412 | 29.8k | } AArch64Mapping.c:AArch64_AM_decodeLogicalImmediate Line | Count | Source | 386 | 6.63k | { | 387 | | // Extract the N, imms, and immr fields. | 388 | 6.63k | unsigned N = (val >> 12) & 1; | 389 | 6.63k | unsigned immr = (val >> 6) & 0x3f; | 390 | 6.63k | unsigned imms = val & 0x3f; | 391 | | | 392 | 6.63k | int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f)); | 393 | 6.63k | if (len < 1) { | 394 | 0 | CS_ASSERT(len >= 1 && "Unhandled integer type"); | 395 | 0 | return 0; | 396 | 0 | } | 397 | | | 398 | 6.63k | unsigned size = (1 << len); | 399 | 6.63k | unsigned R = immr & (size - 1); | 400 | 6.63k | unsigned S = imms & (size - 1); | 401 | | | 402 | 6.63k | uint64_t pattern = (1ULL << (S + 1)) - 1; | 403 | 59.0k | for (unsigned i = 0; i < R; ++i) | 404 | 52.4k | pattern = AArch64_AM_ror(pattern, size); | 405 | | | 406 | | // Replicate the pattern to fill the regSize. | 407 | 12.4k | while (size != regSize) { | 408 | 5.83k | pattern |= (pattern << size); | 409 | 5.83k | size *= 2; | 410 | 5.83k | } | 411 | 6.63k | return pattern; | 412 | 6.63k | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeLogicalImmediate Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeLogicalImmediate AArch64InstPrinter.c:AArch64_AM_decodeLogicalImmediate Line | Count | Source | 386 | 23.2k | { | 387 | | // Extract the N, imms, and immr fields. | 388 | 23.2k | unsigned N = (val >> 12) & 1; | 389 | 23.2k | unsigned immr = (val >> 6) & 0x3f; | 390 | 23.2k | unsigned imms = val & 0x3f; | 391 | | | 392 | 23.2k | int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f)); | 393 | 23.2k | if (len < 1) { | 394 | 0 | CS_ASSERT(len >= 1 && "Unhandled integer type"); | 395 | 0 | return 0; | 396 | 0 | } | 397 | | | 398 | 23.2k | unsigned size = (1 << len); | 399 | 23.2k | unsigned R = immr & (size - 1); | 400 | 23.2k | unsigned S = imms & (size - 1); | 401 | | | 402 | 23.2k | uint64_t pattern = (1ULL << (S + 1)) - 1; | 403 | 183k | for (unsigned i = 0; i < R; ++i) | 404 | 160k | pattern = AArch64_AM_ror(pattern, size); | 405 | | | 406 | | // Replicate the pattern to fill the regSize. | 407 | 76.5k | while (size != regSize) { | 408 | 53.2k | pattern |= (pattern << size); | 409 | 53.2k | size *= 2; | 410 | 53.2k | } | 411 | 23.2k | return pattern; | 412 | 23.2k | } |
|
413 | | |
414 | | /// isValidDecodeLogicalImmediate - Check to see if the logical immediate value |
415 | | /// in the form "N:immr:imms" (where the immr and imms fields are each 6 bits) |
416 | | /// is a valid encoding for an integer value with regSize bits. |
417 | | static inline bool AArch64_AM_isValidDecodeLogicalImmediate(uint64_t val, |
418 | | unsigned regSize) |
419 | 13.9k | { |
420 | | // Extract the N and imms fields needed for checking. |
421 | 13.9k | unsigned N = (val >> 12) & 1; |
422 | 13.9k | unsigned imms = val & 0x3f; |
423 | | |
424 | 13.9k | if (regSize == 32 && N != 0) // undefined logical immediate encoding |
425 | 0 | return false; |
426 | 13.9k | int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f)); |
427 | 13.9k | if (len < 0) // undefined logical immediate encoding |
428 | 7 | return false; |
429 | 13.9k | unsigned size = (1 << len); |
430 | 13.9k | unsigned S = imms & (size - 1); |
431 | 13.9k | if (S == size - 1) // undefined logical immediate encoding |
432 | 12 | return false; |
433 | | |
434 | 13.9k | return true; |
435 | 13.9k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isValidDecodeLogicalImmediate AArch64Disassembler.c:AArch64_AM_isValidDecodeLogicalImmediate Line | Count | Source | 419 | 13.9k | { | 420 | | // Extract the N and imms fields needed for checking. | 421 | 13.9k | unsigned N = (val >> 12) & 1; | 422 | 13.9k | unsigned imms = val & 0x3f; | 423 | | | 424 | 13.9k | if (regSize == 32 && N != 0) // undefined logical immediate encoding | 425 | 0 | return false; | 426 | 13.9k | int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f)); | 427 | 13.9k | if (len < 0) // undefined logical immediate encoding | 428 | 7 | return false; | 429 | 13.9k | unsigned size = (1 << len); | 430 | 13.9k | unsigned S = imms & (size - 1); | 431 | 13.9k | if (S == size - 1) // undefined logical immediate encoding | 432 | 12 | return false; | 433 | | | 434 | 13.9k | return true; | 435 | 13.9k | } |
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isValidDecodeLogicalImmediate Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isValidDecodeLogicalImmediate |
436 | | |
437 | | //===----------------------------------------------------------------------===// |
438 | | // Floating-point Immediates |
439 | | // |
440 | | static inline float AArch64_AM_getFPImmFloat(unsigned Imm) |
441 | 1.87k | { |
442 | | // We expect an 8-bit binary encoding of a floating-point number here. |
443 | | |
444 | 1.87k | uint32_t Sign = (Imm >> 7) & 0x1; |
445 | 1.87k | uint32_t Exp = (Imm >> 4) & 0x7; |
446 | 1.87k | uint32_t Mantissa = Imm & 0xf; |
447 | | |
448 | | // 8-bit FP IEEE Float Encoding |
449 | | // abcd efgh aBbbbbbc defgh000 00000000 00000000 |
450 | | // |
451 | | // where B = NOT(b); |
452 | | |
453 | 1.87k | uint32_t I = 0; |
454 | 1.87k | I |= Sign << 31; |
455 | 1.87k | I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30; |
456 | 1.87k | I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25; |
457 | 1.87k | I |= (Exp & 0x3) << 23; |
458 | 1.87k | I |= Mantissa << 19; |
459 | 1.87k | return BitsToFloat(I); |
460 | 1.87k | } AArch64Mapping.c:AArch64_AM_getFPImmFloat Line | Count | Source | 441 | 410 | { | 442 | | // We expect an 8-bit binary encoding of a floating-point number here. | 443 | | | 444 | 410 | uint32_t Sign = (Imm >> 7) & 0x1; | 445 | 410 | uint32_t Exp = (Imm >> 4) & 0x7; | 446 | 410 | uint32_t Mantissa = Imm & 0xf; | 447 | | | 448 | | // 8-bit FP IEEE Float Encoding | 449 | | // abcd efgh aBbbbbbc defgh000 00000000 00000000 | 450 | | // | 451 | | // where B = NOT(b); | 452 | | | 453 | 410 | uint32_t I = 0; | 454 | 410 | I |= Sign << 31; | 455 | 410 | I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30; | 456 | 410 | I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25; | 457 | 410 | I |= (Exp & 0x3) << 23; | 458 | 410 | I |= Mantissa << 19; | 459 | 410 | return BitsToFloat(I); | 460 | 410 | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getFPImmFloat Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getFPImmFloat AArch64InstPrinter.c:AArch64_AM_getFPImmFloat Line | Count | Source | 441 | 1.46k | { | 442 | | // We expect an 8-bit binary encoding of a floating-point number here. | 443 | | | 444 | 1.46k | uint32_t Sign = (Imm >> 7) & 0x1; | 445 | 1.46k | uint32_t Exp = (Imm >> 4) & 0x7; | 446 | 1.46k | uint32_t Mantissa = Imm & 0xf; | 447 | | | 448 | | // 8-bit FP IEEE Float Encoding | 449 | | // abcd efgh aBbbbbbc defgh000 00000000 00000000 | 450 | | // | 451 | | // where B = NOT(b); | 452 | | | 453 | 1.46k | uint32_t I = 0; | 454 | 1.46k | I |= Sign << 31; | 455 | 1.46k | I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30; | 456 | 1.46k | I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25; | 457 | 1.46k | I |= (Exp & 0x3) << 23; | 458 | 1.46k | I |= Mantissa << 19; | 459 | 1.46k | return BitsToFloat(I); | 460 | 1.46k | } |
|
461 | | |
462 | | //===--------------------------------------------------------------------===// |
463 | | // AdvSIMD Modified Immediates |
464 | | //===--------------------------------------------------------------------===// |
465 | | // 0x00 0x00 0x00 abcdefgh 0x00 0x00 0x00 abcdefgh |
466 | | static inline bool AArch64_AM_isAdvSIMDModImmType1(uint64_t Imm) |
467 | 0 | { |
468 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
469 | 0 | ((Imm & 0xffffff00ffffff00ULL) == 0); |
470 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType1 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType1 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType1 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType1 |
471 | | |
472 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType1(uint64_t Imm) |
473 | 0 | { |
474 | 0 | return (Imm & 0xffULL); |
475 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType1 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType1 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType1 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType1 |
476 | | |
477 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType1(uint8_t Imm) |
478 | 0 | { |
479 | 0 | uint64_t EncVal = Imm; |
480 | 0 | return (EncVal << 32) | EncVal; |
481 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType1 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType1 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType1 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType1 |
482 | | |
483 | | // 0x00 0x00 abcdefgh 0x00 0x00 0x00 abcdefgh 0x00 |
484 | | static inline bool AArch64_AM_isAdvSIMDModImmType2(uint64_t Imm) |
485 | 0 | { |
486 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
487 | 0 | ((Imm & 0xffff00ffffff00ffULL) == 0); |
488 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType2 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType2 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType2 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType2 |
489 | | |
490 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType2(uint64_t Imm) |
491 | 0 | { |
492 | 0 | return (Imm & 0xff00ULL) >> 8; |
493 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType2 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType2 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType2 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType2 |
494 | | |
495 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType2(uint8_t Imm) |
496 | 0 | { |
497 | 0 | uint64_t EncVal = Imm; |
498 | 0 | return (EncVal << 40) | (EncVal << 8); |
499 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType2 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType2 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType2 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType2 |
500 | | |
501 | | // 0x00 abcdefgh 0x00 0x00 0x00 abcdefgh 0x00 0x00 |
502 | | static inline bool AArch64_AM_isAdvSIMDModImmType3(uint64_t Imm) |
503 | 0 | { |
504 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
505 | 0 | ((Imm & 0xff00ffffff00ffffULL) == 0); |
506 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType3 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType3 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType3 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType3 |
507 | | |
508 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType3(uint64_t Imm) |
509 | 0 | { |
510 | 0 | return (Imm & 0xff0000ULL) >> 16; |
511 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType3 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType3 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType3 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType3 |
512 | | |
513 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType3(uint8_t Imm) |
514 | 0 | { |
515 | 0 | uint64_t EncVal = Imm; |
516 | 0 | return (EncVal << 48) | (EncVal << 16); |
517 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType3 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType3 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType3 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType3 |
518 | | |
519 | | // abcdefgh 0x00 0x00 0x00 abcdefgh 0x00 0x00 0x00 |
520 | | static inline bool AArch64_AM_isAdvSIMDModImmType4(uint64_t Imm) |
521 | 0 | { |
522 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
523 | 0 | ((Imm & 0x00ffffff00ffffffULL) == 0); |
524 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType4 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType4 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType4 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType4 |
525 | | |
526 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType4(uint64_t Imm) |
527 | 0 | { |
528 | 0 | return (Imm & 0xff000000ULL) >> 24; |
529 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType4 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType4 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType4 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType4 |
530 | | |
531 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType4(uint8_t Imm) |
532 | 0 | { |
533 | 0 | uint64_t EncVal = Imm; |
534 | 0 | return (EncVal << 56) | (EncVal << 24); |
535 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType4 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType4 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType4 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType4 |
536 | | |
537 | | // 0x00 abcdefgh 0x00 abcdefgh 0x00 abcdefgh 0x00 abcdefgh |
538 | | static inline bool AArch64_AM_isAdvSIMDModImmType5(uint64_t Imm) |
539 | 0 | { |
540 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
541 | 0 | (((Imm & 0x00ff0000ULL) >> 16) == (Imm & 0x000000ffULL)) && |
542 | 0 | ((Imm & 0xff00ff00ff00ff00ULL) == 0); |
543 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType5 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType5 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType5 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType5 |
544 | | |
545 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType5(uint64_t Imm) |
546 | 0 | { |
547 | 0 | return (Imm & 0xffULL); |
548 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType5 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType5 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType5 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType5 |
549 | | |
550 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType5(uint8_t Imm) |
551 | 0 | { |
552 | 0 | uint64_t EncVal = Imm; |
553 | 0 | return (EncVal << 48) | (EncVal << 32) | (EncVal << 16) | EncVal; |
554 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType5 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType5 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType5 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType5 |
555 | | |
556 | | // abcdefgh 0x00 abcdefgh 0x00 abcdefgh 0x00 abcdefgh 0x00 |
557 | | static inline bool AArch64_AM_isAdvSIMDModImmType6(uint64_t Imm) |
558 | 0 | { |
559 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
560 | 0 | (((Imm & 0xff000000ULL) >> 16) == (Imm & 0x0000ff00ULL)) && |
561 | 0 | ((Imm & 0x00ff00ff00ff00ffULL) == 0); |
562 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType6 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType6 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType6 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType6 |
563 | | |
564 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType6(uint64_t Imm) |
565 | 0 | { |
566 | 0 | return (Imm & 0xff00ULL) >> 8; |
567 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType6 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType6 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType6 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType6 |
568 | | |
569 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType6(uint8_t Imm) |
570 | 0 | { |
571 | 0 | uint64_t EncVal = Imm; |
572 | 0 | return (EncVal << 56) | (EncVal << 40) | (EncVal << 24) | (EncVal << 8); |
573 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType6 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType6 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType6 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType6 |
574 | | |
575 | | // 0x00 0x00 abcdefgh 0xFF 0x00 0x00 abcdefgh 0xFF |
576 | | static inline bool AArch64_AM_isAdvSIMDModImmType7(uint64_t Imm) |
577 | 0 | { |
578 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
579 | 0 | ((Imm & 0xffff00ffffff00ffULL) == 0x000000ff000000ffULL); |
580 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType7 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType7 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType7 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType7 |
581 | | |
582 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType7(uint64_t Imm) |
583 | 0 | { |
584 | 0 | return (Imm & 0xff00ULL) >> 8; |
585 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType7 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType7 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType7 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType7 |
586 | | |
587 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType7(uint8_t Imm) |
588 | 0 | { |
589 | 0 | uint64_t EncVal = Imm; |
590 | 0 | return (EncVal << 40) | (EncVal << 8) | 0x000000ff000000ffULL; |
591 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType7 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType7 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType7 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType7 |
592 | | |
593 | | // 0x00 abcdefgh 0xFF 0xFF 0x00 abcdefgh 0xFF 0xFF |
594 | | static inline bool AArch64_AM_isAdvSIMDModImmType8(uint64_t Imm) |
595 | 0 | { |
596 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
597 | 0 | ((Imm & 0xff00ffffff00ffffULL) == 0x0000ffff0000ffffULL); |
598 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType8 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType8 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType8 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType8 |
599 | | |
600 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType8(uint8_t Imm) |
601 | 0 | { |
602 | 0 | uint64_t EncVal = Imm; |
603 | 0 | return (EncVal << 48) | (EncVal << 16) | 0x0000ffff0000ffffULL; |
604 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType8 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType8 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType8 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType8 |
605 | | |
606 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType8(uint64_t Imm) |
607 | 0 | { |
608 | 0 | return (Imm & 0x00ff0000ULL) >> 16; |
609 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType8 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType8 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType8 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType8 |
610 | | |
611 | | // abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh abcdefgh |
612 | | static inline bool AArch64_AM_isAdvSIMDModImmType9(uint64_t Imm) |
613 | 0 | { |
614 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
615 | 0 | ((Imm >> 48) == (Imm & 0x0000ffffULL)) && |
616 | 0 | ((Imm >> 56) == (Imm & 0x000000ffULL)); |
617 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType9 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType9 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType9 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType9 |
618 | | |
619 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType9(uint64_t Imm) |
620 | 0 | { |
621 | 0 | return (Imm & 0xffULL); |
622 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType9 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType9 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType9 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType9 |
623 | | |
624 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType9(uint8_t Imm) |
625 | 0 | { |
626 | 0 | uint64_t EncVal = Imm; |
627 | 0 | EncVal |= (EncVal << 8); |
628 | 0 | EncVal |= (EncVal << 16); |
629 | 0 | EncVal |= (EncVal << 32); |
630 | 0 | return EncVal; |
631 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType9 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType9 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType9 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType9 |
632 | | |
633 | | // aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff gggggggg hhhhhhhh |
634 | | // cmode: 1110, op: 1 |
635 | | static inline bool AArch64_AM_isAdvSIMDModImmType10(uint64_t Imm) |
636 | 0 | { |
637 | 0 | #if defined(_MSC_VER) && _MSC_VER == 1937 && !defined(__clang__) && \ |
638 | 0 | defined(_M_ARM64) |
639 | 0 | // The MSVC compiler 19.37 for ARM64 has an optimization bug that |
640 | 0 | // causes an incorrect behavior with the orignal version. Work around |
641 | 0 | // by using a slightly different variation. |
642 | 0 | // https://developercommunity.visualstudio.com/t/C-ARM64-compiler-optimization-bug/10481261 |
643 | 0 | constexpr uint64_t Mask = 0xFFULL; |
644 | 0 | uint64_t ByteA = (Imm >> 56) & Mask; |
645 | 0 | uint64_t ByteB = (Imm >> 48) & Mask; |
646 | 0 | uint64_t ByteC = (Imm >> 40) & Mask; |
647 | 0 | uint64_t ByteD = (Imm >> 32) & Mask; |
648 | 0 | uint64_t ByteE = (Imm >> 24) & Mask; |
649 | 0 | uint64_t ByteF = (Imm >> 16) & Mask; |
650 | 0 | uint64_t ByteG = (Imm >> 8) & Mask; |
651 | 0 | uint64_t ByteH = Imm & Mask; |
652 | 0 |
|
653 | 0 | return (ByteA == 0ULL || ByteA == Mask) && |
654 | 0 | (ByteB == 0ULL || ByteB == Mask) && |
655 | 0 | (ByteC == 0ULL || ByteC == Mask) && |
656 | 0 | (ByteD == 0ULL || ByteD == Mask) && |
657 | 0 | (ByteE == 0ULL || ByteE == Mask) && |
658 | 0 | (ByteF == 0ULL || ByteF == Mask) && |
659 | 0 | (ByteG == 0ULL || ByteG == Mask) && |
660 | 0 | (ByteH == 0ULL || ByteH == Mask); |
661 | 0 | #else |
662 | 0 | uint64_t ByteA = Imm & 0xff00000000000000ULL; |
663 | 0 | uint64_t ByteB = Imm & 0x00ff000000000000ULL; |
664 | 0 | uint64_t ByteC = Imm & 0x0000ff0000000000ULL; |
665 | 0 | uint64_t ByteD = Imm & 0x000000ff00000000ULL; |
666 | 0 | uint64_t ByteE = Imm & 0x00000000ff000000ULL; |
667 | 0 | uint64_t ByteF = Imm & 0x0000000000ff0000ULL; |
668 | 0 | uint64_t ByteG = Imm & 0x000000000000ff00ULL; |
669 | 0 | uint64_t ByteH = Imm & 0x00000000000000ffULL; |
670 | 0 |
|
671 | 0 | return (ByteA == 0ULL || ByteA == 0xff00000000000000ULL) && |
672 | 0 | (ByteB == 0ULL || ByteB == 0x00ff000000000000ULL) && |
673 | 0 | (ByteC == 0ULL || ByteC == 0x0000ff0000000000ULL) && |
674 | 0 | (ByteD == 0ULL || ByteD == 0x000000ff00000000ULL) && |
675 | 0 | (ByteE == 0ULL || ByteE == 0x00000000ff000000ULL) && |
676 | 0 | (ByteF == 0ULL || ByteF == 0x0000000000ff0000ULL) && |
677 | 0 | (ByteG == 0ULL || ByteG == 0x000000000000ff00ULL) && |
678 | 0 | (ByteH == 0ULL || ByteH == 0x00000000000000ffULL); |
679 | 0 | #endif |
680 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType10 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType10 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType10 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType10 |
681 | | |
682 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType10(uint64_t Imm) |
683 | 0 | { |
684 | 0 | uint8_t BitA = (Imm & 0xff00000000000000ULL) != 0; |
685 | 0 | uint8_t BitB = (Imm & 0x00ff000000000000ULL) != 0; |
686 | 0 | uint8_t BitC = (Imm & 0x0000ff0000000000ULL) != 0; |
687 | 0 | uint8_t BitD = (Imm & 0x000000ff00000000ULL) != 0; |
688 | 0 | uint8_t BitE = (Imm & 0x00000000ff000000ULL) != 0; |
689 | 0 | uint8_t BitF = (Imm & 0x0000000000ff0000ULL) != 0; |
690 | 0 | uint8_t BitG = (Imm & 0x000000000000ff00ULL) != 0; |
691 | 0 | uint8_t BitH = (Imm & 0x00000000000000ffULL) != 0; |
692 | 0 |
|
693 | 0 | uint8_t EncVal = BitA; |
694 | 0 | EncVal <<= 1; |
695 | 0 | EncVal |= BitB; |
696 | 0 | EncVal <<= 1; |
697 | 0 | EncVal |= BitC; |
698 | 0 | EncVal <<= 1; |
699 | 0 | EncVal |= BitD; |
700 | 0 | EncVal <<= 1; |
701 | 0 | EncVal |= BitE; |
702 | 0 | EncVal <<= 1; |
703 | 0 | EncVal |= BitF; |
704 | 0 | EncVal <<= 1; |
705 | 0 | EncVal |= BitG; |
706 | 0 | EncVal <<= 1; |
707 | 0 | EncVal |= BitH; |
708 | 0 | return EncVal; |
709 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType10 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType10 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType10 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType10 |
710 | | |
711 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType10(uint8_t Imm) |
712 | 2.42k | { |
713 | 2.42k | uint64_t EncVal = 0; |
714 | 2.42k | if (Imm & 0x80) |
715 | 441 | EncVal |= 0xff00000000000000ULL; |
716 | 2.42k | if (Imm & 0x40) |
717 | 512 | EncVal |= 0x00ff000000000000ULL; |
718 | 2.42k | if (Imm & 0x20) |
719 | 747 | EncVal |= 0x0000ff0000000000ULL; |
720 | 2.42k | if (Imm & 0x10) |
721 | 1.54k | EncVal |= 0x000000ff00000000ULL; |
722 | 2.42k | if (Imm & 0x08) |
723 | 1.36k | EncVal |= 0x00000000ff000000ULL; |
724 | 2.42k | if (Imm & 0x04) |
725 | 610 | EncVal |= 0x0000000000ff0000ULL; |
726 | 2.42k | if (Imm & 0x02) |
727 | 1.46k | EncVal |= 0x000000000000ff00ULL; |
728 | 2.42k | if (Imm & 0x01) |
729 | 1.71k | EncVal |= 0x00000000000000ffULL; |
730 | 2.42k | return EncVal; |
731 | 2.42k | } AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType10 Line | Count | Source | 712 | 812 | { | 713 | 812 | uint64_t EncVal = 0; | 714 | 812 | if (Imm & 0x80) | 715 | 53 | EncVal |= 0xff00000000000000ULL; | 716 | 812 | if (Imm & 0x40) | 717 | 30 | EncVal |= 0x00ff000000000000ULL; | 718 | 812 | if (Imm & 0x20) | 719 | 147 | EncVal |= 0x0000ff0000000000ULL; | 720 | 812 | if (Imm & 0x10) | 721 | 599 | EncVal |= 0x000000ff00000000ULL; | 722 | 812 | if (Imm & 0x08) | 723 | 561 | EncVal |= 0x00000000ff000000ULL; | 724 | 812 | if (Imm & 0x04) | 725 | 208 | EncVal |= 0x0000000000ff0000ULL; | 726 | 812 | if (Imm & 0x02) | 727 | 635 | EncVal |= 0x000000000000ff00ULL; | 728 | 812 | if (Imm & 0x01) | 729 | 503 | EncVal |= 0x00000000000000ffULL; | 730 | 812 | return EncVal; | 731 | 812 | } |
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType10 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType10 AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType10 Line | Count | Source | 712 | 1.60k | { | 713 | 1.60k | uint64_t EncVal = 0; | 714 | 1.60k | if (Imm & 0x80) | 715 | 388 | EncVal |= 0xff00000000000000ULL; | 716 | 1.60k | if (Imm & 0x40) | 717 | 482 | EncVal |= 0x00ff000000000000ULL; | 718 | 1.60k | if (Imm & 0x20) | 719 | 600 | EncVal |= 0x0000ff0000000000ULL; | 720 | 1.60k | if (Imm & 0x10) | 721 | 949 | EncVal |= 0x000000ff00000000ULL; | 722 | 1.60k | if (Imm & 0x08) | 723 | 801 | EncVal |= 0x00000000ff000000ULL; | 724 | 1.60k | if (Imm & 0x04) | 725 | 402 | EncVal |= 0x0000000000ff0000ULL; | 726 | 1.60k | if (Imm & 0x02) | 727 | 834 | EncVal |= 0x000000000000ff00ULL; | 728 | 1.60k | if (Imm & 0x01) | 729 | 1.20k | EncVal |= 0x00000000000000ffULL; | 730 | 1.60k | return EncVal; | 731 | 1.60k | } |
|
732 | | |
733 | | // aBbbbbbc defgh000 0x00 0x00 aBbbbbbc defgh000 0x00 0x00 |
734 | | static inline bool AArch64_AM_isAdvSIMDModImmType11(uint64_t Imm) |
735 | 0 | { |
736 | 0 | uint64_t BString = (Imm & 0x7E000000ULL) >> 25; |
737 | 0 | return ((Imm >> 32) == (Imm & 0xffffffffULL)) && |
738 | 0 | (BString == 0x1f || BString == 0x20) && |
739 | 0 | ((Imm & 0x0007ffff0007ffffULL) == 0); |
740 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType11 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType11 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType11 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType11 |
741 | | |
742 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType11(uint64_t Imm) |
743 | 0 | { |
744 | 0 | uint8_t BitA = (Imm & 0x80000000ULL) != 0; |
745 | 0 | uint8_t BitB = (Imm & 0x20000000ULL) != 0; |
746 | 0 | uint8_t BitC = (Imm & 0x01000000ULL) != 0; |
747 | 0 | uint8_t BitD = (Imm & 0x00800000ULL) != 0; |
748 | 0 | uint8_t BitE = (Imm & 0x00400000ULL) != 0; |
749 | 0 | uint8_t BitF = (Imm & 0x00200000ULL) != 0; |
750 | 0 | uint8_t BitG = (Imm & 0x00100000ULL) != 0; |
751 | 0 | uint8_t BitH = (Imm & 0x00080000ULL) != 0; |
752 | 0 |
|
753 | 0 | uint8_t EncVal = BitA; |
754 | 0 | EncVal <<= 1; |
755 | 0 | EncVal |= BitB; |
756 | 0 | EncVal <<= 1; |
757 | 0 | EncVal |= BitC; |
758 | 0 | EncVal <<= 1; |
759 | 0 | EncVal |= BitD; |
760 | 0 | EncVal <<= 1; |
761 | 0 | EncVal |= BitE; |
762 | 0 | EncVal <<= 1; |
763 | 0 | EncVal |= BitF; |
764 | 0 | EncVal <<= 1; |
765 | 0 | EncVal |= BitG; |
766 | 0 | EncVal <<= 1; |
767 | 0 | EncVal |= BitH; |
768 | 0 | return EncVal; |
769 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType11 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType11 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType11 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType11 |
770 | | |
771 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType11(uint8_t Imm) |
772 | 0 | { |
773 | 0 | uint64_t EncVal = 0; |
774 | 0 | if (Imm & 0x80) |
775 | 0 | EncVal |= 0x80000000ULL; |
776 | 0 | if (Imm & 0x40) |
777 | 0 | EncVal |= 0x3e000000ULL; |
778 | 0 | else |
779 | 0 | EncVal |= 0x40000000ULL; |
780 | 0 | if (Imm & 0x20) |
781 | 0 | EncVal |= 0x01000000ULL; |
782 | 0 | if (Imm & 0x10) |
783 | 0 | EncVal |= 0x00800000ULL; |
784 | 0 | if (Imm & 0x08) |
785 | 0 | EncVal |= 0x00400000ULL; |
786 | 0 | if (Imm & 0x04) |
787 | 0 | EncVal |= 0x00200000ULL; |
788 | 0 | if (Imm & 0x02) |
789 | 0 | EncVal |= 0x00100000ULL; |
790 | 0 | if (Imm & 0x01) |
791 | 0 | EncVal |= 0x00080000ULL; |
792 | 0 | return (EncVal << 32) | EncVal; |
793 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType11 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType11 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType11 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType11 |
794 | | |
795 | | // aBbbbbbb bbcdefgh 0x00 0x00 0x00 0x00 0x00 0x00 |
796 | | static inline bool AArch64_AM_isAdvSIMDModImmType12(uint64_t Imm) |
797 | 0 | { |
798 | 0 | uint64_t BString = (Imm & 0x7fc0000000000000ULL) >> 54; |
799 | 0 | return ((BString == 0xff || BString == 0x100) && |
800 | 0 | ((Imm & 0x0000ffffffffffffULL) == 0)); |
801 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAdvSIMDModImmType12 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAdvSIMDModImmType12 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAdvSIMDModImmType12 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_isAdvSIMDModImmType12 |
802 | | |
803 | | static inline uint8_t AArch64_AM_encodeAdvSIMDModImmType12(uint64_t Imm) |
804 | 0 | { |
805 | 0 | uint8_t BitA = (Imm & 0x8000000000000000ULL) != 0; |
806 | 0 | uint8_t BitB = (Imm & 0x0040000000000000ULL) != 0; |
807 | 0 | uint8_t BitC = (Imm & 0x0020000000000000ULL) != 0; |
808 | 0 | uint8_t BitD = (Imm & 0x0010000000000000ULL) != 0; |
809 | 0 | uint8_t BitE = (Imm & 0x0008000000000000ULL) != 0; |
810 | 0 | uint8_t BitF = (Imm & 0x0004000000000000ULL) != 0; |
811 | 0 | uint8_t BitG = (Imm & 0x0002000000000000ULL) != 0; |
812 | 0 | uint8_t BitH = (Imm & 0x0001000000000000ULL) != 0; |
813 | 0 |
|
814 | 0 | uint8_t EncVal = BitA; |
815 | 0 | EncVal <<= 1; |
816 | 0 | EncVal |= BitB; |
817 | 0 | EncVal <<= 1; |
818 | 0 | EncVal |= BitC; |
819 | 0 | EncVal <<= 1; |
820 | 0 | EncVal |= BitD; |
821 | 0 | EncVal <<= 1; |
822 | 0 | EncVal |= BitE; |
823 | 0 | EncVal <<= 1; |
824 | 0 | EncVal |= BitF; |
825 | 0 | EncVal <<= 1; |
826 | 0 | EncVal |= BitG; |
827 | 0 | EncVal <<= 1; |
828 | 0 | EncVal |= BitH; |
829 | 0 | return EncVal; |
830 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_encodeAdvSIMDModImmType12 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_encodeAdvSIMDModImmType12 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_encodeAdvSIMDModImmType12 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_encodeAdvSIMDModImmType12 |
831 | | |
832 | | static inline uint64_t AArch64_AM_decodeAdvSIMDModImmType12(uint8_t Imm) |
833 | 0 | { |
834 | 0 | uint64_t EncVal = 0; |
835 | 0 | if (Imm & 0x80) |
836 | 0 | EncVal |= 0x8000000000000000ULL; |
837 | 0 | if (Imm & 0x40) |
838 | 0 | EncVal |= 0x3fc0000000000000ULL; |
839 | 0 | else |
840 | 0 | EncVal |= 0x4000000000000000ULL; |
841 | 0 | if (Imm & 0x20) |
842 | 0 | EncVal |= 0x0020000000000000ULL; |
843 | 0 | if (Imm & 0x10) |
844 | 0 | EncVal |= 0x0010000000000000ULL; |
845 | 0 | if (Imm & 0x08) |
846 | 0 | EncVal |= 0x0008000000000000ULL; |
847 | 0 | if (Imm & 0x04) |
848 | 0 | EncVal |= 0x0004000000000000ULL; |
849 | 0 | if (Imm & 0x02) |
850 | 0 | EncVal |= 0x0002000000000000ULL; |
851 | 0 | if (Imm & 0x01) |
852 | 0 | EncVal |= 0x0001000000000000ULL; |
853 | 0 | return (EncVal << 32) | EncVal; |
854 | 0 | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType12 Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType12 Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType12 Unexecuted instantiation: AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType12 |
855 | | |
856 | | /// Returns true if Imm is the concatenation of a repeating pattern of type T. |
857 | | #define DEFINE_isSVEMaskOfIdenticalElements(T) \ |
858 | | static inline bool CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, \ |
859 | | T)(int64_t Imm) \ |
860 | 40.8k | { \ |
861 | 40.8k | union { \ |
862 | 40.8k | int64_t In; \ |
863 | 40.8k | T Out[sizeof(int64_t) / sizeof(T)]; \ |
864 | 40.8k | } U_Parts; \ |
865 | 40.8k | U_Parts.In = Imm; \ |
866 | 40.8k | T *Parts = U_Parts.Out; \ |
867 | 185k | for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \ |
868 | 150k | if (Parts[i] != Parts[0]) \ |
869 | 150k | return false; \ |
870 | 150k | } \ |
871 | 40.8k | return true; \ |
872 | 40.8k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isSVEMaskOfIdenticalElements_int8_t Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isSVEMaskOfIdenticalElements_int16_t Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isSVEMaskOfIdenticalElements_int32_t Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isSVEMaskOfIdenticalElements_int64_t Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isSVEMaskOfIdenticalElements_int8_t Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isSVEMaskOfIdenticalElements_int16_t Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isSVEMaskOfIdenticalElements_int32_t Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isSVEMaskOfIdenticalElements_int64_t Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isSVEMaskOfIdenticalElements_int8_t Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isSVEMaskOfIdenticalElements_int16_t Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isSVEMaskOfIdenticalElements_int32_t Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isSVEMaskOfIdenticalElements_int64_t AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int8_t Line | Count | Source | 860 | 10.3k | { \ | 861 | 10.3k | union { \ | 862 | 10.3k | int64_t In; \ | 863 | 10.3k | T Out[sizeof(int64_t) / sizeof(T)]; \ | 864 | 10.3k | } U_Parts; \ | 865 | 10.3k | U_Parts.In = Imm; \ | 866 | 10.3k | T *Parts = U_Parts.Out; \ | 867 | 77.5k | for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \ | 868 | 69.6k | if (Parts[i] != Parts[0]) \ | 869 | 69.6k | return false; \ | 870 | 69.6k | } \ | 871 | 10.3k | return true; \ | 872 | 10.3k | } |
AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int16_t Line | Count | Source | 860 | 14.1k | { \ | 861 | 14.1k | union { \ | 862 | 14.1k | int64_t In; \ | 863 | 14.1k | T Out[sizeof(int64_t) / sizeof(T)]; \ | 864 | 14.1k | } U_Parts; \ | 865 | 14.1k | U_Parts.In = Imm; \ | 866 | 14.1k | T *Parts = U_Parts.Out; \ | 867 | 62.8k | for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \ | 868 | 51.4k | if (Parts[i] != Parts[0]) \ | 869 | 51.4k | return false; \ | 870 | 51.4k | } \ | 871 | 14.1k | return true; \ | 872 | 14.1k | } |
AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int32_t Line | Count | Source | 860 | 13.3k | { \ | 861 | 13.3k | union { \ | 862 | 13.3k | int64_t In; \ | 863 | 13.3k | T Out[sizeof(int64_t) / sizeof(T)]; \ | 864 | 13.3k | } U_Parts; \ | 865 | 13.3k | U_Parts.In = Imm; \ | 866 | 13.3k | T *Parts = U_Parts.Out; \ | 867 | 39.3k | for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \ | 868 | 26.7k | if (Parts[i] != Parts[0]) \ | 869 | 26.7k | return false; \ | 870 | 26.7k | } \ | 871 | 13.3k | return true; \ | 872 | 13.3k | } |
AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int64_t Line | Count | Source | 860 | 3.02k | { \ | 861 | 3.02k | union { \ | 862 | 3.02k | int64_t In; \ | 863 | 3.02k | T Out[sizeof(int64_t) / sizeof(T)]; \ | 864 | 3.02k | } U_Parts; \ | 865 | 3.02k | U_Parts.In = Imm; \ | 866 | 3.02k | T *Parts = U_Parts.Out; \ | 867 | 6.04k | for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \ | 868 | 3.02k | if (Parts[i] != Parts[0]) \ | 869 | 3.02k | return false; \ | 870 | 3.02k | } \ | 871 | 3.02k | return true; \ | 872 | 3.02k | } |
|
873 | | DEFINE_isSVEMaskOfIdenticalElements(int8_t); |
874 | | DEFINE_isSVEMaskOfIdenticalElements(int16_t); |
875 | | DEFINE_isSVEMaskOfIdenticalElements(int32_t); |
876 | | DEFINE_isSVEMaskOfIdenticalElements(int64_t); |
877 | | |
878 | | static inline bool isSVECpyImm8(int64_t Imm) |
879 | 6.41k | { |
880 | 6.41k | bool IsImm8 = (int8_t)Imm == Imm; |
881 | | |
882 | 6.41k | return IsImm8 || (uint8_t)Imm == Imm; |
883 | 6.41k | } Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm8 Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm8 Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm8 AArch64InstPrinter.c:isSVECpyImm8 Line | Count | Source | 879 | 6.41k | { | 880 | 6.41k | bool IsImm8 = (int8_t)Imm == Imm; | 881 | | | 882 | 6.41k | return IsImm8 || (uint8_t)Imm == Imm; | 883 | 6.41k | } |
|
884 | | |
885 | | static inline bool isSVECpyImm16(int64_t Imm) |
886 | 9.84k | { |
887 | 9.84k | bool IsImm8 = (int8_t)Imm == Imm; |
888 | 9.84k | bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm; |
889 | | |
890 | 9.84k | return IsImm8 || IsImm16 || (uint16_t)(Imm & ~0xff) == Imm; |
891 | 9.84k | } Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm16 Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm16 Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm16 AArch64InstPrinter.c:isSVECpyImm16 Line | Count | Source | 886 | 9.84k | { | 887 | 9.84k | bool IsImm8 = (int8_t)Imm == Imm; | 888 | 9.84k | bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm; | 889 | | | 890 | 9.84k | return IsImm8 || IsImm16 || (uint16_t)(Imm & ~0xff) == Imm; | 891 | 9.84k | } |
|
892 | | |
893 | | static inline bool isSVECpyImm32(int64_t Imm) |
894 | 13.0k | { |
895 | 13.0k | bool IsImm8 = (int8_t)Imm == Imm; |
896 | 13.0k | bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm; |
897 | | |
898 | 13.0k | return IsImm8 || IsImm16; |
899 | 13.0k | } Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm32 Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm32 Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm32 AArch64InstPrinter.c:isSVECpyImm32 Line | Count | Source | 894 | 13.0k | { | 895 | 13.0k | bool IsImm8 = (int8_t)Imm == Imm; | 896 | 13.0k | bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm; | 897 | | | 898 | 13.0k | return IsImm8 || IsImm16; | 899 | 13.0k | } |
|
900 | | |
901 | | static inline bool isSVECpyImm64(int64_t Imm) |
902 | 14.4k | { |
903 | 14.4k | bool IsImm8 = (int8_t)Imm == Imm; |
904 | 14.4k | bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm; |
905 | | |
906 | 14.4k | return IsImm8 || IsImm16; |
907 | 14.4k | } Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm64 Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm64 Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm64 AArch64InstPrinter.c:isSVECpyImm64 Line | Count | Source | 902 | 14.4k | { | 903 | 14.4k | bool IsImm8 = (int8_t)Imm == Imm; | 904 | 14.4k | bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm; | 905 | | | 906 | 14.4k | return IsImm8 || IsImm16; | 907 | 14.4k | } |
|
908 | | |
909 | | /// Return true if Imm is valid for DUPM and has no single CPY/DUP equivalent. |
910 | | static inline bool |
911 | | AArch64_AM_isSVEMoveMaskPreferredLogicalImmediate(int64_t Imm) |
912 | 14.4k | { |
913 | 14.4k | if (isSVECpyImm64(Imm)) |
914 | 298 | return false; |
915 | | |
916 | 14.1k | union { |
917 | 14.1k | int64_t In; |
918 | 14.1k | int32_t Out[2]; |
919 | 14.1k | } U_S; |
920 | 14.1k | U_S.In = Imm; |
921 | 14.1k | int32_t *S = U_S.Out; |
922 | 14.1k | union { |
923 | 14.1k | int64_t In; |
924 | 14.1k | int16_t Out[4]; |
925 | 14.1k | } U_H; |
926 | 14.1k | U_H.In = Imm; |
927 | 14.1k | int16_t *H = U_H.Out; |
928 | 14.1k | union { |
929 | 14.1k | int64_t In; |
930 | 14.1k | int8_t Out[8]; |
931 | 14.1k | } U_B; |
932 | 14.1k | U_B.In = Imm; |
933 | 14.1k | int8_t *B = U_B.Out; |
934 | | |
935 | 14.1k | if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int32_t)(Imm) && |
936 | 14.1k | isSVECpyImm32(S[0])) |
937 | 1.63k | return false; |
938 | 12.4k | if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int16_t)(Imm) && |
939 | 12.4k | isSVECpyImm16(H[0])) |
940 | 2.83k | return false; |
941 | 9.63k | if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int8_t)(Imm) && |
942 | 9.63k | isSVECpyImm8(B[0])) |
943 | 6.41k | return false; |
944 | 3.21k | return AArch64_AM_isLogicalImmediate(Imm, 64); |
945 | 9.63k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isSVEMoveMaskPreferredLogicalImmediate Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isSVEMoveMaskPreferredLogicalImmediate Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isSVEMoveMaskPreferredLogicalImmediate AArch64InstPrinter.c:AArch64_AM_isSVEMoveMaskPreferredLogicalImmediate Line | Count | Source | 912 | 14.4k | { | 913 | 14.4k | if (isSVECpyImm64(Imm)) | 914 | 298 | return false; | 915 | | | 916 | 14.1k | union { | 917 | 14.1k | int64_t In; | 918 | 14.1k | int32_t Out[2]; | 919 | 14.1k | } U_S; | 920 | 14.1k | U_S.In = Imm; | 921 | 14.1k | int32_t *S = U_S.Out; | 922 | 14.1k | union { | 923 | 14.1k | int64_t In; | 924 | 14.1k | int16_t Out[4]; | 925 | 14.1k | } U_H; | 926 | 14.1k | U_H.In = Imm; | 927 | 14.1k | int16_t *H = U_H.Out; | 928 | 14.1k | union { | 929 | 14.1k | int64_t In; | 930 | 14.1k | int8_t Out[8]; | 931 | 14.1k | } U_B; | 932 | 14.1k | U_B.In = Imm; | 933 | 14.1k | int8_t *B = U_B.Out; | 934 | | | 935 | 14.1k | if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int32_t)(Imm) && | 936 | 14.1k | isSVECpyImm32(S[0])) | 937 | 1.63k | return false; | 938 | 12.4k | if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int16_t)(Imm) && | 939 | 12.4k | isSVECpyImm16(H[0])) | 940 | 2.83k | return false; | 941 | 9.63k | if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int8_t)(Imm) && | 942 | 9.63k | isSVECpyImm8(B[0])) | 943 | 6.41k | return false; | 944 | 3.21k | return AArch64_AM_isLogicalImmediate(Imm, 64); | 945 | 9.63k | } |
|
946 | | |
947 | | inline static bool AArch64_AM_isAnyMOVZMovAlias(uint64_t Value, int RegWidth) |
948 | 2.74k | { |
949 | 11.7k | for (int Shift = 0; Shift <= RegWidth - 16; Shift += 16) |
950 | 9.69k | if ((Value & ~(0xffffULL << Shift)) == 0) |
951 | 634 | return true; |
952 | | |
953 | 2.10k | return false; |
954 | 2.74k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAnyMOVZMovAlias Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAnyMOVZMovAlias Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAnyMOVZMovAlias AArch64InstPrinter.c:AArch64_AM_isAnyMOVZMovAlias Line | Count | Source | 948 | 2.74k | { | 949 | 11.7k | for (int Shift = 0; Shift <= RegWidth - 16; Shift += 16) | 950 | 9.69k | if ((Value & ~(0xffffULL << Shift)) == 0) | 951 | 634 | return true; | 952 | | | 953 | 2.10k | return false; | 954 | 2.74k | } |
|
955 | | |
956 | | inline static bool AArch64_AM_isMOVZMovAlias(uint64_t Value, int Shift, |
957 | | int RegWidth) |
958 | 1.27k | { |
959 | 1.27k | if (RegWidth == 32) |
960 | 86 | Value &= 0xffffffffULL; |
961 | | |
962 | | // "lsl #0" takes precedence: in practice this only affects "#0, lsl #0". |
963 | 1.27k | if (Value == 0 && Shift != 0) |
964 | 54 | return false; |
965 | | |
966 | 1.22k | return (Value & ~(0xffffULL << Shift)) == 0; |
967 | 1.27k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isMOVZMovAlias Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isMOVZMovAlias Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isMOVZMovAlias AArch64InstPrinter.c:AArch64_AM_isMOVZMovAlias Line | Count | Source | 958 | 1.27k | { | 959 | 1.27k | if (RegWidth == 32) | 960 | 86 | Value &= 0xffffffffULL; | 961 | | | 962 | | // "lsl #0" takes precedence: in practice this only affects "#0, lsl #0". | 963 | 1.27k | if (Value == 0 && Shift != 0) | 964 | 54 | return false; | 965 | | | 966 | 1.22k | return (Value & ~(0xffffULL << Shift)) == 0; | 967 | 1.27k | } |
|
968 | | |
969 | | inline static bool AArch64_AM_isMOVNMovAlias(uint64_t Value, int Shift, |
970 | | int RegWidth) |
971 | 1.90k | { |
972 | | // MOVZ takes precedence over MOVN. |
973 | 1.90k | if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth)) |
974 | 136 | return false; |
975 | | |
976 | 1.77k | Value = ~Value; |
977 | 1.77k | if (RegWidth == 32) |
978 | 296 | Value &= 0xffffffffULL; |
979 | | |
980 | 1.77k | return AArch64_AM_isMOVZMovAlias(Value, Shift, RegWidth); |
981 | 1.90k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isMOVNMovAlias Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isMOVNMovAlias Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isMOVNMovAlias AArch64InstPrinter.c:AArch64_AM_isMOVNMovAlias Line | Count | Source | 971 | 1.90k | { | 972 | | // MOVZ takes precedence over MOVN. | 973 | 1.90k | if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth)) | 974 | 136 | return false; | 975 | | | 976 | 1.77k | Value = ~Value; | 977 | 1.77k | if (RegWidth == 32) | 978 | 296 | Value &= 0xffffffffULL; | 979 | | | 980 | 1.77k | return AArch64_AM_isMOVZMovAlias(Value, Shift, RegWidth); | 981 | 1.90k | } |
|
982 | | |
983 | | inline static bool AArch64_AM_isAnyMOVWMovAlias(uint64_t Value, int RegWidth) |
984 | 1.17k | { |
985 | 1.17k | if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth)) |
986 | 185 | return true; |
987 | | |
988 | | // It's not a MOVZ, but it might be a MOVN. |
989 | 990 | Value = ~Value; |
990 | 990 | if (RegWidth == 32) |
991 | 156 | Value &= 0xffffffffULL; |
992 | | |
993 | 990 | return AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth); |
994 | 1.17k | } Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isAnyMOVWMovAlias Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_isAnyMOVWMovAlias Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_isAnyMOVWMovAlias AArch64InstPrinter.c:AArch64_AM_isAnyMOVWMovAlias Line | Count | Source | 984 | 1.17k | { | 985 | 1.17k | if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth)) | 986 | 185 | return true; | 987 | | | 988 | | // It's not a MOVZ, but it might be a MOVN. | 989 | 990 | Value = ~Value; | 990 | 990 | if (RegWidth == 32) | 991 | 156 | Value &= 0xffffffffULL; | 992 | | | 993 | 990 | return AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth); | 994 | 1.17k | } |
|
995 | | |
996 | | // CS namespace end: AArch64_AM |
997 | | |
998 | | // end namespace AArch64_AM |
999 | | |
1000 | | // end namespace llvm |
1001 | | |
1002 | | #endif |