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 21 LLVM_C_EXTERN_C_BEGIN 22 23 /** 24 * A set of options passed which are attached to the Pass Manager upon run. 25 * 26 * This corresponds to an llvm::LLVMPassBuilderOptions instance 27 * 28 * The details for how the different properties of this structure are used can 29 * be found in the source for LLVMRunPasses 30 */ 31 typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef; 32 33 /** 34 * Construct and run a set of passes over a module 35 * 36 * This function takes a string with the passes that should be used. The format 37 * of this string is the same as opt's -passes argument for the new pass 38 * manager. Individual passes may be specified, separated by commas. Full 39 * pipelines may also be invoked using `default<O3>` and friends. See opt for 40 * full reference of the Passes format. 41 */ 42 LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, 43 LLVMTargetMachineRef TM, 44 LLVMPassBuilderOptionsRef Options); 45 46 /** 47 * Create a new set of options for a PassBuilder 48 * 49 * Ownership of the returned instance is given to the client, and they are 50 * responsible for it. The client should call LLVMDisposePassBuilderOptions 51 * to free the pass builder options. 52 */ 53 LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(); 54 55 /** 56 * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions 57 * inside the module is valid. 58 */ 59 void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, 60 LLVMBool VerifyEach); 61 62 /** 63 * Toggle debug logging when running the PassBuilder 64 */ 65 void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, 66 LLVMBool DebugLogging); 67 68 void LLVMPassBuilderOptionsSetLoopInterleaving( 69 LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving); 70 71 void LLVMPassBuilderOptionsSetLoopVectorization( 72 LLVMPassBuilderOptionsRef Options, LLVMBool LoopVectorization); 73 74 void LLVMPassBuilderOptionsSetSLPVectorization( 75 LLVMPassBuilderOptionsRef Options, LLVMBool SLPVectorization); 76 77 void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options, 78 LLVMBool LoopUnrolling); 79 80 void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll( 81 LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll); 82 83 void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options, 84 unsigned LicmMssaOptCap); 85 86 void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap( 87 LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap); 88 89 void LLVMPassBuilderOptionsSetCallGraphProfile( 90 LLVMPassBuilderOptionsRef Options, LLVMBool CallGraphProfile); 91 92 void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options, 93 LLVMBool MergeFunctions); 94 95 /** 96 * Dispose of a heap-allocated PassBuilderOptions instance 97 */ 98 void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options); 99 100 LLVM_C_EXTERN_C_END 101 102 #endif // LLVM_C_TRANSFORMS_PASSBUILDER_H 103