From: Elle Rhumsaa <[email protected]>

Uses the `memmodel` enum variants for `atomic_*` intrinsic functions.

gcc/
        * rust/backend/rust-compile-intrinsic.cc: use memmodel
        * rust/backend/rust-intrinsic-handlers.cc: use memmodel
        * rust/backend/rust-intrinsic-handlers.h: use memmodel
---
 gcc/rust/backend/rust-compile-intrinsic.cc  | 16 ++++++++--------
 gcc/rust/backend/rust-intrinsic-handlers.cc | 20 ++++++++++----------
 gcc/rust/backend/rust-intrinsic-handlers.h  |  8 ++++----
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc 
b/gcc/rust/backend/rust-compile-intrinsic.cc
index a733f83e63d0..bb499c94f40a 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -43,15 +43,15 @@ static const std::map<std::string, 
handlers::HandlerBuilder> generic_intrinsics
      {IValue::COPY_NONOVERLAPPING, handlers::copy (false)},
      {IValue::PREFETCH_READ_DATA, handlers::prefetch_read_data},
      {IValue::PREFETCH_WRITE_DATA, handlers::prefetch_write_data},
-     {IValue::ATOMIC_STORE_SEQCST, handlers::atomic_store (__ATOMIC_SEQ_CST)},
-     {IValue::ATOMIC_STORE_RELEASE, handlers::atomic_store (__ATOMIC_RELEASE)},
-     {IValue::ATOMIC_STORE_RELAXED, handlers::atomic_store (__ATOMIC_RELAXED)},
+     {IValue::ATOMIC_STORE_SEQCST, handlers::atomic_store (MEMMODEL_SEQ_CST)},
+     {IValue::ATOMIC_STORE_RELEASE, handlers::atomic_store (MEMMODEL_RELEASE)},
+     {IValue::ATOMIC_STORE_RELAXED, handlers::atomic_store (MEMMODEL_RELAXED)},
      {IValue::ATOMIC_STORE_UNORDERED,
-      handlers::atomic_store (__ATOMIC_RELAXED)},
-     {IValue::ATOMIC_LOAD_SEQCST, handlers::atomic_load (__ATOMIC_SEQ_CST)},
-     {IValue::ATOMIC_LOAD_ACQUIRE, handlers::atomic_load (__ATOMIC_ACQUIRE)},
-     {IValue::ATOMIC_LOAD_RELAXED, handlers::atomic_load (__ATOMIC_RELAXED)},
-     {IValue::ATOMIC_LOAD_UNORDERED, handlers::atomic_load (__ATOMIC_RELAXED)},
+      handlers::atomic_store (MEMMODEL_RELAXED)},
+     {IValue::ATOMIC_LOAD_SEQCST, handlers::atomic_load (MEMMODEL_SEQ_CST)},
+     {IValue::ATOMIC_LOAD_ACQUIRE, handlers::atomic_load (MEMMODEL_ACQUIRE)},
+     {IValue::ATOMIC_LOAD_RELAXED, handlers::atomic_load (MEMMODEL_RELAXED)},
+     {IValue::ATOMIC_LOAD_UNORDERED, handlers::atomic_load (MEMMODEL_RELAXED)},
      {IValue::ATOMIC_EXCHANGE_SEQCST,
       handlers::atomic_exchange (MEMMODEL_SEQ_CST)},
      {IValue::ATOMIC_EXCHANGE_ACQUIRE,
diff --git a/gcc/rust/backend/rust-intrinsic-handlers.cc 
b/gcc/rust/backend/rust-intrinsic-handlers.cc
index d9aa95b79a8b..abec54c4ad7a 100644
--- a/gcc/rust/backend/rust-intrinsic-handlers.cc
+++ b/gcc/rust/backend/rust-intrinsic-handlers.cc
@@ -633,7 +633,7 @@ copy (Context *ctx, TyTy::FnType *fntype, bool overlaps)
 }
 
 tree
-atomic_store (Context *ctx, TyTy::FnType *fntype, int ordering)
+atomic_store (Context *ctx, TyTy::FnType *fntype, memmodel model)
 {
   rust_assert (fntype->get_params ().size () == 2);
   rust_assert (fntype->get_num_substitutions () == 1);
@@ -662,7 +662,7 @@ atomic_store (Context *ctx, TyTy::FnType *fntype, int 
ordering)
   TREE_READONLY (dst) = 0;
 
   auto value = Backend::var_expression (param_vars[1], UNDEF_LOCATION);
-  auto memorder = make_unsigned_long_tree (ordering);
+  auto memorder = make_memmodel_tree (model);
 
   auto monomorphized_type
     = fntype->get_substs ()[0].get_param_ty ()->resolve ();
@@ -694,7 +694,7 @@ atomic_store (Context *ctx, TyTy::FnType *fntype, int 
ordering)
 }
 
 tree
-atomic_load (Context *ctx, TyTy::FnType *fntype, int ordering)
+atomic_load (Context *ctx, TyTy::FnType *fntype, memmodel model)
 {
   rust_assert (fntype->get_params ().size () == 1);
   rust_assert (fntype->get_num_substitutions () == 1);
@@ -721,7 +721,7 @@ atomic_load (Context *ctx, TyTy::FnType *fntype, int 
ordering)
   enter_intrinsic_block (ctx, fndecl);
 
   auto src = Backend::var_expression (param_vars[0], UNDEF_LOCATION);
-  auto memorder = make_unsigned_long_tree (ordering);
+  auto memorder = make_memmodel_tree (model);
 
   auto monomorphized_type
     = fntype->get_substs ()[0].get_param_ty ()->resolve ();
@@ -1126,18 +1126,18 @@ wrapping_op (tree_code op)
 }
 
 HandlerBuilder
-atomic_store (int ordering)
+atomic_store (memmodel model)
 {
-  return [ordering] (Context *ctx, TyTy::FnType *fntype) {
-    return inner::atomic_store (ctx, fntype, ordering);
+  return [model] (Context *ctx, TyTy::FnType *fntype) {
+    return inner::atomic_store (ctx, fntype, model);
   };
 }
 
 HandlerBuilder
-atomic_load (int ordering)
+atomic_load (memmodel model)
 {
-  return [ordering] (Context *ctx, TyTy::FnType *fntype) {
-    return inner::atomic_load (ctx, fntype, ordering);
+  return [model] (Context *ctx, TyTy::FnType *fntype) {
+    return inner::atomic_load (ctx, fntype, model);
   };
 }
 
diff --git a/gcc/rust/backend/rust-intrinsic-handlers.h 
b/gcc/rust/backend/rust-intrinsic-handlers.h
index 96c62f0a1cae..87d7224cbb95 100644
--- a/gcc/rust/backend/rust-intrinsic-handlers.h
+++ b/gcc/rust/backend/rust-intrinsic-handlers.h
@@ -36,8 +36,8 @@ namespace handlers {
 namespace inner {
 tree wrapping_op (Context *ctx, TyTy::FnType *fntype, tree_code op);
 
-tree atomic_store (Context *ctx, TyTy::FnType *fntype, int ordering);
-tree atomic_load (Context *ctx, TyTy::FnType *fntype, int ordering);
+tree atomic_store (Context *ctx, TyTy::FnType *fntype, memmodel model);
+tree atomic_load (Context *ctx, TyTy::FnType *fntype, memmodel model);
 tree atomic_exchange (Context *ctx, TyTy::FnType *fntype, memmodel model);
 inline tree copy (Context *ctx, TyTy::FnType *fntype, bool overlaps);
 inline tree expect (Context *ctx, TyTy::FnType *fntype, bool likely);
@@ -77,9 +77,9 @@ tree prefetch_data (Context *ctx, TyTy::FnType *fntype, 
Prefetch kind);
 const std::function<tree (Context *, TyTy::FnType *)>
 wrapping_op (tree_code op);
 
-HandlerBuilder atomic_store (int ordering);
+HandlerBuilder atomic_store (memmodel model);
 
-HandlerBuilder atomic_load (int ordering);
+HandlerBuilder atomic_load (memmodel model);
 
 HandlerBuilder atomic_exchange (memmodel model);
 
-- 
2.54.0

Reply via email to