aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-builtins.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-10-26 17:00:55 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2023-02-21 12:36:43 +0100
commit5b5a0ca771797e99de80876b5504e1792bbca7ce (patch)
tree8d703f616f65fbfda712ee4e6cb5ac94b438cfc4 /gcc/rust/backend/rust-builtins.cc
parentf4c818c623c049a33d7cd3313c6859dee88b9e22 (diff)
downloadgcc-5b5a0ca771797e99de80876b5504e1792bbca7ce.zip
gcc-5b5a0ca771797e99de80876b5504e1792bbca7ce.tar.gz
gcc-5b5a0ca771797e99de80876b5504e1792bbca7ce.tar.bz2
gccrs: intrinsics: Implement atomic_load intrinsics
gcc/rust/ChangeLog: * backend/rust-builtins.cc (BuiltinsContext::setup_atomic_fns): Declare atomic load intrinsics. * backend/rust-compile-intrinsic.cc (atomic_load_handler_inner): New handler. (atomic_load_handler): Likewise. (unchecked_op_handler): Remove `static` function qualifier. (build_atomic_builtin_name): Handle load intrinsics. (atomic_store_handler_inner): New handler. gcc/testsuite/ChangeLog: * rust/compile/torture/intrinsics-3.rs: * rust/execute/torture/atomic_load.rs: New test.
Diffstat (limited to 'gcc/rust/backend/rust-builtins.cc')
-rw-r--r--gcc/rust/backend/rust-builtins.cc56
1 files changed, 31 insertions, 25 deletions
diff --git a/gcc/rust/backend/rust-builtins.cc b/gcc/rust/backend/rust-builtins.cc
index 64e06e1..66b3bec 100644
--- a/gcc/rust/backend/rust-builtins.cc
+++ b/gcc/rust/backend/rust-builtins.cc
@@ -71,36 +71,42 @@ BuiltinsContext::setup_math_fns ()
void
BuiltinsContext::setup_atomic_fns ()
{
- define_builtin ("atomic_store", BUILT_IN_ATOMIC_STORE, "__atomic_store", NULL,
- build_function_type_list (void_type_node, size_type_node,
- build_pointer_type (void_type_node),
- const_ptr_type_node,
- integer_type_node, NULL_TREE),
- 0);
- define_builtin ("atomic_store_n", BUILT_IN_ATOMIC_STORE_N, "__atomic_store_n",
- NULL,
- build_varargs_function_type_list (void_type_node, NULL_TREE),
- 0);
+ auto atomic_store_type
+ = build_varargs_function_type_list (void_type_node, NULL_TREE);
+ auto atomic_load_type = [] (tree ret_type_node) {
+ return build_function_type_list (ret_type_node,
+ ptr_type_node, // const_ptr_type_node?
+ integer_type_node, NULL_TREE);
+ };
+
+ // FIXME: These should be the definition for the generic version of the
+ // atomic_store builtins, but I cannot get them to work properly. Revisit
+ // later. define_builtin ("atomic_store", BUILT_IN_ATOMIC_STORE,
+ // "__atomic_store", NULL,
+ // atomic_store_type, 0);
+ // define_builtin ("atomic_store_n", BUILT_IN_ATOMIC_STORE_N,
+ // "__atomic_store_n",
+ // NULL, atomic_store_type, 0);
+
define_builtin ("atomic_store_1", BUILT_IN_ATOMIC_STORE_1, "__atomic_store_1",
- NULL,
- build_varargs_function_type_list (void_type_node, NULL_TREE),
- 0);
+ NULL, atomic_store_type, 0);
define_builtin ("atomic_store_2", BUILT_IN_ATOMIC_STORE_2, "__atomic_store_2",
- NULL,
- build_varargs_function_type_list (void_type_node, NULL_TREE),
- 0);
+ NULL, atomic_store_type, 0);
define_builtin ("atomic_store_4", BUILT_IN_ATOMIC_STORE_4, "__atomic_store_4",
- NULL,
- build_varargs_function_type_list (void_type_node, NULL_TREE),
- 0);
+ NULL, atomic_store_type, 0);
define_builtin ("atomic_store_8", BUILT_IN_ATOMIC_STORE_8, "__atomic_store_8",
- NULL,
- build_varargs_function_type_list (void_type_node, NULL_TREE),
- 0);
+ NULL, atomic_store_type, 0);
define_builtin ("atomic_store_16", BUILT_IN_ATOMIC_STORE_16,
- "__atomic_store_16", NULL,
- build_varargs_function_type_list (void_type_node, NULL_TREE),
- 0);
+ "__atomic_store_16", NULL, atomic_store_type, 0);
+
+ define_builtin ("atomic_load_1", BUILT_IN_ATOMIC_LOAD_1, "__atomic_load_1",
+ NULL, atomic_load_type (integer_type_node), 0);
+ define_builtin ("atomic_load_2", BUILT_IN_ATOMIC_LOAD_2, "__atomic_load_2",
+ NULL, atomic_load_type (integer_type_node), 0);
+ define_builtin ("atomic_load_4", BUILT_IN_ATOMIC_LOAD_4, "__atomic_load_4",
+ NULL, atomic_load_type (integer_type_node), 0);
+ define_builtin ("atomic_load_8", BUILT_IN_ATOMIC_LOAD_8, "__atomic_load_8",
+ NULL, atomic_load_type (integer_type_node), 0);
}
void