OpenASIP 2.2
Loading...
Searching...
No Matches
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
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 */
59public:
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
71protected:
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
81private:
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
virtual Word startAddress() const
virtual DisassemblyInstruction * createInstruction(Word instructionIndex) const
DisassemblyElement * createDisassemblyElement(TPEF::MoveElement::FieldType type, Word unit, Word index, ImmediateMap &immediateMap) const
void clearCache() const
std::pair< Word, Word > ImmediateKey
std::vector< Word > instructionStartCache_
Cache of starting elements of instructions.
const TPEF::Binary * tpef_
Binary where data for disassembler is retrieved.
virtual ~TPEFDisassembler()
std::map< ImmediateKey, TPEF::ImmediateElement * > ImmediateMap
virtual Word instructionCount() const