[lto] PATCH: Skeleton LTO front end

Mark Mitchell mark@codesourcery.com
Mon Jun 12 19:06:00 GMT 2006


This patch creates the LTO front end -- which does absolutely nothing
of any interest at this point.  This is just a skeleton.

The next steps will be:

1. Basic command-line processing so that we can specify the object
   files to read/optimize.

2. Locate DWARF information in ELF files.  (Presumably, this will be
   extended to other object formats later.)

3. Create a tree -- of some kind -- from the stored DWARF information.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2006-06-12  Mark Mitchell  <mark@codesourcery.com>

	* config-lang.in: New file.
	* Make-lang.in: Likewise.
	* lto-tree.h: Likewise.
	* lto-lang.c: Likewise.

Index: lto/Make-lang.in
===================================================================
--- lto/Make-lang.in	(revision 0)
+++ lto/Make-lang.in	(revision 0)
@@ -0,0 +1,79 @@
+# Top level -*- makefile -*- fragment for LTO
+#   Copyright (C) 2006
+#   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 2, 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 COPYING.  If not, write to
+#the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+#Boston, MA 02110-1301, USA.
+
+########################################################################
+# Variables
+########################################################################
+
+# The name of the LTO compiler.
+LTO_EXE = lto1$(exeext)
+# The LTO-specific object files inclued in $(LTO_EXE).
+LTO_OBJS = lto/lto-lang.o
+
+########################################################################
+# Rules
+########################################################################
+
+# These hooks are used by the main GCC Makefile.  Consult that
+# Makefile for documentation.
+
+lto.all.cross: 
+lto.start.encap: $(LTO_EXE)
+lto.rest.encap:
+lto.tags:
+lto.install-common:
+lto.install-man:
+lto.install-info:
+lto.dvi:
+lto.html:
+lto.uninstall:
+lto.info:
+lto.man:
+lto.srcextra:
+lto.srcman:
+lto.srcinfo:
+
+lto.mostlyclean:
+	rm -f $(LTO_OBJS) $(LTO_EXE)
+
+lto.clean:
+lto.distclean:
+lto.maintainer-clean:
+lto.stage1:
+lto.stage2:
+lto.stage3:
+lto.stage4:
+lto.stageprofile:
+lto.stagefeedback:
+
+# LTO rules.
+
+$(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIBDEPS)
+	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
+		$(LTO_OBJS) $(BACKEND) $(LIBS)
+
+########################################################################
+# Dependencies
+########################################################################
+
+lto/lto-lang.o: lto/lto-lang.c $(CONFIG_H) coretypes.h debug.h \
+	$(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(SYSTEM_H) \
+	lto/lto-tree.h gtype-lto.h
Index: lto/lto-tree.h
===================================================================
--- lto/lto-tree.h	(revision 0)
+++ lto/lto-tree.h	(revision 0)
@@ -0,0 +1,53 @@
+/* Language-dependent trees for LTO.
+   Copyright 2006 Free Software Foundation, Inc.
+   Contributed by CodeSourcery, 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 2, 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 COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+#ifndef GCC_LTO_TREE_H
+#define GCC_LTO_TREE_H
+
+struct lang_identifier GTY(())
+{
+};
+
+struct lang_decl GTY(())
+{
+};
+
+struct lang_type GTY(())
+{
+};
+
+struct language_function GTY(())
+{
+};
+
+enum lto_tree_node_structure_enum {
+  TS_LTO_GENERIC
+};
+
+union lang_tree_node GTY(
+ (desc ("lto_tree_node_structure (&%h)"),
+  chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
+{
+  union tree_node GTY ((tag ("TS_LTO_GENERIC"),
+			desc ("tree_node_structure (&%h)"))) generic;
+};
+
+#endif /* GCC_LTO_TREE_H */
Index: lto/config-lang.in
===================================================================
--- lto/config-lang.in	(revision 0)
+++ lto/config-lang.in	(revision 0)
@@ -0,0 +1,26 @@
+# Top level configure fragment for LTO
+#   Copyright (C) 2006
+#   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 2, 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 COPYING.  If not, write to
+#the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+#Boston, MA 02110-1301, USA.
+
+language="lto"
+compilers="lto1\$(exeext)"
+stagestuff="lto1\$(exeext)"
+
+gtfiles="\$(srcdir)/lto/lto-tree.h"
Index: lto/lto-lang.c
===================================================================
--- lto/lto-lang.c	(revision 0)
+++ lto/lto-lang.c	(revision 0)
@@ -0,0 +1,171 @@
+/* Language-dependent hooks for LTO.
+   Copyright 2006 Free Software Foundation, Inc.
+   Contributed by CodeSourcery, 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 2, 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 COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "langhooks.h"
+#include "langhooks-def.h"
+#include "debug.h"
+#include "lto-tree.h"
+
+/* Tables of information about tree codes.  */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+const enum tree_code_class tree_code_type[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+const unsigned char tree_code_length[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+const char *const tree_code_name[] = {
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Language hooks.  */
+
+static bool 
+lto_mark_addressable (tree t ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_type_for_mode (enum machine_mode mode ATTRIBUTE_UNUSED, 
+		   int unsigned_p ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_type_for_size (unsigned precision ATTRIBUTE_UNUSED, 
+		   int unsigned_p ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_unsigned_type (tree type ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_signed_type (tree type ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_signed_or_unsigned_type (int unsigned_p ATTRIBUTE_UNUSED,
+			     tree type ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static int
+lto_global_bindings_p (void) 
+{
+  gcc_unreachable ();
+}
+
+static void
+lto_insert_block (tree block ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_pushdecl (tree t ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_getdecls (void)
+{
+  gcc_unreachable ();
+}
+
+static void
+lto_write_globals (void)
+{
+  gcc_unreachable ();
+}
+
+static tree
+lto_builtin_function (const char *name ATTRIBUTE_UNUSED,
+		      tree type ATTRIBUTE_UNUSED,
+		      int function_code ATTRIBUTE_UNUSED,
+		      enum built_in_class bt_class ATTRIBUTE_UNUSED,
+		      const char *library_name ATTRIBUTE_UNUSED,
+		      tree attrs ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+#define LANG_HOOKS_MARK_ADDRESSABLE lto_mark_addressable
+#define LANG_HOOKS_TYPE_FOR_MODE lto_type_for_mode
+#define LANG_HOOKS_TYPE_FOR_SIZE lto_type_for_size
+#define LANG_HOOKS_UNSIGNED_TYPE lto_unsigned_type
+#define LANG_HOOKS_SIGNED_TYPE lto_signed_type
+#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE lto_signed_or_unsigned_type
+#undef LANG_HOOKS_GLOBAL_BINDINGS_P
+#define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p
+#undef LANG_HOOKS_INSERT_BLOCK
+#define LANG_HOOKS_INSERT_BLOCK lto_insert_block
+#undef LANG_HOOKS_PUSHDECL
+#define LANG_HOOKS_PUSHDECL lto_pushdecl
+#undef LANG_HOOKS_GETDECLS
+#define LANG_HOOKS_GETDECLS lto_getdecls
+#undef LANG_HOOKS_WRITE_GLOBALS
+#define LANG_HOOKS_WRITE_GLOBALS lto_write_globals
+#undef LANG_HOOKS_BUILTIN_FUNCTION
+#define LANG_HOOKS_BUILTIN_FUNCTION lto_builtin_function
+
+const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
+
+/* Language hooks that are not part of lang_hooks.  */
+
+tree
+convert (tree type ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
+{
+  gcc_unreachable ();
+}
+
+/* Tree walking support.  */
+
+static enum lto_tree_node_structure_enum
+lto_tree_node_structure (union lang_tree_node *t ATTRIBUTE_UNUSED)
+{
+  return TS_LTO_GENERIC;
+}
+
+#include "ggc.h"
+#include "gtype-lto.h"



More information about the Gcc-patches mailing list