Commit 7035307e by Chris Manghane Committed by Ian Lance Taylor

Sync to current external repository.

user:        Ian Lance Taylor <iant@golang.org>
date:        Thu Apr 10 09:25:24 2014 -0700
files:       go/expressions.cc
description:
compiler: add checks for constant overflow

Prevent extremely large constants from eating all of memory.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Apr 07 16:57:09 2014 -0700
files:       go/gogo-tree.cc go/gogo.cc go/gogo.h go/statements.cc
description:
compiler: Use backend interface for variable initialization.


user:        Chris Manghane <cmang@golang.org>
date:        Thu Apr 03 19:56:05 2014 -0700
files:       go/backend.h go/gogo-tree.cc go/gogo.cc go/gogo.h
description:
compiler: Use backend interface to build function code.


changeset:   1269:6e30875d539e
user:        Chris Manghane <cmang@golang.org>
date:        Wed Apr 02 13:16:00 2014 -0700
files:       go/backend.h go/gogo-tree.cc go/gogo.cc go/gogo.h
description:
compiler: Use backend interface for building function defer wrappers.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Mar 31 12:42:49 2014 -0700
files:       go/expressions.cc go/gogo-tree.cc go/gogo.cc go/gogo.h
description:
compiler: Use backend interface for memory allocation.


user:        Chris Manghane <cmang@golang.org>
date:        Thu Mar 27 14:22:49 2014 -0700
files:       go/backend.h go/expressions.cc go/expressions.h
description:
compiler: Use backend interface for fixed array construction.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Mar 17 21:25:04 2014 -0700
files:       go/expressions.cc
description:
compiler: Check for loops in self-referential array types. Fixes issue 7525.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Mar 17 14:31:59 2014 -0700
files:       go/gogo.cc go/parse.cc
description:
compiler: Don't declare blank labels. Fixes issue 7539.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Mar 17 13:12:32 2014 -0700
files:       go/backend.h go/expressions.cc go/expressions.h go/runtime.def
description:
compiler: Use backend interface for call expressions.


user:        Chris Manghane <cmang@golang.org>
date:        Wed Mar 12 13:34:27 2014 -0700
files:       go/expressions.cc go/expressions.h go/gogo-tree.cc go/statements.cc
description:
compiler: Use backend interface map construction.


user:        Chris Manghane <cmang@golang.org>
date:        Tue Mar 11 12:53:06 2014 -0700
files:       go/backend.h go/expressions.cc go/gogo-tree.cc go/gogo.h
description:
compiler: Use backend interface for string expressions.


user:        Chris Manghane <cmang@golang.org>
date:        Sat Mar 08 15:56:59 2014 -0800
files:       go/backend.h go/expressions.cc go/expressions.h
description:
compiler: Use backend interface for array and string indexing.


user:        Chris Manghane <cmang@golang.org>
date:        Fri Mar 07 16:02:18 2014 -0800
files:       go/expressions.cc
description:
compiler: Use backend interface for constant expressions.


user:        Chris Manghane <cmang@golang.org>
date:        Thu Mar 06 16:00:18 2014 -0800
files:       go/expressions.cc
description:
compiler: Use backend interface for struct construction.


user:        Chris Manghane <cmang@golang.org>
date:        Wed Mar 05 13:09:37 2014 -0800
files:       go/expressions.cc
description:
compiler: Use backend interface for type conversions.


user:        Chris Manghane <cmang@golang.org>
date:        Tue Mar 04 07:03:47 2014 -0800
files:       go/expressions.cc go/expressions.h go/gogo-tree.cc go/gogo.h go/runtime.def libgo/runtime/chan.c
description:
compiler: Use backend interface for channel receive.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Mar 03 15:18:57 2014 -0800
files:       go/backend.h go/expressions.cc go/runtime.def
description:
compiler: Use backend interface for builtin calls.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Mar 03 07:44:35 2014 -0800
files:       go/expressions.cc go/expressions.h go/types.cc go/types.h
description:
compiler: Use backend interface for string info.


user:        Chris Manghane <cmang@golang.org>
date:        Fri Feb 28 10:45:55 2014 -0800
files:       go/expressions.cc go/expressions.h go/gogo-tree.cc go/statements.cc
description:
compiler: Use backend interface for map indexing.


user:        Chris Manghane <cmang@golang.org>
date:        Wed Feb 26 14:13:10 2014 -0800
files:       go/expressions.cc go/expressions.h
description:
compiler: Use backend interface for slice value expressions.


user:        Chris Manghane <cmang@golang.org>
date:        Wed Feb 26 13:12:19 2014 -0800
files:       go/backend.h go/expressions.cc go/expressions.h go/gogo-tree.cc go/runtime.def go/statements.cc
description:
compiler: Use backend interface for interface values.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Feb 24 12:30:13 2014 -0800
files:       go/expressions.cc go/expressions.h go/parse.cc go/statements.cc
description:
compiler: Change Heap_composite_expression to Heap_expression.


user:        Chris Manghane <cmang@golang.org>
date:        Thu Feb 20 19:47:06 2014 -0800
files:       go/expressions.cc go/expressions.h go/gogo-tree.cc go/gogo.cc go/gogo.h go/types.cc go/types.h
description:
compiler: Use backend interface for interface method table expressions.


user:        Chris Manghane <cmang@golang.org>
date:        Mon Feb 03 14:36:20 2014 -0800
files:       go/expressions.cc go/expressions.h
description:
compiler: Add compound expressions to the frontend.


	* go-gcc.cc: Include "convert.h".
	(Gcc_backend::string_constant_expression): New function.
	(Gcc_backend::real_part_expression): Likewise.
	(Gcc_backend::imag_part_expression): Likewise.
	(Gcc_backend::complex_expression): Likewise.
	(Gcc_backend::constructor_expression): Likewise.
	(Gcc_backend::array_constructor_expression): Likewise.
	(Gcc_backend::pointer_offset_expression): Likewise.
	(Gcc_backend::array_index_expression): Likewise.
	(Gcc_backend::call_expression): Likewise.
	(Gcc_backend::exception_handler_statement): Likewise.
	(Gcc_backend::function_defer_statement): Likewise.
	(Gcc_backend::function_set_parameters): Likewise.
	(Gcc_backend::function_set_body): Likewise.
	(Gcc_backend::convert_expression): Handle various type
	conversions.

From-SVN: r209393
parent 88f592e3
2014-04-14 Chris Manghane <cmang@google.com>
* go-gcc.cc: Include "convert.h".
(Gcc_backend::string_constant_expression): New function.
(Gcc_backend::real_part_expression): Likewise.
(Gcc_backend::imag_part_expression): Likewise.
(Gcc_backend::complex_expression): Likewise.
(Gcc_backend::constructor_expression): Likewise.
(Gcc_backend::array_constructor_expression): Likewise.
(Gcc_backend::pointer_offset_expression): Likewise.
(Gcc_backend::array_index_expression): Likewise.
(Gcc_backend::call_expression): Likewise.
(Gcc_backend::exception_handler_statement): Likewise.
(Gcc_backend::function_defer_statement): Likewise.
(Gcc_backend::function_set_parameters): Likewise.
(Gcc_backend::function_set_body): Likewise.
(Gcc_backend::convert_expression): Handle various type
conversions.
2014-03-03 Ian Lance Taylor <iant@google.com>
* go-gcc.cc (Gcc_backend::immutable_struct): If IS_COMMON, set
......
......@@ -269,6 +269,22 @@ class Backend
virtual Bexpression*
complex_constant_expression(Btype* btype, mpfr_t real, mpfr_t imag) = 0;
// Return an expression for the string value VAL.
virtual Bexpression*
string_constant_expression(const std::string& val) = 0;
// Return an expression for the real part of BCOMPLEX.
virtual Bexpression*
real_part_expression(Bexpression* bcomplex, Location) = 0;
// Return an expression for the imaginary part of BCOMPLEX.
virtual Bexpression*
imag_part_expression(Bexpression* bcomplex, Location) = 0;
// Return an expression for the complex number (BREAL, BIMAG).
virtual Bexpression*
complex_expression(Bexpression* breal, Bexpression* bimag, Location) = 0;
// Return an expression that converts EXPR to TYPE.
virtual Bexpression*
convert_expression(Btype* type, Bexpression* expr, Location) = 0;
......@@ -312,6 +328,38 @@ class Backend
binary_expression(Operator op, Bexpression* left, Bexpression* right,
Location) = 0;
// Return an expression that constructs BTYPE with VALS. BTYPE must be the
// backend representation a of struct. VALS must be in the same order as the
// corresponding fields in BTYPE.
virtual Bexpression*
constructor_expression(Btype* btype, const std::vector<Bexpression*>& vals,
Location) = 0;
// Return an expression that constructs an array of BTYPE with INDEXES and
// VALS. INDEXES and VALS must have the same amount of elements. Each index
// in INDEXES must be in the same order as the corresponding value in VALS.
virtual Bexpression*
array_constructor_expression(Btype* btype,
const std::vector<unsigned long>& indexes,
const std::vector<Bexpression*>& vals,
Location) = 0;
// Return an expression for the address of BASE[INDEX].
// BASE has a pointer type. This is used for slice indexing.
virtual Bexpression*
pointer_offset_expression(Bexpression* base, Bexpression* index,
Location) = 0;
// Return an expression for ARRAY[INDEX] as an l-value. ARRAY is a valid
// fixed-length array, not a slice.
virtual Bexpression*
array_index_expression(Bexpression* array, Bexpression* index, Location) = 0;
// Create an expression for a call to FN with ARGS.
virtual Bexpression*
call_expression(Bexpression* fn, const std::vector<Bexpression*>& args,
Location) = 0;
// Statements.
// Create an error statement. This is used for cases which should
......@@ -367,6 +415,15 @@ class Backend
virtual Bstatement*
statement_list(const std::vector<Bstatement*>&) = 0;
// Create a statement that attempts to execute BSTAT and calls EXCEPT_STMT if
// an exception occurs. EXCEPT_STMT may be NULL. FINALLY_STMT may be NULL and
// if not NULL, it will always be executed. This is used for handling defers
// in Go functions. In C++, the resulting code is of this form:
// try { BSTAT; } catch { EXCEPT_STMT; } finally { FINALLY_STMT; }
virtual Bstatement*
exception_handler_statement(Bstatement* bstat, Bstatement* except_stmt,
Bstatement* finally_stmt, Location) = 0;
// Blocks.
// Create a block. The frontend will call this function when it
......@@ -570,6 +627,26 @@ class Backend
function(Btype* fntype, const std::string& name, const std::string& asm_name,
bool is_visible, bool is_declaration, bool is_inlinable,
bool disable_split_stack, bool in_unique_section, Location) = 0;
// Create a statement that runs all deferred calls for FUNCTION. This should
// be a statement that looks like this in C++:
// finish:
// try { UNDEFER; } catch { CHECK_DEFER; goto finish; }
virtual Bstatement*
function_defer_statement(Bfunction* function, Bexpression* undefer,
Bexpression* check_defer, Location) = 0;
// Record PARAM_VARS as the variables to use for the parameters of FUNCTION.
// This will only be called for a function definition. Returns true on
// success, false on failure.
virtual bool
function_set_parameters(Bfunction* 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, Bstatement* code_stmt) = 0;
};
// The backend interface has to define this function.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -612,34 +612,9 @@ class Gogo
void
build_interface_method_tables();
// Build an interface method table for a type: a list of function
// pointers, one for each interface method. This returns a decl.
tree
interface_method_table_for_type(const Interface_type*, Type*,
bool is_pointer);
// Return a tree which allocate SIZE bytes to hold values of type
// TYPE.
tree
allocate_memory(Type *type, tree size, Location);
// Return a type to use for pointer to const char.
static tree
const_char_pointer_type_tree();
// Build a string constant with the right type.
static tree
string_constant_tree(const std::string&);
// Build a Go string constant. This returns a pointer to the
// constant.
tree
go_string_constant_tree(const std::string&);
// Receive a value from a channel.
static tree
receive_from_channel(tree type_tree, tree type_descriptor_tree, tree channel,
Location);
// Return an expression which allocates memory to hold values of type TYPE.
Expression*
allocate_memory(Type *type, Location);
private:
// During parsing, we keep a stack of functions. Each function on
......@@ -687,11 +662,6 @@ class Gogo
void
register_gc_vars(const std::vector<Named_object*>&, tree*);
// Build a pointer to a Go string constant. This returns a pointer
// to the pointer.
tree
ptr_go_string_constant_tree(const std::string&);
// Type used to map import names to packages.
typedef std::map<std::string, Package*> Imports;
......@@ -1119,14 +1089,14 @@ class Function
tree
get_decl() const;
// Set the function decl to hold a tree of the function code.
// Set the function decl to hold a backend representation of the function
// code.
void
build_tree(Gogo*, Named_object*);
build(Gogo*, Named_object*);
// Get the value to return when not explicitly specified. May also
// add statements to execute first to STMT_LIST.
tree
return_value(Gogo*, Named_object*, Location, tree* stmt_list) const;
// Get the statement that assigns values to this function's result struct.
Bstatement*
return_value(Gogo*, Named_object*, Location) const;
// Get a tree for the variable holding the defer stack.
Expression*
......@@ -1151,14 +1121,8 @@ class Function
// Type for mapping from label names to Label objects.
typedef Unordered_map(std::string, Label*) Labels;
tree
make_receiver_parm_decl(Gogo*, Named_object*, tree);
tree
copy_parm_to_heap(Gogo*, Named_object*, tree);
void
build_defer_wrapper(Gogo*, Named_object*, tree*, tree*);
build_defer_wrapper(Gogo*, Named_object*, Bstatement**, Bstatement**);
typedef std::vector<std::pair<Named_object*,
Location> > Closure_fields;
......@@ -1531,16 +1495,16 @@ class Variable
get_backend_variable(Gogo*, Named_object*, const Package*,
const std::string&);
// Get the initial value of the variable as a tree. This may only
// Get the initial value of the variable. This may only
// be called if has_pre_init() returns false.
tree
get_init_tree(Gogo*, Named_object* function);
Bexpression*
get_init(Gogo*, Named_object* function);
// Return a series of statements which sets the value of the
// variable in DECL. This should only be called is has_pre_init()
// returns true. DECL may be NULL for a sink variable.
tree
get_init_block(Gogo*, Named_object* function, tree decl);
Bstatement*
get_init_block(Gogo*, Named_object* function, Bvariable* decl);
// Export the variable.
void
......
......@@ -2955,7 +2955,7 @@ Parse::create_closure(Named_object* function, Enclosing_vars* enclosing_vars,
Struct_type* st = closure_var->var_value()->type()->deref()->struct_type();
Expression* cv = Expression::make_struct_composite_literal(st, initializer,
location);
return Expression::make_heap_composite(cv, location);
return Expression::make_heap_expression(cv, location);
}
// PrimaryExpr = Operand { Selector | Index | Slice | TypeGuard | Call } .
......@@ -3538,7 +3538,7 @@ Parse::unary_expr(bool may_be_sink, bool may_be_composite_lit,
expr = Expression::make_type(Type::make_pointer_type(expr->type()),
location);
else if (op == OPERATOR_AND && expr->is_composite_literal())
expr = Expression::make_heap_composite(expr, location);
expr = Expression::make_heap_expression(expr, location);
else if (op != OPERATOR_CHANOP)
expr = Expression::make_unary(op, expr, location);
else
......@@ -3765,7 +3765,8 @@ Parse::labeled_stmt(const std::string& label_name, Location location)
{
// Mark the label as used to avoid a useless error about an
// unused label.
label->set_is_used();
if (label != NULL)
label->set_is_used();
error_at(location, "missing statement after label");
this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON,
......
......@@ -142,11 +142,8 @@ DEF_GO_RUNTIME(SEND_SMALL, "__go_send_small", P3(TYPE, CHAN, UINT64), R0())
// Send a big value on a channel.
DEF_GO_RUNTIME(SEND_BIG, "__go_send_big", P3(TYPE, CHAN, POINTER), R0())
// Receive a small value from a channel.
DEF_GO_RUNTIME(RECEIVE_SMALL, "__go_receive_small", P2(TYPE, CHAN), R1(UINT64))
// Receive a big value from a channel.
DEF_GO_RUNTIME(RECEIVE_BIG, "__go_receive_big", P3(TYPE, CHAN, POINTER), R0())
// Receive a value from a channel.
DEF_GO_RUNTIME(RECEIVE, "__go_receive", P3(TYPE, CHAN, POINTER), R0())
// Receive a value from a channel returning whether it is closed.
DEF_GO_RUNTIME(CHANRECV2, "runtime.chanrecv2", P3(TYPE, CHAN, POINTER),
......@@ -208,7 +205,7 @@ DEF_GO_RUNTIME(RUNTIME_ERROR, "__go_runtime_error", P1(INT32), R0())
// Close.
DEF_GO_RUNTIME(CLOSE, "__go_close", P1(CHAN), R0())
DEF_GO_RUNTIME(CLOSE, "__go_builtin_close", P1(CHAN), R0())
// Copy.
......@@ -233,6 +230,11 @@ DEF_GO_RUNTIME(NEW_NOPOINTERS, "__go_new_nopointers", P1(UINTPTR), R1(POINTER))
// Start a new goroutine.
DEF_GO_RUNTIME(GO, "__go_go", P2(FUNC_PTR, POINTER), R0())
// Get the function closure.
DEF_GO_RUNTIME(GET_CLOSURE, "__go_get_closure", P0(), R1(POINTER))
// Set the function closure.
DEF_GO_RUNTIME(SET_CLOSURE, "__go_set_closure", P1(POINTER), R0())
// Defer a function.
DEF_GO_RUNTIME(DEFER, "__go_defer", P3(BOOLPTR, FUNC_PTR, POINTER), R0())
......@@ -270,7 +272,7 @@ DEF_GO_RUNTIME(IFACEI2T2, "runtime.ifaceI2T2", P3(TYPE, IFACE, POINTER),
// A type assertion from one interface type to another. This is
// used for a type assertion.
DEF_GO_RUNTIME(ASSERT_INTERFACE, "__go_assert_interface", P2(TYPE, TYPE), R0())
DEF_GO_RUNTIME(ASSERT_INTERFACE, "__go_assert_interface", P2(TYPE, TYPE), R1(POINTER))
// Convert one interface type to another. This is used for an
// assignment.
......
......@@ -264,8 +264,7 @@ Variable_declaration_statement::do_get_backend(Translate_context* context)
Variable* var = this->var_->var_value();
Bvariable* bvar = this->var_->get_backend_variable(context->gogo(),
context->function());
tree init = var->get_init_tree(context->gogo(), context->function());
Bexpression* binit = init == NULL ? NULL : tree_to_expr(init);
Bexpression* binit = var->get_init(context->gogo(), context->function());
if (!var->is_in_heap())
{
......@@ -638,13 +637,17 @@ Assignment_statement::do_check_types(Gogo*)
Bstatement*
Assignment_statement::do_get_backend(Translate_context* context)
{
tree rhs_tree = this->rhs_->get_tree(context);
if (this->lhs_->is_sink_expression())
return context->backend()->expression_statement(tree_to_expr(rhs_tree));
{
tree rhs_tree = this->rhs_->get_tree(context);
return context->backend()->expression_statement(tree_to_expr(rhs_tree));
}
tree lhs_tree = this->lhs_->get_tree(context);
rhs_tree = Expression::convert_for_assignment(context, this->lhs_->type(),
this->rhs_->type(), rhs_tree,
this->location());
Expression* rhs =
Expression::convert_for_assignment(context->gogo(), this->lhs_->type(),
this->rhs_, this->location());
tree rhs_tree = rhs->get_tree(context);
return context->backend()->assignment_statement(tree_to_expr(lhs_tree),
tree_to_expr(rhs_tree),
this->location());
......@@ -2187,7 +2190,7 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function,
location);
// Allocate the initialized struct on the heap.
constructor = Expression::make_heap_composite(constructor, location);
constructor = Expression::make_heap_expression(constructor, location);
// Look up the thunk.
Named_object* named_thunk = gogo->lookup(thunk_name, NULL);
......
......@@ -3075,34 +3075,6 @@ String_type::do_get_backend(Gogo* gogo)
return backend_string_type;
}
// Return a tree for the length of STRING.
tree
String_type::length_tree(Gogo*, tree string)
{
tree string_type = TREE_TYPE(string);
go_assert(TREE_CODE(string_type) == RECORD_TYPE);
tree length_field = DECL_CHAIN(TYPE_FIELDS(string_type));
go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(length_field)),
"__length") == 0);
return fold_build3(COMPONENT_REF, TREE_TYPE(length_field), string,
length_field, NULL_TREE);
}
// Return a tree for a pointer to the bytes of STRING.
tree
String_type::bytes_tree(Gogo*, tree string)
{
tree string_type = TREE_TYPE(string);
go_assert(TREE_CODE(string_type) == RECORD_TYPE);
tree bytes_field = TYPE_FIELDS(string_type);
go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(bytes_field)),
"__data") == 0);
return fold_build3(COMPONENT_REF, TREE_TYPE(bytes_field), string,
bytes_field, NULL_TREE);
}
// The type descriptor for the string type.
Expression*
......@@ -4916,9 +4888,8 @@ Struct_type::method_function(const std::string& name, bool* is_ambiguous) const
// the interface INTERFACE. IS_POINTER is true if this is for a
// pointer to THIS.
tree
Struct_type::interface_method_table(Gogo* gogo,
const Interface_type* interface,
Expression*
Struct_type::interface_method_table(Interface_type* interface,
bool is_pointer)
{
std::pair<Struct_type*, Struct_type::Struct_method_table_pair*>
......@@ -4937,7 +4908,7 @@ Struct_type::interface_method_table(Gogo* gogo,
ins.first->second = smtp;
}
return Type::interface_method_table(gogo, this, interface, is_pointer,
return Type::interface_method_table(this, interface, is_pointer,
&smtp->first, &smtp->second);
}
......@@ -8198,13 +8169,12 @@ Named_type::method_function(const std::string& name, bool* is_ambiguous) const
// the interface INTERFACE. IS_POINTER is true if this is for a
// pointer to THIS.
tree
Named_type::interface_method_table(Gogo* gogo, const Interface_type* interface,
bool is_pointer)
Expression*
Named_type::interface_method_table(Interface_type* interface, bool is_pointer)
{
return Type::interface_method_table(gogo, this, interface, is_pointer,
&this->interface_method_tables_,
&this->pointer_interface_method_tables_);
return Type::interface_method_table(this, interface, is_pointer,
&this->interface_method_tables_,
&this->pointer_interface_method_tables_);
}
// Return whether a named type has any hidden fields.
......@@ -9385,9 +9355,9 @@ Type::method_function(const Methods* methods, const std::string& name,
// Return a pointer to the interface method table for TYPE for the
// interface INTERFACE.
tree
Type::interface_method_table(Gogo* gogo, Type* type,
const Interface_type *interface,
Expression*
Type::interface_method_table(Type* type,
Interface_type *interface,
bool is_pointer,
Interface_method_tables** method_tables,
Interface_method_tables** pointer_tables)
......@@ -9399,23 +9369,18 @@ Type::interface_method_table(Gogo* gogo, Type* type,
if (*pimt == NULL)
*pimt = new Interface_method_tables(5);
std::pair<const Interface_type*, tree> val(interface, NULL_TREE);
std::pair<Interface_type*, Expression*> val(interface, NULL);
std::pair<Interface_method_tables::iterator, bool> ins = (*pimt)->insert(val);
Location loc = Linemap::predeclared_location();
if (ins.second)
{
// This is a new entry in the hash table.
go_assert(ins.first->second == NULL_TREE);
ins.first->second = gogo->interface_method_table_for_type(interface,
type,
is_pointer);
go_assert(ins.first->second == NULL);
ins.first->second =
Expression::make_interface_mtable_ref(interface, type, is_pointer, loc);
}
tree decl = ins.first->second;
if (decl == error_mark_node)
return error_mark_node;
go_assert(decl != NULL_TREE && TREE_CODE(decl) == VAR_DECL);
return build_fold_addr_expr(decl);
return Expression::make_unary(OPERATOR_AND, ins.first->second, loc);
}
// Look for field or method NAME for TYPE. Return an Expression for
......
......@@ -1019,14 +1019,14 @@ class Type
// A mapping from interfaces to the associated interface method
// tables for this type. This maps to a decl.
typedef Unordered_map_hash(const Interface_type*, tree, Type_hash_identical,
typedef Unordered_map_hash(Interface_type*, Expression*, Type_hash_identical,
Type_identical) Interface_method_tables;
// Return a pointer to the interface method table for TYPE for the
// interface INTERFACE.
static tree
interface_method_table(Gogo* gogo, Type* type,
const Interface_type *interface, bool is_pointer,
static Expression*
interface_method_table(Type* type,
Interface_type *interface, bool is_pointer,
Interface_method_tables** method_tables,
Interface_method_tables** pointer_tables);
......@@ -1688,14 +1688,6 @@ class String_type : public Type
: Type(TYPE_STRING)
{ }
// Return a tree for the length of STRING.
static tree
length_tree(Gogo*, tree string);
// Return a tree which points to the bytes of STRING.
static tree
bytes_tree(Gogo*, tree string);
protected:
bool
do_has_pointer() const
......@@ -2205,9 +2197,8 @@ class Struct_type : public Type
// the interface INTERFACE. If IS_POINTER is true, set the type
// descriptor to a pointer to this type, otherwise set it to this
// type.
tree
interface_method_table(Gogo*, const Interface_type* interface,
bool is_pointer);
Expression*
interface_method_table(Interface_type* interface, bool is_pointer);
// Traverse just the field types of a struct type.
int
......@@ -2946,9 +2937,8 @@ class Named_type : public Type
// the interface INTERFACE. If IS_POINTER is true, set the type
// descriptor to a pointer to this type, otherwise set it to this
// type.
tree
interface_method_table(Gogo*, const Interface_type* interface,
bool is_pointer);
Expression*
interface_method_table(Interface_type* interface, bool is_pointer);
// Whether this type has any hidden fields.
bool
......
......@@ -483,31 +483,10 @@ __go_send_big(ChanType *t, Hchan* c, byte* p)
runtime_chansend(t, c, p, nil, runtime_getcallerpc(&t));
}
// The compiler generates a call to __go_receive_small to receive a
// value 8 bytes or smaller.
uint64
__go_receive_small(ChanType *t, Hchan* c)
{
union {
byte b[sizeof(uint64)];
uint64 v;
} u;
byte *p;
u.v = 0;
#ifndef WORDS_BIGENDIAN
p = u.b;
#else
p = u.b + sizeof(uint64) - t->__element_type->__size;
#endif
runtime_chanrecv(t, c, p, nil, nil);
return u.v;
}
// The compiler generates a call to __go_receive_big to receive a
// value larger than 8 bytes.
// The compiler generates a call to __go_receive to receive a
// value from a channel.
void
__go_receive_big(ChanType *t, Hchan* c, byte* p)
__go_receive(ChanType *t, Hchan* c, byte* p)
{
runtime_chanrecv(t, c, p, nil, nil);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment