148 lines · c
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_H15#define LLVM_C_TRANSFORMS_PASSBUILDER_H16 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 Manager24 * @ingroup LLVMCCore25 *26 * @{27 */28 29LLVM_C_EXTERN_C_BEGIN30 31/**32 * A set of options passed which are attached to the Pass Manager upon run.33 *34 * This corresponds to an llvm::LLVMPassBuilderOptions instance35 *36 * The details for how the different properties of this structure are used can37 * be found in the source for LLVMRunPasses38 */39typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef;40 41/**42 * Construct and run a set of passes over a module43 *44 * This function takes a string with the passes that should be used. The format45 * of this string is the same as opt's -passes argument for the new pass46 * manager. Individual passes may be specified, separated by commas. Full47 * pipelines may also be invoked using `default<O3>` and friends. See opt for48 * full reference of the Passes format.49 */50LLVM_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 single58 * function instead of an entire module.59 */60LLVM_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 PassBuilder66 *67 * Ownership of the returned instance is given to the client, and they are68 * responsible for it. The client should call LLVMDisposePassBuilderOptions69 * to free the pass builder options.70 */71LLVM_C_ABI LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void);72 73/**74 * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions75 * inside the module is valid.76 */77LLVM_C_ABI void78LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options,79 LLVMBool VerifyEach);80 81/**82 * Toggle debug logging when running the PassBuilder83 */84LLVM_C_ABI void85LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options,86 LLVMBool DebugLogging);87 88/**89 * Specify a custom alias analysis pipeline for the PassBuilder to be used90 * instead of the default one. The string argument is not copied; the caller91 * is responsible for ensuring it outlives the PassBuilderOptions instance.92 */93LLVM_C_ABI void94LLVMPassBuilderOptionsSetAAPipeline(LLVMPassBuilderOptionsRef Options,95 const char *AAPipeline);96 97LLVM_C_ABI void98LLVMPassBuilderOptionsSetLoopInterleaving(LLVMPassBuilderOptionsRef Options,99 LLVMBool LoopInterleaving);100 101LLVM_C_ABI void102LLVMPassBuilderOptionsSetLoopVectorization(LLVMPassBuilderOptionsRef Options,103 LLVMBool LoopVectorization);104 105LLVM_C_ABI void106LLVMPassBuilderOptionsSetSLPVectorization(LLVMPassBuilderOptionsRef Options,107 LLVMBool SLPVectorization);108 109LLVM_C_ABI void110LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options,111 LLVMBool LoopUnrolling);112 113LLVM_C_ABI void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll(114 LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll);115 116LLVM_C_ABI void117LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options,118 unsigned LicmMssaOptCap);119 120LLVM_C_ABI void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap(121 LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap);122 123LLVM_C_ABI void124LLVMPassBuilderOptionsSetCallGraphProfile(LLVMPassBuilderOptionsRef Options,125 LLVMBool CallGraphProfile);126 127LLVM_C_ABI void128LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options,129 LLVMBool MergeFunctions);130 131LLVM_C_ABI void132LLVMPassBuilderOptionsSetInlinerThreshold(LLVMPassBuilderOptionsRef Options,133 int Threshold);134 135/**136 * Dispose of a heap-allocated PassBuilderOptions instance137 */138LLVM_C_ABI void139LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options);140 141/**142 * @}143 */144 145LLVM_C_EXTERN_C_END146 147#endif // LLVM_C_TRANSFORMS_PASSBUILDER_H148