mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-26 18:20:39 +00:00
code cleanups only.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130414 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -63,50 +63,48 @@ static cl::opt<bool> EnableLoadPRE("enable-load-pre", cl::init(true));
|
|||||||
namespace {
|
namespace {
|
||||||
struct Expression {
|
struct Expression {
|
||||||
uint32_t opcode;
|
uint32_t opcode;
|
||||||
const Type* type;
|
const Type *type;
|
||||||
SmallVector<uint32_t, 4> varargs;
|
SmallVector<uint32_t, 4> varargs;
|
||||||
|
|
||||||
Expression() { }
|
Expression(uint32_t o = ~2U) : opcode(o) { }
|
||||||
Expression(uint32_t o) : opcode(o) { }
|
|
||||||
|
|
||||||
bool operator==(const Expression &other) const {
|
bool operator==(const Expression &other) const {
|
||||||
if (opcode != other.opcode)
|
if (opcode != other.opcode)
|
||||||
return false;
|
return false;
|
||||||
else if (opcode == ~0U || opcode == ~1U)
|
if (opcode == ~0U || opcode == ~1U)
|
||||||
return true;
|
return true;
|
||||||
else if (type != other.type)
|
if (type != other.type)
|
||||||
return false;
|
return false;
|
||||||
else if (varargs != other.varargs)
|
if (varargs != other.varargs)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ValueTable {
|
class ValueTable {
|
||||||
private:
|
DenseMap<Value*, uint32_t> valueNumbering;
|
||||||
DenseMap<Value*, uint32_t> valueNumbering;
|
DenseMap<Expression, uint32_t> expressionNumbering;
|
||||||
DenseMap<Expression, uint32_t> expressionNumbering;
|
AliasAnalysis *AA;
|
||||||
AliasAnalysis* AA;
|
MemoryDependenceAnalysis *MD;
|
||||||
MemoryDependenceAnalysis* MD;
|
DominatorTree *DT;
|
||||||
DominatorTree* DT;
|
|
||||||
|
|
||||||
uint32_t nextValueNumber;
|
uint32_t nextValueNumber;
|
||||||
|
|
||||||
Expression create_expression(Instruction* I);
|
Expression create_expression(Instruction* I);
|
||||||
uint32_t lookup_or_add_call(CallInst* C);
|
uint32_t lookup_or_add_call(CallInst* C);
|
||||||
public:
|
public:
|
||||||
ValueTable() : nextValueNumber(1) { }
|
ValueTable() : nextValueNumber(1) { }
|
||||||
uint32_t lookup_or_add(Value *V);
|
uint32_t lookup_or_add(Value *V);
|
||||||
uint32_t lookup(Value *V) const;
|
uint32_t lookup(Value *V) const;
|
||||||
void add(Value *V, uint32_t num);
|
void add(Value *V, uint32_t num);
|
||||||
void clear();
|
void clear();
|
||||||
void erase(Value *v);
|
void erase(Value *v);
|
||||||
void setAliasAnalysis(AliasAnalysis* A) { AA = A; }
|
void setAliasAnalysis(AliasAnalysis* A) { AA = A; }
|
||||||
AliasAnalysis *getAliasAnalysis() const { return AA; }
|
AliasAnalysis *getAliasAnalysis() const { return AA; }
|
||||||
void setMemDep(MemoryDependenceAnalysis* M) { MD = M; }
|
void setMemDep(MemoryDependenceAnalysis* M) { MD = M; }
|
||||||
void setDomTree(DominatorTree* D) { DT = D; }
|
void setDomTree(DominatorTree* D) { DT = D; }
|
||||||
uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
|
uint32_t getNextUnusedValueNumber() { return nextValueNumber; }
|
||||||
void verifyRemoved(const Value *) const;
|
void verifyRemoved(const Value *) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,14 +362,14 @@ uint32_t ValueTable::lookup(Value *V) const {
|
|||||||
return VI->second;
|
return VI->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// clear - Remove all entries from the ValueTable
|
/// clear - Remove all entries from the ValueTable.
|
||||||
void ValueTable::clear() {
|
void ValueTable::clear() {
|
||||||
valueNumbering.clear();
|
valueNumbering.clear();
|
||||||
expressionNumbering.clear();
|
expressionNumbering.clear();
|
||||||
nextValueNumber = 1;
|
nextValueNumber = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// erase - Remove a value from the value numbering
|
/// erase - Remove a value from the value numbering.
|
||||||
void ValueTable::erase(Value *V) {
|
void ValueTable::erase(Value *V) {
|
||||||
valueNumbering.erase(V);
|
valueNumbering.erase(V);
|
||||||
}
|
}
|
||||||
@@ -393,9 +391,7 @@ namespace {
|
|||||||
|
|
||||||
class GVN : public FunctionPass {
|
class GVN : public FunctionPass {
|
||||||
bool NoLoads;
|
bool NoLoads;
|
||||||
public:
|
|
||||||
MemoryDependenceAnalysis *MD;
|
MemoryDependenceAnalysis *MD;
|
||||||
private:
|
|
||||||
DominatorTree *DT;
|
DominatorTree *DT;
|
||||||
const TargetData *TD;
|
const TargetData *TD;
|
||||||
|
|
||||||
@@ -431,6 +427,7 @@ namespace {
|
|||||||
const TargetData *getTargetData() const { return TD; }
|
const TargetData *getTargetData() const { return TD; }
|
||||||
DominatorTree &getDominatorTree() const { return *DT; }
|
DominatorTree &getDominatorTree() const { return *DT; }
|
||||||
AliasAnalysis *getAliasAnalysis() const { return VN.getAliasAnalysis(); }
|
AliasAnalysis *getAliasAnalysis() const { return VN.getAliasAnalysis(); }
|
||||||
|
MemoryDependenceAnalysis &getMemDep() const { return *MD; }
|
||||||
private:
|
private:
|
||||||
/// addToLeaderTable - Push a new Value to the LeaderTable onto the list for
|
/// addToLeaderTable - Push a new Value to the LeaderTable onto the list for
|
||||||
/// its value number.
|
/// its value number.
|
||||||
@@ -969,8 +966,7 @@ static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
|
|||||||
NewLoadSize*8-SrcVal->getType()->getPrimitiveSizeInBits());
|
NewLoadSize*8-SrcVal->getType()->getPrimitiveSizeInBits());
|
||||||
RV = Builder.CreateTrunc(RV, SrcVal->getType());
|
RV = Builder.CreateTrunc(RV, SrcVal->getType());
|
||||||
SrcVal->replaceAllUsesWith(RV);
|
SrcVal->replaceAllUsesWith(RV);
|
||||||
gvn.MD->removeInstruction(SrcVal);
|
gvn.getMemDep().removeInstruction(SrcVal);
|
||||||
//gvn.markInstructionForDeletion(SrcVal);
|
|
||||||
SrcVal = NewLoad;
|
SrcVal = NewLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user