diff options
author | David Faust <david.faust@oracle.com> | 2021-11-15 09:49:38 -0800 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2021-11-16 13:12:53 -0800 |
commit | 95048daaffa5e16df4d663702fe80294eac7b85e (patch) | |
tree | b56f8e72ac7161b460b8e8455d1c957330680790 /gcc/rust/backend | |
parent | 553e88f1dd4b4794334ee6d1861c185b92361a0b (diff) | |
download | gcc-95048daaffa5e16df4d663702fe80294eac7b85e.zip gcc-95048daaffa5e16df4d663702fe80294eac7b85e.tar.gz gcc-95048daaffa5e16df4d663702fe80294eac7b85e.tar.bz2 |
Replace Bfunction with GCC tree
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.h | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 23 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-extern.h | 8 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-fnparam.h | 12 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.h | 12 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-intrinsic.cc | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-intrinsic.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 6 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-var-decl.h | 7 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 12 |
13 files changed, 46 insertions, 50 deletions
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<HIR::BlockExpr> &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<Bvariable *> &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<fncontext> fn_stack; std::map<HirId, ::Bvariable *> compiled_var_decls; std::map<HirId, tree> compiled_type_map; - std::map<HirId, ::Bfunction *> compiled_fn_map; + std::map<HirId, tree> compiled_fn_map; std::map<HirId, tree> compiled_consts; std::map<HirId, ::Blabel *> compiled_labels; std::vector<::std::vector<tree>> statements; @@ -328,14 +327,14 @@ private: std::vector<::Bvariable *> loop_value_stack; std::vector<::Blabel *> loop_begin_labels; std::map<const TyTy::BaseType *, std::pair<HirId, ::tree >> mono; - std::map<DefId, std::vector<std::pair<const TyTy::BaseType *, ::Bfunction *>>> + std::map<DefId, std::vector<std::pair<const TyTy::BaseType *, tree>>> mono_fns; // To GCC middle-end std::vector<tree> type_decls; std::vector<::Bvariable *> var_decls; std::vector<tree> const_decls; - std::vector<::Bfunction *> func_decls; + std::vector<tree> 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<TyTy::FnType *> (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<HIR::BlockExpr> &function_body, + tree fndecl, std::unique_ptr<HIR::BlockExpr> &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<Bvariable *> &locals) { rib.iterate_decls ([&] (NodeId n, Location) mutable -> bool { |