From: Elle Rhumsaa <[email protected]>

---
 gcc/rust/backend/rust-compile-context.h     |  1 +
 gcc/rust/backend/rust-compile-intrinsic.cc  |  8 ++++----
 gcc/rust/backend/rust-compile-intrinsic.h   |  1 +
 gcc/rust/backend/rust-intrinsic-handlers.cc | 12 +++++++++---
 gcc/rust/backend/rust-intrinsic-handlers.h  |  4 ++--
 5 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-context.h 
b/gcc/rust/backend/rust-compile-context.h
index 3fd686d81d1e..62e7a4ff218b 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -28,6 +28,7 @@
 #include "rust-mangle.h"
 #include "rust-tree.h"
 #include "rust-immutable-name-resolution-context.h"
+#include "memmodel.h"
 
 namespace Rust {
 namespace Compile {
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc 
b/gcc/rust/backend/rust-compile-intrinsic.cc
index 1342772ce4e6..1bfc9630435a 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -53,13 +53,13 @@ static const std::map<std::string, 
handlers::HandlerBuilder> generic_intrinsics
      {IValue::ATOMIC_LOAD_RELAXED, handlers::atomic_load (__ATOMIC_RELAXED)},
      {IValue::ATOMIC_LOAD_UNORDERED, handlers::atomic_load (__ATOMIC_RELAXED)},
      {IValue::ATOMIC_EXCHANGE_SEQCST,
-      handlers::atomic_exchange (__ATOMIC_SEQ_CST)},
+      handlers::atomic_exchange (MEMMODEL_SEQ_CST)},
      {IValue::ATOMIC_EXCHANGE_RELEASE,
-      handlers::atomic_exchange (__ATOMIC_RELEASE)},
+      handlers::atomic_exchange (MEMMODEL_RELEASE)},
      {IValue::ATOMIC_EXCHANGE_RELAXED,
-      handlers::atomic_exchange (__ATOMIC_RELAXED)},
+      handlers::atomic_exchange (MEMMODEL_RELAXED)},
      {IValue::ATOMIC_EXCHANGE_UNORDERED,
-      handlers::atomic_exchange (__ATOMIC_RELAXED)},
+      handlers::atomic_exchange (MEMMODEL_RELAXED)},
      {IValue::UNCHECKED_ADD, handlers::unchecked_op (PLUS_EXPR)},
      {IValue::UNCHECKED_SUB, handlers::unchecked_op (MINUS_EXPR)},
      {IValue::UNCHECKED_MUL, handlers::unchecked_op (MULT_EXPR)},
diff --git a/gcc/rust/backend/rust-compile-intrinsic.h 
b/gcc/rust/backend/rust-compile-intrinsic.h
index dceb0864fd49..7b5e7e1cb9ff 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.h
+++ b/gcc/rust/backend/rust-compile-intrinsic.h
@@ -19,6 +19,7 @@
 
 #include "rust-compile-context.h"
 #include "langhooks.h"
+#include "memmodel.h"
 
 namespace Rust {
 namespace Compile {
diff --git a/gcc/rust/backend/rust-intrinsic-handlers.cc 
b/gcc/rust/backend/rust-intrinsic-handlers.cc
index f8e6bb8b977e..78e05f828414 100644
--- a/gcc/rust/backend/rust-intrinsic-handlers.cc
+++ b/gcc/rust/backend/rust-intrinsic-handlers.cc
@@ -45,6 +45,12 @@ make_unsigned_long_tree (unsigned long value)
   return build_int_cst (integer_type_node, value);
 }
 
+static tree
+make_memmodel_tree (memmodel value)
+{
+  return build_int_cst (integer_type_node, value);
+}
+
 static bool
 is_basic_integer_type (TyTy::BaseType *type)
 {
@@ -749,7 +755,7 @@ atomic_load (Context *ctx, TyTy::FnType *fntype, int 
ordering)
 }
 
 tree
-atomic_exchange (Context *ctx, TyTy::FnType *fntype, int ordering)
+atomic_exchange (Context *ctx, TyTy::FnType *fntype, memmodel ordering)
 {
   rust_assert (fntype->get_params ().size () == 2);
   rust_assert (fntype->get_num_substitutions () == 1);
@@ -778,7 +784,7 @@ atomic_exchange (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 (ordering);
 
   auto monomorphized_type
     = fntype->get_substs ()[0].get_param_ty ()->resolve ();
@@ -1135,7 +1141,7 @@ atomic_load (int ordering)
 }
 
 HandlerBuilder
-atomic_exchange (int ordering)
+atomic_exchange (memmodel ordering)
 {
   return [ordering] (Context *ctx, TyTy::FnType *fntype) {
     return inner::atomic_exchange (ctx, fntype, ordering);
diff --git a/gcc/rust/backend/rust-intrinsic-handlers.h 
b/gcc/rust/backend/rust-intrinsic-handlers.h
index ac26749dfdb9..e5ce4481c5d7 100644
--- a/gcc/rust/backend/rust-intrinsic-handlers.h
+++ b/gcc/rust/backend/rust-intrinsic-handlers.h
@@ -37,7 +37,7 @@ 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_exchange (Context *ctx, TyTy::FnType *fntype, int ordering);
+tree atomic_exchange (Context *ctx, TyTy::FnType *fntype, memmodel ordering);
 inline tree copy (Context *ctx, TyTy::FnType *fntype, bool overlaps);
 inline tree expect (Context *ctx, TyTy::FnType *fntype, bool likely);
 tree try_handler (Context *ctx, TyTy::FnType *fntype, bool is_new_api);
@@ -80,7 +80,7 @@ HandlerBuilder atomic_store (int ordering);
 
 HandlerBuilder atomic_load (int ordering);
 
-HandlerBuilder atomic_exchange (int ordering);
+HandlerBuilder atomic_exchange (memmodel ordering);
 
 const HandlerBuilder unchecked_op (tree_code op);
 
-- 
2.54.0

Reply via email to