From patchwork Fri Nov 25 17:35:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 127719 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id CCE311007D5 for ; Sat, 26 Nov 2011 04:36:36 +1100 (EST) Received: (qmail 27302 invoked by alias); 25 Nov 2011 17:36:33 -0000 Received: (qmail 26822 invoked by uid 22791); 25 Nov 2011 17:36:30 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Nov 2011 17:36:15 +0000 Received: by ggnl1 with SMTP id l1so1313732ggn.20 for ; Fri, 25 Nov 2011 09:36:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.181.225 with SMTP id l61mr49377518yhm.131.1322242551187; Fri, 25 Nov 2011 09:35:51 -0800 (PST) Received: by 10.146.137.4 with HTTP; Fri, 25 Nov 2011 09:35:51 -0800 (PST) Date: Fri, 25 Nov 2011 18:35:51 +0100 Message-ID: Subject: [PATCH, testsuite]: Introduce sync_int128_runtime and sync_long_long_runtime From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Andrew MacLeod Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello! Attached patch introduces sync_int128_runtime and sync_long_long_runtime runtime check to prevent running atomic runtime tests on targets that don't support them. I also merged runtime check for arm*-*-linux-gnueabi with corresponding arm*-*-* compile-time check. This change has a nice side effect that gcc.dg/di-longlong64-sync.c and gcc.dg/di-sync-multithread.c tests now also run on x86_64. Regarding arm, I have simply copied existing runtime check. Various long-long atomic tests now also run on this target, so perhaps there will be some fallout on recently introduced tests. 2011-11-25 Uros Bizjak PR testsuite/51258 * lib/target-supports.exp (check_effective_target_sync_int_128_runtime): New procedure. (check_effective_target_sync_long_long_runtime): Ditto. (check_effective_target_sync_long_long): Add arm*-*-*. (check_effective_target_sync_longlong): Remove. * gcc.dg/atomic-op-5.c: Require sync_int_128_runtime effective target. * gcc.dg/atomic-compare-exchange-5.c: Ditto. * gcc.dg/atomic-exchange-5.c: Ditto. * gcc.dg/atomic-load-5.c: Ditto. * gcc.dg/atomic-store-5.c: Ditto. * gcc.dg/simulate-thread/atomic-load-int128.c: Ditto. * gcc.dg/simulate-thread/atomic-other-int128.c: Ditto. * gcc.dg/atomic-op-4.c: Require sync_long_long_runtime effective target. * gcc.dg/atomic-compare-exchange-4.c: Ditto. * gcc.dg/atomic-exchange-4.c: Ditto. * gcc.dg/atomic-load-4.c: Ditto. * gcc.dg/atomic-store-4.c: Ditto. * gcc.dg/di-longlong64-sync-1.c: Ditto. * gcc.dg/di-sync-multithread.c: Ditto. * gcc.dg/simulate-thread/atomic-load-longlong.c: Ditto. * gcc.dg/simulate-thread/atomic-other-longlong.c: Ditto. Patch was tested on x86_64-pc-linux-gnu and was committed to mainline SVN. Uros. Index: lib/target-supports.exp =================================================================== --- lib/target-supports.exp (revision 181721) +++ lib/target-supports.exp (working copy) @@ -3620,17 +3620,80 @@ } } +# Return 1 if the target supports atomic operations on "int_128" values +# and can execute them. + +proc check_effective_target_sync_int_128_runtime { } { + if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) + && ![is-effective-target ia32] } { + return [check_cached_effective_target sync_int_128_available { + check_runtime_nocache sync_int_128_available { + #include "cpuid.h" + int main () + { + unsigned int eax, ebx, ecx, edx; + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return !(ecx & bit_CMPXCHG16B); + return 1; + } + } "" + }] + } else { + return 0 + } +} + # Return 1 if the target supports atomic operations on "long long". proc check_effective_target_sync_long_long { } { if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) - && ![is-effective-target ia32] } { + && ![is-effective-target ia32] + || [istarget arm*-*-*] } { return 1 } else { return 0 } } +# Return 1 if the target supports atomic operations on "long long" +# and can execute them. + +proc check_effective_target_sync_long_long_runtime { } { + if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) + && ![is-effective-target ia32] } { + return [check_cached_effective_target sync_long_long_available { + check_runtime_nocache sync_long_long_available { + #include "cpuid.h" + int main () + { + unsigned int eax, ebx, ecx, edx; + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return !(edx & bit_CMPXCHG8B); + return 1; + } + } "" + }] + } elseif { [istarget arm*-*-linux-gnueabi] } { + return [check_runtime sync_longlong_runtime { + #include + int main () + { + long long l1; + + if (sizeof (long long) != 8) + exit (1); + + /* Just check for native; checking for kernel fallback is tricky. */ + asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1"); + + exit (0); + } + } "" ] + } else { + return 0 + } +} + # Return 1 if the target supports atomic operations on "int" and "long". proc check_effective_target_sync_int_long { } { @@ -3662,31 +3725,6 @@ return $et_sync_int_long_saved } -# Return 1 if the target supports atomic operations on "long long" and can -# execute them -# So far only put checks in for ARM, others may want to add their own -proc check_effective_target_sync_longlong { } { - return [check_runtime sync_longlong_runtime { - #include - int main () - { - long long l1; - - if (sizeof (long long) != 8) - exit (1); - - #ifdef __arm__ - /* Just check for native; checking for kernel fallback is tricky. */ - asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1"); - #else - # error "Add other suitable archs here" - #endif - - exit (0); - } - } "" ] -} - # Return 1 if the target supports atomic operations on "char" and "short". proc check_effective_target_sync_char_short { } { Index: gcc.dg/atomic-exchange-5.c =================================================================== --- gcc.dg/atomic-exchange-5.c (revision 181721) +++ gcc.dg/atomic-exchange-5.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 16 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ /* Test the execution of the __atomic_X builtin for a 16 byte value. */ Index: gcc.dg/atomic-op-5.c =================================================================== --- gcc.dg/atomic-op-5.c (revision 181721) +++ gcc.dg/atomic-op-5.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 16 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ /* Test the execution of the __atomic_*OP builtin routines for an int_128. */ Index: gcc.dg/atomic-compare-exchange-4.c =================================================================== --- gcc.dg/atomic-compare-exchange-4.c (revision 181721) +++ gcc.dg/atomic-compare-exchange-4.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 8 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ /* Test the execution of __atomic_compare_exchange_n builtin for a long_long. */ Index: gcc.dg/di-longlong64-sync-1.c =================================================================== --- gcc.dg/di-longlong64-sync-1.c (revision 181721) +++ gcc.dg/di-longlong64-sync-1.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-require-effective-target sync_longlong } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "-std=gnu99" } */ /* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ /* { dg-message "note: '__sync_nand_and_fetch' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */ Index: gcc.dg/atomic-load-4.c =================================================================== --- gcc.dg/atomic-load-4.c (revision 181721) +++ gcc.dg/atomic-load-4.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 8 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ extern void abort(void); Index: gcc.dg/simulate-thread/atomic-load-longlong.c =================================================================== --- gcc.dg/simulate-thread/atomic-load-longlong.c (revision 181721) +++ gcc.dg/simulate-thread/atomic-load-longlong.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ /* { dg-final { simulate-thread } } */ Index: gcc.dg/simulate-thread/atomic-other-longlong.c =================================================================== --- gcc.dg/simulate-thread/atomic-other-longlong.c (revision 181721) +++ gcc.dg/simulate-thread/atomic-other-longlong.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ /* { dg-final { simulate-thread } } */ Index: gcc.dg/simulate-thread/atomic-load-int128.c =================================================================== --- gcc.dg/simulate-thread/atomic-load-int128.c (revision 181721) +++ gcc.dg/simulate-thread/atomic-load-int128.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { x86_64-*-* i?86-*-* } } } */ /* { dg-final { simulate-thread } } */ Index: gcc.dg/simulate-thread/atomic-other-int128.c =================================================================== --- gcc.dg/simulate-thread/atomic-other-int128.c (revision 181721) +++ gcc.dg/simulate-thread/atomic-other-int128.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do link } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { x86_64-*-* i?86-*-* } } } */ /* { dg-final { simulate-thread } } */ Index: gcc.dg/atomic-store-4.c =================================================================== --- gcc.dg/atomic-store-4.c (revision 181721) +++ gcc.dg/atomic-store-4.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 8 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ /* Test the execution of the __atomic_store_n builtin for a long long. */ Index: gcc.dg/atomic-compare-exchange-5.c =================================================================== --- gcc.dg/atomic-compare-exchange-5.c (revision 181721) +++ gcc.dg/atomic-compare-exchange-5.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 16 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ /* Test the execution of __atomic_compare_exchange_n builtin for an int_128. */ Index: gcc.dg/atomic-load-5.c =================================================================== --- gcc.dg/atomic-load-5.c (revision 181721) +++ gcc.dg/atomic-load-5.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 16 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ extern void abort(void); Index: gcc.dg/atomic-exchange-4.c =================================================================== --- gcc.dg/atomic-exchange-4.c (revision 181721) +++ gcc.dg/atomic-exchange-4.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 8 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ /* Test the execution of the __atomic_X builtin for a long_long. */ Index: gcc.dg/atomic-op-4.c =================================================================== --- gcc.dg/atomic-op-4.c (revision 181721) +++ gcc.dg/atomic-op-4.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 8 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_long_long } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-options "" } */ /* Test the execution of the __atomic_*OP builtin routines for long long. */ Index: gcc.dg/atomic-store-5.c =================================================================== --- gcc.dg/atomic-store-5.c (revision 181721) +++ gcc.dg/atomic-store-5.c (working copy) @@ -1,7 +1,7 @@ /* Test __atomic routines for existence and proper execution on 16 byte values with each valid memory model. */ /* { dg-do run } */ -/* { dg-require-effective-target sync_int_128 } */ +/* { dg-require-effective-target sync_int_128_runtime } */ /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */ /* Test the execution of the __atomic_store_n builtin for a 16 byte value. */ Index: gcc.dg/di-sync-multithread.c =================================================================== --- gcc.dg/di-sync-multithread.c (revision 181721) +++ gcc.dg/di-sync-multithread.c (working copy) @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-require-effective-target sync_longlong } */ +/* { dg-require-effective-target sync_long_long_runtime } */ /* { dg-require-effective-target pthread_h } */ /* { dg-require-effective-target pthread } */ /* { dg-options "-pthread -std=gnu99" } */