OpenVDB 13.0.0

Loading...
Searching...
No Matches
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 {
22 OPENVDB_USE_VERSION_NAMESPACE
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.
32 struct VolumeComputeGenerator : public ComputeGenerator
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
AttributeRegistry.h
These classes contain lists of expected attributes and volumes which are populated by compiler during...
ComputeGenerator.h
The core visitor framework for code generation.
Value.h
Intermediate representation of supported AX values.
Types.h
Consolidated llvm types for most supported types.
openvdb::v13_0::ax::AttributeRegistry
This class stores a list of access names, types and their dependency connections.
Definition AttributeRegistry.h:40
openvdb::v13_0::ax::AttributeRegistry::Ptr
std::shared_ptr< AttributeRegistry > Ptr
Definition AttributeRegistry.h:42
openvdb::v13_0::ax::Logger
Logger for collecting errors and warnings that occur during AX compilation.
Definition Logger.h:58
openvdb::v13_0::ax::codegen::FunctionRegistry
The function registry which is used for function code generation. Each time a function is visited wit...
Definition FunctionRegistry.h:40
openvdb::v13_0::ax::codegen::Value
Intermediate representation wrapper for supported value types in AX as immutable instances.
Definition Value.h:63
openvdb
Definition Exceptions.h:13
openvdb::v13_0::ax::FunctionOptions
Options that control how functions behave.
Definition CompilerOptions.h:25
openvdb::v13_0::ax::ast::Attribute
Attributes represent any access to a primitive value, typically associated with the '@' symbol syntax...
Definition AST.h:1875
openvdb::v13_0::ax::ast::Tree
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy....
Definition AST.h:563
openvdb::v13_0::ax::codegen::SymbolTable
A symbol table which can be used to represent a single scoped set of a programs variables....
Definition SymbolTable.h:38
openvdb::v13_0::ax::codegen::codegen_internal::ComputeGenerator::ComputeGenerator
ComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
openvdb::v13_0::ax::codegen::codegen_internal::ComputeGenerator::traverse
bool traverse(const ast::Block *block)
Custom traversal of scoped blocks.
Definition ComputeGenerator.h:112
openvdb::v13_0::ax::codegen::codegen_internal::ComputeGenerator::visit
virtual bool visit(const ast::CommaOperator *)
Visitor methods for all AST nodes which implement IR generation.
openvdb::v13_0::ax::codegen::codegen_internal::VolumeComputeGenerator::generate
AttributeRegistry::Ptr generate(const ast::Tree &node)
openvdb::v13_0::ax::codegen::codegen_internal::VolumeComputeGenerator::VolumeComputeGenerator
VolumeComputeGenerator(llvm::Module &module, const FunctionOptions &options, FunctionRegistry &functionRegistry, Logger &logger)
Constructor.
openvdb::v13_0::ax::codegen::codegen_internal::VolumeComputeGenerator::~VolumeComputeGenerator
~VolumeComputeGenerator() override=default
openvdb::v13_0::ax::codegen::codegen_internal::VolumeComputeGenerator::visit
bool visit(const ast::Attribute *) override
Visitor methods for all AST nodes which implement IR generation.
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218