1 //===-- InterferenceGraph.h - Interference graph for register coloring -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 /* Title: InterferenceGraph.h -*- C++ -*-
11 Author: Ruchira Sasanka
13 Purpose: Interference Graph used for register coloring.
16 Adj Info is stored in the lower trangular matrix (i.e., row > col )
18 This class must be used in the following way:
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.
29 #ifndef INTERFERENCEGRAPH_H
30 #define INTERFERENCEGRAPH_H
40 class InterferenceGraph {
41 char **IG; // a poiner to the interference graph
42 unsigned int Size; // size of a side of the IG
43 RegClass *const RegCl; // RegCl contains this IG
44 std::vector<IGNode *> IGNodeList; // a list of all IGNodes in a reg class
47 // the matrix is not yet created by the constructor. Call createGraph()
48 // to create it after adding all IGNodes to the IGNodeList
49 InterferenceGraph(RegClass *RC);
54 void addLRToIG(LiveRange *LR);
56 void setInterference(const LiveRange *LR1,
57 const LiveRange *LR2);
59 unsigned getInterference(const LiveRange *LR1,
60 const LiveRange *LR2) const ;
62 void mergeIGNodesOfLRs(const LiveRange *LR1, LiveRange *LR2);
64 std::vector<IGNode *> &getIGNodeList() { return IGNodeList; }
65 const std::vector<IGNode *> &getIGNodeList() const { return IGNodeList; }
67 void setCurDegreeOfIGNodes();
70 void printIGNodeList() const;
73 } // End llvm namespace