Make add constantexprs work with all types, fixing the regressions from last night

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-07-11 08:01:11 +00:00
parent 7c38def077
commit 5f90cb8c98

View File

@ -208,14 +208,38 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
} }
case Instruction::Add: case Instruction::Add:
if (CE->getOperand(0)->getType() == Type::LongTy || switch (CE->getOperand(0)->getType()->getTypeID()) {
CE->getOperand(0)->getType() == Type::ULongTy) default: assert(0 && "Bad add type!"); abort();
case Type::LongTyID:
case Type::ULongTyID:
Result.LongVal = getConstantValue(CE->getOperand(0)).LongVal + Result.LongVal = getConstantValue(CE->getOperand(0)).LongVal +
getConstantValue(CE->getOperand(1)).LongVal; getConstantValue(CE->getOperand(1)).LongVal;
else
break; 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; return Result;
default: default:
break; break;
} }