From 7a751f354a91a8459b877c60a5e5d78203aeb3ce Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 11:29:10 -0800 Subject: Replace Btype use with GCC tree --- gcc/rust/backend/rust-compile-context.h | 102 +++++++++++++++---------------- gcc/rust/backend/rust-compile-expr.cc | 6 +- gcc/rust/backend/rust-compile-expr.h | 26 ++++---- gcc/rust/backend/rust-compile-extern.h | 4 +- gcc/rust/backend/rust-compile-fnparam.h | 8 +-- gcc/rust/backend/rust-compile-implitem.h | 16 ++--- gcc/rust/backend/rust-compile-item.h | 8 +-- gcc/rust/backend/rust-compile-stmt.h | 2 +- gcc/rust/backend/rust-compile-tyty.h | 16 ++--- gcc/rust/backend/rust-compile-var-decl.h | 2 +- gcc/rust/backend/rust-compile.cc | 6 +- 11 files changed, 98 insertions(+), 98 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 396cb10..82c02f8 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -60,20 +60,20 @@ public: ok = tyctx->lookup_type (ref, &lookup); rust_assert (ok); - Btype *compiled = TyTyCompile::compile (backend, lookup); - compiled_type_map.insert (std::pair (ref, compiled)); + tree compiled = TyTyCompile::compile (backend, lookup); + compiled_type_map.insert (std::pair (ref, compiled)); builtin_range.insert (ref); } } - bool lookup_compiled_types (HirId id, ::Btype **type, + bool lookup_compiled_types (HirId id, ::tree *type, const TyTy::BaseType *ref = nullptr) { if (ref != nullptr) { for (auto it = mono.begin (); it != mono.end (); it++) { - std::pair &val = it->second; + std::pair &val = it->second; const TyTy::BaseType *r = it->first; if (ref->is_equal (*r)) @@ -94,14 +94,14 @@ public: return true; } - void insert_compiled_type (HirId id, ::Btype *type, + void insert_compiled_type (HirId id, ::tree type, const TyTy::BaseType *ref = nullptr) { rust_assert (builtin_range.find (id) == builtin_range.end ()); - compiled_type_map.insert (std::pair (id, type)); + compiled_type_map.insert (std::pair (id, type)); if (ref != nullptr) { - std::pair elem (id, type); + std::pair elem (id, type); mono[ref] = std::move (elem); } } @@ -247,7 +247,7 @@ public: void pop_fn () { fn_stack.pop_back (); } fncontext peek_fn () { return fn_stack.back (); } - void push_type (::Btype *t) { type_decls.push_back (t); } + void push_type (::tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); } void push_const (::Bexpression *c) { const_decls.push_back (c); } void push_function (::Bfunction *f) { func_decls.push_back (f); } @@ -322,7 +322,7 @@ private: // state std::vector fn_stack; std::map compiled_var_decls; - std::map compiled_type_map; + std::map compiled_type_map; std::map compiled_fn_map; std::map compiled_consts; std::map compiled_labels; @@ -330,12 +330,12 @@ private: std::vector<::Bblock *> scope_stack; std::vector<::Bvariable *> loop_value_stack; std::vector<::Blabel *> loop_begin_labels; - std::map> mono; + std::map> mono; std::map>> mono_fns; // To GCC middle-end - std::vector<::Btype *> type_decls; + std::vector type_decls; std::vector<::Bvariable *> var_decls; std::vector<::Bexpression *> const_decls; std::vector<::Bfunction *> func_decls; @@ -344,7 +344,7 @@ private: class TyTyResolveCompile : public TyTy::TyConstVisitor { public: - static ::Btype *compile (Context *ctx, const TyTy::BaseType *ty, + static tree compile (Context *ctx, const TyTy::BaseType *ty, bool trait_object_mode = false) { TyTyResolveCompile compiler (ctx, trait_object_mode); @@ -375,16 +375,16 @@ public: void visit (const TyTy::FnType &type) override { - Backend::Btyped_identifier receiver; - std::vector parameters; - std::vector results; + Backend::typed_identifier receiver; + std::vector parameters; + std::vector results; if (!type.get_return_type ()->is_unit ()) { auto hir_type = type.get_return_type (); auto ret = TyTyResolveCompile::compile (ctx, hir_type, trait_object_mode); - results.push_back (Backend::Btyped_identifier ( + results.push_back (Backend::typed_identifier ( "_", ret, ctx->get_mappings ()->lookup_location (hir_type->get_ref ()))); } @@ -395,7 +395,7 @@ public: auto compiled_param_type = TyTyResolveCompile::compile (ctx, param_tyty, trait_object_mode); - auto compiled_param = Backend::Btyped_identifier ( + auto compiled_param = Backend::typed_identifier ( param_pair.first->as_string (), compiled_param_type, ctx->get_mappings ()->lookup_location (param_tyty->get_ref ())); @@ -414,12 +414,12 @@ public: void visit (const TyTy::FnPtr &type) override { - Btype *result_type + tree result_type = TyTyResolveCompile::compile (ctx, type.get_return_type ()); - std::vector parameters; + std::vector parameters; type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool { - Btype *pty = TyTyResolveCompile::compile (ctx, p); + tree pty = TyTyResolveCompile::compile (ctx, p); parameters.push_back (pty); return true; }); @@ -439,25 +439,25 @@ public: rust_assert (type.number_of_variants () == 1); TyTy::VariantDef &variant = *type.get_variants ().at (0); - std::vector fields; + std::vector fields; for (size_t i = 0; i < variant.num_fields (); i++) { const TyTy::StructFieldType *field = variant.get_field_at_index (i); - Btype *compiled_field_ty + tree compiled_field_ty = TyTyResolveCompile::compile (ctx, field->get_field_type ()); - Backend::Btyped_identifier f (field->get_name (), compiled_field_ty, + Backend::typed_identifier f (field->get_name (), compiled_field_ty, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } - Btype *type_record; + tree type_record; if (type.is_union ()) type_record = ctx->get_backend ()->union_type (fields); else type_record = ctx->get_backend ()->struct_type (fields); - Btype *named_struct + tree named_struct = ctx->get_backend ()->named_type (type.get_name (), type_record, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); @@ -482,11 +482,11 @@ public: return; // create implicit struct - std::vector fields; + std::vector fields; for (size_t i = 0; i < type.num_fields (); i++) { TyTy::BaseType *field = type.get_field (i); - Btype *compiled_field_ty = TyTyResolveCompile::compile (ctx, field); + tree compiled_field_ty = TyTyResolveCompile::compile (ctx, field); // rustc uses the convention __N, where N is an integer, to // name the fields of a tuple. We follow this as well, @@ -494,15 +494,15 @@ public: // this, rather than simply emitting the integer, is that this // approach makes it simpler to use a C-only debugger, or // GDB's C mode, when debugging Rust. - Backend::Btyped_identifier f ("__" + std::to_string (i), + Backend::typed_identifier f ("__" + std::to_string (i), compiled_field_ty, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } - Btype *struct_type_record = ctx->get_backend ()->struct_type (fields); - Btype *named_struct + tree struct_type_record = ctx->get_backend ()->struct_type (fields); + tree named_struct = ctx->get_backend ()->named_type (type.as_string (), struct_type_record, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); @@ -514,7 +514,7 @@ public: void visit (const TyTy::ArrayType &type) override { - Btype *element_type + tree element_type = TyTyResolveCompile::compile (ctx, type.get_element_type ()); translated = ctx->get_backend ()->array_type (element_type, type.get_capacity ()); @@ -522,7 +522,7 @@ public: void visit (const TyTy::BoolType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -530,7 +530,7 @@ public: void visit (const TyTy::IntType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -538,7 +538,7 @@ public: void visit (const TyTy::UintType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -546,7 +546,7 @@ public: void visit (const TyTy::FloatType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -554,7 +554,7 @@ public: void visit (const TyTy::USizeType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -562,7 +562,7 @@ public: void visit (const TyTy::ISizeType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -570,7 +570,7 @@ public: void visit (const TyTy::CharType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -578,7 +578,7 @@ public: void visit (const TyTy::ReferenceType &type) override { - Btype *base_compiled_type + tree base_compiled_type = TyTyResolveCompile::compile (ctx, type.get_base (), trait_object_mode); if (type.is_mutable ()) { @@ -593,7 +593,7 @@ public: void visit (const TyTy::PointerType &type) override { - Btype *base_compiled_type + tree base_compiled_type = TyTyResolveCompile::compile (ctx, type.get_base (), trait_object_mode); if (type.is_mutable ()) { @@ -608,7 +608,7 @@ public: void visit (const TyTy::StrType &type) override { - ::Btype *compiled_type = nullptr; + ::tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -633,13 +633,13 @@ public: // create implicit struct auto items = type.get_object_items (); - std::vector fields; + std::vector fields; - Btype *uint = ctx->get_backend ()->integer_type ( + tree uint = ctx->get_backend ()->integer_type ( true, ctx->get_backend ()->get_pointer_size ()); - Btype *uintptr_ty = ctx->get_backend ()->pointer_type (uint); + tree uintptr_ty = ctx->get_backend ()->pointer_type (uint); - Backend::Btyped_identifier f ("__receiver_trait_obj_ptr", uintptr_ty, + Backend::typed_identifier f ("__receiver_trait_obj_ptr", uintptr_ty, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); @@ -647,18 +647,18 @@ public: for (size_t i = 0; i < items.size (); i++) { // mrustc seems to make a vtable consisting of uintptr's - Btype *uint = ctx->get_backend ()->integer_type ( + tree uint = ctx->get_backend ()->integer_type ( true, ctx->get_backend ()->get_pointer_size ()); - Btype *uintptr_ty = ctx->get_backend ()->pointer_type (uint); + tree uintptr_ty = ctx->get_backend ()->pointer_type (uint); - Backend::Btyped_identifier f ("__" + std::to_string (i), uintptr_ty, + Backend::typed_identifier f ("__" + std::to_string (i), uintptr_ty, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } - Btype *type_record = ctx->get_backend ()->struct_type (fields); - Btype *named_struct + tree type_record = ctx->get_backend ()->struct_type (fields); + tree named_struct = ctx->get_backend ()->named_type (type.get_name (), type_record, ctx->get_mappings ()->lookup_location ( type.get_ty_ref ())); @@ -679,7 +679,7 @@ private: Context *ctx; bool trait_object_mode; - ::Btype *translated; + ::tree translated; size_t recursion_count; static const size_t kDefaultRecusionLimit = 5; diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 594cfff..0279ef9 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -150,7 +150,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, { TyTy::ReferenceType *r = static_cast (receiver); auto indirect_ty = r->get_base (); - Btype *indrect_compiled_tyty + tree indrect_compiled_tyty = TyTyResolveCompile::compile (ctx, indirect_ty); Bexpression *indirect @@ -171,7 +171,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, expr_locus); // cast it to the correct fntype - Btype *expected_fntype = TyTyResolveCompile::compile (ctx, fntype, true); + tree expected_fntype = TyTyResolveCompile::compile (ctx, fntype, true); Bexpression *fn_convert_expr = ctx->get_backend ()->convert_expression (expected_fntype, fn_vtable_access, expr_locus); @@ -370,7 +370,7 @@ CompileExpr::resolve_operator_overload ( break; case Resolver::Adjustment::AdjustmentType::DEREF_REF: - Btype *expected_type + tree expected_type = TyTyResolveCompile::compile (ctx, adjustment.get_expected ()); self = ctx->get_backend ()->indirect_expression (expected_type, self, diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index b4079f7..d2f79ec 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -58,7 +58,7 @@ public: TyTy::ReferenceType *r = static_cast (tuple_expr_ty); TyTy::BaseType *tuple_type = r->get_base (); - Btype *tuple_tyty = TyTyResolveCompile::compile (ctx, tuple_type); + tree tuple_tyty = TyTyResolveCompile::compile (ctx, tuple_type); Bexpression *indirect = ctx->get_backend ()->indirect_expression (tuple_tyty, receiver_ref, @@ -88,7 +88,7 @@ public: return; } - Btype *tuple_type = TyTyResolveCompile::compile (ctx, tyty); + tree tuple_type = TyTyResolveCompile::compile (ctx, tyty); rust_assert (tuple_type != nullptr); // this assumes all fields are in order from type resolution @@ -259,7 +259,7 @@ public: return; } - Btype *type = TyTyResolveCompile::compile (ctx, tyty); + tree type = TyTyResolveCompile::compile (ctx, tyty); translated = ctx->get_backend ()->integer_constant_expression (type, ival); } @@ -285,7 +285,7 @@ public: return; } - Btype *type = TyTyResolveCompile::compile (ctx, tyty); + tree type = TyTyResolveCompile::compile (ctx, tyty); translated = ctx->get_backend ()->float_constant_expression (type, fval); } @@ -341,7 +341,7 @@ public: indexes.push_back (i); } - Btype *array_type = TyTyResolveCompile::compile (ctx, array_tyty); + tree array_type = TyTyResolveCompile::compile (ctx, array_tyty); Bexpression *constructed = ctx->get_backend ()->array_constructor_expression ( array_type, indexes, vals, expr.get_locus ()); @@ -414,7 +414,7 @@ public: TyTy::ArrayType *array_tyty = static_cast (tyty); capacity_expr = array_tyty->get_capacity (); - Btype *array_type = TyTyResolveCompile::compile (ctx, array_tyty); + tree array_type = TyTyResolveCompile::compile (ctx, array_tyty); rust_assert (array_type != nullptr); expr.get_internal_elements ()->accept_vis (*this); @@ -517,7 +517,7 @@ public: { fncontext fnctx = ctx->peek_fn (); Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Btype *block_type = TyTyResolveCompile::compile (ctx, if_type); + tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; Bstatement *ret_var_stmt = nullptr; @@ -554,7 +554,7 @@ public: { fncontext fnctx = ctx->peek_fn (); Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Btype *block_type = TyTyResolveCompile::compile (ctx, if_type); + tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; Bstatement *ret_var_stmt = nullptr; @@ -590,7 +590,7 @@ public: { fncontext fnctx = ctx->peek_fn (); Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Btype *block_type = TyTyResolveCompile::compile (ctx, block_tyty); + tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; Bstatement *ret_var_stmt = nullptr; @@ -640,7 +640,7 @@ public: return; } - Btype *type = TyTyResolveCompile::compile (ctx, tyty); + tree type = TyTyResolveCompile::compile (ctx, tyty); rust_assert (type != nullptr); // this assumes all fields are in order from type resolution and if a base @@ -705,7 +705,7 @@ public: &field_index); rust_assert (ok); - Btype *adt_tyty = TyTyResolveCompile::compile (ctx, adt); + tree adt_tyty = TyTyResolveCompile::compile (ctx, adt); Bexpression *indirect = ctx->get_backend ()->indirect_expression (adt_tyty, receiver_ref, true, expr.get_locus ()); @@ -743,7 +743,7 @@ public: if (needs_temp) { Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Btype *block_type = TyTyResolveCompile::compile (ctx, block_tyty); + tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; Bstatement *ret_var_stmt = nullptr; @@ -975,7 +975,7 @@ public: return; } - Btype *expected_type = TyTyResolveCompile::compile (ctx, tyty); + tree expected_type = TyTyResolveCompile::compile (ctx, tyty); bool known_valid = true; translated = ctx->get_backend ()->indirect_expression (expected_type, main_expr, diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 6e5a3fd..2d3d251 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -55,7 +55,7 @@ public: // FIXME this is assuming C ABI std::string asm_name = name; - Btype *type = TyTyResolveCompile::compile (ctx, resolved_type); + tree type = TyTyResolveCompile::compile (ctx, resolved_type); bool is_external = true; bool is_hidden = false; bool in_unique_section = false; @@ -128,7 +128,7 @@ public: return; } - ::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); + tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); compiled_fn_type = ctx->get_backend ()->specify_abi_attribute (compiled_fn_type, fntype->get_abi ()); diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h index b246948..903f839 100644 --- a/gcc/rust/backend/rust-compile-fnparam.h +++ b/gcc/rust/backend/rust-compile-fnparam.h @@ -30,7 +30,7 @@ class CompileFnParam : public HIRCompileBase public: static Bvariable *compile (Context *ctx, Bfunction *fndecl, - HIR::FunctionParam *param, Btype *decl_type, + HIR::FunctionParam *param, tree decl_type, Location locus) { CompileFnParam compiler (ctx, fndecl, decl_type, locus); @@ -51,14 +51,14 @@ public: } private: - CompileFnParam (Context *ctx, ::Bfunction *fndecl, ::Btype *decl_type, + CompileFnParam (Context *ctx, ::Bfunction *fndecl, tree decl_type, Location locus) : HIRCompileBase (ctx), fndecl (fndecl), decl_type (decl_type), locus (locus), translated (nullptr) {} ::Bfunction *fndecl; - ::Btype *decl_type; + tree decl_type; Location locus; ::Bvariable *translated; }; @@ -67,7 +67,7 @@ class CompileSelfParam : public HIRCompileBase { public: static Bvariable *compile (Context *ctx, Bfunction *fndecl, - HIR::SelfParam &self, Btype *decl_type, + HIR::SelfParam &self, tree decl_type, Location locus) { bool is_immutable diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 05c7910..51a691f 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -60,7 +60,7 @@ public: &resolved_type); rust_assert (ok); - ::Btype *type = TyTyResolveCompile::compile (ctx, resolved_type); + tree type = TyTyResolveCompile::compile (ctx, resolved_type); Bexpression *value = CompileExpr::Compile (constant.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; @@ -136,7 +136,7 @@ public: } // convert to the actual function type - ::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); + tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); unsigned int flags = 0; @@ -178,7 +178,7 @@ public: return; } - Btype *self_type = TyTyResolveCompile::compile (ctx, self_tyty_lookup); + tree self_type = TyTyResolveCompile::compile (ctx, self_tyty_lookup); if (self_type == nullptr) { rust_error_at (function.get_self_param ().get_locus (), @@ -275,7 +275,7 @@ public: Bvariable *return_address = nullptr; if (function.has_function_return_type ()) { - Btype *return_type = TyTyResolveCompile::compile (ctx, tyret); + tree return_type = TyTyResolveCompile::compile (ctx, tyret); bool address_is_taken = false; Bstatement *ret_var_stmt = nullptr; @@ -349,7 +349,7 @@ public: rust_assert (concrete != nullptr); TyTy::BaseType *resolved_type = concrete; - ::Btype *type = TyTyResolveCompile::compile (ctx, resolved_type); + tree type = TyTyResolveCompile::compile (ctx, resolved_type); Bexpression *value = CompileExpr::Compile (constant.get_expr ().get (), ctx); @@ -404,7 +404,7 @@ public: } // convert to the actual function type - ::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); + tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); HIR::TraitFunctionDecl &function = func.get_decl (); unsigned int flags = 0; @@ -440,7 +440,7 @@ public: return; } - Btype *self_type = TyTyResolveCompile::compile (ctx, self_tyty_lookup); + tree self_type = TyTyResolveCompile::compile (ctx, self_tyty_lookup); if (self_type == nullptr) { rust_error_at (function.get_self ().get_locus (), @@ -536,7 +536,7 @@ public: Bvariable *return_address = nullptr; if (function.has_return_type ()) { - Btype *return_type = TyTyResolveCompile::compile (ctx, tyret); + tree return_type = TyTyResolveCompile::compile (ctx, tyret); bool address_is_taken = false; Bstatement *ret_var_stmt = nullptr; diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 6691c2a..87c577c 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -61,7 +61,7 @@ public: &resolved_type); rust_assert (ok); - Btype *type = TyTyResolveCompile::compile (ctx, resolved_type); + tree type = TyTyResolveCompile::compile (ctx, resolved_type); Bexpression *value = CompileExpr::Compile (var.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; @@ -97,7 +97,7 @@ public: &resolved_type); rust_assert (ok); - ::Btype *type = TyTyResolveCompile::compile (ctx, resolved_type); + tree type = TyTyResolveCompile::compile (ctx, resolved_type); Bexpression *value = CompileExpr::Compile (constant.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; @@ -174,7 +174,7 @@ public: fntype->override_context (); } - ::Btype *compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); + tree compiled_fn_type = TyTyResolveCompile::compile (ctx, fntype); unsigned int flags = 0; bool is_main_fn = function.get_function_name ().compare ("main") == 0; @@ -275,7 +275,7 @@ public: Bvariable *return_address = nullptr; if (function.has_function_return_type ()) { - Btype *return_type = TyTyResolveCompile::compile (ctx, tyret); + tree return_type = TyTyResolveCompile::compile (ctx, tyret); bool address_is_taken = false; Bstatement *ret_var_stmt = nullptr; diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 754c5d2..80566f6 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -56,7 +56,7 @@ public: &resolved_type); rust_assert (ok); - ::Btype *type = TyTyResolveCompile::compile (ctx, resolved_type); + tree type = TyTyResolveCompile::compile (ctx, resolved_type); Bexpression *value = CompileExpr::Compile (constant.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; diff --git a/gcc/rust/backend/rust-compile-tyty.h b/gcc/rust/backend/rust-compile-tyty.h index 180b971..04a3ecd 100644 --- a/gcc/rust/backend/rust-compile-tyty.h +++ b/gcc/rust/backend/rust-compile-tyty.h @@ -34,7 +34,7 @@ namespace Compile { class TyTyCompile : public TyTy::TyVisitor { public: - static ::Btype *compile (::Backend *backend, TyTy::BaseType *ty) + static tree compile (::Backend *backend, TyTy::BaseType *ty) { TyTyCompile compiler (backend); ty->accept_vis (compiler); @@ -72,15 +72,15 @@ public: void visit (TyTy::FnType &type) override { - Backend::Btyped_identifier receiver; - std::vector parameters; - std::vector results; + Backend::typed_identifier receiver; + std::vector parameters; + std::vector results; if (!type.get_return_type ()->is_unit ()) { auto hir_type = type.get_return_type (); auto ret = TyTyCompile::compile (backend, hir_type); - results.push_back (Backend::Btyped_identifier ( + results.push_back (Backend::typed_identifier ( "_", ret, mappings->lookup_location (hir_type->get_ref ()))); } @@ -90,7 +90,7 @@ public: auto param_tyty = params.second; auto compiled_param_type = TyTyCompile::compile (backend, param_tyty); - auto compiled_param = Backend::Btyped_identifier ( + auto compiled_param = Backend::typed_identifier ( param_pattern->as_string (), compiled_param_type, mappings->lookup_location (param_tyty->get_ref ())); @@ -227,7 +227,7 @@ public: void visit (TyTy::StrType &) override { - Btype *raw_str = backend->raw_str_type (); + tree raw_str = backend->raw_str_type (); translated = backend->named_type ("str", raw_str, Linemap::predeclared_location ()); } @@ -248,7 +248,7 @@ private: {} ::Backend *backend; - ::Btype *translated; + tree translated; Analysis::Mappings *mappings; }; diff --git a/gcc/rust/backend/rust-compile-var-decl.h b/gcc/rust/backend/rust-compile-var-decl.h index 7a86e15..deabd7d 100644 --- a/gcc/rust/backend/rust-compile-var-decl.h +++ b/gcc/rust/backend/rust-compile-var-decl.h @@ -70,7 +70,7 @@ private: {} ::Bfunction *fndecl; - ::Btype *translated_type; + tree translated_type; Location locus; ::Bvariable *translated; }; diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index e53993a..cb736f3 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -72,7 +72,7 @@ CompileExpr::visit (HIR::CallExpr &expr) { rust_assert (tyty->get_kind () == TyTy::TypeKind::ADT); TyTy::ADTType *adt = static_cast (tyty); - Btype *compiled_adt_type = TyTyResolveCompile::compile (ctx, tyty); + tree compiled_adt_type = TyTyResolveCompile::compile (ctx, tyty); rust_assert (!adt->is_enum ()); rust_assert (adt->number_of_variants () == 1); @@ -275,7 +275,7 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) break; case Resolver::Adjustment::AdjustmentType::DEREF_REF: - Btype *expected_type + tree expected_type = TyTyResolveCompile::compile (ctx, adjustment.get_expected ()); self = ctx->get_backend ()->indirect_expression ( expected_type, self, true, /* known_valid*/ @@ -587,7 +587,7 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref, const TyTy::DynamicObjectType *ty, Location locus) { - Btype *dynamic_object = TyTyResolveCompile::compile (ctx, ty); + tree dynamic_object = TyTyResolveCompile::compile (ctx, ty); //' this assumes ordering and current the structure is // __trait_object_ptr -- cgit v1.1 From b52a68d2d8676ea378f0fbb6726639cc80402542 Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 11:17:26 -0800 Subject: Replace Bexpression with GCC tree --- gcc/rust/backend/rust-compile-base.h | 14 ++-- gcc/rust/backend/rust-compile-context.h | 15 ++-- gcc/rust/backend/rust-compile-expr.cc | 31 ++++---- gcc/rust/backend/rust-compile-expr.h | 96 +++++++++++------------ gcc/rust/backend/rust-compile-implitem.h | 31 ++++---- gcc/rust/backend/rust-compile-item.h | 17 ++-- gcc/rust/backend/rust-compile-resolve-path.cc | 6 +- gcc/rust/backend/rust-compile-resolve-path.h | 21 +++-- gcc/rust/backend/rust-compile-stmt.h | 10 +-- gcc/rust/backend/rust-compile-struct-field-expr.h | 4 +- gcc/rust/backend/rust-compile.cc | 47 +++++------ 11 files changed, 136 insertions(+), 156 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index 3184e27..5650451 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -200,16 +200,14 @@ protected: bool compile_locals_for_block (Resolver::Rib &rib, Bfunction *fndecl, std::vector &locals); - Bexpression *coercion_site (Bexpression *compiled_ref, TyTy::BaseType *actual, - TyTy::BaseType *expected, Location locus); + tree coercion_site (tree compiled_ref, TyTy::BaseType *actual, + TyTy::BaseType *expected, Location locus); - Bexpression *coerce_to_dyn_object (Bexpression *compiled_ref, - const TyTy::BaseType *actual, - const TyTy::BaseType *expected, - const TyTy::DynamicObjectType *ty, - Location locus); + tree coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual, + const TyTy::BaseType *expected, + const TyTy::DynamicObjectType *ty, Location locus); - Bexpression *compute_address_for_trait_item ( + tree compute_address_for_trait_item ( const Resolver::TraitItemReference *ref, const TyTy::TypeBoundPredicate *predicate, std::vector> diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 82c02f8..35ea012 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -210,12 +210,9 @@ public: return true; } - void insert_const_decl (HirId id, ::Bexpression *expr) - { - compiled_consts[id] = expr; - } + void insert_const_decl (HirId id, ::tree expr) { compiled_consts[id] = expr; } - bool lookup_const_decl (HirId id, ::Bexpression **expr) + bool lookup_const_decl (HirId id, ::tree *expr) { auto it = compiled_consts.find (id); if (it == compiled_consts.end ()) @@ -249,7 +246,7 @@ public: void push_type (::tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); } - void push_const (::Bexpression *c) { const_decls.push_back (c); } + void push_const (::tree c) { const_decls.push_back (c); } void push_function (::Bfunction *f) { func_decls.push_back (f); } void write_to_backend () @@ -322,9 +319,9 @@ private: // state std::vector fn_stack; std::map compiled_var_decls; - std::map compiled_type_map; + std::map compiled_type_map; std::map compiled_fn_map; - std::map compiled_consts; + std::map compiled_consts; std::map compiled_labels; std::vector<::std::vector> statements; std::vector<::Bblock *> scope_stack; @@ -337,7 +334,7 @@ private: // To GCC middle-end std::vector type_decls; std::vector<::Bvariable *> var_decls; - std::vector<::Bexpression *> const_decls; + std::vector const_decls; std::vector<::Bfunction *> func_decls; }; diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 0279ef9..d475ec4 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -117,11 +117,10 @@ CompileExpr::visit (HIR::NegationExpr &expr) = ctx->get_backend ()->negation_expression (op, negated_expr, location); } -Bexpression * +tree CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, TyTy::BaseType *receiver, - TyTy::FnType *fntype, - Bexpression *receiver_ref, + TyTy::FnType *fntype, tree receiver_ref, std::vector &arguments, Location expr_locus) { @@ -153,7 +152,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, tree indrect_compiled_tyty = TyTyResolveCompile::compile (ctx, indirect_ty); - Bexpression *indirect + tree indirect = ctx->get_backend ()->indirect_expression (indrect_compiled_tyty, receiver_ref, true, expr_locus); @@ -161,18 +160,18 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, } // access the offs + 1 for the fnptr and offs=0 for the reciever obj - Bexpression *self_argument + tree self_argument = ctx->get_backend ()->struct_field_expression (receiver_ref, 0, expr_locus); // access the vtable for the fn - Bexpression *fn_vtable_access + tree fn_vtable_access = ctx->get_backend ()->struct_field_expression (receiver_ref, offs + 1, expr_locus); // cast it to the correct fntype tree expected_fntype = TyTyResolveCompile::compile (ctx, fntype, true); - Bexpression *fn_convert_expr + tree fn_convert_expr = ctx->get_backend ()->convert_expression (expected_fntype, fn_vtable_access, expr_locus); @@ -187,22 +186,22 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, &ret_var_stmt); ctx->add_statement (ret_var_stmt); - std::vector args; + std::vector args; args.push_back (self_argument); for (auto &argument : arguments) { - Bexpression *compiled_expr = CompileExpr::Compile (argument, ctx); + tree compiled_expr = CompileExpr::Compile (argument, ctx); args.push_back (compiled_expr); } - Bexpression *fn_expr + tree fn_expr = ctx->get_backend ()->var_expression (fn_convert_expr_tmp, expr_locus); return ctx->get_backend ()->call_expression (fnctx.fndecl, fn_expr, args, nullptr, expr_locus); } -Bexpression * +tree CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, TyTy::BaseType *receiver, HIR::PathIdentSegment &segment, @@ -294,10 +293,10 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, } } -Bexpression * +tree CompileExpr::resolve_operator_overload ( Analysis::RustLangItem::ItemType lang_item_type, HIR::OperatorExpr &expr, - Bexpression *lhs, Bexpression *rhs, HIR::Expr *lhs_expr, HIR::Expr *rhs_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 ( @@ -346,7 +345,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)); - Bexpression *fn_expr + tree fn_expr = resolve_method_address (fntype, ref, receiver, segment_name, expr.get_mappings (), expr.get_locus ()); @@ -357,7 +356,7 @@ CompileExpr::resolve_operator_overload ( rust_assert (ok); // FIXME refactor this out - Bexpression *self = lhs; + tree self = lhs; for (auto &adjustment : *adjustments) { switch (adjustment.get_type ()) @@ -380,7 +379,7 @@ CompileExpr::resolve_operator_overload ( } } - std::vector args; + std::vector args; args.push_back (self); // adjusted self if (rhs != nullptr) // can be null for negation_expr (unary ones) args.push_back (rhs); diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index d2f79ec..2f6395c 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -33,7 +33,7 @@ class CompileExpr : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *Compile (HIR::Expr *expr, Context *ctx) + static tree Compile (HIR::Expr *expr, Context *ctx) { CompileExpr compiler (ctx); expr->accept_vis (compiler); @@ -45,7 +45,7 @@ public: HIR::Expr *tuple_expr = expr.get_tuple_expr ().get (); TupleIndex index = expr.get_tuple_index (); - Bexpression *receiver_ref = CompileExpr::Compile (tuple_expr, ctx); + tree receiver_ref = CompileExpr::Compile (tuple_expr, ctx); TyTy::BaseType *tuple_expr_ty = nullptr; bool ok = ctx->get_tyctx ()->lookup_type ( @@ -60,7 +60,7 @@ public: TyTy::BaseType *tuple_type = r->get_base (); tree tuple_tyty = TyTyResolveCompile::compile (ctx, tuple_type); - Bexpression *indirect + tree indirect = ctx->get_backend ()->indirect_expression (tuple_tyty, receiver_ref, true, expr.get_locus ()); receiver_ref = indirect; @@ -92,7 +92,7 @@ public: rust_assert (tuple_type != nullptr); // this assumes all fields are in order from type resolution - std::vector vals; + std::vector vals; for (auto &elem : expr.get_tuple_elems ()) { auto e = CompileExpr::Compile (elem.get (), ctx); @@ -108,10 +108,10 @@ public: { auto fncontext = ctx->peek_fn (); - std::vector retstmts; + std::vector retstmts; if (expr.has_return_expr ()) { - Bexpression *compiled_expr + tree compiled_expr = CompileExpr::Compile (expr.return_expr.get (), ctx); rust_assert (compiled_expr != nullptr); @@ -330,21 +330,19 @@ public: auto array_tyty = static_cast (base_tyty); std::string value_str = expr.get_literal ()->as_string (); - std::vector vals; + std::vector vals; std::vector indexes; for (size_t i = 0; i < value_str.size (); i++) { char b = value_str.at (i); - Bexpression *bb - = ctx->get_backend ()->char_constant_expression (b); + tree bb = ctx->get_backend ()->char_constant_expression (b); vals.push_back (bb); indexes.push_back (i); } tree array_type = TyTyResolveCompile::compile (ctx, array_tyty); - Bexpression *constructed - = ctx->get_backend ()->array_constructor_expression ( - array_type, indexes, vals, expr.get_locus ()); + tree constructed = ctx->get_backend ()->array_constructor_expression ( + array_type, indexes, vals, expr.get_locus ()); translated = ctx->get_backend ()->address_expression (constructed, @@ -392,8 +390,8 @@ public: void visit (HIR::ArrayIndexExpr &expr) override { - Bexpression *array = CompileExpr::Compile (expr.get_array_expr (), ctx); - Bexpression *index = CompileExpr::Compile (expr.get_index_expr (), ctx); + tree array = CompileExpr::Compile (expr.get_array_expr (), ctx); + tree index = CompileExpr::Compile (expr.get_index_expr (), ctx); translated = ctx->get_backend ()->array_index_expression (array, index, expr.get_locus ()); @@ -432,14 +430,14 @@ public: { for (auto &elem : elems.get_values ()) { - Bexpression *translated_expr = CompileExpr::Compile (elem.get (), ctx); + tree translated_expr = CompileExpr::Compile (elem.get (), ctx); constructor.push_back (translated_expr); } } void visit (HIR::ArrayElemsCopied &elems) override { - Bexpression *translated_expr + tree translated_expr = CompileExpr::Compile (elems.get_elem_to_copy (), ctx); size_t capacity; @@ -645,10 +643,10 @@ public: // this assumes all fields are in order from type resolution and if a base // struct was specified those fields are filed via accesors - std::vector vals; + std::vector vals; for (auto &field : struct_expr.get_fields ()) { - Bexpression *expr = CompileStructExprField::Compile (field.get (), ctx); + tree expr = CompileStructExprField::Compile (field.get (), ctx); vals.push_back (expr); } @@ -665,7 +663,7 @@ public: void visit (HIR::FieldAccessExpr &expr) override { - Bexpression *receiver_ref + tree receiver_ref = CompileExpr::Compile (expr.get_receiver_expr ().get (), ctx); // resolve the receiver back to ADT type @@ -706,7 +704,7 @@ public: rust_assert (ok); tree adt_tyty = TyTyResolveCompile::compile (ctx, adt); - Bexpression *indirect + tree indirect = ctx->get_backend ()->indirect_expression (adt_tyty, receiver_ref, true, expr.get_locus ()); receiver_ref = indirect; @@ -777,7 +775,7 @@ public: Bblock *code_block = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); - Bexpression *loop_expr + tree loop_expr = ctx->get_backend ()->loop_expression (code_block, expr.get_locus ()); Bstatement *loop_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, loop_expr); @@ -826,9 +824,9 @@ public: ctx->add_statement (loop_begin_label_decl); ctx->push_loop_begin_label (loop_begin_label); - Bexpression *condition + tree condition = CompileExpr::Compile (expr.get_predicate_expr ().get (), ctx); - Bexpression *exit_expr + tree exit_expr = ctx->get_backend ()->exit_expression (condition, expr.get_locus ()); Bstatement *break_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, exit_expr); @@ -843,7 +841,7 @@ public: ctx->pop_loop_begin_label (); ctx->pop_block (); - Bexpression *loop_expr + tree loop_expr = ctx->get_backend ()->loop_expression (loop_block, expr.get_locus ()); Bstatement *loop_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, loop_expr); @@ -855,11 +853,11 @@ public: fncontext fnctx = ctx->peek_fn (); if (expr.has_break_expr ()) { - Bexpression *compiled_expr + tree compiled_expr = CompileExpr::Compile (expr.get_expr ().get (), ctx); Bvariable *loop_result_holder = ctx->peek_loop_context (); - Bexpression *result_reference = ctx->get_backend ()->var_expression ( + tree result_reference = ctx->get_backend ()->var_expression ( loop_result_holder, expr.get_expr ()->get_locus ()); Bstatement *assignment = ctx->get_backend ()->assignment_statement ( @@ -904,7 +902,7 @@ public: } else { - Bexpression *exit_expr = ctx->get_backend ()->exit_expression ( + tree exit_expr = ctx->get_backend ()->exit_expression ( ctx->get_backend ()->boolean_constant_expression (true), expr.get_locus ()); Bstatement *break_stmt @@ -954,8 +952,7 @@ public: void visit (HIR::BorrowExpr &expr) override { - Bexpression *main_expr - = CompileExpr::Compile (expr.get_expr ().get (), ctx); + tree main_expr = CompileExpr::Compile (expr.get_expr ().get (), ctx); translated = ctx->get_backend ()->address_expression (main_expr, expr.get_locus ()); @@ -963,8 +960,7 @@ public: void visit (HIR::DereferenceExpr &expr) override { - Bexpression *main_expr - = CompileExpr::Compile (expr.get_expr ().get (), ctx); + tree main_expr = CompileExpr::Compile (expr.get_expr ().get (), ctx); TyTy::BaseType *tyty = nullptr; if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), @@ -984,33 +980,31 @@ public: } protected: - Bexpression *compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, - TyTy::BaseType *receiver, - TyTy::FnType *fntype, - Bexpression *receiver_ref, - std::vector &arguments, - Location expr_locus); - - Bexpression *resolve_method_address (TyTy::FnType *fntype, HirId ref, - TyTy::BaseType *receiver, - HIR::PathIdentSegment &segment, - Analysis::NodeMapping expr_mappings, - Location expr_locus); - - Bexpression * + tree compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, + TyTy::BaseType *receiver, + TyTy::FnType *fntype, tree receiver_ref, + std::vector &arguments, + Location expr_locus); + + tree resolve_method_address (TyTy::FnType *fntype, HirId ref, + TyTy::BaseType *receiver, + HIR::PathIdentSegment &segment, + Analysis::NodeMapping expr_mappings, + Location expr_locus); + + tree resolve_operator_overload (Analysis::RustLangItem::ItemType lang_item_type, - HIR::OperatorExpr &expr, Bexpression *lhs, - Bexpression *rhs, HIR::Expr *lhs_expr, - HIR::Expr *rhs_expr); + HIR::OperatorExpr &expr, tree lhs, tree rhs, + HIR::Expr *lhs_expr, HIR::Expr *rhs_expr); private: CompileExpr (Context *ctx) : HIRCompileBase (ctx), translated (nullptr), capacity_expr (nullptr) {} - Bexpression *translated; - Bexpression *capacity_expr; - std::vector constructor; + tree translated; + tree capacity_expr; + std::vector constructor; }; } // namespace Compile diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 51a691f..65f3d2c 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -34,11 +34,11 @@ class CompileInherentImplItem : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *Compile (const TyTy::BaseType *self, HIR::ImplItem *item, - Context *ctx, bool compile_fns, - TyTy::BaseType *concrete = nullptr, - bool is_query_mode = false, - Location ref_locus = Location ()) + static tree Compile (const TyTy::BaseType *self, HIR::ImplItem *item, + Context *ctx, bool compile_fns, + TyTy::BaseType *concrete = nullptr, + bool is_query_mode = false, + Location ref_locus = Location ()) { CompileInherentImplItem compiler (self, ctx, compile_fns, concrete, ref_locus); @@ -61,7 +61,7 @@ public: rust_assert (ok); tree type = TyTyResolveCompile::compile (ctx, resolved_type); - Bexpression *value = CompileExpr::Compile (constant.get_expr (), ctx); + tree value = CompileExpr::Compile (constant.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; ok = ctx->get_mappings ()->lookup_canonical_path ( @@ -70,7 +70,7 @@ public: rust_assert (ok); std::string ident = canonical_path->get (); - Bexpression *const_expr = ctx->get_backend ()->named_constant_expression ( + tree const_expr = ctx->get_backend ()->named_constant_expression ( type, constant.get_identifier (), value, constant.get_locus ()); ctx->push_const (const_expr); @@ -319,7 +319,7 @@ private: const TyTy::BaseType *self; bool compile_fns; TyTy::BaseType *concrete; - Bexpression *reference; + tree reference; Location ref_locus; }; @@ -328,10 +328,10 @@ class CompileTraitItem : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *Compile (const TyTy::BaseType *self, HIR::TraitItem *item, - Context *ctx, TyTy::BaseType *concrete, - bool is_query_mode = false, - Location ref_locus = Location ()) + static tree Compile (const TyTy::BaseType *self, HIR::TraitItem *item, + Context *ctx, TyTy::BaseType *concrete, + bool is_query_mode = false, + Location ref_locus = Location ()) { CompileTraitItem compiler (self, ctx, concrete, ref_locus); item->accept_vis (compiler); @@ -350,8 +350,7 @@ public: TyTy::BaseType *resolved_type = concrete; tree type = TyTyResolveCompile::compile (ctx, resolved_type); - Bexpression *value - = CompileExpr::Compile (constant.get_expr ().get (), ctx); + tree value = CompileExpr::Compile (constant.get_expr ().get (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; bool ok = ctx->get_mappings ()->lookup_canonical_path ( @@ -360,7 +359,7 @@ public: rust_assert (ok); std::string ident = canonical_path->get (); - Bexpression *const_expr = ctx->get_backend ()->named_constant_expression ( + tree const_expr = ctx->get_backend ()->named_constant_expression ( type, constant.get_name (), value, constant.get_locus ()); ctx->push_const (const_expr); @@ -578,7 +577,7 @@ private: const TyTy::BaseType *self; TyTy::BaseType *concrete; - Bexpression *reference; + tree reference; Location ref_locus; }; diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 87c577c..95de611 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -37,11 +37,10 @@ protected: using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *compile (HIR::Item *item, Context *ctx, - bool compile_fns = true, - TyTy::BaseType *concrete = nullptr, - bool is_query_mode = false, - Location ref_locus = Location ()) + static tree compile (HIR::Item *item, Context *ctx, bool compile_fns = true, + TyTy::BaseType *concrete = nullptr, + bool is_query_mode = false, + Location ref_locus = Location ()) { CompileItem compiler (ctx, compile_fns, concrete, ref_locus); item->accept_vis (compiler); @@ -62,7 +61,7 @@ public: rust_assert (ok); tree type = TyTyResolveCompile::compile (ctx, resolved_type); - Bexpression *value = CompileExpr::Compile (var.get_expr (), ctx); + tree value = CompileExpr::Compile (var.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; ok = ctx->get_mappings ()->lookup_canonical_path ( @@ -98,7 +97,7 @@ public: rust_assert (ok); tree type = TyTyResolveCompile::compile (ctx, resolved_type); - Bexpression *value = CompileExpr::Compile (constant.get_expr (), ctx); + tree value = CompileExpr::Compile (constant.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; ok = ctx->get_mappings ()->lookup_canonical_path ( @@ -107,7 +106,7 @@ public: rust_assert (ok); std::string ident = canonical_path->get (); - Bexpression *const_expr + tree const_expr = ctx->get_backend ()->named_constant_expression (type, ident, value, constant.get_locus ()); @@ -347,7 +346,7 @@ protected: bool compile_fns; TyTy::BaseType *concrete; - Bexpression *reference; + tree reference; Location ref_locus; }; diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index d571d4a..81ffad8 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -40,7 +40,7 @@ ResolvePathRef::visit (HIR::PathInExpression &expr) expr.get_mappings (), expr.get_locus (), false); } -Bexpression * +tree ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, const Analysis::NodeMapping &mappings, Location expr_locus, bool is_qualified_path) @@ -76,7 +76,7 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, } // might be a constant - Bexpression *constant_expr; + tree constant_expr; if (ctx->lookup_const_decl (ref, &constant_expr)) return constant_expr; @@ -104,7 +104,7 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, is_qualified_path); } -Bexpression * +tree ResolvePathRef::query_compile (HirId ref, TyTy::BaseType *lookup, const HIR::PathIdentSegment &final_segment, const Analysis::NodeMapping &mappings, diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h index ecb89b3..56f82d1 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.h +++ b/gcc/rust/backend/rust-compile-resolve-path.h @@ -30,15 +30,14 @@ class ResolvePathRef : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *Compile (HIR::QualifiedPathInExpression &expr, - Context *ctx) + static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx) { ResolvePathRef resolver (ctx); expr.accept_vis (resolver); return resolver.resolved; } - static Bexpression *Compile (HIR::PathInExpression &expr, Context *ctx) + static tree Compile (HIR::PathInExpression &expr, Context *ctx) { ResolvePathRef resolver (ctx); expr.accept_vis (resolver); @@ -54,16 +53,16 @@ private: : HIRCompileBase (ctx), resolved (ctx->get_backend ()->error_expression ()) {} - Bexpression *resolve (const HIR::PathIdentSegment &final_segment, - const Analysis::NodeMapping &mappings, Location locus, - bool is_qualified_path); + tree resolve (const HIR::PathIdentSegment &final_segment, + const Analysis::NodeMapping &mappings, Location locus, + bool is_qualified_path); - Bexpression *query_compile (HirId ref, TyTy::BaseType *lookup, - const HIR::PathIdentSegment &final_segment, - const Analysis::NodeMapping &mappings, - Location expr_locus, bool is_qualified_path); + tree query_compile (HirId ref, TyTy::BaseType *lookup, + const HIR::PathIdentSegment &final_segment, + const Analysis::NodeMapping &mappings, + Location expr_locus, bool is_qualified_path); - Bexpression *resolved; + tree resolved; }; } // namespace Compile diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 80566f6..604d9a5 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -31,7 +31,7 @@ class CompileStmt : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *Compile (HIR::Stmt *stmt, Context *ctx) + static tree Compile (HIR::Stmt *stmt, Context *ctx) { CompileStmt compiler (ctx); stmt->accept_vis (compiler); @@ -57,7 +57,7 @@ public: rust_assert (ok); tree type = TyTyResolveCompile::compile (ctx, resolved_type); - Bexpression *value = CompileExpr::Compile (constant.get_expr (), ctx); + tree value = CompileExpr::Compile (constant.get_expr (), ctx); const Resolver::CanonicalPath *canonical_path = nullptr; ok = ctx->get_mappings ()->lookup_canonical_path ( @@ -66,7 +66,7 @@ public: rust_assert (ok); std::string ident = canonical_path->get (); - Bexpression *const_expr + tree const_expr = ctx->get_backend ()->named_constant_expression (type, ident, value, constant.get_locus ()); @@ -101,7 +101,7 @@ public: return; } - Bexpression *init = CompileExpr::Compile (stmt.get_init_expr (), ctx); + tree init = CompileExpr::Compile (stmt.get_init_expr (), ctx); // FIXME use error_mark_node, check that CompileExpr returns error_mark_node // on failure and make this an assertion if (init == nullptr) @@ -132,7 +132,7 @@ public: private: CompileStmt (Context *ctx) : HIRCompileBase (ctx), translated (nullptr) {} - Bexpression *translated; + tree translated; }; } // namespace Compile diff --git a/gcc/rust/backend/rust-compile-struct-field-expr.h b/gcc/rust/backend/rust-compile-struct-field-expr.h index 553e870..6754e8c 100644 --- a/gcc/rust/backend/rust-compile-struct-field-expr.h +++ b/gcc/rust/backend/rust-compile-struct-field-expr.h @@ -30,7 +30,7 @@ class CompileStructExprField : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bexpression *Compile (HIR::StructExprField *field, Context *ctx) + static tree Compile (HIR::StructExprField *field, Context *ctx) { CompileStructExprField compiler (ctx); field->accept_vis (compiler); @@ -49,7 +49,7 @@ private: : HIRCompileBase (ctx), translated (nullptr) {} - Bexpression *translated; + tree translated; }; } // namespace Compile diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index cb736f3..3531930 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -80,7 +80,7 @@ CompileExpr::visit (HIR::CallExpr &expr) // this assumes all fields are in order from type resolution and if a // base struct was specified those fields are filed via accesors - std::vector vals; + std::vector vals; for (size_t i = 0; i < expr.get_arguments ().size (); i++) { auto &argument = expr.get_arguments ().at (i); @@ -150,7 +150,7 @@ CompileExpr::visit (HIR::CallExpr &expr) required_num_args = fn->num_params (); } - std::vector args; + std::vector args; for (size_t i = 0; i < expr.get_arguments ().size (); i++) { auto &argument = expr.get_arguments ().at (i); @@ -195,7 +195,7 @@ void CompileExpr::visit (HIR::MethodCallExpr &expr) { // method receiver - Bexpression *self = CompileExpr::Compile (expr.get_receiver ().get (), ctx); + tree self = CompileExpr::Compile (expr.get_receiver ().get (), ctx); // lookup the resolved name NodeId resolved_node_id = UNKNOWN_NODEID; @@ -254,7 +254,7 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) // lookup compiled functions since it may have already been compiled HIR::PathExprSegment method_name = expr.get_method_name (); HIR::PathIdentSegment segment_name = method_name.get_segment (); - Bexpression *fn_expr + tree fn_expr = resolve_method_address (fntype, ref, receiver, segment_name, expr.get_mappings (), expr.get_locus ()); @@ -284,7 +284,7 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) } } - std::vector args; + std::vector args; args.push_back (self); // adjusted self // normal args @@ -360,7 +360,7 @@ CompileBlock::visit (HIR::BlockExpr &expr) { // the previous passes will ensure this is a valid return or // a valid trailing expression - Bexpression *compiled_expr = CompileExpr::Compile (expr.expr.get (), ctx); + tree compiled_expr = CompileExpr::Compile (expr.expr.get (), ctx); if (compiled_expr != nullptr) { if (result == nullptr) @@ -372,9 +372,8 @@ CompileBlock::visit (HIR::BlockExpr &expr) } else { - Bexpression *result_reference - = ctx->get_backend ()->var_expression ( - result, expr.get_final_expr ()->get_locus ()); + tree result_reference = ctx->get_backend ()->var_expression ( + result, expr.get_final_expr ()->get_locus ()); Bstatement *assignment = ctx->get_backend ()->assignment_statement (fnctx.fndecl, @@ -395,8 +394,7 @@ CompileConditionalBlocks::visit (HIR::IfExpr &expr) { fncontext fnctx = ctx->peek_fn (); Bfunction *fndecl = fnctx.fndecl; - Bexpression *condition_expr - = CompileExpr::Compile (expr.get_if_condition (), ctx); + tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); Bblock *then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); @@ -410,8 +408,7 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqElse &expr) { fncontext fnctx = ctx->peek_fn (); Bfunction *fndecl = fnctx.fndecl; - Bexpression *condition_expr - = CompileExpr::Compile (expr.get_if_condition (), ctx); + tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); Bblock *then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); Bblock *else_block @@ -427,8 +424,7 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqIf &expr) { fncontext fnctx = ctx->peek_fn (); Bfunction *fndecl = fnctx.fndecl; - Bexpression *condition_expr - = CompileExpr::Compile (expr.get_if_condition (), ctx); + tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); Bblock *then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); @@ -500,14 +496,14 @@ HIRCompileBase::compile_function_body ( { // the previous passes will ensure this is a valid return // or a valid trailing expression - Bexpression *compiled_expr + tree compiled_expr = CompileExpr::Compile (function_body->expr.get (), ctx); if (compiled_expr != nullptr) { if (has_return_type) { - std::vector retstmts; + std::vector retstmts; retstmts.push_back (compiled_expr); auto ret = ctx->get_backend ()->return_statement ( @@ -561,10 +557,9 @@ HIRCompileBase::compile_locals_for_block (Resolver::Rib &rib, Bfunction *fndecl, return true; } -Bexpression * -HIRCompileBase::coercion_site (Bexpression *compiled_ref, - TyTy::BaseType *actual, TyTy::BaseType *expected, - Location locus) +tree +HIRCompileBase::coercion_site (tree compiled_ref, TyTy::BaseType *actual, + TyTy::BaseType *expected, Location locus) { auto root_actual_kind = actual->get_root ()->get_kind (); auto root_expected_kind = expected->get_root ()->get_kind (); @@ -580,8 +575,8 @@ HIRCompileBase::coercion_site (Bexpression *compiled_ref, return compiled_ref; } -Bexpression * -HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref, +tree +HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, const TyTy::BaseType *actual, const TyTy::BaseType *expected, const TyTy::DynamicObjectType *ty, @@ -597,7 +592,7 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref, std::vector> probed_bounds_for_receiver = Resolver::TypeBoundsProbe::Probe (root); - std::vector vals; + std::vector vals; vals.push_back (compiled_ref); for (auto &bound : ty->get_object_items ()) { @@ -610,7 +605,7 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref, vals.push_back (address); } - Bexpression *constructed_trait_object + tree constructed_trait_object = ctx->get_backend ()->constructor_expression (dynamic_object, vals, -1, locus); @@ -659,7 +654,7 @@ HIRCompileBase::coerce_to_dyn_object (Bexpression *compiled_ref, return resulting_dyn_object_ref; } -Bexpression * +tree HIRCompileBase::compute_address_for_trait_item ( const Resolver::TraitItemReference *ref, const TyTy::TypeBoundPredicate *predicate, -- cgit v1.1 From 553e88f1dd4b4794334ee6d1861c185b92361a0b Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 11:24:40 -0800 Subject: Replace Bstatement with GCC tree --- gcc/rust/backend/rust-compile-block.h | 11 +++++----- gcc/rust/backend/rust-compile-context.h | 6 +++--- gcc/rust/backend/rust-compile-expr.cc | 4 ++-- gcc/rust/backend/rust-compile-expr.h | 35 ++++++++++++++++---------------- gcc/rust/backend/rust-compile-implitem.h | 4 ++-- gcc/rust/backend/rust-compile-item.h | 2 +- gcc/rust/backend/rust-compile-stmt.h | 2 +- gcc/rust/backend/rust-compile.cc | 14 ++++++------- 8 files changed, 38 insertions(+), 40 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-block.h b/gcc/rust/backend/rust-compile-block.h index 6876e8a..0e631e1 100644 --- a/gcc/rust/backend/rust-compile-block.h +++ b/gcc/rust/backend/rust-compile-block.h @@ -53,8 +53,7 @@ class CompileConditionalBlocks : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bstatement *compile (HIR::IfExpr *expr, Context *ctx, - Bvariable *result) + static tree compile (HIR::IfExpr *expr, Context *ctx, Bvariable *result) { CompileConditionalBlocks resolver (ctx, result); expr->accept_vis (resolver); @@ -72,7 +71,7 @@ private: : HIRCompileBase (ctx), translated (nullptr), result (result) {} - Bstatement *translated; + tree translated; Bvariable *result; }; @@ -81,8 +80,8 @@ class CompileExprWithBlock : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bstatement *compile (HIR::ExprWithBlock *expr, Context *ctx, - Bvariable *result) + static tree compile (HIR::ExprWithBlock *expr, Context *ctx, + Bvariable *result) { CompileExprWithBlock resolver (ctx, result); expr->accept_vis (resolver); @@ -109,7 +108,7 @@ private: : HIRCompileBase (ctx), translated (nullptr), result (result) {} - Bstatement *translated; + tree translated; Bvariable *result; }; diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 35ea012..1128fa8 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -139,12 +139,12 @@ public: return scope_stack.back (); } - void add_statement_to_enclosing_scope (Bstatement *stmt) + void add_statement_to_enclosing_scope (tree stmt) { statements.at (statements.size () - 2).push_back (stmt); } - void add_statement (Bstatement *stmt) { statements.back ().push_back (stmt); } + void add_statement (tree stmt) { statements.back ().push_back (stmt); } void insert_var_decl (HirId id, ::Bvariable *decl) { @@ -323,7 +323,7 @@ private: std::map compiled_fn_map; std::map compiled_consts; std::map compiled_labels; - std::vector<::std::vector> statements; + std::vector<::std::vector> statements; std::vector<::Bblock *> scope_stack; std::vector<::Bvariable *> loop_value_stack; std::vector<::Blabel *> loop_begin_labels; diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index d475ec4..8786702 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -86,7 +86,7 @@ CompileExpr::visit (HIR::CompoundAssignmentExpr &expr) auto operator_expr = ctx->get_backend ()->arithmetic_or_logical_expression (op, lhs, rhs, expr.get_locus ()); - Bstatement *assignment + tree assignment = ctx->get_backend ()->assignment_statement (fn.fndecl, lhs, operator_expr, expr.get_locus ()); ctx->add_statement (assignment); @@ -178,7 +178,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, fncontext fnctx = ctx->peek_fn (); Bblock *enclosing_scope = ctx->peek_enclosing_scope (); bool is_address_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = NULL_TREE; Bvariable *fn_convert_expr_tmp = ctx->get_backend ()->temporary_variable (fnctx.fndecl, enclosing_scope, expected_fntype, fn_convert_expr, diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 2f6395c..14d4345 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -379,7 +379,7 @@ public: rvalue = coercion_site (rvalue, actual, expected, expr.get_locus ()); - Bstatement *assignment + tree assignment = ctx->get_backend ()->assignment_statement (fn.fndecl, lvalue, rvalue, expr.get_locus ()); @@ -518,7 +518,7 @@ public: tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = nullptr; tmp = ctx->get_backend ()->temporary_variable ( fnctx.fndecl, enclosing_scope, block_type, NULL, is_address_taken, expr.get_locus (), &ret_var_stmt); @@ -555,7 +555,7 @@ public: tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = nullptr; tmp = ctx->get_backend ()->temporary_variable ( fnctx.fndecl, enclosing_scope, block_type, NULL, is_address_taken, expr.get_locus (), &ret_var_stmt); @@ -591,7 +591,7 @@ public: tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = nullptr; tmp = ctx->get_backend ()->temporary_variable ( fnctx.fndecl, enclosing_scope, block_type, NULL, is_address_taken, expr.get_locus (), &ret_var_stmt); @@ -744,7 +744,7 @@ public: tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = NULL_TREE; tmp = ctx->get_backend ()->temporary_variable ( fnctx.fndecl, enclosing_scope, block_type, NULL, is_address_taken, expr.get_locus (), &ret_var_stmt); @@ -759,7 +759,7 @@ public: = ctx->get_backend ()->label (fnctx.fndecl, loop_label.get_lifetime ().get_name (), loop_label.get_locus ()); - Bstatement *label_decl + tree label_decl = ctx->get_backend ()->label_definition_statement (label); ctx->add_statement (label_decl); ctx->insert_label_decl ( @@ -768,7 +768,7 @@ public: Blabel *loop_begin_label = ctx->get_backend ()->label (fnctx.fndecl, "", expr.get_locus ()); - Bstatement *loop_begin_label_decl + tree loop_begin_label_decl = ctx->get_backend ()->label_definition_statement (loop_begin_label); ctx->add_statement (loop_begin_label_decl); ctx->push_loop_begin_label (loop_begin_label); @@ -777,7 +777,7 @@ public: = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); tree loop_expr = ctx->get_backend ()->loop_expression (code_block, expr.get_locus ()); - Bstatement *loop_stmt + tree loop_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, loop_expr); ctx->add_statement (loop_stmt); @@ -800,7 +800,7 @@ public: = ctx->get_backend ()->label (fnctx.fndecl, loop_label.get_lifetime ().get_name (), loop_label.get_locus ()); - Bstatement *label_decl + tree label_decl = ctx->get_backend ()->label_definition_statement (label); ctx->add_statement (label_decl); ctx->insert_label_decl ( @@ -819,7 +819,7 @@ public: Blabel *loop_begin_label = ctx->get_backend ()->label (fnctx.fndecl, "", expr.get_locus ()); - Bstatement *loop_begin_label_decl + tree loop_begin_label_decl = ctx->get_backend ()->label_definition_statement (loop_begin_label); ctx->add_statement (loop_begin_label_decl); ctx->push_loop_begin_label (loop_begin_label); @@ -828,14 +828,13 @@ public: = CompileExpr::Compile (expr.get_predicate_expr ().get (), ctx); tree exit_expr = ctx->get_backend ()->exit_expression (condition, expr.get_locus ()); - Bstatement *break_stmt + tree break_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, exit_expr); ctx->add_statement (break_stmt); Bblock *code_block = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); - Bstatement *code_block_stmt - = ctx->get_backend ()->block_statement (code_block); + tree code_block_stmt = ctx->get_backend ()->block_statement (code_block); ctx->add_statement (code_block_stmt); ctx->pop_loop_begin_label (); @@ -843,7 +842,7 @@ public: tree loop_expr = ctx->get_backend ()->loop_expression (loop_block, expr.get_locus ()); - Bstatement *loop_stmt + tree loop_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, loop_expr); ctx->add_statement (loop_stmt); } @@ -860,7 +859,7 @@ public: tree result_reference = ctx->get_backend ()->var_expression ( loop_result_holder, expr.get_expr ()->get_locus ()); - Bstatement *assignment = ctx->get_backend ()->assignment_statement ( + tree assignment = ctx->get_backend ()->assignment_statement ( fnctx.fndecl, result_reference, compiled_expr, expr.get_locus ()); ctx->add_statement (assignment); } @@ -896,7 +895,7 @@ public: return; } - Bstatement *goto_label + tree goto_label = ctx->get_backend ()->goto_statement (label, expr.get_locus ()); ctx->add_statement (goto_label); } @@ -905,7 +904,7 @@ public: tree exit_expr = ctx->get_backend ()->exit_expression ( ctx->get_backend ()->boolean_constant_expression (true), expr.get_locus ()); - Bstatement *break_stmt + tree break_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, exit_expr); ctx->add_statement (break_stmt); } @@ -945,7 +944,7 @@ public: } } - Bstatement *goto_label + tree goto_label = ctx->get_backend ()->goto_statement (label, expr.get_locus ()); ctx->add_statement (goto_label); } diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 65f3d2c..fb3b381 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -278,7 +278,7 @@ public: tree return_type = TyTyResolveCompile::compile (ctx, tyret); bool address_is_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = NULL_TREE; return_address = ctx->get_backend ()->temporary_variable ( fndecl, code_block, return_type, NULL, address_is_taken, @@ -538,7 +538,7 @@ public: tree return_type = TyTyResolveCompile::compile (ctx, tyret); bool address_is_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = NULL_TREE; return_address = ctx->get_backend ()->temporary_variable ( fndecl, code_block, return_type, NULL, address_is_taken, diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 95de611..0e7737c 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -277,7 +277,7 @@ public: tree return_type = TyTyResolveCompile::compile (ctx, tyret); bool address_is_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = NULL_TREE; return_address = ctx->get_backend ()->temporary_variable ( fndecl, code_block, return_type, NULL, address_is_taken, diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 604d9a5..f3ee69d 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -118,7 +118,7 @@ public: auto fnctx = ctx->peek_fn (); if (ty->is_unit ()) { - Bstatement *expr_stmt + tree expr_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, init); ctx->add_statement (expr_stmt); } diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 3531930..8b74c77 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -349,7 +349,7 @@ CompileBlock::visit (HIR::BlockExpr &expr) auto compiled_expr = CompileStmt::Compile (s.get (), ctx); if (compiled_expr != nullptr) { - Bstatement *compiled_stmt + tree compiled_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, compiled_expr); ctx->add_statement (compiled_stmt); @@ -365,7 +365,7 @@ CompileBlock::visit (HIR::BlockExpr &expr) { if (result == nullptr) { - Bstatement *final_stmt + tree final_stmt = ctx->get_backend ()->expression_statement (fnctx.fndecl, compiled_expr); ctx->add_statement (final_stmt); @@ -375,7 +375,7 @@ CompileBlock::visit (HIR::BlockExpr &expr) tree result_reference = ctx->get_backend ()->var_expression ( result, expr.get_final_expr ()->get_locus ()); - Bstatement *assignment + tree assignment = ctx->get_backend ()->assignment_statement (fnctx.fndecl, result_reference, compiled_expr, @@ -438,7 +438,7 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqIf &expr) start_location, end_location); ctx->push_block (else_block); - Bstatement *else_stmt_decl + tree else_stmt_decl = CompileConditionalBlocks::compile (expr.get_conseq_if_expr (), ctx, result); ctx->add_statement (else_stmt_decl); @@ -486,7 +486,7 @@ HIRCompileBase::compile_function_body ( auto compiled_expr = CompileStmt::Compile (s.get (), ctx); if (compiled_expr != nullptr) { - Bstatement *compiled_stmt + tree compiled_stmt = ctx->get_backend ()->expression_statement (fndecl, compiled_expr); ctx->add_statement (compiled_stmt); } @@ -513,7 +513,7 @@ HIRCompileBase::compile_function_body ( } else { - Bstatement *final_stmt + tree final_stmt = ctx->get_backend ()->expression_statement (fndecl, compiled_expr); ctx->add_statement (final_stmt); @@ -612,7 +612,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, fncontext fnctx = ctx->peek_fn (); Bblock *enclosing_scope = ctx->peek_enclosing_scope (); bool is_address_taken = false; - Bstatement *ret_var_stmt = nullptr; + tree ret_var_stmt = NULL_TREE; Bvariable *dyn_tmp = ctx->get_backend ()->temporary_variable ( fnctx.fndecl, enclosing_scope, dynamic_object, constructed_trait_object, -- cgit v1.1 From 95048daaffa5e16df4d663702fe80294eac7b85e Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 09:49:38 -0800 Subject: Replace Bfunction with GCC tree --- gcc/rust/backend/rust-compile-base.h | 4 ++-- gcc/rust/backend/rust-compile-context.h | 23 +++++++++++------------ gcc/rust/backend/rust-compile-expr.cc | 2 +- gcc/rust/backend/rust-compile-expr.h | 2 +- gcc/rust/backend/rust-compile-extern.h | 8 ++++---- gcc/rust/backend/rust-compile-fnparam.h | 12 +++++------- gcc/rust/backend/rust-compile-implitem.h | 12 ++++++------ gcc/rust/backend/rust-compile-intrinsic.cc | 4 ++-- gcc/rust/backend/rust-compile-intrinsic.h | 2 +- gcc/rust/backend/rust-compile-item.h | 6 +++--- gcc/rust/backend/rust-compile-resolve-path.cc | 2 +- gcc/rust/backend/rust-compile-var-decl.h | 7 +++---- gcc/rust/backend/rust-compile.cc | 12 ++++++------ 13 files changed, 46 insertions(+), 50 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index 5650451..af0ea40 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -193,11 +193,11 @@ protected: Context *get_context () { return ctx; } - void compile_function_body (Bfunction *fndecl, + void compile_function_body (tree fndecl, std::unique_ptr &function_body, bool has_return_type); - bool compile_locals_for_block (Resolver::Rib &rib, Bfunction *fndecl, + bool compile_locals_for_block (Resolver::Rib &rib, tree fndecl, std::vector &locals); tree coercion_site (tree compiled_ref, TyTy::BaseType *actual, diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 1128fa8..4c8f722 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -35,7 +35,7 @@ namespace Compile { struct fncontext { - ::Bfunction *fndecl; + ::tree fndecl; ::Bvariable *ret_addr; }; @@ -161,7 +161,7 @@ public: return true; } - void insert_function_decl (const TyTy::FnType *ref, ::Bfunction *fn) + void insert_function_decl (const TyTy::FnType *ref, tree fn) { auto id = ref->get_ty_ref (); auto dId = ref->get_id (); @@ -176,8 +176,7 @@ public: mono_fns[dId].push_back ({ref, fn}); } - bool lookup_function_decl (HirId id, ::Bfunction **fn, - DefId dId = UNKNOWN_DEFID, + bool lookup_function_decl (HirId id, tree *fn, DefId dId = UNKNOWN_DEFID, const TyTy::BaseType *ref = nullptr) { // for for any monomorphized fns @@ -192,7 +191,7 @@ public: for (auto &e : mono_fns[dId]) { const TyTy::BaseType *r = e.first; - ::Bfunction *f = e.second; + tree f = e.second; if (ref->is_equal (*r)) { *fn = f; @@ -237,7 +236,7 @@ public: return true; } - void push_fn (::Bfunction *fn, ::Bvariable *ret_addr) + void push_fn (tree fn, ::Bvariable *ret_addr) { fn_stack.push_back (fncontext{fn, ret_addr}); } @@ -247,7 +246,7 @@ public: void push_type (::tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); } void push_const (::tree c) { const_decls.push_back (c); } - void push_function (::Bfunction *f) { func_decls.push_back (f); } + void push_function (tree f) { func_decls.push_back (f); } void write_to_backend () { @@ -255,11 +254,11 @@ public: var_decls); } - bool function_completed (Bfunction *fn) + bool function_completed (tree fn) { for (auto it = func_decls.begin (); it != func_decls.end (); it++) { - Bfunction *i = (*it); + tree i = (*it); if (i == fn) { return true; @@ -320,7 +319,7 @@ private: std::vector fn_stack; std::map compiled_var_decls; std::map compiled_type_map; - std::map compiled_fn_map; + std::map compiled_fn_map; std::map compiled_consts; std::map compiled_labels; std::vector<::std::vector> statements; @@ -328,14 +327,14 @@ private: std::vector<::Bvariable *> loop_value_stack; std::vector<::Blabel *> loop_begin_labels; std::map> mono; - std::map>> + std::map>> mono_fns; // To GCC middle-end std::vector type_decls; std::vector<::Bvariable *> var_decls; std::vector const_decls; - std::vector<::Bfunction *> func_decls; + std::vector func_decls; }; class TyTyResolveCompile : public TyTy::TyConstVisitor diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 8786702..8b1da22 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -209,7 +209,7 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, Location expr_locus) { // lookup compiled functions since it may have already been compiled - Bfunction *fn = nullptr; + tree fn = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn)) { return ctx->get_backend ()->function_code_expression (fn, expr_locus); diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 14d4345..f739273 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -204,7 +204,7 @@ public: gcc_unreachable (); } - Bfunction *fn = nullptr; + tree fn = NULL_TREE; Bvariable *var = nullptr; if (ctx->lookup_const_decl (ref, &translated)) { diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 2d3d251..aa73509 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -99,14 +99,14 @@ public: // items can be forward compiled which means we may not need to invoke this // code. We might also have already compiled this generic function as well. - Bfunction *lookup = nullptr; + tree lookup = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype->get_id (), fntype)) { // has this been added to the list then it must be finished if (ctx->function_completed (lookup)) { - Bfunction *dummy = nullptr; + tree dummy = NULL_TREE; if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &dummy)) ctx->insert_function_decl (fntype, lookup); @@ -123,7 +123,7 @@ public: if (fntype->get_abi () == ABI::INTRINSIC) { Intrinsics compile (ctx); - Bfunction *fndecl = compile.compile (fntype); + tree fndecl = compile.compile (fntype); ctx->insert_function_decl (fntype, fndecl); return; } @@ -139,7 +139,7 @@ public: std::string ir_symbol_name = function.get_item_name (); std::string asm_name = function.get_item_name (); - Bfunction *fndecl + tree fndecl = ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name, asm_name, flags, function.get_locus ()); ctx->insert_function_decl (fntype, fndecl); diff --git a/gcc/rust/backend/rust-compile-fnparam.h b/gcc/rust/backend/rust-compile-fnparam.h index 903f839..629f0f5 100644 --- a/gcc/rust/backend/rust-compile-fnparam.h +++ b/gcc/rust/backend/rust-compile-fnparam.h @@ -29,7 +29,7 @@ class CompileFnParam : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bvariable *compile (Context *ctx, Bfunction *fndecl, + static Bvariable *compile (Context *ctx, tree fndecl, HIR::FunctionParam *param, tree decl_type, Location locus) { @@ -51,13 +51,12 @@ public: } private: - CompileFnParam (Context *ctx, ::Bfunction *fndecl, tree decl_type, - Location locus) + CompileFnParam (Context *ctx, tree fndecl, tree decl_type, Location locus) : HIRCompileBase (ctx), fndecl (fndecl), decl_type (decl_type), locus (locus), translated (nullptr) {} - ::Bfunction *fndecl; + tree fndecl; tree decl_type; Location locus; ::Bvariable *translated; @@ -66,9 +65,8 @@ private: class CompileSelfParam : public HIRCompileBase { public: - static Bvariable *compile (Context *ctx, Bfunction *fndecl, - HIR::SelfParam &self, tree decl_type, - Location locus) + static Bvariable *compile (Context *ctx, tree fndecl, HIR::SelfParam &self, + tree decl_type, Location locus) { bool is_immutable = self.get_self_kind () == HIR::SelfParam::ImplicitSelfKind::IMM diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index fb3b381..23b10d6 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -110,14 +110,14 @@ public: // items can be forward compiled which means we may not need to invoke this // code. We might also have already compiled this generic function as well. - Bfunction *lookup = nullptr; + tree lookup = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype->get_id (), fntype)) { // has this been added to the list then it must be finished if (ctx->function_completed (lookup)) { - Bfunction *dummy = nullptr; + tree dummy = NULL_TREE; if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &dummy)) { ctx->insert_function_decl (fntype, lookup); @@ -156,7 +156,7 @@ public: std::string asm_name = ctx->mangle_impl_item (self, fntype, function.get_function_name ()); - Bfunction *fndecl + tree fndecl = ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name, asm_name, flags, function.get_locus ()); ctx->insert_function_decl (fntype, fndecl); @@ -377,14 +377,14 @@ public: // items can be forward compiled which means we may not need to invoke this // code. We might also have already compiled this generic function as well. - Bfunction *lookup = nullptr; + tree lookup = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype->get_id (), fntype)) { // has this been added to the list then it must be finished if (ctx->function_completed (lookup)) { - Bfunction *dummy = nullptr; + tree dummy = NULL_TREE; if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &dummy)) { ctx->insert_function_decl (fntype, lookup); @@ -417,7 +417,7 @@ public: std::string fn_identifier = canonical_path->get (); std::string asm_name = ctx->mangle_item (fntype, *canonical_path); - Bfunction *fndecl + tree fndecl = ctx->get_backend ()->function (compiled_fn_type, fn_identifier, asm_name, flags, func.get_locus ()); ctx->insert_function_decl (fntype, fndecl); diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index 66d36e3..69626a9 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -21,7 +21,7 @@ namespace Compile { Intrinsics::Intrinsics (Context *ctx) : ctx (ctx) {} -Bfunction * +tree Intrinsics::compile (TyTy::FnType *fntype) { rust_assert (fntype->get_abi () == ABI::INTRINSIC); @@ -77,7 +77,7 @@ Intrinsics::compile (TyTy::FnType *fntype) // }; // Some(cx.get_intrinsic(&llvm_name)) - Bfunction *builtin = ctx->get_backend ()->lookup_builtin_by_rust_name ( + tree builtin = ctx->get_backend ()->lookup_builtin_by_rust_name ( fntype->get_identifier ()); if (builtin != nullptr) return builtin; diff --git a/gcc/rust/backend/rust-compile-intrinsic.h b/gcc/rust/backend/rust-compile-intrinsic.h index 25e298a..2d44baa 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.h +++ b/gcc/rust/backend/rust-compile-intrinsic.h @@ -27,7 +27,7 @@ class Intrinsics public: Intrinsics (Context *ctx); - Bfunction *compile (TyTy::FnType *fntype); + tree compile (TyTy::FnType *fntype); private: Context *ctx; diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 0e7737c..94a313e 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -147,14 +147,14 @@ public: // items can be forward compiled which means we may not need to invoke this // code. We might also have already compiled this generic function as well. - Bfunction *lookup = nullptr; + tree lookup = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &lookup, fntype->get_id (), fntype)) { // has this been added to the list then it must be finished if (ctx->function_completed (lookup)) { - Bfunction *dummy = nullptr; + tree dummy = NULL_TREE; if (!ctx->lookup_function_decl (fntype->get_ty_ref (), &dummy)) { ctx->insert_function_decl (fntype, lookup); @@ -201,7 +201,7 @@ public: asm_name = ctx->mangle_item (fntype, *canonical_path); } - Bfunction *fndecl + tree fndecl = ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name, asm_name, flags, function.get_locus ()); ctx->insert_function_decl (fntype, fndecl); diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 81ffad8..cb3f0df 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -92,7 +92,7 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, if (lookup->get_kind () == TyTy::TypeKind::FNDEF) { TyTy::FnType *fntype = static_cast (lookup); - Bfunction *fn = nullptr; + tree fn = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn)) { return ctx->get_backend ()->function_code_expression (fn, expr_locus); diff --git a/gcc/rust/backend/rust-compile-var-decl.h b/gcc/rust/backend/rust-compile-var-decl.h index deabd7d..a964fa2 100644 --- a/gcc/rust/backend/rust-compile-var-decl.h +++ b/gcc/rust/backend/rust-compile-var-decl.h @@ -29,8 +29,7 @@ class CompileVarDecl : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static ::Bvariable *compile (::Bfunction *fndecl, HIR::Stmt *stmt, - Context *ctx) + static ::Bvariable *compile (tree fndecl, HIR::Stmt *stmt, Context *ctx) { CompileVarDecl compiler (ctx, fndecl); stmt->accept_vis (compiler); @@ -64,12 +63,12 @@ public: } private: - CompileVarDecl (Context *ctx, ::Bfunction *fndecl) + CompileVarDecl (Context *ctx, tree fndecl) : HIRCompileBase (ctx), fndecl (fndecl), translated_type (nullptr), translated (nullptr) {} - ::Bfunction *fndecl; + tree fndecl; tree translated_type; Location locus; ::Bvariable *translated; diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 8b74c77..71435f3 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -322,7 +322,7 @@ void CompileBlock::visit (HIR::BlockExpr &expr) { fncontext fnctx = ctx->peek_fn (); - Bfunction *fndecl = fnctx.fndecl; + tree fndecl = fnctx.fndecl; Location start_location = expr.get_locus (); Location end_location = expr.get_closing_locus (); auto body_mappings = expr.get_mappings (); @@ -393,7 +393,7 @@ void CompileConditionalBlocks::visit (HIR::IfExpr &expr) { fncontext fnctx = ctx->peek_fn (); - Bfunction *fndecl = fnctx.fndecl; + tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); Bblock *then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); @@ -407,7 +407,7 @@ void CompileConditionalBlocks::visit (HIR::IfExprConseqElse &expr) { fncontext fnctx = ctx->peek_fn (); - Bfunction *fndecl = fnctx.fndecl; + tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); Bblock *then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); @@ -423,7 +423,7 @@ void CompileConditionalBlocks::visit (HIR::IfExprConseqIf &expr) { fncontext fnctx = ctx->peek_fn (); - Bfunction *fndecl = fnctx.fndecl; + tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); Bblock *then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); @@ -478,7 +478,7 @@ CompileStructExprField::visit (HIR::StructExprFieldIdentifier &field) void HIRCompileBase::compile_function_body ( - Bfunction *fndecl, std::unique_ptr &function_body, + tree fndecl, std::unique_ptr &function_body, bool has_return_type) { for (auto &s : function_body->get_statements ()) @@ -523,7 +523,7 @@ HIRCompileBase::compile_function_body ( } bool -HIRCompileBase::compile_locals_for_block (Resolver::Rib &rib, Bfunction *fndecl, +HIRCompileBase::compile_locals_for_block (Resolver::Rib &rib, tree fndecl, std::vector &locals) { rib.iterate_decls ([&] (NodeId n, Location) mutable -> bool { -- cgit v1.1 From a4e5aee5863c7d898ee640296bc837e0baa8e796 Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 10:12:20 -0800 Subject: Replace Bblock with GCC tree --- gcc/rust/backend/rust-compile-block.h | 4 ++-- gcc/rust/backend/rust-compile-context.h | 8 ++++---- gcc/rust/backend/rust-compile-expr.cc | 2 +- gcc/rust/backend/rust-compile-expr.h | 16 ++++++++-------- gcc/rust/backend/rust-compile-implitem.h | 8 ++++---- gcc/rust/backend/rust-compile-item.h | 4 ++-- gcc/rust/backend/rust-compile.cc | 28 +++++++++++----------------- 7 files changed, 32 insertions(+), 38 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-block.h b/gcc/rust/backend/rust-compile-block.h index 0e631e1..af90671 100644 --- a/gcc/rust/backend/rust-compile-block.h +++ b/gcc/rust/backend/rust-compile-block.h @@ -30,7 +30,7 @@ class CompileBlock : public HIRCompileBase using Rust::Compile::HIRCompileBase::visit; public: - static Bblock *compile (HIR::BlockExpr *expr, Context *ctx, Bvariable *result) + static tree compile (HIR::BlockExpr *expr, Context *ctx, Bvariable *result) { CompileBlock compiler (ctx, result); expr->accept_vis (compiler); @@ -44,7 +44,7 @@ private: : HIRCompileBase (ctx), translated (nullptr), result (result) {} - Bblock *translated; + tree translated; Bvariable *result; }; diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 4c8f722..1fe67d2 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -112,13 +112,13 @@ public: Analysis::Mappings *get_mappings () { return mappings; } ConstFold::Context *get_const_ctx () { return const_ctx; } - void push_block (Bblock *scope) + void push_block (tree scope) { scope_stack.push_back (scope); statements.push_back ({}); } - Bblock *pop_block () + tree pop_block () { auto block = scope_stack.back (); scope_stack.pop_back (); @@ -131,7 +131,7 @@ public: return block; } - Bblock *peek_enclosing_scope () + tree peek_enclosing_scope () { if (scope_stack.size () == 0) return nullptr; @@ -323,7 +323,7 @@ private: std::map compiled_consts; std::map compiled_labels; std::vector<::std::vector> statements; - std::vector<::Bblock *> scope_stack; + std::vector scope_stack; std::vector<::Bvariable *> loop_value_stack; std::vector<::Blabel *> loop_begin_labels; std::map> mono; diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 8b1da22..fb01d8d 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -176,7 +176,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, fn_vtable_access, expr_locus); fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); bool is_address_taken = false; tree ret_var_stmt = NULL_TREE; Bvariable *fn_convert_expr_tmp diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index f739273..52cc58a 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -514,7 +514,7 @@ public: if (needs_temp) { fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; @@ -551,7 +551,7 @@ public: if (needs_temp) { fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, if_type); bool is_address_taken = false; @@ -587,7 +587,7 @@ public: if (needs_temp) { fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; @@ -740,7 +740,7 @@ public: bool needs_temp = !block_tyty->is_unit (); if (needs_temp) { - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); tree block_type = TyTyResolveCompile::compile (ctx, block_tyty); bool is_address_taken = false; @@ -773,7 +773,7 @@ public: ctx->add_statement (loop_begin_label_decl); ctx->push_loop_begin_label (loop_begin_label); - Bblock *code_block + tree code_block = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); tree loop_expr = ctx->get_backend ()->loop_expression (code_block, expr.get_locus ()); @@ -811,8 +811,8 @@ public: Location start_location = expr.get_loop_block ()->get_locus (); Location end_location = expr.get_loop_block ()->get_locus (); // FIXME - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Bblock *loop_block + tree enclosing_scope = ctx->peek_enclosing_scope (); + tree loop_block = ctx->get_backend ()->block (fnctx.fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (loop_block); @@ -832,7 +832,7 @@ public: = ctx->get_backend ()->expression_statement (fnctx.fndecl, exit_expr); ctx->add_statement (break_stmt); - Bblock *code_block + tree code_block = CompileBlock::compile (expr.get_loop_block ().get (), ctx, nullptr); tree code_block_stmt = ctx->get_backend ()->block_statement (code_block); ctx->add_statement (code_block_stmt); diff --git a/gcc/rust/backend/rust-compile-implitem.h b/gcc/rust/backend/rust-compile-implitem.h index 23b10d6..7b41226 100644 --- a/gcc/rust/backend/rust-compile-implitem.h +++ b/gcc/rust/backend/rust-compile-implitem.h @@ -262,12 +262,12 @@ public: ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = NULL; + tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body = function.get_definition ().get (); Location start_location = function_body->get_locus (); Location end_location = function_body->get_closing_locus (); - Bblock *code_block + tree code_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (code_block); @@ -522,12 +522,12 @@ public: ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = NULL; + tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body = func.get_block_expr ().get (); Location start_location = function_body->get_locus (); Location end_location = function_body->get_closing_locus (); - Bblock *code_block + tree code_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (code_block); diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index 94a313e..5af9ab3 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -261,12 +261,12 @@ public: ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = NULL; + tree enclosing_scope = NULL_TREE; HIR::BlockExpr *function_body = function.get_definition ().get (); Location start_location = function_body->get_locus (); Location end_location = function_body->get_closing_locus (); - Bblock *code_block + tree code_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, start_location, end_location); ctx->push_block (code_block); diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 71435f3..579b323 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -338,10 +338,9 @@ CompileBlock::visit (HIR::BlockExpr &expr) bool ok = compile_locals_for_block (*rib, fndecl, locals); rust_assert (ok); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Bblock *new_block - = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, - start_location, end_location); + tree enclosing_scope = ctx->peek_enclosing_scope (); + tree new_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, + start_location, end_location); ctx->push_block (new_block); for (auto &s : expr.get_statements ()) @@ -395,8 +394,7 @@ CompileConditionalBlocks::visit (HIR::IfExpr &expr) fncontext fnctx = ctx->peek_fn (); tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); - Bblock *then_block - = CompileBlock::compile (expr.get_if_block (), ctx, result); + tree then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); translated = ctx->get_backend ()->if_statement (fndecl, condition_expr, then_block, @@ -409,10 +407,8 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqElse &expr) fncontext fnctx = ctx->peek_fn (); tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); - Bblock *then_block - = CompileBlock::compile (expr.get_if_block (), ctx, result); - Bblock *else_block - = CompileBlock::compile (expr.get_else_block (), ctx, result); + tree then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); + tree else_block = CompileBlock::compile (expr.get_else_block (), ctx, result); translated = ctx->get_backend ()->if_statement (fndecl, condition_expr, then_block, @@ -425,17 +421,15 @@ CompileConditionalBlocks::visit (HIR::IfExprConseqIf &expr) fncontext fnctx = ctx->peek_fn (); tree fndecl = fnctx.fndecl; tree condition_expr = CompileExpr::Compile (expr.get_if_condition (), ctx); - Bblock *then_block - = CompileBlock::compile (expr.get_if_block (), ctx, result); + tree then_block = CompileBlock::compile (expr.get_if_block (), ctx, result); // else block std::vector locals; Location start_location = expr.get_conseq_if_expr ()->get_locus (); Location end_location = expr.get_conseq_if_expr ()->get_locus (); // FIXME - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); - Bblock *else_block - = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, - start_location, end_location); + tree enclosing_scope = ctx->peek_enclosing_scope (); + tree else_block = ctx->get_backend ()->block (fndecl, enclosing_scope, locals, + start_location, end_location); ctx->push_block (else_block); tree else_stmt_decl @@ -610,7 +604,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, locus); fncontext fnctx = ctx->peek_fn (); - Bblock *enclosing_scope = ctx->peek_enclosing_scope (); + tree enclosing_scope = ctx->peek_enclosing_scope (); bool is_address_taken = false; tree ret_var_stmt = NULL_TREE; -- cgit v1.1 From 01a52df9440a78ec5221c7f2430f06e770133e06 Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 10:21:04 -0800 Subject: Replace Blabel with GCC tree --- gcc/rust/backend/rust-compile-context.h | 19 ++++++++----------- gcc/rust/backend/rust-compile-expr.h | 12 ++++++------ 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 1fe67d2..72ab4f2 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -221,12 +221,9 @@ public: return true; } - void insert_label_decl (HirId id, ::Blabel *label) - { - compiled_labels[id] = label; - } + void insert_label_decl (HirId id, tree label) { compiled_labels[id] = label; } - bool lookup_label_decl (HirId id, ::Blabel **label) + bool lookup_label_decl (HirId id, tree *label) { auto it = compiled_labels.find (id); if (it == compiled_labels.end ()) @@ -278,16 +275,16 @@ public: return back; } - void push_loop_begin_label (Blabel *label) + void push_loop_begin_label (tree label) { loop_begin_labels.push_back (label); } - Blabel *peek_loop_begin_label () { return loop_begin_labels.back (); } + tree peek_loop_begin_label () { return loop_begin_labels.back (); } - Blabel *pop_loop_begin_label () + tree pop_loop_begin_label () { - Blabel *pop = loop_begin_labels.back (); + tree pop = loop_begin_labels.back (); loop_begin_labels.pop_back (); return pop; } @@ -321,11 +318,11 @@ private: std::map compiled_type_map; std::map compiled_fn_map; std::map compiled_consts; - std::map compiled_labels; + std::map compiled_labels; std::vector<::std::vector> statements; std::vector scope_stack; std::vector<::Bvariable *> loop_value_stack; - std::vector<::Blabel *> loop_begin_labels; + std::vector loop_begin_labels; std::map> mono; std::map>> mono_fns; diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 52cc58a..2bf969b 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -755,7 +755,7 @@ public: if (expr.has_loop_label ()) { HIR::LoopLabel &loop_label = expr.get_loop_label (); - Blabel *label + tree label = ctx->get_backend ()->label (fnctx.fndecl, loop_label.get_lifetime ().get_name (), loop_label.get_locus ()); @@ -766,7 +766,7 @@ public: loop_label.get_lifetime ().get_mappings ().get_hirid (), label); } - Blabel *loop_begin_label + tree loop_begin_label = ctx->get_backend ()->label (fnctx.fndecl, "", expr.get_locus ()); tree loop_begin_label_decl = ctx->get_backend ()->label_definition_statement (loop_begin_label); @@ -796,7 +796,7 @@ public: if (expr.has_loop_label ()) { HIR::LoopLabel &loop_label = expr.get_loop_label (); - Blabel *label + tree label = ctx->get_backend ()->label (fnctx.fndecl, loop_label.get_lifetime ().get_name (), loop_label.get_locus ()); @@ -817,7 +817,7 @@ public: start_location, end_location); ctx->push_block (loop_block); - Blabel *loop_begin_label + tree loop_begin_label = ctx->get_backend ()->label (fnctx.fndecl, "", expr.get_locus ()); tree loop_begin_label_decl = ctx->get_backend ()->label_definition_statement (loop_begin_label); @@ -887,7 +887,7 @@ public: return; } - Blabel *label = nullptr; + tree label = NULL_TREE; if (!ctx->lookup_label_decl (ref, &label)) { rust_error_at (expr.get_label ().get_locus (), @@ -912,7 +912,7 @@ public: void visit (HIR::ContinueExpr &expr) override { - Blabel *label = ctx->peek_loop_begin_label (); + tree label = ctx->peek_loop_begin_label (); if (expr.has_label ()) { NodeId resolved_node_id = UNKNOWN_NODEID; -- cgit v1.1 From 5c87e61f96e0b394ce406bf9967c92708a16becc Mon Sep 17 00:00:00 2001 From: David Faust Date: Mon, 15 Nov 2021 10:27:34 -0800 Subject: clang-format and minor cleanup --- gcc/rust/backend/rust-compile-context.h | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 72ab4f2..668e8ba 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -35,7 +35,7 @@ namespace Compile { struct fncontext { - ::tree fndecl; + tree fndecl; ::Bvariable *ret_addr; }; @@ -61,19 +61,19 @@ public: rust_assert (ok); tree compiled = TyTyCompile::compile (backend, lookup); - compiled_type_map.insert (std::pair (ref, compiled)); + compiled_type_map.insert (std::pair (ref, compiled)); builtin_range.insert (ref); } } - bool lookup_compiled_types (HirId id, ::tree *type, + bool lookup_compiled_types (HirId id, tree *type, const TyTy::BaseType *ref = nullptr) { if (ref != nullptr) { for (auto it = mono.begin (); it != mono.end (); it++) { - std::pair &val = it->second; + std::pair &val = it->second; const TyTy::BaseType *r = it->first; if (ref->is_equal (*r)) @@ -94,14 +94,14 @@ public: return true; } - void insert_compiled_type (HirId id, ::tree type, + void insert_compiled_type (HirId id, tree type, const TyTy::BaseType *ref = nullptr) { rust_assert (builtin_range.find (id) == builtin_range.end ()); - compiled_type_map.insert (std::pair (id, type)); + compiled_type_map.insert (std::pair (id, type)); if (ref != nullptr) { - std::pair elem (id, type); + std::pair elem (id, type); mono[ref] = std::move (elem); } } @@ -209,9 +209,9 @@ public: return true; } - void insert_const_decl (HirId id, ::tree expr) { compiled_consts[id] = expr; } + void insert_const_decl (HirId id, tree expr) { compiled_consts[id] = expr; } - bool lookup_const_decl (HirId id, ::tree *expr) + bool lookup_const_decl (HirId id, tree *expr) { auto it = compiled_consts.find (id); if (it == compiled_consts.end ()) @@ -240,9 +240,9 @@ public: void pop_fn () { fn_stack.pop_back (); } fncontext peek_fn () { return fn_stack.back (); } - void push_type (::tree t) { type_decls.push_back (t); } + void push_type (tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); } - void push_const (::tree c) { const_decls.push_back (c); } + void push_const (tree c) { const_decls.push_back (c); } void push_function (tree f) { func_decls.push_back (f); } void write_to_backend () @@ -323,7 +323,7 @@ private: std::vector scope_stack; std::vector<::Bvariable *> loop_value_stack; std::vector loop_begin_labels; - std::map> mono; + std::map> mono; std::map>> mono_fns; @@ -338,7 +338,7 @@ class TyTyResolveCompile : public TyTy::TyConstVisitor { public: static tree compile (Context *ctx, const TyTy::BaseType *ty, - bool trait_object_mode = false) + bool trait_object_mode = false) { TyTyResolveCompile compiler (ctx, trait_object_mode); ty->accept_vis (compiler); @@ -410,7 +410,7 @@ public: tree result_type = TyTyResolveCompile::compile (ctx, type.get_return_type ()); - std::vector parameters; + std::vector parameters; type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool { tree pty = TyTyResolveCompile::compile (ctx, p); parameters.push_back (pty); @@ -440,8 +440,8 @@ public: = TyTyResolveCompile::compile (ctx, field->get_field_type ()); Backend::typed_identifier f (field->get_name (), compiled_field_ty, - ctx->get_mappings ()->lookup_location ( - type.get_ty_ref ())); + ctx->get_mappings ()->lookup_location ( + type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -488,9 +488,9 @@ public: // approach makes it simpler to use a C-only debugger, or // GDB's C mode, when debugging Rust. Backend::typed_identifier f ("__" + std::to_string (i), - compiled_field_ty, - ctx->get_mappings ()->lookup_location ( - type.get_ty_ref ())); + compiled_field_ty, + ctx->get_mappings ()->lookup_location ( + type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -515,7 +515,7 @@ public: void visit (const TyTy::BoolType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -523,7 +523,7 @@ public: void visit (const TyTy::IntType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -531,7 +531,7 @@ public: void visit (const TyTy::UintType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -539,7 +539,7 @@ public: void visit (const TyTy::FloatType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -547,7 +547,7 @@ public: void visit (const TyTy::USizeType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -555,7 +555,7 @@ public: void visit (const TyTy::ISizeType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -563,7 +563,7 @@ public: void visit (const TyTy::CharType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -601,7 +601,7 @@ public: void visit (const TyTy::StrType &type) override { - ::tree compiled_type = nullptr; + tree compiled_type = nullptr; bool ok = ctx->lookup_compiled_types (type.get_ty_ref (), &compiled_type); rust_assert (ok); translated = compiled_type; @@ -633,8 +633,8 @@ public: tree uintptr_ty = ctx->get_backend ()->pointer_type (uint); Backend::typed_identifier f ("__receiver_trait_obj_ptr", uintptr_ty, - ctx->get_mappings ()->lookup_location ( - type.get_ty_ref ())); + ctx->get_mappings ()->lookup_location ( + type.get_ty_ref ())); fields.push_back (std::move (f)); for (size_t i = 0; i < items.size (); i++) @@ -645,8 +645,8 @@ public: tree uintptr_ty = ctx->get_backend ()->pointer_type (uint); Backend::typed_identifier f ("__" + std::to_string (i), uintptr_ty, - ctx->get_mappings ()->lookup_location ( - type.get_ty_ref ())); + ctx->get_mappings ()->lookup_location ( + type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -672,7 +672,7 @@ private: Context *ctx; bool trait_object_mode; - ::tree translated; + tree translated; size_t recursion_count; static const size_t kDefaultRecusionLimit = 5; -- cgit v1.1