OpenVDB  11.0.0
CompilerOptions.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 compiler/CompilerOptions.h
5 ///
6 /// @authors Nick Avramoussis
7 ///
8 /// @brief OpenVDB AX Compiler Options
9 ///
10 
11 #ifndef OPENVDB_AX_COMPILER_COMPILER_OPTIONS_HAS_BEEN_INCLUDED
12 #define OPENVDB_AX_COMPILER_COMPILER_OPTIONS_HAS_BEEN_INCLUDED
13 
14 #include <openvdb/openvdb.h>
15 #include <openvdb/version.h>
16 
17 namespace openvdb {
19 namespace OPENVDB_VERSION_NAME {
20 
21 namespace ax {
22 
23 /// @brief Options that control how functions behave
25 {
26  /// @brief Enable the constant folding of C bindings. Functions may use this setting
27  /// to determine whether they are allowed to be called during code generation
28  /// to evaluate call sites with purely constant arguments and replace the call
29  /// with the result.
30  /// @note This does not impact IR functions which we leave to LLVM's CF during
31  /// IR optimization.
32  /// @note We used to bind IR methods to corresponding C bindings, however it can be
33  /// very easy to implement incorrectly, leading to discrepancies in the CF
34  /// results. Fundamentally, LLVM's support for CF IR is far superior and our
35  /// framework only supports some types of folding (see codegen/ConstantFolding.h)
36  bool mConstantFoldCBindings = true;
37  /// @brief When enabled, functions which have IR builder instruction definitions will
38  /// prioritise those over any registered external calls
39  bool mPrioritiseIR = true;
40  /// @brief When enabled, the function registry is only populated on a function visit.
41  /// At the end of code generation, only functions which have been instantiated
42  /// will exist in the function map.
43  bool mLazyFunctions = true;
44 };
45 
46 /// @brief Settings which control how a Compiler class object behaves
48 {
49  /// @brief Controls the llvm compiler optimization level
50  enum class OptLevel
51  {
52  NONE, // Do not run any optimization passes
53  O0, // Optimization level 0. Similar to clang -O0
54  O1, // Optimization level 1. Similar to clang -O1
55  O2, // Optimization level 2. Similar to clang -O2
56  Os, // Like -O2 with extra optimizations for size. Similar to clang -Os
57  Oz, // Like -Os but reduces code size further. Similar to clang -Oz
58  O3 // Optimization level 3. Similar to clang -O3
59  };
60 
61  OptLevel mOptLevel = OptLevel::O3;
62 
63  /// @brief If this flag is true, the generated llvm module will be verified when compilation
64  /// occurs, resulting in an exception being thrown if it is not valid
65  bool mVerify = true;
66  /// @brief Options for the function registry
67  FunctionOptions mFunctionOptions = FunctionOptions();
68 };
69 
70 } // namespace ax
71 } // namespace OPENVDB_VERSION_NAME
72 } // namespace openvdb
73 
74 #endif // OPENVDB_AX_COMPILER_FUNCTION_REGISTRY_OPTIONS_HAS_BEEN_INCLUDED
75 
#define OPENVDB_AX_API
Definition: Platform.h:295
OptLevel
Controls the llvm compiler optimization level.
Definition: CompilerOptions.h:50
Options that control how functions behave.
Definition: CompilerOptions.h:24
Settings which control how a Compiler class object behaves.
Definition: CompilerOptions.h:47
Definition: Exceptions.h:13
#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