OpenASIP  2.0
AddressSpaceCheck.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 AddressSpaceCheck.hh
26  *
27  * Implementation of AddressSpaceCheck class.
28  *
29  * @author Viljami Korhonen 2007 (viljami.korhonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 
35 #include "AddressSpaceCheck.hh"
36 #include "FunctionUnit.hh"
37 #include "HWOperation.hh"
38 #include "Machine.hh"
39 #include "Operation.hh"
40 #include "OperationPool.hh"
41 #include "TCEString.hh"
42 #include "MachineCheckResults.hh"
43 
44 using namespace TTAMachine;
45 
46 /**
47  * The constructor.
48  *
49  * @param operationPool operation pool to search the operations for
50  */
52  MachineCheck("Address space check."),
53  operationPool_(operationPool) {
54 }
55 
56 /**
57  * The destructor.
58  */
60 }
61 
62 /**
63  * Checks that if the FUs' operations access memory,
64  * there is a memory address space available for them.
65  *
66  * @param mach Machine to be checked.
67  * @param results Check results.
68  * @return True if the check passed
69  */
70 bool
72  const TTAMachine::Machine& mach,
73  MachineCheckResults& results) const {
74 
76  for (int i = 0; i < FUs.count(); i++) {
77  FunctionUnit* unit = FUs.item(i);
78 
79  if (unit->addressSpace() != NULL) {
80  continue;
81  }
82 
83  for (int j = 0; j < unit->operationCount(); ++j) {
84  Operation& op =
85  operationPool_.operation(unit->operation(j)->name().c_str());
86 
87  // skip any Nulloperations because the check is done elsewhere
88  if (&op == &NullOperation::instance()) {
89  continue;
90  }
91 
92  if (op.usesMemory() && unit->addressSpace() == NULL) {
93  results.addError(*this,
94  std::string("operation ") + op.name() + " accesses memory" +
95  " but the memory address space was not set.");
96  return false;
97  }
98  }
99  } // end for all FUs
100 
101  return true;
102 }
103 
OperationPool::operation
Operation & operation(const char *name)
Definition: OperationPool.cc:99
MachineCheckResults::addError
void addError(const MachineCheck &check, const std::string &errorMsg)
Definition: MachineCheckResults.cc:85
TTAMachine::FunctionUnit::addressSpace
virtual AddressSpace * addressSpace() const
Definition: FunctionUnit.cc:580
TTAMachine::Machine::Navigator::count
int count() const
NullOperation::instance
static NullOperation & instance()
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
TCEString.hh
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
AddressSpaceCheck::operationPool_
OperationPool & operationPool_
Definition: AddressSpaceCheck.hh:59
AddressSpaceCheck.hh
HWOperation.hh
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
AddressSpaceCheck::AddressSpaceCheck
AddressSpaceCheck(OperationPool &operationPool)
Definition: AddressSpaceCheck.cc:51
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
Operation.hh
AddressSpaceCheck::check
virtual bool check(const TTAMachine::Machine &mach, MachineCheckResults &results) const
Definition: AddressSpaceCheck.cc:71
MachineCheckResults
Definition: MachineCheckResults.hh:46
Machine.hh
Operation
Definition: Operation.hh:59
AddressSpaceCheck::~AddressSpaceCheck
virtual ~AddressSpaceCheck()
Definition: AddressSpaceCheck.cc:59
Operation::usesMemory
virtual bool usesMemory() const
Definition: Operation.cc:232
MachineCheckResults.hh
MachineCheck
Definition: MachineCheck.hh:50
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
OperationPool
Definition: OperationPool.hh:52
TTAMachine
Definition: Assembler.hh:48
OperationPool.hh
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::Machine
Definition: Machine.hh:73
FunctionUnit.hh