![]() |
chigraph
master
Systems programming language written for beginners in LLVM
|
Class for compiling GraphFunctions
into llvm::Function
s.
More...
#include <chi/FunctionCompiler.hpp>
Public Types | |
using | DebugFile = llvm::DIFile |
using | DebugFunction = llvm::DISubprogram |
using | DebugFunctionType = llvm::DISubroutineType * |
Public Member Functions | |
FunctionCompiler (const GraphFunction &func, llvm::Module &moduleToGenInto, llvm::DICompileUnit &debugCU, llvm::DIBuilder &debugBuilder) | |
Constructor. More... | |
llvm::BasicBlock & | allocBlock () const |
The block for allocating variables at the beginning of the function. More... | |
Result | compile () |
Generates the contents of the function. More... | |
bool | compiled () const |
Get if the function has been compiled (compile() has been called) More... | |
Context & | context () const |
Get function().context() More... | |
DebugFunctionType | createSubroutineType () |
Create the subroutine type for the function. More... | |
llvm::DICompileUnit * | debugCompileUnit () const |
The compile unit for the module. More... | |
llvm::DIBuilder & | diBuilder () const |
The debug builder we're using for the module. More... | |
DebugFunction | diFunction () |
Get the debug function. More... | |
const GraphFunction & | function () const |
Get the graph function The GraphFunction. | |
NodeCompiler * | getOrCreateNodeCompiler (NodeInstance &node) |
Get or create a node compiler for a node. More... | |
Result | initialize (bool validate=true) |
Creates the function, but don't actually generate into it. More... | |
bool | initialized () const |
Get if the function is initialized (initialize() has been called) More... | |
llvm::Function & | llFunction () const |
Get the llvm function this compiler is generating. More... | |
llvm::Module & | llvmModule () const |
Get the module being generated. More... | |
llvm::Value * | localVariable (boost::string_view name) |
Get the value for a local variable. More... | |
GraphModule & | module () const |
Get function().module() More... | |
NodeCompiler * | nodeCompiler (NodeInstance &node) |
Get a node compile for a certain node. More... | |
int | nodeLineNumber (NodeInstance &node) |
Get the debug line number for the node instance Unique for each node. More... | |
llvm::Value & | postPureBreak () const |
Get the value for the address to jump back to. More... | |
Class for compiling GraphFunctions
into llvm::Function
s.
Definition at line 24 of file FunctionCompiler.hpp.
chi::FunctionCompiler::FunctionCompiler | ( | const GraphFunction & | func, |
llvm::Module & | moduleToGenInto, | ||
llvm::DICompileUnit & | debugCU, | ||
llvm::DIBuilder & | debugBuilder | ||
) |
Constructor.
func | The function to compile |
moduleToGenInto | The module to create the function in |
debugCU | The compile unit we're in |
debugBuilder | The Debug information builder for the module |
Definition at line 31 of file FunctionCompiler.cpp.
|
inline |
The block for allocating variables at the beginning of the function.
initialized() == true
Definition at line 94 of file FunctionCompiler.hpp.
References initialized(), and localVariable().
Referenced by compile().
Result chi::FunctionCompiler::compile | ( | ) |
Generates the contents of the function.
initialized() == true
compiled() == false
compiled() == true
Definition at line 198 of file FunctionCompiler.cpp.
References allocBlock(), compiled(), chi::dependentPuresRecursive(), chi::NodeCompiler::firstBlock(), getOrCreateNodeCompiler(), initialized(), and nodeCompiler().
|
inline |
Get if the function has been compiled (compile()
has been called)
Definition at line 148 of file FunctionCompiler.hpp.
References chi::compileFunction(), getOrCreateNodeCompiler(), and nodeCompiler().
Referenced by compile().
Context & chi::FunctionCompiler::context | ( | ) | const |
Get function().context()
function().context()
Definition at line 340 of file FunctionCompiler.cpp.
Referenced by createSubroutineType(), and function().
FunctionCompiler::DebugFunctionType chi::FunctionCompiler::createSubroutineType | ( | ) |
Create the subroutine type for the function.
Definition at line 275 of file FunctionCompiler.cpp.
References context(), chi::Context::langModule(), chi::LangModule::typeFromName(), and chi::DataType::valid().
Referenced by initialize().
|
inline |
The compile unit for the module.
Definition at line 89 of file FunctionCompiler.hpp.
Referenced by initialize().
|
inline |
The debug builder we're using for the module.
Definition at line 85 of file FunctionCompiler.hpp.
Referenced by initialize(), and chi::NodeCompiler::NodeCompiler().
|
inline |
Get the debug function.
initialized() == true
Definition at line 73 of file FunctionCompiler.hpp.
References initialized().
NodeCompiler * chi::FunctionCompiler::getOrCreateNodeCompiler | ( | NodeInstance & | node | ) |
Get or create a node compiler for a node.
&node.function() == &function()
Definition at line 362 of file FunctionCompiler.cpp.
References chi::NodeInstance::function().
Referenced by compile(), and compiled().
Result chi::FunctionCompiler::initialize | ( | bool | validate = true | ) |
Creates the function, but don't actually generate into it.
initialized() == false
initialized() == true
validate | Should the module be validated (using functions in FunctionValidator.hpp)? |
Definition at line 35 of file FunctionCompiler.cpp.
References chi::Result::addEntry(), chi::Result::addScopedContext(), chi::GraphModule::createLineNumberAssoc(), createSubroutineType(), debugCompileUnit(), diBuilder(), chi::ChiModule::fullName(), initialized(), llvmModule(), chi::mangleFunctionName(), module(), nodeLineNumber(), and chi::validateFunction().
|
inline |
Get if the function is initialized (initialize()
has been called)
Definition at line 144 of file FunctionCompiler.hpp.
Referenced by allocBlock(), compile(), diFunction(), initialize(), llFunction(), localVariable(), and postPureBreak().
|
inline |
Get the llvm function this compiler is generating.
initialized() == true
Definition at line 108 of file FunctionCompiler.hpp.
References initialized().
|
inline |
Get the module being generated.
Definition at line 81 of file FunctionCompiler.hpp.
Referenced by initialize(), and chi::NodeCompiler::llvmModule().
llvm::Value * chi::FunctionCompiler::localVariable | ( | boost::string_view | name | ) |
Get the value for a local variable.
initialized() == true
Definition at line 330 of file FunctionCompiler.cpp.
References initialized().
Referenced by allocBlock().
GraphModule & chi::FunctionCompiler::module | ( | ) | const |
Get function().module()
function().module()
Definition at line 339 of file FunctionCompiler.cpp.
Referenced by function(), and initialize().
NodeCompiler * chi::FunctionCompiler::nodeCompiler | ( | NodeInstance & | node | ) |
Get a node compile for a certain node.
&node.function() == &function()
Definition at line 353 of file FunctionCompiler.cpp.
References chi::NodeInstance::function().
Referenced by compile(), chi::NodeCompiler::compile_stage1(), and compiled().
int chi::FunctionCompiler::nodeLineNumber | ( | NodeInstance & | node | ) |
Get the debug line number for the node instance Unique for each node.
&node.function() == &function()
node | The instance to get the line number for |
Definition at line 342 of file FunctionCompiler.cpp.
References chi::NodeInstance::function().
Referenced by function(), and initialize().
|
inline |
Get the value for the address to jump back to.
initialized() == true
Definition at line 117 of file FunctionCompiler.hpp.
References initialized().