public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Replace Bfunction with GCC tree
@ 2022-06-08 11:51 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:51 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:95048daaffa5e16df4d663702fe80294eac7b85e

commit 95048daaffa5e16df4d663702fe80294eac7b85e
Author: David Faust <david.faust@oracle.com>
Date:   Mon Nov 15 09:49:38 2021 -0800

    Replace Bfunction with GCC tree

Diff:
---
 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 +-
 gcc/rust/rust-backend.h                       |  65 ++++-----
 gcc/rust/rust-gcc.cc                          | 189 +++++++++++---------------
 15 files changed, 156 insertions(+), 194 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h
index 56504515b5c..af0ea408ccd 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 1128fa82cae..4c8f7223bc9 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 8786702498a..8b1da22efcf 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 14d43450b42..f7392739e55 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 2d3d251bb30..aa73509f634 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 903f8395cb6..629f0f5a873 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 fb3b381144e..23b10d61de5 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 66d36e32ecb..69626a930e9 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 25e298aa57b..2d44baa037c 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 0e7737c27f4..94a313e1aa8 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 81ffad8d147..cb3f0df8db0 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 deabd7df343..a964fa2206b 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 8b74c779f45..71435f37e88 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 {
diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h
index 22e2b6b2a2a..836f5190e8b 100644
--- a/gcc/rust/rust-backend.h
+++ b/gcc/rust/rust-backend.h
@@ -41,9 +41,6 @@ saw_errors (void);
 // frontend, and passed back to the backend.  The types must be
 // defined by the backend using these names.
 
-// The backend representation of a function definition or declaration.
-class Bfunction;
-
 // The backend representation of a block.
 class Bblock;
 
@@ -81,7 +78,6 @@ public:
 
   // debug
   virtual void debug (tree) = 0;
-  virtual void debug (Bfunction *) = 0;
   virtual void debug (Bblock *) = 0;
   virtual void debug (Bvariable *) = 0;
   virtual void debug (Blabel *) = 0;
@@ -314,7 +310,7 @@ public:
 
   // Create an expression for the address of a function.  This is used to
   // get the address of the code for a function.
-  virtual tree function_code_expression (Bfunction *, Location) = 0;
+  virtual tree function_code_expression (tree, Location) = 0;
 
   // Create an expression that takes the address of an expression.
   virtual tree address_expression (tree, Location) = 0;
@@ -329,7 +325,7 @@ public:
   // Return an expression that executes THEN_EXPR if CONDITION is true, or
   // ELSE_EXPR otherwise and returns the result as type BTYPE, within the
   // specified function FUNCTION.  ELSE_EXPR may be NULL.  BTYPE may be NULL.
-  virtual tree conditional_expression (Bfunction *function, tree btype,
+  virtual tree conditional_expression (tree function, tree btype,
 				       tree condition, tree then_expr,
 				       tree else_expr, Location)
     = 0;
@@ -385,7 +381,7 @@ public:
 
   // Create an expression for a call to FN with ARGS, taking place within
   // caller CALLER.
-  virtual tree call_expression (Bfunction *caller, tree fn,
+  virtual tree call_expression (tree caller, tree fn,
 				const std::vector<tree> &args,
 				tree static_chain, Location)
     = 0;
@@ -398,25 +394,22 @@ public:
   virtual tree error_statement () = 0;
 
   // Create an expression statement within the specified function.
-  virtual tree expression_statement (Bfunction *, tree) = 0;
+  virtual tree expression_statement (tree, tree) = 0;
 
   // Create a variable initialization statement in the specified
   // function.  This initializes a local variable at the point in the
   // program flow where it is declared.
-  virtual tree init_statement (Bfunction *, Bvariable *var, tree init) = 0;
+  virtual tree init_statement (tree, Bvariable *var, tree init) = 0;
 
   // Create an assignment statement within the specified function.
-  virtual tree assignment_statement (Bfunction *, tree lhs, tree rhs, Location)
-    = 0;
+  virtual tree assignment_statement (tree, tree lhs, tree rhs, Location) = 0;
 
   // Create a return statement, passing the representation of the
   // function and the list of values to return.
-  virtual tree return_statement (Bfunction *, const std::vector<tree> &,
-				 Location)
-    = 0;
+  virtual tree return_statement (tree, const std::vector<tree> &, Location) = 0;
 
   // Create an if statement within a function.  ELSE_BLOCK may be NULL.
-  virtual tree if_statement (Bfunction *, tree condition, Bblock *then_block,
+  virtual tree if_statement (tree, tree condition, Bblock *then_block,
 			     Bblock *else_block, Location)
     = 0;
 
@@ -433,7 +426,7 @@ public:
   // either end with a goto statement or will fall through into
   // STATEMENTS[i + 1].  CASES[i] is empty for the default clause,
   // which need not be last.  FUNCTION is the current function.
-  virtual tree switch_statement (Bfunction *function, tree value,
+  virtual tree switch_statement (tree function, tree value,
 				 const std::vector<std::vector<tree> > &cases,
 				 const std::vector<tree> &statements, Location)
     = 0;
@@ -465,7 +458,7 @@ public:
   // the initial curly brace.  END_LOCATION is the location of the end
   // of the block, more or less the location of the final curly brace.
   // The statements will be added after the block is created.
-  virtual Bblock *block (Bfunction *function, Bblock *enclosing,
+  virtual Bblock *block (tree function, Bblock *enclosing,
 			 const std::vector<Bvariable *> &vars,
 			 Location start_location, Location end_location)
     = 0;
@@ -523,21 +516,21 @@ public:
   // the function, as otherwise the variable would be on the heap).
   // LOCATION is where the variable is defined.  For each local variable
   // the frontend will call init_statement to set the initial value.
-  virtual Bvariable *
-  local_variable (Bfunction *function, const std::string &name, tree type,
-		  Bvariable *decl_var, bool is_address_taken, Location location)
+  virtual Bvariable *local_variable (tree function, const std::string &name,
+				     tree type, Bvariable *decl_var,
+				     bool is_address_taken, Location location)
     = 0;
 
   // Create a function parameter.  This is an incoming parameter, not
   // a result parameter (result parameters are treated as local
   // variables).  The arguments are as for local_variable.
-  virtual Bvariable *
-  parameter_variable (Bfunction *function, const std::string &name, tree type,
-		      bool is_address_taken, Location location)
+  virtual Bvariable *parameter_variable (tree function, const std::string &name,
+					 tree type, bool is_address_taken,
+					 Location location)
     = 0;
 
   // Create a static chain parameter.  This is the closure parameter.
-  virtual Bvariable *static_chain_variable (Bfunction *function,
+  virtual Bvariable *static_chain_variable (tree function,
 					    const std::string &name, tree type,
 					    Location location)
     = 0;
@@ -553,7 +546,7 @@ public:
   // variable, and may not be very useful.  This function should
   // return a variable which can be referenced later and should set
   // *PSTATEMENT to a statement which initializes the variable.
-  virtual Bvariable *temporary_variable (Bfunction *, Bblock *, tree, tree init,
+  virtual Bvariable *temporary_variable (tree, Bblock *, tree, tree init,
 					 bool address_is_taken,
 					 Location location, tree *pstatement)
     = 0;
@@ -676,7 +669,7 @@ public:
   // Create a new label.  NAME will be empty if this is a label
   // created by the frontend for a loop construct.  The location is
   // where the label is defined.
-  virtual Blabel *label (Bfunction *, const std::string &name, Location) = 0;
+  virtual Blabel *label (tree, const std::string &name, Location) = 0;
 
   // Create a statement which defines a label.  This statement will be
   // put into the codestream at the point where the label should be
@@ -696,7 +689,7 @@ public:
   // Create an error function.  This is used for cases which should
   // not occur in a correct program, in order to keep the compilation
   // going without crashing.
-  virtual Bfunction *error_function () = 0;
+  virtual tree error_function () = 0;
 
   // Bit flags to pass to the function method.
 
@@ -735,9 +728,9 @@ public:
   // string, is the name that should be used in the symbol table; this
   // will be non-empty if a magic extern comment is used.  FLAGS is
   // bit flags described above.
-  virtual Bfunction *function (tree fntype, const std::string &name,
-			       const std::string &asm_name, unsigned int flags,
-			       Location)
+  virtual tree function (tree fntype, const std::string &name,
+			 const std::string &asm_name, unsigned int flags,
+			 Location)
     = 0;
 
   virtual tree specify_abi_attribute (tree type, Rust::ABI abi) = 0;
@@ -746,7 +739,7 @@ public:
   // be a statement that looks like this in C++:
   //   finish:
   //     try { DEFER_RETURN; } catch { CHECK_DEFER; goto finish; }
-  virtual tree function_defer_statement (Bfunction *function, tree undefer,
+  virtual tree function_defer_statement (tree function, tree undefer,
 					 tree check_defer, Location)
     = 0;
 
@@ -754,19 +747,19 @@ public:
   // This will only be called for a function definition.  Returns true on
   // success, false on failure.
   virtual bool
-  function_set_parameters (Bfunction *function,
+  function_set_parameters (tree function,
 			   const std::vector<Bvariable *> &param_vars)
     = 0;
 
   // Set the function body for FUNCTION using the code in CODE_STMT.  Returns
   // true on success, false on failure.
-  virtual bool function_set_body (Bfunction *function, tree code_stmt) = 0;
+  virtual bool function_set_body (tree function, tree code_stmt) = 0;
 
   // Look up a named built-in function in the current backend implementation.
   // Returns NULL if no built-in function by that name exists.
-  virtual Bfunction *lookup_gcc_builtin (const std::string &) = 0;
+  virtual tree lookup_gcc_builtin (const std::string &) = 0;
 
-  virtual Bfunction *lookup_builtin_by_rust_name (const std::string &) = 0;
+  virtual tree lookup_builtin_by_rust_name (const std::string &) = 0;
 
   // Utility.
 
@@ -775,7 +768,7 @@ public:
   virtual void
   write_global_definitions (const std::vector<tree> &type_decls,
 			    const std::vector<tree> &constant_decls,
-			    const std::vector<Bfunction *> &function_decls,
+			    const std::vector<tree> &function_decls,
 			    const std::vector<Bvariable *> &variable_decls)
     = 0;
 
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 873e664f6b5..730835325db 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -70,12 +70,6 @@ private:
 
 // In gcc, types, expressions, and statements are all trees.
 
-class Bfunction : public Gcc_tree
-{
-public:
-  Bfunction (tree t) : Gcc_tree (t) {}
-};
-
 class Bblock : public Gcc_tree
 {
 public:
@@ -143,7 +137,6 @@ public:
   Gcc_backend ();
 
   void debug (tree t) { debug_tree (t); };
-  void debug (Bfunction *t) { debug_tree (t->get_tree ()); };
   void debug (Bblock *t) { debug_tree (t->get_tree ()); };
   void debug (Bvariable *t) { debug_tree (t->get_decl ()); };
   void debug (Blabel *t) { debug_tree (t->get_tree ()); };
@@ -305,7 +298,7 @@ public:
 
   tree convert_expression (tree type, tree expr, Location);
 
-  tree function_code_expression (Bfunction *, Location);
+  tree function_code_expression (tree, Location);
 
   tree address_expression (tree, Location);
 
@@ -313,7 +306,7 @@ public:
 
   tree compound_expression (tree, tree, Location);
 
-  tree conditional_expression (Bfunction *, tree, tree, tree, tree, Location);
+  tree conditional_expression (tree, tree, tree, tree, tree, Location);
 
   tree negation_expression (NegationOperator op, tree expr, Location);
 
@@ -335,26 +328,25 @@ public:
 
   tree array_index_expression (tree array, tree index, Location);
 
-  tree call_expression (Bfunction *caller, tree fn,
-			const std::vector<tree> &args, tree static_chain,
-			Location);
+  tree call_expression (tree caller, tree fn, const std::vector<tree> &args,
+			tree static_chain, Location);
 
   // Statements.
 
   tree error_statement () { return error_mark_node; }
 
-  tree expression_statement (Bfunction *, tree);
+  tree expression_statement (tree, tree);
 
-  tree init_statement (Bfunction *, Bvariable *var, tree init);
+  tree init_statement (tree, Bvariable *var, tree init);
 
-  tree assignment_statement (Bfunction *, tree lhs, tree rhs, Location);
+  tree assignment_statement (tree, tree lhs, tree rhs, Location);
 
-  tree return_statement (Bfunction *, const std::vector<tree> &, Location);
+  tree return_statement (tree, const std::vector<tree> &, Location);
 
-  tree if_statement (Bfunction *, tree condition, Bblock *then_block,
+  tree if_statement (tree, tree condition, Bblock *then_block,
 		     Bblock *else_block, Location);
 
-  tree switch_statement (Bfunction *function, tree value,
+  tree switch_statement (tree function, tree value,
 			 const std::vector<std::vector<tree>> &cases,
 			 const std::vector<tree> &statements, Location);
 
@@ -371,8 +363,8 @@ public:
 
   // Blocks.
 
-  Bblock *block (Bfunction *, Bblock *, const std::vector<Bvariable *> &,
-		 Location, Location);
+  Bblock *block (tree, Bblock *, const std::vector<Bvariable *> &, Location,
+		 Location);
 
   void block_add_statements (Bblock *, const std::vector<tree> &);
 
@@ -389,17 +381,16 @@ public:
 
   void global_variable_set_init (Bvariable *, tree);
 
-  Bvariable *local_variable (Bfunction *, const std::string &, tree,
-			     Bvariable *, bool, Location);
+  Bvariable *local_variable (tree, const std::string &, tree, Bvariable *, bool,
+			     Location);
 
-  Bvariable *parameter_variable (Bfunction *, const std::string &, tree,
-				 bool, Location);
+  Bvariable *parameter_variable (tree, const std::string &, tree, bool,
+				 Location);
 
-  Bvariable *static_chain_variable (Bfunction *, const std::string &, tree,
-				    Location);
+  Bvariable *static_chain_variable (tree, const std::string &, tree, Location);
 
-  Bvariable *temporary_variable (Bfunction *, Bblock *, tree, tree, bool,
-				 Location, tree *);
+  Bvariable *temporary_variable (tree, Bblock *, tree, tree, bool, Location,
+				 tree *);
 
   Bvariable *implicit_variable (const std::string &, const std::string &,
 				tree, bool, bool, bool, int64_t);
@@ -422,7 +413,7 @@ public:
 
   // Labels.
 
-  Blabel *label (Bfunction *, const std::string &name, Location);
+  Blabel *label (tree, const std::string &name, Location);
 
   tree label_definition_statement (Blabel *);
 
@@ -432,35 +423,32 @@ public:
 
   // Functions.
 
-  Bfunction *error_function () { return this->make_function (error_mark_node); }
+  tree error_function () { return error_mark_node; }
 
-  Bfunction *function (tree fntype, const std::string &name,
-		       const std::string &asm_name, unsigned int flags,
-		       Location);
+  tree function (tree fntype, const std::string &name,
+		 const std::string &asm_name, unsigned int flags, Location);
 
-  tree function_defer_statement (Bfunction *function, tree undefer, tree defer,
+  tree function_defer_statement (tree function, tree undefer, tree defer,
 				 Location);
 
-  bool function_set_parameters (Bfunction *function,
+  bool function_set_parameters (tree function,
 				const std::vector<Bvariable *> &);
 
-  bool function_set_body (Bfunction *function, tree code_stmt);
+  bool function_set_body (tree function, tree code_stmt);
 
-  Bfunction *lookup_gcc_builtin (const std::string &);
+  tree lookup_gcc_builtin (const std::string &);
 
-  Bfunction *lookup_builtin_by_rust_name (const std::string &);
+  tree lookup_builtin_by_rust_name (const std::string &);
 
   void write_global_definitions (const std::vector<tree> &,
 				 const std::vector<tree> &,
-				 const std::vector<Bfunction *> &,
+				 const std::vector<tree> &,
 				 const std::vector<Bvariable *> &);
 
   void write_export_data (const char *bytes, unsigned int size);
 
 private:
 
-  Bfunction *make_function (tree t) { return new Bfunction (t); }
-
   tree fill_in_fields (tree, const std::vector<typed_identifier> &);
 
   tree fill_in_array (tree, tree, tree);
@@ -479,7 +467,7 @@ private:
 		       int flags);
 
   // A mapping of the GCC built-ins exposed to GCCRust.
-  std::map<std::string, Bfunction *> builtin_functions_;
+  std::map<std::string, tree> builtin_functions_;
   std::map<std::string, std::string> rust_intrinsic_to_gcc_builtin;
 };
 
@@ -1458,9 +1446,8 @@ Gcc_backend::convert_expression (tree type_tree, tree expr_tree,
 // Get the address of a function.
 
 tree
-Gcc_backend::function_code_expression (Bfunction *bfunc, Location location)
+Gcc_backend::function_code_expression (tree func, Location location)
 {
-  tree func = bfunc->get_tree ();
   if (func == error_mark_node)
     return this->error_expression ();
 
@@ -1527,9 +1514,9 @@ Gcc_backend::compound_expression (tree stat, tree expr, Location location)
 // ELSE_EXPR otherwise.
 
 tree
-Gcc_backend::conditional_expression (Bfunction *, tree type_tree,
-				     tree cond_expr, tree then_expr,
-				     tree else_expr, Location location)
+Gcc_backend::conditional_expression (tree, tree type_tree, tree cond_expr,
+				     tree then_expr, tree else_expr,
+				     Location location)
 {
   if (type_tree == error_mark_node || cond_expr == error_mark_node
       || then_expr == error_mark_node || else_expr == error_mark_node)
@@ -1949,7 +1936,7 @@ Gcc_backend::array_index_expression (tree array_tree, tree index_tree,
 
 // Create an expression for a call to FN_EXPR with FN_ARGS.
 tree
-Gcc_backend::call_expression (Bfunction *, // containing fcn for call
+Gcc_backend::call_expression (tree, // containing fcn for call
 			      tree fn, const std::vector<tree> &fn_args,
 			      tree chain_expr, Location location)
 {
@@ -2025,7 +2012,7 @@ Gcc_backend::call_expression (Bfunction *, // containing fcn for call
 // An expression as a statement.
 
 tree
-Gcc_backend::expression_statement (Bfunction *, tree expr)
+Gcc_backend::expression_statement (tree, tree expr)
 {
   return expr;
 }
@@ -2033,7 +2020,7 @@ Gcc_backend::expression_statement (Bfunction *, tree expr)
 // Variable initialization.
 
 tree
-Gcc_backend::init_statement (Bfunction *, Bvariable *var, tree init_tree)
+Gcc_backend::init_statement (tree, Bvariable *var, tree init_tree)
 {
   tree var_tree = var->get_decl ();
   if (var_tree == error_mark_node || init_tree == error_mark_node)
@@ -2065,7 +2052,7 @@ Gcc_backend::init_statement (Bfunction *, Bvariable *var, tree init_tree)
 // Assignment.
 
 tree
-Gcc_backend::assignment_statement (Bfunction *bfn, tree lhs, tree rhs,
+Gcc_backend::assignment_statement (tree bfn, tree lhs, tree rhs,
 				   Location location)
 {
   if (lhs == error_mark_node || rhs == error_mark_node)
@@ -2093,10 +2080,9 @@ Gcc_backend::assignment_statement (Bfunction *bfn, tree lhs, tree rhs,
 // Return.
 
 tree
-Gcc_backend::return_statement (Bfunction *bfunction,
-			       const std::vector<tree> &vals, Location location)
+Gcc_backend::return_statement (tree fntree, const std::vector<tree> &vals,
+			       Location location)
 {
-  tree fntree = bfunction->get_tree ();
   if (fntree == error_mark_node)
     return this->error_statement ();
   tree result = DECL_RESULT (fntree);
@@ -2208,7 +2194,7 @@ Gcc_backend::exception_handler_statement (tree try_stmt, tree except_stmt,
 // If.
 
 tree
-Gcc_backend::if_statement (Bfunction *, tree cond_tree, Bblock *then_block,
+Gcc_backend::if_statement (tree, tree cond_tree, Bblock *then_block,
 			   Bblock *else_block, Location location)
 {
   tree then_tree = then_block->get_tree ();
@@ -2240,14 +2226,13 @@ Gcc_backend::exit_expression (tree cond_tree, Location locus)
 // Switch.
 
 tree
-Gcc_backend::switch_statement (Bfunction *function, tree value,
+Gcc_backend::switch_statement (tree decl, tree value,
 			       const std::vector<std::vector<tree>> &cases,
 			       const std::vector<tree> &statements,
 			       Location switch_location)
 {
   gcc_assert (cases.size () == statements.size ());
 
-  tree decl = function->get_tree ();
   if (DECL_STRUCT_FUNCTION (decl) == NULL)
     push_struct_function (decl);
   else
@@ -2345,14 +2330,13 @@ Gcc_backend::statement_list (const std::vector<tree> &statements)
 // the Bblock.
 
 Bblock *
-Gcc_backend::block (Bfunction *function, Bblock *enclosing,
+Gcc_backend::block (tree fndecl, Bblock *enclosing,
 		    const std::vector<Bvariable *> &vars,
 		    Location start_location, Location)
 {
   tree block_tree = make_node (BLOCK);
   if (enclosing == NULL)
     {
-      tree fndecl = function->get_tree ();
       gcc_assert (fndecl != NULL_TREE);
 
       // We may have already created a block for local variables when
@@ -2599,7 +2583,7 @@ Gcc_backend::global_variable_set_init (Bvariable *var, tree expr_tree)
 // Make a local variable.
 
 Bvariable *
-Gcc_backend::local_variable (Bfunction *function, const std::string &name,
+Gcc_backend::local_variable (tree function, const std::string &name,
 			     tree type_tree, Bvariable *decl_var,
 			     bool is_address_taken, Location location)
 {
@@ -2607,7 +2591,7 @@ Gcc_backend::local_variable (Bfunction *function, const std::string &name,
     return this->error_variable ();
   tree decl = build_decl (location.gcc_location (), VAR_DECL,
 			  get_identifier_from_string (name), type_tree);
-  DECL_CONTEXT (decl) = function->get_tree ();
+  DECL_CONTEXT (decl) = function;
   TREE_USED (decl) = 1;
   if (is_address_taken)
     TREE_ADDRESSABLE (decl) = 1;
@@ -2623,7 +2607,7 @@ Gcc_backend::local_variable (Bfunction *function, const std::string &name,
 // Make a function parameter variable.
 
 Bvariable *
-Gcc_backend::parameter_variable (Bfunction *function, const std::string &name,
+Gcc_backend::parameter_variable (tree function, const std::string &name,
 				 tree type_tree, bool is_address_taken,
 				 Location location)
 {
@@ -2631,7 +2615,7 @@ Gcc_backend::parameter_variable (Bfunction *function, const std::string &name,
     return this->error_variable ();
   tree decl = build_decl (location.gcc_location (), PARM_DECL,
 			  get_identifier_from_string (name), type_tree);
-  DECL_CONTEXT (decl) = function->get_tree ();
+  DECL_CONTEXT (decl) = function;
   DECL_ARG_TYPE (decl) = type_tree;
   TREE_USED (decl) = 1;
   if (is_address_taken)
@@ -2643,15 +2627,13 @@ Gcc_backend::parameter_variable (Bfunction *function, const std::string &name,
 // Make a static chain variable.
 
 Bvariable *
-Gcc_backend::static_chain_variable (Bfunction *function,
-				    const std::string &name, tree type_tree,
-				    Location location)
+Gcc_backend::static_chain_variable (tree fndecl, const std::string &name,
+				    tree type_tree, Location location)
 {
   if (type_tree == error_mark_node)
     return this->error_variable ();
   tree decl = build_decl (location.gcc_location (), PARM_DECL,
 			  get_identifier_from_string (name), type_tree);
-  tree fndecl = function->get_tree ();
   DECL_CONTEXT (decl) = fndecl;
   DECL_ARG_TYPE (decl) = type_tree;
   TREE_USED (decl) = 1;
@@ -2677,15 +2659,13 @@ Gcc_backend::static_chain_variable (Bfunction *function,
 // Make a temporary variable.
 
 Bvariable *
-Gcc_backend::temporary_variable (Bfunction *function, Bblock *bblock,
-				 tree type_tree, tree init_tree,
-				 bool is_address_taken, Location location,
-				 tree *pstatement)
+Gcc_backend::temporary_variable (tree fndecl, Bblock *bblock, tree type_tree,
+				 tree init_tree, bool is_address_taken,
+				 Location location, tree *pstatement)
 {
-  gcc_assert (function != NULL);
-  tree decl = function->get_tree ();
+  gcc_assert (fndecl != NULL_TREE);
   if (type_tree == error_mark_node || init_tree == error_mark_node
-      || decl == error_mark_node)
+      || fndecl == error_mark_node)
     {
       *pstatement = this->error_statement ();
       return this->error_variable ();
@@ -2695,10 +2675,10 @@ Gcc_backend::temporary_variable (Bfunction *function, Bblock *bblock,
   // We can only use create_tmp_var if the type is not addressable.
   if (!TREE_ADDRESSABLE (type_tree))
     {
-      if (DECL_STRUCT_FUNCTION (decl) == NULL)
-	push_struct_function (decl);
+      if (DECL_STRUCT_FUNCTION (fndecl) == NULL)
+	push_struct_function (fndecl);
       else
-	push_cfun (DECL_STRUCT_FUNCTION (decl));
+	push_cfun (DECL_STRUCT_FUNCTION (fndecl));
 
       var = create_tmp_var (type_tree, "RUSTTMP");
       pop_cfun ();
@@ -2711,7 +2691,7 @@ Gcc_backend::temporary_variable (Bfunction *function, Bblock *bblock,
       DECL_ARTIFICIAL (var) = 1;
       DECL_IGNORED_P (var) = 1;
       TREE_USED (var) = 1;
-      DECL_CONTEXT (var) = decl;
+      DECL_CONTEXT (var) = fndecl;
 
       // We have to add this variable to the BLOCK and the BIND_EXPR.
       tree bind_tree = bblock->get_tree ();
@@ -2739,7 +2719,7 @@ Gcc_backend::temporary_variable (Bfunction *function, Bblock *bblock,
       && (this->type_size (type_tree) == 0
 	  || TREE_TYPE (init_tree) == void_type_node))
     *pstatement = this->compound_statement (
-      this->expression_statement (function, init_tree), *pstatement);
+      this->expression_statement (fndecl, init_tree), *pstatement);
 
   return new Bvariable (var);
 }
@@ -2950,13 +2930,11 @@ Gcc_backend::immutable_struct_reference (const std::string &name,
 // Make a label.
 
 Blabel *
-Gcc_backend::label (Bfunction *function, const std::string &name,
-		    Location location)
+Gcc_backend::label (tree func_tree, const std::string &name, Location location)
 {
   tree decl;
   if (name.empty ())
     {
-      tree func_tree = function->get_tree ();
       if (DECL_STRUCT_FUNCTION (func_tree) == NULL)
 	push_struct_function (func_tree);
       else
@@ -2971,7 +2949,7 @@ Gcc_backend::label (Bfunction *function, const std::string &name,
       tree id = get_identifier_from_string (name);
       decl
 	= build_decl (location.gcc_location (), LABEL_DECL, id, void_type_node);
-      DECL_CONTEXT (decl) = function->get_tree ();
+      DECL_CONTEXT (decl) = func_tree;
     }
   return new Blabel (decl);
 }
@@ -3013,7 +2991,7 @@ Gcc_backend::label_address (Blabel *label, Location location)
 
 // Declare or define a new function.
 
-Bfunction *
+tree
 Gcc_backend::function (tree functype, const std::string &name,
 		       const std::string &asm_name, unsigned int flags,
 		       Location location)
@@ -3061,7 +3039,7 @@ Gcc_backend::function (tree functype, const std::string &name,
     TREE_READONLY (decl) = 1;
 
   rust_preserve_from_gc (decl);
-  return new Bfunction (decl);
+  return decl;
 }
 
 // Create a statement that runs all deferred calls for FUNCTION.  This should
@@ -3070,19 +3048,17 @@ Gcc_backend::function (tree functype, const std::string &name,
 //     try { UNDEFER; } catch { CHECK_DEFER; goto finish; }
 
 tree
-Gcc_backend::function_defer_statement (Bfunction *function, tree undefer_tree,
+Gcc_backend::function_defer_statement (tree function, tree undefer_tree,
 				       tree defer_tree, Location location)
 {
-  tree fntree = function->get_tree ();
-
   if (undefer_tree == error_mark_node || defer_tree == error_mark_node
-      || fntree == error_mark_node)
+      || function == error_mark_node)
     return this->error_statement ();
 
-  if (DECL_STRUCT_FUNCTION (fntree) == NULL)
-    push_struct_function (fntree);
+  if (DECL_STRUCT_FUNCTION (function) == NULL)
+    push_struct_function (function);
   else
-    push_cfun (DECL_STRUCT_FUNCTION (fntree));
+    push_cfun (DECL_STRUCT_FUNCTION (function));
 
   tree stmt_list = NULL;
   Blabel *blabel = this->label (function, "", location);
@@ -3106,10 +3082,9 @@ Gcc_backend::function_defer_statement (Bfunction *function, tree undefer_tree,
 
 bool
 Gcc_backend::function_set_parameters (
-  Bfunction *function, const std::vector<Bvariable *> &param_vars)
+  tree function, const std::vector<Bvariable *> &param_vars)
 {
-  tree func_tree = function->get_tree ();
-  if (func_tree == error_mark_node)
+  if (function == error_mark_node)
     return false;
 
   tree params = NULL_TREE;
@@ -3122,27 +3097,25 @@ Gcc_backend::function_set_parameters (
       pp = &DECL_CHAIN (*pp);
     }
   *pp = NULL_TREE;
-  DECL_ARGUMENTS (func_tree) = params;
+  DECL_ARGUMENTS (function) = params;
   return true;
 }
 
 // Set the function body for FUNCTION using the code in CODE_BLOCK.
 
 bool
-Gcc_backend::function_set_body (Bfunction *function, tree code_stmt)
+Gcc_backend::function_set_body (tree function, tree code_stmt)
 {
-  tree func_tree = function->get_tree ();
-
-  if (func_tree == error_mark_node || code_stmt == error_mark_node)
+  if (function == error_mark_node || code_stmt == error_mark_node)
     return false;
-  DECL_SAVED_TREE (func_tree) = code_stmt;
+  DECL_SAVED_TREE (function) = code_stmt;
   return true;
 }
 
 // Look up a named built-in function in the current backend implementation.
 // Returns NULL if no built-in function by that name exists.
 
-Bfunction *
+tree
 Gcc_backend::lookup_gcc_builtin (const std::string &name)
 {
   if (this->builtin_functions_.count (name) != 0)
@@ -3150,7 +3123,7 @@ Gcc_backend::lookup_gcc_builtin (const std::string &name)
   return NULL;
 }
 
-Bfunction *
+tree
 Gcc_backend::lookup_builtin_by_rust_name (const std::string &name)
 {
   auto it = rust_intrinsic_to_gcc_builtin.find (name);
@@ -3167,7 +3140,7 @@ Gcc_backend::lookup_builtin_by_rust_name (const std::string &name)
 void
 Gcc_backend::write_global_definitions (
   const std::vector<tree> &type_decls, const std::vector<tree> &constant_decls,
-  const std::vector<Bfunction *> &function_decls,
+  const std::vector<tree> &function_decls,
   const std::vector<Bvariable *> &variable_decls)
 {
   size_t count_definitions = type_decls.size () + constant_decls.size ()
@@ -3211,10 +3184,10 @@ Gcc_backend::write_global_definitions (
 	  ++i;
 	}
     }
-  for (std::vector<Bfunction *>::const_iterator p = function_decls.begin ();
+  for (std::vector<tree>::const_iterator p = function_decls.begin ();
        p != function_decls.end (); ++p)
     {
-      tree decl = (*p)->get_tree ();
+      tree decl = (*p);
       if (decl != error_mark_node)
 	{
 	  rust_preserve_from_gc (decl);
@@ -3262,7 +3235,7 @@ Gcc_backend::define_builtin (const std::string rust_name,
   if ((flags & builtin_novops) != 0)
     DECL_IS_NOVOPS (decl) = 1;
   set_builtin_decl (bcode, decl, true);
-  this->builtin_functions_[name] = this->make_function (decl);
+  this->builtin_functions_[name] = decl;
   if (libname != NULL)
     {
       decl = add_builtin_function (libname, fntype, bcode, BUILT_IN_NORMAL,
@@ -3273,7 +3246,7 @@ Gcc_backend::define_builtin (const std::string rust_name,
 	TREE_THIS_VOLATILE (decl) = 1;
       if ((flags & builtin_novops) != 0)
 	DECL_IS_NOVOPS (decl) = 1;
-      this->builtin_functions_[libname] = this->make_function (decl);
+      this->builtin_functions_[libname] = decl;
     }
 
   rust_intrinsic_to_gcc_builtin[rust_name] = name;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 11:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:51 [gcc/devel/rust/master] Replace Bfunction with GCC tree Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).