OpenASIP 2.2
Loading...
Searching...
No Matches
ConstantAliasAnalyzer.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 ConstantAliasAnalyzer.cc
26 *
27 * Implementation of ConstantAliasAnalyzer class.
28 *
29 * This class does simple alias analysis between memove addresses
30 * that come directly from immediates.
31 *
32 * @author Heikki Kultala 2007 (heikki.kultala-no.spam-tut.fi)
33 * @note rating: red
34 */
35
37
38#include "MoveNode.hh"
39#include "Move.hh"
41#include "Terminal.hh"
42#include "Operation.hh"
43#include "MoveNodeSet.hh"
44
45using namespace TTAProgram;
46using namespace TTAMachine;
47
48
49
52 long& addr, long& loopIncrement) {
53 const MoveNode* mn = addressOperandMove(po);
54 addr = 0;
55 while (mn != NULL && mn->isMove()) {
56 if (mn->isSourceVariable()) {
57 MoveNode* prevSrc = ddg.onlyRegisterRawSource(*mn,2,2);
58 MoveNode* loopSrc = ddg.onlyRegisterRawSource(*mn,2,1);
59 if (prevSrc == NULL) {
60 break;
61 }
62 if (loopSrc) {
63 if (!findIncrement(*loopSrc, loopIncrement)) {
64 return false;
65 }
66 }
67 mn = prevSrc;
68 } else {
69 if (mn->isSourceOperation()) {
70 const MoveNode* incrementInput = findIncrement(*mn, addr);
71 if (incrementInput != NULL) {
72 mn = incrementInput;
73 } else {
74 mn = searchLoopIndexBasedIncrement(ddg, *mn, loopIncrement);
75 }
76 } else {
77 if (mn->isMove()) {
78 const Move& move = mn->move();
79 if (!move.isFunctionCall()) {
80 const Terminal& src = move.source();
81 if (src.isImmediate()) {
82 addr += src.value().unsignedValue();
83 return true;
84 }
85 }
86 }
87 return false;
88 }
89 }
90 }
91 return false;
92}
93
94bool
96 DataDependenceGraph& ddg, const ProgramOperation& po) {
97 long tmp;
98 long tmp2 = 0;
99 return getConstantAddress(ddg, po, tmp, tmp2);
100}
101
102// TODO: does not handle unaligned 64-bit memory operations well.
106 const ProgramOperation& pop1,
107 const ProgramOperation& pop2,
109
110 long addr1, addr2;
111 long inc1 = 0, inc2 = 0;
112
113 if (!getConstantAddress(ddg, pop1, addr1, inc1) ||
114 !getConstantAddress(ddg, pop2, addr2, inc2)) {
115 return ALIAS_UNKNOWN;
116 }
117
118 // if updated different amount, may overlap?
119 if (inc1 != inc2) {
120 return ALIAS_UNKNOWN;
121 }
122
123 if (bbRel != MoveNodeUse::LOOP) {
124 return compareIndeces(addr1, addr2, pop1, pop2);
125 } else {
126 return compareIndeces(addr1, addr2+inc2, pop1, pop2);
127 }
128}
129
static bool getConstantAddress(DataDependenceGraph &ddg, const ProgramOperation &po, long &addr, long &loopIncrement)
virtual AliasingResult analyze(DataDependenceGraph &ddg, const ProgramOperation &pop1, const ProgramOperation &pop2, MoveNodeUse::BBRelation bbInfo)
virtual bool isAddressTraceable(DataDependenceGraph &ddg, const ProgramOperation &pop)
MoveNode * onlyRegisterRawSource(const MoveNode &mn, int allowGuardEdges=2, int backEdges=0) const
static const MoveNode * findIncrement(const MoveNode &mn, long &increment)
AliasingResult compareIndeces(int index1, int index2, const ProgramOperation &pop1, const ProgramOperation &pop2)
static const MoveNode * searchLoopIndexBasedIncrement(DataDependenceGraph &ddg, const MoveNode &mn, long &loopIncrement)
static const MoveNode * addressOperandMove(const ProgramOperation &po)
bool isSourceVariable() const
Definition MoveNode.cc:196
bool isMove() const
TTAProgram::Move & move()
bool isSourceOperation() const
Definition MoveNode.cc:168
unsigned int unsignedValue() const
Definition SimValue.cc:919
bool isFunctionCall() const
Definition Move.cc:219
Terminal & source() const
Definition Move.cc:302
virtual SimValue value() const
Definition Terminal.cc:178
virtual bool isImmediate() const
Definition Terminal.cc:63