From 79a7f07ff648d30906c7a77698422192b57bb857 Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Sat, 12 Aug 2023 11:37:10 -0400 Subject: [PATCH] Handle gengtype annotations in rust-constexpr.cc gcc/rust/ChangeLog: * backend/rust-constexpr.cc: Include gt-rust-rust-constexpr.h. (struct constexpr_call_hasher): Rename to ... (struct rust_constexpr_call_hasher): ... here. (struct constexpr_fundef_hasher): Rename to ... (struct rust_constexpr_fundef_hasher): ... here. * config-lang.in: Add rust-constexpr.cc to gtfiles. Signed-off-by: Owen Avery --- gcc/rust/backend/rust-constexpr.cc | 34 +++++++++++++++++------------- gcc/rust/config-lang.in | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index d161022b72d2..83f95c7c8af5 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -150,7 +150,7 @@ struct GTY ((for_user)) constexpr_call bool manifestly_const_eval; }; -struct constexpr_call_hasher : ggc_ptr_hash +struct rust_constexpr_call_hasher : ggc_ptr_hash { static hashval_t hash (constexpr_call *); static bool equal (constexpr_call *, constexpr_call *); @@ -201,7 +201,7 @@ struct constexpr_ctx bool manifestly_const_eval; }; -struct constexpr_fundef_hasher : ggc_ptr_hash +struct rust_constexpr_fundef_hasher : ggc_ptr_hash { static hashval_t hash (const constexpr_fundef *); static bool equal (const constexpr_fundef *, const constexpr_fundef *); @@ -210,15 +210,16 @@ struct constexpr_fundef_hasher : ggc_ptr_hash /* This table holds all constexpr function definitions seen in the current translation unit. */ -static GTY (()) hash_table *constexpr_fundef_table; +static GTY (()) + hash_table *constexpr_fundef_table; /* Utility function used for managing the constexpr function table. Return true if the entries pointed to by P and Q are for the same constexpr function. */ inline bool -constexpr_fundef_hasher::equal (const constexpr_fundef *lhs, - const constexpr_fundef *rhs) +rust_constexpr_fundef_hasher::equal (const constexpr_fundef *lhs, + const constexpr_fundef *rhs) { return lhs->decl == rhs->decl; } @@ -227,7 +228,7 @@ constexpr_fundef_hasher::equal (const constexpr_fundef *lhs, Return a hash value for the entry pointed to by Q. */ inline hashval_t -constexpr_fundef_hasher::hash (const constexpr_fundef *fundef) +rust_constexpr_fundef_hasher::hash (const constexpr_fundef *fundef) { return DECL_UID (fundef->decl); } @@ -343,12 +344,12 @@ uid_sensitive_constexpr_evaluation_checker::evaluation_restricted_p () const /* A table of all constexpr calls that have been evaluated by the compiler in this translation unit. */ -static GTY (()) hash_table *constexpr_call_table; +static GTY (()) hash_table *constexpr_call_table; /* Compute a hash value for a constexpr call representation. */ inline hashval_t -constexpr_call_hasher::hash (constexpr_call *info) +rust_constexpr_call_hasher::hash (constexpr_call *info) { return info->hash; } @@ -358,7 +359,7 @@ constexpr_call_hasher::hash (constexpr_call *info) Otherwise, return false. */ bool -constexpr_call_hasher::equal (constexpr_call *lhs, constexpr_call *rhs) +rust_constexpr_call_hasher::equal (constexpr_call *lhs, constexpr_call *rhs) { if (lhs == rhs) return true; @@ -366,7 +367,7 @@ constexpr_call_hasher::equal (constexpr_call *lhs, constexpr_call *rhs) return false; if (lhs->manifestly_const_eval != rhs->manifestly_const_eval) return false; - if (!constexpr_fundef_hasher::equal (lhs->fundef, rhs->fundef)) + if (!rust_constexpr_fundef_hasher::equal (lhs->fundef, rhs->fundef)) return false; return rs_tree_equal (lhs->bindings, rhs->bindings); } @@ -377,7 +378,8 @@ static void maybe_initialize_constexpr_call_table (void) { if (constexpr_call_table == NULL) - constexpr_call_table = hash_table::create_ggc (101); + constexpr_call_table + = hash_table::create_ggc (101); } /* During constexpr CALL_EXPR evaluation, to avoid issues with sharing when @@ -3462,7 +3464,7 @@ eval_call_expression (const constexpr_ctx *ctx, tree t, bool lval, constexpr_call *entry = NULL; if (depth_ok && !non_constant_args && ctx->strict) { - new_call.hash = constexpr_fundef_hasher::hash (new_call.fundef); + new_call.hash = rust_constexpr_fundef_hasher::hash (new_call.fundef); new_call.hash = iterative_hash_object (new_call.bindings, new_call.hash); new_call.hash = iterative_hash_object (ctx->manifestly_const_eval, new_call.hash); @@ -4583,7 +4585,7 @@ register_constexpr_fundef (const constexpr_fundef &value) /* Create the constexpr function table if necessary. */ if (constexpr_fundef_table == NULL) constexpr_fundef_table - = hash_table::create_ggc (101); + = hash_table::create_ggc (101); constexpr_fundef **slot = constexpr_fundef_table->find_slot ( const_cast (&value), INSERT); @@ -6474,7 +6476,9 @@ fold_non_dependent_init (tree t, tsubst_flags_t /*=tf_warning_or_error*/, return maybe_constant_init (t, object, manifestly_const_eval); } -// #include "gt-rust-rust-constexpr.h" - } // namespace Compile } // namespace Rust + +using namespace Rust::Compile; + +#include "gt-rust-rust-constexpr.h" diff --git a/gcc/rust/config-lang.in b/gcc/rust/config-lang.in index c4f7943f3a04..5bc66360877f 100644 --- a/gcc/rust/config-lang.in +++ b/gcc/rust/config-lang.in @@ -31,4 +31,4 @@ build_by_default="no" target_libs="target-libgrust" -gtfiles="\$(srcdir)/rust/rust-lang.cc" +gtfiles="\$(srcdir)/rust/rust-lang.cc \$(srcdir)/rust/backend/rust-constexpr.cc"