| chigraph master Systems programming language written for beginners in LLVM

Public Member Functions | List of all members
chi::NodeCompiler Struct Reference

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...

## Detailed Description

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.

## Constructor & Destructor Documentation

## ◆ NodeCompiler()

chi::NodeCompiler::NodeCompiler | ( | FunctionCompiler & | functionCompiler,
|  | NodeInstance & | inst
| ) |  |

Constructor.

Parameters

  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().

Here is the call graph for this function:

## Member Function Documentation

## ◆ codeBlock()

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.

Parameters

  inputExecID | the ID to get the code block for

Precondition
  `inputExecID < inputExecs()`

Returns
  The BasicBlock

Definition at line 221 of file NodeCompiler.cpp.

References inputExecs().

Referenced by compile_stage1(), compile_stage2(), firstBlock(), and node().

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

## ◆ compile_stage1()

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.

Parameters

  inputExecID | The input exec to compile

Precondition
  `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().

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

## ◆ compile_stage2()

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.

Parameters

  trailingBlocks | The basic blocks to br to when the node is done, one for each exec output

Precondition
  `pure() || (trailingBlock.size() == node().outputExecConnections.size())` Either it's pure (in which case `trailingBlock` is ignored) or it must be defined

Parameters

  inputExecID | The input exec ID to compile

Precondition
  `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().

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

## ◆ compiled()

bool chi::NodeCompiler::compiled | ( | size_t | inputExecID | ) | const

Get if compile_stage2 has been called for a given inputExecID.

Parameters

  inputExecID | the ID to check

Precondition
  `inputExecID < inputExecs()`

Returns
  true if it's already been called, false otherwise

Definition at line 228 of file NodeCompiler.cpp.

References inputExecs().

Referenced by compile_stage2(), and node().

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

## ◆ firstBlock()

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.

Parameters

  inputExecID | the ID to get the block for.

Precondition
  `inputExecID < inputExecs()`

Returns
  The basic block.

Definition at line 214 of file NodeCompiler.cpp.

References codeBlock(), and inputExecs().

Referenced by chi::FunctionCompiler::compile(), compile_stage1(), and node().

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

## ◆ funcCompiler()

FunctionCompiler& chi::NodeCompiler::funcCompiler | ( |  | ) | const
| inline

Get the function compiler.

Returns
  the FunctionCompiler

Definition at line 42 of file NodeCompiler.hpp.

Referenced by compile_stage1(), compile_stage2(), llvmModule(), and NodeCompiler().

Here is the caller graph for this function:

## ◆ inputExecs()

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()

Returns
  The count

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().

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

## ◆ jumpBackInst()

llvm::IndirectBrInst& chi::NodeCompiler::jumpBackInst | ( |  | ) | const
| inline

Get the IndirectBrInst* for the pure.

Precondition
  `pure()`

Returns
  The indirectbr instance

Definition at line 110 of file NodeCompiler.hpp.

References chi::dependentPuresRecursive(), and pure().

Referenced by compile_stage1().

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

## ◆ llvmModule()

llvm::Module & chi::NodeCompiler::llvmModule | ( |  | ) | const

Get the module being generated.

Returns
  The Module

Definition at line 226 of file NodeCompiler.cpp.

References funcCompiler(), and chi::FunctionCompiler::llvmModule().

Referenced by node().

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

## ◆ node()

NodeInstance& chi::NodeCompiler::node | ( |  | ) | const
| inline

The node we're compiling.

Returns
  The NodeInstance

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().

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

## ◆ pure()

bool chi::NodeCompiler::pure | ( |  | ) | const

`node().type().pure()`

Returns
  `node().type().pure()`

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().

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

## ◆ returnValues()

std::vector<llvm::Value*> chi::NodeCompiler::returnValues | ( |  | ) | const
| inline

Get return values.

Returns
  a vector of the return values

Definition at line 105 of file NodeCompiler.hpp.

Referenced by compile_stage2().

Here is the caller graph for this function:

The documentation for this struct was generated from the following files:

- lib/core/include/chi/NodeCompiler.hpp
- lib/core/src/NodeCompiler.cpp