Skip to content

Commit bdde413

Browse files
committed
Add sem_dir argument to lifter cli
1 parent dead280 commit bdde413

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

tests/X86/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ function(COMPILE_X86_TESTS name address_size has_avx has_avx512)
4646

4747
add_custom_command(
4848
OUTPUT tests_${name}.bc
49-
COMMAND lift-${name}-tests --arch ${name} --bc_out tests_${name}.bc
49+
COMMAND lift-${name}-tests --arch ${name}
50+
--sem_dir ${CMAKE_BINARY_DIR}/lib/Arch/X86/Runtime
51+
--bc_out tests_${name}.bc
5052
DEPENDS semantics lift-${name}-tests ${name}
5153
)
5254

tests/X86/Lift.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <algorithm>
2727
#include <cstdint>
28+
#include <filesystem>
2829
#include <fstream>
2930
#include <map>
3031
#include <memory>
@@ -57,6 +58,9 @@ DEFINE_string(arch, REMILL_ARCH,
5758
"Architecture of the code being translated. "
5859
"Valid architectures: x86, amd64 (with or without "
5960
"`_avx` or `_avx512` appended), aarch64, aarch32");
61+
DEFINE_string(sem_dir, "",
62+
"Directory containing architecture semantics bitcode to prefer "
63+
"when lifting tests.");
6064

6165
namespace {
6266

@@ -127,7 +131,14 @@ extern "C" int main(int argc, char *argv[]) {
127131
auto os_name = remill::GetOSName(REMILL_OS);
128132
auto arch_name = remill::GetArchName(FLAGS_arch);
129133
auto arch = remill::Arch::Build(&context, os_name, arch_name);
130-
auto module = remill::LoadArchSemantics(arch.get());
134+
135+
std::unique_ptr<llvm::Module> module;
136+
if (!FLAGS_sem_dir.empty()) {
137+
module = remill::LoadArchSemantics(
138+
arch.get(), std::vector<std::filesystem::path>{FLAGS_sem_dir});
139+
} else {
140+
module = remill::LoadArchSemantics(arch.get());
141+
}
131142

132143
remill::IntrinsicTable intrinsics(module.get());
133144
remill::TraceLifter trace_lifter(arch.get(), manager);

0 commit comments

Comments
 (0)