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"
24 * A set of options passed which are attached to the Pass Manager upon run.
26 * This corresponds to an llvm::LLVMPassBuilderOptions instance
28 * The details for how the different properties of this structure are used can
29 * be found in the source for LLVMRunPasses
31 typedef struct LLVMOpaquePassBuilderOptions
*LLVMPassBuilderOptionsRef
;
34 * Construct and run a set of passes over a module
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.
42 LLVMErrorRef
LLVMRunPasses(LLVMModuleRef M
, const char *Passes
,
43 LLVMTargetMachineRef TM
,
44 LLVMPassBuilderOptionsRef Options
);
47 * Create a new set of options for a PassBuilder
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.
53 LLVMPassBuilderOptionsRef
LLVMCreatePassBuilderOptions();
56 * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions
57 * inside the module is valid.
59 void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options
,
63 * Toggle debug logging when running the PassBuilder
65 void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options
,
66 LLVMBool DebugLogging
);
68 void LLVMPassBuilderOptionsSetLoopInterleaving(
69 LLVMPassBuilderOptionsRef Options
, LLVMBool LoopInterleaving
);
71 void LLVMPassBuilderOptionsSetLoopVectorization(
72 LLVMPassBuilderOptionsRef Options
, LLVMBool LoopVectorization
);
74 void LLVMPassBuilderOptionsSetSLPVectorization(
75 LLVMPassBuilderOptionsRef Options
, LLVMBool SLPVectorization
);
77 void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options
,
78 LLVMBool LoopUnrolling
);
80 void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(
81 LLVMPassBuilderOptionsRef Options
, LLVMBool ForgetAllSCEVInLoopUnroll
);
83 void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options
,
84 unsigned LicmMssaOptCap
);
86 void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap(
87 LLVMPassBuilderOptionsRef Options
, unsigned LicmMssaNoAccForPromotionCap
);
89 void LLVMPassBuilderOptionsSetCallGraphProfile(
90 LLVMPassBuilderOptionsRef Options
, LLVMBool CallGraphProfile
);
92 void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options
,
93 LLVMBool MergeFunctions
);
96 * Dispose of a heap-allocated PassBuilderOptions instance
98 void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options
);
102 #endif // LLVM_C_TRANSFORMS_PASSBUILDER_H