mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-19 20:51:06 +08:00
re PR bootstrap/46776 (gogo-tree.cc uses TRAMPOLINE_ALIGNMENT and TRAMPOLINE_SIZE)
PR bootstrap/46776 * go-backend.c: New file. * go-c.h (go_type_alignment): Declare. (go_field_alignment, go_trampoline_info): Declare. * Make-lang.in (GO_OBJS): Add go/go-backend.o. (go/go-backend.o): New target. (go/go-lang.o): Make dependencies match source file. (go/expressions.o): Don't depend on $(TM_H) $(TM_P_H). (go/gogo-tree.o): Don't depend on $(TM_H). Remove #include "tm.h" from gofrontend/*.cc. From-SVN: r167451
This commit is contained in:
parent
43dcc93137
commit
3dcdeeb24b
@ -1,3 +1,15 @@
|
||||
2010-12-03 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
PR bootstrap/46776
|
||||
* go-backend.c: New file.
|
||||
* go-c.h (go_type_alignment): Declare.
|
||||
(go_field_alignment, go_trampoline_info): Declare.
|
||||
* Make-lang.in (GO_OBJS): Add go/go-backend.o.
|
||||
(go/go-backend.o): New target.
|
||||
(go/go-lang.o): Make dependencies match source file.
|
||||
(go/expressions.o): Don't depend on $(TM_H) $(TM_P_H).
|
||||
(go/gogo-tree.o): Don't depend on $(TM_H).
|
||||
|
||||
2010-12-03 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
* config-lang.in (build_by_default): Set to no.
|
||||
|
@ -48,6 +48,7 @@ GO_OBJS = \
|
||||
go/dataflow.o \
|
||||
go/export.o \
|
||||
go/expressions.o \
|
||||
go/go-backend.o \
|
||||
go/go-dump.o \
|
||||
go/go-lang.o \
|
||||
go/go.o \
|
||||
@ -215,10 +216,12 @@ GO_STATEMENTS_H = go/gofrontend/statements.h go/gofrontend/operator.h
|
||||
GO_EXPRESSIONS_H = go/gofrontend/expressions.h go/gofrontend/operator.h
|
||||
GO_IMPORT_H = go/gofrontend/import.h go/gofrontend/export.h
|
||||
|
||||
go/go-lang.o: go/go-lang.c $(GO_SYSTEM_H) coretypes.h opts.h $(TREE_H) \
|
||||
$(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h $(FLAGS_H) \
|
||||
convert.h langhooks.h $(LANGHOOKS_DEF_H) $(EXCEPT_H) $(TARGET_H) \
|
||||
$(DIAGNOSTIC_H) $(GO_C_H) gt-go-go-lang.h gtype-go.h
|
||||
go/go-backend.o: go/go-backend.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
||||
$(TREE_H) $(TM_H) $(TM_P_H)
|
||||
go/go-lang.o: go/go-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(OPTS_H) \
|
||||
$(TREE_H) $(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h \
|
||||
$(FLAGS_H) convert.h $(DIAGNOSTIC_H) langhooks.h $(LANGHOOKS_DEF_H) \
|
||||
$(EXCEPT_H) $(TARGET_H) $(GO_C_H) gt-go-go-lang.h gtype-go.h
|
||||
|
||||
GOINCLUDES = -I $(srcdir)/go -I $(srcdir)/go/gofrontend
|
||||
|
||||
@ -232,14 +235,14 @@ go/export.o: go/gofrontend/export.cc $(GO_SYSTEM_H) \
|
||||
$(GO_GOGO_H) $(GO_TYPES_H) $(GO_STATEMENTS_H) go/gofrontend/export.h
|
||||
go/expressions.o: go/gofrontend/expressions.cc $(GO_SYSTEM_H) $(TOPLEV_H) \
|
||||
intl.h $(TREE_H) $(GIMPLE_H) tree-iterator.h convert.h $(REAL_H) \
|
||||
realmpfr.h $(TM_H) $(TM_P_H) $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) \
|
||||
realmpfr.h $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) \
|
||||
go/gofrontend/export.h $(GO_IMPORT_H) $(GO_STATEMENTS_H) $(GO_LEX_H) \
|
||||
$(GO_EXPRESSIONS_H)
|
||||
go/go.o: go/gofrontend/go.cc $(GO_SYSTEM_H) $(GO_C_H) $(GO_LEX_H) \
|
||||
$(GO_PARSE_H) $(GO_GOGO_H)
|
||||
go/go-dump.o: go/gofrontend/go-dump.cc $(GO_SYSTEM_H) $(GO_C_H) \
|
||||
go/gofrontend/go-dump.h
|
||||
go/gogo-tree.o: go/gofrontend/gogo-tree.cc $(GO_SYSTEM_H) $(TM_H) $(TOPLEV_H) \
|
||||
go/gogo-tree.o: go/gofrontend/gogo-tree.cc $(GO_SYSTEM_H) $(TOPLEV_H) \
|
||||
$(TREE_H) $(GIMPLE_H) tree-iterator.h $(CGRAPH_H) langhooks.h \
|
||||
convert.h output.h $(DIAGNOSTIC_H) $(RTL_H) $(GO_TYPES_H) \
|
||||
$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) $(GO_GOGO_H)
|
||||
|
72
gcc/go/go-backend.c
Normal file
72
gcc/go/go-backend.c
Normal file
@ -0,0 +1,72 @@
|
||||
/* go-backend.c -- Go frontend interface to gcc backend.
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 3, or (at your option) any later
|
||||
version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "tree.h"
|
||||
#include "tm.h"
|
||||
#include "tm_p.h"
|
||||
|
||||
#include "go-c.h"
|
||||
|
||||
/* This file holds all the cases where the Go frontend needs
|
||||
information from gcc's backend. */
|
||||
|
||||
/* Return the alignment in bytes of a value of type T. */
|
||||
|
||||
unsigned int
|
||||
go_type_alignment (tree t)
|
||||
{
|
||||
return TYPE_ALIGN_UNIT (t);
|
||||
}
|
||||
|
||||
/* Return the alignment in bytes of a struct field of type T. */
|
||||
|
||||
unsigned int
|
||||
go_field_alignment (tree t)
|
||||
{
|
||||
unsigned int v;
|
||||
|
||||
v = TYPE_ALIGN (t);
|
||||
|
||||
#ifdef BIGGEST_FIELD_ALIGNMENT
|
||||
if (v > BIGGEST_FIELD_ALIGNMENT)
|
||||
v = BIGGEST_FIELD_ALIGNMENT;
|
||||
#endif
|
||||
|
||||
#ifdef ADJUST_FIELD_ALIGN
|
||||
{
|
||||
tree field;
|
||||
field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL, t);
|
||||
v = ADJUST_FIELD_ALIGN (field, v);
|
||||
}
|
||||
#endif
|
||||
|
||||
return v / BITS_PER_UNIT;
|
||||
}
|
||||
|
||||
/* Return the size and alignment of a trampoline. */
|
||||
|
||||
void
|
||||
go_trampoline_info (unsigned int *size, unsigned int *alignment)
|
||||
{
|
||||
*size = TRAMPOLINE_SIZE;
|
||||
*alignment = TRAMPOLINE_ALIGNMENT;
|
||||
}
|
@ -59,6 +59,12 @@ extern void go_preserve_from_gc (tree);
|
||||
|
||||
extern const char *go_localize_identifier (const char*);
|
||||
|
||||
extern unsigned int go_type_alignment (tree);
|
||||
|
||||
extern unsigned int go_field_alignment (tree);
|
||||
|
||||
extern void go_trampoline_info (unsigned int *size, unsigned int *alignment);
|
||||
|
||||
#if defined(__cplusplus) && !defined(ENABLE_BUILD_WITH_CXX)
|
||||
} /* End extern "C". */
|
||||
#endif
|
||||
|
@ -21,8 +21,6 @@ extern "C"
|
||||
#include "convert.h"
|
||||
#include "real.h"
|
||||
#include "realmpfr.h"
|
||||
#include "tm.h"
|
||||
#include "tm_p.h"
|
||||
|
||||
#ifndef ENABLE_BUILD_WITH_CXX
|
||||
}
|
||||
@ -6737,25 +6735,14 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant,
|
||||
}
|
||||
else if (this->code_ == BUILTIN_ALIGNOF)
|
||||
{
|
||||
val_long = TYPE_ALIGN(arg_type_tree);
|
||||
if (arg->field_reference_expression() != NULL)
|
||||
if (arg->field_reference_expression() == NULL)
|
||||
val_long = go_type_alignment(arg_type_tree);
|
||||
else
|
||||
{
|
||||
// Calling unsafe.Alignof(s.f) returns the alignment of
|
||||
// the type of f when it is used as a field in a struct.
|
||||
#ifdef BIGGEST_FIELD_ALIGNMENT
|
||||
if (val_long > BIGGEST_FIELD_ALIGNMENT)
|
||||
val_long = BIGGEST_FIELD_ALIGNMENT;
|
||||
#endif
|
||||
#ifdef ADJUST_FIELD_ALIGN
|
||||
// A separate declaration avoids a warning promoted to
|
||||
// an error if ADJUST_FIELD_ALIGN ignores FIELD.
|
||||
tree field;
|
||||
field = build_decl(UNKNOWN_LOCATION, FIELD_DECL, NULL,
|
||||
arg_type_tree);
|
||||
val_long = ADJUST_FIELD_ALIGN(field, val_long);
|
||||
#endif
|
||||
val_long = go_field_alignment(arg_type_tree);
|
||||
}
|
||||
val_long /= BITS_PER_UNIT;
|
||||
}
|
||||
else
|
||||
gcc_unreachable();
|
||||
@ -12033,26 +12020,11 @@ Type_info_expression::do_get_tree(Translate_context* context)
|
||||
TYPE_SIZE_UNIT(type_tree));
|
||||
else
|
||||
{
|
||||
unsigned HOST_WIDE_INT val;
|
||||
unsigned int val;
|
||||
if (this->type_info_ == TYPE_INFO_ALIGNMENT)
|
||||
val = TYPE_ALIGN_UNIT(type_tree);
|
||||
val = go_type_alignment(type_tree);
|
||||
else
|
||||
{
|
||||
gcc_assert(this->type_info_ == TYPE_INFO_FIELD_ALIGNMENT);
|
||||
val = TYPE_ALIGN(type_tree);
|
||||
#ifdef BIGGEST_FIELD_ALIGMENT
|
||||
if (val > BIGGEST_FIELD_ALIGNMENT)
|
||||
val = BIGGEST_FIELD_ALIGNMENT;
|
||||
#endif
|
||||
#ifdef ADJUST_FIELD_ALIGN
|
||||
{
|
||||
tree f = build_decl(UNKNOWN_LOCATION, FIELD_DECL, NULL, type_tree);
|
||||
val = ADJUST_FIELD_ALIGN(f, val);
|
||||
}
|
||||
#endif
|
||||
val /= BITS_PER_UNIT;
|
||||
}
|
||||
|
||||
val = go_field_alignment(type_tree);
|
||||
return build_int_cstu(val_type_tree, val);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "tm.h"
|
||||
#include "toplev.h"
|
||||
#include "tree.h"
|
||||
#include "gimple.h"
|
||||
@ -3048,8 +3047,9 @@ Gogo::trampoline_type_tree()
|
||||
static tree type_tree;
|
||||
if (type_tree == NULL_TREE)
|
||||
{
|
||||
unsigned int align = TRAMPOLINE_ALIGNMENT;
|
||||
unsigned int size = TRAMPOLINE_SIZE;
|
||||
unsigned int size;
|
||||
unsigned int align;
|
||||
go_trampoline_info(&size, &align);
|
||||
tree t = build_index_type(build_int_cst(integer_type_node, size - 1));
|
||||
t = build_array_type(char_type_node, t);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user