OpenASIP 2.2
Loading...
Searching...
No Matches
OperationDAGBuilder.hh
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 OperationDAGBuilder.hh
26 *
27 * Declaration of OperationDAGBuilder class.
28 *
29 * @author Mikael Lepistö 2007 (tmlepist-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#ifndef TTA_OPERATION_DAG_BUILDER_HH
34#define TTA_OPERATION_DAG_BUILDER_HH
35
37
38class OperationNode;
39class TerminalNode;
40class OperationPimpl;
41class OperationDAG;
43
44/**
45 * Builds OperationDAG from parsed and tokenized OSAL code.
46 */
48public:
50 const OperationPimpl& operation,
51 OperationDAG& dag,
53
54 void parse();
55
56private:
57 /// Node and operand which is referred by a variable.
58 typedef std::pair<OperationDAGNode*, int> VariableBinding;
59
60 /// Information of object and index of operand of a variable.
61 typedef std::pair<TerminalNode*, unsigned int> TerminalBinding;
62
64 void createOperationNode(const std::string& operation);
65
67 const TokenizerData::TokenTreeNode* var, unsigned int operandIndex);
68
69 void finalize();
70
72
73 void assignVariable(
75 void assignVariable(
78
79 std::string getVariableName(const TokenizerData::TokenTreeNode* var);
80
82 VariableBinding& getBinding(std::string varName);
83 VariableBinding& getBinding(unsigned int operandIndex);
85
86 unsigned int getIOOperand(const TokenizerData::TokenTreeNode* var);
87
88 /// DAG where all nodes and edges are added.
90
91 /// Root of tokenized data parsed from OSAL DAG source code.
93
94 /// Currently created handled operation.
96
97 /// Node and operand which are referred by IO(x) or declared variable.
98 std::map<std::string, VariableBinding> variableBindings_;
99
100 /// Node representing constant value.
101 std::map<long, VariableBinding> constantBindings_;
102
103 /// IO(x) variables and corresponding TerminalNodes and operand indices.
104 std::map<std::string, TerminalBinding> ioVariables_;
105
107};
108
109#endif
void parseNode(const TokenizerData::TokenTreeNode *node)
const OperationPimpl & operation_
std::map< long, VariableBinding > constantBindings_
Node representing constant value.
unsigned int getIOOperand(const TokenizerData::TokenTreeNode *var)
OperationDAG * dag_
DAG where all nodes and edges are added.
std::pair< TerminalNode *, unsigned int > TerminalBinding
Information of object and index of operand of a variable.
VariableBinding & getBinding(const TokenizerData::TokenTreeNode *var)
std::string getVariableName(const TokenizerData::TokenTreeNode *var)
void connectOperandToNode(const TokenizerData::TokenTreeNode *var, unsigned int operandIndex)
OperationNode * currentOperation_
Currently created handled operation.
void declareVariable(const TokenizerData::TokenTreeNode *var)
void createOperationNode(const std::string &operation)
std::map< std::string, VariableBinding > variableBindings_
Node and operand which are referred by IO(x) or declared variable.
VariableBinding & getConstantBinding(long value)
std::pair< OperationDAGNode *, int > VariableBinding
Node and operand which is referred by a variable.
const TokenizerData::TokenTreeNode & rootNode_
Root of tokenized data parsed from OSAL DAG source code.
std::map< std::string, TerminalBinding > ioVariables_
IO(x) variables and corresponding TerminalNodes and operand indices.
void assignVariable(const TokenizerData::TokenTreeNode *dst, VariableBinding &src)