aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-02-23 00:10:22 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-02-23 00:10:22 +0000
commit869c22c50b4d254bbfcc7ae47ba51386c229860e (patch)
tree80aaae8eb6d466fd88ebd8a096b6c30c0ec02582 /gcc
parent1d05ab3690b26285c5b4801c18caaabae7acb333 (diff)
downloadgcc-869c22c50b4d254bbfcc7ae47ba51386c229860e.zip
gcc-869c22c50b4d254bbfcc7ae47ba51386c229860e.tar.gz
gcc-869c22c50b4d254bbfcc7ae47ba51386c229860e.tar.bz2
backport: trunk.
Merge in changes from gofrontend repository that are not in GCC trunk. This includes changes up to e387439bfd24d5e142874b8e68e7039f74c744d7. From-SVN: r245668
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/go-backend.c2
-rw-r--r--gcc/go/go-gcc.cc11
-rw-r--r--gcc/go/gofrontend/backend.h5
-rw-r--r--gcc/go/gofrontend/export.cc8
-rw-r--r--gcc/go/gofrontend/export.h6
-rw-r--r--gcc/go/gofrontend/expressions.cc30
-rw-r--r--gcc/go/gofrontend/expressions.h5
-rw-r--r--gcc/go/gofrontend/gogo.cc2
-rw-r--r--gcc/go/gofrontend/statements.cc4
-rw-r--r--gcc/go/gofrontend/types.cc7
10 files changed, 66 insertions, 14 deletions
diff --git a/gcc/go/go-backend.c b/gcc/go/go-backend.c
index 1705b84..8f915a0 100644
--- a/gcc/go/go-backend.c
+++ b/gcc/go/go-backend.c
@@ -30,7 +30,7 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "output.h" /* for assemble_string */
#include "common/common-target.h"
-
+#include "go-c.h"
/* The segment name we pass to simple_object_start_read to find Go
export data. */
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index ed6fc2c..25de526 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -506,6 +506,10 @@ class Gcc_backend : public Backend
const std::vector<Bfunction*>&,
const std::vector<Bvariable*>&);
+ void
+ write_export_data(const char* bytes, unsigned int size);
+
+
private:
// Make a Bexpression from a tree.
Bexpression*
@@ -3211,6 +3215,13 @@ Gcc_backend::write_global_definitions(
delete[] defs;
}
+void
+Gcc_backend::write_export_data(const char* bytes, unsigned int size)
+{
+ go_write_export_data(bytes, size);
+}
+
+
// Define a builtin function. BCODE is the builtin function code
// defined by builtins.def. NAME is the name of the builtin function.
// LIBNAME is the name of the corresponding library function, and is
diff --git a/gcc/go/gofrontend/backend.h b/gcc/go/gofrontend/backend.h
index 93835d9..e51efe4ef 100644
--- a/gcc/go/gofrontend/backend.h
+++ b/gcc/go/gofrontend/backend.h
@@ -750,6 +750,11 @@ class Backend
const std::vector<Bexpression*>& constant_decls,
const std::vector<Bfunction*>& function_decls,
const std::vector<Bvariable*>& variable_decls) = 0;
+
+ // Write SIZE bytes of export data from BYTES to the proper
+ // section in the output object file.
+ virtual void
+ write_export_data(const char* bytes, unsigned int size) = 0;
};
#endif // !defined(GO_BACKEND_H)
diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc
index 6e08599..2ea543a 100644
--- a/gcc/go/gofrontend/export.cc
+++ b/gcc/go/gofrontend/export.cc
@@ -14,6 +14,9 @@
#include "statements.h"
#include "export.h"
+#include "go-linemap.h"
+#include "backend.h"
+
// This file handles exporting global declarations.
// Class Export.
@@ -727,7 +730,8 @@ Export::Stream::write_checksum(const std::string& s)
// Class Stream_to_section.
-Stream_to_section::Stream_to_section()
+Stream_to_section::Stream_to_section(Backend* backend)
+ : backend_(backend)
{
}
@@ -736,5 +740,5 @@ Stream_to_section::Stream_to_section()
void
Stream_to_section::do_write(const char* bytes, size_t length)
{
- go_write_export_data (bytes, length);
+ this->backend_->write_export_data (bytes, length);
}
diff --git a/gcc/go/gofrontend/export.h b/gcc/go/gofrontend/export.h
index fec73fb..1365677 100644
--- a/gcc/go/gofrontend/export.h
+++ b/gcc/go/gofrontend/export.h
@@ -16,6 +16,7 @@ class Bindings;
class Type;
class Package;
class Import_init_set;
+class Backend;
// Codes used for the builtin types. These are all negative to make
// them easily distinct from the codes assigned by Export::write_type.
@@ -236,11 +237,14 @@ class Export : public String_dump
class Stream_to_section : public Export::Stream
{
public:
- Stream_to_section();
+ Stream_to_section(Backend*);
protected:
void
do_write(const char*, size_t);
+
+ private:
+ Backend* backend_;
};
#endif // !defined(GO_EXPORT_H)
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 8006888..79e9cd1 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -10231,16 +10231,13 @@ Call_expression::do_get_backend(Translate_context* context)
if (this->results_ != NULL)
{
- go_assert(this->call_temp_ != NULL);
- Expression* call_ref =
- Expression::make_temporary_reference(this->call_temp_, location);
- Bexpression* bcall_ref = call_ref->get_backend(context);
+ Bexpression* bcall_ref = this->call_result_ref(context);
Bfunction* bfunction = context->function()->func_value()->get_decl();
Bstatement* assn_stmt =
gogo->backend()->assignment_statement(bfunction,
bcall_ref, call, location);
- this->call_ = this->set_results(context, bcall_ref);
+ this->call_ = this->set_results(context);
Bexpression* set_and_call =
gogo->backend()->compound_expression(assn_stmt, this->call_,
@@ -10252,16 +10249,32 @@ Call_expression::do_get_backend(Translate_context* context)
return this->call_;
}
+// Return the backend representation of a reference to the struct used
+// to capture the result of a multiple-output call.
+
+Bexpression*
+Call_expression::call_result_ref(Translate_context* context)
+{
+ go_assert(this->call_temp_ != NULL);
+ Location location = this->location();
+ Expression* call_ref =
+ Expression::make_temporary_reference(this->call_temp_, location);
+ Bexpression* bcall_ref = call_ref->get_backend(context);
+ return bcall_ref;
+}
+
// Set the result variables if this call returns multiple results.
Bexpression*
-Call_expression::set_results(Translate_context* context, Bexpression* call)
+Call_expression::set_results(Translate_context* context)
{
Gogo* gogo = context->gogo();
Bexpression* results = NULL;
Location loc = this->location();
+ go_assert(this->call_temp_ != NULL);
+
size_t rc = this->result_count();
for (size_t i = 0; i < rc; ++i)
{
@@ -10277,12 +10290,15 @@ Call_expression::set_results(Translate_context* context, Bexpression* call)
Bfunction* bfunction = context->function()->func_value()->get_decl();
Bexpression* result_ref = ref->get_backend(context);
+ Bexpression* bcall_ref = this->call_result_ref(context);
Bexpression* call_result =
- gogo->backend()->struct_field_expression(call, i, loc);
+ gogo->backend()->struct_field_expression(bcall_ref, i, loc);
Bstatement* assn_stmt =
gogo->backend()->assignment_statement(bfunction,
result_ref, call_result, loc);
+ bcall_ref = this->call_result_ref(context);
+ call_result = gogo->backend()->struct_field_expression(bcall_ref, i, loc);
Bexpression* result =
gogo->backend()->compound_expression(assn_stmt, call_result, loc);
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h
index e088100..51d27c4 100644
--- a/gcc/go/gofrontend/expressions.h
+++ b/gcc/go/gofrontend/expressions.h
@@ -2267,7 +2267,10 @@ class Call_expression : public Expression
Expression**);
Bexpression*
- set_results(Translate_context*, Bexpression*);
+ set_results(Translate_context*);
+
+ Bexpression*
+ call_result_ref(Translate_context* context);
// The function to call.
Expression* fn_;
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index c5ce5d9..28aaecf 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -4497,7 +4497,7 @@ Gogo::do_exports()
{
// For now we always stream to a section. Later we may want to
// support streaming to a separate file.
- Stream_to_section stream;
+ Stream_to_section stream(this->backend());
// Write out either the prefix or pkgpath depending on how we were
// invoked.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index d6ab4cc..00367ef 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -510,6 +510,10 @@ Temporary_statement::do_get_backend(Translate_context* context)
binit = init->get_backend(context);
}
+ if (binit != NULL)
+ binit = context->backend()->convert_expression(btype, binit,
+ this->location());
+
Bstatement* statement;
this->bvariable_ =
context->backend()->temporary_variable(bfunction, context->bblock(),
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index 9423ef6..a471e52 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -1177,7 +1177,12 @@ Type::type_descriptor_pointer(Gogo* gogo, Location location)
Bexpression* var_expr =
gogo->backend()->var_expression(t->type_descriptor_var_,
VE_rvalue, location);
- return gogo->backend()->address_expression(var_expr, location);
+ Bexpression* var_addr =
+ gogo->backend()->address_expression(var_expr, location);
+ Type* td_type = Type::make_type_descriptor_type();
+ Btype* td_btype = td_type->get_backend(gogo);
+ Btype* ptd_btype = gogo->backend()->pointer_type(td_btype);
+ return gogo->backend()->convert_expression(ptd_btype, var_addr, location);
}
// A mapping from unnamed types to type descriptor variables.