]> granicus.if.org Git - llvm/commitdiff
DAG: Provide access to Pass instance from SelectionDAG
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 3 Aug 2017 21:54:00 +0000 (21:54 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 3 Aug 2017 21:54:00 +0000 (21:54 +0000)
This allows accessing an analysis pass during lowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309991 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAG.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 56b4e4b7ee61b99024da9d33cf687a94866c1488..bdcc17b2e37eb2f23eb9b736a1495067f732c2ce 100644 (file)
@@ -211,6 +211,7 @@ class SelectionDAG {
   const SelectionDAGTargetInfo *TSI = nullptr;
   const TargetLowering *TLI = nullptr;
   MachineFunction *MF;
+  Pass *SDAGISelPass = nullptr;
   LLVMContext *Context;
   CodeGenOpt::Level OptLevel;
 
@@ -366,13 +367,16 @@ public:
   ~SelectionDAG();
 
   /// Prepare this SelectionDAG to process code in the given MachineFunction.
-  void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE);
+  void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
+            Pass *PassPtr);
 
   /// Clear state and free memory necessary to make this
   /// SelectionDAG ready to process a new block.
   void clear();
 
   MachineFunction &getMachineFunction() const { return *MF; }
+  const Pass *getPass() const { return SDAGISelPass; }
+
   const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
   const TargetMachine &getTarget() const { return TM; }
   const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
index a396f3368cf8583540cb04f61bc53ba15c9a3c15..c052bc64d7d824ce7aeb15718339074b11b9dbe2 100644 (file)
@@ -892,8 +892,10 @@ SelectionDAG::SelectionDAG(const TargetMachine &tm, CodeGenOpt::Level OL)
 }
 
 void SelectionDAG::init(MachineFunction &NewMF,
-                        OptimizationRemarkEmitter &NewORE) {
+                        OptimizationRemarkEmitter &NewORE,
+                        Pass *PassPtr) {
   MF = &NewMF;
+  SDAGISelPass = PassPtr;
   ORE = &NewORE;
   TLI = getSubtarget().getTargetLowering();
   TSI = getSubtarget().getSelectionDAGInfo();
index ed9cb09dccb3f33251cd0205a701e2772d4cf65c..ceab4d7397671f9fed08c0958c7d5601617876ed 100644 (file)
@@ -414,7 +414,7 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
 
   SplitCriticalSideEffectEdges(const_cast<Function &>(Fn), DT, LI);
 
-  CurDAG->init(*MF, *ORE);
+  CurDAG->init(*MF, *ORE, this);
   FuncInfo->set(Fn, *MF, CurDAG);
 
   // Now get the optional analyzes if we want to.