diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-27 04:20:05 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-27 04:20:05 +0000 |
| commit | bdef5df44e59e941e71e16eebd2001b38e22e901 (patch) | |
| tree | 26fbb16c2eeae90b6ba20d091f1e65895b37000b /clang/lib | |
| parent | 3e113409cb69ad9bc10224c333e47dc8395caef9 (diff) | |
| download | bcm5719-llvm-bdef5df44e59e941e71e16eebd2001b38e22e901.tar.gz bcm5719-llvm-bdef5df44e59e941e71e16eebd2001b38e22e901.zip | |
Generalize the float type generation code, and specifically fix the
codegen of X86 long double.
llvm-svn: 51578
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTypes.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index b640c912e5c..aa0d2ed0531 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -161,6 +161,21 @@ void CodeGenTypes::CollectObjCIvarTypes(ObjCInterfaceDecl *ObjCClass, } } +static const llvm::Type* getTypeForFormat(const llvm::fltSemantics * format) { + if (format == &llvm::APFloat::IEEEsingle) + return llvm::Type::FloatTy; + if (format == &llvm::APFloat::IEEEdouble) + return llvm::Type::DoubleTy; + if (format == &llvm::APFloat::IEEEquad) + return llvm::Type::FP128Ty; + if (format == &llvm::APFloat::PPCDoubleDouble) + return llvm::Type::PPC_FP128Ty; + if (format == &llvm::APFloat::x87DoubleExtended) + return llvm::Type::X86_FP80Ty; + assert(9 && "Unknown float format!"); + return 0; +} + const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { const clang::Type &Ty = *T.getCanonicalType(); @@ -195,13 +210,12 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { return llvm::IntegerType::get( static_cast<unsigned>(Context.getTypeSize(T))); - case BuiltinType::Float: return llvm::Type::FloatTy; + case BuiltinType::Float: + return getTypeForFormat(Context.Target.getFloatFormat()); case BuiltinType::Double: - return (Context.Target.getDoubleFormat() == &llvm::APFloat::IEEEdouble) ? - llvm::Type::DoubleTy : llvm::Type::FloatTy; + return getTypeForFormat(Context.Target.getDoubleFormat()); case BuiltinType::LongDouble: - // FIXME: mapping long double onto double. - return llvm::Type::DoubleTy; + return getTypeForFormat(Context.Target.getLongDoubleFormat()); } break; } |

