diff options
author | Ian Lance Taylor <iant@google.com> | 2010-12-04 01:47:21 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-04 01:47:21 +0000 |
commit | 3dcdeeb24bb56e82edc9c6a136028df504ba1d1e (patch) | |
tree | c171c12e8ffacae44c074e5a825254f5a831b6e5 /gcc | |
parent | 43dcc93137e15a6dd85d73d869764dafcc52fb67 (diff) | |
download | gcc-3dcdeeb24bb56e82edc9c6a136028df504ba1d1e.zip gcc-3dcdeeb24bb56e82edc9c6a136028df504ba1d1e.tar.gz gcc-3dcdeeb24bb56e82edc9c6a136028df504ba1d1e.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/go/Make-lang.in | 15 | ||||
-rw-r--r-- | gcc/go/go-backend.c | 72 | ||||
-rw-r--r-- | gcc/go/go-c.h | 6 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 42 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo-tree.cc | 6 |
6 files changed, 109 insertions, 44 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index b96f506..b68f4bb 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,5 +1,17 @@ 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. 2010-12-02 Ian Lance Taylor <iant@google.com> diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in index 971490c..fc981d4 100644 --- a/gcc/go/Make-lang.in +++ b/gcc/go/Make-lang.in @@ -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) diff --git a/gcc/go/go-backend.c b/gcc/go/go-backend.c new file mode 100644 index 0000000..15986dc --- /dev/null +++ b/gcc/go/go-backend.c @@ -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; +} diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h index 2075494..19d5c05 100644 --- a/gcc/go/go-c.h +++ b/gcc/go/go-c.h @@ -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 diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index f35b3639..0387ee4 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -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); } } diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index 755a0e9..41e621e 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -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); |