aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-02-27 14:39:22 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-02-29 15:52:44 +0000
commit6895e0bb24ddc3893f917537b319ac20ba31f369 (patch)
treebf8050f889fc7db23041f3c5bc64d596b7d5e9d0 /gcc/rust/backend
parente9de5b410da43cb2ac5f9865756153648e6f078b (diff)
downloadgcc-6895e0bb24ddc3893f917537b319ac20ba31f369.zip
gcc-6895e0bb24ddc3893f917537b319ac20ba31f369.tar.gz
gcc-6895e0bb24ddc3893f917537b319ac20ba31f369.tar.bz2
lang-items: Make lang items enum stronger, rename class, cleanup ns.
gcc/rust/ChangeLog: * util/rust-lang-item.h (class RustLangItem): Renamed to... (class LangItem): ...this. Rename ItemType enum to Kind * util/rust-lang-item.cc: Rename methods to use new class name. * backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API. (CompileExpr::resolve_operator_overload): Likewise. * backend/rust-compile-expr.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise. * typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise. (AutoderefCycle::cycle): Likewise. * typecheck/rust-autoderef.h: Likewise. * typecheck/rust-hir-type-bounds.h: Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise. * typecheck/rust-hir-type-check-base.h: Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. * typecheck/rust-hir-type-check-expr.h: Likewise. * typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise. * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise. (TypeBoundsProbe::assemble_builtin_candidate): Likewise. (TypeCheckBase::get_predicate_from_bound): Likewise. * typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise. * util/rust-hir-map.cc (Mappings::get_lang_item): Likewise. (Mappings::lookup_trait_item_lang_item): Likewise. * util/rust-hir-map.h: Likewise.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc24
-rw-r--r--gcc/rust/backend/rust-compile-expr.h8
2 files changed, 15 insertions, 17 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 596b848..65de24b 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -150,7 +150,7 @@ CompileExpr::visit (HIR::ArithmeticOrLogicalExpr &expr)
if (is_op_overload)
{
auto lang_item_type
- = Analysis::RustLangItem::OperatorToLangItem (expr.get_expr_type ());
+ = LangItem::OperatorToLangItem (expr.get_expr_type ());
translated = resolve_operator_overload (lang_item_type, expr, lhs, rhs,
expr.get_lhs ().get (),
expr.get_rhs ().get ());
@@ -193,9 +193,8 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr)
expr.get_mappings ().get_hirid (), &fntype);
if (is_op_overload)
{
- auto lang_item_type
- = Analysis::RustLangItem::CompoundAssignmentOperatorToLangItem (
- expr.get_expr_type ());
+ auto lang_item_type = LangItem::CompoundAssignmentOperatorToLangItem (
+ expr.get_expr_type ());
auto compound_assignment
= resolve_operator_overload (lang_item_type, expr, lhs, rhs,
expr.get_lhs ().get (),
@@ -244,8 +243,7 @@ CompileExpr::visit (HIR::NegationExpr &expr)
expr.get_mappings ().get_hirid (), &fntype);
if (is_op_overload)
{
- auto lang_item_type
- = Analysis::RustLangItem::NegationOperatorToLangItem (op);
+ auto lang_item_type = LangItem::NegationOperatorToLangItem (op);
translated
= resolve_operator_overload (lang_item_type, expr, negated_expr,
nullptr, expr.get_expr ().get (), nullptr);
@@ -836,7 +834,7 @@ CompileExpr::visit (HIR::DereferenceExpr &expr)
expr.get_mappings ().get_hirid (), &fntype);
if (is_op_overload)
{
- auto lang_item_type = Analysis::RustLangItem::ItemType::DEREF;
+ auto lang_item_type = LangItem::Kind::DEREF;
tree operator_overload_call
= resolve_operator_overload (lang_item_type, expr, main_expr, nullptr,
expr.get_expr ().get (), nullptr);
@@ -1423,9 +1421,10 @@ CompileExpr::get_receiver_from_dyn (const TyTy::DynamicObjectType *dyn,
}
tree
-CompileExpr::resolve_operator_overload (
- Analysis::RustLangItem::ItemType lang_item_type, HIR::OperatorExprMeta expr,
- tree lhs, tree rhs, HIR::Expr *lhs_expr, HIR::Expr *rhs_expr)
+CompileExpr::resolve_operator_overload (LangItem::Kind lang_item_type,
+ HIR::OperatorExprMeta expr, tree lhs,
+ tree rhs, HIR::Expr *lhs_expr,
+ HIR::Expr *rhs_expr)
{
TyTy::FnType *fntype;
bool is_op_overload = ctx->get_tyctx ()->lookup_operator_overload (
@@ -1446,8 +1445,7 @@ CompileExpr::resolve_operator_overload (
}
// lookup compiled functions since it may have already been compiled
- HIR::PathIdentSegment segment_name (
- Analysis::RustLangItem::ToString (lang_item_type));
+ HIR::PathIdentSegment segment_name (LangItem::ToString (lang_item_type));
tree fn_expr = resolve_method_address (fntype, receiver, expr.get_locus ());
// lookup the autoderef mappings
@@ -2120,7 +2118,7 @@ CompileExpr::visit (HIR::ArrayIndexExpr &expr)
expr.get_mappings ().get_hirid (), &fntype);
if (is_op_overload)
{
- auto lang_item_type = Analysis::RustLangItem::ItemType::INDEX;
+ auto lang_item_type = LangItem::Kind::INDEX;
tree operator_overload_call
= resolve_operator_overload (lang_item_type, expr, array_reference,
index, expr.get_array_expr ().get (),
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index e947825..af2e1bc 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -97,10 +97,10 @@ protected:
TyTy::BaseType *receiver, TyTy::FnType *fntype,
tree receiver_ref, location_t expr_locus);
- tree
- resolve_operator_overload (Analysis::RustLangItem::ItemType lang_item_type,
- HIR::OperatorExprMeta expr, tree lhs, tree rhs,
- HIR::Expr *lhs_expr, HIR::Expr *rhs_expr);
+ tree resolve_operator_overload (LangItem::Kind lang_item_type,
+ HIR::OperatorExprMeta expr, tree lhs,
+ tree rhs, HIR::Expr *lhs_expr,
+ HIR::Expr *rhs_expr);
tree compile_bool_literal (const HIR::LiteralExpr &expr,
const TyTy::BaseType *tyty);