2.5.3 Blocks

C Type: gcc_jit_block

A gcc_jit_block represents a basic block within a function i.e. a sequence of statements with a single entry point and a single exit point.

The first basic block that you create within a function will be the entrypoint.

Each basic block that you create within a function must be terminated, either with a conditional, a jump, a return, or a switch.

It’s legal to have multiple basic blocks that return within one function.

C Function: gcc_jit_block * gcc_jit_function_new_block (gcc_jit_function *func, const char *name)

Create a basic block of the given name. The name may be NULL, but providing meaningful names is often helpful when debugging: it may show up in dumps of the internal representation, and in error messages. It is copied, so the input buffer does not need to outlive the call; you can pass in a pointer to an on-stack buffer, e.g.:

for (pc = 0; pc < fn->fn_num_ops; pc++)
 {
   char buf[16];
   sprintf (buf, "instr%i", pc);
   state.op_blocks[pc] = gcc_jit_function_new_block (state.fn, buf);
 }
C Function: gcc_jit_object * gcc_jit_block_as_object (gcc_jit_block *block)

Upcast from block to object.

C Function: gcc_jit_function * gcc_jit_block_get_function (gcc_jit_block *block)

Which function is this block within?