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
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
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);
51 void addLRToIG(LiveRange *LR);
53 void setInterference(const LiveRange *LR1,
54 const LiveRange *LR2);
56 unsigned getInterference(const LiveRange *LR1,
57 const LiveRange *LR2) const ;
59 void mergeIGNodesOfLRs(const LiveRange *LR1, LiveRange *LR2);
61 std::vector<IGNode *> &getIGNodeList() { return IGNodeList; }
62 const std::vector<IGNode *> &getIGNodeList() const { return IGNodeList; }
64 void setCurDegreeOfIGNodes();
67 void printIGNodeList() const;