Skip to content

Commit

Permalink
Add translated and hand-fixed ARMBaseInfo.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Feb 22, 2023
1 parent cd8514b commit 5533eab
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ set(TEST_SOURCES test_basic.c test_detail.c test_skipdata.c test_iter.c)
if(CAPSTONE_ARM_SUPPORT)
add_definitions(-DCAPSTONE_HAS_ARM)
set(SOURCES_ARM
arch/ARM/ARMBaseInfo.c
arch/ARM/ARMDisassembler.c
arch/ARM/ARMDisassemblerExtension.c
arch/ARM/ARMInstPrinter.c
Expand Down
40 changes: 40 additions & 0 deletions arch/ARM/ARMBaseInfo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//===-- ARMBaseInfo.cpp - ARM Base encoding information------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file provides basic encoding and assembly information for ARM.
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <capstone/platform.h>

#include "ARMBaseInfo.h"

#define CONCAT(a, b) CONCAT_(a, b)
#define CONCAT_(a, b) a##_##b

// lookup system register using 12-bit SYSm value.
// Note: the search is uniqued using M1 mask
const MClassSysReg *lookupMClassSysRegBy12bitSYSmValue(unsigned SYSm)
{
return lookupMClassSysRegByM1Encoding12(SYSm);
}

// returns APSR with _<bits> qualifier.
// Note: ARMv7-M deprecates using MSR APSR without a _<bits> qualifier
const MClassSysReg *lookupMClassSysRegAPSRNonDeprecated(unsigned SYSm)
{
return lookupMClassSysRegByM2M3Encoding8((1 << 9) | (SYSm & 0xFF));
}

// lookup system registers using 8-bit SYSm value
const MClassSysReg *lookupMClassSysRegBy8bitSYSmValue(unsigned SYSm)
{
return lookupMClassSysRegByM2M3Encoding8((1 << 8) | (SYSm & 0xFF));
}
2 changes: 2 additions & 0 deletions suite/auto-sync/CppTranslator/Patches/Includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def get_ARM_includes(filename: str) -> bytes:
+ b'#include "../../MCInstPrinter.h"\n'
+ b'#include "../../utils.h"\n\n'
)
elif filename == "ARMBaseInfo.cpp":
return b'#include "ARMBaseInfo.h"\n\n'
elif filename == "ARMAddressingModes.h":
return b"#include <assert.h>\n" + b'#include "../../MathExtras.h"\n\n'
log.fatal(f"No includes given for ARM source file: {filename}")
Expand Down
3 changes: 3 additions & 0 deletions suite/auto-sync/CppTranslator/arch_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
},{
"in": "../vendor/llvm_root/llvm/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h",
"out": "../build/trans_out/ARMAddressingModes.h"
},{
"in": "../vendor/llvm_root/llvm/lib/Target/ARM/Utils/ARMBaseInfo.cpp",
"out": "../build/trans_out/ARMBaseInfo.cpp"
}
],
"files_for_template_search": [
Expand Down

0 comments on commit 5533eab

Please sign in to comment.