/* { dg-do run } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
/* Test the execution of __atomic_compare_exchange_n builtin for an int_128. */
/* { dg-do run } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
/* Test the execution of the __atomic_X builtin for a 16 byte value. */
/* { dg-do run } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
extern void abort(void);
/* { dg-do run } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
/* Test the execution of the __atomic_*OP builtin routines for an int_128. */
/* { dg-do run } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
/* Test the execution of the __atomic_store_n builtin for a 16 byte value. */
/* { dg-do run } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
__int128_t i;
/* { dg-do link } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { x86_64-*-* i?86-*-* } } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
/* { dg-final { simulate-thread } } */
#include <stdio.h>
/* { dg-do link } */
/* { dg-require-effective-target sync_int_128_runtime } */
/* { dg-options "-mcx16" { target { x86_64-*-* i?86-*-* } } } */
-/* { dg-final { simulate-thread } } */
+/* { dg-options "-mlsx -mscq" { target { loongarch64-*-* } } } */
+
+/* xfail on loongarch64 until the new GDB versions with
+ https://sourceware.org/pipermail/gdb-patches/2025-August/220034.html
+ is widely used by distros. */
+/* { dg-final { simulate-thread { xfail loongarch64-*-* } } } */
#include <stdio.h>
#include "simulate-thread.h"
# This requires support for both compare-and-swap and true atomic loads.
proc check_effective_target_sync_int_128_runtime { } {
- return 0
+ if { [istarget loongarch64-*-*]
+ && [check_effective_target_loongarch_sx_hw]
+ && [check_effective_target_loongarch_scq_hw] } {
+ return 1
+ } else {
+ return 0
+ }
}
# Return 1 if the target supports atomic operations on "long long".
} "-mlasx"]
}
+proc check_effective_target_loongarch_scq_hw { } {
+ return [check_runtime loongarch_scq_hw {
+ #include <larchintrin.h>
+ int main (void)
+ {
+ if (__cpucfg (2) & (1 << 30))
+ return 0;
+ __builtin_trap ();
+ }
+ } ""]
+}
+
# Check whether LoongArch binutils supports call36 relocation.
proc check_effective_target_loongarch_call36_support { } {
return [check_no_compiler_messages loongarch_call36_support object {