|
BFC-Compiler
A C23 Brainfuck compiler
|
Brainfuck intermediate representation interface. More...
Go to the source code of this file.
Data Structures | |
| struct | bfc_ir_instr_t |
| One IR instruction. More... | |
| struct | bfc_ir_block |
| Owning, dynamically sized sequence of IR instructions. More... | |
Typedefs | |
| typedef struct bfc_ir_block | bfc_ir_block_t |
Enumerations | |
| enum | bfc_ir_token_type_t { IR_ADD , IR_MOVE , IR_PUT , IR_GET , IR_SET , IR_LOOP } |
| Operations understood by the optimizer and code generator. | |
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-valued IR instruction. | |
| bfc_ir_instr_t | bfc_ir_make_zero_instr (bfc_ir_token_type_t const ir_token_type) |
| Constructs an IR instruction with a zero-initialized 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 from the token stream. | |
| bfc_error_t | bfc_ir_optimize_rep (bfc_ir_block_t **ir_block) |
| Optimizes repeated operations and recognized clear loops in place. | |
| void | bfc_ir_destroy (bfc_ir_block_t **proot_block) |
| Recursively destroys an IR block and all nested loop bodies. | |
Brainfuck intermediate representation interface.
Defines nested IR blocks, instructions, construction, optimization, and recursive destruction.
| 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 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. |
Builds a nested IR tree from the token stream.
| void bfc_ir_destroy | ( | bfc_ir_block_t ** | proot_block | ) |
Recursively destroys an IR block and all nested loop bodies.
Recursively releases an IR block and all owned loop bodies.
Recursively destroys an IR block and all nested loop bodies.
|
nodiscard |
Constructs an immediate-valued IR instruction.
Constructs an immediate IR instruction.
Constructs an immediate-valued IR instruction.
|
nodiscard |
Constructs an IR instruction with a zero-initialized operand union.
Constructs an instruction with a zeroed operand union.
Constructs an IR instruction with a zero-initialized operand union.
| bfc_error_t bfc_ir_optimize_rep | ( | bfc_ir_block_t ** | ir_block | ) |
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. |
Optimizes repeated operations and recognized clear loops in place.