LLVM API Documentation
00001 //===-- InterferenceGraph.h - Interference graph for register coloring -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 /* Title: InterferenceGraph.h -*- C++ -*- 00011 Author: Ruchira Sasanka 00012 Date: July 20, 01 00013 Purpose: Interference Graph used for register coloring. 00014 00015 Notes: 00016 Adj Info is stored in the lower trangular matrix (i.e., row > col ) 00017 00018 This class must be used in the following way: 00019 00020 * Construct class 00021 * call addLRToIG as many times to add ALL LRs to this IG 00022 * call createGraph to create the actual matrix 00023 * Then setInterference, getInterference, mergeIGNodesOfLRs can be 00024 called as desired to modify the graph. 00025 * Once the modifications to the graph are over, call 00026 setCurDegreeOfIGNodes() before pushing IGNodes on to stack for coloring. 00027 */ 00028 00029 #ifndef INTERFERENCEGRAPH_H 00030 #define INTERFERENCEGRAPH_H 00031 00032 #include <vector> 00033 00034 namespace llvm { 00035 00036 class LiveRange; 00037 class RegClass; 00038 class IGNode; 00039 00040 class InterferenceGraph { 00041 char **IG; // a poiner to the interference graph 00042 unsigned int Size; // size of a side of the IG 00043 RegClass *const RegCl; // RegCl contains this IG 00044 std::vector<IGNode *> IGNodeList; // a list of all IGNodes in a reg class 00045 00046 public: 00047 // the matrix is not yet created by the constructor. Call createGraph() 00048 // to create it after adding all IGNodes to the IGNodeList 00049 InterferenceGraph(RegClass *RC); 00050 ~InterferenceGraph(); 00051 00052 void createGraph(); 00053 00054 void addLRToIG(LiveRange *LR); 00055 00056 void setInterference(const LiveRange *LR1, 00057 const LiveRange *LR2); 00058 00059 unsigned getInterference(const LiveRange *LR1, 00060 const LiveRange *LR2) const ; 00061 00062 void mergeIGNodesOfLRs(const LiveRange *LR1, LiveRange *LR2); 00063 00064 std::vector<IGNode *> &getIGNodeList() { return IGNodeList; } 00065 const std::vector<IGNode *> &getIGNodeList() const { return IGNodeList; } 00066 00067 void setCurDegreeOfIGNodes(); 00068 00069 void printIG() const; 00070 void printIGNodeList() const; 00071 }; 00072 00073 } // End llvm namespace 00074 00075 #endif