Commit Graph

36 Commits

Author SHA1 Message Date
Ronald Caesar
65ffdcb083 docs: Remove ARM64 HTML files
HTML files are not needed to build Ballistic, only the XML files.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:22:49 -04:00
Ronald Caesar
a2981ec38e decoder/tools: Add comment for struct attribute array_index
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:44 -04:00
Ronald Caesar
4aa8335612 decoder: Make decoder API public
The decoder API is now suitable to be made public. decoder.h is the sole
entry point for the decoder and it has been moved to `include/`

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:43 -04:00
Ronald Caesar
05f73eeaa8 other: Update .gitignore
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:43 -04:00
Ronald Caesar
8fbfbe0cdc tools: Add readme for tools folder
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:43 -04:00
Ronald Caesar
3ae2e5dfae decoder/tools: Add type hinting to scripts
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:42 -04:00
Ronald Caesar
f19cd7cc78 decoder/tools: Assign instruction indices seperatly
Assign indices in generate_a64_table.py at the very end, right before
generation. This is much safer than maintaining a running counter during
parsing.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:42 -04:00
Ronald Caesar
3c28b8f3e8 decoder/tools: Sort instructions in a bucket by priority
This ensures specific instructions are checked before generic ones.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:42 -04:00
Ronald Caesar
f2c923cad2 decoder: Implement hashing algorithm
Switch to hashing bits [32:21] instead of bits [27:20] and [7:4]. This
massively reduces the average amount of instructions in a bucket.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:41 -04:00
Ronald Caesar
2637ba6ed0 decoder: shrink the very bloated hash table array
512 instructions are being declared in every bucket.

Size per bucket:
512 x 8 bytes (ptr) = 4096 bytes

Total Table Size:
4096 buckets x 4096 bytes ≈ 16.7 MB

This will destroy the CPU cache performance.

To fix this we generate small seperate arrays for each bucket that
actually has content and point to them.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:41 -04:00
Ronald Caesar
1dce881f33 build: Add generate_a64_table.py to cmake
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:41 -04:00
Ronald Caesar
1cee684f0b decoder: Replace linear search with hash table
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:40 -04:00
Ronald Caesar
c24f4f6e80 tests: Add decoder fuzzer
I realized that a fuzzer made in python is way slower than a fuzzer in
C. So here you go.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:40 -04:00
Ronald Caesar
9f1a2a63ed decoder/tools: Add fuzzer script
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:40 -04:00
Ronald Caesar
d988272544 decoder/tools: Fix flawed decoder table generation logic
generate_a64_table.py only generated instruction variants. For
example, the instruction ADD has forms. The default form with bit 31
set to 0, and its variant with bit 31 set to 1. The script ignored the
default form and added the varient.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:39 -04:00
Ronald Caesar
99e91b4921 decoder/tools: Add decoder_cli program
This program takes a 32-bit hexidecimal representing an ARM instruction
and prints its corresponding mnemonic. This program will be used in
tandem with a python fuzzing script to verify the decoder table
generated by tools/generate_a64_table.py.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:39 -04:00
Ronald Caesar
c0b4f95010 build: Fix windows compiler warnings
Apperantly -Wall does exactly what it says it does on Windows and enables
every single warning. This is why the build fails on Windows and not on
Linux or MacOS.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:39 -04:00
Ronald Caesar
bd323a946e decoder/tests: Add small tests
This is just to test if the decoder even works. Ii will implement a
fuzzer to test the decoder against 10,000 randomly generated
instructions.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:38 -04:00
Ronald Caesar
2bea3a817f decoder/tools: Made python script more user-friendly
- Added default values for input/output directories
- Improve error handling for missing cli arguments

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:38 -04:00
Ronald Caesar
e0c76b5361 decoder: Implement linear search decoder
This will be replace with a hash table but I need a working
decoding implementation right now.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:38 -04:00
Ronald Caesar
7c62fb2d21 decoder: Rename arm64 global instructions array
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:37 -04:00
Ronald Caesar
c25abe080d decoder/tools: Generate arm64 instruction size constant
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:37 -04:00
Ronald Caesar
4e42c9050b decoder/tools: Generate decoder table header file
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:36 -04:00
Ronald Caesar
fe07956d6b decoder/tools: Add CLI args and more erorr handling
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:36 -04:00
Ronald Caesar
0fee614994 decoder: Implement initial A64 instruction decoder
Adds a python script, tools/generate_a64_table.py, to parse ARM's
machine readable XML. The script generates a static C lookup table
containing instruction mnemonics, masks, and values.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:36 -04:00
Ronald Caesar
26a677f8b4 decoder: Add ARM specification docs
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-12 18:11:36 -04:00
Ronald Caesar
f0d1f5219f Empty Commit 2025-12-12 18:11:17 -04:00
GloriousTacoo
18e67471a9 Update README.md
The flaws listed are not accurate. This section of the Readme will have to be rewritten once the instruction decoder is complete
2025-12-10 08:10:44 -04:00
GloriousTacoo
25c3eeb998 Update README.md 2025-12-09 14:41:52 -04:00
Ronald Caesar
c0cbeb609d build: Disable cpu feature detection option
This will not be implemented any time soon so this might mislead
developers new to the project.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 15:49:08 -04:00
Xphalnos
c033264d26 Update CMakeLists.txt 2025-12-07 20:10:17 +01:00
Ronald Caesar
5f5cfe8d6c build: remove architecture detection
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 15:03:19 -04:00
Ronald Caesar
83d784e029 decoder: add arm decoder stub
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 14:56:46 -04:00
Ronald Caesar
3933adbc2e Add .github folder
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 14:52:05 -04:00
Ronald Caesar
b18bd29f66 Add .gitignore
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-07 14:15:06 -04:00
GloriousTacoo
27968ec7ed Initial commit 2025-12-07 13:09:15 -04:00