From aa4a99b4a62615db243f7a5c433169f2fc704420 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Fri, 14 Oct 2011 23:23:15 +0000 Subject: Provide half floating point support as a storage only type. Lack of half FP was a regression compared to llvm-gcc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142016 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenTypes.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/CodeGen/CodeGenTypes.cpp') diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 03a15ae67e..e0d9218965 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -263,6 +263,8 @@ void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) { static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext, const llvm::fltSemantics &format) { + if (&format == &llvm::APFloat::IEEEhalf) + return llvm::Type::getInt16Ty(VMContext); if (&format == &llvm::APFloat::IEEEsingle) return llvm::Type::getFloatTy(VMContext); if (&format == &llvm::APFloat::IEEEdouble) @@ -341,6 +343,14 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { static_cast(Context.getTypeSize(T))); break; + case BuiltinType::Half: + // Half is special: it might be lowered to i16 (and will be storage-only + // type),. or can be represented as a set of native operations. + + // FIXME: Ask target which kind of half FP it prefers (storage only vs + // native). + ResultType = llvm::Type::getInt16Ty(getLLVMContext()); + break; case BuiltinType::Float: case BuiltinType::Double: case BuiltinType::LongDouble: -- cgit v1.2.3