From dbaf4bc5864d80a3f3e51700219c30900cde7300 Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Mon, 29 Oct 2012 14:59:24 +0000 Subject: [PATCH] This patch adds alignment information for long double to the 64-bit PowerPC ELF subtarget. The existing description string is moved from PPC64TargetInfo to its DarwinTargetInfo subclass, to avoid any changes to the Darwin ABI. PPC64TargetInfo now has two possible description strings: one for FreeBSD, which requires 8-byte alignment, and a default string that requires 16-byte alignment. I've added a test for PPC64 Linux to verify the 16-byte alignment. If somebody wants to add a separate test for FreeBSD, that would be great. Note that there is a companion patch to update the alignment information in LLVM, which I am committing now as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166927 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 13 ++++++++++--- test/CodeGen/ppc64-align-long-double.c | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/CodeGen/ppc64-align-long-double.c diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 1ab151e5ef..eb4bd8582f 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1054,13 +1054,18 @@ public: IntMaxType = SignedLong; UIntMaxType = UnsignedLong; Int64Type = SignedLong; - DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" - "i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"; if (getTriple().getOS() == llvm::Triple::FreeBSD) { LongDoubleWidth = LongDoubleAlign = 64; LongDoubleFormat = &llvm::APFloat::IEEEdouble; - } + DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" + "i64:64:64-f32:32:32-f64:64:64-f128:64:64-" + "v128:128:128-n32:64"; + } else + DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" + "i64:64:64-f32:32:32-f64:64:64-f128:128:128-" + "v128:128:128-n32:64"; + } virtual BuiltinVaListKind getBuiltinVaListKind() const { return TargetInfo::CharPtrBuiltinVaList; @@ -1094,6 +1099,8 @@ public: : DarwinTargetInfo(triple) { HasAlignMac68kSupport = true; SuitableAlign = 128; + DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" + "i64:64:64-f32:32:32-f64:64:64-v128:128:128-n32:64"; } }; } // end anonymous namespace. diff --git a/test/CodeGen/ppc64-align-long-double.c b/test/CodeGen/ppc64-align-long-double.c new file mode 100644 index 0000000000..c4dcfa0723 --- /dev/null +++ b/test/CodeGen/ppc64-align-long-double.c @@ -0,0 +1,18 @@ +// REQUIRES: ppc64-registered-target +// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s + +// CHECK: -f128:128:128- + +struct S { + double a; + long double b; +}; + +// CHECK: %struct.{{[a-zA-Z0-9]+}} = type { double, ppc_fp128 } + +long double test (struct S x) +{ + return x.b; +} + +// CHECK: %{{[0-9]}} = load ppc_fp128* %{{[a-zA-Z0-9]+}}, align 16 -- 2.50.1