OpenASIP  2.0
TPEFTools.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 TPEFTools.hh
26  *
27  * Declaration of TPEFTools.
28  *
29  * @author Mikael Lepistö 2005 (tmlepist-no.spam-cs.tut.fi)
30  *
31  * @note rating: yellow
32  */
33 
34 #ifndef TTA_TPEF_TOOLS_HH
35 #define TTA_TPEF_TOOLS_HH
36 
37 #include <string>
38 
39 #include "Application.hh"
40 #include "ResourceElement.hh"
41 
42 namespace TPEF {
43 
44 class Binary;
45 class ASpaceElement;
46 class SectionElement;
47 class RelocElement;
48 class Section;
49 
50 /**
51  * Contains many helper functions that makes TPEF handling
52  * a bit easier.
53  *
54  * These are kind of functions that doesn't fit to any Sections' or
55  * SectionElements' interfaces.
56  *
57  * Class can be used stright through static interface,
58  * or client may create instance of TPEFTools, which enables
59  * caching functionality. Basically, if TPEFTools is highly utilized
60  * it should be used as a object.
61  */
62 class TPEFTools {
63 public:
64  TPEFTools(const Binary &aTpef);
65 
66  // clears cache tables
67  void clearCache() const;
68 
70  const SectionElement& element);
71 
72  std::string resourceName(
74  HalfWord resourceId) const;
75 
76  std::string addressSpaceName(
77  const ASpaceElement& aSpace) const;
78 
79  bool hasRelocation(const SectionElement& element) const;
80 
81  const RelocElement& relocation(const SectionElement& element) const;
82 
83  static Section& sectionOfElement(
84  const Binary& bin,
85  const SectionElement& element);
86 
87  static std::string resourceName(
88  const Binary& bin,
90  HalfWord resourceId);
91 
92  static std::string addressSpaceName(
93  const Binary& bin,
94  const ASpaceElement& aSpace);
95 
96  static bool hasRelocation(
97  const Binary& bin,
98  const SectionElement& element);
99 
100  static const RelocElement& relocation(
101  const Binary& bin,
102  const SectionElement& element);
103 
104 private:
105  /// TPEF whose resources are accessed.
106  const Binary& tpef_;
107 
108  /// Cache of Chunks and immediates, which are relocated.
109  mutable std::map<
111 
112  void initRelocationCache() const;
113 
114 };
115 
116 }
117 
118 #endif
TPEF::TPEFTools::addressSpaceName
std::string addressSpaceName(const ASpaceElement &aSpace) const
Definition: TPEFTools.cc:96
TPEF::Binary
Definition: Binary.hh:49
TPEF::TPEFTools::hasRelocation
bool hasRelocation(const SectionElement &element) const
Definition: TPEFTools.cc:107
TPEF::Section
Definition: Section.hh:64
TPEF::ASpaceElement
Definition: ASpaceElement.hh:48
ResourceElement.hh
TPEF::TPEFTools::initRelocationCache
void initRelocationCache() const
Definition: TPEFTools.cc:323
Application.hh
TPEF::SectionElement
Definition: SectionElement.hh:44
TPEF::ResourceElement::ResourceType
ResourceType
Resource types.
Definition: ResourceElement.hh:51
TPEF::TPEFTools::resourceName
std::string resourceName(ResourceElement::ResourceType type, HalfWord resourceId) const
Definition: TPEFTools.cc:84
TPEF::TPEFTools::relocationCache_
std::map< const SectionElement *, const RelocElement * > relocationCache_
Cache of Chunks and immediates, which are relocated.
Definition: TPEFTools.hh:110
TPEF::RelocElement
Definition: RelocElement.hh:51
TPEF::TPEFTools::tpef_
const Binary & tpef_
TPEF whose resources are accessed.
Definition: TPEFTools.hh:106
TPEF::TPEFTools
Definition: TPEFTools.hh:62
TPEF::TPEFTools::TPEFTools
TPEFTools(const Binary &aTpef)
Definition: TPEFTools.cc:54
TPEF::TPEFTools::sectionOfElement
Section & sectionOfElement(const SectionElement &element)
Definition: TPEFTools.cc:72
TPEF
Definition: Assembler.hh:43
TPEF::TPEFTools::relocation
const RelocElement & relocation(const SectionElement &element) const
Definition: TPEFTools.cc:119
TPEF::TPEFTools::clearCache
void clearCache() const
Definition: TPEFTools.cc:61