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