Coverage Report

Created: 2023-12-08 06:05

/src/capstonenext/arch/AArch64/AArch64BaseInfo.c
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
//===-- AArch64BaseInfo.cpp - AArch64 Base encoding information------------===//
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 provides basic encoding and assembly information for AArch64.
24
//
25
//===----------------------------------------------------------------------===//
26
#include <capstone/platform.h>
27
#include <stdio.h>
28
#include <stdlib.h>
29
#include <string.h>
30
31
#include "AArch64BaseInfo.h"
32
33
#define CONCAT(a, b) CONCAT_(a, b)
34
#define CONCAT_(a, b) a##_##b
35
36
#define GET_AT_IMPL
37
#include "AArch64GenSystemOperands.inc"
38
#undef GET_AT_IMPL
39
40
#define GET_DBNXS_IMPL
41
#include "AArch64GenSystemOperands.inc"
42
#undef GET_DBNXS_IMPL
43
44
#define GET_DB_IMPL
45
#include "AArch64GenSystemOperands.inc"
46
#undef GET_DB_IMPL
47
48
#define GET_DC_IMPL
49
#include "AArch64GenSystemOperands.inc"
50
#undef GET_DC_IMPL
51
52
#define GET_IC_IMPL
53
#include "AArch64GenSystemOperands.inc"
54
#undef GET_IC_IMPL
55
56
#define GET_ISB_IMPL
57
#include "AArch64GenSystemOperands.inc"
58
#undef GET_ISB_IMPL
59
60
#define GET_TSB_IMPL
61
#include "AArch64GenSystemOperands.inc"
62
#undef GET_TSB_IMPL
63
64
#define GET_PRCTX_IMPL
65
#include "AArch64GenSystemOperands.inc"
66
#undef GET_PRCTX_IMPL
67
68
#define GET_PRFM_IMPL
69
#include "AArch64GenSystemOperands.inc"
70
#undef GET_PRFM_IMPL
71
72
#define GET_SVEPRFM_IMPL
73
#include "AArch64GenSystemOperands.inc"
74
#undef GET_SVEPRFM_IMPL
75
76
#define GET_RPRFM_IMPL
77
#include "AArch64GenSystemOperands.inc"
78
#undef GET_RPRFM_IMPL
79
80
// namespace AArch64RPRFM
81
// namespace llvm
82
83
#define GET_SVEPREDPAT_IMPL
84
#include "AArch64GenSystemOperands.inc"
85
#undef GET_SVEPREDPAT_IMPL
86
87
#define GET_SVEVECLENSPECIFIER_IMPL
88
#include "AArch64GenSystemOperands.inc"
89
#undef GET_SVEVECLENSPECIFIER_IMPL
90
91
// namespace AArch64SVEVecLenSpecifier
92
// namespace llvm
93
94
#define GET_EXACTFPIMM_IMPL
95
#include "AArch64GenSystemOperands.inc"
96
#undef GET_EXACTFPIMM_IMPL
97
98
#define GET_PSTATEIMM0_15_IMPL
99
#include "AArch64GenSystemOperands.inc"
100
#undef GET_PSTATEIMM0_15_IMPL
101
102
#define GET_PSTATEIMM0_1_IMPL
103
#include "AArch64GenSystemOperands.inc"
104
#undef GET_PSTATEIMM0_1_IMPL
105
106
#define GET_PSB_IMPL
107
#include "AArch64GenSystemOperands.inc"
108
#undef GET_PSB_IMPL
109
110
#define GET_BTI_IMPL
111
#include "AArch64GenSystemOperands.inc"
112
#undef GET_BTI_IMPL
113
114
#define SysReg AArch64SysReg_SysReg
115
#define GET_SYSREG_IMPL
116
#include "AArch64GenSystemOperands.inc"
117
#undef GET_SYSREG_IMPL
118
119
#undef SysReg
120
121
// return a string representing the number X
122
// NOTE: result must be big enough to contain the data
123
static void utostr(uint64_t X, bool isNeg, char *result)
124
35.9k
{
125
35.9k
  char Buffer[22];
126
35.9k
  char *BufPtr = Buffer + 21;
127
128
35.9k
  Buffer[21] = '\0';
129
35.9k
  if (X == 0) *--BufPtr = '0';  // Handle special case...
130
131
62.3k
  while (X) {
132
26.4k
    *--BufPtr = X % 10 + '0';
133
26.4k
    X /= 10;
134
26.4k
  }
135
136
35.9k
  if (isNeg) *--BufPtr = '-';   // Add negative sign...
137
138
  // suppose that result is big enough
139
35.9k
  strncpy(result, BufPtr, sizeof(Buffer));
140
35.9k
}
141
142
// NOTE: result must be big enough to contain the result
143
void AArch64SysReg_genericRegisterString(uint32_t Bits, char *result)
144
7.18k
{
145
  // assert(Bits < 0x10000);
146
7.18k
  char Op0Str[32], Op1Str[32], CRnStr[32], CRmStr[32], Op2Str[32];
147
7.18k
  int dummy;
148
7.18k
  uint32_t Op0 = (Bits >> 14) & 0x3;
149
7.18k
  uint32_t Op1 = (Bits >> 11) & 0x7;
150
7.18k
  uint32_t CRn = (Bits >> 7) & 0xf;
151
7.18k
  uint32_t CRm = (Bits >> 3) & 0xf;
152
7.18k
  uint32_t Op2 = Bits & 0x7;
153
154
7.18k
  utostr(Op0, false, Op0Str);
155
7.18k
  utostr(Op1, false, Op1Str);
156
7.18k
  utostr(Op2, false, Op2Str);
157
7.18k
  utostr(CRn, false, CRnStr);
158
7.18k
  utostr(CRm, false, CRmStr);
159
160
7.18k
  dummy = cs_snprintf(result, AARCH64_GRS_LEN, "s%s_%s_c%s_c%s_%s",
161
7.18k
      Op0Str, Op1Str, CRnStr, CRmStr, Op2Str);
162
7.18k
  (void)dummy;
163
7.18k
}
164
165
#define GET_TLBITable_IMPL
166
#include "AArch64GenSystemOperands.inc"
167
#undef GET_TLBITable_IMPL
168
169
#define GET_SVCR_IMPL
170
#include "AArch64GenSystemOperands.inc"
171
#undef GET_SVCR_IMPL