mirror of
https://github.com/pound-emu/ballistic.git
synced 2026-01-31 01:15:21 +01:00
docs: Rework variable design implementation
When I was designing the instruction struct, I needed to figure out how an instruction knows which argument position is a variable and a constant. So the variable type is baked into the struct. I also added a variable array for obvious reasons. Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit is contained in:
@@ -6,7 +6,22 @@ All memory will be allocated from a contiguous memory arena before the pass begi
|
||||
// Ref: Chapter 3.1.3
|
||||
typedef struct
|
||||
{
|
||||
instruction_t* defining_instruction;
|
||||
type_t type; // TYPE_INT, TYPE_FLOAT
|
||||
|
||||
// 1: x = 4 Defines x so reachingDef = 1 (x₁)
|
||||
// 2: y = x + 1 Only uses x so reachingDef is still 1.
|
||||
// 3: x = 5 Redefines x so reachingDef = 2 (x₂).
|
||||
int reaching_definition;
|
||||
} variable_t;
|
||||
} original_variable_t;
|
||||
|
||||
// This array maps the source code definition to its SSA version.
|
||||
// IT is the frontend's job to populate this array.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// Instruction 100: x = y + z
|
||||
//
|
||||
// If `x` is at index 5, original_variables[5].reachingDef = 100.
|
||||
// `x` maps to instruction 100.
|
||||
original_variable_t original_variables[???];
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user