pirama updated this revision to Diff 139666.
pirama added a comment.

- [CodeGen] Mark fma as const for Android


Repository:
  rC Clang

https://reviews.llvm.org/D37302

Files:
  lib/Headers/float.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/math-builtins.c
  test/Headers/float.c

Index: test/Headers/float.c
===================================================================
--- test/Headers/float.c
+++ test/Headers/float.c
@@ -61,6 +61,21 @@
     #if ((FLT_DECIMAL_DIG > DBL_DECIMAL_DIG) || (DBL_DECIMAL_DIG > LDBL_DECIMAL_DIG))
         #error "Mandatory macros {FLT,DBL,LDBL}_DECIMAL_DIG are invalid."
     #endif
+    #ifndef FLT_HAS_SUBNORM
+        #error "Mandatory macro FLT_HAS_SUBNORM is missing."
+    #elif FLT_HAS_SUBNORM != __FLT_HAS_DENORM__
+        #error "Mandatory macro FLT_HAS_SUBNORM is invalid."
+    #endif
+    #ifndef LDBL_HAS_SUBNORM
+        #error "Mandatory macro LDBL_HAS_SUBNORM is missing."
+    #elif LDBL_HAS_SUBNORM != __LDBL_HAS_DENORM__
+        #error "Mandatory macro LDBL_HAS_SUBNORM is invalid."
+    #endif
+    #ifndef DBL_HAS_SUBNORM
+        #error "Mandatory macro DBL_HAS_SUBNORM is missing."
+    #elif DBL_HAS_SUBNORM != __DBL_HAS_DENORM__
+        #error "Mandatory macro DBL_HAS_SUBNORM is invalid."
+    #endif
 #else
     #ifdef FLT_DECIMAL_DIG
         #error "Macro FLT_DECIMAL_DIG should not be defined."
@@ -71,6 +86,15 @@
     #ifdef LDBL_DECIMAL_DIG
         #error "Macro LDBL_DECIMAL_DIG should not be defined."
     #endif
+    #ifdef FLT_HAS_SUBNORM
+        #error "Macro FLT_HAS_SUBNORM should not be defined."
+    #endif
+    #ifdef DBL_HAS_SUBNORM
+        #error "Macro DBL_HAS_SUBNORM should not be defined."
+    #endif
+    #ifdef LDBL_HAS_SUBNORM
+        #error "Macro LDBL_HAS_SUBNORM should not be defined."
+    #endif
 #endif
 
 
Index: test/CodeGen/math-builtins.c
===================================================================
--- test/CodeGen/math-builtins.c
+++ test/CodeGen/math-builtins.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm              %s | FileCheck %s -check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown-android -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_ANDROID
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
 // Test attributes and codegen of math builtins.
@@ -296,6 +297,10 @@
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
 
+// HAS_ERRNO_ANDROID: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
+// HAS_ERRNO_ANDROID: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
+// HAS_ERRNO_ANDROID: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
+
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
@@ -582,5 +587,6 @@
 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
 
 // HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
+// HAS_ERRNO_ANDROID: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 // HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
 
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13109,7 +13109,7 @@
     // errno in those environments even though it could set errno based on the
     // C standard.
     const llvm::Triple &Trip = Context.getTargetInfo().getTriple();
-    if ((Trip.isGNUEnvironment() || Trip.isOSMSVCRT()) &&
+    if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
         !FD->hasAttr<ConstAttr>()) {
       switch (BuiltinID) {
       case Builtin::BI__builtin_fma:
Index: lib/Headers/float.h
===================================================================
--- lib/Headers/float.h
+++ lib/Headers/float.h
@@ -85,6 +85,9 @@
 #    undef FLT_DECIMAL_DIG
 #    undef DBL_DECIMAL_DIG
 #    undef LDBL_DECIMAL_DIG
+#    undef FLT_HAS_SUBNORM
+#    undef DBL_HAS_SUBNORM
+#    undef LDBL_HAS_SUBNORM
 #  endif
 #endif
 
@@ -141,6 +144,9 @@
 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
+#  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
+#  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
+#  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
 #endif
 
 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D37302: [Hea... Pirama Arumuga Nainar via Phabricator via cfe-commits

Reply via email to