diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-12-11 21:09:45 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-01-09 14:13:31 +0100 |
commit | 4784601d726e5b70b6c4e050c77749706536ccf3 (patch) | |
tree | 8b36adcad405d9aaf1687abccf87c33ce43d0770 /gcc/ada/gcc-interface | |
parent | 8f987210930e53e6f729d0a84a5fe682aeb74b19 (diff) | |
download | gcc-4784601d726e5b70b6c4e050c77749706536ccf3.zip gcc-4784601d726e5b70b6c4e050c77749706536ccf3.tar.gz gcc-4784601d726e5b70b6c4e050c77749706536ccf3.tar.bz2 |
ada: Add __atomic_store_n binding to System.Atomic_Primitives
This is modeled on the existing binding for __atomic_load_n.
gcc/ada/
* libgnat/s-atopri.ads (Atomic_Store): New generic procedure.
(Atomic_Store_8): New instantiated procedure.
(Atomic_Store_16): Likewise.
(Atomic_Store_32): Likewise.
(Atomic_Store_64): Likewise.
* libgnat/s-atopri__32.ads (Atomic_Store): New generic procedure.
(Atomic_Store_8): New instantiated procedure.
(Atomic_Store_16): Likewise.
(Atomic_Store_32): Likewise.
* gcc-interface/decl.cc (gnat_to_gnu_subprog_type): Implement the
support for __atomic_store_n and __sync_bool_compare_and_swap_n.
* gcc-interface/gigi.h (list_second): New inline function.
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r-- | gcc/ada/gcc-interface/decl.cc | 24 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/gigi.h | 8 |
2 files changed, 30 insertions, 2 deletions
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index c3d2de2..89a374f 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -6504,6 +6504,28 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, } break; + case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N: + case BUILT_IN_ATOMIC_STORE_N: + /* This is a generic builtin overloaded on its second + parameter type, so do type resolution based on it. */ + if (list_length (gnu_param_type_list) >= 3 + && type_for_atomic_builtin_p + (list_second (gnu_param_type_list))) + gnu_builtin_decl + = resolve_atomic_builtin + (fncode, list_second (gnu_param_type_list)); + else + { + post_error + ("??cannot import type-generic 'G'C'C builtin!", + gnat_subprog); + post_error + ("\\?use a supported second parameter type", + gnat_subprog); + gnu_builtin_decl = NULL_TREE; + } + break; + case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N: /* This is a generic builtin overloaded on its third parameter type, so do type resolution based on it. */ @@ -6525,9 +6547,7 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition, } break; - case BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_N: case BUILT_IN_SYNC_LOCK_RELEASE_N: - case BUILT_IN_ATOMIC_STORE_N: post_error ("??unsupported type-generic 'G'C'C builtin!", gnat_subprog); diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 63ccf31..2a7320f 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -1238,6 +1238,14 @@ operand_type (tree expr) return TREE_TYPE (TREE_OPERAND (expr, 0)); } +/* Return the second value of a list. */ + +static inline tree +list_second (tree list) +{ + return TREE_VALUE (TREE_CHAIN (list)); +} + /* Return the third value of a list. */ static inline tree |