Otawa  0.10
LiExeGraph.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * exegraph module interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2007, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef _LI_EXEGRAPH_H_
23 #define _LI_EXEGRAPH_H_
24 
25 #include "ExeGraph.h"
26 
27 namespace otawa {
28 
29 #define INFINITE_TIME 0x0FFFFFF
30 
31 class LiExeGraph;
32 
33 class LiExeNode : public ExeGraph<LiExeNode>::ExeNode {
34  private:
36  bool _shaded;
38  public:
41  {return _time[step][bound];}
43  inline void shade(void)
44  {_shaded = true;}
45  inline bool isShaded(void)
46  {return _shaded;}
47 };
48 
49 class LiExeGraph : public ExeGraph<LiExeNode> {
50  public:
51  typedef class LiExeNode Node;
52  private:
54  void latestTimes();
55  void earliestTimes();
57  void shadeNodes(LiExeNode * node);
58  void nodeLatestTimes(LiExeNode *node);
59  void nodeEarliestTimes(LiExeNode *node);
60  bool separated(LiExeNode *u, LiExeNode *v);
61  inline elm::String timeName(int time);
62  public:
63  inline LiExeGraph(WorkSpace *fw, Microprocessor<LiExeNode> * microprocessor, ExeSequence<LiExeNode> *sequence)
65  build(fw, microprocessor, sequence);
66  }
67  int analyze();
68  inline void setTimesChanged()
69  {_times_changed = true;}
70  void dump(elm::io::Output& dotFile);
71 };
72 
74  : ExeNode(graph, stage, inst), _shaded(false), _graph((LiExeGraph *)graph) {
75  if (inst->codePart() >= ExeGraph<LiExeNode>::BODY) {
79  }
80  else {
84  }
88 }
89 
91 // elm::cout << "Setting time for node " << name() << " to " << time << " \n";
92  if (_time[step][bound] != time) {
94  _time[step][bound] = time;
95  }
96 }
97 
98 #define EPSILON 10
100  StringBuffer _buffer;
101  if (time < -INFINITE_TIME+EPSILON)
102  _buffer << "-INF";
103  else {
104  if (time > INFINITE_TIME-EPSILON)
105  _buffer << "-INF";
106  else
107  _buffer << time;
108  }
109  return _buffer.toString();
110 }
111 
112 
113 }; // namespace otawa
114 
115 #endif //_LI_EXEGRAPH_H_
int analyze()
Definition: exegraph_LiExeGraph.cpp:110
struct otawa::sem::inst inst
dtd::RefAttr< BasicBlock * > source("source", dtd::STRICT|dtd::REQUIRED)
void setTime(ExeGraph< LiExeNode >::time_step_t step, ExeGraph< LiExeNode >::time_bound_t bound, int time)
Definition: LiExeGraph.h:90
bool maxTimeToNode(LiExeNode *source, LiExeNode *target, int *time)
Definition: exegraph_LiExeGraph.cpp:140
int minLatency(void)
Definition: Microprocessor.h:200
LiExeNode(ExeGraph< LiExeNode > *graph, PipelineStage< LiExeNode > *stage, ExeInst< LiExeNode > *inst)
Builds an execution node tuned for Li's algorithm.
Definition: LiExeGraph.h:73
void shade(void)
Marks the node as "shaded" (see Li's algorithm)
Definition: LiExeGraph.h:43
void earliestTimes()
Definition: exegraph_LiExeGraph.cpp:183
bool _shaded
Definition: LiExeGraph.h:36
LiExeGraph(WorkSpace *fw, Microprocessor< LiExeNode > *microprocessor, ExeSequence< LiExeNode > *sequence)
Definition: LiExeGraph.h:63
class LiExeNode Node
Definition: LiExeGraph.h:51
ExeGraph< N >::code_part_t codePart()
Definition: ExeGraph.h:62
void latestTimes()
Definition: exegraph_LiExeGraph.cpp:164
bool isShaded(void)
Definition: LiExeGraph.h:45
Graph * graph(void) const
Get the container graph if any.
Definition: Graph.h:75
bool separated(LiExeNode *u, LiExeNode *v)
Definition: exegraph_LiExeGraph.cpp:482
#define EPSILON
Definition: LiExeGraph.h:98
void nodeEarliestTimes(LiExeNode *node)
Definition: exegraph_LiExeGraph.cpp:377
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
LiExeGraph * _graph
Definition: LiExeGraph.h:37
dtd::RefAttr< BasicBlock * > target("target", dtd::STRICT|dtd::REQUIRED)
#define INFINITE_TIME
Definition: LiExeGraph.h:29
An instruction represented in an ExeGraph.
Definition: ExeGraph.h:49
An execution graph that expresses precedence constraints on the execution of a sequence of instructio...
Definition: ExeGraph.h:40
elm::String timeName(int time)
Definition: LiExeGraph.h:99
void shadeNodes(LiExeNode *node)
Definition: exegraph_LiExeGraph.cpp:192
virtual void build(WorkSpace *fw, Microprocessor< LiExeNode > *microprocessor, ExeSequence< LiExeNode > *sequence)
bool _times_changed
Definition: LiExeGraph.h:53
int _time[ExeGraph< LiExeNode >::STEPS][ExeGraph< LiExeNode >::BOUNDS]
Definition: LiExeGraph.h:35
void dump(elm::io::Output &dotFile)
Definition: exegraph_LiExeGraph.cpp:28
ExeInst< N > * inst(void)
Definition: ExeGraph.h:169
void nodeLatestTimes(LiExeNode *node)
Definition: exegraph_LiExeGraph.cpp:216
t::int64 time
Definition: base.h:47
Definition: LiExeGraph.h:49
void setTimesChanged()
Definition: LiExeGraph.h:68
Definition: LiExeGraph.h:33
int time(ExeGraph< LiExeNode >::time_step_t step, ExeGraph< LiExeNode >::time_bound_t bound)
Definition: LiExeGraph.h:40
String toString(void)