Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:00

0001 /*===-- llvm-c/Transform/PassBuilder.h - PassBuilder for LLVM C ---*- C -*-===*\
0002 |*                                                                            *|
0003 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
0004 |* Exceptions.                                                                *|
0005 |* See https://llvm.org/LICENSE.txt for license information.                  *|
0006 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
0007 |*                                                                            *|
0008 |*===----------------------------------------------------------------------===*|
0009 |*                                                                            *|
0010 |* This header contains the LLVM-C interface into the new pass manager        *|
0011 |*                                                                            *|
0012 \*===----------------------------------------------------------------------===*/
0013 
0014 #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H
0015 #define LLVM_C_TRANSFORMS_PASSBUILDER_H
0016 
0017 #include "llvm-c/Error.h"
0018 #include "llvm-c/TargetMachine.h"
0019 #include "llvm-c/Types.h"
0020 
0021 /**
0022  * @defgroup LLVMCCoreNewPM New Pass Manager
0023  * @ingroup LLVMCCore
0024  *
0025  * @{
0026  */
0027 
0028 LLVM_C_EXTERN_C_BEGIN
0029 
0030 /**
0031  * A set of options passed which are attached to the Pass Manager upon run.
0032  *
0033  * This corresponds to an llvm::LLVMPassBuilderOptions instance
0034  *
0035  * The details for how the different properties of this structure are used can
0036  * be found in the source for LLVMRunPasses
0037  */
0038 typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef;
0039 
0040 /**
0041  * Construct and run a set of passes over a module
0042  *
0043  * This function takes a string with the passes that should be used. The format
0044  * of this string is the same as opt's -passes argument for the new pass
0045  * manager. Individual passes may be specified, separated by commas. Full
0046  * pipelines may also be invoked using `default<O3>` and friends. See opt for
0047  * full reference of the Passes format.
0048  */
0049 LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes,
0050                            LLVMTargetMachineRef TM,
0051                            LLVMPassBuilderOptionsRef Options);
0052 
0053 /**
0054  * Construct and run a set of passes over a function.
0055  *
0056  * This function behaves the same as LLVMRunPasses, but operates on a single
0057  * function instead of an entire module.
0058  */
0059 LLVMErrorRef LLVMRunPassesOnFunction(LLVMValueRef F, const char *Passes,
0060                                      LLVMTargetMachineRef TM,
0061                                      LLVMPassBuilderOptionsRef Options);
0062 
0063 /**
0064  * Create a new set of options for a PassBuilder
0065  *
0066  * Ownership of the returned instance is given to the client, and they are
0067  * responsible for it. The client should call LLVMDisposePassBuilderOptions
0068  * to free the pass builder options.
0069  */
0070 LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void);
0071 
0072 /**
0073  * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions
0074  * inside the module is valid.
0075  */
0076 void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options,
0077                                          LLVMBool VerifyEach);
0078 
0079 /**
0080  * Toggle debug logging when running the PassBuilder
0081  */
0082 void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options,
0083                                            LLVMBool DebugLogging);
0084 
0085 /**
0086  * Specify a custom alias analysis pipeline for the PassBuilder to be used
0087  * instead of the default one. The string argument is not copied; the caller
0088  * is responsible for ensuring it outlives the PassBuilderOptions instance.
0089  */
0090 void LLVMPassBuilderOptionsSetAAPipeline(LLVMPassBuilderOptionsRef Options,
0091                                          const char *AAPipeline);
0092 
0093 void LLVMPassBuilderOptionsSetLoopInterleaving(
0094     LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving);
0095 
0096 void LLVMPassBuilderOptionsSetLoopVectorization(
0097     LLVMPassBuilderOptionsRef Options, LLVMBool LoopVectorization);
0098 
0099 void LLVMPassBuilderOptionsSetSLPVectorization(
0100     LLVMPassBuilderOptionsRef Options, LLVMBool SLPVectorization);
0101 
0102 void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options,
0103                                             LLVMBool LoopUnrolling);
0104 
0105 void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(
0106     LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll);
0107 
0108 void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options,
0109                                              unsigned LicmMssaOptCap);
0110 
0111 void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap(
0112     LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap);
0113 
0114 void LLVMPassBuilderOptionsSetCallGraphProfile(
0115     LLVMPassBuilderOptionsRef Options, LLVMBool CallGraphProfile);
0116 
0117 void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options,
0118                                              LLVMBool MergeFunctions);
0119 
0120 void LLVMPassBuilderOptionsSetInlinerThreshold(
0121     LLVMPassBuilderOptionsRef Options, int Threshold);
0122 
0123 /**
0124  * Dispose of a heap-allocated PassBuilderOptions instance
0125  */
0126 void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options);
0127 
0128 /**
0129  * @}
0130  */
0131 
0132 LLVM_C_EXTERN_C_END
0133 
0134 #endif // LLVM_C_TRANSFORMS_PASSBUILDER_H