| 1 | /*===-- llvm-c/Transform/PassBuilder.h - PassBuilder for LLVM C ---*- C -*-===*\ |
| 2 | |* *| |
| 3 | |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| |
| 4 | |* Exceptions. *| |
| 5 | |* See https://llvm.org/LICENSE.txt for license information. *| |
| 6 | |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |
| 7 | |* *| |
| 8 | |*===----------------------------------------------------------------------===*| |
| 9 | |* *| |
| 10 | |* This header contains the LLVM-C interface into the new pass manager *| |
| 11 | |* *| |
| 12 | \*===----------------------------------------------------------------------===*/ |
| 13 | |
| 14 | #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H |
| 15 | #define LLVM_C_TRANSFORMS_PASSBUILDER_H |
| 16 | |
| 17 | #include "llvm-c/Error.h" |
| 18 | #include "llvm-c/TargetMachine.h" |
| 19 | #include "llvm-c/Types.h" |
| 20 | #include "llvm-c/Visibility.h" |
| 21 | |
| 22 | /** |
| 23 | * @defgroup LLVMCCoreNewPM New Pass Manager |
| 24 | * @ingroup LLVMCCore |
| 25 | * |
| 26 | * @{ |
| 27 | */ |
| 28 | |
| 29 | LLVM_C_EXTERN_C_BEGIN |
| 30 | |
| 31 | /** |
| 32 | * A set of options passed which are attached to the Pass Manager upon run. |
| 33 | * |
| 34 | * This corresponds to an llvm::LLVMPassBuilderOptions instance |
| 35 | * |
| 36 | * The details for how the different properties of this structure are used can |
| 37 | * be found in the source for LLVMRunPasses |
| 38 | */ |
| 39 | typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef; |
| 40 | |
| 41 | /** |
| 42 | * Construct and run a set of passes over a module |
| 43 | * |
| 44 | * This function takes a string with the passes that should be used. The format |
| 45 | * of this string is the same as opt's -passes argument for the new pass |
| 46 | * manager. Individual passes may be specified, separated by commas. Full |
| 47 | * pipelines may also be invoked using `default<O3>` and friends. See opt for |
| 48 | * full reference of the Passes format. |
| 49 | */ |
| 50 | LLVM_C_ABI LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, |
| 51 | LLVMTargetMachineRef TM, |
| 52 | LLVMPassBuilderOptionsRef Options); |
| 53 | |
| 54 | /** |
| 55 | * Construct and run a set of passes over a function. |
| 56 | * |
| 57 | * This function behaves the same as LLVMRunPasses, but operates on a single |
| 58 | * function instead of an entire module. |
| 59 | */ |
| 60 | LLVM_C_ABI LLVMErrorRef LLVMRunPassesOnFunction( |
| 61 | LLVMValueRef F, const char *Passes, LLVMTargetMachineRef TM, |
| 62 | LLVMPassBuilderOptionsRef Options); |
| 63 | |
| 64 | /** |
| 65 | * Create a new set of options for a PassBuilder |
| 66 | * |
| 67 | * Ownership of the returned instance is given to the client, and they are |
| 68 | * responsible for it. The client should call LLVMDisposePassBuilderOptions |
| 69 | * to free the pass builder options. |
| 70 | */ |
| 71 | LLVM_C_ABI LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void); |
| 72 | |
| 73 | /** |
| 74 | * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions |
| 75 | * inside the module is valid. |
| 76 | */ |
| 77 | LLVM_C_ABI void |
| 78 | LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, |
| 79 | LLVMBool VerifyEach); |
| 80 | |
| 81 | /** |
| 82 | * Toggle debug logging when running the PassBuilder |
| 83 | */ |
| 84 | LLVM_C_ABI void |
| 85 | LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, |
| 86 | LLVMBool DebugLogging); |
| 87 | |
| 88 | /** |
| 89 | * Specify a custom alias analysis pipeline for the PassBuilder to be used |
| 90 | * instead of the default one. The string argument is not copied; the caller |
| 91 | * is responsible for ensuring it outlives the PassBuilderOptions instance. |
| 92 | */ |
| 93 | LLVM_C_ABI void |
| 94 | LLVMPassBuilderOptionsSetAAPipeline(LLVMPassBuilderOptionsRef Options, |
| 95 | const char *AAPipeline); |
| 96 | |
| 97 | LLVM_C_ABI void |
| 98 | LLVMPassBuilderOptionsSetLoopInterleaving(LLVMPassBuilderOptionsRef Options, |
| 99 | LLVMBool LoopInterleaving); |
| 100 | |
| 101 | LLVM_C_ABI void |
| 102 | LLVMPassBuilderOptionsSetLoopVectorization(LLVMPassBuilderOptionsRef Options, |
| 103 | LLVMBool LoopVectorization); |
| 104 | |
| 105 | LLVM_C_ABI void |
| 106 | LLVMPassBuilderOptionsSetSLPVectorization(LLVMPassBuilderOptionsRef Options, |
| 107 | LLVMBool SLPVectorization); |
| 108 | |
| 109 | LLVM_C_ABI void |
| 110 | LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options, |
| 111 | LLVMBool LoopUnrolling); |
| 112 | |
| 113 | LLVM_C_ABI void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll( |
| 114 | LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll); |
| 115 | |
| 116 | LLVM_C_ABI void |
| 117 | LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options, |
| 118 | unsigned LicmMssaOptCap); |
| 119 | |
| 120 | LLVM_C_ABI void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap( |
| 121 | LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap); |
| 122 | |
| 123 | LLVM_C_ABI void |
| 124 | LLVMPassBuilderOptionsSetCallGraphProfile(LLVMPassBuilderOptionsRef Options, |
| 125 | LLVMBool CallGraphProfile); |
| 126 | |
| 127 | LLVM_C_ABI void |
| 128 | LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options, |
| 129 | LLVMBool MergeFunctions); |
| 130 | |
| 131 | LLVM_C_ABI void |
| 132 | LLVMPassBuilderOptionsSetInlinerThreshold(LLVMPassBuilderOptionsRef Options, |
| 133 | int Threshold); |
| 134 | |
| 135 | /** |
| 136 | * Dispose of a heap-allocated PassBuilderOptions instance |
| 137 | */ |
| 138 | LLVM_C_ABI void |
| 139 | LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options); |
| 140 | |
| 141 | /** |
| 142 | * @} |
| 143 | */ |
| 144 | |
| 145 | LLVM_C_EXTERN_C_END |
| 146 | |
| 147 | #endif // LLVM_C_TRANSFORMS_PASSBUILDER_H |
| 148 | |