Skip to content

Commit d1e3919

Browse files
committed
jit/decoder: Add generated arm32 tests
Introduces the first unit tests for the ARM32 JIT decoder. A new script automatically generates a test case for every instruction in arm32.inc, providing 100% of the isa. This also includes a critical rework of the decoder's lookup table generation logic. The previous hashing method was flawed, causing build-time overflows and incorrect instruction matching (shadowing) for patterns with wildcards. The new algorithm correctly populates the lookup table. Signed-off-by: Ronald Caesar <github43132@proton.me>
1 parent c235e57 commit d1e3919

File tree

13 files changed

+37513
-502
lines changed

13 files changed

+37513
-502
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,16 @@ jobs:
114114

115115
- name: Install Dependencies
116116
run: |
117-
brew install llvm
117+
brew install llvm@20
118+
echo "CMAKE_PREFIX_PATH=/usr/local/opt/llvm@20" >> $GITHUB_ENV
118119
119120
- name: Configure CMake (x86_64)
120121
run: >
121122
cmake -G Ninja -B "${{env.BUILD_DIR}}"
122123
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
123124
-DCMAKE_OSX_ARCHITECTURES=x86_64
124-
-DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang
125-
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm)/bin/clang++
125+
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@20/bin/clang
126+
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@20/bin/clang++
126127
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
127128
128129
- name: Build (x86_64)
@@ -156,14 +157,15 @@ jobs:
156157

157158
- name: Install Dependencies
158159
run: |
159-
brew install llvm
160+
brew install llvm@20
161+
echo "CMAKE_PREFIX_PATH=/opt/homebrew/opt/llvm@20" >> $GITHUB_ENV
160162
161163
- name: Configure CMake (ARM64)
162164
run: >
163165
cmake -G Ninja -B "${{env.BUILD_DIR}}"
164166
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
165-
-DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang
166-
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm)/bin/clang++
167+
-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm@20/bin/clang
168+
-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@20/bin/clang++
167169
-DCMAKE_OSX_ARCHITECTURES=arm64
168170
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15
169171

CMakeLists.txt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ endif()
1313
set(CMAKE_C_STANDARD 11)
1414
set(CMAKE_C_STANDARD_REQUIRED TRUE)
1515
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
16+
set(CMAKE_CXX_STANDARD 17)
17+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1618
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1719

1820
#-------------------------------
@@ -91,17 +93,29 @@ message(STATUS "All submodules verified successfully")
9193
#-----------------------------
9294
# ---- Target Definitions ----
9395
#-----------------------------
94-
9596
add_executable(Pound
9697
src/main.c
9798
)
9899

99-
set(TEST_SRC
100-
${CMAKE_CURRENT_SOURCE_DIR}/tests/jit/ir/test_value.cpp
101-
${CMAKE_CURRENT_SOURCE_DIR}/tests/jit/decoder/test_arm32.cpp
100+
find_package(Python3 REQUIRED)
101+
102+
# Define the test generation command
103+
set(GEN_TEST_SRC ${CMAKE_CURRENT_SOURCE_DIR}/tests/jit/decoder/test_arm32_generated.cpp)
104+
105+
add_custom_command(
106+
OUTPUT ${GEN_TEST_SRC}
107+
COMMAND Python3::Interpreter ${CMAKE_SOURCE_DIR}/scripts/generate_decoder_tests.py
108+
${CMAKE_SOURCE_DIR}/src/jit/frontend/decoder/arm32.inc
109+
${GEN_TEST_SRC}
110+
DEPENDS ${CMAKE_SOURCE_DIR}/scripts/generate_decoder_tests.py
111+
${CMAKE_SOURCE_DIR}/src/jit/frontend/decoder/arm32.inc
112+
COMMENT "Generating ARM32 Decoder Tests"
102113
)
103114

104-
#add_executable(tests ${TEST_SRC})
115+
# Add to test executable
116+
add_executable(tests
117+
${GEN_TEST_SRC}
118+
)
105119

106120
add_subdirectory(3rd_Party)
107121
add_subdirectory(src/common)
@@ -161,8 +175,8 @@ target_link_libraries(Pound PRIVATE
161175
)
162176

163177

164-
#target_link_libraries(tests PRIVATE
165-
# jit
166-
# gtest
167-
# gtest_main
168-
#)
178+
target_link_libraries(tests PRIVATE
179+
jit
180+
gtest
181+
gtest_main
182+
)

0 commit comments

Comments
 (0)