X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FValueTypes.cpp;h=21a1f034446a41d926dbd17c7771c254903d8b24;hb=a0c138429e101f573d43740322245c1d5b8b04a0;hp=5224e021de75544d4c5a659b8ca741ab16e2e333;hpb=ab5a5a6a769ee9d77e32f9cc7e87b609caeb9016;p=oota-llvm.git diff --git a/lib/VMCore/ValueTypes.cpp b/lib/VMCore/ValueTypes.cpp index 5224e021de7..21a1f034446 100644 --- a/lib/VMCore/ValueTypes.cpp +++ b/lib/VMCore/ValueTypes.cpp @@ -1,4 +1,4 @@ -//===----------- ValueTypes.cpp - Implementation of MVT methods -----------===// +//===----------- ValueTypes.cpp - Implementation of EVT methods -----------===// // // The LLVM Compiler Infrastructure // @@ -19,60 +19,63 @@ #include "llvm/Support/ErrorHandling.h" using namespace llvm; -MVT MVT::getExtendedIntegerVT(unsigned BitWidth) { - MVT VT; - VT.LLVMTy = getGlobalContext().getIntegerType(BitWidth); +EVT EVT::getExtendedIntegerVT(LLVMContext &Context, unsigned BitWidth) { + EVT VT; + VT.LLVMTy = IntegerType::get(Context, BitWidth); assert(VT.isExtended() && "Type is not extended!"); return VT; } -MVT MVT::getExtendedVectorVT(MVT VT, unsigned NumElements) { - MVT ResultVT; - ResultVT.LLVMTy = getGlobalContext().getVectorType( - VT.getTypeForMVT(getGlobalContext()), - NumElements); +EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, + unsigned NumElements) { + EVT ResultVT; + ResultVT.LLVMTy = VectorType::get(VT.getTypeForEVT(Context), NumElements); assert(ResultVT.isExtended() && "Type is not extended!"); return ResultVT; } -bool MVT::isExtendedFloatingPoint() const { +bool EVT::isExtendedFloatingPoint() const { assert(isExtended() && "Type is not extended!"); - return LLVMTy->isFPOrFPVector(); + return LLVMTy->isFPOrFPVectorTy(); } -bool MVT::isExtendedInteger() const { +bool EVT::isExtendedInteger() const { assert(isExtended() && "Type is not extended!"); - return LLVMTy->isIntOrIntVector(); + return LLVMTy->isIntOrIntVectorTy(); } -bool MVT::isExtendedVector() const { +bool EVT::isExtendedVector() const { assert(isExtended() && "Type is not extended!"); - return isa(LLVMTy); + return LLVMTy->isVectorTy(); } -bool MVT::isExtended64BitVector() const { +bool EVT::isExtended64BitVector() const { return isExtendedVector() && getSizeInBits() == 64; } -bool MVT::isExtended128BitVector() const { +bool EVT::isExtended128BitVector() const { return isExtendedVector() && getSizeInBits() == 128; } -bool MVT::isExtended256BitVector() const { +bool EVT::isExtended256BitVector() const { return isExtendedVector() && getSizeInBits() == 256; } -MVT MVT::getExtendedVectorElementType() const { +bool EVT::isExtended512BitVector() const { + return isExtendedVector() && getSizeInBits() == 512; +} + +EVT EVT::getExtendedVectorElementType() const { assert(isExtended() && "Type is not extended!"); - return MVT::getMVT(cast(LLVMTy)->getElementType()); + return EVT::getEVT(cast(LLVMTy)->getElementType()); } -unsigned MVT::getExtendedVectorNumElements() const { +unsigned EVT::getExtendedVectorNumElements() const { assert(isExtended() && "Type is not extended!"); return cast(LLVMTy)->getNumElements(); } -unsigned MVT::getExtendedSizeInBits() const { +unsigned EVT::getExtendedSizeInBits() const { assert(isExtended() && "Type is not extended!"); if (const IntegerType *ITy = dyn_cast(LLVMTy)) return ITy->getBitWidth(); @@ -82,16 +85,16 @@ unsigned MVT::getExtendedSizeInBits() const { return 0; // Suppress warnings. } -/// getMVTString - This function returns value type as a string, e.g. "i32". -std::string MVT::getMVTString() const { - switch (V) { +/// getEVTString - This function returns value type as a string, e.g. "i32". +std::string EVT::getEVTString() const { + switch (V.SimpleTy) { default: if (isVector()) return "v" + utostr(getVectorNumElements()) + - getVectorElementType().getMVTString(); + getVectorElementType().getEVTString(); if (isInteger()) return "i" + utostr(getSizeInBits()); - LLVM_UNREACHABLE("Invalid MVT!"); + llvm_unreachable("Invalid EVT!"); return "?"; case MVT::i1: return "i1"; case MVT::i8: return "i8"; @@ -106,7 +109,8 @@ std::string MVT::getMVTString() const { case MVT::ppcf128: return "ppcf128"; case MVT::isVoid: return "isVoid"; case MVT::Other: return "ch"; - case MVT::Flag: return "flag"; + case MVT::Glue: return "glue"; + case MVT::x86mmx: return "x86mmx"; case MVT::v2i8: return "v2i8"; case MVT::v4i8: return "v4i8"; case MVT::v8i8: return "v8i8"; @@ -117,89 +121,92 @@ std::string MVT::getMVTString() const { case MVT::v8i16: return "v8i16"; case MVT::v16i16: return "v16i16"; case MVT::v2i32: return "v2i32"; - case MVT::v3i32: return "v3i32"; case MVT::v4i32: return "v4i32"; case MVT::v8i32: return "v8i32"; case MVT::v1i64: return "v1i64"; case MVT::v2i64: return "v2i64"; case MVT::v4i64: return "v4i64"; + case MVT::v8i64: return "v8i64"; case MVT::v2f32: return "v2f32"; - case MVT::v3f32: return "v3f32"; case MVT::v4f32: return "v4f32"; case MVT::v8f32: return "v8f32"; case MVT::v2f64: return "v2f64"; case MVT::v4f64: return "v4f64"; + case MVT::Metadata:return "Metadata"; + case MVT::untyped: return "untyped"; } } -/// getTypeForMVT - This method returns an LLVM type corresponding to the -/// specified MVT. For integer types, this returns an unsigned type. Note +/// getTypeForEVT - This method returns an LLVM type corresponding to the +/// specified EVT. For integer types, this returns an unsigned type. Note /// that this will abort for types that cannot be represented. -const Type *MVT::getTypeForMVT(LLVMContext &Context) const { - switch (V) { +const Type *EVT::getTypeForEVT(LLVMContext &Context) const { + switch (V.SimpleTy) { default: assert(isExtended() && "Type is not extended!"); return LLVMTy; - case MVT::isVoid: return Type::VoidTy; - case MVT::i1: return Type::Int1Ty; - case MVT::i8: return Type::Int8Ty; - case MVT::i16: return Type::Int16Ty; - case MVT::i32: return Type::Int32Ty; - case MVT::i64: return Type::Int64Ty; - case MVT::i128: return Context.getIntegerType(128); - case MVT::f32: return Type::FloatTy; - case MVT::f64: return Type::DoubleTy; - case MVT::f80: return Type::X86_FP80Ty; - case MVT::f128: return Type::FP128Ty; - case MVT::ppcf128: return Type::PPC_FP128Ty; - case MVT::v2i8: return Context.getVectorType(Type::Int8Ty, 2); - case MVT::v4i8: return Context.getVectorType(Type::Int8Ty, 4); - case MVT::v8i8: return Context.getVectorType(Type::Int8Ty, 8); - case MVT::v16i8: return Context.getVectorType(Type::Int8Ty, 16); - case MVT::v32i8: return Context.getVectorType(Type::Int8Ty, 32); - case MVT::v2i16: return Context.getVectorType(Type::Int16Ty, 2); - case MVT::v4i16: return Context.getVectorType(Type::Int16Ty, 4); - case MVT::v8i16: return Context.getVectorType(Type::Int16Ty, 16); - case MVT::v16i16: return Context.getVectorType(Type::Int16Ty, 8); - case MVT::v2i32: return Context.getVectorType(Type::Int32Ty, 2); - case MVT::v3i32: return Context.getVectorType(Type::Int32Ty, 3); - case MVT::v4i32: return Context.getVectorType(Type::Int32Ty, 4); - case MVT::v8i32: return Context.getVectorType(Type::Int32Ty, 8); - case MVT::v1i64: return Context.getVectorType(Type::Int64Ty, 1); - case MVT::v2i64: return Context.getVectorType(Type::Int64Ty, 2); - case MVT::v4i64: return Context.getVectorType(Type::Int64Ty, 4); - case MVT::v2f32: return Context.getVectorType(Type::FloatTy, 2); - case MVT::v3f32: return Context.getVectorType(Type::FloatTy, 3); - case MVT::v4f32: return Context.getVectorType(Type::FloatTy, 4); - case MVT::v8f32: return Context.getVectorType(Type::FloatTy, 8); - case MVT::v2f64: return Context.getVectorType(Type::DoubleTy, 2); - case MVT::v4f64: return Context.getVectorType(Type::DoubleTy, 4); + case MVT::isVoid: return Type::getVoidTy(Context); + case MVT::i1: return Type::getInt1Ty(Context); + case MVT::i8: return Type::getInt8Ty(Context); + case MVT::i16: return Type::getInt16Ty(Context); + case MVT::i32: return Type::getInt32Ty(Context); + case MVT::i64: return Type::getInt64Ty(Context); + case MVT::i128: return IntegerType::get(Context, 128); + case MVT::f32: return Type::getFloatTy(Context); + case MVT::f64: return Type::getDoubleTy(Context); + case MVT::f80: return Type::getX86_FP80Ty(Context); + case MVT::f128: return Type::getFP128Ty(Context); + case MVT::ppcf128: return Type::getPPC_FP128Ty(Context); + case MVT::x86mmx: return Type::getX86_MMXTy(Context); + case MVT::v2i8: return VectorType::get(Type::getInt8Ty(Context), 2); + case MVT::v4i8: return VectorType::get(Type::getInt8Ty(Context), 4); + case MVT::v8i8: return VectorType::get(Type::getInt8Ty(Context), 8); + case MVT::v16i8: return VectorType::get(Type::getInt8Ty(Context), 16); + case MVT::v32i8: return VectorType::get(Type::getInt8Ty(Context), 32); + case MVT::v2i16: return VectorType::get(Type::getInt16Ty(Context), 2); + case MVT::v4i16: return VectorType::get(Type::getInt16Ty(Context), 4); + case MVT::v8i16: return VectorType::get(Type::getInt16Ty(Context), 8); + case MVT::v16i16: return VectorType::get(Type::getInt16Ty(Context), 16); + case MVT::v2i32: return VectorType::get(Type::getInt32Ty(Context), 2); + case MVT::v4i32: return VectorType::get(Type::getInt32Ty(Context), 4); + case MVT::v8i32: return VectorType::get(Type::getInt32Ty(Context), 8); + case MVT::v1i64: return VectorType::get(Type::getInt64Ty(Context), 1); + case MVT::v2i64: return VectorType::get(Type::getInt64Ty(Context), 2); + case MVT::v4i64: return VectorType::get(Type::getInt64Ty(Context), 4); + case MVT::v8i64: return VectorType::get(Type::getInt64Ty(Context), 8); + case MVT::v2f32: return VectorType::get(Type::getFloatTy(Context), 2); + case MVT::v4f32: return VectorType::get(Type::getFloatTy(Context), 4); + case MVT::v8f32: return VectorType::get(Type::getFloatTy(Context), 8); + case MVT::v2f64: return VectorType::get(Type::getDoubleTy(Context), 2); + case MVT::v4f64: return VectorType::get(Type::getDoubleTy(Context), 4); + case MVT::Metadata: return Type::getMetadataTy(Context); } } -/// getMVT - Return the value type corresponding to the specified type. This +/// getEVT - Return the value type corresponding to the specified type. This /// returns all pointers as MVT::iPTR. If HandleUnknown is true, unknown types /// are returned as Other, otherwise they are invalid. -MVT MVT::getMVT(const Type *Ty, bool HandleUnknown){ +EVT EVT::getEVT(const Type *Ty, bool HandleUnknown){ switch (Ty->getTypeID()) { default: - if (HandleUnknown) return MVT::Other; - LLVM_UNREACHABLE("Unknown type!"); + if (HandleUnknown) return MVT(MVT::Other); + llvm_unreachable("Unknown type!"); return MVT::isVoid; case Type::VoidTyID: return MVT::isVoid; case Type::IntegerTyID: - return getIntegerVT(cast(Ty)->getBitWidth()); - case Type::FloatTyID: return MVT::f32; - case Type::DoubleTyID: return MVT::f64; - case Type::X86_FP80TyID: return MVT::f80; - case Type::FP128TyID: return MVT::f128; - case Type::PPC_FP128TyID: return MVT::ppcf128; - case Type::PointerTyID: return MVT::iPTR; + return getIntegerVT(Ty->getContext(), cast(Ty)->getBitWidth()); + case Type::FloatTyID: return MVT(MVT::f32); + case Type::DoubleTyID: return MVT(MVT::f64); + case Type::X86_FP80TyID: return MVT(MVT::f80); + case Type::X86_MMXTyID: return MVT(MVT::x86mmx); + case Type::FP128TyID: return MVT(MVT::f128); + case Type::PPC_FP128TyID: return MVT(MVT::ppcf128); + case Type::PointerTyID: return MVT(MVT::iPTR); case Type::VectorTyID: { const VectorType *VTy = cast(Ty); - return getVectorVT(getMVT(VTy->getElementType(), false), + return getVectorVT(Ty->getContext(), getEVT(VTy->getElementType(), false), VTy->getNumElements()); } } -} \ No newline at end of file +}