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"
18 mips*) druntime_target_cpu_parsed="mips"
21 druntime_target_cpu_parsed="powerpc"
24 druntime_target_cpu_parsed="x86"
27 druntime_target_cpu_parsed="s390x"
30 druntime_target_cpu_parsed="s390"
33 AM_CONDITIONAL([DRUNTIME_CPU_AARCH64],
34 [test "$druntime_target_cpu_parsed" = "aarch64"])
35 AM_CONDITIONAL([DRUNTIME_CPU_ARM],
36 [test "$druntime_target_cpu_parsed" = "arm"])
37 AM_CONDITIONAL([DRUNTIME_CPU_MIPS],
38 [test "$druntime_target_cpu_parsed" = "mips"])
39 AM_CONDITIONAL([DRUNTIME_CPU_POWERPC],
40 [test "$druntime_target_cpu_parsed" = "powerpc"])
41 AM_CONDITIONAL([DRUNTIME_CPU_X86],
42 [test "$druntime_target_cpu_parsed" = "x86"])
43 AM_CONDITIONAL([DRUNTIME_CPU_SYSTEMZ],
44 [test "$druntime_target_cpu_parsed" = "s390x"])
45 AM_CONDITIONAL([DRUNTIME_CPU_S390],
46 [test "$druntime_target_cpu_parsed" = "s390"])
50 # DRUNTIME_ENABLE_ATOMIC_BUILTINS
51 # -------------------------
52 # Check support for atomic builtins up to 64 bit.
53 AC_DEFUN([DRUNTIME_ENABLE_ATOMIC_BUILTINS],
55 # This checks to see if the host supports the compiler-generated builtins
56 # for atomic operations for various integral sizes. Note, this is intended
57 # to be an all-or-nothing switch, so all the atomic operations that are
58 # used should be checked.
59 AC_MSG_CHECKING([for atomic builtins for byte])
60 AC_CACHE_VAL(druntime_cv_atomic_byte, [
62 [import gcc.builtins;], [
65 __atomic_compare_exchange_1(&c1, &c2, c3, false, 5, 5);
66 __atomic_load_1(&c1, 5);
67 __atomic_store_1(&c1, c2, 5);
70 [druntime_cv_atomic_byte=yes],
71 [druntime_cv_atomic_byte=no])
73 AC_MSG_RESULT($druntime_cv_atomic_byte)
75 AC_MSG_CHECKING([for atomic builtins for short])
76 AC_CACHE_VAL(druntime_cv_atomic_short, [
78 [import gcc.builtins;], [
81 __atomic_compare_exchange_2(&c1, &c2, c3, false, 5, 5);
82 __atomic_load_2(&c1, 5);
83 __atomic_store_2(&c1, c2, 5);
86 [druntime_cv_atomic_short=yes],
87 [druntime_cv_atomic_short=no])
89 AC_MSG_RESULT($druntime_cv_atomic_short)
91 AC_MSG_CHECKING([for atomic builtins for int])
92 AC_CACHE_VAL(druntime_cv_atomic_int, [
94 [import gcc.builtins;], [
97 __atomic_compare_exchange_4(&c1, &c2, c3, false, 5, 5);
98 __atomic_load_4(&c1, 5);
99 __atomic_store_4(&c1, c2, 5);
102 [druntime_cv_atomic_int=yes],
103 [druntime_cv_atomic_int=no])
105 AC_MSG_RESULT($druntime_cv_atomic_int)
107 AC_MSG_CHECKING([for atomic builtins for long])
108 AC_CACHE_VAL(druntime_cv_atomic_long, [
110 [import gcc.builtins;], [
113 __atomic_compare_exchange_8(&c1, &c2, c3, false, 5, 5);
114 __atomic_load_8(&c1, 5);
115 __atomic_store_8(&c1, c2, 5);
118 [druntime_cv_atomic_long=yes],
119 [druntime_cv_atomic_long=no])
121 AC_MSG_RESULT($druntime_cv_atomic_long)
123 # Have atomic builtin support if all but the long test above passes.
124 DCFG_HAVE_ATOMIC_BUILTINS=false
125 if test "$druntime_cv_atomic_byte" = yes \
126 && test "$druntime_cv_atomic_short" = yes \
127 && test "$druntime_cv_atomic_int" = yes; then \
128 DCFG_HAVE_ATOMIC_BUILTINS=true
131 # Have 64-bit atomic support if the long test above passes.
132 DCFG_HAVE_64BIT_ATOMICS=false
133 if test "$druntime_cv_atomic_long" = yes; then
134 DCFG_HAVE_64BIT_ATOMICS=true
137 AC_SUBST(DCFG_HAVE_ATOMIC_BUILTINS)
138 AC_SUBST(DCFG_HAVE_64BIT_ATOMICS)