mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 23:32:27 +00:00
Minor cosmetics: indentation, formatting, naming.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76839 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4bf370698a
commit
3b59dd886a
@ -26,37 +26,37 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class AliasAnalysis;
|
class AliasAnalysis;
|
||||||
class AnalysisUsage;
|
class AnalysisUsage;
|
||||||
class ScalarEvolution;
|
class ScalarEvolution;
|
||||||
class Value;
|
class Value;
|
||||||
|
|
||||||
class LoopDependenceAnalysis : public LoopPass {
|
class LoopDependenceAnalysis : public LoopPass {
|
||||||
Loop *L;
|
Loop *L;
|
||||||
AliasAnalysis *AA;
|
AliasAnalysis *AA;
|
||||||
ScalarEvolution *SE;
|
ScalarEvolution *SE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Class identification, replacement for typeinfo
|
static char ID; // Class identification, replacement for typeinfo
|
||||||
LoopDependenceAnalysis() : LoopPass(&ID) {}
|
LoopDependenceAnalysis() : LoopPass(&ID) {}
|
||||||
|
|
||||||
/// TODO: docs
|
/// TODO: docs
|
||||||
bool isDependencePair(const Value*, const Value*) const;
|
bool isDependencePair(const Value*, const Value*) const;
|
||||||
bool depends(Value*, Value*);
|
bool depends(Value*, Value*);
|
||||||
|
|
||||||
bool runOnLoop(Loop*, LPPassManager&);
|
bool runOnLoop(Loop*, LPPassManager&);
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage&) const;
|
virtual void getAnalysisUsage(AnalysisUsage&) const;
|
||||||
|
|
||||||
void print(raw_ostream&, const Module* = 0) const;
|
void print(raw_ostream&, const Module* = 0) const;
|
||||||
virtual void print(std::ostream&, const Module* = 0) const;
|
virtual void print(std::ostream&, const Module* = 0) const;
|
||||||
}; // class LoopDependenceAnalysis
|
}; // class LoopDependenceAnalysis
|
||||||
|
|
||||||
|
|
||||||
// createLoopDependenceAnalysisPass - This creates an instance of the
|
// createLoopDependenceAnalysisPass - This creates an instance of the
|
||||||
// LoopDependenceAnalysis pass.
|
// LoopDependenceAnalysis pass.
|
||||||
//
|
//
|
||||||
LoopPass *createLoopDependenceAnalysisPass();
|
LoopPass *createLoopDependenceAnalysisPass();
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
|
@ -45,14 +45,14 @@ static inline bool IsMemRefInstr(const Value *V) {
|
|||||||
return I && (I->mayReadFromMemory() || I->mayWriteToMemory());
|
return I && (I->mayReadFromMemory() || I->mayWriteToMemory());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetMemRefInstrs(
|
static void GetMemRefInstrs(const Loop *L,
|
||||||
const Loop *L, SmallVectorImpl<Instruction*> &memrefs) {
|
SmallVectorImpl<Instruction*> &Memrefs) {
|
||||||
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
|
for (Loop::block_iterator b = L->block_begin(), be = L->block_end();
|
||||||
b != be; ++b)
|
b != be; ++b)
|
||||||
for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
|
for (BasicBlock::iterator i = (*b)->begin(), ie = (*b)->end();
|
||||||
i != ie; ++i)
|
i != ie; ++i)
|
||||||
if (IsMemRefInstr(i))
|
if (IsMemRefInstr(i))
|
||||||
memrefs.push_back(i);
|
Memrefs.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsLoadOrStoreInst(Value *I) {
|
static bool IsLoadOrStoreInst(Value *I) {
|
||||||
@ -73,25 +73,25 @@ static Value *GetPointerOperand(Value *I) {
|
|||||||
// Dependence Testing
|
// Dependence Testing
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
bool LoopDependenceAnalysis::isDependencePair(const Value *x,
|
bool LoopDependenceAnalysis::isDependencePair(const Value *A,
|
||||||
const Value *y) const {
|
const Value *B) const {
|
||||||
return IsMemRefInstr(x) &&
|
return IsMemRefInstr(A) &&
|
||||||
IsMemRefInstr(y) &&
|
IsMemRefInstr(B) &&
|
||||||
(cast<const Instruction>(x)->mayWriteToMemory() ||
|
(cast<const Instruction>(A)->mayWriteToMemory() ||
|
||||||
cast<const Instruction>(y)->mayWriteToMemory());
|
cast<const Instruction>(B)->mayWriteToMemory());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoopDependenceAnalysis::depends(Value *src, Value *dst) {
|
bool LoopDependenceAnalysis::depends(Value *Src, Value *Dst) {
|
||||||
assert(isDependencePair(src, dst) && "Values form no dependence pair!");
|
assert(isDependencePair(Src, Dst) && "Values form no dependence pair!");
|
||||||
DOUT << "== LDA test ==\n" << *src << *dst;
|
DOUT << "== LDA test ==\n" << *Src << *Dst;
|
||||||
|
|
||||||
// We only analyse loads and stores; for possible memory accesses by e.g.
|
// We only analyse loads and stores; for possible memory accesses by e.g.
|
||||||
// free, call, or invoke instructions we conservatively assume dependence.
|
// free, call, or invoke instructions we conservatively assume dependence.
|
||||||
if (!IsLoadOrStoreInst(src) || !IsLoadOrStoreInst(dst))
|
if (!IsLoadOrStoreInst(Src) || !IsLoadOrStoreInst(Dst))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Value *srcPtr = GetPointerOperand(src);
|
Value *srcPtr = GetPointerOperand(Src);
|
||||||
Value *dstPtr = GetPointerOperand(dst);
|
Value *dstPtr = GetPointerOperand(Dst);
|
||||||
const Value *srcObj = srcPtr->getUnderlyingObject();
|
const Value *srcObj = srcPtr->getUnderlyingObject();
|
||||||
const Value *dstObj = dstPtr->getUnderlyingObject();
|
const Value *dstObj = dstPtr->getUnderlyingObject();
|
||||||
AliasAnalysis::AliasResult alias = AA->alias(
|
AliasAnalysis::AliasResult alias = AA->alias(
|
||||||
@ -130,8 +130,8 @@ void LoopDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
AU.addRequiredTransitive<ScalarEvolution>();
|
AU.addRequiredTransitive<ScalarEvolution>();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintLoopInfo(
|
static void PrintLoopInfo(raw_ostream &OS,
|
||||||
raw_ostream &OS, LoopDependenceAnalysis *LDA, const Loop *L) {
|
LoopDependenceAnalysis *LDA, const Loop *L) {
|
||||||
if (!L->empty()) return; // ignore non-innermost loops
|
if (!L->empty()) return; // ignore non-innermost loops
|
||||||
|
|
||||||
SmallVector<Instruction*, 8> memrefs;
|
SmallVector<Instruction*, 8> memrefs;
|
||||||
@ -144,7 +144,7 @@ static void PrintLoopInfo(
|
|||||||
OS << " Load/store instructions: " << memrefs.size() << "\n";
|
OS << " Load/store instructions: " << memrefs.size() << "\n";
|
||||||
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
||||||
end = memrefs.end(); x != end; ++x)
|
end = memrefs.end(); x != end; ++x)
|
||||||
OS << "\t" << (x - memrefs.begin()) << ": " << **x;
|
OS << "\t" << (x - memrefs.begin()) << ": " << **x << "\n";
|
||||||
|
|
||||||
OS << " Pairwise dependence results:\n";
|
OS << " Pairwise dependence results:\n";
|
||||||
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
for (SmallVector<Instruction*, 8>::const_iterator x = memrefs.begin(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user