This does two things so I'll split them.
(1) Add function intern_constant() which adds a constant to the
constants array and returns the index.
The assembly for this function is beautiful. Only one load and store on
a successfull path.
Dump of assembler code for function intern_constant:
0x0000000000010ee0 <+0>: ldr w8, [x4]
0x0000000000010ee4 <+4>: cbnz w8, 0x10f08 <intern_constant+40>
0x0000000000010ee8 <+8>: ldrh w8, [x2]
0x0000000000010eec <+12>: cmp x3, x8
0x0000000000010ef0 <+16>: b.ls 0x10f10 <intern_constant+48> // b.plast
0x0000000000010ef4 <+20>: str w0, [x1, x8, lsl #2]
0x0000000000010ef8 <+24>: add w9, w8, #0x1
0x0000000000010efc <+28>: orr w0, w8, #0x10000
0x0000000000010f00 <+32>: strh w9, [x2]
0x0000000000010f04 <+36>: ret
0x0000000000010f08 <+40>: mov w0, #0x10000 // #65536
0x0000000000010f0c <+44>: ret
0x0000000000010f10 <+48>: mov w8, #0xffffff9c // #-100
0x0000000000010f14 <+52>: mov w0, #0x10000 // #65536
0x0000000000010f18 <+56>: str w8, [x4]
0x0000000000010f1c <+60>: ret
End of assembler dump.
(2) I've decided that the entire translation code will fit in
bal_engine.c so the bal_ir_immiter and bal_translator files are not
needed anymore. I moved their preprocessor definitions into bal_engine.c
Signed-off-by: Ronald Caesar <github43132@proton.me>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>