BFC-Compiler
A C23 Brainfuck compiler
Loading...
Searching...
No Matches
bfc_codegen.h File Reference

Public assembly code-generation interface. More...

#include "bfc_error.h"
#include "bfc_ir.h"
#include "bfc_target.h"

Go to the source code of this file.

Typedefs

typedef struct bfc_asm bfc_asm_t
 Opaque generated-assembly object.

Functions

bfc_error_t bfc_codegen (bfc_asm_t **out_asm, const bfc_ir_block_t *ir_block, bfc_target_t target)
 Generates target-specific assembly from an optimized IR tree.
void bfc_asm_destroy (bfc_asm_t **asm_prog)
 Releases an assembly object and nulls the caller pointer.
bfc_error_t bfc_asm_write_file (const bfc_asm_t *asm_prog, const char *path)
 Writes generated assembly bytes to a file.

Detailed Description

Public assembly code-generation interface.

Exposes the opaque assembly object, target-aware code generation, file output, and destruction.

Function Documentation

◆ bfc_asm_destroy()

void bfc_asm_destroy ( bfc_asm_t ** pasm_prog)

Releases an assembly object and nulls the caller pointer.

Releases generated assembly state and nulls the caller pointer.

Parameters
[in,out]asm_progAddress of the owned assembly pointer.

Releases an assembly object and nulls the caller pointer.

◆ bfc_asm_write_file()

bfc_error_t bfc_asm_write_file ( const bfc_asm_t * asm_prog,
const char * path )

Writes generated assembly bytes to a file.

Writes exactly the generated assembly length to a binary-mode file.

Parameters
[in]asm_progCompleted assembly object.
[in]pathDestination file path.
Returns
BFC_ERR_OK on success; otherwise an I/O error.

Writes generated assembly bytes to a file.

◆ bfc_codegen()

bfc_error_t bfc_codegen ( bfc_asm_t ** out_asm,
const bfc_ir_block_t * ir_block,
bfc_target_t target )

Generates target-specific assembly from an optimized IR tree.

Allocates assembly state and orchestrates complete target-specific emission.

Parameters
[out]out_asmReceives the allocated assembly object on success.
[in]ir_blockRoot IR block.
[in]targetRequested code-generation target.
Returns
BFC_ERR_OK on success; otherwise a target, allocation, or emission error.
Note
Release the result with bfc_asm_destroy().

Generates target-specific assembly from an optimized IR tree.