mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
refactor some code out to a new helper method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
25bceead50
commit
5362c545e8
@ -1277,6 +1277,32 @@ struct AvailableValueInBlock {
|
||||
assert(!isSimpleValue() && "Wrong accessor");
|
||||
return cast<MemIntrinsic>(Val.getPointer());
|
||||
}
|
||||
|
||||
/// MaterializeAdjustedValue - Emit code into this block to adjust the value
|
||||
/// defined here to the specified type. This handles various coercion cases.
|
||||
Value *MaterializeAdjustedValue(const Type *LoadTy,
|
||||
const TargetData *TD) const {
|
||||
Value *Res;
|
||||
if (isSimpleValue()) {
|
||||
Res = getSimpleValue();
|
||||
if (Res->getType() != LoadTy) {
|
||||
assert(TD && "Need target data to handle type mismatch case");
|
||||
Res = GetStoreValueForLoad(Res, Offset, LoadTy, BB->getTerminator(),
|
||||
*TD);
|
||||
|
||||
DEBUG(errs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " "
|
||||
<< *getSimpleValue() << '\n'
|
||||
<< *Res << '\n' << "\n\n\n");
|
||||
}
|
||||
} else {
|
||||
Res = GetMemInstValueForLoad(getMemIntrinValue(), Offset,
|
||||
LoadTy, BB->getTerminator(), *TD);
|
||||
DEBUG(errs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset
|
||||
<< " " << *getMemIntrinValue() << '\n'
|
||||
<< *Res << '\n' << "\n\n\n");
|
||||
}
|
||||
return Res;
|
||||
}
|
||||
};
|
||||
|
||||
/// ConstructSSAForLoadSet - Given a set of loads specified by ValuesPerBlock,
|
||||
@ -1299,28 +1325,7 @@ static Value *ConstructSSAForLoadSet(LoadInst *LI,
|
||||
if (SSAUpdate.HasValueForBlock(BB))
|
||||
continue;
|
||||
|
||||
unsigned Offset = AV.Offset;
|
||||
|
||||
Value *AvailableVal;
|
||||
if (AV.isSimpleValue()) {
|
||||
AvailableVal = AV.getSimpleValue();
|
||||
if (AvailableVal->getType() != LoadTy) {
|
||||
assert(TD && "Need target data to handle type mismatch case");
|
||||
AvailableVal = GetStoreValueForLoad(AvailableVal, Offset, LoadTy,
|
||||
BB->getTerminator(), *TD);
|
||||
|
||||
DEBUG(errs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " "
|
||||
<< *AV.getSimpleValue() << '\n'
|
||||
<< *AvailableVal << '\n' << "\n\n\n");
|
||||
}
|
||||
} else {
|
||||
AvailableVal = GetMemInstValueForLoad(AV.getMemIntrinValue(), Offset,
|
||||
LoadTy, BB->getTerminator(), *TD);
|
||||
DEBUG(errs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset
|
||||
<< " " << *AV.getMemIntrinValue() << '\n'
|
||||
<< *AvailableVal << '\n' << "\n\n\n");
|
||||
}
|
||||
SSAUpdate.AddAvailableValue(BB, AvailableVal);
|
||||
SSAUpdate.AddAvailableValue(BB, AV.MaterializeAdjustedValue(LoadTy, TD));
|
||||
}
|
||||
|
||||
// Perform PHI construction.
|
||||
|
Loading…
Reference in New Issue
Block a user