OpenASIP  2.0
GlobalScope.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 GlobalScope.hh
26  *
27  * Declaration of GlobalScope class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_GLOBAL_SCOPE_HH
34 #define TTA_GLOBAL_SCOPE_HH
35 
36 #include "Scope.hh"
37 
38 namespace TTAMachine {
39  class AddressSpace;
40 }
41 
42 namespace TTAProgram {
43 
44  class Program;
45  class Label;
46 
47 class GlobalScope : public Scope {
48 public:
49  GlobalScope();
50  virtual ~GlobalScope();
51 
52  virtual bool isGlobal() const;
53 
54  int globalCodeLabelCount(Address address) const;
55 
56  const CodeLabel& globalCodeLabel(Address address, int index) const;
57 
58  int globalCodeLabelCount() const;
59 
60  const CodeLabel& globalCodeLabel(int index) const;
61 
62  int globalDataLabelCount(Address address) const;
63 
64  const DataLabel& globalDataLabel(Address address, int index) const;
65 
66  int globalDataLabelCount() const;
67 
68  const DataLabel& globalDataLabel(int index) const;
69 
70  virtual void removeCodeLabels(InstructionAddress address);
71 
72  virtual Scope* copy() const;
73 
74  virtual Scope* copyAndRelocate(const TTAProgram::Program& program) const;
75 
76  virtual void setDataLabelAddressSpace(
77  const TTAMachine::AddressSpace& space);
78 
79 protected:
80  virtual void addGlobalCodeLabel(
81  const CodeLabel& codeLabel, const Scope& owner);
82  virtual void addGlobalDataLabel(
83  const DataLabel& codeLabel, const Scope& owner);
84 
85 private:
86 
87  /**
88  * Connects a label and its owner for bookkeeping.
89  */
90  class LabelOwner {
91  public:
92  LabelOwner(const Label& label, const Scope& owner);
93  ~LabelOwner();
94  const Label& label() const;
95  const Scope& scope() const;
96  private:
97  /// The label.
98  const Label* label_;
99  /// The owner scope of the label.
100  const Scope* owner_;
101  };
102 
103  /// Copying not allowed.
104  GlobalScope(const GlobalScope&);
105  /// Assignment not allowed.
107 
108  /// List for LabelOwners.
109  typedef std::vector<LabelOwner*> LabelOwnerList;
110 
111  /// Container for all code labels contained in the global scope and its
112  /// child scopes.
114  /// Container for all data labels.
116 };
117 
118 }
119 
120 #endif
TTAProgram
Definition: Estimator.hh:65
TTAProgram::Program
Definition: Program.hh:63
TTAProgram::Scope::codeLabel
const CodeLabel & codeLabel(const std::string &name) const
Definition: Scope.cc:233
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
TTAProgram::GlobalScope::LabelOwnerList
std::vector< LabelOwner * > LabelOwnerList
List for LabelOwners.
Definition: GlobalScope.hh:109
TTAProgram::Address
Definition: Address.hh:51
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
TTAProgram::GlobalScope::LabelOwner::label
const Label & label() const
Definition: GlobalScope.cc:404
TTAProgram::Label
Definition: Label.hh:55
TTAProgram::GlobalScope::copyAndRelocate
virtual Scope * copyAndRelocate(const TTAProgram::Program &program) const
Definition: GlobalScope.cc:334
TTAProgram::GlobalScope::LabelOwner::owner_
const Scope * owner_
The owner scope of the label.
Definition: GlobalScope.hh:100
TTAProgram::Scope
Definition: Scope.hh:53
TTAProgram::GlobalScope::globalDataLabel
const DataLabel & globalDataLabel(Address address, int index) const
Definition: GlobalScope.cc:220
TTAProgram::GlobalScope::copy
virtual Scope * copy() const
Definition: GlobalScope.cc:282
TTAProgram::GlobalScope::allDataLabels_
LabelOwnerList allDataLabels_
Container for all data labels.
Definition: GlobalScope.hh:115
TTAProgram::GlobalScope::LabelOwner::~LabelOwner
~LabelOwner()
Definition: GlobalScope.cc:395
TTAProgram::GlobalScope::LabelOwner::scope
const Scope & scope() const
Definition: GlobalScope.cc:414
TTAProgram::GlobalScope::LabelOwner::LabelOwner
LabelOwner(const Label &label, const Scope &owner)
Definition: GlobalScope.cc:386
TTAProgram::GlobalScope::setDataLabelAddressSpace
virtual void setDataLabelAddressSpace(const TTAMachine::AddressSpace &space)
Definition: GlobalScope.cc:305
TTAProgram::GlobalScope::globalDataLabelCount
int globalDataLabelCount() const
Definition: GlobalScope.cc:250
Scope.hh
TTAProgram::DataLabel
Definition: DataLabel.hh:45
TTAProgram::GlobalScope::GlobalScope
GlobalScope()
Definition: GlobalScope.cc:50
TTAProgram::GlobalScope::allCodeLabels_
LabelOwnerList allCodeLabels_
Container for all code labels contained in the global scope and its child scopes.
Definition: GlobalScope.hh:113
TTAProgram::CodeLabel
Definition: CodeLabel.hh:49
TTAProgram::GlobalScope
Definition: GlobalScope.hh:47
TTAProgram::GlobalScope::removeCodeLabels
virtual void removeCodeLabels(InstructionAddress address)
Definition: GlobalScope.cc:363
TTAProgram::GlobalScope::~GlobalScope
virtual ~GlobalScope()
Definition: GlobalScope.cc:56
TTAProgram::GlobalScope::LabelOwner
Definition: GlobalScope.hh:90
TTAProgram::GlobalScope::operator=
GlobalScope & operator=(const GlobalScope &)
Assignment not allowed.
TTAProgram::GlobalScope::globalCodeLabel
const CodeLabel & globalCodeLabel(Address address, int index) const
Definition: GlobalScope.cc:118
TTAProgram::GlobalScope::LabelOwner::label_
const Label * label_
The label.
Definition: GlobalScope.hh:98
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
TTAProgram::GlobalScope::addGlobalCodeLabel
virtual void addGlobalCodeLabel(const CodeLabel &codeLabel, const Scope &owner)
Definition: GlobalScope.cc:78
TTAMachine
Definition: Assembler.hh:48
TTAProgram::GlobalScope::isGlobal
virtual bool isGlobal() const
Definition: GlobalScope.cc:67
TTAProgram::GlobalScope::addGlobalDataLabel
virtual void addGlobalDataLabel(const DataLabel &codeLabel, const Scope &owner)
Definition: GlobalScope.cc:180
TTAProgram::GlobalScope::globalCodeLabelCount
int globalCodeLabelCount() const
Definition: GlobalScope.cc:148