1 /*===-- llvm-c/Transform/PassBuilder.h - PassBuilder for LLVM C ---*- C -*-===*\
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
8 |*===----------------------------------------------------------------------===*|
10 |* This header contains the LLVM-C interface into the new pass manager *|
12 \*===----------------------------------------------------------------------===*/
14 #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H
15 #define LLVM_C_TRANSFORMS_PASSBUILDER_H
17 #include "llvm-c/Error.h"
18 #include "llvm-c/TargetMachine.h"
19 #include "llvm-c/Types.h"
22 * @defgroup LLVMCCoreNewPM New Pass Manager
31 * A set of options passed which are attached to the Pass Manager upon run.
33 * This corresponds to an llvm::LLVMPassBuilderOptions instance
35 * The details for how the different properties of this structure are used can
36 * be found in the source for LLVMRunPasses
38 typedef struct LLVMOpaquePassBuilderOptions
*LLVMPassBuilderOptionsRef
;
41 * Construct and run a set of passes over a module
43 * This function takes a string with the passes that should be used. The format
44 * of this string is the same as opt's -passes argument for the new pass
45 * manager. Individual passes may be specified, separated by commas. Full
46 * pipelines may also be invoked using `default<O3>` and friends. See opt for
47 * full reference of the Passes format.
49 LLVMErrorRef
LLVMRunPasses(LLVMModuleRef M
, const char *Passes
,
50 LLVMTargetMachineRef TM
,
51 LLVMPassBuilderOptionsRef Options
);
54 * Create a new set of options for a PassBuilder
56 * Ownership of the returned instance is given to the client, and they are
57 * responsible for it. The client should call LLVMDisposePassBuilderOptions
58 * to free the pass builder options.
60 LLVMPassBuilderOptionsRef
LLVMCreatePassBuilderOptions(void);
63 * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions
64 * inside the module is valid.
66 void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options
,
70 * Toggle debug logging when running the PassBuilder
72 void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options
,
73 LLVMBool DebugLogging
);
75 void LLVMPassBuilderOptionsSetLoopInterleaving(
76 LLVMPassBuilderOptionsRef Options
, LLVMBool LoopInterleaving
);
78 void LLVMPassBuilderOptionsSetLoopVectorization(
79 LLVMPassBuilderOptionsRef Options
, LLVMBool LoopVectorization
);
81 void LLVMPassBuilderOptionsSetSLPVectorization(
82 LLVMPassBuilderOptionsRef Options
, LLVMBool SLPVectorization
);
84 void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options
,
85 LLVMBool LoopUnrolling
);
87 void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(
88 LLVMPassBuilderOptionsRef Options
, LLVMBool ForgetAllSCEVInLoopUnroll
);
90 void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options
,
91 unsigned LicmMssaOptCap
);
93 void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap(
94 LLVMPassBuilderOptionsRef Options
, unsigned LicmMssaNoAccForPromotionCap
);
96 void LLVMPassBuilderOptionsSetCallGraphProfile(
97 LLVMPassBuilderOptionsRef Options
, LLVMBool CallGraphProfile
);
99 void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options
,
100 LLVMBool MergeFunctions
);
102 void LLVMPassBuilderOptionsSetInlinerThreshold(
103 LLVMPassBuilderOptionsRef Options
, int Threshold
);
106 * Dispose of a heap-allocated PassBuilderOptions instance
108 void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options
);
116 #endif // LLVM_C_TRANSFORMS_PASSBUILDER_H