LLVM  16.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"
21 #include "llvm/Pass.h"
22 
23 #define DEBUG_TYPE "instcombine"
25 
26 namespace llvm {
27 
28 class InstCombinePass : public PassInfoMixin<InstCombinePass> {
29  InstructionWorklist Worklist;
30  const unsigned MaxIterations;
31 
32 public:
33  explicit InstCombinePass();
34  explicit InstCombinePass(unsigned MaxIterations);
35 
37 };
38 
39 /// The legacy pass manager's instcombine pass.
40 ///
41 /// This is a basic whole-function wrapper around the instcombine utility. It
42 /// will try to combine all instructions in the function.
44  InstructionWorklist Worklist;
45  const unsigned MaxIterations;
46 
47 public:
48  static char ID; // Pass identification, replacement for typeid
49 
50  explicit InstructionCombiningPass();
51  explicit InstructionCombiningPass(unsigned MaxIterations);
52 
53  void getAnalysisUsage(AnalysisUsage &AU) const override;
54  bool runOnFunction(Function &F) override;
55 };
56 
57 //===----------------------------------------------------------------------===//
58 //
59 // InstructionCombining - Combine instructions to form fewer, simple
60 // instructions. This pass does not modify the CFG, and has a tendency to make
61 // instructions dead, so a subsequent DCE pass is useful.
62 //
63 // This pass combines things like:
64 // %Y = add int 1, %X
65 // %Z = add int 1, %Y
66 // into:
67 // %Z = add int 2, %X
68 //
70 FunctionPass *createInstructionCombiningPass(unsigned MaxIterations);
71 }
72 
73 #undef DEBUG_TYPE
74 
75 #endif
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:4645
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
llvm::Function
Definition: Function.h:60
Pass.h
llvm::InstructionCombiningPass::InstructionCombiningPass
InstructionCombiningPass()
Definition: InstructionCombining.cpp:4689
llvm::InstCombinePass::InstCombinePass
InstCombinePass()
Definition: InstructionCombining.cpp:4612
F
#define F(x, y, z)
Definition: MD5.cpp:55
InstructionWorklist.h
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::InstructionCombiningPass::ID
static char ID
Definition: InstCombine.h:48
llvm::InstCombinePass
Definition: InstCombine.h:28
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:4661
Function.h
PassManager.h
llvm::InstructionWorklist
InstructionWorklist - This is the worklist management logic for InstCombine and other simplification ...
Definition: InstructionWorklist.h:25
llvm::createInstructionCombiningPass
FunctionPass * createInstructionCombiningPass()
Definition: InstructionCombining.cpp:4722
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
llvm::InstCombinePass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: InstructionCombining.cpp:4617
llvm::InstructionCombiningPass
The legacy pass manager's instcombine pass.
Definition: InstCombine.h:43