Go to the documentation of this file.
11 #ifndef OPENVDB_AX_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
12 #define OPENVDB_AX_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
18 #include "../ast/AST.h"
19 #include "../ast/Visitor.h"
20 #include "../compiler/CompilerOptions.h"
21 #include "../compiler/Logger.h"
25 #include <llvm/Analysis/TargetLibraryInfo.h>
26 #include <llvm/IR/BasicBlock.h>
27 #include <llvm/IR/Function.h>
28 #include <llvm/IR/IRBuilder.h>
29 #include <llvm/IR/LLVMContext.h>
30 #include <llvm/IR/Module.h>
51 static const std::string
Name;
56 static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
67 namespace codegen_internal {
110 if (!block)
return true;
111 if (!this->visit(block))
return false;
121 if (!comma)
return true;
122 if (!this->visit(comma))
return false;
132 if (!cond)
return true;
133 if (!this->visit(cond))
return false;
142 if (!bin)
return true;
143 if (!this->visit(bin))
return false;
152 if (!tern)
return true;
153 if (!this->visit(tern))
return false;
163 if (!loop)
return true;
164 if (!this->visit(loop))
return false;
174 if (!decl)
return true;
175 if (!this->visit(decl))
return false;
206 template <
typename ValueType>
207 typename std::enable_if<std::is_integral<ValueType>::value,
bool>::type
210 template <
typename ValueType>
211 typename std::enable_if<std::is_floating_point<ValueType>::value,
bool>::type
217 const bool allowInternal =
false);
257 #endif // OPENVDB_AX_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition: AST.h:562
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:55
Contains the global function registration definition which described all available user front end fun...
A symbol table which can be used to represent a single scoped set of a programs variables....
Definition: SymbolTable.h:35
Templated function traits which provides compile-time index access to the types of the function signa...
Definition: ax/openvdb_ax/codegen/Types.h:279
bool generate(const ast::Tree &)
void(const void *const) Signature
The signature of the generated function.
Definition: ComputeGenerator.h:54
A Block node represents a scoped list of statements. It may comprise of 0 or more statements,...
Definition: AST.h:476
SymbolTableBlocks mSymbolTables
Definition: ComputeGenerator.h:237
A Crement node represents a single increment '++' and decrement '–' operation. As well as it's cremen...
Definition: AST.h:1294
Cast nodes represent the conversion of an underlying expression to a target type. Cast nodes are typi...
Definition: AST.h:1464
The function registry which is used for function code generation. Each time a function is visited wit...
Definition: FunctionRegistry.h:37
A Value (literal) AST node holds either literal text or absolute value information on all numerical,...
Definition: AST.h:2253
Keywords represent keyword statements defining changes in execution. These include those that define ...
Definition: AST.h:1641
Logger & mLog
Definition: ComputeGenerator.h:244
ArrayUnpack represent indexing operations into AX container types, primarily vectors and matrices ind...
Definition: AST.h:1686
Options that control how functions behave.
Definition: CompilerOptions.h:25
A TernaryOperator represents a ternary (conditional) expression 'a ? b : c' which evaluates to 'b' if...
Definition: AST.h:1092
Library and file format version numbers.
const FunctionOptions mOptions
Definition: ComputeGenerator.h:242
A UnaryOperator represents a single unary operation on an expression. The operation type is stored as...
Definition: AST.h:1389
bool binaryExpression(llvm::Value *&result, llvm::Value *lhs, llvm::Value *rhs, const ast::tokens::OperatorToken op, const ast::Node *node)
Local AST nodes represent a single accesses to a local variable. The only store the name of the varia...
Definition: AST.h:2112
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:102
Specialization of Values for strings.
Definition: AST.h:2335
static const std::array< std::string, N_ARGS > & getArgumentKeys()
The argument key names available during code generation.
DeclareLocal AST nodes symbolize a single type declaration of a local variable. These store the local...
Definition: AST.h:2139
ExternalVariable represent any access to external (custom) data, typically associated with the '$' sy...
Definition: AST.h:2002
virtual ~ComputeGenerator()=default
The Visitor class uses the Curiously Recursive Template Pattern (CRTP) to provide a customizable inte...
Definition: Visitor.h:96
ConditionalStatements represents all combinations of 'if', 'else' and 'else if' syntax and semantics....
Definition: AST.h:864
std::stack< std::pair< llvm::BasicBlock *, llvm::BasicBlock * > > mBreakContinueStack
Definition: ComputeGenerator.h:231
static const std::string Name
The name of the generated function.
Definition: ComputeGenerator.h:51
Visitor object which will generate llvm IR for a syntax tree. This provides the majority of the code ...
Definition: ComputeGenerator.h:84
llvm::Module & mModule
Definition: ComputeGenerator.h:223
ComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
Contains the symbol table which holds mappings of variables names to llvm::Values.
const FunctionGroup * getFunction(const std::string &identifier, const bool allowInternal=false)
std::stack< llvm::Value * > mValues
Definition: ComputeGenerator.h:228
const SymbolTable & globals() const
Definition: ComputeGenerator.h:95
size_t mScopeIndex
Definition: ComputeGenerator.h:234
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:147
bool postOrderNodes() const
Code generation always runs post order.
Definition: ComputeGenerator.h:103
OperatorToken
Definition: Tokens.h:151
Loops represent for, while and do-while loop constructs. These all consist of a condition - evaluated...
Definition: AST.h:708
A map of unique ids to symbol tables which can be used to represent local variables within a program....
Definition: SymbolTable.h:112
Contains frameworks for creating custom AX functions which can be registered within the FunctionRegis...
A BinaryOperator represents a single binary operation between a left hand side (LHS) and right hand s...
Definition: AST.h:988
The function definition and signature which is built by the ComputeGenerator.
Definition: ComputeGenerator.h:49
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition: AST.h:1874
AssignExpressions represents a similar object construction to a BinaryOperator. AssignExpressions can...
Definition: AST.h:1198
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:95
llvm::IRBuilder mBuilder
Definition: ComputeGenerator.h:225
FunctionCalls represent a single call to a function and any provided arguments. The argument list can...
Definition: AST.h:1541
bool assignExpression(llvm::Value *lhs, llvm::Value *&rhs, const ast::Node *node)
static std::string getDefaultName()
Definition: openvdb/Exceptions.h:13
llvm::Function * mFunction
Definition: ComputeGenerator.h:240
SymbolTable & globals()
Definition: ComputeGenerator.h:94
ArrayPacks represent temporary container creations of arbitrary sizes, typically generated through th...
Definition: AST.h:1785
todo
Definition: FunctionTypes.h:779
llvm::LLVMContext & mContext
Definition: ComputeGenerator.h:224