2003-10-21 15:29:18 +00:00
|
|
|
//===-- InterferenceGraph.h - Interference graph for register coloring -*- C++ -*-===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2003-10-21 15:29:18 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2003-10-21 15:29:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
/* Title: InterferenceGraph.h -*- C++ -*-
|
2001-09-08 14:22:50 +00:00
|
|
|
Author: Ruchira Sasanka
|
|
|
|
Date: July 20, 01
|
|
|
|
Purpose: Interference Graph used for register coloring.
|
|
|
|
|
2005-04-21 23:30:14 +00:00
|
|
|
Notes:
|
|
|
|
Adj Info is stored in the lower trangular matrix (i.e., row > col )
|
2001-09-08 14:22:50 +00:00
|
|
|
|
|
|
|
This class must be used in the following way:
|
|
|
|
|
|
|
|
* Construct class
|
|
|
|
* call addLRToIG as many times to add ALL LRs to this IG
|
|
|
|
* call createGraph to create the actual matrix
|
2005-04-21 23:30:14 +00:00
|
|
|
* Then setInterference, getInterference, mergeIGNodesOfLRs can be
|
2001-09-08 14:22:50 +00:00
|
|
|
called as desired to modify the graph.
|
2005-04-21 23:30:14 +00:00
|
|
|
* Once the modifications to the graph are over, call
|
2001-09-08 14:22:50 +00:00
|
|
|
setCurDegreeOfIGNodes() before pushing IGNodes on to stack for coloring.
|
|
|
|
*/
|
|
|
|
|
2003-09-21 02:31:37 +00:00
|
|
|
#ifndef INTERFERENCEGRAPH_H
|
|
|
|
#define INTERFERENCEGRAPH_H
|
2001-09-08 14:22:50 +00:00
|
|
|
|
2002-10-29 16:50:06 +00:00
|
|
|
#include <vector>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2005-06-12 23:52:58 +00:00
|
|
|
class V9LiveRange;
|
2002-10-29 16:50:06 +00:00
|
|
|
class RegClass;
|
|
|
|
class IGNode;
|
2001-09-08 14:22:50 +00:00
|
|
|
|
2002-10-29 16:42:34 +00:00
|
|
|
class InterferenceGraph {
|
2001-09-08 14:22:50 +00:00
|
|
|
char **IG; // a poiner to the interference graph
|
|
|
|
unsigned int Size; // size of a side of the IG
|
|
|
|
RegClass *const RegCl; // RegCl contains this IG
|
2002-10-29 16:50:06 +00:00
|
|
|
std::vector<IGNode *> IGNodeList; // a list of all IGNodes in a reg class
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2001-09-08 14:22:50 +00:00
|
|
|
public:
|
2005-04-21 23:30:14 +00:00
|
|
|
// the matrix is not yet created by the constructor. Call createGraph()
|
2001-09-08 14:22:50 +00:00
|
|
|
// to create it after adding all IGNodes to the IGNodeList
|
2002-10-29 16:42:34 +00:00
|
|
|
InterferenceGraph(RegClass *RC);
|
2002-01-20 22:54:45 +00:00
|
|
|
~InterferenceGraph();
|
|
|
|
|
2001-09-08 14:22:50 +00:00
|
|
|
void createGraph();
|
|
|
|
|
2005-06-12 23:52:58 +00:00
|
|
|
void addLRToIG(V9LiveRange *LR);
|
2001-09-08 14:22:50 +00:00
|
|
|
|
2005-06-12 23:52:58 +00:00
|
|
|
void setInterference(const V9LiveRange *LR1,
|
|
|
|
const V9LiveRange *LR2);
|
2001-09-08 14:22:50 +00:00
|
|
|
|
2005-06-12 23:52:58 +00:00
|
|
|
unsigned getInterference(const V9LiveRange *LR1,
|
|
|
|
const V9LiveRange *LR2) const ;
|
2001-09-08 14:22:50 +00:00
|
|
|
|
2005-06-12 23:52:58 +00:00
|
|
|
void mergeIGNodesOfLRs(const V9LiveRange *LR1, V9LiveRange *LR2);
|
2001-09-08 14:22:50 +00:00
|
|
|
|
2005-04-21 23:30:14 +00:00
|
|
|
std::vector<IGNode *> &getIGNodeList() { return IGNodeList; }
|
|
|
|
const std::vector<IGNode *> &getIGNodeList() const { return IGNodeList; }
|
2001-09-08 14:22:50 +00:00
|
|
|
|
|
|
|
void setCurDegreeOfIGNodes();
|
|
|
|
|
|
|
|
void printIG() const;
|
|
|
|
void printIGNodeList() const;
|
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-09-08 14:22:50 +00:00
|
|
|
#endif
|