OpenVDB  12.1.0
VolumeComputeGenerator.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: Apache-2.0
3 
4 /// @file codegen/VolumeComputeGenerator.h
5 ///
6 /// @authors Nick Avramoussis
7 ///
8 /// @brief The visitor framework and function definition for volume grid
9 /// code generation
10 ///
11 
12 #ifndef OPENVDB_AX_VOLUME_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_VOLUME_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
14 
15 #include "ComputeGenerator.h"
16 #include "Types.h"
17 #include "Value.h"
18 #include "../compiler/AttributeRegistry.h"
19 #include <openvdb/version.h>
20 
21 namespace openvdb {
23 namespace OPENVDB_VERSION_NAME {
24 
25 namespace ax {
26 namespace codegen {
27 namespace codegen_internal {
28 
29 /// @brief Visitor object which will generate llvm IR for a syntax tree which has been generated
30 /// from AX that targets volumes. The IR will represent a single function. It is mainly
31 /// used by the Compiler class.
33 {
34  /// @brief Constructor
35  /// @param module llvm Module for generating IR
36  /// @param options Options for the function registry behaviour
37  /// @param functionRegistry Function registry object which will be used when generating IR
38  /// for function calls
39  /// @param logger Logger for collecting logical errors and warnings
40  VolumeComputeGenerator(llvm::Module& module,
41  const FunctionOptions& options,
42  FunctionRegistry& functionRegistry,
43  Logger& logger);
44 
45  ~VolumeComputeGenerator() override = default;
46 
47  using ComputeGenerator::traverse;
48  using ComputeGenerator::visit;
49 
50  AttributeRegistry::Ptr generate(const ast::Tree& node);
51  bool visit(const ast::Attribute*) override;
52 
53 private:
54  llvm::Value* accessorHandleFromToken(const std::string&);
55  void getAccessorValue(const std::string&, Value);
56 
57  void computek2(llvm::Function*, const AttributeRegistry&);
58  void computek3(llvm::Function*, const AttributeRegistry&);
59 
60  // Stores internal ptrs to accessor allocations
61  SymbolTable<llvm::Value*> mInternalPtrs;
62 };
63 
64 } // namespace codegen_internal
65 
66 } // namespace codegen
67 } // namespace ax
68 } // namespace OPENVDB_VERSION_NAME
69 } // namespace openvdb
70 
71 #endif // OPENVDB_AX_VOLUME_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
72 
Attributes represent any access to a primitive value, typically associated with the &#39;@&#39; symbol syntax...
Definition: AST.h:1874
The core visitor framework for code generation.
Visitor object which will generate llvm IR for a syntax tree which has been generated from AX that ta...
Definition: VolumeComputeGenerator.h:32
Options that control how functions behave.
Definition: CompilerOptions.h:24
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:562
Consolidated llvm types for most supported types.
Definition: Exceptions.h:13
std::shared_ptr< AttributeRegistry > Ptr
Definition: AttributeRegistry.h:42
The function registry which is used for function code generation. Each time a function is visited wit...
Definition: FunctionRegistry.h:39
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:57
Intermediate representation of supported AX values.
Intermediate representation wrapper for supported value types in AX as immutable instances.
Definition: Value.h:62
This class stores a list of access names, types and their dependency connections. ...
Definition: AttributeRegistry.h:39
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
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:37
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
Visitor object which will generate llvm IR for a syntax tree. This provides the majority of the code ...
Definition: ComputeGenerator.h:87