2 # Contains macros to detect CPU features.
8 # Detect target CPU and add DRUNTIME_CPU_XXX conditionals.
9 AC_DEFUN([DRUNTIME_CPU_SOURCES],
11 druntime_target_cpu_parsed=""
14 druntime_target_cpu_parsed="aarch64"
16 arm*) druntime_target_cpu_parsed="arm"
19 druntime_target_cpu_parsed="loongarch"
21 mips*) druntime_target_cpu_parsed="mips"
24 druntime_target_cpu_parsed="powerpc"
27 druntime_target_cpu_parsed="x86"
30 druntime_target_cpu_parsed="s390x"
33 druntime_target_cpu_parsed="s390"
36 AM_CONDITIONAL([DRUNTIME_CPU_AARCH64],
37 [test "$druntime_target_cpu_parsed" = "aarch64"])
38 AM_CONDITIONAL([DRUNTIME_CPU_ARM],
39 [test "$druntime_target_cpu_parsed" = "arm"])
40 AM_CONDITIONAL([DRUNTIME_CPU_LOONGARCH],
41 [test "$druntime_target_cpu_parsed" = "loongarch"])
42 AM_CONDITIONAL([DRUNTIME_CPU_MIPS],
43 [test "$druntime_target_cpu_parsed" = "mips"])
44 AM_CONDITIONAL([DRUNTIME_CPU_POWERPC],
45 [test "$druntime_target_cpu_parsed" = "powerpc"])
46 AM_CONDITIONAL([DRUNTIME_CPU_X86],
47 [test "$druntime_target_cpu_parsed" = "x86"])
48 AM_CONDITIONAL([DRUNTIME_CPU_SYSTEMZ],
49 [test "$druntime_target_cpu_parsed" = "s390x"])
50 AM_CONDITIONAL([DRUNTIME_CPU_S390],
51 [test "$druntime_target_cpu_parsed" = "s390"])
55 # DRUNTIME_ENABLE_ATOMIC_BUILTINS
56 # -------------------------
57 # Check support for atomic builtins up to 64 bit.
58 AC_DEFUN([DRUNTIME_ENABLE_ATOMIC_BUILTINS],
60 # This checks to see if the host supports the compiler-generated builtins
61 # for atomic operations for various integral sizes. Note, this is intended
62 # to be an all-or-nothing switch, so all the atomic operations that are
63 # used should be checked.
64 AC_MSG_CHECKING([for atomic builtins for byte])
65 AC_CACHE_VAL(druntime_cv_atomic_byte, [
67 [import gcc.builtins;], [
70 __atomic_compare_exchange_1(&c1, &c2, c3, false, 5, 5);
71 __atomic_load_1(&c1, 5);
72 __atomic_store_1(&c1, c2, 5);
75 [druntime_cv_atomic_byte=yes],
76 [druntime_cv_atomic_byte=no])
78 AC_MSG_RESULT($druntime_cv_atomic_byte)
80 AC_MSG_CHECKING([for atomic builtins for short])
81 AC_CACHE_VAL(druntime_cv_atomic_short, [
83 [import gcc.builtins;], [
86 __atomic_compare_exchange_2(&c1, &c2, c3, false, 5, 5);
87 __atomic_load_2(&c1, 5);
88 __atomic_store_2(&c1, c2, 5);
91 [druntime_cv_atomic_short=yes],
92 [druntime_cv_atomic_short=no])
94 AC_MSG_RESULT($druntime_cv_atomic_short)
96 AC_MSG_CHECKING([for atomic builtins for int])
97 AC_CACHE_VAL(druntime_cv_atomic_int, [
99 [import gcc.builtins;], [
102 __atomic_compare_exchange_4(&c1, &c2, c3, false, 5, 5);
103 __atomic_load_4(&c1, 5);
104 __atomic_store_4(&c1, c2, 5);
107 [druntime_cv_atomic_int=yes],
108 [druntime_cv_atomic_int=no])
110 AC_MSG_RESULT($druntime_cv_atomic_int)
112 AC_MSG_CHECKING([for atomic builtins for long])
113 AC_CACHE_VAL(druntime_cv_atomic_long, [
115 [import gcc.builtins;], [
118 __atomic_compare_exchange_8(&c1, &c2, c3, false, 5, 5);
119 __atomic_load_8(&c1, 5);
120 __atomic_store_8(&c1, c2, 5);
123 [druntime_cv_atomic_long=yes],
124 [druntime_cv_atomic_long=no])
126 AC_MSG_RESULT($druntime_cv_atomic_long)
128 # Have atomic builtin support if all but the long test above passes.
129 DCFG_HAVE_ATOMIC_BUILTINS=false
130 if test "$druntime_cv_atomic_byte" = yes \
131 && test "$druntime_cv_atomic_short" = yes \
132 && test "$druntime_cv_atomic_int" = yes; then \
133 DCFG_HAVE_ATOMIC_BUILTINS=true
136 # Have 64-bit atomic support if the long test above passes.
137 DCFG_HAVE_64BIT_ATOMICS=false
138 if test "$druntime_cv_atomic_long" = yes; then
139 DCFG_HAVE_64BIT_ATOMICS=true
142 AC_SUBST(DCFG_HAVE_ATOMIC_BUILTINS)
143 AC_SUBST(DCFG_HAVE_64BIT_ATOMICS)