Don't #include <Support/*>, #include "Support/*"
[oota-llvm.git] / lib / Target / SparcV9 / InstrSched / SchedPriorities.h
index 78b685daddec8eb09983d0023906ee9f2468f80f..1366884b580f093b117528b68d4f14e0ffbc2481 100644 (file)
@@ -1,10 +1,4 @@
-// -*-C++-*-
-//***************************************************************************
-// File:
-//     SchedPriorities.h
-// 
-// Purpose:
-//     Encapsulate heuristics for instruction scheduling.
+//===-- SchedPriorities.h - Encapsulate scheduling heuristics --*- C++ -*--===//
 // 
 // Strategy:
 //    Priority ordering rules:
 //    (3) Instruction that has the maximum number of dependent instructions.
 //    Note that rules 2 and 3 are only used if issue conflicts prevent
 //    choosing a higher priority instruction by rule 1.
-// 
-// History:
-//     7/30/01  -  Vikram Adve  -  Created
-//**************************************************************************/
+//
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_CODEGEN_SCHEDPRIORITIES_H
 #define LLVM_CODEGEN_SCHEDPRIORITIES_H
 
 #include "SchedGraph.h"
 #include "llvm/CodeGen/InstrScheduling.h"
-#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "llvm/Target/MachineSchedInfo.h"
-#include "Support/CommandLine.h"
+#include "Support/hash_set"
 #include <list>
 
-class Method;
+class Function;
 class MachineInstr;
 class SchedulingManager;
+class FunctionLiveVarInfo;
 
 //---------------------------------------------------------------------------
 // Debug option levels for instruction scheduling
 
 enum SchedDebugLevel_t {
   Sched_NoDebugInfo,
+  Sched_Disable,
   Sched_PrintMachineCode, 
   Sched_PrintSchedTrace,
   Sched_PrintSchedGraphs,
 };
 
-extern cl::Enum<SchedDebugLevel_t> SchedDebugLevel;
+extern SchedDebugLevel_t SchedDebugLevel;
 
 //---------------------------------------------------------------------------
 // Function: instrIsFeasible
@@ -76,10 +69,9 @@ public:
   typedef std::list<NodeDelayPair*>::const_iterator const_iterator;
   
 public:
-  /*ctor*/       NodeHeap      () : std::list<NodeDelayPair*>(), _size(0) {}
-  /*dtor*/       ~NodeHeap     () {}
+  NodeHeap() : _size(0) {}
   
-  inline unsigned int  size    () const { return _size; }
+  inline unsigned       size() const { return _size; }
   
   const SchedGraphNode* getNode        (const_iterator i) const { return (*i)->node; }
   cycles_t             getDelay(const_iterator i) const { return (*i)->delay;}
@@ -125,8 +117,9 @@ private:
 
 class SchedPriorities: public NonCopyable {
 public:
-  /*ctor*/     SchedPriorities         (const Method* method,
-                                        const SchedGraph* _graph);
+  SchedPriorities(const Function *F, const SchedGraph *G,
+                  FunctionLiveVarInfo &LVI);
+                  
   
   // This must be called before scheduling begins.
   void         initialize              ();
@@ -155,13 +148,14 @@ private:
 private:
   cycles_t curTime;
   const SchedGraph* graph;
-  MethodLiveVarInfo methodLiveVarInfo;
-  std::hash_map<const MachineInstr*, bool> lastUseMap;
+  FunctionLiveVarInfo &methodLiveVarInfo;
+  hash_map<const MachineInstr*, bool> lastUseMap;
   std::vector<cycles_t> nodeDelayVec;
-  std::vector<cycles_t> earliestForNode;
+  std::vector<cycles_t> nodeEarliestUseVec;
+  std::vector<cycles_t> earliestReadyTimeForNode;
   cycles_t earliestReadyTime;
   NodeHeap candsAsHeap;                                // candidate nodes, ready to go
-  std::hash_set<const SchedGraphNode*> candsAsSet;//same entries as candsAsHeap,
+  hash_set<const SchedGraphNode*> candsAsSet;   //same entries as candsAsHeap,
                                                //   but as set for fast lookup
   std::vector<candIndex> mcands;                // holds pointers into cands
   candIndex nextToTry;                         // next cand after the last
@@ -178,18 +172,25 @@ private:
   
   void         initializeReadyHeap     (const SchedGraph* graph);
   
-  bool         instructionHasLastUse   (MethodLiveVarInfo& methodLiveVarInfo,
+  bool         instructionHasLastUse   (FunctionLiveVarInfo& LVI,
                                         const SchedGraphNode* graphNode);
   
   // NOTE: The next two return references to the actual vector entries.
-  //       Use with care.
+  //       Use the following two if you don't need to modify the value.
   cycles_t&    getNodeDelayRef         (const SchedGraphNode* node) {
     assert(node->getNodeId() < nodeDelayVec.size());
     return nodeDelayVec[node->getNodeId()];
   }
-  cycles_t&    getEarliestForNodeRef   (const SchedGraphNode* node) {
-    assert(node->getNodeId() < earliestForNode.size());
-    return earliestForNode[node->getNodeId()];
+  cycles_t&     getEarliestReadyTimeForNodeRef   (const SchedGraphNode* node) {
+    assert(node->getNodeId() < earliestReadyTimeForNode.size());
+    return earliestReadyTimeForNode[node->getNodeId()];
+  }
+  
+  cycles_t      getNodeDelay            (const SchedGraphNode* node) const {
+    return ((SchedPriorities*) this)->getNodeDelayRef(node); 
+  }
+  cycles_t      getEarliestReadyTimeForNode(const SchedGraphNode* node) const {
+    return ((SchedPriorities*) this)->getEarliestReadyTimeForNodeRef(node);
   }
 };