From acec1a7668f73bfbf441f5151ec29945f09b386a Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 4 Feb 2018 15:24:31 +0300 Subject: [PATCH] Simplified asm constraints to avoid comma-separated alternatives. Alternatives are not supported by all compilers, and for the purpose we're using them we can use constraint-local alternatives (i.e. "qm" instead of "q,m"). Additionally, this reduces duplication of other constraints in the asm block. --- include/boost/atomic/detail/config.hpp | 2 +- include/boost/atomic/detail/ops_gcc_x86_dcas.hpp | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/include/boost/atomic/detail/config.hpp b/include/boost/atomic/detail/config.hpp index 6af8d50..51eed39 100644 --- a/include/boost/atomic/detail/config.hpp +++ b/include/boost/atomic/detail/config.hpp @@ -46,7 +46,7 @@ #endif #if defined(__CUDACC__) -// nvcc does not support alternatives in asm statement constraints +// nvcc does not support alternatives ("q,m") in asm statement constraints #define BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES // nvcc does not support condition code register ("cc") clobber in asm statements #define BOOST_ATOMIC_DETAIL_NO_ASM_CLOBBER_CC diff --git a/include/boost/atomic/detail/ops_gcc_x86_dcas.hpp b/include/boost/atomic/detail/ops_gcc_x86_dcas.hpp index a9c0ade..fd2a3e6 100644 --- a/include/boost/atomic/detail/ops_gcc_x86_dcas.hpp +++ b/include/boost/atomic/detail/ops_gcc_x86_dcas.hpp @@ -250,13 +250,8 @@ struct gcc_dcas_x86 ( "lock; cmpxchg8b %[dest]\n\t" "sete %[success]\n\t" -#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) - : "+A,A" (expected), [dest] "+m,m" (storage), [success] "=q,m" (success) - : "b,b" ((uint32_t)desired), "c,c" ((uint32_t)(desired >> 32)) -#else - : "+A" (expected), [dest] "+m" (storage), [success] "=q" (success) + : "+A" (expected), [dest] "+m" (storage), [success] "=qm" (success) : "b" ((uint32_t)desired), "c" ((uint32_t)(desired >> 32)) -#endif : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" ); #endif // defined(BOOST_ATOMIC_DETAIL_ASM_HAS_FLAG_OUTPUTS) @@ -476,13 +471,8 @@ struct gcc_dcas_x86_64 ( "lock; cmpxchg16b %[dest]\n\t" "sete %[success]\n\t" -#if !defined(BOOST_ATOMIC_DETAIL_NO_ASM_CONSTRAINT_ALTERNATIVES) - : "+A,A" (expected), [dest] "+m,m" (storage), [success] "=q,m" (success) - : "b,b" (reinterpret_cast< const aliasing_uint64_t* >(&desired)[0]), "c,c" (reinterpret_cast< const aliasing_uint64_t* >(&desired)[1]) -#else - : "+A" (expected), [dest] "+m" (storage), [success] "=q" (success) + : "+A" (expected), [dest] "+m" (storage), [success] "=qm" (success) : "b" (reinterpret_cast< const aliasing_uint64_t* >(&desired)[0]), "c" (reinterpret_cast< const aliasing_uint64_t* >(&desired)[1]) -#endif : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory" ); #endif // defined(BOOST_ATOMIC_DETAIL_ASM_HAS_FLAG_OUTPUTS)