OpenASIP  2.0
ASpaceSection.cc
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 ASpaceSection.cc
26  *
27  * Definition of ASpaceSection class,
28  *
29  * @author Mikael Lepistö 2004 (tmlepist-no.spam-cs.tut.fi)
30  *
31  * @note rating: yellow
32  */
33 
34 #include "ASpaceSection.hh"
35 
36 namespace TPEF {
37 
38 using ReferenceManager::SafePointer;
39 
40 // registers section prototype to base class
41 ASpaceSection ASpaceSection::proto_(true);
42 
43 /**
44  * Constructor.
45  *
46  * @param init true if registeration is wanted
47  */
49  Section(), undefinedElement_(&SafePointer::null) {
50 
51  if (init) {
53  }
54 
55  unsetFlagVLen();
58 }
59 
60 /**
61  * Destructor
62  */
64 }
65 
66 /**
67  * Returns sections type.
68  *
69  * @return type of section.
70  */
73  return ST_ADDRSP;
74 }
75 
76 /**
77  * Creates an instance of class.
78  *
79  * @return Newly created section.
80  */
81 Section*
83  return new ASpaceSection(false);
84 }
85 
86 /**
87  * Checks if the parameter, is undefined address space.
88  *
89  * @param aSpace Element to check.
90  * @return True, if parameter is the undefined address space.
91  */
92 bool
94  assert(aSpace != NULL);
96  return (undefinedElement_->pointer() == aSpace);
97 }
98 
99 /**
100  * Set undefined address space.
101  *
102  * This method must be runned, before checking of undefined address
103  * space is allowed. If set is runned many times, it overrides earlier
104  * setings.
105  *
106  * @param aSpace Element to define as undefined address space.
107  */
108 void
110  assert(aSpace != NULL);
111  assert(aSpace->MAU() == 0);
112  assert(aSpace->align() == 0);
113  assert(aSpace->wordSize() == 0);
116 }
117 
118 /**
119  * Returns undefined address space element.
120  *
121  * @return Undefined address space element.
122  */
125  return dynamic_cast<ASpaceElement*>(
127 }
128 
129 }
TPEF::ReferenceManager::SafePointer::replaceReference
static const SafePointer * replaceReference(const SafePointer *old, SafePointable *obj)
TPEF::ASpaceSection::proto_
static ASpaceSection proto_
Prototype instance.
Definition: ASpaceSection.hh:62
TPEF::Section::aSpace
ASpaceElement * aSpace() const
TPEF::Section::unsetFlagVLen
void unsetFlagVLen()
TPEF::ASpaceSection::~ASpaceSection
virtual ~ASpaceSection()
Definition: ASpaceSection.cc:63
TPEF::ReferenceManager::SafePointer::null
static const SafePointer null
The default SafePointer that is used in null references.
Definition: SafePointer.hh:229
TPEF::ASpaceSection::isUndefined
bool isUndefined(ASpaceElement *aSpace) const
Definition: ASpaceSection.cc:93
TPEF::ASpaceElement::wordSize
Byte wordSize() const
TPEF::ASpaceElement::MAU
Byte MAU() const
TPEF::Section
Definition: Section.hh:64
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::ReferenceManager::SafePointer
Definition: SafePointer.hh:188
TPEF::ASpaceElement
Definition: ASpaceElement.hh:48
TPEF::ASpaceSection::undefinedASpace
ASpaceElement * undefinedASpace() const
Definition: ASpaceSection.cc:124
TPEF::ReferenceManager::SafePointer::pointer
SafePointable * pointer() const
ASpaceSection.hh
TPEF::Section::unsetFlagNoBits
void unsetFlagNoBits()
TPEF::ASpaceSection::type
virtual SectionType type() const
Definition: ASpaceSection.cc:72
TPEF::Section::setStartingAddress
void setStartingAddress(AddressImage address)
TPEF::ASpaceSection::clone
virtual Section * clone() const
Definition: ASpaceSection.cc:82
TPEF::Section::registerSection
static void registerSection(const Section *section)
Definition: Section.cc:114
TPEF::ASpaceSection::ASpaceSection
ASpaceSection(bool init)
Definition: ASpaceSection.cc:48
TPEF::ASpaceSection::setUndefinedASpace
void setUndefinedASpace(ASpaceElement *aSpace)
Definition: ASpaceSection.cc:109
TPEF::Section::SectionType
SectionType
Definition: Section.hh:69
TPEF::ASpaceSection::undefinedElement_
const ReferenceManager::SafePointer * undefinedElement_
Undefined address space. This element is not allowed to be removed from section is recognized as spec...
Definition: ASpaceSection.hh:66
TPEF::ASpaceElement::align
Byte align() const
TPEF::Section::ST_ADDRSP
@ ST_ADDRSP
Address space section.
Definition: Section.hh:77
TPEF
Definition: Assembler.hh:43