diff options
author | Dan Gohman <gohman@apple.com> | 2011-12-17 00:04:22 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2011-12-17 00:04:22 +0000 |
commit | ce16339930a2b03e53b4e6399ef59c092a7f2cfa (patch) | |
tree | 8265888014a73aa5764f99d7b6bb0553066f78bc /lib/VMCore/Type.cpp | |
parent | 2e1b0c0cd9fab8f1841e1039cf39dcceeba70f73 (diff) | |
download | llvm-ce16339930a2b03e53b4e6399ef59c092a7f2cfa.tar.gz llvm-ce16339930a2b03e53b4e6399ef59c092a7f2cfa.tar.bz2 llvm-ce16339930a2b03e53b4e6399ef59c092a7f2cfa.tar.xz |
The powers that be have decided that LLVM IR should now support 16-bit
"half precision" floating-point with a first-class type.
This patch adds basic IR support (but not codegen support).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r-- | lib/VMCore/Type.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 469defdb85..f4fad667a1 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -25,6 +25,7 @@ using namespace llvm; Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) { switch (IDNumber) { case VoidTyID : return getVoidTy(C); + case HalfTyID : return getHalfTy(C); case FloatTyID : return getFloatTy(C); case DoubleTyID : return getDoubleTy(C); case X86_FP80TyID : return getX86_FP80Ty(C); @@ -73,7 +74,7 @@ bool Type::isIntOrIntVectorTy() const { /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP types. /// bool Type::isFPOrFPVectorTy() const { - if (ID == Type::FloatTyID || ID == Type::DoubleTyID || + if (ID == Type::HalfTyID || ID == Type::FloatTyID || ID == Type::DoubleTyID || ID == Type::FP128TyID || ID == Type::X86_FP80TyID || ID == Type::PPC_FP128TyID) return true; @@ -139,6 +140,7 @@ bool Type::isEmptyTy() const { unsigned Type::getPrimitiveSizeInBits() const { switch (getTypeID()) { + case Type::HalfTyID: return 16; case Type::FloatTyID: return 32; case Type::DoubleTyID: return 64; case Type::X86_FP80TyID: return 80; @@ -165,6 +167,7 @@ int Type::getFPMantissaWidth() const { if (const VectorType *VTy = dyn_cast<VectorType>(this)) return VTy->getElementType()->getFPMantissaWidth(); assert(isFloatingPointTy() && "Not a floating point type!"); + if (ID == HalfTyID) return 11; if (ID == FloatTyID) return 24; if (ID == DoubleTyID) return 53; if (ID == X86_FP80TyID) return 64; @@ -207,6 +210,7 @@ bool Type::isSizedDerivedType() const { Type *Type::getVoidTy(LLVMContext &C) { return &C.pImpl->VoidTy; } Type *Type::getLabelTy(LLVMContext &C) { return &C.pImpl->LabelTy; } +Type *Type::getHalfTy(LLVMContext &C) { return &C.pImpl->HalfTy; } Type *Type::getFloatTy(LLVMContext &C) { return &C.pImpl->FloatTy; } Type *Type::getDoubleTy(LLVMContext &C) { return &C.pImpl->DoubleTy; } Type *Type::getMetadataTy(LLVMContext &C) { return &C.pImpl->MetadataTy; } @@ -225,6 +229,10 @@ IntegerType *Type::getIntNTy(LLVMContext &C, unsigned N) { return IntegerType::get(C, N); } +PointerType *Type::getHalfPtrTy(LLVMContext &C, unsigned AS) { + return getHalfTy(C)->getPointerTo(AS); +} + PointerType *Type::getFloatPtrTy(LLVMContext &C, unsigned AS) { return getFloatTy(C)->getPointerTo(AS); } |