summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2018-01-06 21:49:54 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2018-01-06 21:49:54 +0000
commitdfecbe9ad865ad769e36208b21cd31b773d9a323 (patch)
treee9dd783a5a98a655fa50ce55fe385ebf43288233 /clang/test
parentcf93feb9815529acfc4f5de22fe1ba7d35100996 (diff)
downloadbcm5719-llvm-dfecbe9ad865ad769e36208b21cd31b773d9a323.tar.gz
bcm5719-llvm-dfecbe9ad865ad769e36208b21cd31b773d9a323.zip
Add support for a limited subset of TS 18661-3 math builtins.
These just overloads for _Float128. They're supported by GCC 7 and used by glibc. APFloat support is already there so just add the overloads. __builtin_copysignf128 __builtin_fabsf128 __builtin_huge_valf128 __builtin_inff128 __builtin_nanf128 __builtin_nansf128 This is the same support that GCC has, according to the documentation, but limited to _Float128. llvm-svn: 321948
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/math-builtins.c20
-rw-r--r--clang/test/Sema/constant-builtins-2.c25
2 files changed, 35 insertions, 10 deletions
diff --git a/clang/test/CodeGen/math-builtins.c b/clang/test/CodeGen/math-builtins.c
index 799d91b4ec0..89be56dc186 100644
--- a/clang/test/CodeGen/math-builtins.c
+++ b/clang/test/CodeGen/math-builtins.c
@@ -24,23 +24,27 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
// HAS_ERRNO: declare float @atan2f(float, float) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) [[NOT_READNONE]]
- __builtin_copysign(f,f); __builtin_copysignf(f,f);__builtin_copysignl(f,f);
+ __builtin_copysign(f,f); __builtin_copysignf(f,f); __builtin_copysignl(f,f); __builtin_copysignf128(f,f);
// NO__ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// NO__ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare fp128 @llvm.copysign.f128(fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare fp128 @llvm.copysign.f128(fp128, fp128) [[READNONE_INTRINSIC]]
- __builtin_fabs(f); __builtin_fabsf(f); __builtin_fabsl(f);
+ __builtin_fabs(f); __builtin_fabsf(f); __builtin_fabsl(f); __builtin_fabsf128(f);
// NO__ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
+// HAS_ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_frexp(f,i); __builtin_frexpf(f,i); __builtin_frexpl(f,i);
@@ -51,14 +55,14 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
// HAS_ERRNO: declare float @frexpf(float, i32*) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @frexpl(x86_fp80, i32*) [[NOT_READNONE]]
- __builtin_huge_val(); __builtin_huge_valf(); __builtin_huge_vall();
+ __builtin_huge_val(); __builtin_huge_valf(); __builtin_huge_vall(); __builtin_huge_valf128();
// NO__ERRNO-NOT: .huge
// NO__ERRNO-NOT: @huge
// HAS_ERRNO-NOT: .huge
// HAS_ERRNO-NOT: @huge
- __builtin_inf(); __builtin_inff(); __builtin_infl();
+ __builtin_inf(); __builtin_inff(); __builtin_infl(); __builtin_inff128();
// NO__ERRNO-NOT: .inf
// NO__ERRNO-NOT: @inf
@@ -83,23 +87,27 @@ void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
// HAS_ERRNO: declare float @modff(float, float*) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80, x86_fp80*) [[NOT_READNONE]]
- __builtin_nan(c); __builtin_nanf(c); __builtin_nanl(c);
+ __builtin_nan(c); __builtin_nanf(c); __builtin_nanl(c); __builtin_nanf128(c);
// NO__ERRNO: declare double @nan(i8*) [[READNONE]]
// NO__ERRNO: declare float @nanf(i8*) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @nanl(i8*) [[READNONE]]
+// NO__ERRNO: declare fp128 @nanf128(i8*) [[READNONE]]
// HAS_ERRNO: declare double @nan(i8*) [[READNONE:#[0-9]+]]
// HAS_ERRNO: declare float @nanf(i8*) [[READNONE]]
// HAS_ERRNO: declare x86_fp80 @nanl(i8*) [[READNONE]]
+// HAS_ERRNO: declare fp128 @nanf128(i8*) [[READNONE]]
- __builtin_nans(c); __builtin_nansf(c); __builtin_nansl(c);
+ __builtin_nans(c); __builtin_nansf(c); __builtin_nansl(c); __builtin_nansf128(c);
// NO__ERRNO: declare double @nans(i8*) [[READNONE]]
// NO__ERRNO: declare float @nansf(i8*) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @nansl(i8*) [[READNONE]]
+// NO__ERRNO: declare fp128 @nansf128(i8*) [[READNONE]]
// HAS_ERRNO: declare double @nans(i8*) [[READNONE]]
// HAS_ERRNO: declare float @nansf(i8*) [[READNONE]]
// HAS_ERRNO: declare x86_fp80 @nansl(i8*) [[READNONE]]
+// HAS_ERRNO: declare fp128 @nansf128(i8*) [[READNONE]]
__builtin_pow(f,f); __builtin_powf(f,f); __builtin_powl(f,f);
diff --git a/clang/test/Sema/constant-builtins-2.c b/clang/test/Sema/constant-builtins-2.c
index a4baecb6155..40cfce1f4a0 100644
--- a/clang/test/Sema/constant-builtins-2.c
+++ b/clang/test/Sema/constant-builtins-2.c
@@ -5,24 +5,35 @@
double g0 = __builtin_huge_val();
float g1 = __builtin_huge_valf();
long double g2 = __builtin_huge_vall();
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g2_2 = __builtin_huge_valf128();
+#endif
double g3 = __builtin_inf();
float g4 = __builtin_inff();
long double g5 = __builtin_infl();
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g5_2 = __builtin_inff128();
+#endif
double g6 = __builtin_nan("");
float g7 = __builtin_nanf("");
long double g8 = __builtin_nanl("");
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g8_2 = __builtin_nanf128("");
+#endif
// GCC constant folds these too (via native strtol):
//double g6_1 = __builtin_nan("1");
//float g7_1 = __builtin_nanf("1");
//long double g8_1 = __builtin_nanl("1");
-// APFloat doesn't have signalling NaN functions.
-//double g9 = __builtin_nans("");
-//float g10 = __builtin_nansf("");
-//long double g11 = __builtin_nansl("");
+double g9 = __builtin_nans("");
+float g10 = __builtin_nansf("");
+long double g11 = __builtin_nansl("");
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g11_2 = __builtin_nansf128("");
+#endif
//int g12 = __builtin_abs(-12);
@@ -32,10 +43,16 @@ double g13_1 = __builtin_fabs(-__builtin_inf());
float g14 = __builtin_fabsf(-12.f);
// GCC doesn't eat this one.
//long double g15 = __builtin_fabsfl(-12.0L);
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g15_2 = __builtin_fabsf128(-12.q);
+#endif
float g16 = __builtin_copysign(1.0, -1.0);
double g17 = __builtin_copysignf(1.0f, -1.0f);
long double g18 = __builtin_copysignl(1.0L, -1.0L);
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+__float128 g18_2 = __builtin_copysignf128(1.0q, -1.0q);
+#endif
char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))];
char classify_snan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))];
OpenPOWER on IntegriCloud