| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 { | ||
| 18 | OPENVDB_USE_VERSION_NAMESPACE | ||
| 19 | namespace OPENVDB_VERSION_NAME { | ||
| 20 | |||
| 21 | namespace ax { | ||
| 22 | |||
| 23 | /// @brief Options that control how functions behave | ||
| 24 | 186 | struct OPENVDB_AX_API FunctionOptions | |
| 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 | ||
| 47 |
6/11✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
|
186 | struct OPENVDB_AX_API CompilerOptions |
| 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 | |||
| 76 |