OpenASIP 2.2
Loading...
Searching...
No Matches
ProgramGraph.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file ProgramGraph.cc
26 *
27 * Implementation of ProgramGraph class.
28 *
29 * ProgramGraph represents a program in PDG form.
30 *
31 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
32 * @note rating: red
33 */
34
35#include "ProgramGraph.hh"
36#include "Port.hh"
37#include "Bus.hh"
38#include "UniversalMachine.hh"
39#include "NullProgram.hh"
40#include "ControlFlowGraph.hh"
45#include "SequenceTools.hh"
46
47/**
48 * Constructor.
49 *
50 * Creates a new ProgramGraph from Program
51 * @param program Program in POM
52 */
53
56 : program_(program){
57 try {
58 for (int i = 0; i < program.procedureCount(); i++) {
59 ControlFlowGraph* cfg = NULL;
60 cfg = new ControlFlowGraph(program.procedure(i));
61 cfgs_.push_back(cfg);
62 ControlDependenceGraph* cdg = NULL;
63 try {
64 cdg = new ControlDependenceGraph(*cfg);
65 cdgs_.push_back(cdg);
66 } catch (const InvalidData& e) {
67 delete cdg;
68 continue;
69 }
71 DataDependenceGraph* ddg = NULL;
72 ddg = builder.build(*cfg, DataDependenceGraph::ALL_ANTIDEPS,mach);
73 ddgs_.push_back(ddg);
74 ProgramDependenceGraph* pdg = NULL;
75 pdg = new ProgramDependenceGraph(*cdg, *ddg);
76 pdgs_.push_back(pdg);
77 }
78 } catch (Exception&) {
79 clear();
80 throw;
81 }
82}
83
84/**
85 * Deletes all graphs owned by this.
86 */
93
94/**
95 * Destructor.
96 *
97 * Removes the graphs.
98 */
102
103/**
104 * Convert Program Graph to Program Object Model
105 * and returns POM
106 * @return POM
107 */
110 ///TODO: convert PDG to POM
111 /// this is basically scheduling
113}
114
115/**
116 * Returns MoveNode of program representation corresponding
117 * to Move of POM.
118 * @param move move from POM
119 * @return MoveNode corresponding to move
120 */
123 ///TODO: find a move and return corresponding MoveNode
124 return *(new MoveNode());
125}
126
127/**
128 * Returns number of PDG's in a program graph, equals number of procedures
129 * in program.
130 * @return number of PDG's in a graph
131 */
132int
134 return pdgs_.size();
135}
136
137/**
138 * Returns a PDG for procedure identified by index.
139 * @param i index of a procedure
140 * @return PDG for given procedure
141 */
144 if (i < 0 || i >= graphCount()){
145 throw InvalidData(__FILE__, __LINE__, __func__, "Trying to access"
146 " graph out of a scope!");
147 }
148 return pdgs_.at(i);
149}
150
151/**
152 * Returns a PDG for procedure identified by procedure name.
153 * @param name name of a procedure
154 * @return PDG for given procedure
155 */
157ProgramGraph::graph(const std::string name) {
158 for (int i = 0; i < graphCount(); i++) {
159 if (pdgs_.at(i)->name() == name) {
160 return pdgs_.at(i);
161 }
162 }
163 throw InvalidData(__FILE__, __LINE__, __func__, "Can not find graph of "
164 "procedure " + name);
165}
#define __func__
find Finds info of the inner loops in the program
virtual DataDependenceGraph * build(ControlFlowGraph &cGraph, DataDependenceGraph::AntidependenceLevel antidependenceLevel, const TTAMachine::Machine &mach, const UniversalMachine *um=NULL, bool createMemAndFUDeps=true, bool createDeathInformation=true, llvm::AliasAnalysis *AA=NULL)
int graphCount() const
ProgramGraph(TTAProgram::Program &program, const TTAMachine::Machine &mach)
MoveNode & nodeOf(const TTAProgram::Move &) const
std::vector< ControlFlowGraph * > cfgs_
Vector of CFG's for each procedure.
ProgramDependenceGraph * graph(const std::string)
std::vector< ControlDependenceGraph * > cdgs_
Vector of CDG's for each procedure.
std::vector< ProgramDependenceGraph * > pdgs_
Vector of PDG's for each procedure.
TTAProgram::Program & generateProgram() const
ProgramDependenceGraph * graphAt(int)
virtual ~ProgramGraph()
std::vector< DataDependenceGraph * > ddgs_
Vector of DDG's for each procedure.
static void deleteAllItems(SequenceType &aSequence)
static NullProgram & instance()