Coverage Report

Created: 2025-07-18 06:43

/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
52.8k
#define CONCAT(a, b) CONCAT_(a, b)
40
52.8k
#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
14.7k
{
71
14.7k
  switch (ST) {
72
0
  default:
73
0
    CS_ASSERT_RET_VAL(0 && "unhandled shift type!", NULL);
74
5.95k
  case AArch64_AM_LSL:
75
5.95k
    return "lsl";
76
2.19k
  case AArch64_AM_LSR:
77
2.19k
    return "lsr";
78
1.28k
  case AArch64_AM_ASR:
79
1.28k
    return "asr";
80
1.91k
  case AArch64_AM_ROR:
81
1.91k
    return "ror";
82
679
  case AArch64_AM_MSL:
83
679
    return "msl";
84
431
  case AArch64_AM_UXTB:
85
431
    return "uxtb";
86
577
  case AArch64_AM_UXTH:
87
577
    return "uxth";
88
553
  case AArch64_AM_UXTW:
89
553
    return "uxtw";
90
375
  case AArch64_AM_UXTX:
91
375
    return "uxtx";
92
342
  case AArch64_AM_SXTB:
93
342
    return "sxtb";
94
83
  case AArch64_AM_SXTH:
95
83
    return "sxth";
96
69
  case AArch64_AM_SXTW:
97
69
    return "sxtw";
98
249
  case AArch64_AM_SXTX:
99
249
    return "sxtx";
100
14.7k
  }
101
0
  return NULL;
102
14.7k
}
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
14.7k
{
71
14.7k
  switch (ST) {
72
0
  default:
73
0
    CS_ASSERT_RET_VAL(0 && "unhandled shift type!", NULL);
74
5.95k
  case AArch64_AM_LSL:
75
5.95k
    return "lsl";
76
2.19k
  case AArch64_AM_LSR:
77
2.19k
    return "lsr";
78
1.28k
  case AArch64_AM_ASR:
79
1.28k
    return "asr";
80
1.91k
  case AArch64_AM_ROR:
81
1.91k
    return "ror";
82
679
  case AArch64_AM_MSL:
83
679
    return "msl";
84
431
  case AArch64_AM_UXTB:
85
431
    return "uxtb";
86
577
  case AArch64_AM_UXTH:
87
577
    return "uxth";
88
553
  case AArch64_AM_UXTW:
89
553
    return "uxtw";
90
375
  case AArch64_AM_UXTX:
91
375
    return "uxtx";
92
342
  case AArch64_AM_SXTB:
93
342
    return "sxtb";
94
83
  case AArch64_AM_SXTH:
95
83
    return "sxth";
96
69
  case AArch64_AM_SXTW:
97
69
    return "sxtw";
98
249
  case AArch64_AM_SXTX:
99
249
    return "sxtx";
100
14.7k
  }
101
0
  return NULL;
102
14.7k
}
103
104
/// getShiftType - Extract the shift type.
105
static inline AArch64_AM_ShiftExtendType AArch64_AM_getShiftType(unsigned Imm)
106
37.7k
{
107
37.7k
  switch ((Imm >> 6) & 0x7) {
108
0
  default:
109
0
    return AArch64_AM_InvalidShiftExtend;
110
19.5k
  case 0:
111
19.5k
    return AArch64_AM_LSL;
112
6.58k
  case 1:
113
6.58k
    return AArch64_AM_LSR;
114
3.86k
  case 2:
115
3.86k
    return AArch64_AM_ASR;
116
5.74k
  case 3:
117
5.74k
    return AArch64_AM_ROR;
118
2.03k
  case 4:
119
2.03k
    return AArch64_AM_MSL;
120
37.7k
  }
121
37.7k
}
AArch64Mapping.c:AArch64_AM_getShiftType
Line
Count
Source
106
12.8k
{
107
12.8k
  switch ((Imm >> 6) & 0x7) {
108
0
  default:
109
0
    return AArch64_AM_InvalidShiftExtend;
110
6.79k
  case 0:
111
6.79k
    return AArch64_AM_LSL;
112
2.19k
  case 1:
113
2.19k
    return AArch64_AM_LSR;
114
1.28k
  case 2:
115
1.28k
    return AArch64_AM_ASR;
116
1.91k
  case 3:
117
1.91k
    return AArch64_AM_ROR;
118
679
  case 4:
119
679
    return AArch64_AM_MSL;
120
12.8k
  }
121
12.8k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getShiftType
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getShiftType
AArch64InstPrinter.c:AArch64_AM_getShiftType
Line
Count
Source
106
24.9k
{
107
24.9k
  switch ((Imm >> 6) & 0x7) {
108
0
  default:
109
0
    return AArch64_AM_InvalidShiftExtend;
110
12.7k
  case 0:
111
12.7k
    return AArch64_AM_LSL;
112
4.39k
  case 1:
113
4.39k
    return AArch64_AM_LSR;
114
2.57k
  case 2:
115
2.57k
    return AArch64_AM_ASR;
116
3.82k
  case 3:
117
3.82k
    return AArch64_AM_ROR;
118
1.35k
  case 4:
119
1.35k
    return AArch64_AM_MSL;
120
24.9k
  }
121
24.9k
}
122
123
/// getShiftValue - Extract the shift value.
124
static inline unsigned AArch64_AM_getShiftValue(unsigned Imm)
125
46.0k
{
126
46.0k
  return Imm & 0x3f;
127
46.0k
}
AArch64Mapping.c:AArch64_AM_getShiftValue
Line
Count
Source
125
17.8k
{
126
17.8k
  return Imm & 0x3f;
127
17.8k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getShiftValue
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getShiftValue
AArch64InstPrinter.c:AArch64_AM_getShiftValue
Line
Count
Source
125
28.2k
{
126
28.2k
  return Imm & 0x3f;
127
28.2k
}
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
6.17k
{
170
6.17k
  return Imm & 0x7;
171
6.17k
}
AArch64Mapping.c:AArch64_AM_getArithShiftValue
Line
Count
Source
169
3.08k
{
170
3.08k
  return Imm & 0x7;
171
3.08k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getArithShiftValue
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getArithShiftValue
AArch64InstPrinter.c:AArch64_AM_getArithShiftValue
Line
Count
Source
169
3.08k
{
170
3.08k
  return Imm & 0x7;
171
3.08k
}
172
173
/// getExtendType - Extract the extend type for operands of arithmetic ops.
174
static inline AArch64_AM_ShiftExtendType AArch64_AM_getExtendType(unsigned Imm)
175
6.17k
{
176
6.17k
  switch (Imm) {
177
0
  default:
178
0
    CS_ASSERT_RET_VAL(0 && "Compiler bug!", 0);
179
862
  case 0:
180
862
    return AArch64_AM_UXTB;
181
1.15k
  case 1:
182
1.15k
    return AArch64_AM_UXTH;
183
1.58k
  case 2:
184
1.58k
    return AArch64_AM_UXTW;
185
1.08k
  case 3:
186
1.08k
    return AArch64_AM_UXTX;
187
684
  case 4:
188
684
    return AArch64_AM_SXTB;
189
166
  case 5:
190
166
    return AArch64_AM_SXTH;
191
138
  case 6:
192
138
    return AArch64_AM_SXTW;
193
498
  case 7:
194
498
    return AArch64_AM_SXTX;
195
6.17k
  }
196
6.17k
}
AArch64Mapping.c:AArch64_AM_getExtendType
Line
Count
Source
175
3.08k
{
176
3.08k
  switch (Imm) {
177
0
  default:
178
0
    CS_ASSERT_RET_VAL(0 && "Compiler bug!", 0);
179
431
  case 0:
180
431
    return AArch64_AM_UXTB;
181
577
  case 1:
182
577
    return AArch64_AM_UXTH;
183
794
  case 2:
184
794
    return AArch64_AM_UXTW;
185
544
  case 3:
186
544
    return AArch64_AM_UXTX;
187
342
  case 4:
188
342
    return AArch64_AM_SXTB;
189
83
  case 5:
190
83
    return AArch64_AM_SXTH;
191
69
  case 6:
192
69
    return AArch64_AM_SXTW;
193
249
  case 7:
194
249
    return AArch64_AM_SXTX;
195
3.08k
  }
196
3.08k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getExtendType
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getExtendType
AArch64InstPrinter.c:AArch64_AM_getExtendType
Line
Count
Source
175
3.08k
{
176
3.08k
  switch (Imm) {
177
0
  default:
178
0
    CS_ASSERT_RET_VAL(0 && "Compiler bug!", 0);
179
431
  case 0:
180
431
    return AArch64_AM_UXTB;
181
577
  case 1:
182
577
    return AArch64_AM_UXTH;
183
794
  case 2:
184
794
    return AArch64_AM_UXTW;
185
544
  case 3:
186
544
    return AArch64_AM_UXTX;
187
342
  case 4:
188
342
    return AArch64_AM_SXTB;
189
83
  case 5:
190
83
    return AArch64_AM_SXTH;
191
69
  case 6:
192
69
    return AArch64_AM_SXTW;
193
249
  case 7:
194
249
    return AArch64_AM_SXTX;
195
3.08k
  }
196
3.08k
}
197
198
static inline AArch64_AM_ShiftExtendType
199
AArch64_AM_getArithExtendType(unsigned Imm)
200
6.17k
{
201
6.17k
  return AArch64_AM_getExtendType((Imm >> 3) & 0x7);
202
6.17k
}
AArch64Mapping.c:AArch64_AM_getArithExtendType
Line
Count
Source
200
3.08k
{
201
3.08k
  return AArch64_AM_getExtendType((Imm >> 3) & 0x7);
202
3.08k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getArithExtendType
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getArithExtendType
AArch64InstPrinter.c:AArch64_AM_getArithExtendType
Line
Count
Source
200
3.08k
{
201
3.08k
  return AArch64_AM_getExtendType((Imm >> 3) & 0x7);
202
3.08k
}
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
651k
{
292
651k
  return ((elt & 1) << (size - 1)) | (elt >> 1);
293
651k
}
AArch64Mapping.c:AArch64_AM_ror
Line
Count
Source
291
161k
{
292
161k
  return ((elt & 1) << (size - 1)) | (elt >> 1);
293
161k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_ror
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_ror
AArch64InstPrinter.c:AArch64_AM_ror
Line
Count
Source
291
489k
{
292
489k
  return ((elt & 1) << (size - 1)) | (elt >> 1);
293
489k
}
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.64k
{
303
3.64k
  if (Imm == 0ULL || Imm == ~0ULL ||
304
3.64k
      (RegSize != 64 &&
305
3.64k
       (Imm >> RegSize != 0 || Imm == (~0ULL >> (64 - RegSize)))))
306
0
    return false;
307
308
  // First, determine the element size.
309
3.64k
  unsigned Size = RegSize;
310
311
6.74k
  do {
312
6.74k
    Size /= 2;
313
6.74k
    uint64_t Mask = (1ULL << Size) - 1;
314
315
6.74k
    if ((Imm & Mask) != ((Imm >> Size) & Mask)) {
316
3.64k
      Size *= 2;
317
3.64k
      break;
318
3.64k
    }
319
6.74k
  } 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.64k
  uint64_t Mask = ((uint64_t)-1LL) >> (64 - Size);
324
3.64k
  Imm &= Mask;
325
326
3.64k
  if (isShiftedMask_64(Imm)) {
327
2.46k
    I = CountTrailingZeros_64(Imm);
328
329
2.46k
    CTO = CountTrailingOnes_64(Imm >> I);
330
2.46k
  } else {
331
1.18k
    Imm |= ~Mask;
332
1.18k
    if (!isShiftedMask_64(~Imm))
333
0
      return false;
334
335
1.18k
    unsigned CLO = CountLeadingOnes_64(Imm);
336
1.18k
    I = 64 - CLO;
337
1.18k
    CTO = CLO + CountTrailingOnes_64(Imm) - (64 - Size);
338
1.18k
  }
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.64k
  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.64k
  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.64k
  NImms |= (CTO - 1);
353
354
  // Extract the seventh bit and toggle it to create the N field.
355
3.64k
  unsigned N = ((NImms >> 6) & 1) ^ 1;
356
357
3.64k
  *Encoding = (N << 12) | (Immr << 6) | (NImms & 0x3f);
358
3.64k
  return true;
359
3.64k
}
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.64k
{
303
3.64k
  if (Imm == 0ULL || Imm == ~0ULL ||
304
3.64k
      (RegSize != 64 &&
305
3.64k
       (Imm >> RegSize != 0 || Imm == (~0ULL >> (64 - RegSize)))))
306
0
    return false;
307
308
  // First, determine the element size.
309
3.64k
  unsigned Size = RegSize;
310
311
6.74k
  do {
312
6.74k
    Size /= 2;
313
6.74k
    uint64_t Mask = (1ULL << Size) - 1;
314
315
6.74k
    if ((Imm & Mask) != ((Imm >> Size) & Mask)) {
316
3.64k
      Size *= 2;
317
3.64k
      break;
318
3.64k
    }
319
6.74k
  } 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.64k
  uint64_t Mask = ((uint64_t)-1LL) >> (64 - Size);
324
3.64k
  Imm &= Mask;
325
326
3.64k
  if (isShiftedMask_64(Imm)) {
327
2.46k
    I = CountTrailingZeros_64(Imm);
328
329
2.46k
    CTO = CountTrailingOnes_64(Imm >> I);
330
2.46k
  } else {
331
1.18k
    Imm |= ~Mask;
332
1.18k
    if (!isShiftedMask_64(~Imm))
333
0
      return false;
334
335
1.18k
    unsigned CLO = CountLeadingOnes_64(Imm);
336
1.18k
    I = 64 - CLO;
337
1.18k
    CTO = CLO + CountTrailingOnes_64(Imm) - (64 - Size);
338
1.18k
  }
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.64k
  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.64k
  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.64k
  NImms |= (CTO - 1);
353
354
  // Extract the seventh bit and toggle it to create the N field.
355
3.64k
  unsigned N = ((NImms >> 6) & 1) ^ 1;
356
357
3.64k
  *Encoding = (N << 12) | (Immr << 6) | (NImms & 0x3f);
358
3.64k
  return true;
359
3.64k
}
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
3.64k
{
365
3.64k
  uint64_t encoding = 0;
366
3.64k
  return AArch64_AM_processLogicalImmediate(imm, regSize, &encoding);
367
3.64k
}
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
3.64k
{
365
3.64k
  uint64_t encoding = 0;
366
3.64k
  return AArch64_AM_processLogicalImmediate(imm, regSize, &encoding);
367
3.64k
}
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
68.9k
{
387
  // Extract the N, imms, and immr fields.
388
68.9k
  unsigned N = (val >> 12) & 1;
389
68.9k
  unsigned immr = (val >> 6) & 0x3f;
390
68.9k
  unsigned imms = val & 0x3f;
391
392
68.9k
  int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f));
393
68.9k
  if (len < 1) {
394
0
    CS_ASSERT(len >= 1 && "Unhandled integer type");
395
0
    return 0;
396
0
  }
397
398
68.9k
  unsigned size = (1 << len);
399
68.9k
  unsigned R = immr & (size - 1);
400
68.9k
  unsigned S = imms & (size - 1);
401
402
68.9k
  uint64_t pattern = (1ULL << (S + 1)) - 1;
403
720k
  for (unsigned i = 0; i < R; ++i)
404
651k
    pattern = AArch64_AM_ror(pattern, size);
405
406
  // Replicate the pattern to fill the regSize.
407
195k
  while (size != regSize) {
408
126k
    pattern |= (pattern << size);
409
126k
    size *= 2;
410
126k
  }
411
68.9k
  return pattern;
412
68.9k
}
AArch64Mapping.c:AArch64_AM_decodeLogicalImmediate
Line
Count
Source
386
15.8k
{
387
  // Extract the N, imms, and immr fields.
388
15.8k
  unsigned N = (val >> 12) & 1;
389
15.8k
  unsigned immr = (val >> 6) & 0x3f;
390
15.8k
  unsigned imms = val & 0x3f;
391
392
15.8k
  int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f));
393
15.8k
  if (len < 1) {
394
0
    CS_ASSERT(len >= 1 && "Unhandled integer type");
395
0
    return 0;
396
0
  }
397
398
15.8k
  unsigned size = (1 << len);
399
15.8k
  unsigned R = immr & (size - 1);
400
15.8k
  unsigned S = imms & (size - 1);
401
402
15.8k
  uint64_t pattern = (1ULL << (S + 1)) - 1;
403
177k
  for (unsigned i = 0; i < R; ++i)
404
161k
    pattern = AArch64_AM_ror(pattern, size);
405
406
  // Replicate the pattern to fill the regSize.
407
30.0k
  while (size != regSize) {
408
14.1k
    pattern |= (pattern << size);
409
14.1k
    size *= 2;
410
14.1k
  }
411
15.8k
  return pattern;
412
15.8k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeLogicalImmediate
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeLogicalImmediate
AArch64InstPrinter.c:AArch64_AM_decodeLogicalImmediate
Line
Count
Source
386
53.0k
{
387
  // Extract the N, imms, and immr fields.
388
53.0k
  unsigned N = (val >> 12) & 1;
389
53.0k
  unsigned immr = (val >> 6) & 0x3f;
390
53.0k
  unsigned imms = val & 0x3f;
391
392
53.0k
  int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f));
393
53.0k
  if (len < 1) {
394
0
    CS_ASSERT(len >= 1 && "Unhandled integer type");
395
0
    return 0;
396
0
  }
397
398
53.0k
  unsigned size = (1 << len);
399
53.0k
  unsigned R = immr & (size - 1);
400
53.0k
  unsigned S = imms & (size - 1);
401
402
53.0k
  uint64_t pattern = (1ULL << (S + 1)) - 1;
403
543k
  for (unsigned i = 0; i < R; ++i)
404
489k
    pattern = AArch64_AM_ror(pattern, size);
405
406
  // Replicate the pattern to fill the regSize.
407
165k
  while (size != regSize) {
408
112k
    pattern |= (pattern << size);
409
112k
    size *= 2;
410
112k
  }
411
53.0k
  return pattern;
412
53.0k
}
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
17.1k
{
420
  // Extract the N and imms fields needed for checking.
421
17.1k
  unsigned N = (val >> 12) & 1;
422
17.1k
  unsigned imms = val & 0x3f;
423
424
17.1k
  if (regSize == 32 && N != 0) // undefined logical immediate encoding
425
0
    return false;
426
17.1k
  int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f));
427
17.1k
  if (len < 0)         // undefined logical immediate encoding
428
4
    return false;
429
17.1k
  unsigned size = (1 << len);
430
17.1k
  unsigned S = imms & (size - 1);
431
17.1k
  if (S == size - 1) // undefined logical immediate encoding
432
3
    return false;
433
434
17.1k
  return true;
435
17.1k
}
Unexecuted instantiation: AArch64Mapping.c:AArch64_AM_isValidDecodeLogicalImmediate
AArch64Disassembler.c:AArch64_AM_isValidDecodeLogicalImmediate
Line
Count
Source
419
17.1k
{
420
  // Extract the N and imms fields needed for checking.
421
17.1k
  unsigned N = (val >> 12) & 1;
422
17.1k
  unsigned imms = val & 0x3f;
423
424
17.1k
  if (regSize == 32 && N != 0) // undefined logical immediate encoding
425
0
    return false;
426
17.1k
  int len = 31 - countLeadingZeros((N << 6) | (~imms & 0x3f));
427
17.1k
  if (len < 0)         // undefined logical immediate encoding
428
4
    return false;
429
17.1k
  unsigned size = (1 << len);
430
17.1k
  unsigned S = imms & (size - 1);
431
17.1k
  if (S == size - 1) // undefined logical immediate encoding
432
3
    return false;
433
434
17.1k
  return true;
435
17.1k
}
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
412
{
442
  // We expect an 8-bit binary encoding of a floating-point number here.
443
444
412
  uint32_t Sign = (Imm >> 7) & 0x1;
445
412
  uint32_t Exp = (Imm >> 4) & 0x7;
446
412
  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
412
  uint32_t I = 0;
454
412
  I |= Sign << 31;
455
412
  I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
456
412
  I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
457
412
  I |= (Exp & 0x3) << 23;
458
412
  I |= Mantissa << 19;
459
412
  return BitsToFloat(I);
460
412
}
AArch64Mapping.c:AArch64_AM_getFPImmFloat
Line
Count
Source
441
206
{
442
  // We expect an 8-bit binary encoding of a floating-point number here.
443
444
206
  uint32_t Sign = (Imm >> 7) & 0x1;
445
206
  uint32_t Exp = (Imm >> 4) & 0x7;
446
206
  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
206
  uint32_t I = 0;
454
206
  I |= Sign << 31;
455
206
  I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
456
206
  I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
457
206
  I |= (Exp & 0x3) << 23;
458
206
  I |= Mantissa << 19;
459
206
  return BitsToFloat(I);
460
206
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_getFPImmFloat
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_getFPImmFloat
AArch64InstPrinter.c:AArch64_AM_getFPImmFloat
Line
Count
Source
441
206
{
442
  // We expect an 8-bit binary encoding of a floating-point number here.
443
444
206
  uint32_t Sign = (Imm >> 7) & 0x1;
445
206
  uint32_t Exp = (Imm >> 4) & 0x7;
446
206
  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
206
  uint32_t I = 0;
454
206
  I |= Sign << 31;
455
206
  I |= ((Exp & 0x4) != 0 ? 0 : 1) << 30;
456
206
  I |= ((Exp & 0x4) != 0 ? 0x1f : 0) << 25;
457
206
  I |= (Exp & 0x3) << 23;
458
206
  I |= Mantissa << 19;
459
206
  return BitsToFloat(I);
460
206
}
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
3.11k
{
713
3.11k
  uint64_t EncVal = 0;
714
3.11k
  if (Imm & 0x80)
715
958
    EncVal |= 0xff00000000000000ULL;
716
3.11k
  if (Imm & 0x40)
717
226
    EncVal |= 0x00ff000000000000ULL;
718
3.11k
  if (Imm & 0x20)
719
416
    EncVal |= 0x0000ff0000000000ULL;
720
3.11k
  if (Imm & 0x10)
721
1.92k
    EncVal |= 0x000000ff00000000ULL;
722
3.11k
  if (Imm & 0x08)
723
1.70k
    EncVal |= 0x00000000ff000000ULL;
724
3.11k
  if (Imm & 0x04)
725
478
    EncVal |= 0x0000000000ff0000ULL;
726
3.11k
  if (Imm & 0x02)
727
2.32k
    EncVal |= 0x000000000000ff00ULL;
728
3.11k
  if (Imm & 0x01)
729
1.69k
    EncVal |= 0x00000000000000ffULL;
730
3.11k
  return EncVal;
731
3.11k
}
AArch64Mapping.c:AArch64_AM_decodeAdvSIMDModImmType10
Line
Count
Source
712
1.55k
{
713
1.55k
  uint64_t EncVal = 0;
714
1.55k
  if (Imm & 0x80)
715
479
    EncVal |= 0xff00000000000000ULL;
716
1.55k
  if (Imm & 0x40)
717
113
    EncVal |= 0x00ff000000000000ULL;
718
1.55k
  if (Imm & 0x20)
719
208
    EncVal |= 0x0000ff0000000000ULL;
720
1.55k
  if (Imm & 0x10)
721
964
    EncVal |= 0x000000ff00000000ULL;
722
1.55k
  if (Imm & 0x08)
723
850
    EncVal |= 0x00000000ff000000ULL;
724
1.55k
  if (Imm & 0x04)
725
239
    EncVal |= 0x0000000000ff0000ULL;
726
1.55k
  if (Imm & 0x02)
727
1.16k
    EncVal |= 0x000000000000ff00ULL;
728
1.55k
  if (Imm & 0x01)
729
846
    EncVal |= 0x00000000000000ffULL;
730
1.55k
  return EncVal;
731
1.55k
}
Unexecuted instantiation: AArch64Disassembler.c:AArch64_AM_decodeAdvSIMDModImmType10
Unexecuted instantiation: AArch64DisassemblerExtension.c:AArch64_AM_decodeAdvSIMDModImmType10
AArch64InstPrinter.c:AArch64_AM_decodeAdvSIMDModImmType10
Line
Count
Source
712
1.55k
{
713
1.55k
  uint64_t EncVal = 0;
714
1.55k
  if (Imm & 0x80)
715
479
    EncVal |= 0xff00000000000000ULL;
716
1.55k
  if (Imm & 0x40)
717
113
    EncVal |= 0x00ff000000000000ULL;
718
1.55k
  if (Imm & 0x20)
719
208
    EncVal |= 0x0000ff0000000000ULL;
720
1.55k
  if (Imm & 0x10)
721
964
    EncVal |= 0x000000ff00000000ULL;
722
1.55k
  if (Imm & 0x08)
723
850
    EncVal |= 0x00000000ff000000ULL;
724
1.55k
  if (Imm & 0x04)
725
239
    EncVal |= 0x0000000000ff0000ULL;
726
1.55k
  if (Imm & 0x02)
727
1.16k
    EncVal |= 0x000000000000ff00ULL;
728
1.55k
  if (Imm & 0x01)
729
846
    EncVal |= 0x00000000000000ffULL;
730
1.55k
  return EncVal;
731
1.55k
}
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
87.0k
  { \
861
87.0k
    union { \
862
87.0k
      int64_t In; \
863
87.0k
      T Out[sizeof(int64_t) / sizeof(T)]; \
864
87.0k
    } U_Parts; \
865
87.0k
    U_Parts.In = Imm; \
866
87.0k
    T *Parts = U_Parts.Out; \
867
383k
    for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \
868
313k
      if (Parts[i] != Parts[0]) \
869
313k
        return false; \
870
313k
    } \
871
87.0k
    return true; \
872
87.0k
  }
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
22.6k
  { \
861
22.6k
    union { \
862
22.6k
      int64_t In; \
863
22.6k
      T Out[sizeof(int64_t) / sizeof(T)]; \
864
22.6k
    } U_Parts; \
865
22.6k
    U_Parts.In = Imm; \
866
22.6k
    T *Parts = U_Parts.Out; \
867
163k
    for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \
868
146k
      if (Parts[i] != Parts[0]) \
869
146k
        return false; \
870
146k
    } \
871
22.6k
    return true; \
872
22.6k
  }
AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int16_t
Line
Count
Source
860
29.7k
  { \
861
29.7k
    union { \
862
29.7k
      int64_t In; \
863
29.7k
      T Out[sizeof(int64_t) / sizeof(T)]; \
864
29.7k
    } U_Parts; \
865
29.7k
    U_Parts.In = Imm; \
866
29.7k
    T *Parts = U_Parts.Out; \
867
125k
    for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \
868
103k
      if (Parts[i] != Parts[0]) \
869
103k
        return false; \
870
103k
    } \
871
29.7k
    return true; \
872
29.7k
  }
AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int32_t
Line
Count
Source
860
28.4k
  { \
861
28.4k
    union { \
862
28.4k
      int64_t In; \
863
28.4k
      T Out[sizeof(int64_t) / sizeof(T)]; \
864
28.4k
    } U_Parts; \
865
28.4k
    U_Parts.In = Imm; \
866
28.4k
    T *Parts = U_Parts.Out; \
867
82.7k
    for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \
868
56.9k
      if (Parts[i] != Parts[0]) \
869
56.9k
        return false; \
870
56.9k
    } \
871
28.4k
    return true; \
872
28.4k
  }
AArch64InstPrinter.c:AArch64_AM_isSVEMaskOfIdenticalElements_int64_t
Line
Count
Source
860
6.21k
  { \
861
6.21k
    union { \
862
6.21k
      int64_t In; \
863
6.21k
      T Out[sizeof(int64_t) / sizeof(T)]; \
864
6.21k
    } U_Parts; \
865
6.21k
    U_Parts.In = Imm; \
866
6.21k
    T *Parts = U_Parts.Out; \
867
12.4k
    for (int i = 0; i < (sizeof(int64_t) / sizeof(T)); i++) { \
868
6.21k
      if (Parts[i] != Parts[0]) \
869
6.21k
        return false; \
870
6.21k
    } \
871
6.21k
    return true; \
872
6.21k
  }
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
12.2k
{
880
12.2k
  bool IsImm8 = (int8_t)Imm == Imm;
881
882
12.2k
  return IsImm8 || (uint8_t)Imm == Imm;
883
12.2k
}
Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm8
Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm8
Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm8
AArch64InstPrinter.c:isSVECpyImm8
Line
Count
Source
879
12.2k
{
880
12.2k
  bool IsImm8 = (int8_t)Imm == Imm;
881
882
12.2k
  return IsImm8 || (uint8_t)Imm == Imm;
883
12.2k
}
884
885
static inline bool isSVECpyImm16(int64_t Imm)
886
15.3k
{
887
15.3k
  bool IsImm8 = (int8_t)Imm == Imm;
888
15.3k
  bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
889
890
15.3k
  return IsImm8 || IsImm16 || (uint16_t)(Imm & ~0xff) == Imm;
891
15.3k
}
Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm16
Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm16
Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm16
AArch64InstPrinter.c:isSVECpyImm16
Line
Count
Source
886
15.3k
{
887
15.3k
  bool IsImm8 = (int8_t)Imm == Imm;
888
15.3k
  bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
889
890
15.3k
  return IsImm8 || IsImm16 || (uint16_t)(Imm & ~0xff) == Imm;
891
15.3k
}
892
893
static inline bool isSVECpyImm32(int64_t Imm)
894
17.4k
{
895
17.4k
  bool IsImm8 = (int8_t)Imm == Imm;
896
17.4k
  bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
897
898
17.4k
  return IsImm8 || IsImm16;
899
17.4k
}
Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm32
Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm32
Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm32
AArch64InstPrinter.c:isSVECpyImm32
Line
Count
Source
894
17.4k
{
895
17.4k
  bool IsImm8 = (int8_t)Imm == Imm;
896
17.4k
  bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
897
898
17.4k
  return IsImm8 || IsImm16;
899
17.4k
}
900
901
static inline bool isSVECpyImm64(int64_t Imm)
902
18.6k
{
903
18.6k
  bool IsImm8 = (int8_t)Imm == Imm;
904
18.6k
  bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
905
906
18.6k
  return IsImm8 || IsImm16;
907
18.6k
}
Unexecuted instantiation: AArch64Mapping.c:isSVECpyImm64
Unexecuted instantiation: AArch64Disassembler.c:isSVECpyImm64
Unexecuted instantiation: AArch64DisassemblerExtension.c:isSVECpyImm64
AArch64InstPrinter.c:isSVECpyImm64
Line
Count
Source
902
18.6k
{
903
18.6k
  bool IsImm8 = (int8_t)Imm == Imm;
904
18.6k
  bool IsImm16 = (int16_t)(Imm & ~0xff) == Imm;
905
906
18.6k
  return IsImm8 || IsImm16;
907
18.6k
}
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
18.6k
{
913
18.6k
  if (isSVECpyImm64(Imm))
914
21
    return false;
915
916
18.6k
  union {
917
18.6k
    int64_t In;
918
18.6k
    int32_t Out[2];
919
18.6k
  } U_S;
920
18.6k
  U_S.In = Imm;
921
18.6k
  int32_t *S = U_S.Out;
922
18.6k
  union {
923
18.6k
    int64_t In;
924
18.6k
    int16_t Out[4];
925
18.6k
  } U_H;
926
18.6k
  U_H.In = Imm;
927
18.6k
  int16_t *H = U_H.Out;
928
18.6k
  union {
929
18.6k
    int64_t In;
930
18.6k
    int8_t Out[8];
931
18.6k
  } U_B;
932
18.6k
  U_B.In = Imm;
933
18.6k
  int8_t *B = U_B.Out;
934
935
18.6k
  if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int32_t)(Imm) &&
936
18.6k
      isSVECpyImm32(S[0]))
937
282
    return false;
938
18.3k
  if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int16_t)(Imm) &&
939
18.3k
      isSVECpyImm16(H[0]))
940
2.45k
    return false;
941
15.9k
  if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int8_t)(Imm) &&
942
15.9k
      isSVECpyImm8(B[0]))
943
12.2k
    return false;
944
3.64k
  return AArch64_AM_isLogicalImmediate(Imm, 64);
945
15.9k
}
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
18.6k
{
913
18.6k
  if (isSVECpyImm64(Imm))
914
21
    return false;
915
916
18.6k
  union {
917
18.6k
    int64_t In;
918
18.6k
    int32_t Out[2];
919
18.6k
  } U_S;
920
18.6k
  U_S.In = Imm;
921
18.6k
  int32_t *S = U_S.Out;
922
18.6k
  union {
923
18.6k
    int64_t In;
924
18.6k
    int16_t Out[4];
925
18.6k
  } U_H;
926
18.6k
  U_H.In = Imm;
927
18.6k
  int16_t *H = U_H.Out;
928
18.6k
  union {
929
18.6k
    int64_t In;
930
18.6k
    int8_t Out[8];
931
18.6k
  } U_B;
932
18.6k
  U_B.In = Imm;
933
18.6k
  int8_t *B = U_B.Out;
934
935
18.6k
  if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int32_t)(Imm) &&
936
18.6k
      isSVECpyImm32(S[0]))
937
282
    return false;
938
18.3k
  if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int16_t)(Imm) &&
939
18.3k
      isSVECpyImm16(H[0]))
940
2.45k
    return false;
941
15.9k
  if (CONCAT(AArch64_AM_isSVEMaskOfIdenticalElements, int8_t)(Imm) &&
942
15.9k
      isSVECpyImm8(B[0]))
943
12.2k
    return false;
944
3.64k
  return AArch64_AM_isLogicalImmediate(Imm, 64);
945
15.9k
}
946
947
inline static bool AArch64_AM_isAnyMOVZMovAlias(uint64_t Value, int RegWidth)
948
6.16k
{
949
25.0k
  for (int Shift = 0; Shift <= RegWidth - 16; Shift += 16)
950
20.7k
    if ((Value & ~(0xffffULL << Shift)) == 0)
951
1.81k
      return true;
952
953
4.34k
  return false;
954
6.16k
}
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
6.16k
{
949
25.0k
  for (int Shift = 0; Shift <= RegWidth - 16; Shift += 16)
950
20.7k
    if ((Value & ~(0xffffULL << Shift)) == 0)
951
1.81k
      return true;
952
953
4.34k
  return false;
954
6.16k
}
955
956
inline static bool AArch64_AM_isMOVZMovAlias(uint64_t Value, int Shift,
957
               int RegWidth)
958
2.30k
{
959
2.30k
  if (RegWidth == 32)
960
736
    Value &= 0xffffffffULL;
961
962
  // "lsl #0" takes precedence: in practice this only affects "#0, lsl #0".
963
2.30k
  if (Value == 0 && Shift != 0)
964
82
    return false;
965
966
2.21k
  return (Value & ~(0xffffULL << Shift)) == 0;
967
2.30k
}
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
2.30k
{
959
2.30k
  if (RegWidth == 32)
960
736
    Value &= 0xffffffffULL;
961
962
  // "lsl #0" takes precedence: in practice this only affects "#0, lsl #0".
963
2.30k
  if (Value == 0 && Shift != 0)
964
82
    return false;
965
966
2.21k
  return (Value & ~(0xffffULL << Shift)) == 0;
967
2.30k
}
968
969
inline static bool AArch64_AM_isMOVNMovAlias(uint64_t Value, int Shift,
970
               int RegWidth)
971
895
{
972
  // MOVZ takes precedence over MOVN.
973
895
  if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth))
974
107
    return false;
975
976
788
  Value = ~Value;
977
788
  if (RegWidth == 32)
978
92
    Value &= 0xffffffffULL;
979
980
788
  return AArch64_AM_isMOVZMovAlias(Value, Shift, RegWidth);
981
895
}
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
895
{
972
  // MOVZ takes precedence over MOVN.
973
895
  if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth))
974
107
    return false;
975
976
788
  Value = ~Value;
977
788
  if (RegWidth == 32)
978
92
    Value &= 0xffffffffULL;
979
980
788
  return AArch64_AM_isMOVZMovAlias(Value, Shift, RegWidth);
981
895
}
982
983
inline static bool AArch64_AM_isAnyMOVWMovAlias(uint64_t Value, int RegWidth)
984
3.04k
{
985
3.04k
  if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth))
986
827
    return true;
987
988
  // It's not a MOVZ, but it might be a MOVN.
989
2.22k
  Value = ~Value;
990
2.22k
  if (RegWidth == 32)
991
373
    Value &= 0xffffffffULL;
992
993
2.22k
  return AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth);
994
3.04k
}
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
3.04k
{
985
3.04k
  if (AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth))
986
827
    return true;
987
988
  // It's not a MOVZ, but it might be a MOVN.
989
2.22k
  Value = ~Value;
990
2.22k
  if (RegWidth == 32)
991
373
    Value &= 0xffffffffULL;
992
993
2.22k
  return AArch64_AM_isAnyMOVZMovAlias(Value, RegWidth);
994
3.04k
}
995
996
// CS namespace end: AArch64_AM
997
998
// end namespace AArch64_AM
999
1000
// end namespace llvm
1001
1002
#endif