compiler: permit inlining receive expressions
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 10 May 2019 19:41:55 +0000 (19:41 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 10 May 2019 19:41:55 +0000 (19:41 +0000)
    This does not permit any new inlinable functions in the standard library.

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176637

From-SVN: r271074

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/expressions.h

index 8158367c62b38d2be476db2d70cfd205dfd10215..d8bcef43a92414cb5cf2c79ade123de73a713b71 100644 (file)
@@ -1,4 +1,4 @@
-b5e4ba88a2e7f3c34e9183f43370c38ea639c393
+76ab85364745e445498fe53f9ca8e37b49650779
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index ed6585242401a5b230a75f10f4bbde52ca0e8ba3..54f6e525e1ed0757cbe06707cc61346ac6f31497 100644 (file)
@@ -15423,6 +15423,15 @@ Receive_expression::do_get_backend(Translate_context* context)
   return Expression::make_compound(recv, recv_ref, loc)->get_backend(context);
 }
 
+// Export a receive expression.
+
+void
+Receive_expression::do_export(Export_function_body* efb) const
+{
+  efb->write_c_string("<-");
+  this->channel_->export_expression(efb);
+}
+
 // Dump ast representation for a receive expression.
 
 void
@@ -15432,6 +15441,16 @@ Receive_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
   ast_dump_context->dump_expression(channel_);
 }
 
+// Import a receive expression.
+
+Expression*
+Receive_expression::do_import(Import_expression* imp, Location loc)
+{
+  imp->require_c_string("<-");
+  Expression* expr = Expression::import_expression(imp, loc);
+  return Expression::make_receive(expr, loc);
+}
+
 // Make a receive expression.
 
 Receive_expression*
@@ -16783,6 +16802,8 @@ Expression::import_expression(Import_expression* imp, Location loc)
       // This handles integers, floats and complex constants.
       return Integer_expression::do_import(imp, loc);
     }
+  else if (imp->match_c_string("<-"))
+    return Receive_expression::do_import(imp, loc);
   else if (imp->match_c_string("$nil")
           || (imp->version() < EXPORT_FORMAT_V3
               && imp->match_c_string("nil")))
index 2cca8240fcd084fa7ecf5dbd5131add45596483d..9ed81f11ea5966c8a093051a422cb40bc3138aea 100644 (file)
@@ -3982,6 +3982,9 @@ class Receive_expression : public Expression
   channel()
   { return this->channel_; }
 
+  static Expression*
+  do_import(Import_expression*, Location);
+
  protected:
   int
   do_traverse(Traverse* traverse)
@@ -4010,6 +4013,10 @@ class Receive_expression : public Expression
     return Expression::make_receive(this->channel_->copy(), this->location());
   }
 
+  int
+  do_inlining_cost() const
+  { return 1; }
+
   bool
   do_must_eval_in_order() const
   { return true; }
@@ -4017,6 +4024,9 @@ class Receive_expression : public Expression
   Bexpression*
   do_get_backend(Translate_context*);
 
+  void
+  do_export(Export_function_body*) const;
+
   void
   do_dump_expression(Ast_dump_context*) const;