Module Gccjit.Block

val create : ?name:string -> function_ -> block

Create a block. You can give it a meaningful name, which may show up in dumps of the internal representation, and in error messages.

val parent : block -> function_

Which function is this block within?

val eval : ?loc:location -> block -> rvalue -> unit

Add evaluation of an rvalue, discarding the result (e.g. a function call that returns void). This is equivalent to this C code:

(void)expression;
val assign : ?loc:location -> block -> lvalue -> rvalue -> unit

Add evaluation of an rvalue, assigning the result to the given lvalue. This is roughly equivalent to this C code:

lvalue = rvalue;
val assign_op : ?loc:location -> block -> lvalue -> binary_op -> rvalue -> unit

Add evaluation of an rvalue, using the result to modify an lvalue. This is analogous to "+=" and friends:

lvalue += rvalue;
lvalue *= rvalue;
lvalue /= rvalue;
etc

For example:

(* "i++" *)
add_assignment_op loop_body i Plus (one ctx int_type)
val comment : ?loc:location -> block -> string -> unit

Add a no-op textual comment to the internal representation of the code. It will be optimized away, but will be visible in the dumps seen via Dump_initial_tree and Dump_initial_gimple and thus may be of use when debugging how your project's internal representation gets converted to the libgccjit IR.

val cond_jump : ?loc:location -> block -> rvalue -> block -> block -> unit

Terminate a block by adding evaluation of an rvalue, branching on the result to the appropriate successor block. This is roughly equivalent to this C code:

if (boolval)
  goto on_true;
else
  goto on_false;
val jump : ?loc:location -> block -> block -> unit

Terminate a block by adding a jump to the given target block. This is roughly equivalent to this C code:

goto target;
val return : ?loc:location -> block -> rvalue -> unit

Terminate a block by adding evaluation of an rvalue, returning the value. This is roughly equivalent to this C code:

return expression;
val return_void : ?loc:location -> block -> unit

Terminate a block by adding a valueless return, for use within a function with void return type. This is equivalent to this C code:

return;
val to_string : block -> string

Get a human-readable description of this object.