Added LLVM copyright header.
[oota-llvm.git] / lib / Target / SparcV9 / RegAlloc / InterferenceGraph.h
1 /* Title:   InterferenceGraph.h   -*- C++ -*-
2    Author:  Ruchira Sasanka
3    Date:    July 20, 01
4    Purpose: Interference Graph used for register coloring.
5
6    Notes: 
7    Adj Info is  stored in the lower trangular matrix (i.e., row > col ) 
8
9    This class must be used in the following way:
10
11    * Construct class
12    * call addLRToIG as many times to add ALL LRs to this IG
13    * call createGraph to create the actual matrix
14    * Then setInterference, getInterference, mergeIGNodesOfLRs can be 
15      called as desired to modify the graph.
16    * Once the modifications to the graph are over, call 
17      setCurDegreeOfIGNodes() before pushing IGNodes on to stack for coloring.
18 */
19
20 #ifndef INTERFERENCEGRAPH_H
21 #define INTERFERENCEGRAPH_H
22
23 #include <vector>
24 class LiveRange;
25 class RegClass;
26 class IGNode;
27
28 class InterferenceGraph {
29   char **IG;                            // a poiner to the interference graph
30   unsigned int Size;                    // size of a side of the IG
31   RegClass *const RegCl;                // RegCl contains this IG
32   std::vector<IGNode *> IGNodeList;     // a list of all IGNodes in a reg class
33                             
34  public:
35   // the matrix is not yet created by the constructor. Call createGraph() 
36   // to create it after adding all IGNodes to the IGNodeList
37   InterferenceGraph(RegClass *RC);
38   ~InterferenceGraph();
39
40   void createGraph();
41
42   void addLRToIG(LiveRange *LR);
43
44   void setInterference(const LiveRange *LR1,
45                        const LiveRange *LR2);
46
47   unsigned getInterference(const LiveRange *LR1,
48                            const LiveRange *LR2) const ;
49
50   void mergeIGNodesOfLRs(const LiveRange *LR1, LiveRange *LR2);
51
52   std::vector<IGNode *> &getIGNodeList() { return IGNodeList; } 
53   const std::vector<IGNode *> &getIGNodeList() const { return IGNodeList; } 
54
55   void setCurDegreeOfIGNodes();
56
57   void printIG() const;
58   void printIGNodeList() const;
59 };
60
61 #endif