From: bruce@heather.pooh.COM (Bruce Robertson)
Subject: REPOST: gcc 2.1 configuration for 680x0 cross development
Organization: Hundred Acre Consulting, Reno, NV
Distribution: gnu
Date: Thu, 9 Apr 1992 19:54:54 GMT

This got truncated for some reason, so here's a repost.  I'm also
posting it to alt.sources and comp.sources.misc, so if it gets
truncated again try in those places.

Below is a tm.h file to set up gcc 2.1 for 680x0 cross development.
See the comments at the beginning of m68k-hac.h for details of exactly
what's changed.  Also included are some diffs to the configure script
so that you can configure gcc for this stuff with something like this:

	configure -target m68k-hac-embedded sparc-sun-sunos4

Whoever ends up integrating this stuff into the gcc distribution:  if
you don't like my choice of "-embedded", or "hac" for Hundred Acre
Consulting, feel free to change it.  Just let me know what you do, so
I can make the same changes here.

Support for these and other configurations is available; contact
bruce@pooh.com for details.

--
Bruce Robertson			bruce@pooh.com		Phone: +1-702-329-9333
Hundred Acre Consulting		1280 Terminal Way #26	Reno, NV 89502-3243



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  DIFFS m68k-hac.h
# Wrapped by bruce@heather on Tue Apr  7 00:22:32 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'DIFFS' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'DIFFS'\"
else
echo shar: Extracting \"'DIFFS'\" \(1030 characters\)
sed "s/^X//" >'DIFFS' <<'END_OF_FILE'
X*** ORIG/config.sub	Wed Mar 25 18:34:03 1992
X--- config.sub	Mon Mar 30 23:53:35 1992
X***************
X*** 434,440 ****
X  	      | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos* | -hpux* \
X  	      | -unos* | -osf* | -luna* | -dgux* | -solari* | -sym* | -amix* \
X  	      | -amigados* | -msdos* | -unicos* | -aos* \
X! 	      | -nindy* | -vxworks* | -ebmon* | -hds* | -m88kbcs*)
X  		;;
X  	-newsos*)
X  		os=-bsd
X--- 434,440 ----
X  	      | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos* | -hpux* \
X  	      | -unos* | -osf* | -luna* | -dgux* | -solari* | -sym* | -amix* \
X  	      | -amigados* | -msdos* | -unicos* | -aos* \
X! 	      | -nindy* | -vxworks* | -ebmon* | -hds* | -m88kbcs* | -embedded*)
X  		;;
X  	-newsos*)
X  		os=-bsd
X*** ORIG/configure	Wed Mar 25 18:34:04 1992
X--- configure	Mon Mar 30 23:50:48 1992
X***************
X*** 412,417 ****
X--- 412,420 ----
X  		tm_file=tower-as.h
X  		xm_file=xm-tower.h
X  		;;
X+ 	m68k-hac-embedded)
X+ 		tm_file=m68k-hac.h
X+ 		;;
X  	m68000-sun-sunos3*)
X  		cpu_type=m68k
X  		tm_file=sun2.h
END_OF_FILE
if test 1030 -ne `wc -c <'DIFFS'`; then
    echo shar: \"'DIFFS'\" unpacked with wrong size!
fi
# end of 'DIFFS'
fi
if test -f 'm68k-hac.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'m68k-hac.h'\"
else
echo shar: Extracting \"'m68k-hac.h'\" \(6655 characters\)
sed "s/^X//" >'m68k-hac.h' <<'END_OF_FILE'
X/*
X * 680x0 definitions for cross development, for use with GAS.
X * Donated by:	Bruce Robertson
X *		Hundred Acre Consulting
X *		bruce@pooh.com
X *
X * This set of macros sets things up for cross development of embedded
X * 680x0 systems.
X *
X * Features:
X *
X *	-mregparams is implemented correctly.  The first two long words of
X *	the arguments to a function are passed in register D0 and D1.  This
X *	feature is turned off for varargs functions, and therefore you MUST
X *	declare such functions with the "..." construct.  Another restriction
X *	with this feature is that arguments are not passed partially in
X *	registers.  If an argument won't fit entirely into D0 and D1, it is
X *	passed on the stack.
X *
X *	PCC_BITFIELD_TYPE_MATTERS is defined (see discussion below).  This
X *	being undefined in the other m68k configurations is a bug.
X *
X *	A -mlong-align option is added, to force data to be allocated with
X *	long word alignment, rather than the default short word alignment.
X *	If you're wondering if this sets things up for the Motorola/AT&T ABI
X *	specification, it doesn't, quite.
X *
X *	STRICT_ALIGNMENT is turned off if -m68020 is specified, since
X *	non-aligned moves on the 68020 and above work, and are actually
X *	quite fast on processors with a data cache.  Does anyone know if
X *	this will break anything?
X *
X *	STRUCTURE_SIZE_BOUNDARY is set to 8, just because I prefer it that
X *	way for embedded development.
X *
X * To generate code for the 68340, invoke with the -nobitfields option.
X */
X
X
X#include "m68k.h"
X
X/*
X * Add a parameter for regparams.  Unfortunately, this means completely
X * redefining the TARGET_SWITCHES macro.
X */
X#undef TARGET_SWITCHES
X#define TARGET_SWITCHES  \
X  { { "68020", 5},				\
X    { "c68020", 5},				\
X    { "68881", 2},				\
X    { "bitfield", 4},				\
X    { "68000", -5},				\
X    { "c68000", -5},				\
X    { "soft-float", -0102},			\
X    { "nobitfield", -4},			\
X    { "rtd", 8},				\
X    { "nortd", -8},				\
X    { "short", 040},				\
X    { "noshort", -040},				\
X    { "fpa", 0100},				\
X    { "nofpa", -0100},				\
X    { "sky", 0200},				\
X    { "nosky", -0200},				\
X    { "68040", 0407},				\
X    { "68030", -01400},				\
X    { "68030", 7},				\
X    { "68040-only", 01000},			\
X    { "regparams", 020},			\
X    { "noregparams", -020},			\
X    { "long-align", 02000},			\
X    { "nolong-align", -02000},			\
X    { "", TARGET_DEFAULT}}
X
X/* Force the strictest alignment to be long.  This is good for processors
X   with 32-bit busses, such as the 68020/30/40.  */
X#define	TARGET_LONG_ALIGN (target_flags & 02000)
X
X/* Redefine this to prevent -mregparams and -mshort at once.  */
X#undef OVERRIDE_OPTIONS
X#define OVERRIDE_OPTIONS		\
X{					\
X  if (! TARGET_68020 && flag_pic == 2)	\
X    error("-fPIC is not currently supported on the 68000 or 68010\n");	\
X  if (TARGET_REGPARM && TARGET_SHORT)	\
X    error("-mregparams and -mshort don't work together\n"); \
X}
X
X/* See tm-m68k.h.  5 means 68020 with software floating point.  */
X
X#ifndef TARGET_DEFAULT
X#define TARGET_DEFAULT 5
X#endif
X
X
X
X/* Define __HAVE_FPA__ or __HAVE_68881__ in preprocessor,
X   according to the -m flags.
X   This will control the use of inline 68881 insns in certain macros.
X   Also inform the program which CPU this is for.  */
X
X/* -msoft-float is the default */
X#define CPP_SPEC \
X"%{m68881:-D__HAVE_68881__ }%{mfpa:-D__HAVE_FPA__ }\
X%{m68000:-D__mc68010__}%{mc68000:-D__mc68010__}%{!mc68000:%{!m68000:-D__mc68020__}} \
X%{!ansi:%{m68000:-Dmc68010}%{mc68000:-Dmc68010}%{!mc68000:%{!m68000:-Dmc68020}}}"
X
X/* Prevent error on `-sun3' and `-target sun3' options.  */
X
X#define CC1_SPEC "%{sun3:} %{target:}"
X
X/* These compiler options take an argument.  We ignore -target for now.  */
X
X#define WORD_SWITCH_TAKES_ARG(STR)				\
X (!strcmp (STR, "Tdata") || !strcmp (STR, "include")		\
X  || !strcmp (STR, "imacros") || !strcmp (STR, "target")	\
X  || !strcmp (STR, "assert") || !strcmp (STR, "aux-info"))
X
X/* -m68000 requires special flags to the assembler.  */
X
X#define ASM_SPEC \
X "%{m68000:-mc68010}%{mc68000:-mc68010}%{!mc68000:%{!m68000:-mc68020}}"
X
X/* Names to predefine in the preprocessor for this target machine.  */
X
X#define CPP_PREDEFINES "-Dmc68000 -Dunix"
X
X/* This is BSD, so it wants DBX format.  */
X
X#define DBX_DEBUGGING_INFO
X
X/* Allow folding division by zero.  */
X#define REAL_INFINITY
X
X/* Generate calls to memcpy, memcmp and memset.  */
X#define TARGET_MEM_FUNCTIONS
X
X
X/* Redefine alignment constants to support the -mlong-align option.  */
X#undef STACK_BOUNDARY
X#undef FUNCTION_BOUNDARY
X#undef EMPTY_FIELD_BOUNDARY
X#undef BIGGEST_ALIGNMENT
X#undef ASM_OUTPUT_ALIGN
X#define STACK_BOUNDARY		(TARGET_LONG_ALIGN ? 32 : 16)
X#define FUNCTION_BOUNDARY	(TARGET_LONG_ALIGN ? 32 : 16)
X#define EMPTY_FIELD_BOUNDARY	(TARGET_LONG_ALIGN ? 32 : 16)
X#define BIGGEST_ALIGNMENT	(TARGET_LONG_ALIGN ? 32 : 16)
X#define ASM_OUTPUT_ALIGN(FILE,LOG)      \
X  fprintf (FILE, "\t.align %d\n", (LOG))
X
X/* On 68020 and above, nonaligned move instructions work.  */
X#undef STRICT_ALIGNMENT
X#define STRICT_ALIGNMENT	TARGET_68020
X
X/* Set the structure size boundary to 8 bits, to make arrays and such
X   smaller.  */
X#define STRUCTURE_SIZE_BOUNDARY 8
X
X/* The m68k.h configuration by default leaves this undefined, which is
X   actually wrong for the -mnobitfield case (it causes an abort).  I thought
X   a long time about setting it to false when bitfield instructions are
X   allowed, and true when not, because I liked the idea of having the
X   structures tightly packed regardless of the size of the fields.  Such
X   behavior comes in handy when declaring SCSI data structures, for example.
X   I finally decided that this would be a bad thing to do, because then the
X   structure layout would change depending on whether you specified
X   -mbitfield.  Also, it isn't good practice to rely on that sort of
X   structure packing if you expect to be able to move declarations between
X   compiler implementations.  So, I'm unconditionally defining this to
X   be true.
X   As implied above, this being left undefined in the other m68k.h files
X   is a bug.  */
X#define	PCC_BITFIELD_TYPE_MATTERS 1
X
X
X
X/*
X * The FUNCTION_ARG macro in tm-m68k.h is incorrect.
X */
X#undef FUNCTION_ARG
X#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)				\
X(TARGET_REGPARM								\
X && (NAMED)								\
X && (CUM) < 8								\
X && ((TYPE)==0 || ! TREE_ADDRESSABLE ((tree)(TYPE)))			\
X && ((TYPE)==0 || (MODE) != BLKmode || (TYPE_ALIGN ((TYPE)) % PARM_BOUNDARY == 0))		\
X && ((CUM)								\
X     + ((MODE) == BLKmode						\
X	? int_size_in_bytes (TYPE)					\
X	: GET_MODE_SIZE (MODE)) <= 8)					\
X ? gen_rtx (REG, (MODE), (CUM) / 4) : 0)
X
X
X/* This isn't worth it.  */
X#undef FUNCTION_ARG_PARTIAL_NREGS
END_OF_FILE
if test 6655 -ne `wc -c <'m68k-hac.h'`; then
    echo shar: \"'m68k-hac.h'\" unpacked with wrong size!
fi
# end of 'm68k-hac.h'
fi
echo shar: End of shell archive.
exit 0
--
Bruce Robertson			bruce@pooh.com		Phone: +1-702-329-9333
Hundred Acre Consulting		1280 Terminal Way #26	Reno, NV 89502-3243


Newsgroups: gnu.gcc.bug