mirror of
https://github.com/pound-emu/ballistic.git
synced 2026-01-31 01:15:21 +01:00
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>
This commit is contained in:
@@ -36,6 +36,7 @@ add_library(Ballistic STATIC
|
|||||||
src/decoder.c
|
src/decoder.c
|
||||||
src/decoder_table_gen.c
|
src/decoder_table_gen.c
|
||||||
src/bal_engine.c
|
src/bal_engine.c
|
||||||
|
src/bal_translator.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(Ballistic PUBLIC include)
|
target_include_directories(Ballistic PUBLIC include)
|
||||||
|
|||||||
@@ -1,11 +1,46 @@
|
|||||||
#include "bal_translator.h"
|
#include "bal_translator.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bal_instruction_t *BAL_RESTRICT instructions;
|
bal_instruction_t *BAL_RESTRICT instructions;
|
||||||
bal_bit_width_t *BAL_RESTRICT ssa_bit_widths;
|
bal_bit_width_t *BAL_RESTRICT ssa_bit_widths;
|
||||||
bal_source_variable_t *BAL_RESTRICT source_variables;
|
bal_source_variable_t *BAL_RESTRICT source_variables;
|
||||||
size_t instruction_count;
|
size_t instruction_count;
|
||||||
|
uint32_t max_instructions;
|
||||||
|
bal_error_t status;
|
||||||
} bal_translation_context_t;
|
} bal_translation_context_t;
|
||||||
|
|
||||||
|
bal_error_t
|
||||||
|
bal_translate_block (bal_engine_t *BAL_RESTRICT engine,
|
||||||
|
const uint32_t *BAL_RESTRICT arm_code)
|
||||||
|
{
|
||||||
|
// Copy pointers to the stack to deal with Double Indirection and Aliasing
|
||||||
|
// Fear.
|
||||||
|
//
|
||||||
|
bal_translation_context_t context;
|
||||||
|
context.instructions = engine->instructions;
|
||||||
|
context.ssa_bit_widths = engine->ssa_bit_widths;
|
||||||
|
context.source_variables = engine->source_variables;
|
||||||
|
|
||||||
|
// Copy other important data to `context` to keep register pressure low.
|
||||||
|
//
|
||||||
|
context.instruction_count = engine->instruction_count;
|
||||||
|
context.max_instructions
|
||||||
|
= engine->instructions_size / sizeof(bal_instruction_t);
|
||||||
|
context.status = BAL_SUCCESS;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < context.max_instructions; ++i)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync back to memory. We should only write to engine once in this
|
||||||
|
// function.
|
||||||
|
//
|
||||||
|
engine->instruction_count = context.instruction_count;
|
||||||
|
engine->status = context.status;
|
||||||
|
|
||||||
|
return context.status;
|
||||||
|
}
|
||||||
|
|
||||||
/*** end of file ***/
|
/*** end of file ***/
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "bal_engine.h"
|
#include "bal_engine.h"
|
||||||
#include "bal_types.h"
|
#include "bal_types.h"
|
||||||
|
#include "bal_errors.h"
|
||||||
|
|
||||||
|
|
||||||
#endif /* BAL_TRANSLATOR_H */
|
#endif /* BAL_TRANSLATOR_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user