Patchwork Go patch committed: Remove #include "tm.h" from gofrontend

login
register
mail settings
Submitter Ian Taylor
Date Dec. 4, 2010, 1:48 a.m.
Message ID <mcry686xq8t.fsf@google.com>
Download mbox | patch
Permalink /patch/74231/
State New
Headers show

Comments

Ian Taylor - Dec. 4, 2010, 1:48 a.m.
This patch removes the two uses of #include "tm.h" from the Go frontend
proper.  This fixes PR bootstrap/46776.  Committed to mainline.

Ian


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).

Patch

Index: Make-lang.in
===================================================================
--- Make-lang.in	(revision 167407)
+++ Make-lang.in	(working copy)
@@ -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/statemen
 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 $(G
 	$(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)
Index: gofrontend/expressions.cc
===================================================================
--- gofrontend/expressions.cc	(revision 167407)
+++ gofrontend/expressions.cc	(working copy)
@@ -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_cons
 	}
       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(Transl
 			    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);
     }
 }
Index: gofrontend/gogo-tree.cc
===================================================================
--- gofrontend/gogo-tree.cc	(revision 167407)
+++ gofrontend/gogo-tree.cc	(working copy)
@@ -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);
 
Index: go-c.h
===================================================================
--- go-c.h	(revision 167407)
+++ go-c.h	(working copy)
@@ -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
Index: go-backend.c
===================================================================
--- go-backend.c	(revision 0)
+++ go-backend.c	(revision 0)
@@ -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;
+}