#include "llvm/ADT/StringExtras.h"
#include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
MVT MVT::getExtendedIntegerVT(unsigned BitWidth) {
MVT VT;
- VT.LLVMTy = IntegerType::get(BitWidth);
+ VT.LLVMTy = getGlobalContext().getIntegerType(BitWidth);
assert(VT.isExtended() && "Type is not extended!");
return VT;
}
MVT MVT::getExtendedVectorVT(MVT VT, unsigned NumElements) {
MVT ResultVT;
- ResultVT.LLVMTy = VectorType::get(VT.getTypeForMVT(), NumElements);
+ ResultVT.LLVMTy = getGlobalContext().getVectorType(
+ VT.getTypeForMVT(getGlobalContext()),
+ NumElements);
assert(ResultVT.isExtended() && "Type is not extended!");
return ResultVT;
}
return isExtendedVector() && getSizeInBits() == 128;
}
+bool MVT::isExtended256BitVector() const {
+ return isExtendedVector() && getSizeInBits() == 256;
+}
+
MVT MVT::getExtendedVectorElementType() const {
assert(isExtended() && "Type is not extended!");
return MVT::getMVT(cast<VectorType>(LLVMTy)->getElementType());
if (const VectorType *VTy = dyn_cast<VectorType>(LLVMTy))
return VTy->getBitWidth();
assert(false && "Unrecognized extended type!");
+ return 0; // Suppress warnings.
}
/// getMVTString - This function returns value type as a string, e.g. "i32".
getVectorElementType().getMVTString();
if (isInteger())
return "i" + utostr(getSizeInBits());
- assert(0 && "Invalid MVT!");
+ llvm_unreachable("Invalid MVT!");
return "?";
case MVT::i1: return "i1";
case MVT::i8: return "i8";
case MVT::isVoid: return "isVoid";
case MVT::Other: return "ch";
case MVT::Flag: return "flag";
+ case MVT::v2i8: return "v2i8";
+ case MVT::v4i8: return "v4i8";
case MVT::v8i8: return "v8i8";
- case MVT::v4i16: return "v4i16";
- case MVT::v2i32: return "v2i32";
- case MVT::v1i64: return "v1i64";
case MVT::v16i8: return "v16i8";
+ case MVT::v32i8: return "v32i8";
+ case MVT::v2i16: return "v2i16";
+ case MVT::v4i16: return "v4i16";
case MVT::v8i16: return "v8i16";
+ case MVT::v16i16: return "v16i16";
+ case MVT::v2i32: return "v2i32";
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::v2f32: return "v2f32";
case MVT::v4f32: return "v4f32";
+ case MVT::v8f32: return "v8f32";
case MVT::v2f64: return "v2f64";
- case MVT::v3i32: return "v3i32";
- case MVT::v3f32: return "v3f32";
+ case MVT::v4f64: return "v4f64";
}
}
/// getTypeForMVT - This method returns an LLVM type corresponding to the
/// specified MVT. For integer types, this returns an unsigned type. Note
/// that this will abort for types that cannot be represented.
-const Type *MVT::getTypeForMVT() const {
+const Type *MVT::getTypeForMVT(LLVMContext &Context) const {
switch (V) {
default:
- if (isVector())
- return VectorType::get(getVectorElementType().getTypeForMVT(),
- getVectorNumElements());
- if (isInteger())
- return IntegerType::get(getSizeInBits());
- assert(0 && "MVT does not correspond to LLVM type!");
- return Type::VoidTy;
+ 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 IntegerType::get(128);
+ 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::v8i8: return VectorType::get(Type::Int8Ty, 8);
- case MVT::v4i16: return VectorType::get(Type::Int16Ty, 4);
- case MVT::v2i32: return VectorType::get(Type::Int32Ty, 2);
- case MVT::v1i64: return VectorType::get(Type::Int64Ty, 1);
- case MVT::v16i8: return VectorType::get(Type::Int8Ty, 16);
- case MVT::v8i16: return VectorType::get(Type::Int16Ty, 8);
- case MVT::v4i32: return VectorType::get(Type::Int32Ty, 4);
- case MVT::v2i64: return VectorType::get(Type::Int64Ty, 2);
- case MVT::v2f32: return VectorType::get(Type::FloatTy, 2);
- case MVT::v4f32: return VectorType::get(Type::FloatTy, 4);
- case MVT::v2f64: return VectorType::get(Type::DoubleTy, 2);
- case MVT::v3i32: return VectorType::get(Type::Int32Ty, 3);
- case MVT::v3f32: return VectorType::get(Type::FloatTy, 3);
- }
+ 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, 8);
+ case MVT::v16i16: return Context.getVectorType(Type::Int16Ty, 16);
+ case MVT::v2i32: return Context.getVectorType(Type::Int32Ty, 2);
+ 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::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);
+ }
}
/// getMVT - Return the value type corresponding to the specified type. This
switch (Ty->getTypeID()) {
default:
if (HandleUnknown) return MVT::Other;
- assert(0 && "Unknown type!");
+ llvm_unreachable("Unknown type!");
return MVT::isVoid;
case Type::VoidTyID:
return MVT::isVoid;