summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-11 08:01:11 +0000
committerChris Lattner <sabre@nondot.org>2004-07-11 08:01:11 +0000
commitc4e6bb5f9fac6dc724845bfd09a4b079e515f533 (patch)
treeea1b09fff2797be29882bbbbc17b2c512a36f650 /llvm/lib
parentc9c16a0e60941640223c34a42818b2539863a9da (diff)
downloadbcm5719-llvm-c4e6bb5f9fac6dc724845bfd09a4b079e515f533.tar.gz
bcm5719-llvm-c4e6bb5f9fac6dc724845bfd09a4b079e515f533.zip
Make add constantexprs work with all types, fixing the regressions from last night
llvm-svn: 14760
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 4ece8b9c84b..465b19e42da 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -208,14 +208,38 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
}
case Instruction::Add:
- if (CE->getOperand(0)->getType() == Type::LongTy ||
- CE->getOperand(0)->getType() == Type::ULongTy)
+ switch (CE->getOperand(0)->getType()->getTypeID()) {
+ default: assert(0 && "Bad add type!"); abort();
+ case Type::LongTyID:
+ case Type::ULongTyID:
Result.LongVal = getConstantValue(CE->getOperand(0)).LongVal +
getConstantValue(CE->getOperand(1)).LongVal;
- else
break;
+ case Type::IntTyID:
+ case Type::UIntTyID:
+ Result.IntVal = getConstantValue(CE->getOperand(0)).IntVal +
+ getConstantValue(CE->getOperand(1)).IntVal;
+ break;
+ case Type::ShortTyID:
+ case Type::UShortTyID:
+ Result.ShortVal = getConstantValue(CE->getOperand(0)).ShortVal +
+ getConstantValue(CE->getOperand(1)).ShortVal;
+ break;
+ case Type::SByteTyID:
+ case Type::UByteTyID:
+ Result.SByteVal = getConstantValue(CE->getOperand(0)).SByteVal +
+ getConstantValue(CE->getOperand(1)).SByteVal;
+ break;
+ case Type::FloatTyID:
+ Result.FloatVal = getConstantValue(CE->getOperand(0)).FloatVal +
+ getConstantValue(CE->getOperand(1)).FloatVal;
+ break;
+ case Type::DoubleTyID:
+ Result.DoubleVal = getConstantValue(CE->getOperand(0)).DoubleVal +
+ getConstantValue(CE->getOperand(1)).DoubleVal;
+ break;
+ }
return Result;
-
default:
break;
}
OpenPOWER on IntegriCloud