Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AArch64 update to LLVM 18 #2298

Merged
merged 78 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
7d19b18
Run clang-format
Rot127 Mar 25, 2024
e698143
Remove arm.h header from AArch64 files
Rot127 Mar 25, 2024
4070fbd
Update all AArch64 module files to LLVM-18.
Rot127 Apr 25, 2024
faf2e29
Add check if the differs save file is up-to-date with the current files.
Rot127 Apr 25, 2024
368b996
Add new generator for MC test trnaslation.
Rot127 Apr 26, 2024
d159e5f
Fix warnings
Rot127 Apr 30, 2024
fd0e6d9
Update generated AsmWriter files
Rot127 Apr 30, 2024
a11ef6a
Remove unused variable
Rot127 Apr 30, 2024
094e82a
Change MCPhysReg type to int16_t as LLVM 18 dictates.
Rot127 Apr 30, 2024
d3aba59
Assign enum values to raw_struct member
Rot127 Apr 30, 2024
fc263a9
Add printAdrAdrpLabel def
Rot127 Apr 30, 2024
c8eba0a
Add header to regression test files.
Rot127 May 10, 2024
a770254
Write files to build dir and ignore more parsing errors.
Rot127 May 10, 2024
f012a27
Fix parsing of MC test files.
Rot127 May 10, 2024
304d9e1
Reset parser after every block
Rot127 May 10, 2024
19042bc
Add write and patch header step.
Rot127 May 10, 2024
879f004
Add and update MC tests for AArch64
Rot127 May 11, 2024
6e317b4
Fix clang-tidy warnings
Rot127 May 11, 2024
d2a01cf
Don't warn about padding issues.
Rot127 May 11, 2024
012fd3e
Fix: Incorrect access of LLVM instruction descriptions.
Rot127 May 15, 2024
fd174af
Initialize DecoderComplete flag
Rot127 May 15, 2024
f8fc8dc
Add more mapping and flag details
Rot127 May 15, 2024
67420c4
Add function to get MCInstDesc from table
Rot127 May 15, 2024
505b9f6
Fix incorrect memory operand access types.
Rot127 May 15, 2024
2f9550f
Fix test where memory was not written, ut only read.
Rot127 May 15, 2024
8a6c3a8
Attempt to fix Windows build
Rot127 May 15, 2024
3773aa4
Fix 2268
Rot127 May 16, 2024
36dad9c
Refactor SME operands.
Rot127 May 20, 2024
6109632
Fix up typo in WRITE
Rot127 May 21, 2024
fbaa390
Print actual path to struct fields
Rot127 May 21, 2024
5212515
Add Registers of SME operands to the reg-read list
Rot127 May 21, 2024
16c38be
Add tests for SME operands.
Rot127 May 21, 2024
5630d12
Use Capstone reg enum for comparison
Rot127 May 21, 2024
d96c364
Fix tests: 'Vector arra...' to 'operands[x].vas'
Rot127 May 21, 2024
8497cd8
Add the developer fuzz option.
Rot127 May 21, 2024
4831460
Fix Python bindings for SME operands
Rot127 May 21, 2024
d94b752
Fix variable shadowing.
Rot127 May 21, 2024
e8f93e3
Fix clang-tidy warnings
Rot127 May 21, 2024
e9a21d3
Add missing break.
Rot127 May 21, 2024
4d25bbb
Fix varg usage
Rot127 May 21, 2024
2b2cb42
Brackets for case
Rot127 May 21, 2024
18aabf5
Handle AArch64_OP_GROUP_AdrAdrpLabel
Rot127 May 21, 2024
6f58838
Fix endian issue with fuzzing start bytes
Rot127 May 21, 2024
d598966
Move previous sme.pred to it's own operand type.
Rot127 May 22, 2024
62dd279
Fix calculation for imm ranges
Rot127 May 22, 2024
3488caa
Print list member flag
Rot127 May 22, 2024
d323420
Fix up operand strings for cstest
Rot127 May 22, 2024
28c34f1
Do only a shallow clone of the cmocka stable branch
Rot127 May 22, 2024
6dd7eae
Fix: Don't categorize ZT0 as a SME matrix operand.
Rot127 May 26, 2024
388781e
Remove unused code.
Rot127 May 26, 2024
3483664
Add flag to distinguish Vn and Qn registers.
Rot127 May 26, 2024
82592f2
Add all registers to detail struct, even if emitted in the asm text
Rot127 May 28, 2024
4c060f4
Fix: Increment op count after each list member is added.
Rot127 May 28, 2024
37e61ab
Remove implicit write to NZCV for MSR Imm instructions.
Rot127 May 28, 2024
9760361
Handle several alias operands.
Rot127 May 28, 2024
9a24704
Add details for zero alias with za0.h
Rot127 May 29, 2024
98c9130
Add SME tile to write list if written
Rot127 May 29, 2024
31c37c7
Add write access flags to operands which are zeroed.
Rot127 May 29, 2024
5393e0e
Add SME tests of #2285
Rot127 May 29, 2024
d87232f
Fix tests with latest syntax changes.
Rot127 May 29, 2024
8c54f95
Fix segfault if memory operand is only a label without register.
Rot127 May 29, 2024
7c8734d
Fix python bindings
Rot127 Jun 4, 2024
b833ce3
Attempt to fix clang-tidy warning for some configurations.
Rot127 Jun 6, 2024
b1a87a4
Add missing test file (accidentially blocked by gitignore.)
Rot127 Jun 6, 2024
c531fe3
Print clang-tidy version before linting.
Rot127 Jun 6, 2024
b93a512
Update differ save file
Rot127 Jun 6, 2024
4c9ecfd
Formatting
Rot127 Jun 6, 2024
3dda827
Use clang-tidy-15 as if possible.
Rot127 Jun 6, 2024
0ecfba8
Remove search patterns for MC tests, since they need to be reworked a…
Rot127 Jun 26, 2024
db9ed62
Enum to upper case change
Rot127 Jun 27, 2024
2740b7e
Add information to read the OSS fuzz result.
Rot127 Jun 28, 2024
80fbd8d
Fix special case of SVE2 operands.
Rot127 Jun 28, 2024
45f5eef
Handle LLVM expressions without asserts.
Rot127 Jun 28, 2024
162ce0b
Ensure choices are always saved.
Rot127 Jun 28, 2024
b50d7eb
OP_GROUP enums can't be all upper case because they contain type info…
Rot127 Jun 29, 2024
47b8eec
Fix compatibility header patching
Rot127 Jun 29, 2024
a08b66f
Update saved_choices.json
Rot127 Jul 1, 2024
369e530
Allow mode == None in test_corpus
Rot127 Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/workflows/CITest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ jobs:
clang -lcapstone src/test_arm64_compatibility_header.c -o test_arm64_compatibility_header
fi
./test_arm64_compatibility_header
cd "$(git rev-parse --show-toplevel)"

- name: cstool - reaches disassembler engine
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/auto-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ jobs:
- name: Test Header patcher
run: |
python -m unittest src/autosync/Tests/test_header_patcher.py
python -m unittest src/autosync/Tests/test_mcupdater.py

- name: Differ - Test save file is up-to-date
run: |
./src/autosync/cpptranslator/Differ.py -a AArch64 --check_saved
4 changes: 4 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
CC=clang sudo cmake --build . --config Release
cd ..

- name: Install clang-tidy-15
run: |
sudo apt install clang-tidy-15

- name: Check for warnings
env:
base_sha: ${{ github.event.pull_request.base.sha }}
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ if(CAPSTONE_BUILD_CSTEST)
PREFIX extern
GIT_REPOSITORY "https://git.cryptomilk.org/projects/cmocka.git"
GIT_TAG "origin/stable-1.1"
GIT_SHALLOW true
CONFIGURE_COMMAND cmake -DBUILD_SHARED_LIBS=OFF ../cmocka_ext/
BUILD_COMMAND cmake --build . --config Release
INSTALL_COMMAND ""
Expand Down
30 changes: 20 additions & 10 deletions MCInst.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* Capstone Disassembly Engine */
/* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */

#if defined(CAPSTONE_HAS_OSXKERNEL)
#include <Availability.h>
#include <libkern/libkern.h>
Expand All @@ -11,6 +10,7 @@
#include <string.h>
#include <assert.h>

#include "MCInstrDesc.h"
#include "MCInst.h"
#include "utils.h"

Expand Down Expand Up @@ -105,12 +105,12 @@ bool MCOperand_isValid(const MCOperand *op)

bool MCOperand_isReg(const MCOperand *op)
{
return op->Kind == kRegister;
return op->Kind == kRegister || op->MachineOperandType == kRegister;
}

bool MCOperand_isImm(const MCOperand *op)
{
return op->Kind == kImmediate;
return op->Kind == kImmediate || op->MachineOperandType == kImmediate;
}

bool MCOperand_isFPImm(const MCOperand *op)
Expand Down Expand Up @@ -224,16 +224,26 @@ bool MCInst_isPredicable(const MCInstrDesc *MIDesc)
/// Checks if tied operands exist in the instruction and sets
/// - The writeback flag in detail
/// - Saves the indices of the tied destination operands.
void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc)
{
const MCOperandInfo *OpInfo = InstDesc[MCInst_getOpcode(MI)].OpInfo;
unsigned short NumOps = InstDesc[MCInst_getOpcode(MI)].NumOperands;
void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDescTable, unsigned tbl_size)
{
const MCInstrDesc *InstDesc = NULL;
const MCOperandInfo *OpInfo = NULL;
unsigned short NumOps = 0;
if (MI->csh->arch == CS_ARCH_ARM) {
// Uses old (pre LLVM 18) indexing method.
InstDesc = &InstDescTable[MCInst_getOpcode(MI)];
OpInfo = InstDescTable[MCInst_getOpcode(MI)].OpInfo;
NumOps = InstDescTable[MCInst_getOpcode(MI)].NumOperands;
} else {
InstDesc = MCInstrDesc_get(MCInst_getOpcode(MI), InstDescTable, tbl_size);
OpInfo = MCInstrDesc_get(MCInst_getOpcode(MI), InstDescTable, tbl_size)->OpInfo;
NumOps = MCInstrDesc_get(MCInst_getOpcode(MI), InstDescTable, tbl_size)->NumOperands;
}

unsigned i;
for (i = 0; i < NumOps; ++i) {
for (unsigned i = 0; i < NumOps; ++i) {
if (MCOperandInfo_isTiedToOp(&OpInfo[i])) {
int idx = MCOperandInfo_getOperandConstraint(
&InstDesc[MCInst_getOpcode(MI)], i,
InstDesc, i,
MCOI_TIED_TO);

if (idx == -1)
Expand Down
2 changes: 1 addition & 1 deletion MCInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void MCInst_addOperand2(MCInst *inst, MCOperand *Op);

bool MCInst_isPredicable(const MCInstrDesc *MIDesc);

void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDesc);
void MCInst_handleWriteback(MCInst *MI, const MCInstrDesc *InstDescTable, unsigned tbl_size);

bool MCInst_opIsTied(const MCInst *MI, unsigned OpNum);

Expand Down
9 changes: 8 additions & 1 deletion MCInstrDesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ int MCOperandInfo_getOperandConstraint(const MCInstrDesc *InstrDesc,
return (OpInfo.Constraints >> ValuePos) & 0xf;
}
return -1;
}
}

/// Returns the instruction description for the given MCInst opcode.
/// Function should be called like:
/// MCInstrDesc_get(MCInst_getOpcode(MI), ARCHInstDesc, ARR_SIZE(ARCHInstDesc));
const MCInstrDesc *MCInstrDesc_get(unsigned opcode, const MCInstrDesc *table, unsigned tbl_size) {
return &table[tbl_size - 1 - opcode];
}
4 changes: 4 additions & 0 deletions MCInstrDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,9 @@ bool MCOperandInfo_isTiedToOp(const MCOperandInfo *m);
int MCOperandInfo_getOperandConstraint(const MCInstrDesc *OpInfo,
unsigned OpNum,
MCOI_OperandConstraint Constraint);
const MCInstrDesc *MCInstrDesc_get(unsigned opcode,
const MCInstrDesc *table,
unsigned tbl_size);


#endif
2 changes: 1 addition & 1 deletion MCRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/// An unsigned integer type large enough to represent all physical registers,
/// but not necessarily virtual registers.
typedef uint16_t MCPhysReg;
typedef int16_t MCPhysReg;
typedef const MCPhysReg* iterator;

typedef struct MCRegisterClass2 {
Expand Down
1 change: 1 addition & 0 deletions Mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct insn_map {
union {
ppc_suppl_info ppc;
loongarch_suppl_info loongarch;
aarch64_suppl_info aarch64;
} suppl_info; // Supplementary information for each instruction.
#endif
} insn_map;
Expand Down
Loading
Loading