OpenASIP  2.0
Public Member Functions | Static Public Member Functions | List of all members
ConstantAliasAnalyzer Class Reference

#include <ConstantAliasAnalyzer.hh>

Inheritance diagram for ConstantAliasAnalyzer:
Inheritance graph
Collaboration diagram for ConstantAliasAnalyzer:
Collaboration graph

Public Member Functions

virtual bool isAddressTraceable (DataDependenceGraph &ddg, const ProgramOperation &pop)
 
virtual AliasingResult analyze (DataDependenceGraph &ddg, const ProgramOperation &pop1, const ProgramOperation &pop2, MoveNodeUse::BBRelation bbInfo)
 
 ~ConstantAliasAnalyzer ()
 
- Public Member Functions inherited from MemoryAliasAnalyzer
virtual void initProcedure (TTAProgram::Procedure &)
 
virtual ~MemoryAliasAnalyzer ()
 

Static Public Member Functions

static bool getConstantAddress (DataDependenceGraph &ddg, const ProgramOperation &po, long &addr, long &loopIncrement)
 

Additional Inherited Members

- Public Types inherited from MemoryAliasAnalyzer
enum  AliasingResult { ALIAS_FALSE = 0, ALIAS_TRUE = 1, ALIAS_UNKNOWN = 2, ALIAS_PARTIAL = 3 }
 
- Protected Member Functions inherited from MemoryAliasAnalyzer
AliasingResult compareIndeces (int index1, int index2, const ProgramOperation &pop1, const ProgramOperation &pop2)
 
- Static Protected Member Functions inherited from MemoryAliasAnalyzer
static const MoveNodeaddressOperandMove (const ProgramOperation &po)
 
static TwoPartAddressOperandDetection findTwoPartAddressOperands (const ProgramOperation &po)
 
static const MoveNodesearchLoopIndexBasedIncrement (DataDependenceGraph &ddg, const MoveNode &mn, long &loopIncrement)
 
static const MoveNodefindIncrement (const MoveNode &mn, long &increment)
 
static const MoveNodedetectConstantScale (const MoveNode &mn, int &shiftAmount)
 

Detailed Description

Definition at line 42 of file ConstantAliasAnalyzer.hh.

Constructor & Destructor Documentation

◆ ~ConstantAliasAnalyzer()

ConstantAliasAnalyzer::~ConstantAliasAnalyzer ( )

Definition at line 130 of file ConstantAliasAnalyzer.cc.

130 {}

Member Function Documentation

◆ analyze()

MemoryAliasAnalyzer::AliasingResult ConstantAliasAnalyzer::analyze ( DataDependenceGraph ddg,
const ProgramOperation pop1,
const ProgramOperation pop2,
MoveNodeUse::BBRelation  bbInfo 
)
virtual

Implements MemoryAliasAnalyzer.

Definition at line 104 of file ConstantAliasAnalyzer.cc.

108  {
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 }

References MoveNodeUse::LOOP.

◆ getConstantAddress()

bool ConstantAliasAnalyzer::getConstantAddress ( DataDependenceGraph ddg,
const ProgramOperation po,
long &  addr,
long &  loopIncrement 
)
static

Definition at line 50 of file ConstantAliasAnalyzer.cc.

52  {
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 }

References TTAProgram::Move::isFunctionCall(), TTAProgram::Terminal::isImmediate(), MoveNode::isMove(), MoveNode::isSourceOperation(), MoveNode::isSourceVariable(), MoveNode::move(), DataDependenceGraph::onlyRegisterRawSource(), TTAProgram::Move::source(), SimValue::unsignedValue(), and TTAProgram::Terminal::value().

Referenced by GlobalVsStackAA::analyze(), and GlobalVsStackAA::isAddressTraceable().

Here is the call graph for this function:

◆ isAddressTraceable()

bool ConstantAliasAnalyzer::isAddressTraceable ( DataDependenceGraph ddg,
const ProgramOperation pop 
)
virtual

Checks whether the analyzer knows anything about the address.

ie. if it can return true or false to some query concerning this address.

Returns
true if analyzer can know something about the address.

Implements MemoryAliasAnalyzer.

Definition at line 95 of file ConstantAliasAnalyzer.cc.

96  {
97  long tmp;
98  long tmp2 = 0;
99  return getConstantAddress(ddg, po, tmp, tmp2);
100 }

The documentation for this class was generated from the following files:
MemoryAliasAnalyzer::ALIAS_UNKNOWN
@ ALIAS_UNKNOWN
Definition: MemoryAliasAnalyzer.hh:54
TTAProgram::Move::isFunctionCall
bool isFunctionCall() const
Definition: Move.cc:219
MoveNode
Definition: MoveNode.hh:65
DataDependenceGraph::onlyRegisterRawSource
MoveNode * onlyRegisterRawSource(const MoveNode &mn, int allowGuardEdges=2, int backEdges=0) const
Definition: DataDependenceGraph.cc:4083
MoveNode::isMove
bool isMove() const
MoveNode::isSourceOperation
bool isSourceOperation() const
Definition: MoveNode.cc:168
TTAProgram::Terminal::value
virtual SimValue value() const
Definition: Terminal.cc:178
MemoryAliasAnalyzer::searchLoopIndexBasedIncrement
static const MoveNode * searchLoopIndexBasedIncrement(DataDependenceGraph &ddg, const MoveNode &mn, long &loopIncrement)
Definition: MemoryAliasAnalyzer.cc:321
TTAProgram::Move
Definition: Move.hh:55
MemoryAliasAnalyzer::addressOperandMove
static const MoveNode * addressOperandMove(const ProgramOperation &po)
Definition: MemoryAliasAnalyzer.cc:147
MoveNodeUse::LOOP
@ LOOP
Definition: MoveNodeUse.hh:26
SimValue::unsignedValue
unsigned int unsignedValue() const
Definition: SimValue.cc:919
MoveNode::isSourceVariable
bool isSourceVariable() const
Definition: MoveNode.cc:196
MoveNode::move
TTAProgram::Move & move()
MemoryAliasAnalyzer::findIncrement
static const MoveNode * findIncrement(const MoveNode &mn, long &increment)
Definition: MemoryAliasAnalyzer.cc:273
MemoryAliasAnalyzer::compareIndeces
AliasingResult compareIndeces(int index1, int index2, const ProgramOperation &pop1, const ProgramOperation &pop2)
Definition: MemoryAliasAnalyzer.cc:62
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
ConstantAliasAnalyzer::getConstantAddress
static bool getConstantAddress(DataDependenceGraph &ddg, const ProgramOperation &po, long &addr, long &loopIncrement)
Definition: ConstantAliasAnalyzer.cc:50
TTAProgram::Terminal::isImmediate
virtual bool isImmediate() const
Definition: Terminal.cc:63