[llvm-commits] CVS: llvm/include/llvm/CodeGen/SchedGraphCommon.h

Tanya Brethour tbrethou at cs.uiuc.edu
Tue Aug 26 21:46:01 PDT 2003


Changes in directory llvm/include/llvm/CodeGen:

SchedGraphCommon.h updated: 1.1 -> 1.2

---
Log message:

Cleaned up the code (spacing, not needed headers) and changed ostream function. Also made some functions inline.


---
Diffs of the changes:

Index: llvm/include/llvm/CodeGen/SchedGraphCommon.h
diff -u llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.1 llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.2
--- llvm/include/llvm/CodeGen/SchedGraphCommon.h:1.1	Mon Aug 25 18:12:23 2003
+++ llvm/include/llvm/CodeGen/SchedGraphCommon.h	Tue Aug 26 21:45:08 2003
@@ -8,11 +8,8 @@
 #ifndef LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
 #define LLVM_CODEGEN_SCHEDGRAPHCOMMON_H
 
-#include <iostream>
-#include <vector>
 #include "llvm/Value.h"
 
-
 class SchedGraphEdge;
 class SchedGraphNode;
 
@@ -24,8 +21,8 @@
 const ResourceId MachineIntRegsRID = -3; // use +ve numbers for actual regs
 const ResourceId MachineFPRegsRID  = -4; // use +ve numbers for actual regs
 
-//*********************** Public Class Declarations ************************/
 
+//*********************** Public Class Declarations ************************/
 class SchedGraphNodeCommon {
 protected:
   unsigned ID;
@@ -33,59 +30,67 @@
   std::vector<SchedGraphEdge*> outEdges;
   int latency;
 
-  friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node);
-  
 public:
-  typedef std::vector<SchedGraphEdge*>::      iterator	       iterator;
-  typedef std::vector<SchedGraphEdge*>::const_iterator         const_iterator;
-  typedef std::vector<SchedGraphEdge*>::      reverse_iterator reverse_iterator;
+  typedef std::vector<SchedGraphEdge*>::iterator iterator;
+  typedef std::vector<SchedGraphEdge*>::const_iterator const_iterator;
+  typedef std::vector<SchedGraphEdge*>::reverse_iterator reverse_iterator;
   typedef std::vector<SchedGraphEdge*>::const_reverse_iterator const_reverse_iterator;
   
   // Accessor methods
-  unsigned 		getNodeId	() const { return ID; }
-  int			getLatency	() const { return latency; }
-  unsigned 		getNumInEdges	() const { return inEdges.size(); }
-  unsigned 		getNumOutEdges	() const { return outEdges.size(); }
+  unsigned getNodeId() const { return ID; }
+  int getLatency() const { return latency; }
+  unsigned getNumInEdges() const { return inEdges.size(); }
+  unsigned getNumOutEdges() const { return outEdges.size(); }
   
 
   // Iterators
-  iterator		beginInEdges	()	 { return inEdges.begin(); }
-  iterator		endInEdges	()	 { return inEdges.end(); }
-  iterator		beginOutEdges	()	 { return outEdges.begin(); }
-  iterator		endOutEdges	()	 { return outEdges.end(); }
-  
-  const_iterator	beginInEdges	() const { return inEdges.begin(); }
-  const_iterator	endInEdges	() const { return inEdges.end(); }
-  const_iterator	beginOutEdges	() const { return outEdges.begin(); }
-  const_iterator	endOutEdges	() const { return outEdges.end(); }
+  iterator beginInEdges() { return inEdges.begin(); }
+  iterator endInEdges()	 { return inEdges.end(); }
+  iterator beginOutEdges() { return outEdges.begin(); }
+  iterator endOutEdges() { return outEdges.end(); }
+  
+  const_iterator beginInEdges() const { return inEdges.begin(); }
+  const_iterator endInEdges() const { return inEdges.end(); }
+  const_iterator beginOutEdges() const { return outEdges.begin(); }
+  const_iterator endOutEdges() const { return outEdges.end(); }
 
+  void dump(int indent=0) const;
 
   // Debugging support
-  friend std::ostream& operator<<(std::ostream& os, const SchedGraphNodeCommon& node);
-
-  void		dump	(int indent=0) const;
-
+  virtual void print(std::ostream &os) const = 0;
+  
 protected:
   friend class SchedGraph;		
   friend class SchedGraphCommon;
   friend class SchedGraphEdge;		// give access for adding edges
-  //friend class ModuloSchedGraph;
   
-  void			addInEdge	(SchedGraphEdge* edge);
-  void			addOutEdge	(SchedGraphEdge* edge);
   
-  void			removeInEdge	(const SchedGraphEdge* edge);
-  void			removeOutEdge	(const SchedGraphEdge* edge);
- 
   // disable default constructor and provide a ctor for single-block graphs
   SchedGraphNodeCommon();	// DO NOT IMPLEMENT
   
-  SchedGraphNodeCommon(unsigned Id);
-  
+  inline SchedGraphNodeCommon(unsigned Id) : ID(Id), latency(0) {}
   virtual ~SchedGraphNodeCommon();
+  
+  //Functions to add and remove edges
+  inline void addInEdge(SchedGraphEdge* edge) { inEdges.push_back(edge); }
+  inline void addOutEdge(SchedGraphEdge* edge) { outEdges.push_back(edge); }
+  void removeInEdge(const SchedGraphEdge* edge);
+  void removeOutEdge(const SchedGraphEdge* edge);
 };
 
+// ostream << operator for SchedGraphNode class
+inline std::ostream &operator<<(std::ostream &os, 
+				const SchedGraphNodeCommon &node) {
+  node.print(os);
+  return os;
+}
+
+
 
+
+//
+// SchedGraphEdge - Edge class to represent dependencies
+//
 class SchedGraphEdge {
 public:
   enum SchedGraphEdgeDepType {
@@ -99,117 +104,107 @@
   SchedGraphNodeCommon*	src;
   SchedGraphNodeCommon*	sink;
   SchedGraphEdgeDepType depType;
-  unsigned int          depOrderType;
-  int			minDelay; // cached latency (assumes fixed target arch)
-  int                   iteDiff;
+  unsigned int depOrderType;
+  int minDelay; // cached latency (assumes fixed target arch)
+  int iteDiff;
   
   union {
     const Value* val;
     int          machineRegNum;
     ResourceId   resourceId;
   };
-  
+
 public:	
   // For all constructors, if minDelay is unspecified, minDelay is
   // set to _src->getLatency().
+  
   // constructor for CtrlDep or MemoryDep edges, selected by 3rd argument
-  /*ctor*/		SchedGraphEdge(SchedGraphNodeCommon* _src,
-				       SchedGraphNodeCommon* _sink,
-				       SchedGraphEdgeDepType _depType,
-				       unsigned int     _depOrderType,
-				       int _minDelay = -1);
+  SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
+		 SchedGraphEdgeDepType _depType, unsigned int _depOrderType,
+		 int _minDelay = -1);
   
   // constructor for explicit value dependence (may be true/anti/output)
-  /*ctor*/		SchedGraphEdge(SchedGraphNodeCommon* _src,
-				       SchedGraphNodeCommon* _sink,
-				       const Value*    _val,
-				       unsigned int     _depOrderType,
-				       int _minDelay = -1);
+  SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
+		 const Value* _val, unsigned int _depOrderType,
+		 int _minDelay = -1);
   
   // constructor for machine register dependence
-  /*ctor*/		SchedGraphEdge(SchedGraphNodeCommon* _src,
-				       SchedGraphNodeCommon* _sink,
-				       unsigned int    _regNum,
-				       unsigned int     _depOrderType,
-				       int _minDelay = -1);
+  SchedGraphEdge(SchedGraphNodeCommon* _src,SchedGraphNodeCommon* _sink,
+		 unsigned int _regNum, unsigned int _depOrderType,
+		 int _minDelay = -1);
   
   // constructor for any other machine resource dependences.
   // DataDepOrderType is always NonDataDep.  It it not an argument to
   // avoid overloading ambiguity with previous constructor.
-  /*ctor*/		SchedGraphEdge(SchedGraphNodeCommon* _src,
-				       SchedGraphNodeCommon* _sink,
-				       ResourceId      _resourceId,
-				       int _minDelay = -1);
-  
-  /*dtor*/		~SchedGraphEdge();
-  
-  SchedGraphNodeCommon*	getSrc		() const { return src; }
-  SchedGraphNodeCommon*	getSink		() const { return sink; }
-  int			getMinDelay	() const { return minDelay; }
-  SchedGraphEdgeDepType getDepType	() const { return depType; }
+  SchedGraphEdge(SchedGraphNodeCommon* _src, SchedGraphNodeCommon* _sink,
+		 ResourceId _resourceId, int _minDelay = -1);
   
-  const Value*		getValue	() const {
+  ~SchedGraphEdge();
+  
+  SchedGraphNodeCommon*	getSrc() const { return src; }
+  SchedGraphNodeCommon*	getSink() const { return sink; }
+  int getMinDelay() const { return minDelay; }
+  SchedGraphEdgeDepType getDepType() const { return depType; }
+  
+  const Value* getValue() const {
     assert(depType == ValueDep); return val;
   }
-  int			getMachineReg	() const {
+
+  int getMachineReg() const {
     assert(depType == MachineRegister); return machineRegNum;
   }
-  int			getResourceId	() const {
+
+  int getResourceId() const {
     assert(depType == MachineResource); return resourceId;
   }
-  void                  setIteDiff      (int _iteDiff) {
+
+  void setIteDiff(int _iteDiff) {
     iteDiff = _iteDiff;
   }
-  int                   getIteDiff      (){
+
+  int getIteDiff() {
     return iteDiff;
   }
   
 public:
-  // 
   // Debugging support
-  // 
-  friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge);
-  
-  void		dump	(int indent=0) const;
+  void print(std::ostream &os) const;
+  void dump(int indent=0) const;
     
 private:
   // disable default ctor
-  /*ctor*/		SchedGraphEdge();	// DO NOT IMPLEMENT
+  SchedGraphEdge();	// DO NOT IMPLEMENT
 };
 
+// ostream << operator for SchedGraphNode class
+inline std::ostream &operator<<(std::ostream &os, const SchedGraphEdge &edge) {
+  edge.print(os);
+  return os;
+}
 
 class SchedGraphCommon {
   
 protected:
-  SchedGraphNodeCommon* graphRoot;		// the root and leaf are not inserted
-  SchedGraphNodeCommon* graphLeaf;		//  in the hash_map (see getNumNodes())
+  SchedGraphNodeCommon* graphRoot;     // the root and leaf are not inserted
+  SchedGraphNodeCommon* graphLeaf;     //  in the hash_map (see getNumNodes())
 
 public:
   //
   // Accessor methods
   //
-  SchedGraphNodeCommon*		   getRoot()	    const { return graphRoot; }
-  SchedGraphNodeCommon*		   getLeaf()	    const { return graphLeaf; } 
+  SchedGraphNodeCommon* getRoot() const { return graphRoot; }
+  SchedGraphNodeCommon* getLeaf() const { return graphLeaf; } 
  
   //
   // Delete nodes or edges from the graph.
   // 
-  void		eraseNode		(SchedGraphNodeCommon* node);
-  
-  void		eraseIncomingEdges	(SchedGraphNodeCommon* node,
-					 bool addDummyEdges = true);
-  
-  void		eraseOutgoingEdges	(SchedGraphNodeCommon* node,
-					 bool addDummyEdges = true);
-  
-  void		eraseIncidentEdges	(SchedGraphNodeCommon* node,
-					 bool addDummyEdges = true);
+  void eraseNode(SchedGraphNodeCommon* node);
+  void eraseIncomingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
+  void eraseOutgoingEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
+  void eraseIncidentEdges(SchedGraphNodeCommon* node, bool addDummyEdges = true);
   
-  /*ctor*/	SchedGraphCommon		();
-  /*dtor*/	~SchedGraphCommon		();
-
+  SchedGraphCommon();
+  ~SchedGraphCommon();
 };
-
-
 
 #endif





More information about the llvm-commits mailing list