diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -5030,6 +5030,10 @@ bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const override; + + void emitTargetMetadata(CodeGen::CodeGenModule &CGM, + const llvm::MapVector + &MangledDeclNames) const override; }; class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo { @@ -5443,6 +5447,22 @@ /*IsAIX*/ false); } +void PPC64_SVR4_TargetCodeGenInfo::emitTargetMetadata( + CodeGen::CodeGenModule &CGM, + const llvm::MapVector &MangledDeclNames) const { + llvm::LLVMContext &Ctx = CGM.getLLVMContext(); + const auto *flt = &CGM.getTarget().getLongDoubleFormat(); + if (flt == &llvm::APFloat::PPCDoubleDouble()) + CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi", + llvm::MDString::get(Ctx, "doubledouble")); + else if (flt == &llvm::APFloat::IEEEquad()) + CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi", + llvm::MDString::get(Ctx, "ieeequad")); + else if (flt == &llvm::APFloat::IEEEdouble()) + CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi", + llvm::MDString::get(Ctx, "ieeedouble")); +} + bool PPC64TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const { diff --git a/clang/test/CodeGen/ppc64-float-abi-attr.c b/clang/test/CodeGen/ppc64-float-abi-attr.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/ppc64-float-abi-attr.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -mabi=ieeelongdouble -o - | FileCheck %s --check-prefix=IEEE +// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -mlong-double-64 -o - | FileCheck %s --check-prefix=LDBL64 + +long double foo(long double a, long double b) { + return a + b; +} + +// CHECK: !{{[0-9]+}} = !{i32 1, !"float-abi", !"doubledouble"} +// IEEE: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeequad"} +// LDBL64: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeedouble"}