r247624 - [WebAssembly] Define the atomic type sizes

Dan Gohman via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 14:56:37 PDT 2015


Author: djg
Date: Mon Sep 14 16:56:37 2015
New Revision: 247624

URL: http://llvm.org/viewvc/llvm-project?rev=247624&view=rev
Log:
[WebAssembly] Define the atomic type sizes

WebAssembly's spec has now been updated to specify some guarantees
about lock free atomic accesses. Update clang to match.

This also updates sig_atomic_t to be 64-bit on wasm64. WebAssembly
does not presently have asynchronous interrupts, but this change is
within the spirit of how they will work if they are added.

Differential Revision: http://reviews.llvm.org/D12862

Modified:
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=247624&r1=247623&r2=247624&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Sep 14 16:56:37 2015
@@ -6994,6 +6994,7 @@ public:
     LargeArrayMinWidth = 128;
     LargeArrayAlign = 128;
     SimdDefaultAlign = 128;
+    SigAtomicType = SignedLong;
   }
 
 protected:
@@ -7096,8 +7097,7 @@ class WebAssembly32TargetInfo : public W
 public:
   explicit WebAssembly32TargetInfo(const llvm::Triple &T)
       : WebAssemblyTargetInfo(T) {
-    // TODO: Set this to the correct value once the spec issues are resolved.
-    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
+    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
     DataLayoutString = "e-p:32:32-i64:64-n32:64-S128";
   }
 
@@ -7115,8 +7115,7 @@ public:
       : WebAssemblyTargetInfo(T) {
     LongAlign = LongWidth = 64;
     PointerAlign = PointerWidth = 64;
-    // TODO: Set this to the correct value once the spec issues are resolved.
-    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
+    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
     DataLayoutString = "e-p:64:64-i64:64-n32:64-S128";
   }
 

Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=247624&r1=247623&r2=247624&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Sep 14 16:56:37 2015
@@ -8472,17 +8472,17 @@
 // WEBASSEMBLY32-NEXT:#define __FLT_MIN_EXP__ (-125){{$}}
 // WEBASSEMBLY32-NEXT:#define __FLT_MIN__ 1.17549435e-38F{{$}}
 // WEBASSEMBLY32-NEXT:#define __FLT_RADIX__ 2{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2{{$}}
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2{{$}}
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2{{$}}
 // WEBASSEMBLY32-NEXT:#define __GNUC_MINOR__ {{.}}
 // WEBASSEMBLY32-NEXT:#define __GNUC_PATCHLEVEL__ {{.}}
 // WEBASSEMBLY32-NEXT:#define __GNUC_STDC_INLINE__ 1{{$}}
@@ -8586,7 +8586,7 @@
 // WEBASSEMBLY32-NOT:#define __REGISTER_PREFIX__
 // WEBASSEMBLY32-NEXT:#define __SCHAR_MAX__ 127{{$}}
 // WEBASSEMBLY32-NEXT:#define __SHRT_MAX__ 32767{{$}}
-// WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647{{$}}
+// WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647L{{$}}
 // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_WIDTH__ 32{{$}}
 // WEBASSEMBLY32-NEXT:#define __SIZEOF_DOUBLE__ 8{{$}}
 // WEBASSEMBLY32-NEXT:#define __SIZEOF_FLOAT__ 4{{$}}
@@ -8788,17 +8788,17 @@
 // WEBASSEMBLY64-NEXT:#define __FLT_MIN_EXP__ (-125){{$}}
 // WEBASSEMBLY64-NEXT:#define __FLT_MIN__ 1.17549435e-38F{{$}}
 // WEBASSEMBLY64-NEXT:#define __FLT_RADIX__ 2{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 1{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2{{$}}
 // WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2{{$}}
 // WEBASSEMBLY64-NEXT:#define __GNUC_MINOR__ {{.}}
 // WEBASSEMBLY64-NEXT:#define __GNUC_PATCHLEVEL__ {{.}}
 // WEBASSEMBLY64-NEXT:#define __GNUC_STDC_INLINE__ 1{{$}}
@@ -8902,8 +8902,8 @@
 // WEBASSEMBLY64-NOT:#define __REGISTER_PREFIX__
 // WEBASSEMBLY64-NEXT:#define __SCHAR_MAX__ 127{{$}}
 // WEBASSEMBLY64-NEXT:#define __SHRT_MAX__ 32767{{$}}
-// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647{{$}}
-// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_WIDTH__ 32{{$}}
+// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MAX__ 9223372036854775807L{{$}}
+// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_WIDTH__ 64{{$}}
 // WEBASSEMBLY64-NEXT:#define __SIZEOF_DOUBLE__ 8{{$}}
 // WEBASSEMBLY64-NEXT:#define __SIZEOF_FLOAT__ 4{{$}}
 // WEBASSEMBLY64-NEXT:#define __SIZEOF_INT128__ 16{{$}}




More information about the cfe-commits mailing list