aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2011-12-17 00:04:22 +0000
committerDan Gohman <gohman@apple.com>2011-12-17 00:04:22 +0000
commitce16339930a2b03e53b4e6399ef59c092a7f2cfa (patch)
tree8265888014a73aa5764f99d7b6bb0553066f78bc /include
parent2e1b0c0cd9fab8f1841e1039cf39dcceeba70f73 (diff)
downloadexternal_llvm-ce16339930a2b03e53b4e6399ef59c092a7f2cfa.zip
external_llvm-ce16339930a2b03e53b4e6399ef59c092a7f2cfa.tar.gz
external_llvm-ce16339930a2b03e53b4e6399ef59c092a7f2cfa.tar.bz2
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 'include')
-rw-r--r--include/llvm-c/Core.h3
-rw-r--r--include/llvm/Bitcode/LLVMBitCodes.h2
-rw-r--r--include/llvm/Type.h36
3 files changed, 25 insertions, 16 deletions
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index 3ffaddd..ed7d469 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -203,6 +203,7 @@ typedef enum {
typedef enum {
LLVMVoidTypeKind, /**< type with no size */
+ LLVMHalfTypeKind, /**< 16 bit floating point type */
LLVMFloatTypeKind, /**< 32 bit floating point type */
LLVMDoubleTypeKind, /**< 64 bit floating point type */
LLVMX86_FP80TypeKind, /**< 80 bit floating point type (X87) */
@@ -382,12 +383,14 @@ LLVMTypeRef LLVMIntType(unsigned NumBits);
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy);
/* Operations on real types */
+LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C);
LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C);
+LLVMTypeRef LLVMHalfType(void);
LLVMTypeRef LLVMFloatType(void);
LLVMTypeRef LLVMDoubleType(void);
LLVMTypeRef LLVMX86FP80Type(void);
diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h
index 48d1695..0b65145 100644
--- a/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/include/llvm/Bitcode/LLVMBitCodes.h
@@ -94,7 +94,7 @@ namespace bitc {
TYPE_CODE_FUNCTION_OLD = 9, // FUNCTION: [vararg, attrid, retty,
// paramty x N]
- // Code #10 is unused.
+ TYPE_CODE_HALF = 10, // HALF
TYPE_CODE_ARRAY = 11, // ARRAY: [numelts, eltty]
TYPE_CODE_VECTOR = 12, // VECTOR: [numelts, eltty]
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index a571b4d..4b5f434 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -47,23 +47,24 @@ public:
enum TypeID {
// PrimitiveTypes - make sure LastPrimitiveTyID stays up to date.
VoidTyID = 0, ///< 0: type with no size
- FloatTyID, ///< 1: 32-bit floating point type
- DoubleTyID, ///< 2: 64-bit floating point type
- X86_FP80TyID, ///< 3: 80-bit floating point type (X87)
- FP128TyID, ///< 4: 128-bit floating point type (112-bit mantissa)
- PPC_FP128TyID, ///< 5: 128-bit floating point type (two 64-bits, PowerPC)
- LabelTyID, ///< 6: Labels
- MetadataTyID, ///< 7: Metadata
- X86_MMXTyID, ///< 8: MMX vectors (64 bits, X86 specific)
+ HalfTyID, ///< 1: 32-bit floating point type
+ FloatTyID, ///< 2: 32-bit floating point type
+ DoubleTyID, ///< 3: 64-bit floating point type
+ X86_FP80TyID, ///< 4: 80-bit floating point type (X87)
+ FP128TyID, ///< 5: 128-bit floating point type (112-bit mantissa)
+ PPC_FP128TyID, ///< 6: 128-bit floating point type (two 64-bits, PowerPC)
+ LabelTyID, ///< 7: Labels
+ MetadataTyID, ///< 8: Metadata
+ X86_MMXTyID, ///< 9: MMX vectors (64 bits, X86 specific)
// Derived types... see DerivedTypes.h file.
// Make sure FirstDerivedTyID stays up to date!
- IntegerTyID, ///< 9: Arbitrary bit width integers
- FunctionTyID, ///< 10: Functions
- StructTyID, ///< 11: Structures
- ArrayTyID, ///< 12: Arrays
- PointerTyID, ///< 13: Pointers
- VectorTyID, ///< 14: SIMD 'packed' format, or other vector type
+ IntegerTyID, ///< 10: Arbitrary bit width integers
+ FunctionTyID, ///< 11: Functions
+ StructTyID, ///< 12: Structures
+ ArrayTyID, ///< 13: Arrays
+ PointerTyID, ///< 14: Pointers
+ VectorTyID, ///< 15: SIMD 'packed' format, or other vector type
NumTypeIDs, // Must remain as last defined ID
LastPrimitiveTyID = X86_MMXTyID,
@@ -121,6 +122,9 @@ public:
/// isVoidTy - Return true if this is 'void'.
bool isVoidTy() const { return ID == VoidTyID; }
+ /// isHalfTy - Return true if this is 'half', a 16-bit IEEE fp type.
+ bool isHalfTy() const { return ID == HalfTyID; }
+
/// isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type.
bool isFloatTy() const { return ID == FloatTyID; }
@@ -139,7 +143,7 @@ public:
/// isFloatingPointTy - Return true if this is one of the five floating point
/// types
bool isFloatingPointTy() const {
- return ID == FloatTyID || ID == DoubleTyID ||
+ return ID == HalfTyID || ID == FloatTyID || ID == DoubleTyID ||
ID == X86_FP80TyID || ID == FP128TyID || ID == PPC_FP128TyID;
}
@@ -310,6 +314,7 @@ public:
//
static Type *getVoidTy(LLVMContext &C);
static Type *getLabelTy(LLVMContext &C);
+ static Type *getHalfTy(LLVMContext &C);
static Type *getFloatTy(LLVMContext &C);
static Type *getDoubleTy(LLVMContext &C);
static Type *getMetadataTy(LLVMContext &C);
@@ -328,6 +333,7 @@ public:
// Convenience methods for getting pointer types with one of the above builtin
// types as pointee.
//
+ static PointerType *getHalfPtrTy(LLVMContext &C, unsigned AS = 0);
static PointerType *getFloatPtrTy(LLVMContext &C, unsigned AS = 0);
static PointerType *getDoublePtrTy(LLVMContext &C, unsigned AS = 0);
static PointerType *getX86_FP80PtrTy(LLVMContext &C, unsigned AS = 0);