Coverage Report

Created: 2025-07-04 06:11

/src/capstonev5/arch/AArch64/AArch64BaseInfo.c
Line
Count
Source (jump to first uncovered line)
1
//===-- AArch64BaseInfo.cpp - AArch64 Base encoding information------------===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file provides basic encoding and assembly information for AArch64.
11
//
12
//===----------------------------------------------------------------------===//
13
14
/* Capstone Disassembly Engine */
15
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
16
17
#ifdef CAPSTONE_HAS_ARM64
18
19
#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)
20
#pragma warning(disable:4996)     // disable MSVC's warning on strcpy()
21
#pragma warning(disable:28719)    // disable MSVC's warning on strcpy()
22
#endif
23
24
#include "../../utils.h"
25
26
#include <stdio.h>
27
#include <stdlib.h>
28
29
#include "AArch64BaseInfo.h"
30
31
#include "AArch64GenSystemOperands.inc"
32
33
// return a string representing the number X
34
// NOTE: result must be big enough to contain the data
35
static void utostr(uint64_t X, bool isNeg, char *result)
36
47.6k
{
37
47.6k
  char Buffer[22];
38
47.6k
  char *BufPtr = Buffer + 21;
39
40
47.6k
  Buffer[21] = '\0';
41
47.6k
  if (X == 0) *--BufPtr = '0';  // Handle special case...
42
43
87.2k
  while (X) {
44
39.6k
    *--BufPtr = X % 10 + '0';
45
39.6k
    X /= 10;
46
39.6k
  }
47
48
47.6k
  if (isNeg) *--BufPtr = '-';   // Add negative sign...
49
50
  // suppose that result is big enough
51
47.6k
  strncpy(result, BufPtr, sizeof(Buffer));
52
47.6k
}
53
54
// NOTE: result must be big enough to contain the result
55
void AArch64SysReg_genericRegisterString(uint32_t Bits, char *result)
56
9.53k
{
57
  // assert(Bits < 0x10000);
58
9.53k
  char Op0Str[32], Op1Str[32], CRnStr[32], CRmStr[32], Op2Str[32];
59
9.53k
  int dummy;
60
9.53k
  uint32_t Op0 = (Bits >> 14) & 0x3;
61
9.53k
  uint32_t Op1 = (Bits >> 11) & 0x7;
62
9.53k
  uint32_t CRn = (Bits >> 7) & 0xf;
63
9.53k
  uint32_t CRm = (Bits >> 3) & 0xf;
64
9.53k
  uint32_t Op2 = Bits & 0x7;
65
66
9.53k
  utostr(Op0, false, Op0Str);
67
9.53k
  utostr(Op1, false, Op1Str);
68
9.53k
  utostr(Op2, false, Op2Str);
69
9.53k
  utostr(CRn, false, CRnStr);
70
9.53k
  utostr(CRm, false, CRmStr);
71
72
9.53k
  dummy = cs_snprintf(result, 128, "s%s_%s_c%s_c%s_%s",
73
9.53k
      Op0Str, Op1Str, CRnStr, CRmStr, Op2Str);
74
9.53k
  (void)dummy;
75
9.53k
}
76
77
#endif