[llvm-commits] llvm-gcc4: stubs for non C-like languages

Duncan Sands baldrick at free.fr
Wed Jan 17 13:06:52 PST 2007


Apple's gcc modifications require the existence of routines like
iasm_addr and build_modify_expr (see the patch for an exhaustive
list) that are only defined by the C-like front-ends (C, C++, ObjC).
Trying to build other language front-ends fails at link-time because
of the lack of these routines.  Rather than adding stubs to each and
every front-end (I see someone made a partial start on this), this
patch introduces a new file stub-c.c that contains all the missing
stubs.  Front-ends can then just link with it.  Later patches rip
out any stubs already defined in the various non C-like front-ends,
and cause them to link with stub-c.o instead.  The only complication
comes from java.  Java defines some of the missing routines (serious
definitions - not stubs) but not all of them.  Because of this I
made all the stubs into weak symbols, so the java routines will
override the corresponding stubs.  Hopefully this patch will not
cause problems for non x86 platforms, but I'm not promising anything
since I only tested it on x86.

Index: gcc.llvm.master/gcc/Makefile.in
===================================================================
--- gcc.llvm.master.orig/gcc/Makefile.in	2007-01-17 21:41:50.000000000 +0100
+++ gcc.llvm.master/gcc/Makefile.in	2007-01-17 21:46:11.000000000 +0100
@@ -1622,6 +1622,8 @@
     c-objc-common.h c-pragma.h
 stub-objc.o : stub-objc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
     $(GGC_H) $(C_COMMON_H)
+stub-c.o : stub-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
+    $(GGC_H) $(C_COMMON_H)
 c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(RTL_H) debug.h $(C_TREE_H) $(C_COMMON_H) real.h c-incpath.h cppdefault.h \
     $(C_PRAGMA_H) input.h intl.h $(FLAGS_H) toplev.h output.h \
Index: gcc.llvm.master/gcc/stub-c.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ gcc.llvm.master/gcc/stub-c.c	2007-01-17 21:46:11.000000000 +0100
@@ -0,0 +1,158 @@
+/* Stub functions for C language routines that are referenced
+   from the back-end.
+   Copyright (C) 1991, 1995, 1997, 1998,
+   1999, 2000, 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "c-common.h"
+
+#define ATTRIBUTE_WEAK	__attribute__ ((__weak__))
+
+enum iasm_states iasm_state ATTRIBUTE_WEAK;
+int iasm_in_operands ATTRIBUTE_WEAK;
+int flag_iasm_blocks ATTRIBUTE_WEAK;
+
+
+tree iasm_addr (tree) ATTRIBUTE_WEAK;
+
+tree iasm_addr (tree e ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+tree iasm_build_bracket (tree, tree) ATTRIBUTE_WEAK;
+
+tree iasm_build_bracket (tree v1 ATTRIBUTE_UNUSED,
+			 tree v2 ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+void iasm_force_constraint (const char *, iasm_md_extra_info *) ATTRIBUTE_WEAK;
+
+void iasm_force_constraint (const char *c ATTRIBUTE_UNUSED,
+			    iasm_md_extra_info *e ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+void iasm_get_register_var (tree, const char *, char *, unsigned, bool,
+			    iasm_md_extra_info *) ATTRIBUTE_WEAK;
+
+void iasm_get_register_var (tree var ATTRIBUTE_UNUSED,
+			    const char *modifier ATTRIBUTE_UNUSED,
+			    char *buf ATTRIBUTE_UNUSED,
+			    unsigned argnum ATTRIBUTE_UNUSED,
+			    bool must_be_reg ATTRIBUTE_UNUSED,
+			    iasm_md_extra_info *e ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+bool iasm_is_pseudo (const char *) ATTRIBUTE_WEAK;
+
+bool iasm_is_pseudo (const char *opcode ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+void iasm_print_operand (char *, tree, unsigned, tree *, bool, bool,
+			 iasm_md_extra_info *) ATTRIBUTE_WEAK;
+
+void iasm_print_operand (char *buf ATTRIBUTE_UNUSED,
+			 tree arg ATTRIBUTE_UNUSED,
+			 unsigned argnum ATTRIBUTE_UNUSED,
+			 tree *uses ATTRIBUTE_UNUSED,
+			 bool must_be_reg ATTRIBUTE_UNUSED,
+			 bool must_not_be_reg ATTRIBUTE_UNUSED,
+			 iasm_md_extra_info *e ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+tree build_modify_expr (tree, enum tree_code, tree) ATTRIBUTE_WEAK;
+
+tree build_modify_expr (tree lhs ATTRIBUTE_UNUSED,
+			enum tree_code modifycode ATTRIBUTE_UNUSED,
+			tree rhs ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+tree decl_constant_value (tree) ATTRIBUTE_WEAK;
+
+tree decl_constant_value (tree decl ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+tree build_function_call (tree, tree) ATTRIBUTE_WEAK;
+
+tree build_function_call (tree function ATTRIBUTE_UNUSED,
+			  tree params ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+tree build_stmt (enum tree_code, ...) ATTRIBUTE_WEAK;
+
+tree build_stmt (enum tree_code code ATTRIBUTE_UNUSED, ...)
+{
+  gcc_assert(0);
+}
+
+
+tree lookup_name_two (tree, int) ATTRIBUTE_WEAK;
+
+tree lookup_name_two (tree name ATTRIBUTE_UNUSED,
+		      int prefer_type ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+tree pointer_int_sum (enum tree_code, tree, tree) ATTRIBUTE_WEAK;
+
+tree pointer_int_sum (enum tree_code resultcode ATTRIBUTE_UNUSED,
+		      tree ptrop ATTRIBUTE_UNUSED,
+		      tree intop ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}
+
+
+void store_init_value (tree, tree) ATTRIBUTE_WEAK;
+
+void store_init_value (tree decl ATTRIBUTE_UNUSED, tree init ATTRIBUTE_UNUSED)
+{
+  gcc_assert(0);
+}



More information about the llvm-commits mailing list