simplify some code that was not llvm_shutdown safe

llvm-svn: 34440
This commit is contained in:
Chris Lattner 2007-02-20 05:46:39 +00:00
parent c35fe713ff
commit dbcb0d3ffe
1 changed files with 5 additions and 36 deletions

View File

@ -89,45 +89,14 @@ bool Constant::canTrap() const {
}
}
// Static constructor to create a '0' constant of arbitrary type...
Constant *Constant::getNullValue(const Type *Ty) {
switch (Ty->getTypeID()) {
case Type::IntegerTyID: {
const IntegerType *ITy = dyn_cast<IntegerType>(Ty);
switch (ITy->getBitWidth()) {
case 1: {
static Constant *NullBool = ConstantInt::get(Ty, false);
return NullBool;
}
case 8: {
static Constant *NullInt8 = ConstantInt::get(Ty, 0);
return NullInt8;
}
case 16: {
static Constant *NullInt16 = ConstantInt::get(Ty, 0);
return NullInt16;
}
case 32: {
static Constant *NullInt32 = ConstantInt::get(Ty, 0);
return NullInt32;
}
case 64: {
static Constant *NullInt64 = ConstantInt::get(Ty, 0);
return NullInt64;
}
default:
return ConstantInt::get(Ty, 0);
}
}
case Type::FloatTyID: {
static Constant *NullFloat = ConstantFP::get(Type::FloatTy, 0);
return NullFloat;
}
case Type::DoubleTyID: {
static Constant *NullDouble = ConstantFP::get(Type::DoubleTy, 0);
return NullDouble;
}
case Type::IntegerTyID:
return ConstantInt::get(Ty, 0);
case Type::FloatTyID:
case Type::DoubleTyID:
return ConstantFP::get(Ty, 0.0);
case Type::PointerTyID:
return ConstantPointerNull::get(cast<PointerType>(Ty));
case Type::StructTyID: