MysoreScript
Typedefs | Functions
anonymous_namespace{compiler.cc} Namespace Reference

Typedefs

typedef std::function< Value *(Compiler::Context &c, Value *, Value *)> BinOpFn
 A function type that is used by the compileBinaryOp function. More...
 

Functions

template<typename T >
Value * staticAddress (Compiler::Context &c, T *ptr, Type *ty)
 Helper function that turns a pointer that is known at compile time into a constant in the code. More...
 
Value * compileSmallInt (Compiler::Context &c, Value *i)
 Generate a small integer object from an integer value. More...
 
Value * compileSmallInt (Compiler::Context &c, intptr_t i)
 Generate a small integer object from an integer constant. More...
 
Value * getAsObject (Compiler::Context &c, Value *i)
 Get the specified value as the LLVM type used for object pointers. More...
 
Value * getAsSmallInt (Compiler::Context &c, Value *i)
 Get the specified value as the LLVM type used for small integer objects. More...
 
Value * compileCompare (Compiler::Context &c, CmpInst::Predicate Op, Value *LHS, Value *RHS)
 Helper function that inserts all of the code required for comparison operations. More...
 
Value * compileBinaryOp (Compiler::Context &c, Value *LHS, Value *RHS, Instruction::BinaryOps Op, const char *slowCallFnName)
 Helper function that inserts all of the code required for small integer operations, either calling the relevant method or doing the arithmetic. More...
 

Typedef Documentation

§ BinOpFn

typedef std::function<Value*(Compiler::Context &c, Value*, Value*)> anonymous_namespace{compiler.cc}::BinOpFn

A function type that is used by the compileBinaryOp function.

Each compileBinOp method for arithmetic operations provides an instance of this type to insert the correct instruction for performing its operation on the two arguments.

Definition at line 644 of file compiler.cc.

Function Documentation

§ compileBinaryOp()

Value* anonymous_namespace{compiler.cc}::compileBinaryOp ( Compiler::Context c,
Value *  LHS,
Value *  RHS,
Instruction::BinaryOps  Op,
const char *  slowCallFnName 
)

Helper function that inserts all of the code required for small integer operations, either calling the relevant method or doing the arithmetic.

For real objects, the function named by the slowCallFnName parameter is called, which then invokes the correct method. For integers, the function inserts the binary op specified by Op.

Definition at line 672 of file compiler.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

§ compileCompare()

Value* anonymous_namespace{compiler.cc}::compileCompare ( Compiler::Context c,
CmpInst::Predicate  Op,
Value *  LHS,
Value *  RHS 
)

Helper function that inserts all of the code required for comparison operations.

Definition at line 650 of file compiler.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

§ compileSmallInt() [1/2]

Value* anonymous_namespace{compiler.cc}::compileSmallInt ( Compiler::Context c,
Value *  i 
)

Generate a small integer object from an integer value.

Definition at line 34 of file compiler.cc.

§ compileSmallInt() [2/2]

Value* anonymous_namespace{compiler.cc}::compileSmallInt ( Compiler::Context c,
intptr_t  i 
)

Generate a small integer object from an integer constant.

Definition at line 42 of file compiler.cc.

Here is the caller graph for this function:

§ getAsObject()

Value* anonymous_namespace{compiler.cc}::getAsObject ( Compiler::Context c,
Value *  i 
)

Get the specified value as the LLVM type used for object pointers.

This inserts a bitcast or inttoptr instruction as appropriate for the source type.

Definition at line 50 of file compiler.cc.

Here is the caller graph for this function:

§ getAsSmallInt()

Value* anonymous_namespace{compiler.cc}::getAsSmallInt ( Compiler::Context c,
Value *  i 
)

Get the specified value as the LLVM type used for small integer objects.

This inserts a bitcast or ptrtoint instruction as appropriate for the source type.

Definition at line 63 of file compiler.cc.

Here is the caller graph for this function:

§ staticAddress()

template<typename T >
Value* anonymous_namespace{compiler.cc}::staticAddress ( Compiler::Context c,
T *  ptr,
Type *  ty 
)

Helper function that turns a pointer that is known at compile time into a constant in the code.

Note that the garbage collector can't see the code (we could tweak the memory manager to use the GC to allocate memory, but even then constants are often materialised as immediate operands to two or more instructions so the GC wouldn't necessarily see them). This means that the address must be a GC root or must be used to store pointers to non-GC'd memory.

Definition at line 26 of file compiler.cc.

Here is the caller graph for this function: