jit/decoder: Overhaul arm32 decoder

Rewrites the Arm32 instruction decoder to align with high integrity
software standards such as MISRA C and BARR-C.

Key Architectural  Changes:

- Added compile time validation.
- Removed dependency on memory allocator. The decoder now uses
   statically allocated global storage.
- Implement a hash-based lookup table to reduce decoding complexity to
   O(1).
- Removed decoder_t in favour of a singleton pattern.
- Add documentation stating thread safety, preconditions, and
   postconditions for all public functions.

Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit is contained in:
Ronald Caesar 2025-11-28 19:03:04 -04:00
parent 04b5af2517
commit 27710ca8c9
No known key found for this signature in database
GPG key ID: 04307C401999C596
3 changed files with 240 additions and 129 deletions

View file

@ -3,23 +3,16 @@
#define LOG_MODULE "main"
#include "common/logging.h"
#include "common/passert.h"
#include "host/memory/arena.h"
#include "jit/decoder/arm32.h"
#include "jit/ir/opcode.h"
#include "jit/a32_types.h"
int main()
{
pound::host::memory::arena_t arena = pound::host::memory::arena_init(8192);
pound::jit::decoder::arm32_decoder_t decoder = {};
pound::jit::decoder::arm32_init(arena, &decoder);
pound::jit::decoder::arm32_init();
/* Add r0, r0, #1 */
pound::jit::decoder::arm32_decode(&decoder, 0xE2800001);
pound::jit::decoder::arm32_decode(0xE2800001);
/* Sub r0, r0, #1 */
pound::jit::decoder::arm32_decode(&decoder, 0xE2400001);
pound::jit::ir::opcode_init();
pound::host::memory::arena_free(&arena);
pound::jit::decoder::arm32_decode(0xE2400001);
//pound::jit::ir::opcode_init();
#if 0
gui::window_t window = {.data = nullptr, .gl_context = nullptr};