This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

An i960-*-elf configuration



I've already submitted patches to ian@cygnus.com for a basic i960-*-elf
binutils.  Here's patches for the non-generated files in egcs (from a recent
cvs version).

The current_function_calls_alloca patch is a fix.  The unpatched compiler
incorrectly does tail call-to-branch optimisation (with -O2) on functions
that call alloca().  The patch to gcc/config/i960/t-960bare is also a fix
(to stop the build trying to test a libgcc1 that it explicitly doesn't
build).

The following gcc/config/i960/i960-elf.h is, hopefully, the minimum
necessary from gcc/config/svr4.h to get elf working with the .type and .size
directives.  Other configurations should be entirely unaffected.

/* Definitions for generic i960-elf with some SVR4-style symbol information.

   Copyright (C) 1998 Free Software Foundation, Inc.
   Contributed by Madge Networks

This file is part of GNU CC.

GNU CC 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.

GNU CC 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 GNU CC; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */

#include "i960/i960-coff.h"

#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP

#define CTORS_SECTION_ASM_OP	".section\t.ctors,\"a\""
#define DTORS_SECTION_ASM_OP	".section\t.dtors,\"a\""


/* begin cribbed from svr4.h */

/* Define the strings used for the special svr4 .type and .size directives.
   These strings generally do not vary from one system running svr4 to
   another, but if a given system (e.g. m88k running svr) needs to use
   different pseudo-op names for these, they may be overridden in the
   file which includes this one.  */

#define TYPE_ASM_OP	".type"
#define SIZE_ASM_OP	".size"

/* This is how we tell the assembler that a symbol is weak.  */

#define ASM_WEAKEN_LABEL(FILE,NAME) \
  do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
       fputc ('\n', FILE); } while (0)

/* The following macro defines the format used to output the second
   operand of the .type assembler directive.  Different svr4 assemblers
   expect various different forms for this operand.  The one given here
   is just a default.  You may need to override it in your machine-
   specific tm.h file (depending upon the particulars of your assembler).
*/

#define TYPE_OPERAND_FMT	"@%s"

/* Write the extra assembler code needed to declare a function's result.
   Most svr4 assemblers don't require any special declaration of the
   result value, but there are exceptions.  */

#ifndef ASM_DECLARE_RESULT
#define ASM_DECLARE_RESULT(FILE, RESULT)
#endif

/* These macros generate the special .type and .size directives which
   are used to set the corresponding fields of the linker symbol table
   entries in an ELF object file under SVR4.  These macros also output
   the starting labels for the relevant functions/objects.  */

/* Write the extra assembler code needed to declare a function properly.
   Some svr4 assemblers need to also have something extra said about the
   function's return value.  We allow for that here.  */

#define SVR4_ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)		\
  do {									\
    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
    assemble_name (FILE, NAME);						\
    putc (',', FILE);							\
    fprintf (FILE, TYPE_OPERAND_FMT, "function");			\
    putc ('\n', FILE);							\
    ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));			\
    ASM_OUTPUT_LABEL(FILE, NAME);					\
  } while (0)

/* Write the extra assembler code needed to declare an object properly.  */

#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)			\
  do {									\
    fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);				\
    assemble_name (FILE, NAME);						\
    putc (',', FILE);							\
    fprintf (FILE, TYPE_OPERAND_FMT, "object");				\
    putc ('\n', FILE);							\
    size_directive_output = 0;						\
    if (!flag_inhibit_size_directive && DECL_SIZE (DECL))		\
      {									\
	size_directive_output = 1;					\
	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
	assemble_name (FILE, NAME);					\
	fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL)));	\
      }									\
    ASM_OUTPUT_LABEL(FILE, NAME);					\
  } while (0)

/* Output the size directive for a decl in rest_of_decl_compilation
   in the case where we did not do so before the initializer.
   Once we find the error_mark_node, we know that the value of
   size_directive_output was set
   by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */

#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)	 \
do {									 \
     char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);			 \
     if (!flag_inhibit_size_directive && DECL_SIZE (DECL)		 \
         && ! AT_END && TOP_LEVEL					 \
	 && DECL_INITIAL (DECL) == error_mark_node			 \
	 && !size_directive_output)					 \
       {								 \
	 size_directive_output = 1;					 \
	 fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);			 \
	 assemble_name (FILE, name);					 \
	 fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
       }								 \
   } while (0)

/* This is how to declare the size of a function.  */

#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)			\
  do {									\
    if (!flag_inhibit_size_directive)					\
      {									\
        char label[256];						\
	static int labelno;						\
	labelno++;							\
	ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);		\
	ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);		\
	fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);				\
	assemble_name (FILE, (FNAME));					\
        fprintf (FILE, ",");						\
	assemble_name (FILE, label);					\
        fprintf (FILE, "-");						\
	assemble_name (FILE, (FNAME));					\
	putc ('\n', FILE);						\
      }									\
  } while (0)

/* end cribbed from svr4.h */

/* merged from svr4.h */
#undef ASM_OUTPUT_ALIGNED_LOCAL

/* This says how to output an assembler line to define a local common
symbol.
   Output unpadded size, with request to linker to align as requested.
   0 size should not be possible here.  */

#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)  \
( fprintf (FILE, "\t%s\t ", TYPE_ASM_OP),	\
  assemble_name (FILE, NAME),			\
  putc (',', FILE),				\
  fprintf (FILE, TYPE_OPERAND_FMT, "object"),	\
  putc ('\n', FILE),				\
  fputs (".bss\t", (FILE)),			\
  assemble_name ((FILE), (NAME)),		\
  fprintf ((FILE), ",%d,%d\n", (SIZE),		\
	   (floor_log2 ((ALIGN) / BITS_PER_UNIT))))

/* end of i960/i960-elf.h */

diff -c3p -r /home/egcswork/latest/egcs/gcc/config/i960/i960.c
./gcc/config/i960/i960.c
*** /home/egcswork/latest/egcs/gcc/config/i960/i960.c	Wed Sep  2 11:13:22
1998
--- ./gcc/config/i960/i960.c	Thu Oct 29 13:32:32 1998
*************** i960_function_name_declare (file, name, 
*** 1037,1043 ****
    /* Even if nobody uses extra parms, can't have leafproc or tail calls if
       argblock, because argblock uses g14 implicitly.  */
  
!   if (current_function_args_size != 0 || VARARGS_STDARG_FUNCTION (fndecl))
      {
        tail_call_ok = 0;
        leaf_proc_ok = 0;
--- 1037,1044 ----
    /* Even if nobody uses extra parms, can't have leafproc or tail calls if
       argblock, because argblock uses g14 implicitly.  */
  
!   if (current_function_args_size != 0 || VARARGS_STDARG_FUNCTION (fndecl)
!       || current_function_calls_alloca)
      {
        tail_call_ok = 0;
        leaf_proc_ok = 0;
*************** i960_function_name_declare (file, name, 
*** 1144,1152 ****
--- 1145,1178 ----
        fprintf (file, "\t.leafproc\t");
        assemble_name (file, name);
        fprintf (file, ",%s.lf\n", (name[0] == '*' ? &name[1] : name));
+ #ifdef SVR4_ASM_DECLARE_FUNCTION_NAME
+       SVR4_ASM_DECLARE_FUNCTION_NAME(file, (name[0] == '*' ? &name[1] :
name), fndecl);
+ #else
        ASM_OUTPUT_LABEL (file, name);
+ #endif
        fprintf (file, "\tlda    LR%d,g14\n", ret_label);
+ 
+ #ifdef TYPE_ASM_OP
+       fprintf (file, "\t%s\t ", TYPE_ASM_OP);
+       assemble_name (file, (name[0] == '*' ? &name[1] : name));
+       fputs (".lf,", file);
+       fprintf (file, TYPE_OPERAND_FMT, "function");
+       putc ('\n', file);
+       ASM_DECLARE_RESULT (file, DECL_RESULT (fndecl));
+       assemble_name (file, (name[0] == '*' ? &name[1] : name));
+       fputs (".lf:\n", file);
+ #else
        fprintf (file, "%s.lf:\n", (name[0] == '*' ? &name[1] : name));
+ #endif
+ 
+ #ifdef ASM_WEAKEN_LABEL
+       if (DECL_WEAK (fndecl))
+       {
+ 	  fputs ("\t.weak\t", file);
+ 	  assemble_name (file, (name[0] == '*' ? &name[1] : name));
+ 	  fputs (".lf\n", file);
+       }
+ #endif
        fprintf (file, "\tmov    g14,g%d\n", i960_leaf_ret_reg);
  
        if (TARGET_C_SERIES)
*************** i960_function_name_declare (file, name, 
*** 1162,1168 ****
--- 1188,1198 ----
      }
    else
      {
+ #ifdef SVR4_ASM_DECLARE_FUNCTION_NAME
+       SVR4_ASM_DECLARE_FUNCTION_NAME(file, (name[0] == '*' ? &name[1] :
name), fndecl);
+ #else
        ASM_OUTPUT_LABEL (file, name);
+ #endif
        i960_last_insn_type = I_TYPE_CTRL; 
      }
  }
diff -c3p -r /home/egcswork/latest/egcs/gcc/config/i960/t-960bare
./gcc/config/i960/t-960bare
*** /home/egcswork/latest/egcs/gcc/config/i960/t-960bare	Mon Aug 11
16:57:28 1997
--- ./gcc/config/i960/t-960bare	Thu Oct 29 13:30:51 1998
***************
*** 1,5 ****
--- 1,6 ----
  LIBGCC1 =
  CROSS_LIBGCC1 =
+ LIBGCC1_TEST =
  
  LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c xp-bit.c
  
diff -c3p -r /home/egcswork/latest/egcs/gcc/configure.in ./gcc/configure.in
*** /home/egcswork/latest/egcs/gcc/configure.in	Thu Oct 29 13:20:03 1998
--- ./gcc/configure.in	Thu Oct 29 13:29:52 1998
*************** changequote([,])dnl
*** 1566,1571 ****
--- 1566,1576 ----
  		tmake_file=i960/t-960bare
  		use_collect2=yes
  		;;
+ 	i960-*-elf*)
+ 		tm_file="${tm_file} i960/i960-elf.h"
+ 		tmake_file=i960/t-960bare
+ 		use_collect2=yes
+ 		;;
  	i960-*-rtems)
  		tmake_file="i960/t-960bare t-rtems"
  		tm_file="${tm_file} dbxcoff.h i960/rtems.h"

-- 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]