OpenASIP 2.2
Loading...
Searching...
No Matches
ImmediateAnalyzer.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2016 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 ImmediateAnalyzer.cc
26 *
27 * Implementation of ImmediateAnalyzer class.
28 *
29 * Created on: 8.3.2016
30 * @author Henry Linjamäki 2016 (henry.linjamaki-no.spam-tut.fi)
31 * @note rating: red
32 */
33
34#include "ImmediateAnalyzer.hh"
35
36#include <memory>
37#include <utility>
38#include <set>
39
40#include "ImmInfo.hh"
41
42#include "Machine.hh"
43#include "FunctionUnit.hh"
44#include "ControlUnit.hh"
45#include "HWOperation.hh"
47#include "FUPort.hh"
48
49#include "TCEString.hh"
50
51using namespace TTAMachine;
52
53
54/**
55 * Collects short immediate capabilities of the machine.
56 *
57 * @param mach The machine.
58 */
61 std::unique_ptr<ImmInfo> result(new ImmInfo);
62
63 for (const FunctionUnit* fu : mach.functionUnitNavigator()) {
65 }
66
68 // ^ todo: fix this. operations of CU are not getting included in analysis.
69
70 //todo: remove duplicates (entries with identical (key, value pairs)).
71
72
73 return result.release();
74}
75
76
77/**
78 * Collects short immediate capabilities for each operation in the FU.
79 *
80 * @param fu The function unit.
81 * @param result The short immediate analysis result object where the
82 * capabilities are inserted into.
83 */
84void
86 const TTAMachine::FunctionUnit& fu, ImmInfo& result) {
87
88 for (int i = 0; i < fu.operationCount(); i++) {
89 HWOperation& hwop = *fu.operation(i);
91 }
92}
93
94
95/**
96 * Collects immediate transport capabilities for the operation.
97 *
98 * @param hwop The operation.
99 * @param result The short immediate analysis result object where the
100 * capabilities are inserted into.
101 */
102void
104 const TTAMachine::HWOperation& hwop, ImmInfo& result) {
105
106 using std::make_pair;
107
108 for (int i = 0; i < hwop.operandCount(); i++) {
109 assert(hwop.port(i+1) != nullptr);
110 const FUPort& boundPort = *hwop.port(i+1);
111 const Machine& mach = *boundPort.parentUnit()->machine();
112 std::set<const TTAMachine::Bus*> connectedBuses =
114 for (const Bus* bus : connectedBuses) {
115 if (bus->immediateWidth() < 1) {
116 continue;
117 }
118 result.insert(
119 make_pair(
120 make_pair(TCEString::toUpper(hwop.name()), i+1),
121 ImmInfoValue(bus->immediateWidth(), bus->signExtends())));
122 }
123
124 for (const ImmediateUnit* iu : mach.immediateUnitNavigator()) {
125 if (MachineConnectivityCheck::isConnected(*iu, boundPort)) {
126 for (auto& it : mach.instructionTemplateNavigator()) {
127 int supportedWidth = it->supportedWidth(*iu);
128 if (supportedWidth < 1) {
129 continue;
130 }
131
132 result.insert(
133 make_pair(
134 make_pair(TCEString::toUpper(hwop.name()), i+1),
135 ImmInfoValue(supportedWidth, iu->signExtends())));
136 }
137 }
138 }
139 }
140}
141
142
143
#define assert(condition)
static void analyzeImmediateCapabilitiesForOperation(const TTAMachine::HWOperation &hwop, ImmInfo &result)
static void analyzeImmediateCapabilitiesForFU(const TTAMachine::FunctionUnit &fu, ImmInfo &result)
static ImmInfo * analyze(const TTAMachine::Machine &mach)
static std::set< const TTAMachine::Bus * > connectedSourceBuses(const TTAMachine::Port &port)
static bool isConnected(const TTAMachine::Port &sourcePort, const TTAMachine::Port &destinationPort, const TTAMachine::Guard *guard=NULL)
static TCEString toUpper(const TCEString &str, const std::locale &loc=std::locale())
Definition TCEString.cc:156
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
virtual Machine * machine() const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
virtual FUPort * port(int operand) const
const std::string & name() const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual InstructionTemplateNavigator instructionTemplateNavigator() const
Definition Machine.cc:428
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345