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" 23 #include <openvdb/version.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;
59 static const std::array<std::string, N_ARGS>& getArgumentKeys();
60 static std::string getDefaultName();
67 namespace codegen_internal {
113 if (!block)
return true;
114 if (!this->visit(block))
return false;
124 if (!comma)
return true;
125 if (!this->visit(comma))
return false;
135 if (!cond)
return true;
136 if (!this->visit(cond))
return false;
145 if (!bin)
return true;
146 if (!this->visit(bin))
return false;
155 if (!tern)
return true;
156 if (!this->visit(tern))
return false;
166 if (!loop)
return true;
167 if (!this->visit(loop))
return false;
177 if (!decl)
return true;
178 if (!this->visit(decl))
return false;
211 template <
typename ValueType>
214 template <
typename ValueType>
222 const FunctionGroup* getFunction(
const std::string& identifier,
223 const bool allowInternal =
false);
225 bool binaryExpression(llvm::Value*& result, llvm::Value* lhs, llvm::Value* rhs,
227 bool assignExpression(llvm::Value* lhs, llvm::Value*& rhs,
const ast::Node* node);
234 void createFreeSymbolStrings(llvm::IRBuilder<>&);
270 #endif // OPENVDB_AX_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED std::stack< std::pair< llvm::BasicBlock *, llvm::BasicBlock * > > mBreakContinueStack
Definition: ComputeGenerator.h:244
Cast nodes represent the conversion of an underlying expression to a target type. Cast nodes are typi...
Definition: AST.h:1463
Specialization of Values for strings.
Definition: AST.h:2334
Loops represent for, while and do-while loop constructs. These all consist of a condition - evaluated...
Definition: AST.h:707
A TernaryOperator represents a ternary (conditional) expression 'a ? b : c' which evaluates to 'b' if...
Definition: AST.h:1091
ArrayPacks represent temporary container creations of arbitrary sizes, typically generated through th...
Definition: AST.h:1784
A UnaryOperator represents a single unary operation on an expression. The operation type is stored as...
Definition: AST.h:1388
bool traverse(const ast::ConditionalStatement *cond)
Custom traversal of conditional statements.
Definition: ComputeGenerator.h:133
SymbolTable & globals()
Definition: ComputeGenerator.h:97
llvm::LLVMContext & mContext
Definition: ComputeGenerator.h:237
todo
Definition: FunctionTypes.h:790
A Value (literal) AST node holds either literal text or absolute value information on all numerical...
Definition: AST.h:2252
bool postOrderNodes() const
Code generation always runs post order.
Definition: ComputeGenerator.h:106
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:54
ArrayUnpack represent indexing operations into AX container types, primarily vectors and matrices ind...
Definition: AST.h:1685
ConditionalStatements represents all combinations of 'if', 'else' and 'else if' syntax and semantics...
Definition: AST.h:863
bool traverse(const ast::Block *block)
Custom traversal of scoped blocks.
Definition: ComputeGenerator.h:111
Contains frameworks for creating custom AX functions which can be registered within the FunctionRegis...
Visitor object which will generate llvm IR for a syntax tree. This provides the majority of the code ...
Definition: ComputeGenerator.h:86
OperatorToken
Definition: Tokens.h:150
llvm::Function * mFunction
Definition: ComputeGenerator.h:253
A BinaryOperator represents a single binary operation between a left hand side (LHS) and right hand s...
Definition: AST.h:987
FunctionCalls represent a single call to a function and any provided arguments. The argument list can...
Definition: AST.h:1540
Contains the global function registration definition which described all available user front end fun...
bool traverse(const ast::TernaryOperator *tern)
Custom traversal of ternary operators.
Definition: ComputeGenerator.h:153
The function registry which is used for function code generation. Each time a function is visited wit...
Definition: FunctionRegistry.h:36
Local AST nodes represent a single accesses to a local variable. The only store the name of the varia...
Definition: AST.h:2111
Logger & mLog
Definition: ComputeGenerator.h:257
static const std::string Name
The name of the generated function.
Definition: ComputeGenerator.h:51
The Visitor class uses the Curiously Recursive Template Pattern (CRTP) to provide a customizable inte...
Definition: Visitor.h:95
const SymbolTable & globals() const
Definition: ComputeGenerator.h:98
The function definition and signature which is built by the ComputeGenerator.
Definition: ComputeGenerator.h:48
llvm::IRBuilder mBuilder
Definition: ComputeGenerator.h:238
Templated function traits which provides compile-time index access to the types of the function signa...
Definition: Types.h:259
Definition: Exceptions.h:13
ValueT value
Definition: GridBuilder.h:1287
The base abstract node which determines the interface and required methods for all derived concrete n...
Definition: AST.h:101
void(const void *const) Signature
The signature of the generated function.
Definition: ComputeGenerator.h:54
Contains the symbol table which holds mappings of variables names to llvm::Values.
A Block node represents a scoped list of statements. It may comprise of 0 or more statements...
Definition: AST.h:475
A symbol table which can be used to represent a single scoped set of a programs variables. This is simply an unordered map of strings to llvm::Values.
Definition: SymbolTable.h:35
bool traverse(const ast::CommaOperator *comma)
Custom traversal of comma expression.
Definition: ComputeGenerator.h:122
Options that control how functions behave.
Definition: CompilerOptions.h:24
DeclareLocal AST nodes symbolize a single type declaration of a local variable. These store the local...
Definition: AST.h:2138
AssignExpressions represents a similar object construction to a BinaryOperator. AssignExpressions can...
Definition: AST.h:1197
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy. It represents an entire conversion of a valid AX string.
Definition: AST.h:561
Keywords represent keyword statements defining changes in execution. These include those that define ...
Definition: AST.h:1640
bool traverse(const ast::BinaryOperator *bin)
Custom traversal of binary operators.
Definition: ComputeGenerator.h:143
llvm::Module & mModule
Definition: ComputeGenerator.h:236
bool traverse(const ast::DeclareLocal *decl)
Custom traversal of declarations.
Definition: ComputeGenerator.h:175
bool traverse(const ast::Loop *loop)
Custom traversal of loops.
Definition: ComputeGenerator.h:164
SymbolTableBlocks mSymbolTables
Definition: ComputeGenerator.h:250
A Crement node represents a single increment '++' and decrement '–' operation. As well as it's creme...
Definition: AST.h:1293
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition: AST.h:1873
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
std::stack< llvm::Value * > mValues
Definition: ComputeGenerator.h:241
const FunctionOptions mOptions
Definition: ComputeGenerator.h:255
ExternalVariable represent any access to external (custom) data, typically associated with the '$' sy...
Definition: AST.h:2001
size_t mScopeIndex
Definition: ComputeGenerator.h:247
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
A map of unique ids to symbol tables which can be used to represent local variables within a program...
Definition: SymbolTable.h:112