OpenASIP 2.2
Loading...
Searching...
No Matches
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"
43
44using 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 */
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 */
70bool
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
virtual bool check(const TTAMachine::Machine &mach, MachineCheckResults &results) const
OperationPool & operationPool_
AddressSpaceCheck(OperationPool &operationPool)
void addError(const MachineCheck &check, const std::string &errorMsg)
static NullOperation & instance()
Operation & operation(const char *name)
virtual TCEString name() const
Definition Operation.cc:93
virtual bool usesMemory() const
Definition Operation.cc:232
virtual AddressSpace * addressSpace() const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
const std::string & name() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380