LLVM  8.0.1
MipsPreLegalizerCombiner.cpp
Go to the documentation of this file.
1 //=== lib/CodeGen/GlobalISel/MipsPreLegalizerCombiner.cpp --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This pass does combining of machine instructions at the generic MI level,
11 // before the legalizer.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "MipsTargetMachine.h"
20 
21 #define DEBUG_TYPE "mips-prelegalizer-combiner"
22 
23 using namespace llvm;
24 
25 namespace {
26 class MipsPreLegalizerCombinerInfo : public CombinerInfo {
27 public:
28  MipsPreLegalizerCombinerInfo()
29  : CombinerInfo(/*AllowIllegalOps*/ true, /*ShouldLegalizeIllegal*/ false,
30  /*LegalizerInfo*/ nullptr) {}
31  virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
32  MachineIRBuilder &B) const override;
33 };
34 
35 bool MipsPreLegalizerCombinerInfo::combine(GISelChangeObserver &Observer,
37  MachineIRBuilder &B) const {
38  return false;
39 }
40 
41 // Pass boilerplate
42 // ================
43 
44 class MipsPreLegalizerCombiner : public MachineFunctionPass {
45 public:
46  static char ID;
47 
48  MipsPreLegalizerCombiner();
49 
50  StringRef getPassName() const override { return "MipsPreLegalizerCombiner"; }
51 
52  bool runOnMachineFunction(MachineFunction &MF) override;
53 
54  void getAnalysisUsage(AnalysisUsage &AU) const override;
55 };
56 } // end anonymous namespace
57 
58 void MipsPreLegalizerCombiner::getAnalysisUsage(AnalysisUsage &AU) const {
60  AU.setPreservesCFG();
63 }
64 
65 MipsPreLegalizerCombiner::MipsPreLegalizerCombiner() : MachineFunctionPass(ID) {
67 }
68 
69 bool MipsPreLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) {
70  if (MF.getProperties().hasProperty(
72  return false;
73  auto *TPC = &getAnalysis<TargetPassConfig>();
74  MipsPreLegalizerCombinerInfo PCInfo;
75  Combiner C(PCInfo, TPC);
76  return C.combineMachineInstrs(MF, nullptr);
77 }
78 
80 INITIALIZE_PASS_BEGIN(MipsPreLegalizerCombiner, DEBUG_TYPE,
81  "Combine Mips machine instrs before legalization", false,
82  false)
84 INITIALIZE_PASS_END(MipsPreLegalizerCombiner, DEBUG_TYPE,
85  "Combine Mips machine instrs before legalization", false,
86  false)
87 
88 namespace llvm {
90  return new MipsPreLegalizerCombiner();
91 }
92 } // end namespace llvm
uint64_t CallInst * C
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
Definition: AllocatorList.h:24
void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
Definition: Utils.cpp:289
const MachineFunctionProperties & getProperties() const
Get the function properties.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:51
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Combine Mips machine instrs before legalization
Target-Independent Code Generator Pass Configuration Options.
Abstract class that contains various methods for clients to notify about changes. ...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Helper class to build MachineInstr.
FunctionPass * createMipsPreLegalizeCombiner()
INITIALIZE_PASS_BEGIN(MipsPreLegalizerCombiner, DEBUG_TYPE, "Combine Mips machine instrs before legalization", false, false) INITIALIZE_PASS_END(MipsPreLegalizerCombiner
Represent the analysis usage information of a pass.
#define DEBUG_TYPE
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:285
bool combineMachineInstrs(MachineFunction &MF, GISelCSEInfo *CSEInfo)
If CSEInfo is not null, then the Combiner will setup observer for CSEInfo and instantiate a CSEMIRBui...
Definition: Combiner.cpp:87
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:286
Representation of each machine instruction.
Definition: MachineInstr.h:64
bool hasProperty(Property P) const
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
void initializeMipsPreLegalizerCombinerPass(PassRegistry &)