Crate gccjit [] [src] - Idiomatic Rust bindings to gccjit

This library aims to provide idiomatic Rust bindings to gccjit, the embeddable shared library that provides JIT compilation utilizing GCC's backend. See for more information and for documentation of gccjit itself.

Each one of the types provided in this crate corresponds to a pointer type provided by the libgccjit C API. Type conversions are handled by the ToRValue and ToLValue types, which represent values that can be rvalues and values that can be lvalues, respectively.

In addition, these types are all statically verified by the Rust compiler to never outlive the Context object from which they came, a requirement to using libgccjit correctly.



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.


Represents a successful compilation of a context. This type provides the means to access compiled functions and globals. JIT compiled functions are exposted to Rust as an extern "C" function pointer.


Wrapper around a GCC JIT context object that keeps the state of the JIT compiler. In GCCJIT, this object is responsible for all memory management of JIT data structures, and as such anything made from this context must have a lifetime strictly less than this object.


Field represents a field that composes structs or unions. A number of fields can be combined to create either a struct or a union.


Function is gccjit's representation of a function. Functions are constructed by constructing basic blocks and connecting them together. Locals are declared at the function level.


An LValue in gccjit represents a value that has a concrete location in memory. A LValue can be converted into an RValue through the ToRValue trait. It is also possible to get the address of an LValue.


A Location represents a location used when debugging jitted code.


Object represents the root of all objects in gccjit. It is not useful in and of itself, but it provides the implementation for Debug used by most objects in this library.


Parameter represents a parameter to a function. A series of parameteres can be combined to form a function signature.


An RValue is a value that may or may not have a storage address in gccjit. RValues can be dereferenced, used for field accesses, and are the parameters given to a majority of the gccjit API calls.


A Struct is gccjit's representation of a composite type. Despite the name, Struct can represent either a struct, an union, or an opaque named type.


A representation of a type, as it is known to the JIT compiler. Types can be created through the Typeable trait or they can be created dynamically by composing Field types.



BinaryOp is a enum representing the various binary operations that gccjit knows how to codegen.


ComparisonOp is an enum representing the various comparisons that gccjit is capable of doing.


FunctionType informs gccjit what sort of function a new function will be. An exported function is a function that will be exported using the CompileResult interface, able to be called outside of the jit. An internal function is a function that cannot be called outside of jitted code. An extern function is a function with external linkage, and always inline is a function that is always inlined wherever it is called and cannot be accessed outside of the jit.


Represents an optimization level that the JIT compiler will use when compiling your code.


This enum indicates to gccjit the format of the output code that is written out by compile_to_file.


UnaryOp is an enum representing the various unary operations that gccjit knows how to codegen.



ToLValue is a trait implemented by types that can be converted (or treated as) LValues.


ToObject is a trait implemented by types that can be upcast to Object.


ToRValue is a trait implemented by types that can be converted to, or treated as, an RValue.


Typeable is a trait for types that have a corresponding type within gccjit. This library implements this type for a variety of primitive types, but it's also possible to implement this trait for more complex types that will use the API on Context to construct analagous struct/union types.