![]() |
chigraph
master
Systems programming language written for beginners in LLVM
|
Helper to compile nodes. More...
#include <chi/NodeCompiler.hpp>
Public Member Functions | |
NodeCompiler (FunctionCompiler &functionCompiler, NodeInstance &inst) | |
Constructor. More... | |
NodeCompiler (const NodeCompiler &)=delete | |
NodeCompiler (NodeCompiler &&)=default | |
Move const. | |
llvm::BasicBlock & | codeBlock (size_t inputExecID) const |
Get the code block for a given inputExecID Requires that compile_stage1 has been called for this ID. More... | |
void | compile_stage1 (size_t inputExecID) |
Add the basic blocks and fill the pure blocks, but don't fill the code block nop if its already been called with this inputExecID. More... | |
Result | compile_stage2 (std::vector< llvm::BasicBlock *> trailingBlocks, size_t inputExecID) |
Fill the codegen block If compile_stage1 hasn't been called for this inputExecID, then it will be called nop if this inputExecID has been compiled before. More... | |
bool | compiled (size_t inputExecID) const |
Get if compile_stage2 has been called for a given inputExecID. More... | |
Context & | context () const |
Just node().context() | |
llvm::BasicBlock & | firstBlock (size_t inputExecID) const |
Get the first block to jump to for the node If there are dependent pures, it's the first pure block Otherwise, it's the code block compile_stage1 needs to be called first for this ID. More... | |
FunctionCompiler & | funcCompiler () const |
Get the function compiler. More... | |
size_t | inputExecs () const |
The number of input execs that we can compile If it's pure or an entry node, this is 1, otherwise it's node().inputExecConnections().size() More... | |
llvm::IndirectBrInst & | jumpBackInst () const |
Get the IndirectBrInst* for the pure. More... | |
llvm::Module & | llvmModule () const |
Get the module being generated. More... | |
NodeInstance & | node () const |
The node we're compiling. More... | |
NodeCompiler & | operator= (const NodeCompiler &)=delete |
NodeCompiler & | operator= (NodeCompiler &&)=default |
Move assign. | |
bool | pure () const |
node().type().pure() More... | |
std::vector< llvm::Value * > | returnValues () const |
Get return values. More... | |
Helper to compile nodes.
Nodes are compiled using many BasicBlock
s The first are for the dependent pures, one for each. The idea is that you point the last pure to jump to the next pure, and when you get to the last pure, then go to the actual block for this node.
Definition at line 24 of file NodeCompiler.hpp.
chi::NodeCompiler::NodeCompiler | ( | FunctionCompiler & | functionCompiler, |
NodeInstance & | inst | ||
) |
Constructor.
functionCompiler | The function compiler instance |
inst | The node to compile |
Definition at line 22 of file NodeCompiler.cpp.
References chi::NodeType::dataOutputs(), chi::FunctionCompiler::diBuilder(), funcCompiler(), node(), chi::NodeInstance::stringId(), and chi::NodeInstance::type().
llvm::BasicBlock & chi::NodeCompiler::codeBlock | ( | size_t | inputExecID | ) | const |
Get the code block for a given inputExecID Requires that compile_stage1
has been called for this ID.
inputExecID | the ID to get the code block for |
inputExecID < inputExecs()
Definition at line 221 of file NodeCompiler.cpp.
References inputExecs().
Referenced by compile_stage1(), compile_stage2(), firstBlock(), and node().
void chi::NodeCompiler::compile_stage1 | ( | size_t | inputExecID | ) |
Add the basic blocks and fill the pure blocks, but don't fill the code block nop if its already been called with this inputExecID.
inputExecID | The input exec to compile |
inputExecID < inputExecs()
Definition at line 91 of file NodeCompiler.cpp.
References codeBlock(), context(), chi::dependentPuresRecursive(), firstBlock(), funcCompiler(), inputExecs(), jumpBackInst(), node(), chi::FunctionCompiler::nodeCompiler(), and pure().
Referenced by compile_stage2(), and node().
Result chi::NodeCompiler::compile_stage2 | ( | std::vector< llvm::BasicBlock *> | trailingBlocks, |
size_t | inputExecID | ||
) |
Fill the codegen block If compile_stage1 hasn't been called for this inputExecID, then it will be called nop if this inputExecID has been compiled before.
trailingBlocks | The basic blocks to br to when the node is done, one for each exec output |
pure() || (trailingBlock.size() == node().outputExecConnections.size())
Either it's pure (in which case trailingBlock
is ignored) or it must be defined inputExecID | The input exec ID to compile |
inputExecID < inputExecs()
Definition at line 151 of file NodeCompiler.cpp.
References codeBlock(), chi::NodeType::codegen(), compile_stage1(), compiled(), context(), chi::NodeType::dataInputs(), funcCompiler(), chi::NodeInstance::inputDataConnections, inputExecs(), node(), chi::NodeInstance::outputExecConnections, pure(), returnValues(), and chi::NodeInstance::type().
Referenced by node().
bool chi::NodeCompiler::compiled | ( | size_t | inputExecID | ) | const |
Get if compile_stage2 has been called for a given inputExecID.
inputExecID | the ID to check |
inputExecID < inputExecs()
Definition at line 228 of file NodeCompiler.cpp.
References inputExecs().
Referenced by compile_stage2(), and node().
llvm::BasicBlock & chi::NodeCompiler::firstBlock | ( | size_t | inputExecID | ) | const |
Get the first block to jump to for the node If there are dependent pures, it's the first pure block Otherwise, it's the code block compile_stage1
needs to be called first for this ID.
inputExecID | the ID to get the block for. |
inputExecID < inputExecs()
Definition at line 214 of file NodeCompiler.cpp.
References codeBlock(), and inputExecs().
Referenced by chi::FunctionCompiler::compile(), compile_stage1(), and node().
|
inline |
Get the function compiler.
Definition at line 42 of file NodeCompiler.hpp.
Referenced by compile_stage1(), compile_stage2(), llvmModule(), and NodeCompiler().
size_t chi::NodeCompiler::inputExecs | ( | ) | const |
The number of input execs that we can compile If it's pure or an entry node, this is 1, otherwise it's node().inputExecConnections().size()
Definition at line 235 of file NodeCompiler.cpp.
References chi::NodeInstance::inputExecConnections, node(), and pure().
Referenced by codeBlock(), compile_stage1(), compile_stage2(), compiled(), firstBlock(), and node().
|
inline |
Get the IndirectBrInst* for the pure.
pure()
Definition at line 110 of file NodeCompiler.hpp.
References chi::dependentPuresRecursive(), and pure().
Referenced by compile_stage1().
llvm::Module & chi::NodeCompiler::llvmModule | ( | ) | const |
Get the module being generated.
Definition at line 226 of file NodeCompiler.cpp.
References funcCompiler(), and chi::FunctionCompiler::llvmModule().
Referenced by node().
|
inline |
The node we're compiling.
Definition at line 46 of file NodeCompiler.hpp.
References codeBlock(), compile_stage1(), compile_stage2(), compiled(), context(), firstBlock(), inputExecs(), llvmModule(), and pure().
Referenced by compile_stage1(), compile_stage2(), context(), inputExecs(), NodeCompiler(), and pure().
bool chi::NodeCompiler::pure | ( | ) | const |
Definition at line 89 of file NodeCompiler.cpp.
References node(), chi::NodeType::pure(), and chi::NodeInstance::type().
Referenced by compile_stage1(), compile_stage2(), inputExecs(), jumpBackInst(), and node().
|
inline |
Get return values.
Definition at line 105 of file NodeCompiler.hpp.
Referenced by compile_stage2().