From e898243c23c82247ec01b32f551402ca52f32927 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 10 Jun 2019 21:34:12 +0000 Subject: compiler: support inlining functions that use index expressions Also move the determine_types pass on an inlined function body to one place, rather than doing it ad hoc as needed. This adds 79 new inlinable functions in the standard library, such as bytes.HasPrefix and bytes.LastIndexByte. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/181261 From-SVN: r272133 --- gcc/go/gofrontend/expressions.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gcc/go/gofrontend/expressions.h') diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 22dd2fc..1595eb1 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -3089,6 +3089,13 @@ class Array_index_expression : public Expression Bexpression* do_get_backend(Translate_context*); + int + do_inlining_cost() const + { return this->end_ != NULL ? 2 : 1; } + + void + do_export(Export_function_body*) const; + void do_dump_expression(Ast_dump_context*) const; @@ -3161,6 +3168,13 @@ class String_index_expression : public Expression Bexpression* do_get_backend(Translate_context*); + int + do_inlining_cost() const + { return this->end_ != NULL ? 2 : 1; } + + void + do_export(Export_function_body*) const; + void do_dump_expression(Ast_dump_context*) const; @@ -3247,6 +3261,13 @@ class Map_index_expression : public Expression Bexpression* do_get_backend(Translate_context*); + int + do_inlining_cost() const + { return 5; } + + void + do_export(Export_function_body*) const; + void do_dump_expression(Ast_dump_context*) const; -- cgit v1.1