diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-10-25 11:24:10 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-10-26 09:58:05 +0200 |
commit | 4d42744aa5d5778975d46ac9f5c945f9c7ec2ffa (patch) | |
tree | 2ff9ff65e2f5155b0b344f9e75fff884344e9ffe /gcc/rust/backend/rust-builtins.cc | |
parent | 83e5265d6af48e1572cbe019b4b7f7a5603086a9 (diff) | |
download | gcc-4d42744aa5d5778975d46ac9f5c945f9c7ec2ffa.zip gcc-4d42744aa5d5778975d46ac9f5c945f9c7ec2ffa.tar.gz gcc-4d42744aa5d5778975d46ac9f5c945f9c7ec2ffa.tar.bz2 |
intrinsics: Add early implementation for atomic_store_{seqcst, relaxed, release}
This commit adds support for three `atomic_store_*` intrinsics declared
in the core library. The mapping is as follows:
- atomic_store_seqcst(dst, val) -> __atomic_store_n(dst, val,
__ATOMIC_SEQ_CST)
- atomic_store_release(dst, val) -> __atomic_store_n(dst, val,
__ATOMIC_RELEASE)
- atomic_store_relaxed(dst, val) -> __atomic_store_n(dst, val,
__ATOMIC_RELAXED)
- atomic_store_unordered(dst, val) -> __atomic_store_n(dst, val,
__ATOMIC_RELAXED)
This commit also performs the overloading "by hand": Replacing
`atomic_store_release<i32>` with `__atomic_store_4` as I cannot get the
generic version to work. This will be done in future improvements.
Because of this, size type atomics are not handled and result in a call
to `rust_sorry_at`.
Co-authored-by: bjorn3 <bjorn3@github.com>
Co-authored-by: dafaust <dafaust@github.com>
Diffstat (limited to 'gcc/rust/backend/rust-builtins.cc')
-rw-r--r-- | gcc/rust/backend/rust-builtins.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-builtins.cc b/gcc/rust/backend/rust-builtins.cc index d6f8cb6..64e06e1 100644 --- a/gcc/rust/backend/rust-builtins.cc +++ b/gcc/rust/backend/rust-builtins.cc @@ -69,10 +69,46 @@ 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); + 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); + 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); + 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); + 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); + 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); +} + +void BuiltinsContext::setup () { setup_math_fns (); setup_overflow_fns (); + setup_atomic_fns (); define_builtin ("unreachable", BUILT_IN_UNREACHABLE, "__builtin_unreachable", NULL, build_function_type (void_type_node, void_list_node), |