OpenVDB  11.0.0
PointComputeGenerator.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 /// @file codegen/PointComputeGenerator.h
5 ///
6 /// @authors Nick Avramoussis, Matt Warner, Francisco Gochez, Richard Jones
7 ///
8 /// @brief The visitor framework and function definition for point data
9 /// grid code generation
10 ///
11 
12 #ifndef OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
14 
15 #include "ComputeGenerator.h"
16 #include "FunctionTypes.h"
17 #include "Types.h"
18 #include "Utils.h"
19 
20 #include "../compiler/AttributeRegistry.h"
21 
22 #include <openvdb/version.h>
24 
25 namespace openvdb {
27 namespace OPENVDB_VERSION_NAME {
28 
29 namespace ax {
30 namespace codegen {
31 
32 ///////////////////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////////
34 
36 {
37  // The signature of the generated function
38  using Signature =
39  void(const void* const,
40  const int32_t (*)[3],
41  Index32*, // leaf value buffer
42  bool, // active
43  uint64_t, // pindex
44  void**, // transforms
45  void**, // values
46  uint64_t*, // flags
47  const void* const, // attribute set
48  void**, // group handles
49  void*); // leaf data
50 
52  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
53 
54  static const std::array<const char*, N_ARGS>& argumentKeys();
55  static const char* getDefaultName();
56 };
57 
59 {
60  // The signature of the generated function
61  using Signature =
62  void(const void* const,
63  const int32_t (*)[3],
64  Index32*, // leaf value buffer
65  bool, // active
66  uint64_t, // pindex
67  void**, // transforms
68  void**, // arrays
69  uint64_t*, // flags
70  const void* const, // attribute set
71  void**, // group handles
72  void*); // leaf data
73 
75  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
76 
77  static const std::array<const char*, N_ARGS>& argumentKeys();
78  static const char* getDefaultName();
79 };
80 
82 {
83  // The signature of the generated function
84  using Signature =
85  void(const void* const,
86  const int32_t (*)[3],
87  Index32*, // leaf value buffer
88  bool, // active
89  uint64_t, // pindex
90  void**, // transforms
91  void**, // buffers
92  uint64_t*, // flags
93  const void* const, // attribute set
94  void**, // group handles
95  void*); // leaf data
96 
98  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
99 
100  static const std::array<const char*, N_ARGS>& argumentKeys();
101  static const char* getDefaultName();
102 };
103 
105 {
106  // The signature of the generated function
107  using Signature =
108  void(const void* const,
109  const int32_t (*)[3],
110  Index32*, // leaf value buffer
111  uint64_t*, // active buffer
112  int64_t, // leaf buffer size (512)
113  uint64_t, // mode (0 = off, 1 = active, 2 = both)
114  void**, // transforms
115  void**, // buffers
116  uint64_t*, // flags
117  const void* const, // attribute set
118  void**, // group handles
119  void*); // leaf data
120 
122  static const size_t N_ARGS = FunctionTraitsT::N_ARGS;
123 
124  static const std::array<const char*, N_ARGS>& argumentKeys();
125  static const char* getDefaultName();
126 };
127 
128 
129 ///////////////////////////////////////////////////////////////////////////
130 ///////////////////////////////////////////////////////////////////////////
131 
132 namespace codegen_internal {
133 
134 /// @brief Visitor object which will generate llvm IR for a syntax tree which has been generated from
135 /// AX that targets point grids. The IR will represent 2 functions : one that executes over
136 /// single points and one that executes over a collection of points. This is primarily used by the
137 /// Compiler class.
139 {
140  /// @brief Constructor
141  /// @param module llvm Module for generating IR
142  /// @param options Options for the function registry behaviour
143  /// @param functionRegistry Function registry object which will be used when generating IR
144  /// for function calls
145  /// @param logger Logger for collecting logical errors and warnings
146  PointComputeGenerator(llvm::Module& module,
147  const FunctionOptions& options,
148  FunctionRegistry& functionRegistry,
149  Logger& logger);
150 
151  ~PointComputeGenerator() override = default;
152 
153  using ComputeGenerator::traverse;
154  using ComputeGenerator::visit;
155 
157  bool visit(const ast::Attribute*) override;
158 
159 private:
160  void computePKBR(const AttributeRegistry&);
161  void computePKB(const AttributeRegistry&);
162  void computePKAA(const AttributeRegistry&);
163 };
164 
165 } // namespace namespace codegen_internal
166 
167 } // namespace codegen
168 } // namespace ax
169 } // namespace OPENVDB_VERSION_NAME
170 } // namespace openvdb
171 
172 #endif // OPENVDB_AX_POINT_COMPUTE_GENERATOR_HAS_BEEN_INCLUDED
173 
Attribute Array storage templated on type and compression codec.
The core visitor framework for code generation.
Contains frameworks for creating custom AX functions which can be registered within the FunctionRegis...
Consolidated llvm types for most supported types.
This class stores a list of access names, types and their dependency connections.
Definition: AttributeRegistry.h:39
std::shared_ptr< AttributeRegistry > Ptr
Definition: AttributeRegistry.h:41
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:58
The function registry which is used for function code generation. Each time a function is visited wit...
Definition: FunctionRegistry.h:36
uint32_t Index32
Definition: Types.h:52
Definition: Exceptions.h:13
Utility code generation methods for performing various llvm operations.
Options that control how functions behave.
Definition: CompilerOptions.h:25
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition: AST.h:1874
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition: AST.h:562
Templated function traits which provides compile-time index access to the types of the function signa...
Definition: Types.h:279
Definition: PointComputeGenerator.h:59
void(const void *const, const int32_t(*)[3], Index32 *, bool, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition: PointComputeGenerator.h:72
static const std::array< const char *, N_ARGS > & argumentKeys()
Definition: PointComputeGenerator.h:105
void(const void *const, const int32_t(*)[3], Index32 *, uint64_t *, int64_t, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition: PointComputeGenerator.h:119
static const std::array< const char *, N_ARGS > & argumentKeys()
Definition: PointComputeGenerator.h:82
void(const void *const, const int32_t(*)[3], Index32 *, bool, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition: PointComputeGenerator.h:95
static const std::array< const char *, N_ARGS > & argumentKeys()
Definition: PointComputeGenerator.h:36
void(const void *const, const int32_t(*)[3], Index32 *, bool, uint64_t, void **, void **, uint64_t *, const void *const, void **, void *) Signature
Definition: PointComputeGenerator.h:49
static const std::array< const char *, N_ARGS > & argumentKeys()
Visitor object which will generate llvm IR for a syntax tree. This provides the majority of the code ...
Definition: ComputeGenerator.h:87
Visitor object which will generate llvm IR for a syntax tree which has been generated from AX that ta...
Definition: PointComputeGenerator.h:139
AttributeRegistry::Ptr generate(const ast::Tree &node)
bool visit(const ast::Attribute *) override
Visitor methods for all AST nodes which implement IR generation.
PointComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
Constructor.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212