mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
Implement "unsafe" replaceAllUsesWWith stuff for use during type resolution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8209 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6ac02a9092
commit
23f3a49aec
@ -350,9 +350,6 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) {
|
|||||||
|
|
||||||
// TODO: Figure out how to test if a double can be cast to a float!
|
// TODO: Figure out how to test if a double can be cast to a float!
|
||||||
case Type::FloatTyID:
|
case Type::FloatTyID:
|
||||||
/*
|
|
||||||
return (Val <= UINT8_MAX);
|
|
||||||
*/
|
|
||||||
case Type::DoubleTyID:
|
case Type::DoubleTyID:
|
||||||
return true; // This is the largest type...
|
return true; // This is the largest type...
|
||||||
}
|
}
|
||||||
@ -361,7 +358,8 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// replaceUsesOfWithOnConstant implementations
|
// replaceUsesOfWithOnConstant implementations
|
||||||
|
|
||||||
void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To) {
|
void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To,
|
||||||
|
bool DisableChecking) {
|
||||||
assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!");
|
assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!");
|
||||||
|
|
||||||
std::vector<Constant*> Values;
|
std::vector<Constant*> Values;
|
||||||
@ -376,13 +374,17 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To) {
|
|||||||
assert(Replacement != this && "I didn't contain From!");
|
assert(Replacement != this && "I didn't contain From!");
|
||||||
|
|
||||||
// Everyone using this now uses the replacement...
|
// Everyone using this now uses the replacement...
|
||||||
replaceAllUsesWith(Replacement);
|
if (DisableChecking)
|
||||||
|
uncheckedReplaceAllUsesWith(Replacement);
|
||||||
|
else
|
||||||
|
replaceAllUsesWith(Replacement);
|
||||||
|
|
||||||
// Delete the old constant!
|
// Delete the old constant!
|
||||||
destroyConstant();
|
destroyConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To) {
|
void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To,
|
||||||
|
bool DisableChecking) {
|
||||||
assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!");
|
assert(isa<Constant>(To) && "Cannot make Constant refer to non-constant!");
|
||||||
|
|
||||||
std::vector<Constant*> Values;
|
std::vector<Constant*> Values;
|
||||||
@ -397,33 +399,42 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To) {
|
|||||||
assert(Replacement != this && "I didn't contain From!");
|
assert(Replacement != this && "I didn't contain From!");
|
||||||
|
|
||||||
// Everyone using this now uses the replacement...
|
// Everyone using this now uses the replacement...
|
||||||
replaceAllUsesWith(Replacement);
|
if (DisableChecking)
|
||||||
|
uncheckedReplaceAllUsesWith(Replacement);
|
||||||
|
else
|
||||||
|
replaceAllUsesWith(Replacement);
|
||||||
|
|
||||||
// Delete the old constant!
|
// Delete the old constant!
|
||||||
destroyConstant();
|
destroyConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To) {
|
void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To,
|
||||||
|
bool DisableChecking) {
|
||||||
if (isa<GlobalValue>(To)) {
|
if (isa<GlobalValue>(To)) {
|
||||||
assert(From == getOperand(0) && "Doesn't contain from!");
|
assert(From == getOperand(0) && "Doesn't contain from!");
|
||||||
ConstantPointerRef *Replacement =
|
ConstantPointerRef *Replacement =
|
||||||
ConstantPointerRef::get(cast<GlobalValue>(To));
|
ConstantPointerRef::get(cast<GlobalValue>(To));
|
||||||
|
|
||||||
// Everyone using this now uses the replacement...
|
// Everyone using this now uses the replacement...
|
||||||
replaceAllUsesWith(Replacement);
|
if (DisableChecking)
|
||||||
|
uncheckedReplaceAllUsesWith(Replacement);
|
||||||
|
else
|
||||||
|
replaceAllUsesWith(Replacement);
|
||||||
|
|
||||||
// Delete the old constant!
|
|
||||||
destroyConstant();
|
|
||||||
} else {
|
} else {
|
||||||
// Just replace ourselves with the To value specified.
|
// Just replace ourselves with the To value specified.
|
||||||
replaceAllUsesWith(To);
|
if (DisableChecking)
|
||||||
|
uncheckedReplaceAllUsesWith(To);
|
||||||
// Delete the old constant!
|
else
|
||||||
destroyConstant();
|
replaceAllUsesWith(To);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete the old constant!
|
||||||
|
destroyConstant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV) {
|
void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV,
|
||||||
|
bool DisableChecking) {
|
||||||
assert(isa<Constant>(ToV) && "Cannot make Constant refer to non-constant!");
|
assert(isa<Constant>(ToV) && "Cannot make Constant refer to non-constant!");
|
||||||
Constant *To = cast<Constant>(ToV);
|
Constant *To = cast<Constant>(ToV);
|
||||||
|
|
||||||
@ -457,7 +468,10 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV) {
|
|||||||
assert(Replacement != this && "I didn't contain From!");
|
assert(Replacement != this && "I didn't contain From!");
|
||||||
|
|
||||||
// Everyone using this now uses the replacement...
|
// Everyone using this now uses the replacement...
|
||||||
replaceAllUsesWith(Replacement);
|
if (DisableChecking)
|
||||||
|
uncheckedReplaceAllUsesWith(Replacement);
|
||||||
|
else
|
||||||
|
replaceAllUsesWith(Replacement);
|
||||||
|
|
||||||
// Delete the old constant!
|
// Delete the old constant!
|
||||||
destroyConstant();
|
destroyConstant();
|
||||||
|
Loading…
Reference in New Issue
Block a user