OpenASIP  2.0
TPEFDisassembler.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 TPEFDisassembler.hh
26  *
27  * Declaration of TPEFDisassembler class.
28  *
29  * @author Mikael Lepistö 2005 (tmlepist-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_TPEF_DISASSEMBLER_HH
34 #define TTA_TPEF_DISASSEMBLER_HH
35 
36 #include <vector>
37 
38 #include "BaseType.hh"
39 #include "MoveElement.hh"
40 #include "ImmediateElement.hh"
41 #include "Binary.hh"
42 
44 class DisassemblyElement;
45 
46 /**
47  * TPEF Disassembler.
48  *
49  * Retrievs data from TPEF and builds Disassembler instructions
50  * out of TPEF hierarchy.
51  *
52  * Contains internal cache to speedup instruction fetching, so if
53  * instruction ordering of TPEF is changed cache will not be
54  * valid anymore and must be cleared.
55  *
56  * NOTE: Class disassembles only the first of code sections in binary.
57  */
59 public:
60  TPEFDisassembler(const TPEF::Binary &aTpef);
61  virtual ~TPEFDisassembler();
62 
64  Word instructionIndex) const;
65 
66  virtual Word startAddress() const;
67  virtual Word instructionCount() const;
68 
69  void clearCache() const;
70 
71 protected:
72  typedef std::pair<Word,Word> ImmediateKey;
73  typedef std::map<ImmediateKey, TPEF::ImmediateElement*> ImmediateMap;
74 
75  void initCache() const;
76 
78  TPEF::MoveElement::FieldType type, Word unit, Word index,
79  ImmediateMap &immediateMap) const;
80 
81 private:
82  /// Binary where data for disassembler is retrieved.
84 
85  /// Cache of starting elements of instructions.
86  mutable std::vector<Word> instructionStartCache_;
87 };
88 #endif
BaseType.hh
TPEFDisassembler::initCache
void initCache() const
Definition: TPEFDisassembler.cc:307
TPEF::Binary
Definition: Binary.hh:49
TPEFDisassembler::TPEFDisassembler
TPEFDisassembler(const TPEF::Binary &aTpef)
Definition: TPEFDisassembler.cc:70
TPEF::MoveElement::FieldType
FieldType
Definition: MoveElement.hh:52
DisassemblyElement
Definition: DisassemblyElement.hh:41
TPEFDisassembler::instructionStartCache_
std::vector< Word > instructionStartCache_
Cache of starting elements of instructions.
Definition: TPEFDisassembler.hh:86
TPEFDisassembler::ImmediateMap
std::map< ImmediateKey, TPEF::ImmediateElement * > ImmediateMap
Definition: TPEFDisassembler.hh:73
ImmediateElement.hh
TPEFDisassembler::tpef_
const TPEF::Binary * tpef_
Binary where data for disassembler is retrieved.
Definition: TPEFDisassembler.hh:83
TPEFDisassembler::clearCache
void clearCache() const
Definition: TPEFDisassembler.cc:296
TPEFDisassembler::instructionCount
virtual Word instructionCount() const
Definition: TPEFDisassembler.cc:280
TPEFDisassembler::ImmediateKey
std::pair< Word, Word > ImmediateKey
Definition: TPEFDisassembler.hh:72
TPEFDisassembler::createDisassemblyElement
DisassemblyElement * createDisassemblyElement(TPEF::MoveElement::FieldType type, Word unit, Word index, ImmediateMap &immediateMap) const
Definition: TPEFDisassembler.cc:334
TPEFDisassembler::createInstruction
virtual DisassemblyInstruction * createInstruction(Word instructionIndex) const
Definition: TPEFDisassembler.cc:87
TPEFDisassembler
Definition: TPEFDisassembler.hh:58
TPEFDisassembler::startAddress
virtual Word startAddress() const
Definition: TPEFDisassembler.cc:266
TPEFDisassembler::~TPEFDisassembler
virtual ~TPEFDisassembler()
Definition: TPEFDisassembler.cc:77
MoveElement.hh
DisassemblyInstruction
Definition: DisassemblyInstruction.hh:46
Binary.hh