pub struct Block<'ctx> { /* private fields */ }
Expand description
Block represents a basic block in gccjit. Blocks are created by functions. A basic block consists of a series of instructions terminated by a terminator instruction, which can be either a jump to one block, a conditional branch to two blocks (true/false branches), a return, or a void return.
Implementations§
source§impl<'ctx> Block<'ctx>
impl<'ctx> Block<'ctx>
pub fn get_function(&self) -> Function<'ctx>
sourcepub fn add_eval<T: ToRValue<'ctx>>(&self, loc: Option<Location<'ctx>>, value: T)
pub fn add_eval<T: ToRValue<'ctx>>(&self, loc: Option<Location<'ctx>>, value: T)
Evaluates the rvalue parameter and discards its result. Equivalent
to (void)
sourcepub fn add_assignment<L: ToLValue<'ctx>, R: ToRValue<'ctx>>(
&self,
loc: Option<Location<'ctx>>,
assign_target: L,
value: R
)
pub fn add_assignment<L: ToLValue<'ctx>, R: ToRValue<'ctx>>( &self, loc: Option<Location<'ctx>>, assign_target: L, value: R )
Assigns the value of an rvalue to an lvalue directly. Equivalent
to
sourcepub fn add_assignment_op<L: ToLValue<'ctx>, R: ToRValue<'ctx>>(
&self,
loc: Option<Location<'ctx>>,
assign_target: L,
op: BinaryOp,
value: R
)
pub fn add_assignment_op<L: ToLValue<'ctx>, R: ToRValue<'ctx>>( &self, loc: Option<Location<'ctx>>, assign_target: L, op: BinaryOp, value: R )
Performs a binary operation on an LValue and an RValue, assigning the result of the binary operation to the LValue upon completion. Equivalent to the *=, +=, -=, etc. operator family in C.
sourcepub fn add_comment<S: AsRef<str>>(
&self,
loc: Option<Location<'ctx>>,
message: S
)
pub fn add_comment<S: AsRef<str>>( &self, loc: Option<Location<'ctx>>, message: S )
Adds a comment to a block. It’s unclear from the documentation what this actually means.
sourcepub fn end_with_conditional<T: ToRValue<'ctx>>(
&self,
loc: Option<Location<'ctx>>,
cond: T,
on_true: Block<'ctx>,
on_false: Block<'ctx>
)
pub fn end_with_conditional<T: ToRValue<'ctx>>( &self, loc: Option<Location<'ctx>>, cond: T, on_true: Block<'ctx>, on_false: Block<'ctx> )
Terminates a block by branching to one of two blocks, depending on the value of a conditional RValue.
sourcepub fn end_with_jump(&self, loc: Option<Location<'ctx>>, target: Block<'ctx>)
pub fn end_with_jump(&self, loc: Option<Location<'ctx>>, target: Block<'ctx>)
Terminates a block by unconditionally jumping to another block.
sourcepub fn end_with_return<T: ToRValue<'ctx>>(
&self,
loc: Option<Location<'ctx>>,
ret: T
)
pub fn end_with_return<T: ToRValue<'ctx>>( &self, loc: Option<Location<'ctx>>, ret: T )
Terminates a block by returning from the containing function, setting
the rvalue to be the return value of the function. This is equivalent
to C’s “return
sourcepub fn end_with_void_return(&self, loc: Option<Location<'ctx>>)
pub fn end_with_void_return(&self, loc: Option<Location<'ctx>>)
Terminates a block by returning from the containing function, returning no value. This is equivalent to C’s bare “return” with no expression. This function can only be used to terminate a block within a function that returns void.