|
BFC-Compiler
A C23 Brainfuck compiler
|
Generic IR-to-assembly code generation. More...
#include "bfc_codegen_internal.h"#include <stdarg.h>#include <stdckdint.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "bfc_config.h"#include "bfc_memory.h"Functions | |
| static const bfc_backend_t * | bfc_backend_select (bfc_target_t target) |
| Selects the immutable backend descriptor for a target. | |
| static bfc_error_t | bfc_codegen_emit_loop (bfc_asm_t *asm_prog, const bfc_ir_block_t *body) |
| Recursively lowers one loop using backend-specific branch callbacks. | |
| bfc_error_t | bfc_codegen_emit_text (bfc_asm_t *asm_prog, const char *text) |
| Appends null-terminated text while preserving the assembly-buffer invariant. | |
| bfc_error_t | bfc_codegen_emit_block (bfc_asm_t *asm_prog, const bfc_ir_block_t *ir_block) |
| Dispatches every IR operation through the active backend. | |
| bfc_error_t | bfc_codegen_emitf (bfc_asm_t *asm_prog, const char *format,...) |
| Formats one assembly fragment into a bounded temporary buffer and appends it. | |
| bfc_error_t | bfc_codegen (bfc_asm_t **out_asm, const bfc_ir_block_t *ir_block, bfc_target_t target) |
| Allocates assembly state and orchestrates complete target-specific emission. | |
| void | bfc_asm_destroy (bfc_asm_t **pasm_prog) |
| Releases generated assembly state and nulls the caller pointer. | |
| bfc_error_t | bfc_asm_write_file (const bfc_asm_t *asm_prog, const char *path) |
| Writes exactly the generated assembly length to a binary-mode file. | |
Generic IR-to-assembly code generation.
Selects backends, owns the assembly buffer, recursively lowers loops, dispatches IR instructions, and writes assembly files.
| void bfc_asm_destroy | ( | bfc_asm_t ** | asm_prog | ) |
Releases generated assembly state and nulls the caller pointer.
Releases an assembly object and nulls the caller pointer.
Releases generated assembly state and nulls the caller pointer.
| [in,out] | asm_prog | Address of the owned assembly pointer. |
| bfc_error_t bfc_asm_write_file | ( | const bfc_asm_t * | asm_prog, |
| const char * | path ) |
Writes exactly the generated assembly length to a binary-mode file.
Writes generated assembly bytes to a file.
Writes exactly the generated assembly length to a binary-mode file.
| [in] | asm_prog | Completed assembly object. |
| [in] | path | Destination file path. |
|
static |
Selects the immutable backend descriptor for a target.
| bfc_error_t bfc_codegen | ( | bfc_asm_t ** | out_asm, |
| const bfc_ir_block_t * | ir_block, | ||
| bfc_target_t | target ) |
Allocates assembly state and orchestrates complete target-specific emission.
Generates target-specific assembly from an optimized IR tree.
Allocates assembly state and orchestrates complete target-specific emission.
| [out] | out_asm | Receives the allocated assembly object on success. |
| [in] | ir_block | Root IR block. |
| [in] | target | Requested code-generation target. |
| bfc_error_t bfc_codegen_emit_block | ( | bfc_asm_t * | asm_prog, |
| const bfc_ir_block_t * | ir_block ) |
Dispatches every IR operation through the active backend.
Recursively emits every instruction in an IR block.
Dispatches every IR operation through the active backend.
|
static |
Recursively lowers one loop using backend-specific branch callbacks.
| bfc_error_t bfc_codegen_emit_text | ( | bfc_asm_t * | asm_prog, |
| const char * | text ) |
Appends null-terminated text while preserving the assembly-buffer invariant.
Appends raw text to the assembly buffer.
Appends null-terminated text while preserving the assembly-buffer invariant.
| bfc_error_t bfc_codegen_emitf | ( | bfc_asm_t * | asm_prog, |
| const char * | format, | ||
| ... ) |
Formats one assembly fragment into a bounded temporary buffer and appends it.
Formats and appends one assembly fragment.
Formats one assembly fragment into a bounded temporary buffer and appends it.