2003-04-09 23:51:34 +02:00
|
|
|
//===- ModuloSchedGraph.h - Modulo Scheduling Graph and Set -*- C++ -*-----===//
|
2003-08-28 19:12:14 +02:00
|
|
|
//
|
2003-10-21 17:17:13 +02: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// TODO: Need a description here.
|
2003-03-27 18:57:44 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
#ifndef LLVM_MODULO_SCHED_GRAPH_H
|
|
|
|
#define LLVM_MODULO_SCHED_GRAPH_H
|
2003-04-09 23:51:34 +02:00
|
|
|
|
2003-03-27 18:57:44 +01:00
|
|
|
#include "llvm/Instruction.h"
|
2003-08-28 19:12:14 +02:00
|
|
|
#include "llvm/CodeGen/SchedGraphCommon.h"
|
2003-03-27 18:57:44 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-08-28 19:12:14 +02:00
|
|
|
#include "llvm/BasicBlock.h"
|
|
|
|
#include "llvm/Function.h"
|
2003-04-10 21:19:23 +02:00
|
|
|
#include "Support/hash_map"
|
2003-08-28 19:12:14 +02:00
|
|
|
#include <vector>
|
2003-03-27 18:57:44 +01:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
2003-03-27 18:57:44 +01:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
class ModuloSchedGraphNode : public SchedGraphNodeCommon {
|
2003-03-27 18:57:44 +01:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
const Instruction *Inst; //Node's Instruction
|
|
|
|
unsigned Earliest; //ASAP, or earliest time to be scheduled
|
|
|
|
unsigned Latest; //ALAP, or latested time to be scheduled
|
|
|
|
unsigned Depth; //Max Distance from node to the root
|
|
|
|
unsigned Height; //Max Distance from node to leaf
|
|
|
|
unsigned Mobility; //MOB, number of time slots it can be scheduled
|
|
|
|
const TargetMachine &Target; //Target information.
|
2003-03-27 18:57:44 +01:00
|
|
|
|
|
|
|
public:
|
2003-08-28 19:12:14 +02:00
|
|
|
ModuloSchedGraphNode(unsigned ID, int index, const Instruction *inst,
|
|
|
|
const TargetMachine &target);
|
2003-04-09 23:51:34 +02:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
void print(std::ostream &os) const;
|
|
|
|
const Instruction* getInst() { return Inst; }
|
|
|
|
unsigned getEarliest() { return Earliest; }
|
|
|
|
unsigned getLatest() { return Latest; }
|
|
|
|
unsigned getDepth() { return Depth; }
|
|
|
|
unsigned getHeight() { return Height; }
|
|
|
|
unsigned getMobility() { return Mobility; }
|
2003-06-10 21:09:00 +02:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
void setEarliest(unsigned early) { Earliest = early; }
|
|
|
|
void setLatest(unsigned late) { Latest = late; }
|
|
|
|
void setDepth(unsigned depth) { Depth = depth; }
|
|
|
|
void setHeight(unsigned height) { Height = height; }
|
|
|
|
void setMobility(unsigned mob) { Mobility = mob; }
|
2003-03-27 18:57:44 +01:00
|
|
|
|
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
};
|
2003-03-27 18:57:44 +01:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
class ModuloSchedGraph : public SchedGraphCommon {
|
2003-03-27 18:57:44 +01:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
const BasicBlock *BB; //The Basic block this graph represents
|
|
|
|
const TargetMachine &Target;
|
|
|
|
hash_map<const Instruction*, ModuloSchedGraphNode*> GraphMap;
|
2003-04-09 23:51:34 +02:00
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
void buildNodesForBB();
|
2003-04-09 23:51:34 +02:00
|
|
|
|
|
|
|
public:
|
2003-08-28 19:12:14 +02:00
|
|
|
typedef hash_map<const Instruction*,
|
|
|
|
ModuloSchedGraphNode*>::iterator iterator;
|
|
|
|
typedef hash_map<const Instruction*,
|
|
|
|
ModuloSchedGraphNode*>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
|
|
|
|
ModuloSchedGraph(const BasicBlock *bb, const TargetMachine &targ);
|
|
|
|
|
|
|
|
const BasicBlock* getBB() { return BB; }
|
|
|
|
void setBB(BasicBlock *bb) { BB = bb; }
|
|
|
|
unsigned size() { return GraphMap.size(); }
|
|
|
|
void addNode(const Instruction *I, ModuloSchedGraphNode *node);
|
|
|
|
void ASAP(); //Calculate earliest schedule time for all nodes in graph.
|
|
|
|
void ALAP(); //Calculate latest schedule time for all nodes in graph.
|
|
|
|
void MOB(); //Calculate mobility for all nodes in the graph.
|
|
|
|
void ComputeDepth(); //Compute depth of each node in graph
|
|
|
|
void ComputeHeight(); //Computer height of each node in graph
|
|
|
|
void addDepEdges(); //Add Dependencies
|
|
|
|
iterator find(const Instruction *I) { return GraphMap.find(I); }
|
2003-03-27 18:57:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
class ModuloSchedGraphSet {
|
|
|
|
|
|
|
|
const Function *function; //Function this set of graphs represent.
|
|
|
|
std::vector<ModuloSchedGraph*> Graphs;
|
2003-04-09 23:51:34 +02:00
|
|
|
|
2003-03-27 18:57:44 +01:00
|
|
|
public:
|
2003-08-28 19:12:14 +02:00
|
|
|
typedef std::vector<ModuloSchedGraph*>::iterator iterator;
|
|
|
|
typedef std::vector<ModuloSchedGraph*>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
iterator begin() { return Graphs.begin(); }
|
|
|
|
iterator end() { return Graphs.end(); }
|
|
|
|
|
|
|
|
ModuloSchedGraphSet(const Function *func, const TargetMachine &target);
|
2003-04-09 23:51:34 +02:00
|
|
|
~ModuloSchedGraphSet();
|
|
|
|
|
2003-08-28 19:12:14 +02:00
|
|
|
void addGraph(ModuloSchedGraph *graph);
|
2003-04-10 21:19:23 +02:00
|
|
|
void dump() const;
|
2003-03-27 18:57:44 +01:00
|
|
|
|
|
|
|
|
2003-04-10 21:19:23 +02:00
|
|
|
};
|
2003-04-09 23:51:34 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2003-04-09 23:51:34 +02:00
|
|
|
#endif
|