LLVM  13.0.0git
InstCombine.h
Go to the documentation of this file.
1 //===- InstCombine.h - InstCombine pass -------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 ///
10 /// This file provides the primary interface to the instcombine pass. This pass
11 /// is suitable for use in the new pass manager. For a pass that works with the
12 /// legacy pass manager, use \c createInstructionCombiningPass().
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINE_H
17 #define LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINE_H
18 
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/PassManager.h"
22 
23 namespace llvm {
24 
25 class InstCombinePass : public PassInfoMixin<InstCombinePass> {
26  InstCombineWorklist Worklist;
27  const unsigned MaxIterations;
28 
29 public:
30  explicit InstCombinePass();
31  explicit InstCombinePass(unsigned MaxIterations);
32 
34 };
35 
36 /// The legacy pass manager's instcombine pass.
37 ///
38 /// This is a basic whole-function wrapper around the instcombine utility. It
39 /// will try to combine all instructions in the function.
41  InstCombineWorklist Worklist;
42  const unsigned MaxIterations;
43 
44 public:
45  static char ID; // Pass identification, replacement for typeid
46 
47  explicit InstructionCombiningPass();
48  explicit InstructionCombiningPass(unsigned MaxIterations);
49 
50  void getAnalysisUsage(AnalysisUsage &AU) const override;
51  bool runOnFunction(Function &F) override;
52 };
53 
54 //===----------------------------------------------------------------------===//
55 //
56 // InstructionCombining - Combine instructions to form fewer, simple
57 // instructions. This pass does not modify the CFG, and has a tendency to make
58 // instructions dead, so a subsequent DCE pass is useful.
59 //
60 // This pass combines things like:
61 // %Y = add int 1, %X
62 // %Z = add int 1, %Y
63 // into:
64 // %Z = add int 2, %X
65 //
67 FunctionPass *createInstructionCombiningPass(unsigned MaxIterations);
68 }
69 
70 #endif
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm
Definition: AllocatorList.h:23
llvm::InstructionCombiningPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: InstructionCombining.cpp:4057
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:61
llvm::InstructionCombiningPass::InstructionCombiningPass
InstructionCombiningPass()
Definition: InstructionCombining.cpp:4101
llvm::InstCombinePass::InstCombinePass
InstCombinePass()
Definition: InstructionCombining.cpp:4024
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
InstCombineWorklist.h
llvm::InstCombineWorklist
InstCombineWorklist - This is the worklist management logic for InstCombine.
Definition: InstCombineWorklist.h:27
llvm::InstructionCombiningPass::ID
static char ID
Definition: InstCombine.h:45
llvm::InstCombinePass
Definition: InstCombine.h:25
llvm::InstructionCombiningPass::runOnFunction
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition: InstructionCombining.cpp:4073
Function.h
PassManager.h
llvm::createInstructionCombiningPass
FunctionPass * createInstructionCombiningPass()
Definition: InstructionCombining.cpp:4134
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
llvm::InstCombinePass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: InstructionCombining.cpp:4029
llvm::InstructionCombiningPass
The legacy pass manager's instcombine pass.
Definition: InstCombine.h:40