diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-11-26 21:44:20 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-11-26 21:44:20 +0000 |
commit | 1e4cc1d4b097f346b4cda611782fe83eda0df18f (patch) | |
tree | 2d4e3368b005eaf1e957c8b3437f6e03d7026f42 /gcc/go/gofrontend/statements.h | |
parent | 50e99db39196a0567e844f35ce1cd0f36d066b8f (diff) | |
download | gcc-1e4cc1d4b097f346b4cda611782fe83eda0df18f.zip gcc-1e4cc1d4b097f346b4cda611782fe83eda0df18f.tar.gz gcc-1e4cc1d4b097f346b4cda611782fe83eda0df18f.tar.bz2 |
compiler: initial support for exporting function bodies
Create a framework for putting function bodies in export data. At
present only empty functions will be put there, and they will be
ignored on import. Later patches will get this to the point of
supporting inlining of (some) functions defined in other packages.
Reviewed-on: https://go-review.googlesource.com/c/150061
From-SVN: r266490
Diffstat (limited to 'gcc/go/gofrontend/statements.h')
-rw-r--r-- | gcc/go/gofrontend/statements.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h index 81b26b3..ff57a21 100644 --- a/gcc/go/gofrontend/statements.h +++ b/gcc/go/gofrontend/statements.h @@ -15,6 +15,7 @@ class Statement_inserter; class Block; class Function; class Unnamed_label; +class Export_function_body; class Assignment_statement; class Temporary_statement; class Variable_declaration_statement; @@ -326,6 +327,17 @@ class Statement check_types(Gogo* gogo) { this->do_check_types(gogo); } + // Return the cost of this statement for inlining purposes. + int + inlining_cost() + { return this->do_inlining_cost(); } + + // Export data for this statement to BODY. INDENT is an indentation + // level used if the export data requires multiple lines. + void + export_statement(Export_function_body* efb) + { this->do_export_statement(efb); } + // Return whether this is a block statement. bool is_block_statement() const @@ -488,6 +500,22 @@ class Statement do_check_types(Gogo*) { } + // Implemented by child class: return the cost of this statement for + // inlining. The default cost is high, so we only need to define + // this method for statements that can be inlined. + virtual int + do_inlining_cost() + { return 0x100000; } + + // Implemented by child class: write export data for this statement + // to the string. The integer is an indentation level used if the + // export data requires multiple lines. This need only be + // implemented by classes that implement do_inlining_cost with a + // reasonable value. + virtual void + do_export_statement(Export_function_body*) + { go_unreachable(); } + // Implemented by child class: return true if this statement may // fall through. virtual bool @@ -819,6 +847,11 @@ class Block_statement : public Statement block_(block), is_lowered_for_statement_(false) { } + // Return the actual block. + Block* + block() const + { return this->block_; } + void set_is_lowered_for_statement() { this->is_lowered_for_statement_ = true; } @@ -836,6 +869,13 @@ class Block_statement : public Statement do_determine_types() { this->block_->determine_types(); } + int + do_inlining_cost() + { return 0; } + + void + do_export_statement(Export_function_body*); + bool do_may_fall_through() const { return this->block_->may_fall_through(); } |