Struct gccjit::Block

source ·
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>

source

pub fn get_function(&self) -> Function<'ctx>

source

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) in C.

source

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 = in C.

source

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.

source

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.

source

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.

source

pub fn end_with_jump(&self, loc: Option<Location<'ctx>>, target: Block<'ctx>)

Terminates a block by unconditionally jumping to another block.

source

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 ”. This function can only be used to terminate a block within a function whose return type is not void.

source

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.

source

pub fn end_with_switch<T: ToRValue<'ctx>>( &self, loc: Option<Location<'ctx>>, expr: T, default_block: Block<'ctx>, cases: &[Case<'ctx>] )

source

pub fn add_extended_asm( &self, loc: Option<Location<'ctx>>, asm_template: &str ) -> ExtendedAsm<'ctx>

source

pub fn end_with_extended_asm_goto( &self, loc: Option<Location<'ctx>>, asm_template: &str, goto_blocks: &[Block<'ctx>], fallthrough_block: Option<Block<'ctx>> ) -> ExtendedAsm<'ctx>

Trait Implementations§

source§

impl<'ctx> Clone for Block<'ctx>

source§

fn clone(&self) -> Block<'ctx>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'ctx> Debug for Block<'ctx>

source§

fn fmt<'a>(&self, fmt: &mut Formatter<'a>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'ctx> Hash for Block<'ctx>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'ctx> PartialEq for Block<'ctx>

source§

fn eq(&self, other: &Block<'ctx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'ctx> ToObject<'ctx> for Block<'ctx>

source§

fn to_object(&self) -> Object<'ctx>

source§

impl<'ctx> Copy for Block<'ctx>

source§

impl<'ctx> Eq for Block<'ctx>

source§

impl<'ctx> StructuralPartialEq for Block<'ctx>

Auto Trait Implementations§

§

impl<'ctx> RefUnwindSafe for Block<'ctx>

§

impl<'ctx> !Send for Block<'ctx>

§

impl<'ctx> !Sync for Block<'ctx>

§

impl<'ctx> Unpin for Block<'ctx>

§

impl<'ctx> UnwindSafe for Block<'ctx>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.