File indexing completed on 2026-05-10 08:44:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINE_H
0017 #define LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINE_H
0018
0019 #include "llvm/IR/Function.h"
0020 #include "llvm/IR/PassManager.h"
0021 #include "llvm/Pass.h"
0022
0023 #define DEBUG_TYPE "instcombine"
0024 #include "llvm/Transforms/Utils/InstructionWorklist.h"
0025
0026 namespace llvm {
0027
0028 static constexpr unsigned InstCombineDefaultMaxIterations = 1;
0029
0030 struct InstCombineOptions {
0031
0032 bool VerifyFixpoint = false;
0033 unsigned MaxIterations = InstCombineDefaultMaxIterations;
0034
0035 InstCombineOptions() = default;
0036
0037 InstCombineOptions &setVerifyFixpoint(bool Value) {
0038 VerifyFixpoint = Value;
0039 return *this;
0040 }
0041
0042 InstCombineOptions &setMaxIterations(unsigned Value) {
0043 MaxIterations = Value;
0044 return *this;
0045 }
0046 };
0047
0048 class InstCombinePass : public PassInfoMixin<InstCombinePass> {
0049 private:
0050 InstructionWorklist Worklist;
0051 InstCombineOptions Options;
0052 static char ID;
0053
0054 public:
0055 explicit InstCombinePass(InstCombineOptions Opts = {});
0056 void printPipeline(raw_ostream &OS,
0057 function_ref<StringRef(StringRef)> MapClassName2PassName);
0058
0059 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0060 };
0061
0062
0063
0064
0065
0066 class InstructionCombiningPass : public FunctionPass {
0067 InstructionWorklist Worklist;
0068
0069 public:
0070 static char ID;
0071
0072 explicit InstructionCombiningPass();
0073
0074 void getAnalysisUsage(AnalysisUsage &AU) const override;
0075 bool runOnFunction(Function &F) override;
0076 };
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 FunctionPass *createInstructionCombiningPass();
0091 }
0092
0093 #undef DEBUG_TYPE
0094
0095 #endif