- compile
JITResult compile()
Calls into GCC and runs the build. It can only be called once on a
given context.
- dump
void dump(string path, bool update_locations)
Dump a C-like representation describing what's been set up on the
context to file.
- getBuiltinFunction
JITFunction getBuiltinFunction(string name)
Create a reference to a GCC builtin function.
- getContext
gcc_jit_context* getContext()
Returns the internal gcc_jit_context object.
- getFirstError
string getFirstError()
- getIntType
JITType getIntType(int num_bytes, bool is_signed)
Build an integer type of a given size and signedness.
- getIntType
JITType getIntType()
A way to map a specific int type, using the compiler to
get the details automatically e.g:
JITType type = getIntType!size_t();
- getType
JITType getType(JITTypeKind kind)
Build a JITType from one of the types in JITTypeKind.
- newArrayAccess
JITLValue newArrayAccess(JITRValue ptr, JITRValue index)
Accessing an array or pointer through an index.
- newArrayAccess
JITLValue newArrayAccess(JITLocation loc, JITRValue ptr, JITRValue index)
Accessing an array or pointer through an index.
- newArrayType
JITType newArrayType(JITLocation loc, JITType type, int dims)
JITType newArrayType(JITType type, int dims)
JITType newArrayType(JITLocation loc, JITTypeKind kind, int dims)
JITType newArrayType(JITTypeKind kind, int dims)
Given type "T", build a new array type of "TN".
- newBinaryOp
JITRValue newBinaryOp(JITLocation loc, JITBinaryOp op, JITType type, JITRValue a, JITRValue b)
JITRValue newBinaryOp(JITBinaryOp op, JITType type, JITRValue a, JITRValue b)
Generic binary operations.
Make a JITRValue for the given binary operation.
- newCall
JITRValue newCall(JITLocation loc, JITFunction func, JITRValue[] args)
JITRValue newCall(JITFunction func, JITRValue[] args)
The most general way of creating a function call.
- newCall
JITRValue newCall(JITLocation loc, JITRValue ptr, JITRValue[] args)
JITRValue newCall(JITRValue ptr, JITRValue[] args)
Calling a function through a pointer.
- newCast
JITRValue newCast(JITLocation loc, JITRValue expr, JITType type)
JITRValue newCast(JITRValue expr, JITType type)
JITRValue newCast(JITLocation loc, JITRValue expr, JITTypeKind kind)
JITRValue newCast(JITRValue expr, JITTypeKind kind)
Type-coercion.
Currently only a limited set of conversions are possible.
int <=> float and int <=> bool.
- newChildContext
JITContext newChildContext()
Create a new child context of the given JITContext, inheriting a copy
of all option settings from the parent.
The returned JITContext can reference objects created within the
parent, but not vice-versa. The lifetime of the child context must be
bounded by that of the parent. You should release a child context
before releasing the parent context.
- newComparison
JITRValue newComparison(JITLocation loc, JITComparison op, JITRValue a, JITRValue b)
JITRValue newComparison(JITComparison op, JITRValue a, JITRValue b)
Generic comparisons.
Make a JITRValue of boolean type for the given comparison.
- newField
JITField newField(JITLocation loc, JITType type, string name)
JITField newField(JITType type, string name)
JITField newField(JITLocation loc, JITTypeKind kind, string name)
JITField newField(JITTypeKind kind, string name)
Create a field, for use within a struct or union.
- newFunction
JITFunction newFunction(JITLocation loc, JITFunctionKind kind, JITType return_type, string name, bool is_variadic, JITParam[] params)
JITFunction newFunction(JITFunctionKind kind, JITType return_type, string name, bool is_variadic, JITParam[] params)
JITFunction newFunction(JITLocation loc, JITFunctionKind kind, JITTypeKind return_kind, string name, bool is_variadic, JITParam[] params)
JITFunction newFunction(JITFunctionKind kind, JITTypeKind return_kind, string name, bool is_variadic, JITParam[] params)
- newFunctionType
JITType newFunctionType(JITLocation loc, JITType return_type, bool is_variadic, JITType[] param_types)
JITType newFunctionType(JITType return_type, bool is_variadic, JITType[] param_types)
JITType newFunctionType(JITLocation loc, JITTypeKind return_kind, bool is_variadic, JITType[] param_types)
JITType newFunctionType(JITTypeKind return_kind, bool is_variadic, JITType[] param_types)
- newGlobal
JITLValue newGlobal(JITLocation loc, JITGlobalKind global_kind, JITType type, string name)
JITLValue newGlobal(JITGlobalKind global_kind, JITType type, string name)
JITLValue newGlobal(JITLocation loc, JITGlobalKind global_kind, JITTypeKind kind, string name)
JITLValue newGlobal(JITGlobalKind global_kind, JITTypeKind kind, string name)
- newLocation
JITLocation newLocation(string filename, int line, int column)
Make a JITLocation representing a source location,
for use by the debugger.
Note:
You need to enable JITBoolOption.DEBUGINFO on the context
for these locations to actually be usable by the debugger.
- newOpaqueStructType
JITStruct newOpaqueStructType(JITLocation loc, string name)
JITStruct newOpaqueStructType(string name)
Create an opaque struct type.
- newParam
JITParam newParam(JITLocation loc, JITType type, string name)
JITParam newParam(JITType type, string name)
JITParam newParam(JITLocation loc, JITTypeKind kind, string name)
JITParam newParam(JITTypeKind kind, string name)
Create a function parameter.
- newRValue
JITRValue newRValue(JITType type, int value)
JITRValue newRValue(JITTypeKind kind, int value)
Given a JITType, which must be a numeric type, get an integer constant
as a JITRValue of that type.
- newRValue
JITRValue newRValue(JITType type, double value)
JITRValue newRValue(JITTypeKind kind, double value)
Given a JITType, which must be a floating point type, get a floating
point constant as a JITRValue of that type.
- newRValue
JITRValue newRValue(JITType type, void* value)
JITRValue newRValue(JITTypeKind kind, void* value)
Given a JITType, which must be a pointer type, and an address, get a
JITRValue representing that address as a pointer of that type.
- newRValue
JITRValue newRValue(string value)
Make a JITRValue for the given string literal value.
- newStructType
JITStruct newStructType(JITLocation loc, string name, JITField[] fields)
JITStruct newStructType(string name, JITField[] fields)
Create a struct type from an array of fields.
- newUnaryOp
JITRValue newUnaryOp(JITLocation loc, JITUnaryOp op, JITType type, JITRValue a)
JITRValue newUnaryOp(JITUnaryOp op, JITType type, JITRValue a)
Generic unary operations.
Make a JITRValue for the given unary operation.
- newUnionType
JITType newUnionType(JITLocation loc, string name, JITField[] fields)
JITType newUnionType(string name, JITField[] fields)
Create a union type from an array of fields.
- nil
JITRValue nil(JITType type)
JITRValue nil(JITTypeKind kind)
Given a JITType, which must be a pointer type, get a JITRValue
representing the NULL pointer of that type.
- one
JITRValue one(JITType type)
JITRValue one(JITTypeKind kind)
Given a JITType, which must be a numeric type, get the constant 1 as a
JITRValue of that type.
- release
void release()
Release the context.
After this call, it's no longer valid to use this JITContext.
- setOption
void setOption(JITStrOption opt, string value)
Set a string option of the context; see JITStrOption for notes
on the options and their meanings.
- setOption
void setOption(JITIntOption opt, int value)
Set an integer option of the context; see JITIntOption for notes
on the options and their meanings.
- setOption
void setOption(JITBoolOption opt, bool value)
Set a boolean option of the context; see JITBoolOption for notes
on the options and their meanings.
- zero
JITRValue zero(JITType type)
JITRValue zero(JITTypeKind kind)
Given a JITType, which must be a numeric type, get the constant 0 as a
JITRValue of that type.
The top-level of the API is the JITContext class. A JITContext instance encapsulates the state of a compilation. It goes through two states. Initial: During which you can set up options on it, and add types, functions and code, using the API below. Invoking compile on it transitions it to the PostCompilation state. PostCompilation: When you can call JITContext.release to clean it up.