|
BFC-Compiler
A C23 Brainfuck compiler
|
IR construction, optimization, and destruction. More...
#include "bfc_ir.h"#include <stdckdint.h>#include <stddef.h>#include <stdint.h>#include <stdlib.h>#include "bfc_config.h"#include "bfc_error.h"#include "bfc_memory.h"Data Structures | |
| struct | bfc_ir_stack_t |
| Construction-only stack of currently active nested IR blocks. More... | |
Functions | |
| bfc_ir_instr_t | bfc_ir_make_imm_instr (bfc_ir_token_type_t const ir_token_type, int64_t const imm) |
| Constructs an immediate IR instruction. | |
| bfc_ir_instr_t | bfc_ir_make_zero_instr (bfc_ir_token_type_t const ir_token_type) |
| Constructs an instruction with a zeroed operand union. | |
| bfc_error_t | bfc_ir_create (bfc_ir_block_t **root_block, bfc_token_stream_t const *const tok_stream) |
| Builds a nested IR tree using an explicit stack of active loop blocks. | |
| bfc_error_t | bfc_ir_optimize_rep (bfc_ir_block_t **ir_block) |
| Combines adjacent arithmetic/movement instructions and converts clear loops to IR_SET 0. | |
| void | bfc_ir_destroy (bfc_ir_block_t **proot_block) |
| Recursively releases an IR block and all owned loop bodies. | |
IR construction, optimization, and destruction.
Builds nested blocks, grows typed arrays safely, folds repeated operations, recognizes clear loops, and manages recursive ownership.
| bfc_error_t bfc_ir_create | ( | bfc_ir_block_t ** | root_block, |
| bfc_token_stream_t const *const | tok_stream ) |
Builds a nested IR tree using an explicit stack of active loop blocks.
Builds a nested IR tree from the token stream.
Builds a nested IR tree using an explicit stack of active loop blocks.
| [out] | root_block | Receives the allocated root block. |
| [in] | tok_stream | Validated token stream. |
| void bfc_ir_destroy | ( | bfc_ir_block_t ** | proot_block | ) |
Recursively releases an IR block and all owned loop bodies.
Recursively destroys an IR block and all nested loop bodies.
Recursively releases an IR block and all owned loop bodies.
|
nodiscard |
Constructs an immediate IR instruction.
Constructs an immediate-valued IR instruction.
Constructs an immediate IR instruction.
|
nodiscard |
Constructs an instruction with a zeroed operand union.
Constructs an IR instruction with a zero-initialized operand union.
Constructs an instruction with a zeroed operand union.
| bfc_error_t bfc_ir_optimize_rep | ( | bfc_ir_block_t ** | ir_block | ) |
Combines adjacent arithmetic/movement instructions and converts clear loops to IR_SET 0.
Optimizes repeated operations and recognized clear loops in place.
Combines adjacent arithmetic/movement instructions and converts clear loops to IR_SET 0.
| [in,out] | ir_block | Address of the owned IR block pointer. |