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]

NetBSD sparc & sparc64 compiler descriptions.






hi folks.


this adds support for NetBSD/sparc ELF, including the ability to build
a SPARC_BI_ARCH compiler (disabled by default.)  i've tested this fairly
extensively and it seems to work for C and C++.  i'm also including my
sparc64 description, but i have not been able to build this due to libgcc
not building (the same fault also occurs with the generic `sparc64-elf'
target.)  it would be nice if the sparc64 one was also commited, but if
it must wait until it can be properly tested, that's OK.


i'm well aware that these files do not follow the new-style of listing
all #include'ed files in config.gcc, but this can not work easily with
the way SPARC_BI_ARCH is required by config/sparc/sparc.h.  this seems
to the way things are still done in config/sparc.


.mrg.


2001-07-31  matthew green  <mrg@eterna.com.au>

	* config.gcc (sparc-*-netbsd*elf*): New target.
	(sparc64-*-netbsd*): New target.
	* config/sparc/netbsd-elf-common.h: New file. Common parts of
	NetBSD/sparc & NetBSD/sparc64 compiler.
	* config/sparc/netbsd-elf.h: New file. Description for sparc-netbsdelf.
	* config/sparc/netbsd64.h: New file. Description for sparc64-netbsd.


Index: config.gcc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config.gcc,v
retrieving revision 1.75
diff -p -r1.75 config.gcc
*** config.gcc	2001/07/25 01:49:45	1.75
--- config.gcc	2001/07/31 08:42:58
*************** sparc-*-aout*)
*** 2827,2832 ****
--- 2827,2836 ----
  	tmake_file=sparc/t-sparcbare
  	tm_file="sparc/aout.h libgloss.h"
  	;;
+ sparc-*-netbsd*elf*)
+ 	tm_file=sparc/netbsd-elf.h
+ 	tmake_file=t-netbsd
+ 	;;
  sparc-*-netbsd*)
  	tm_file=sparc/netbsd.h
  	tmake_file=t-netbsd
*************** sparc64-*-linux*)		# 64-bit Sparc's runn
*** 3078,3083 ****
--- 3082,3991 ----
  		thread_file='posix'
  	fi
  	float_format=sparc
+ 	;;
+ sparc64-*-netbsd*)
+ 	tm_file=sparc/netbsd64.h
+ 	tmake_file=t-netbsd
  	;;
  strongarm-*-elf*)
  	tm_file=arm/strongarm-elf.h


--- start config/sparc/netbsd-elf-common.h ---
/* Common definitions of target machine for GNU compiler, for
   ELF on NetBSD/sparc and NetBSD/sparc64.
   Copyright (C) 2001 Free Software Foundation, Inc.
   Contributed by Matthew Green (mrg@eterna.com.au).

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.  */

/* Fix up CPP_SPEC.  */
#undef CPP_SPEC
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} \
%(cpp_cpu) %(cpp_arch) %(cpp_endian) %(cpp_subtarget)"

#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-D__sparc__ -D__NetBSD__ -D__ELF__ \
-Asystem=unix -Asystem=NetBSD"

#undef SIZE_TYPE
#define SIZE_TYPE "long unsigned int"

#undef PTRDIFF_TYPE
#define PTRDIFF_TYPE "long int"

#undef WCHAR_TYPE
#define WCHAR_TYPE "int"

#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 32

#undef WCHAR_UNSIGNED
#define WCHAR_UNSIGNED 0

#undef PREFERRED_DEBUGGING_TYPE
#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG

/* This is the char to use for continuation (in case we need to turn
   continuation back on).  */
#undef DBX_CONTIN_CHAR
#define DBX_CONTIN_CHAR '?'

#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(REGNO) \
  (TARGET_FLAT && REGNO == FRAME_POINTER_REGNUM ? 31 : REGNO)

/* This is how to output a definition of an internal numbered label where
   PREFIX is the class of label and NUM is the number within the class.  */

#undef  ASM_OUTPUT_INTERNAL_LABEL
#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)	\
  fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)

/* This is how to output a reference to an internal numbered label where
   PREFIX is the class of label and NUM is the number within the class.  */

#undef  ASM_OUTPUT_INTERNAL_LABELREF
#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM)	\
  fprintf (FILE, ".L%s%d", PREFIX, NUM)

/* This is how to store into the string LABEL
   the symbol_ref name of an internal numbered label where
   PREFIX is the class of label and NUM is the number within the class.
   This is suitable for output with `assemble_name'.  */

#undef  ASM_GENERATE_INTERNAL_LABEL
#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
  sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))

#undef USER_LABEL_PREFIX
#define USER_LABEL_PREFIX ""

#undef ASM_SPEC
#define ASM_SPEC "%{fpic:-K PIC} %{fPIC:-K PIC} %{V} %{v:%{!V:-V}} \
%{mlittle-endian:-EL} \
%(asm_cpu) %(asm_arch) \
"
  
/* Provide a LIB_SPEC appropriate for NetBSD.  Just select the appropriate
   libc, depending on whether we're doing profiling; if `-posix' is specified,
   link against the appropriate libposix first.  */
  
#undef LIB_SPEC
#define LIB_SPEC							\
  "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}}		\
 %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"

#undef STDC_0_IN_SYSTEM_HEADERS

/** We don't have the C++ support for this (yet). */
#undef DWARF2_UNWIND_INFO
#define DWARF2_UNWIND_INFO 0

/* XXX Redefine this; <sparc/sparc.h> mucks with it. */
#undef TARGET_VERSION
#define TARGET_VERSION fprintf (stderr, " (%s)", TARGET_NAME);

/*
 * Clean up afterwards generic SPARC ELF configuration.
 */

#undef MULDI3_LIBCALL
#undef DIVDI3_LIBCALL
#undef UDIVDI3_LIBCALL
#undef MODDI3_LIBCALL
#undef UMODDI3_LIBCALL
#undef INIT_SUBTARGET_OPTABS  
#define INIT_SUBTARGET_OPTABS  

/* Below here exists the merged NetBSD/sparc & NetBSD/sparc64 compiler
   description, allowing one to build 32 bit or 64 bit applications
   on either.  We define the sparc & sparc64 versions of things, and then
   based on SPARC_BI_ARCH, DEFAULT_ARCH32_P, and TARGET_CPU_DEFAULT,
   we choose the correct version.  */

/* Name the port(s).  */
#define TARGET_NAME64     "sparc64-netbsd"
#define TARGET_NAME32     "sparc-netbsdelf"

#undef CPP_SUBTARGET_SPEC64
#define CPP_SUBTARGET_SPEC64 "-D__sparc64__ -D__arch64__ -D__sparc_v9__"

#undef CPP_SUBTARGET_SPEC32
#define CPP_SUBTARGET_SPEC32 "-D__sparc"

#undef LINK_ARCH_SPEC64
#define LINK_ARCH_SPEC64 \
 "-m elf64_sparc \
  -Y P,/usr/lib/sparcv9 \
  %{assert*} %{R*} %{V} %{v:%{!V:-V}} \
  %{shared:-shared} \
  %{!shared: \
    -dp \
    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
    %{!static: \
      -dy %{rdynamic:-export-dynamic} \
      %{!dynamic-linker:-dynamic-linker /usr/libexec/sparcv9/ld.elf_so}} \
    %{static:-static}}"

#undef LINK_ARCH_SPEC32
#define LINK_ARCH_SPEC32 \
 "-m elf32_sparc \
  %{assert*} %{R*} %{V} %{v:%{!V:-V}} \
  %{shared:-shared} \
  %{!shared: \
    -dp \
    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
    %{!static: \
      -dy %{rdynamic:-export-dynamic} \
      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
    %{static:-static}}"

#undef STARTFILE_SPEC64
#define STARTFILE_SPEC64 \
 "%{!shared: \
     %{pg:/usr/lib/sparcv9/gcrt0%O%s} \
     %{!pg: \
        %{p:/usr/lib/sparcv9/gcrt0%O%s} \
        %{!p:/usr/lib/sparcv9/crt0%O%s}}} \
   %{!shared:/usr/lib/sparcv9/crtbegin%O%s} %{shared:/usr/lib/sparcv9/crtbeginS%O%s}"

#undef STARTFILE_SPEC32
#define STARTFILE_SPEC32 \
 "%{!shared: \
     %{pg:gcrt0%O%s} \
     %{!pg: \
        %{p:crt0%O%s} \
        %{!p:crt0%O%s}}} \
   %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"

#undef ENDFILE_SPEC64
#define ENDFILE_SPEC64 \
 "%{!shared:/usr/lib/sparcv9/crtend%O%s} %{shared:/usr/lib/sparcv9/crtendS%O%s}"

#undef ENDFILE_SPEC32
#define ENDFILE_SPEC32 \
 "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"

#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
/* A 64 bit v9 compiler with stack-bias,
   in a Medium/Low code model environment.  */

#undef TARGET_DEFAULT
#define TARGET_DEFAULT \
  (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
 + MASK_STACK_BIAS + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_LONG_DOUBLE_128)
#endif

#ifdef SPARC_BI_ARCH

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)

#undef MAX_LONG_DOUBLE_TYPE_SIZE
#define MAX_LONG_DOUBLE_TYPE_SIZE 128

#if defined(__arch64__) || defined(__LONG_DOUBLE_128__)
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
#else
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
#endif

#undef STARTFILE_SPEC
#if DEFAULT_ARCH32_P
#define STARTFILE_SPEC "\
%{m32:" STARTFILE_SPEC32 "} \
%{m64:" STARTFILE_SPEC64 "} \
%{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
#else
#define STARTFILE_SPEC "\
%{m32:" STARTFILE_SPEC32 "} \
%{m64:" STARTFILE_SPEC64 "} \
%{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
#endif

#undef ENDFILE_SPEC
#if DEFAULT_ARCH32_P
#define ENDFILE_SPEC "\
%{m32:" ENDFILE_SPEC32 "} \
%{m64:" ENDFILE_SPEC64 "} \
%{!m32:%{!m64:" ENDFILE_SPEC32 "}}"
#else
#define ENDFILE_SPEC "\
%{m32:" ENDFILE_SPEC32 "} \
%{m64:" ENDFILE_SPEC64 "} \
%{!m32:%{!m64:" ENDFILE_SPEC64 "}}"
#endif

#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
  { "link_arch32",       LINK_ARCH_SPEC32 },              \
  { "link_arch64",       LINK_ARCH_SPEC64 },              \
  { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },        \
  { "link_arch",         LINK_ARCH_SPEC },

#undef LINK_ARCH64_SPEC
#define LINK_ARCH64_SPEC LINK_ARCH_SPEC64

#define LINK_ARCH_SPEC "\
%{m32:%(link_arch32)} \
%{m64:%(link_arch64)} \
%{!m32:%{!m64:%(link_arch_default)}}"

#define LINK_ARCH_DEFAULT_SPEC \
(DEFAULT_ARCH32_P ? LINK_ARCH_SPEC32 : LINK_ARCH_SPEC64)

#undef  LINK_SPEC
#define LINK_SPEC "\
%(link_arch) \
%{mlittle-endian:-EL} \
"

#undef  CC1_SPEC
#if DEFAULT_ARCH32_P
#define CC1_SPEC "\
%{sun4:} %{target:} \
%{mcypress:-mcpu=cypress} \
%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
%{m64:-mptr64 -mcpu=ultrasparc -mstack-bias %{p*:-mcmodel=medlow} \
%{p:-mcmodel=medlow} } \
"
#else
#define CC1_SPEC "\
%{sun4:} %{target:} \
%{mcypress:-mcpu=cypress} \
%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
%{m32:-mptr32 -mcpu=cypress -mno-stack-bias} \
%{p*:-mcmodel=medlow} \
"
#endif

#if DEFAULT_ARCH32_P
#define MULTILIB_DEFAULTS { "m32" }
#else
#define MULTILIB_DEFAULTS { "m64" }
#endif

#undef CPP_SUBTARGET_SPEC
#define CPP_SUBTARGET_SPEC \
(DEFAULT_ARCH32_P ? "\
%{m64:" CPP_SUBTARGET_SPEC64 "}%{!m64:" CPP_SUBTARGET_SPEC32 "} \
" : "\
%{!m32:" CPP_SUBTARGET_SPEC64 "}%{m32:" CPP_SUBTARGET_SPEC32 "} \
")

/* Name the port. */
#undef TARGET_NAME
#define TARGET_NAME     (DEFAULT_ARCH32_P ? TARGET_NAME32 : TARGET_NAME64)

#else	/* SPARC_BI_ARCH */

# if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc

/* A 64-bit only compiler.  */

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 128

#undef MAX_LONG_DOUBLE_TYPE_SIZE
#define MAX_LONG_DOUBLE_TYPE_SIZE 128

#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128

#undef LINK_SPEC
#define LINK_SPEC LINK_ARCH_SPEC64

#undef STARTFILE_SPEC
#define STARTFILE_SPEC STARTFILE_SPEC64

#undef ENDFILE_SPEC
#define ENDFILE_SPEC ENDFILE_SPEC64

#undef CPP_SUBTARGET_SPEC
#define CPP_SUBTARGET_SPEC CPP_SUBTARGET_SPEC64

#undef TARGET_NAME
#define TARGET_NAME     TARGET_NAME64

# else	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */

/* A 32-bit only compiler.  */

#undef LONG_DOUBLE_TYPE_SIZE
#define LONG_DOUBLE_TYPE_SIZE 64

#undef MAX_LONG_DOUBLE_TYPE_SIZE
#define MAX_LONG_DOUBLE_TYPE_SIZE 64

#undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE
#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64

#undef LINK_SPEC
#define LINK_SPEC LINK_ARCH_SPEC32

#undef STARTFILE_SPEC
#define STARTFILE_SPEC STARTFILE_SPEC32

#undef ENDFILE_SPEC
#define ENDFILE_SPEC ENDFILE_SPEC32

#undef CPP_SUBTARGET_SPEC
#define CPP_SUBTARGET_SPEC CPP_SUBTARGET_SPEC32

#undef TARGET_NAME
#define TARGET_NAME     TARGET_NAME32

# endif	/* TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc */

#endif  /* SPARC_BI_ARCH */
--- end config/sparc/netbsd-elf-common.h ---

--- start config/sparc/netbsd-elf.h ---
/* Definitions of target machine for GNU compiler, for NetBSD/sparc (ELF).
   Copyright (C) 2001 Free Software Foundation, Inc.
   Contributed by Matthew Green (mrg@eterna.com.au).

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.  */

/* Let us output 64 bit code as well.  */
/* #define SPARC_BI_ARCH */

#include "sparc/sysv4.h"
#include "sparc/netbsd-elf-common.h"
--- end config/sparc/netbsd-elf.h ---

--- start config/sparc/netbsd64.h ---
/* Definitions of target machine for GNU compiler, for NetBSD/sparc64.
   Copyright (C) 2001 Free Software Foundation, Inc.
   Contributed by Matthew Green (mrg@eterna.com.au).

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.  */

/* Let us output 32 bit code as well.  */
#define SPARC_BI_ARCH

#include "sparc/sp64-elf.h"
#include "sparc/netbsd-elf-common.h"
--- end config/sparc/netbsd64.h ---


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