[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365866: [X86][PowerPC] Support -mlong-double-128 (authored 
by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets/PPC.cpp
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/ppc64-long-double.cpp
  cfe/trunk/test/CodeGen/x86-long-double.cpp
  cfe/trunk/test/Driver/mlong-double-128.c

Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -133,6 +133,10 @@
 LongDoubleFormat = ::APFloat::x87DoubleExtended();
   }
 
+  const char *getLongDoubleMangling() const override {
+return LongDoubleFormat == ::APFloat::IEEEquad() ? "g" : "e";
+  }
+
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
 return SSELevel == NoSSE ? 2 : 0;
@@ -845,8 +849,6 @@
   : LinuxTargetInfo(Triple, Opts) {
 LongDoubleFormat = ::APFloat::IEEEquad();
   }
-
-  const char *getLongDoubleMangling() const override { return "g"; }
 };
 } // namespace targets
 } // namespace clang
Index: cfe/trunk/lib/Basic/Targets/PPC.cpp
===
--- cfe/trunk/lib/Basic/Targets/PPC.cpp
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp
@@ -465,6 +465,8 @@
   if (HasAltivec)
 Opts.AltiVec = 1;
   TargetInfo::adjust(Opts);
+  if (LongDoubleFormat != ::APFloat::IEEEdouble())
+LongDoubleFormat = ::APFloat::PPCDoubleDouble();
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {
Index: cfe/trunk/lib/Basic/TargetInfo.cpp
===
--- cfe/trunk/lib/Basic/TargetInfo.cpp
+++ cfe/trunk/lib/Basic/TargetInfo.cpp
@@ -373,10 +373,15 @@
 LongDoubleFormat = ::APFloat::IEEEquad();
   }
 
-  if (Opts.LongDoubleSize && Opts.LongDoubleSize == DoubleWidth) {
-LongDoubleWidth = DoubleWidth;
-LongDoubleAlign = DoubleAlign;
-LongDoubleFormat = DoubleFormat;
+  if (Opts.LongDoubleSize) {
+if (Opts.LongDoubleSize == DoubleWidth) {
+  LongDoubleWidth = DoubleWidth;
+  LongDoubleAlign = DoubleAlign;
+  LongDoubleFormat = DoubleFormat;
+} else if (Opts.LongDoubleSize == 128) {
+  LongDoubleWidth = LongDoubleAlign = 128;
+  LongDoubleFormat = ::APFloat::IEEEquad();
+}
   }
 
   if (Opts.NewAlignOverride)
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4012,15 +4012,15 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
-TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
-} else {
+TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64())
+  A->render(Args, CmdArgs);
+else
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
-}
   }
 
   // Decide whether to use verbose asm. Verbose assembly is the default on
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2025,6 +2025,8 @@
   HelpText<"Generate branches with extended addressability, usually via 

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 209404.
MaskRay added a comment.

Use   A->render(Args, CmdArgs);


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c

Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4012,15 +4012,15 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
-TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
-} else {
+

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm with suggestion




Comment at: lib/Driver/ToolChains/Clang.cpp:4009
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  CmdArgs.push_back(A->getOption().matches(options::OPT_mlong_double_64)
+? "-mlong-double-64"

There should be a shorthand for passing through the argument, `A->render()` or 
something.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping:) It'll be great to have D64277  
(-mlong-double-128) D64282  (libcall) D64283 
 (-mabi=ieeelongdouble) before 9.0.0 is 
branched.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208704.
MaskRay added a comment.

Rebase

The openmp issue was fixed by r365485


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c

Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4001,11 +4001,14 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

ABataev wrote:
> MaskRay wrote:
> > ABataev wrote:
> > > MaskRay wrote:
> > > > ABataev wrote:
> > > > > MaskRay wrote:
> > > > > > @ABataev The mangling scheme of __float128 is broken on x86 before 
> > > > > > this patch. For some reason the two lines no longer apply.. I 
> > > > > > assume you can fix this test properly :)
> > > > > You mean, these lines are not generated anymore? If so, it means that 
> > > > > you broke compatibility between the host and device codegen with this 
> > > > > patch. 
> > > > The two lines are not generated. Can you help fix the test? The 
> > > > mangling scheme of __float128 is incorrect without this patch. If the 
> > > > test relies on that, it should be fixed. I know little about 
> > > > openmp+nvidia to understand what's going on..
> > > Sure, will try to send additional changes next week, most probably on 
> > > Monday. Does this work for you?
> > Thanks!
> Hi, I have a fix for the problem revealed with your patch, will commit it 
> tomorrow. After this, I hope, the problem with the test will disappear.
I fixed the problem, try to update the patch, the test should pass with your 
changes.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-08 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

MaskRay wrote:
> ABataev wrote:
> > MaskRay wrote:
> > > ABataev wrote:
> > > > MaskRay wrote:
> > > > > @ABataev The mangling scheme of __float128 is broken on x86 before 
> > > > > this patch. For some reason the two lines no longer apply.. I assume 
> > > > > you can fix this test properly :)
> > > > You mean, these lines are not generated anymore? If so, it means that 
> > > > you broke compatibility between the host and device codegen with this 
> > > > patch. 
> > > The two lines are not generated. Can you help fix the test? The mangling 
> > > scheme of __float128 is incorrect without this patch. If the test relies 
> > > on that, it should be fixed. I know little about openmp+nvidia to 
> > > understand what's going on..
> > Sure, will try to send additional changes next week, most probably on 
> > Monday. Does this work for you?
> Thanks!
Hi, I have a fix for the problem revealed with your patch, will commit it 
tomorrow. After this, I hope, the problem with the test will disappear.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208402.
MaskRay added a comment.

Rebase after getMangledCodeOfLongDouble -> getLongDoubleMangling rename


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c
  test/OpenMP/nvptx_unsupported_type_codegen.cpp

Index: test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -76,6 +76,3 @@
   f = 1;
   return f;
 }
-
-// CHECK: define weak void @__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*
-// CHECK: store [[BIGTYPE]] 0xL3FFF, [[BIGTYPE]]* %
Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ 

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208314.
MaskRay added a comment.

Rebase


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c
  test/OpenMP/nvptx_unsupported_type_codegen.cpp

Index: test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -76,6 +76,3 @@
   f = 1;
   return f;
 }
-
-// CHECK: define weak void @__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*
-// CHECK: store [[BIGTYPE]] 0xL3FFF, [[BIGTYPE]]* %
Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4001,11 +4001,14 @@
 
   RenderFloatingPointOptions(TC, D, 

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

ABataev wrote:
> MaskRay wrote:
> > ABataev wrote:
> > > MaskRay wrote:
> > > > @ABataev The mangling scheme of __float128 is broken on x86 before this 
> > > > patch. For some reason the two lines no longer apply.. I assume you can 
> > > > fix this test properly :)
> > > You mean, these lines are not generated anymore? If so, it means that you 
> > > broke compatibility between the host and device codegen with this patch. 
> > The two lines are not generated. Can you help fix the test? The mangling 
> > scheme of __float128 is incorrect without this patch. If the test relies on 
> > that, it should be fixed. I know little about openmp+nvidia to understand 
> > what's going on..
> Sure, will try to send additional changes next week, most probably on Monday. 
> Does this work for you?
Thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

MaskRay wrote:
> ABataev wrote:
> > MaskRay wrote:
> > > @ABataev The mangling scheme of __float128 is broken on x86 before this 
> > > patch. For some reason the two lines no longer apply.. I assume you can 
> > > fix this test properly :)
> > You mean, these lines are not generated anymore? If so, it means that you 
> > broke compatibility between the host and device codegen with this patch. 
> The two lines are not generated. Can you help fix the test? The mangling 
> scheme of __float128 is incorrect without this patch. If the test relies on 
> that, it should be fixed. I know little about openmp+nvidia to understand 
> what's going on..
Sure, will try to send additional changes next week, most probably on Monday. 
Does this work for you?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

ABataev wrote:
> MaskRay wrote:
> > @ABataev The mangling scheme of __float128 is broken on x86 before this 
> > patch. For some reason the two lines no longer apply.. I assume you can fix 
> > this test properly :)
> You mean, these lines are not generated anymore? If so, it means that you 
> broke compatibility between the host and device codegen with this patch. 
The two lines are not generated. Can you help fix the test? The mangling scheme 
of __float128 is incorrect without this patch. If the test relies on that, it 
should be fixed. I know little about openmp+nvidia to understand what's going 
on..


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

MaskRay wrote:
> @ABataev The mangling scheme of __float128 is broken on x86 before this 
> patch. For some reason the two lines no longer apply.. I assume you can fix 
> this test properly :)
You mean, these lines are not generated anymore? If so, it means that you broke 
compatibility between the host and device codegen with this patch. 


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added a subscriber: ABataev.
MaskRay added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

@ABataev The mangling scheme of __float128 is broken on x86 before this patch. 
For some reason the two lines no longer apply.. I assume you can fix this test 
properly :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208266.
MaskRay added a comment.
Herald added a subscriber: jdoerfert.

Small adjustment to PPC.cpp to make -mlong-double-128 -mabi=ieeelongdouble 
simpler


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c
  test/OpenMP/nvptx_unsupported_type_codegen.cpp

Index: test/OpenMP/nvptx_unsupported_type_codegen.cpp
===
--- test/OpenMP/nvptx_unsupported_type_codegen.cpp
+++ test/OpenMP/nvptx_unsupported_type_codegen.cpp
@@ -76,6 +76,3 @@
   f = 1;
   return f;
 }
-
-// CHECK: define weak void @__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*
-// CHECK: store [[BIGTYPE]] 0xL3FFF, [[BIGTYPE]]* %
Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- 

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208260.
MaskRay added a comment.

Add a driver test


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c

Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4001,11 +4001,14 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-06 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: awilfox, echristo, erichkeane, hfinkel, jsji, 
majnemer, rnk, rsmith.
Herald added subscribers: cfe-commits, kbarton, nemanjai.
Herald added a project: clang.

This patch makes the driver option -mlong-double-128 available for X86
and PowerPC. The CC1 option -mlong-double-128 is available on all targets
for users to test on unsupported targets.

On PowerPC, -mlong-double-128 uses the IBM extended double format
because we don't support -mabi=ieeelongdouble.


Repository:
  rC Clang

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp

Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4001,11 +4001,14 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  CmdArgs.push_back(A->getOption().matches(options::OPT_mlong_double_64)
+? "-mlong-double-64"
+: "-mlong-double-128");
 } else {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
Index: lib/Basic/Targets/X86.h
===
--- lib/Basic/Targets/X86.h
+++ lib/Basic/Targets/X86.h
@@ -133,6 +133,13 @@
 LongDoubleFormat = ::APFloat::x87DoubleExtended();
   }
 
+  const char