Commit Graph

27 Commits

Author SHA1 Message Date
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
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
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
0de6d5fc07 ir: fix clang-tidy warnings
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-16 22:56:03 -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
f0a8ff857c engine: fix incorrect function doc
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-14 23:30:36 -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
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
0b0f4bab98 engine: add __restrict__ compiler attribute
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-13 18:28:39 -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
126323943b ir: add bit width parameter to emit_instructions()
At first I wondered how will we know the bitfield of the ssa variable
we're creating? Should we hardcode the bit width in the opcode and
create a large switch statement or hash table? To keep things simple
I just added a new bit width parameter to emit_instruction() and it
will be the frontend's responsibility to find the correct bitwidth.
This should better for x86 lowering.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-11 23:41:47 -04:00
Ronald Caesar
07aa3173de engine: move public headers to include folder
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-01-10 18:30:45 -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