1fe6060f1SDimitry Andric /*===-- llvm-c/Transform/PassBuilder.h - PassBuilder for LLVM C ---*- C -*-===*\ 2fe6060f1SDimitry Andric |* *| 3fe6060f1SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 4fe6060f1SDimitry Andric |* Exceptions. *| 5fe6060f1SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information. *| 6fe6060f1SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7fe6060f1SDimitry Andric |* *| 8fe6060f1SDimitry Andric |*===----------------------------------------------------------------------===*| 9fe6060f1SDimitry Andric |* *| 10fe6060f1SDimitry Andric |* This header contains the LLVM-C interface into the new pass manager *| 11fe6060f1SDimitry Andric |* *| 12fe6060f1SDimitry Andric \*===----------------------------------------------------------------------===*/ 13fe6060f1SDimitry Andric 14fe6060f1SDimitry Andric #ifndef LLVM_C_TRANSFORMS_PASSBUILDER_H 15fe6060f1SDimitry Andric #define LLVM_C_TRANSFORMS_PASSBUILDER_H 16fe6060f1SDimitry Andric 17fe6060f1SDimitry Andric #include "llvm-c/Error.h" 18fe6060f1SDimitry Andric #include "llvm-c/TargetMachine.h" 19fe6060f1SDimitry Andric #include "llvm-c/Types.h" 20fe6060f1SDimitry Andric 21349cc55cSDimitry Andric /** 22349cc55cSDimitry Andric * @defgroup LLVMCCoreNewPM New Pass Manager 23349cc55cSDimitry Andric * @ingroup LLVMCCore 24349cc55cSDimitry Andric * 25349cc55cSDimitry Andric * @{ 26349cc55cSDimitry Andric */ 27349cc55cSDimitry Andric 28fe6060f1SDimitry Andric LLVM_C_EXTERN_C_BEGIN 29fe6060f1SDimitry Andric 30fe6060f1SDimitry Andric /** 31fe6060f1SDimitry Andric * A set of options passed which are attached to the Pass Manager upon run. 32fe6060f1SDimitry Andric * 33fe6060f1SDimitry Andric * This corresponds to an llvm::LLVMPassBuilderOptions instance 34fe6060f1SDimitry Andric * 35fe6060f1SDimitry Andric * The details for how the different properties of this structure are used can 36fe6060f1SDimitry Andric * be found in the source for LLVMRunPasses 37fe6060f1SDimitry Andric */ 38fe6060f1SDimitry Andric typedef struct LLVMOpaquePassBuilderOptions *LLVMPassBuilderOptionsRef; 39fe6060f1SDimitry Andric 40fe6060f1SDimitry Andric /** 41fe6060f1SDimitry Andric * Construct and run a set of passes over a module 42fe6060f1SDimitry Andric * 43fe6060f1SDimitry Andric * This function takes a string with the passes that should be used. The format 44fe6060f1SDimitry Andric * of this string is the same as opt's -passes argument for the new pass 45fe6060f1SDimitry Andric * manager. Individual passes may be specified, separated by commas. Full 46fe6060f1SDimitry Andric * pipelines may also be invoked using `default<O3>` and friends. See opt for 47fe6060f1SDimitry Andric * full reference of the Passes format. 48fe6060f1SDimitry Andric */ 49fe6060f1SDimitry Andric LLVMErrorRef LLVMRunPasses(LLVMModuleRef M, const char *Passes, 50fe6060f1SDimitry Andric LLVMTargetMachineRef TM, 51fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options); 52fe6060f1SDimitry Andric 53fe6060f1SDimitry Andric /** 54fe6060f1SDimitry Andric * Create a new set of options for a PassBuilder 55fe6060f1SDimitry Andric * 56fe6060f1SDimitry Andric * Ownership of the returned instance is given to the client, and they are 57fe6060f1SDimitry Andric * responsible for it. The client should call LLVMDisposePassBuilderOptions 58fe6060f1SDimitry Andric * to free the pass builder options. 59fe6060f1SDimitry Andric */ 60349cc55cSDimitry Andric LLVMPassBuilderOptionsRef LLVMCreatePassBuilderOptions(void); 61fe6060f1SDimitry Andric 62fe6060f1SDimitry Andric /** 63fe6060f1SDimitry Andric * Toggle adding the VerifierPass for the PassBuilder, ensuring all functions 64fe6060f1SDimitry Andric * inside the module is valid. 65fe6060f1SDimitry Andric */ 66fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetVerifyEach(LLVMPassBuilderOptionsRef Options, 67fe6060f1SDimitry Andric LLVMBool VerifyEach); 68fe6060f1SDimitry Andric 69fe6060f1SDimitry Andric /** 70fe6060f1SDimitry Andric * Toggle debug logging when running the PassBuilder 71fe6060f1SDimitry Andric */ 72fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetDebugLogging(LLVMPassBuilderOptionsRef Options, 73fe6060f1SDimitry Andric LLVMBool DebugLogging); 74fe6060f1SDimitry Andric 75fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetLoopInterleaving( 76fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options, LLVMBool LoopInterleaving); 77fe6060f1SDimitry Andric 78fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetLoopVectorization( 79fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options, LLVMBool LoopVectorization); 80fe6060f1SDimitry Andric 81fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetSLPVectorization( 82fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options, LLVMBool SLPVectorization); 83fe6060f1SDimitry Andric 84fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetLoopUnrolling(LLVMPassBuilderOptionsRef Options, 85fe6060f1SDimitry Andric LLVMBool LoopUnrolling); 86fe6060f1SDimitry Andric 87fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetForgetAllSCEVInLoopUnroll( 88fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options, LLVMBool ForgetAllSCEVInLoopUnroll); 89fe6060f1SDimitry Andric 90fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetLicmMssaOptCap(LLVMPassBuilderOptionsRef Options, 91fe6060f1SDimitry Andric unsigned LicmMssaOptCap); 92fe6060f1SDimitry Andric 93fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetLicmMssaNoAccForPromotionCap( 94fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options, unsigned LicmMssaNoAccForPromotionCap); 95fe6060f1SDimitry Andric 96fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetCallGraphProfile( 97fe6060f1SDimitry Andric LLVMPassBuilderOptionsRef Options, LLVMBool CallGraphProfile); 98fe6060f1SDimitry Andric 99fe6060f1SDimitry Andric void LLVMPassBuilderOptionsSetMergeFunctions(LLVMPassBuilderOptionsRef Options, 100fe6060f1SDimitry Andric LLVMBool MergeFunctions); 101fe6060f1SDimitry Andric 102*06c3fb27SDimitry Andric void LLVMPassBuilderOptionsSetInlinerThreshold( 103*06c3fb27SDimitry Andric LLVMPassBuilderOptionsRef Options, int Threshold); 104*06c3fb27SDimitry Andric 105fe6060f1SDimitry Andric /** 106fe6060f1SDimitry Andric * Dispose of a heap-allocated PassBuilderOptions instance 107fe6060f1SDimitry Andric */ 108fe6060f1SDimitry Andric void LLVMDisposePassBuilderOptions(LLVMPassBuilderOptionsRef Options); 109fe6060f1SDimitry Andric 110349cc55cSDimitry Andric /** 111349cc55cSDimitry Andric * @} 112349cc55cSDimitry Andric */ 113349cc55cSDimitry Andric 114fe6060f1SDimitry Andric LLVM_C_EXTERN_C_END 115fe6060f1SDimitry Andric 116fe6060f1SDimitry Andric #endif // LLVM_C_TRANSFORMS_PASSBUILDER_H 117