Commit Graph

184 Commits

Author SHA1 Message Date
Ronald Caesar
6a7db3db18 engine: add operand bit extraction
Also tracks the current position in the constants array.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-23 19:19:22 -04:00
Ronald Caesar
fd080b323c decoder: static assert bitfield width
This guarantees the bitfield is 5 bits, so if someone in the future
decides to shift bits around in the struct it wont break Ballistic.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-23 18:57:09 -04:00
Ronald Caesar
24891bf97f engine: update bal_attributes.h docs formatting
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-23 18:19:58 -04:00
Ronald Caesar
d4a1d395ec engine: add arm64 and x86 environment detection
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-23 17:43:09 -04:00
Ronald Caesar
3274568415 build: release v0.4.0
Signed-off-by: Ronald Caesar <github43132@proton.me>
v0.4.0
2026-01-18 19:14:58 -04:00
Ronald Caesar
7da598c273 tests: raise max local candidates to 1024
The windows build is failing because max local candidates is too low.
This makes no sense cause the Linux and macOS builds run completely
fine. Another reason why a hate Windows.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 19:08:51 -04:00
Ronald Caesar
c4a7afa8f0 tests: remove qsort
generate_a64_table.py already sorts the buckets by priority so theres no
reason to do it again.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 18:53:58 -04:00
Ronald Caesar
c2a26d54d5 github/runners: disable tests in debug builds.
The tests take 5-8 minutes to run in debug builds, which is ridiculous.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 18:52:39 -04:00
Ronald Caesar
a997752a50 tests: optimize decoder tests
Instead of iterating 0...2^32, we iterate by hash bucket.
Also done a lot of memory bandwidth optimizations.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 18:39:42 -04:00
Ronald Caesar
98992b54c3 tests: replace fuzzer with exaustive test
Tests the entire 32-bit instruction space (4.29B).

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 05:24:17 -04:00
Ronald Caesar
3b9703f316 decoder: include operands in metadata
Stores operand bit positions and types in the decoder metadata. This
makes it way easier to emit IR instructions.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-18 02:44:40 -04:00
Ronald Caesar
2596a20f31 decoder: rewrite docs for cdoc
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-17 18:25:43 -04:00
Ronald Caesar
5e73e88145 ir: fix incorrect instruction bitfield size
An instruction is suppose to have 17-bit operands but it was actually
18-bit. So I reduce the bitfields by one bit and give the remaining bits
to opcode. An opcode is now 13 bits.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-17 04:19:24 -04:00
Ronald Caesar
a507a5d53e engine: convert array sizes to element count.
The array sizes, such as instructions_size, contains the size of the
array in bytes. This is wrong and should the max element count of the
array.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-17 03:26:47 -04:00
Ronald Caesar
3cf17ac088 tools: fix CDoc ordering of types
Fixes CDoc ordering the sidebar and main page types in alphabetical
order. Only the sidebar should be sorted and the main page should
be rendered the way its header file was parsed, top to bottom.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-17 02:06:36 -04:00
Ronald Caesar
4e41957c21 docs: Add compilation guide to readme
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-17 01:39:09 -04:00
Ronald Caesar
e17119abfa github/runner: disable address sanatizer for cdoc
CDoc leaks about 1KB memory but I really dont care. It works and I wont
touch it.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-17 01:22:53 -04:00
Ronald Caesar
b149fde285 github/runner: fix unknown argument error
Windows' clang-cl treats -fno-omit-frame-pointer as an unknown argument
and returns an error.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 23:32:35 -04:00
Ronald Caesar
6006b5e9e9 build: mark doc target as ALL_BUILD
Windows does not support the doc target, which causes the CI to fail.
Marking the doc target as ALL should fix this.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 23:23:22 -04:00
Ronald Caesar
f4fbdc43e4 github/runner: make bash treat arguments literally
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 23:17:03 -04:00
Ronald Caesar
c6130e1cc0 github/runner: use relative paths
Windows expands the build dir with back slash instead of front slash.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 23:10:56 -04:00
Ronald Caesar
0de6d5fc07 ir: fix clang-tidy warnings
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 22:56:03 -04:00
Ronald Caesar
c6602c1068 github/runner: improve build.yml
- Add Lint job to reject bad code.
- Add Address Sanatizers.
- Add Test Suite verification.
- Add Static Analysis

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 22:47:30 -04:00
Ronald Caesar
15fc9028e7 github: add cmark dependancy to runners
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 21:45:02 -04:00
Ronald Caesar
3f78168ce5 tools: create a rustdoc like documentation generator
While I do not like the Rust Language as a whole, their documentation
generator is the best I've ever seen. in any language. I want to
implement something like it for Ballistic.

Like I said in the README, I have absolutely zero motivation to create
a documentation generator so `cdoc.c` is made completely with AI. The
code is messy but the generated HTML files look beautiful.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 20:23:12 -04:00
Ronald Caesar
7f792157f5 engine: add constants array
This was tricky one to add to bal_engine_t because the struct was
already pretty packed. The struct only had 12 bytes to spare but to add
the constants array and its size required 16 bytes. I determined that
ssa_bit_widths_size was not required since ssa_bit_widths[] and
instructions[] will be parallel to each other, so one variable can keep
track of both arrays.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-15 16:25:42 -04:00
Ronald Caesar
4e4e48e495 engine: change bal_instruction_t to 32-bits
I do not know what I was thinking when I made it 64-bits.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-15 10:03:07 -04:00
Ronald Caesar
4cafd1bf67 docs: add ballistic cli section
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 23:37:59 -04:00
Ronald Caesar
f0a8ff857c engine: fix incorrect function doc
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 23:30:36 -04:00
Ronald Caesar
de8e6e5a4d tools: add ballistic cli program
This program is used to test Ballistic engine's translation logic.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 23:28:28 -04:00
Ronald Caesar
d74290e5fc engine: rename engine_run() to engine_translate()
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 23:27:52 -04:00
Ronald Caesar
00c2866fb4 memory: add flat translation interface
Defines the API for memory translation.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 22:39:06 -04:00
Ronald Caesar
3d02fab4b7 memory: add default allocator
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 19:45:44 -04:00
Ronald Caesar
37cb629909 engine: add platform detection header
I do not want compiler attributes like __clang__ or __linux__ scattered
everywhere to detect the platform Ballistic is running on, so I added
preprocessor directives to make things a lot cleaner.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 18:58:53 -04:00
Ronald Caesar
02501ae7a4 engine: add main jit compilation loop
Also remove bal_translate_block() body. It will need to be redesigned
to be used by bal_engine_run().

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 18:15:35 -04:00
Ronald Caesar
1a1ce44c87 engine: add incomplete translator loop
Everything has been setup except for the main translation loop which
have to be done another day. Its after midnight for me right now :(

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 00:06:15 -04:00
Ronald Caesar
f72da3e121 decoder: add ir opcode to metadata struct
Instead of using strcmp() on each decoded intruction's mnemonic to
translate it, we embedd an IR opcode into the struct. This is a very
barebones implementation and does not cover the entire ARM instruction
set. ARM instructions that does not have an IR opcode equivalent will be
marked with `OPCODE_TRAP` and should be implemented in the future.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 23:31:06 -04:00
Ronald Caesar
f910745a55 docs: add read only data handling to programming rules
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 21:18:50 -04:00
Ronald Caesar
99f4afb9fc docs: add handling arrays in programming rules
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 20:57:16 -04:00
Ronald Caesar
6e4c1edfda docs: add programming rules
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 20:32:41 -04:00
Ronald Caesar
0b0f4bab98 engine: add __restrict__ compiler attribute
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 18:28:39 -04:00
Ronald Caesar
f89973d49d ir: move translation context to source file
There is no need to expose this struct in the header since it be used in
this module only.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 17:34:15 -04:00
Ronald Caesar
35c88dd939 ir: add initial ir translation module
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 19:08:14 -04:00
Ronald Caesar
a15ed49f25 ir: move ir emitter header to src/
I see no reason to make this header public. This is used by Ballistic
only.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 17:30:04 -04:00
Ronald Caesar
4818664671 engine: add alignment compiler attribute
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 14:00:19 -04:00
Ronald Caesar
3ae7e33cd7 engine: add hints for cpu branch predictor
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 12:15:09 -04:00
Ronald Caesar
d54ade0c9f engine: reorganize compiler attribute docs
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 10:18:25 -04:00
Ronald Caesar
e671b6a4f1 ir: add compiler hints for cold functions
Also marked more functions as hot.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 09:19:27 -04:00
Ronald Caesar
0ca446238d ir: Add compiler hints to hot functions
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 00:13:19 -04:00
Ronald Caesar
896012c7fc ir: move bounds checking to debug builds
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-12 00:06:26 -04:00