Added LLVM project notice to the top of every C++ source file.
[oota-llvm.git] / lib / CodeGen / InstrSched / SchedPriorities.cpp
index 8a1c9a534842bfa52d71bc00ad914d87d6bad7a6..a35600c0f0e16383731bb638e26b5a757075747f 100644 (file)
@@ -1,10 +1,11 @@
-// $Id$ -*-C++-*-
-//***************************************************************************
-// File:
-//     SchedPriorities.h
+//===-- SchedPriorities.h - Encapsulate scheduling heuristics -------------===//
 // 
-// Purpose:
-//     Encapsulate heuristics for instruction scheduling.
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 // 
 // 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
-//**************************************************************************/
+//
+//===----------------------------------------------------------------------===//
 
 #include "SchedPriorities.h"
-#include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h"
+#include "llvm/CodeGen/FunctionLiveVarInfo.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/Support/CFG.h"
 #include "Support/PostOrderIterator.h"
 using std::cerr;
 
+std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd) {
+  return os << "Delay for node " << nd->node->getNodeId()
+           << " = " << (long)nd->delay << "\n";
+}
+
+
 SchedPriorities::SchedPriorities(const Function *, const SchedGraph *G,
                                  FunctionLiveVarInfo &LVI)
   : curTime(0), graph(G), methodLiveVarInfo(LVI),
@@ -60,7 +66,7 @@ SchedPriorities::computeDelays(const SchedGraph* graph)
          for (SchedGraphNode::const_iterator E=node->beginOutEdges();
               E != node->endOutEdges(); ++E)
            {
-             cycles_t sinkDelay = getNodeDelay((*E)->getSink());
+             cycles_t sinkDelay = getNodeDelay((SchedGraphNode*)(*E)->getSink());
              nodeDelay = std::max(nodeDelay, sinkDelay + (*E)->getMinDelay());
            }
        }
@@ -72,7 +78,7 @@ SchedPriorities::computeDelays(const SchedGraph* graph)
 void
 SchedPriorities::initializeReadyHeap(const SchedGraph* graph)
 {
-  const SchedGraphNode* graphRoot = graph->getRoot();
+  const SchedGraphNode* graphRoot = (const SchedGraphNode*)graph->getRoot();
   assert(graphRoot->getMachineInstr() == NULL && "Expect dummy root");
   
   // Insert immediate successors of dummy root, which are the actual roots
@@ -138,7 +144,7 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime,
   for (SchedGraphNode::const_iterator E=node->beginOutEdges();
        E != node->endOutEdges(); ++E)
     {
-      cycles_t& etime = getEarliestReadyTimeForNodeRef((*E)->getSink());
+      cycles_t& etime = getEarliestReadyTimeForNodeRef((SchedGraphNode*)(*E)->getSink());
       etime = std::max(etime, curTime + (*E)->getMinDelay());
     }    
 }
@@ -270,14 +276,14 @@ SchedPriorities::instructionHasLastUse(FunctionLiveVarInfo &LVI,
                                       const SchedGraphNode* graphNode) {
   const MachineInstr *MI = graphNode->getMachineInstr();
   
-  std::hash_map<const MachineInstr*, bool>::const_iterator
+  hash_map<const MachineInstr*, bool>::const_iterator
     ui = lastUseMap.find(MI);
   if (ui != lastUseMap.end())
     return ui->second;
   
   // else check if instruction is a last use and save it in the hash_map
   bool hasLastUse = false;
-  const BasicBlock* bb = graphNode->getBB();
+  const BasicBlock* bb = graphNode->getMachineBasicBlock().getBasicBlock();
   const ValueSet &LVs = LVI.getLiveVarSetBeforeMInst(MI, bb);
   
   for (MachineInstr::const_val_op_iterator OI = MI->begin(), OE = MI->end();