OpenASIP  2.0
OperationDAGConverter.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 OperationDAGConverter.hh
26  *
27  * Declaration of OperationDAGConverter class.
28  *
29  * @author Mikael Lepistö 2007 (mikael.lepisto-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_OPERATION_DAG_CONVERTER_HH
34 #define TTA_OPERATION_DAG_CONVERTER_HH
35 
36 #include <string>
37 #include <set>
38 #include <map>
39 #include <vector>
40 
41 #include <Operand.hh>
42 
43 class OperationDAG;
44 class OperationDAGNode;
45 class OperationPimpl;
46 
47 /**
48  * Parser for creating Operation DAG from Operation DAG Language and
49  * for writing Operation DAG back to language form.
50  */
52 public:
53  static OperationDAG* createDAG(const OperationPimpl& operation, std::string sourceCode);
54  static std::string createOsalCode(const OperationDAG& dag);
55  static std::string createSimulationCode(
56  const OperationDAG& dag,
57  std::vector<std::string>* varReplacements = NULL);
58 
59 private:
60  typedef std::pair<const OperationDAGNode*,int> VariableKey;
61 
62  static std::string castedVar(
63  std::string var, Operand::OperandType type);
64 
65  static bool writeNode(
66  std::string& retVal,
67  const OperationDAG& dag, const OperationDAGNode& node,
68  std::map<VariableKey, std::string>& varBindings,
69  std::set<const OperationDAGNode*>& alreadyHandled,
70  int& tempVarCount,
71  std::set<const OperationDAGNode*>& currentlyHandling,
72  std::map<std::string, std::string>* opReplace = NULL,
73  std::vector<std::string>* varReplacements = NULL);
74 };
75 
76 #endif
Operand::OperandType
OperandType
Definition: Operand.hh:58
OperationPimpl
Definition: OperationPimpl.hh:54
OperationDAGConverter::createOsalCode
static std::string createOsalCode(const OperationDAG &dag)
Definition: OperationDAGConverter.cc:509
OperationDAGNode
Definition: OperationDAGNode.hh:45
OperationDAG
Definition: OperationDAG.hh:43
OperationDAGConverter::castedVar
static std::string castedVar(std::string var, Operand::OperandType type)
Definition: OperationDAGConverter.cc:479
OperationDAGConverter
Definition: OperationDAGConverter.hh:51
OperationDAGConverter::createSimulationCode
static std::string createSimulationCode(const OperationDAG &dag, std::vector< std::string > *varReplacements=NULL)
Definition: OperationDAGConverter.cc:534
OperationDAGConverter::writeNode
static bool writeNode(std::string &retVal, const OperationDAG &dag, const OperationDAGNode &node, std::map< VariableKey, std::string > &varBindings, std::set< const OperationDAGNode * > &alreadyHandled, int &tempVarCount, std::set< const OperationDAGNode * > &currentlyHandling, std::map< std::string, std::string > *opReplace=NULL, std::vector< std::string > *varReplacements=NULL)
Definition: OperationDAGConverter.cc:171
Operand.hh
OperationDAGConverter::VariableKey
std::pair< const OperationDAGNode *, int > VariableKey
Definition: OperationDAGConverter.hh:60
OperationDAGConverter::createDAG
static OperationDAG * createDAG(const OperationPimpl &operation, std::string sourceCode)
Definition: OperationDAGConverter.cc:61