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]

MachTen Egcs Patches


Hello,

We have wanted to get our gcc patches into the standard release for a
long time.  We were hoping that with the forthcoming freeze of egcs 1.1
that we might have chance to be included.

For those that dont know, MachTen is a complete Unix virtual machine.  It
like the Java Virtual Machine runs in real and virtual environments.  Into
the MachTen VM we have ported a host (300+) standard Unix commands and 
utilities.  Included in that set is the complete GNU gcc and friends
environment.  Since this system must reside equally well in real memory 
and virtual memory environments we have had to make modifications to the
alloca, __builtin_alloca and __builtin_va_alist parts of gcc.  

What follows here is a ChangeLog entry, the diffs and added files for
our MachTen configuration.  I would have liked to send these as an attachment
but Im unfamiliar with your policies so I include them "inline".  If there
are better ways to do this in the future or you would like me to resend
this with a different packaging please let me know.  

If there is any other information that I can get you or any questions
that I can answer, please contact me.  We are eager to support this in
any way we can.

Regards,
Steve Holmgren

*****************************************************************************

Thu Jul  2 10:45:12 1998  Steve Holmgren (holmgren@tenon.com)

        * configure.in: Added: powerpc-*-machten*)
        * Makefile.in: Added: $(CC1_LDFLAGS) to cc1 link for cc1 specific
        stacksize settings.
        * c-decl.c: Created #ifdef REAL_MEMORY_TARGET
         Added flag_no_builtin_alloca.
        Nonzero means to disable the usual behavior of __builtin_alloca(),
        i.e. treat __builtin_alloca() as any other `libc' function.
        Under REAL_MEMORY_TARGET, the builtin version of alloca is implemented via
        inline instructions that make runtime adjustments to the stack pointer,
        calling _alloca_no_stack() when the stack is insufficient for a request.
        # c-decl.c: (c_decode_option) Added -fbuiltin-alloca and -fno-builtin-alloca
        to reset and set flag_no_builtin_alloca.
        * c-decl.c: (init_decl_processing) used flag_no_builtin_alloca to
        enable or inhibit addition of __builtin_alloca() and alloca()
        * c-pragma.c: (handle_pragma_token) added handling for powerpc
        data structure alignment pragmas:
                #pragma options align=powerpc|m68k|reset
        * rs6000.c: (rs6000_override_options) added ppc processor type
        and support for -malignppc and -malignm68k command line options
        * rs6000.c: (output_prolog) added support for real memory stack
        overflow checking.
        * rs6000.h: added support for -malignppc and -malignm68k
        * config.sub: added support for m68*-mac-machten*) and
        powerpc-apple-machten*)
        * cp/decl.c (init_decl_processing) referenced flag_no_builtin_alloca
        to inhibit loading of __builtin_alloca and alloca as builtin c++
        functions.
        * cp/decl2.c: struct lang_f_options added builtin-alloca.
        * expr.c: (expand_builtin) if TARGET_BUILTIN_ALLOCA defined reference
        the macro.
        * function.c: (assign_parms) modify processing of __builtin_va_alist
        to real memory variable stack processing.
        * gcc.c: modify default_compilers to incorporate libgcc.a into libc.a
        * gcc.c: (process_command) add support -Xl command level processing to
        pass linker stacksize commands through to ld
        * invoke.texi: add information for -fbuiltin-alloca and -fno-builtin-alloca
        * toplev.c: lang-options add -fbuiltin-alloca and -fno-builtin-alloca
        entries
        * tree.c: support overide of OBSTACK_CHUNK_ALIGNMENT
        * Added files:
                gcc/config/m68k/machten68k.h
                gcc/config/m68k/t-machten68k
                gcc/config/m68k/x-machten68k
                gcc/config/m68k/xm-machten68k.h
                gcc/config/rs6000/machtenppc.c
                gcc/config/rs6000/machtenppc.h
                gcc/config/rs6000/t-machtenppc
                gcc/config/rs6000/x-machtenppc
                gcc/config/rs6000/xm-machtenppc.h

**********************************************************************************
gcc/config/m68k/machten68k.h

/* Definitions of target machine for GNU compiler.  Macintosh 68000 version.
   Copyright (C) 1987, 1988 Free Software Foundation, Inc.

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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */


#include "m68k/m68k.h"

/* See m68k.h.  5 means 68020 with no 68881.  */

#ifndef TARGET_DEFAULT
#define TARGET_DEFAULT 5
#endif

/* Use MachTen include file search path.  */
/* Even for a cross compiler with MachTen as target! */
#define INCLUDE_DEFAULTS				\
  {							\
    { GPLUSPLUS_INCLUDE_DIR, 1, 1},			\
    { MACHINE_INCLUDE_DIR, 0, 1},			\
    { LOCAL_INCLUDE_DIR, 0, 1},				\
    { STANDARD_INCLUDE_DIR, 0, 1},			\
    { 0, 0, 0}						\
  }

/* Agree with <machine/ansi.h> */
#define PTRDIFF_TYPE "int"
#define SIZE_TYPE "unsigned int"

/* We must override m68k.h.  */
#undef WCHAR_TYPE
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE "short unsigned int"
#define WCHAR_TYPE_SIZE 16

/* Define __HAVE_68881 in preprocessor only if -m68881 is specified.
   This will control the use of inline 68881 insns in certain macros.
   Also inform the program which CPU this is for.  */

#ifndef CPP_SPEC
#define CPP_SPEC "\
%{!m68040-lc:%{!mc68040-lc:%{m680*: -Dmc680%*}%{mc680*: -Dmc680%*}}}\
%{m68040-lc: -Dmc68LC040}%{mc68040-lc: -Dmc68LC040}\
%{!m680*:%{!mc680*: -Dmc68020}}\
%{m68881:%{!msoft-float: -D__HAVE_68881__}}"
#endif

/* Flags to the assembler.  */

#ifndef ASM_SPEC
#define ASM_SPEC "\
%{!m68040-lc:%{!mc68040-lc:%{m680*: -mc680%*}%{mc680*: -mc680%*}}}\
%{m68040-lc: -mc68040}%{mc68040-lc: -mc68040}\
%{!m680*:%{!mc680*: -mc68020}} %{mno-68*} %{pic}"
#endif

/* Names to predefine in the preprocessor for this target machine.  */
/* __MACHTEN__ is needed inside cpp for direct calls to it; gcc will
   compose it from -DMACHTEN; TENON is a silent holdover.  */
/* TENON is *deprecated*, use __MACHTEN__ instead */
#ifndef CPP_PREDEFINES
#define CPP_PREDEFINES "-Dunix -D__MACHTEN__ -D__MACHTEN_68K__ -DTENON\
 -Asystem(unix) -Asystem(bsd) -Asystem(machten)\
 -Acpu(m68000) -Acpu(mc68000) -Acpu(m68k)\
 -Amachine(m68000) -Amachine(mc68000) -Amachine(m68k) -Amachine(mac)"
#endif

#ifndef	CC1_SPEC
#define CC1_SPEC "-fno-builtin-alloca -fno-defer-pop"
#endif

#ifndef	CC1PLUS_SPEC
#define CC1PLUS_SPEC "-fno-builtin-alloca -fno-defer-pop -felide-constructors"
#endif

#ifndef LINK_SPEC
#define LINK_SPEC "-x"
#endif

#ifndef LIB_SPEC
#define LIB_SPEC "%{fmach-init:-lmach}\
%{!shared:%{g*: -lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
#endif

/* These compiler options take an argument.  We ignore -target for now.  */

#define WORD_SWITCH_TAKES_ARG(STR)	(\
	(strcmp(STR, "stack") == 0) || (strcmp(STR, "Tdata") == 0) || \
	(strcmp(STR, "target") == 0))

/* Alignment of field after `int : 0' in a structure.  */

#undef EMPTY_FIELD_BOUNDARY
#define EMPTY_FIELD_BOUNDARY 16

/* This is BSD, so it wants DBX format.  */

#define DBX_DEBUGGING_INFO

/* Don't default to pcc-struct-return, because gcc is the only compiler, and
   we want to retain compatibility with older gcc versions.  */
#define DEFAULT_PCC_STRUCT_RETURN 0
#undef PCC_STATIC_STRUCT_RETURN

/* Use atexit for static constructors/destructors, instead of defining
   our own exit function.  */
#define HAVE_ATEXIT

***********************************************************************************
gcc/config/m68k/t-machten68k

# Strip installed executables.. please!
INSTALL_PROGRAM = $(INSTALL) -s

# libgcc{1,2}.c is not needed, since the standard library has these functions.
LIBGCC=
LIBGCC1=
LIBGCC2=
INSTALL_LIBGCC=

CFLAGS = -O2 -m68020
T_CPPFLAGS = -DTARGET_MACHTEN

# gcc is the native C/C++ compiler for MachTen.  In the interest of reducing
# MacOS disk activity (saving time), MachTen places gcc,g++ in /usr/bin, the
# backend compilers (cpp,cc1,cc1plus,cc1obj,...) in /usr/mac68k/bin, and
# libraries & special .o files in /usr/lib; no gcc- prefix is anticipated.

# Common prefix for installation directories.
prefix = /usr

# One might argue that GCC_O_CPPFLAGS and CCCP_O_CPPFLAGS belong in
# x-machten68k, however, their presence here is convenient for making both
# a native m68k compiler and a cross compiler running on PowerMacs.
GCC_O_CPPFLAGS=\
	-DSTANDARD_STARTFILE_PREFIX=\"/usr/mac68k/lib/\" \
	-DSTANDARD_EXEC_PREFIX=\"/usr/mac68k/bin/\" \
	-DDEFAULT_TARGET_VERSION=\"$(version)\" \
	-DDEFAULT_TARGET_MACHINE=\"$(target)\" \
	-DTOOLDIR_BASE_PREFIX=\"/usr/local/\"

CCCP_O_CPPFLAGS=\
	-DGCC_INCLUDE_DIR=\"\" \
	-DGPLUSPLUS_INCLUDE_DIR=\"/usr/include/g++\" \
	-DLOCAL_INCLUDE_DIR=\"/usr/local/include\" \
	-DCROSS_INCLUDE_DIR=\"\" \
	-DTOOL_INCLUDE_DIR=\"\" \
	-DMACHINE_INCLUDE_DIR=\"/usr/mac68k/include\"

# Directory in which the compiler finds g++ includes.
gxx_include_dir = /usr/include/g++
***********************************************************************************
gcc/config/m68k/x-machten68k

# Even tho gcc is the compiler on MachTen, refer to it by the historical name
# so that USE_ALLOCA and USE_HOST_ALLOCA are properly set (as alloca.o)!
CC = cc

ALL= native xgcc specs lang.start.encap lang.rest.encap
LANGUAGES = c c++
STMP_FIXPROTO=

X_CFLAGS= -fno-builtin-alloca -fno-defer-pop

# Extra compile/load switches specific to MachTen
ALLOCA= alloca.o
ALLOCA_FLAGS= -DSTACK_DIRECTION=-1

XGCC_LDFLAGS= -stack 32768 ${LDFLAGS}
CCCP_LDFLAGS= -stack 49152 ${LDFLAGS}
CC1_LDFLAGS= -stack 49152 ${LDFLAGS}
CC1OBJ_LDFLAGS= -stack 49152 ${LDFLAGS}
CC1PLUS_LDFLAGS= -stack 49152 ${LDFLAGS}
F771_LDFLAGS= -stack 49152 ${LDFLAGS}
***********************************************************************************
gcc/config/m68k/xm-machten68k.h

#include "m68k/xm-m68k.h"

/* Always use the C-version of alloca to avoid nasty problems due to
   stack overrun */
#undef alloca
#define USE_C_ALLOCA

/* Note presence of selected function in host library */
#define HAVE_PUTENV		/* putenv() */
#define HAVE_STRERROR		/* strerror() */
#define HAVE_VPRINTF		/* vprintf() */

/* Specific to cpp */
#define MAX_OUTPUT_COLUMNS 76	/* # cols in dependency output (-M) */
#define NO_IMPLICIT_EXTERN_C	/* system include files are C and C++ */
**********************************************************************************
gcc/config/rs6000/machtenppc.c

/* Power Macintosh with MachTen.  */

#include "config/rs6000/rs6000.c"

#include "insn-codes.h"


/* The desired treatment of alloca() on a Power Macintosh with MachTen is
   to make a runtime determination whether or not to allocate space on the
   stack or to call the (libc) alloca function.  Until Copland, we are
   running in a physical memory environment (or perhaps in "extended RAM"
   by virtue of RAM Doubler or Apple's Virtual Memory), and stacks are
   fixed in size at the point of initiating execution.  The stack boundary
   for limiting direct stack allocations is set in crt0.

   macppc_builtin_alloca() is derived from allocate_dynamic_stack_space(),
   found in explow.c.  */

/* Return an rtx representing the address of an area of memory dynamically
   pushed on the stack.  This region of memory is always aligned to
   a multiple of BIGGEST_ALIGNMENT.

   Any required stack pointer alignment is preserved.

   SIZE is an rtx representing the size of the area.
   TARGET is a place in which the address can be placed.

   KNOWN_ALIGN is the alignment (in bits) that we know SIZE has.  */

rtx
macppc_builtin_alloca (exp, size, target, ignore)
     tree exp;
     rtx size;
     rtx target;
     int ignore;
{
  rtx value;
  rtx adjust;
  rtx alloca_buf;
  rtx label_callib;
  rtx label_allocd;

  /* Show we're calling alloca or equivalent.  */
  current_function_calls_alloca = 1;

  /* If we're asking for zero bytes, simply call the alloca function to
     release whatever is possible.  Otherwise, compose runtime code which
     will determine whether the requested space may be allocated on the
     stack, or it must be assigned by alloca in libc.  */
  if (size == const0_rtx)
    return( (rtx)expand_call (exp, target, ignore) );

  /* Ensure the size is in the proper mode.  */
  if (GET_MODE (size) != VOIDmode && GET_MODE (size) != Pmode)
    size = convert_to_mode (Pmode, size, 1);

  label_callib = gen_label_rtx ();
  label_allocd = gen_label_rtx ();

  /* If size was not a constant, check now for zero and branch to library
     function call to handle it if so.  */
  if (GET_CODE (size) != CONST_INT )
    {
      rtx new_size = gen_reg_rtx (SImode);

      /* Not sure how to determine whether size is static or not --
	 move it to another register to avoid an (unrecognizable insn)
	 internal error on the subsequent comparison against zero. */
      emit_move_insn (new_size, size);
      size = new_size;
      emit_insn (gen_cmpsi (size, const0_rtx));
      emit_insn (gen_beq (label_callib));
    }

  /* We will need to ensure that the address we return is aligned to
     BIGGEST_ALIGNMENT.  If STACK_DYNAMIC_OFFSET is defined, we don't
     always know its final value at this point in the compilation (it 
     might depend on the size of the outgoing parameter lists, for
     example), so we must align the value to be returned in that case.
     (Note that STACK_DYNAMIC_OFFSET will have a default non-zero value if
     STACK_POINTER_OFFSET or ACCUMULATE_OUTGOING_ARGS are defined).
     We must also do an alignment operation on the returned value if
     the stack pointer alignment is less strict that BIGGEST_ALIGNMENT.

     If we have to align, we must leave space in SIZE for the hole
     that might result from the alignment operation.  */

#if defined (STACK_DYNAMIC_OFFSET) || defined(STACK_POINTER_OFFSET) || defined (ALLOCATE_OUTGOING_ARGS)
#define MUST_ALIGN
#endif

#if ! defined (MUST_ALIGN) && (!defined(STACK_BOUNDARY) || STACK_BOUNDARY < BIGGEST_ALIGNMENT)
#define MUST_ALIGN
#endif

#ifdef MUST_ALIGN

#if 0 /* It turns out we must always make extra space, if MUST_ALIGN
	 because we must always round the address up at the end,
	 because we don't know whether the dynamic offset
	 will mess up the desired alignment.  */
  /* If we have to round the address up regardless of known_align,
     make extra space regardless, also.  */
  if (known_align % BIGGEST_ALIGNMENT != 0)
#endif
    {
      if (GET_CODE (size) == CONST_INT)
	adjust = GEN_INT (INTVAL (size)
			+ (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1));
      else
	adjust = expand_binop (Pmode, add_optab, size,
			     GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
			     NULL_RTX, 1, OPTAB_LIB_WIDEN);
    }

#endif

  /* Round the size to a multiple of the required stack alignment.
     Since the stack if presumed to be rounded before this allocation,
     this will maintain the required alignment.

     If the stack grows downward, we could save an insn by subtracting
     SIZE from the stack pointer and then aligning the stack pointer.
     The problem with this is that the stack pointer may be unaligned
     between the execution of the subtraction and alignment insns and
     some machines do not allow this.  Even on those that do, some
     signal handlers malfunction if a signal should occur between those
     insns.  Since this is an extremely rare event, we have no reliable
     way of knowing which systems have this problem.  So we avoid even
     momentarily mis-aligning the stack.  */

#ifdef STACK_BOUNDARY
  /* If we added a variable amount to SIZE,
     we can no longer assume it is aligned.  */
#if !defined (SETJMP_VIA_SAVE_AREA) && !defined (MUST_ALIGN)
  if (known_align % STACK_BOUNDARY != 0)
#endif
    adjust = round_push (adjust);
#endif

  do_pending_stack_adjust ();

  /* Don't use a TARGET that isn't a pseudo.  */
  if (target == 0 || GET_CODE (target) != REG
      || REGNO (target) < FIRST_PSEUDO_REGISTER)
    target = gen_reg_rtx (Pmode);

  mark_reg_pointer (target,0);

  value = gen_reg_rtx (Pmode);

#ifndef STACK_GROWS_DOWNWARD
  emit_move_insn (value, virtual_stack_dynamic_rtx);
#endif

  /* Perform the required allocation from the stack.  Some systems do
     this differently than simply incrementing/decrementing from the
     stack pointer.  */
    {
      enum machine_mode mode
	= insn_operand_mode[(int) CODE_FOR_allocate_stack][0];
      rtx limit_ptr;
      rtx limit = gen_reg_rtx (SImode);
      rtx new_sp = gen_reg_rtx (SImode);
      rtx chain = gen_reg_rtx (SImode);
      rtx stack_bot = gen_rtx (MEM, Pmode, stack_pointer_rtx);

      if (insn_operand_predicate[(int) CODE_FOR_allocate_stack][0]
	  && ! ((*insn_operand_predicate[(int) CODE_FOR_allocate_stack][0])
		(adjust, mode)))
	adjust = copy_to_mode_reg (mode, adjust);

      limit_ptr = gen_rtx (MEM, Pmode,
			   gen_rtx (SYMBOL_REF, Pmode,
				    "_alloca_stack_limit[RW]"));
      emit_move_insn (limit, limit_ptr);
      emit_insn (gen_subsi3 (new_sp, stack_pointer_rtx, adjust));
      emit_insn (gen_cmpsi (new_sp, limit));
      emit_insn (gen_bltu (label_callib));

      /* emit_insn (gen_allocate_stack (adjust)); */
      emit_move_insn (chain, stack_bot);
      emit_move_insn (stack_pointer_rtx, new_sp);
      emit_move_insn (stack_bot, chain);

    }

#ifdef STACK_GROWS_DOWNWARD
  emit_move_insn (value, virtual_stack_dynamic_rtx);
#endif

#ifdef MUST_ALIGN
#if 0  /* Even if we know the stack pointer has enough alignment,
	  there's no way to tell whether virtual_stack_dynamic_rtx shares that
	  alignment, so we still need to round the address up.  */
  if (known_align % BIGGEST_ALIGNMENT != 0)
#endif
    {
      /* CEIL_DIV_EXPR needs to worry about the addition overflowing,
	 but we know it can't.  So add ourselves and then do TRUNC_DIV_EXPR. */
      value = expand_binop (Pmode, add_optab, value,
			     GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT - 1),
			     NULL_RTX, 1, OPTAB_LIB_WIDEN);
      value = expand_divmod (0, TRUNC_DIV_EXPR, Pmode, value,
			      GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT),
			      NULL_RTX, 1);
      value = expand_mult (Pmode, value,
			    GEN_INT (BIGGEST_ALIGNMENT / BITS_PER_UNIT),
			    NULL_RTX, 1);
    }
#endif

    emit_move_insn (target, value);
  
  /* Some systems require a particular insn to refer to the stack
     to make the pages exist.  */
#ifdef HAVE_probe
  if (HAVE_probe)
    emit_insn (gen_probe ());
#endif

  /* Record the new stack level for nonlocal gotos.  */
  if (nonlocal_goto_handler_slot != 0)
    emit_stack_save (SAVE_NONLOCAL, &nonlocal_goto_stack_level, NULL_RTX);

  emit_jump_insn (gen_jump (label_allocd));
  emit_barrier ();

  emit_label (label_callib);

  /* Generate a call to (libc) _alloca_no_stack() when there is insufficient
     stack to handle the request.  It will either return a pointer to a
     malloc'd buffer or exit with an error.  */

  value = emit_library_call_value
		( gen_rtx (SYMBOL_REF, Pmode, "_alloca_no_stack"),
		  NULL_RTX, 0, Pmode, 1, size, Pmode);
  emit_move_insn (target, value);

  emit_label (label_allocd);

  return target;
}
*********************************************************************************
gcc/config/rs6000/machtenppc.h

/* Definitions of target machine for GNU compiler,
   for IBM RS/6000 PowerPC running AIX version 3.2.
   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
   Contributed by David Edelsohn (edelsohn@npac.syr.edu).

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, 675 Mass Ave, Cambridge, MA 02139, USA.  */


#define MASK_AIX_CALLS		0x02000000	/* Use AIX calling sequence */

#define TARGET_AIX_CALLS	(target_flags & MASK_AIX_CALLS)
#undef TARGET_V4_CALLS

#include "rs6000/rs6000.h"

#undef TARGET_DEFAULT
#define TARGET_DEFAULT (MASK_POWERPC | MASK_NEW_MNEMONICS | MASK_AIX_CALLS)

#undef PROCESSOR_DEFAULT
#define PROCESSOR_DEFAULT PROCESSOR_PPC601

/* No structure field wants to be aligned rounder than this.  */
#undef BIGGEST_FIELD_ALIGNMENT
//
// wanted to make this the default.  simply to many things started
// breaking - therefore had to return to default
#define   BIGGEST_FIELD_ALIGNMENT 16

// and make -malignppc available on the command line and the pragma
// #pragma options align = power|m68k|reset
// for those that want to put things in the best performance
//#define BIGGEST_FIELD_ALIGNMENT 32

/* Be consistant with 680*0 compiler; default to signed char */
#undef DEFAULT_SIGNED_CHAR
#define DEFAULT_SIGNED_CHAR 1

/* enable SYSV pragma for #pragma align (1|2|4|8) */
#define HANDLE_SYSV_PRAGMA	1

/* Agree with <machine/ansi.h> */
#define PTRDIFF_TYPE "int"
#define SIZE_TYPE "unsigned int"

/* Use larger default obstack sizes, and long-word align them.  */
#define OBSTACK_CHUNK_SIZE	8192
#define OBSTACK_CHUNK_ALIGNMENT	4

/* We have special treatment for __builtin_alloca (see expr.c):
   If the size is a constant zero bytes, simply call the alloca function to
   free as many buffers as possible.  Otherwise, compose code which will
   determine at runtime whether the requested space may be allocated on the
   stack, or it must be assigned by alloca in libc.  */

#if 0 /* rtx and tree unknown at this point */
rtx macppc_builtin_alloca ( tree exp, rtx size, rtx target, int ignore);
#endif

#define TARGET_BUILT_IN_ALLOCA \
  if (op0 != const0_rtx)					\
    return (rtx) macppc_builtin_alloca (exp, op0, target, ignore);	\
  break;

#ifdef NOTDEF
/* Use MachTen include file search path.  */
/* Even for a cross compiler with MachTen as target! */
#define INCLUDE_DEFAULTS				\
  {							\
    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1},			\
    { MACHINE_INCLUDE_DIR, "MACHINE", 0, 1},			\
    { LOCAL_INCLUDE_DIR, "BINUTILS", 0, 1},				\
    { STANDARD_INCLUDE_DIR, "INCLUDE", 0, 1},			\
    { 0, 0, 0, 0}						\
  }
#endif

#undef ASM_SPEC
#define ASM_SPEC "-u -mppc"

#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-DPRAGMA_ALIGN_SUPPORTED -D__MACHTEN__ -D__MACHTEN_PPC__ -Dunix \
-Asystem(unix) -Asystem(machten) -Acpu(powerpc) -Amachine(mac)"

#undef CPP_SPEC
#define CPP_SPEC "\
%{!mcpu*: \
  %{mpower: %{!mpower2: -D_ARCH_PWR}} \
  %{mpower2: -D_ARCH_PWR2} \
  %{mppc*: -D_ARCH_PPC} \
  %{mpowerpc*: -D_ARCH_PPC} \
  %{mno-powerpc: %{!mpower: %{!mpower2: -D_ARCH_COM}}} \
  %{!mno-powerpc: -D_ARCH_PPC}} \
%{mcpu=common: -D_ARCH_COM} \
%{mcpu=power: -D_ARCH_PWR} \
%{mcpu=ppc: -D_ARCH_PPC} \
%{mcpu=powerpc: -D_ARCH_PPC} \
%{mcpu=rios: -D_ARCH_PWR} \
%{mcpu=rios1: -D_ARCH_PWR} \
%{mcpu=rios2: -D_ARCH_PWR2} \
%{mcpu=rsc: -D_ARCH_PWR} \
%{mcpu=rsc1: -D_ARCH_PWR} \
%{mcpu=601: -D_ARCH_PPC -D_ARCH_PWR} \
%{mcpu=mpc601: -D_ARCH_PPC -D_ARCH_PWR} \
%{mcpu=ppc601: -D_ARCH_PPC -D_ARCH_PWR} \
%{mcpu=603: -D_ARCH_PPC} \
%{mcpu=mpc603: -D_ARCH_PPC} \
%{mcpu=ppc603: -D_ARCH_PPC} \
%{mcpu=604: -D_ARCH_PPC} \
%{mcpu=mpc604: -D_ARCH_PPC} \
%{mcpu=ppc604: -D_ARCH_PPC}"

/* Define the options for the binder.  */
#undef LINK_SPEC

/* Profiled library versions are used by linking with special directories.  */
#undef LIB_SPEC
#define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\
   %{p:-L/lib/profiled -L/usr/lib/profiled} %{g*:-lg} -lc"

/* libgcc.a is part of libc.a in MachTen.  */
#undef LINK_LIBGCC_SPECIAL_1

/* g++ support */

/* LD recognizes the presence of constructor/destructor functions by scanning
   the symbol table for the special symbol prefix "_GLOBAL_.[ID]."; no other
   symbol table entries are made.  */
#undef ASM_OUTPUT_DESTRUCTOR
#define ASM_OUTPUT_DESTRUCTOR(FILE, NAME)
#undef ASM_OUTPUT_CONSTRUCTOR
#define ASM_OUTPUT_CONSTRUCTOR(FILE, NAME)
#undef ASM_OUTPUT_GC_ENTRY
#define ASM_OUTPUT_GC_ENTRY(FILE, NAME)

/* Stack checking under MachTen is implemented by having selected function
   prologs compare current availability against need.  Only functions that
   call other functions or leaf functions that require excessive stack
   space perform this check.  Need is calculated to be the actual space
   required by the function, plus a red zone (224 bytes) if other functions
   are called.  The red zone allows leaf functions to save registers without
   having to establish a stack frame.  To make this check efficient, R13 is
   assumed to contain the stack limit, which is set in crt0.o.  */
#define STACK_CHECK_BUILTIN 1

/* Review options specified by user; use of certain options implies need
   for others: 1) -fstack-check implies -ffixed-13.  */
#define SUBTARGET_OVERRIDE_OPTIONS			\
{							\
  if (flag_stack_check)					\
    fix_register ("13", 1, 1);				\
}
*********************************************************************************
gcc/config/rs6000/t-machtenppc

# libgcc{1,2}.c is not needed, since the standard library has these functions.
LIBGCC =
LIBGCC1 =
LIBGCC2 =
INSTALL_LIBGCC =

USER_H =
INSTALL_ASSERT_H =

CFLAGS = -malignppc -O3 -pipe -fstrength-reduce -fomit-frame-pointer -finline-functions -finhibit-size-directive -DREAL_MEMORY_TARGET
CXXFLAGS = -malignppc -O3 -pipe -fstrength-reduce -fomit-frame-pointer -finline-functions -finhibit-size-directive -DREAL_MEMORY_TARGET

# gcc is the native C/C++ compiler for MachTen.  In the interest of reducing
# MacOS disk activity (saving time), MachTen places gcc,g++ in /usr/bin, the
# backend compilers (cpp,cc1,cc1plus,cc1obj,...) in /usr/macppc/bin, and
# libraries & special .o files in /usr/lib; no gcc- prefix is anticipated.

# Common prefix for installation directories.
prefix = /usr

# One might argue that GCC_O_CPPFLAGS and CCCP_O_CPPFLAGS belong in
# x-machtenppc, however, their presence here is convenient for making both
# a native PPC compiler and a cross compiler running on m68k-Macs.


GCC_O_CPPFLAGS =\
	-DSTANDARD_STARTFILE_PREFIX=\"$(prefix)/lib/gcc-lib/\"\
	-DSTANDARD_EXEC_PREFIX=\"$(prefix)/lib/gcc-lib/\"\
	-DDEFAULT_TARGET_VERSION=\"$(version)\"\
	-DDEFAULT_TARGET_MACHINE=\"$(target)\"\
	-DTOOLDIR_BASE_PREFIX=\"/usr/lib/gcc-lib/\"

CCCP_O_CPPFLAGS =\
	-DGCC_INCLUDE_DIR=\"$(libsubdir)/include\"\
	-DGPLUSPLUS_INCLUDE_DIR=\"/usr/include/g++\"\
	-DLOCAL_INCLUDE_DIR=\"/usr/local/include\"\
	-DCROSS_INCLUDE_DIR=\"$(libsubdir)/sys-include\"\
	-DTOOL_INCLUDE_DIR=\"$(tooldir)/include\"\
	-DMACHINE_INCLUDE_DIR=\"/usr/macppc/include\"

# Directory in which the compiler finds g++ includes.
gxx_include_dir = /usr/include/g++
*********************************************************************************
gcc/config/rs6000/x-machtenppc

ALL= native xgcc specs lang.start.encap lang.rest.encap
LANGUAGES = c
STMP_FIXPROTO=

# Default stack is okay for gcc and cpp
LDFLAGS	= -Xlstack=1048576 
# CC1 Needs more
CC1_LDFLAGS = -Xlstack=1310720
*********************************************************************************
gcc/config/rs6000/xm-machtenppc.h

/* Configuration for GNU C-compiler for MachTen on Power Macintosh.
   Contributed by Dale S. Russell (dsr@tenon.com).  */

#include "rs6000/xm-rs6000.h"
#undef USG

/* It would be better to get this (actually BSD4_4) from <sys/param.h>,
   however, this is all we really need.  */
#define bsd4_4	1

/* Define this so we include 'alloca(0)' calls to release temporary storage */
#ifndef USE_C_ALLOCA
#define USE_C_ALLOCA
#endif

/* Note presence of selected function in host library */
//#define HAVE_PUTENV		/* putenv() */
//#define HAVE_STRERROR		/* strerror() */
//#define HAVE_VPRINTF		/* vprintf() */

/* Specific to cpp */
#define MAX_OUTPUT_COLUMNS 76	/* # cols in dependency output (-M) */
#define NO_IMPLICIT_EXTERN_C	/* system include files are C and C++ */

#define PRAGMA_ALIGN_SUPPORTED 	1
*********************************************************************************
diffs diff -r -c3p OLD NEW

diff -r -c3p egcs-1.0.3a.orig/configure.in egcs-1.0.3a/configure.in
*** egcs-1.0.3a.orig/configure.in	Sun Feb 22 06:21:02 1998
--- egcs-1.0.3a/configure.in	Thu Jul  2 09:23:00 1998
*************** case "${target}" in
*** 518,523 ****
--- 518,526 ----
      # This is needed until gcc and ld are fixed to work together.
      use_gnu_ld=no
      ;;
+   powerpc-*-machten*)
+     noconfigdirs="$noconfigdirs gdb sim make tcl tk expect itcl tix db sn qnuserv"
+     ;;
    powerpc*-*-winnt* | powerpc*-*-pe* | ppc*-*-pe)
      target_configdirs="$target_configdirs target-winsup"
      noconfigdirs="$noconfigdirs gdb tcl tk make expect target-libgloss itcl tix db sn gnuserv"
diff -r -c3p egcs-1.0.3a.orig/gcc/Makefile.in egcs-1.0.3a/gcc/Makefile.in
*** egcs-1.0.3a.orig/gcc/Makefile.in	Thu Feb 19 11:14:38 1998
--- egcs-1.0.3a/gcc/Makefile.in	Wed Jul  1 15:19:35 1998
*************** gcc-cross: xgcc
*** 782,788 ****
  	cp xgcc$(exeext) gcc-cross$(exeext)
  
  cc1: $(P) $(C_OBJS) $(OBJS) $(BC_OBJS) $(LIBDEPS)
! 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) $(OBJS) $(BC_OBJS) $(LIBS)
  
  # Copy float.h from its source.
  gfloat.h: $(FLOAT_H)
--- 782,788 ----
  	cp xgcc$(exeext) gcc-cross$(exeext)
  
  cc1: $(P) $(C_OBJS) $(OBJS) $(BC_OBJS) $(LIBDEPS)
! 	$(CC) $(ALL_CFLAGS) $(LDFLAGS) $(CC1_LDFLAGS) -o $@ $(C_OBJS) $(OBJS) $(BC_OBJS) $(LIBS)
  
  # Copy float.h from its source.
  gfloat.h: $(FLOAT_H)
diff -r -c3p egcs-1.0.3a.orig/gcc/c-decl.c egcs-1.0.3a/gcc/c-decl.c
*** egcs-1.0.3a.orig/gcc/c-decl.c	Mon Feb  9 13:15:13 1998
--- egcs-1.0.3a/gcc/c-decl.c	Wed Jul  1 10:06:24 1998
*************** int flag_no_builtin;
*** 450,455 ****
--- 450,468 ----
  
  int flag_no_nonansi_builtin;
  
+ #ifdef REAL_MEMORY_TARGET
+  /* Nonzero means to disable the usual behavior of __builtin_alloca(),
+     i.e. treat __builtin_alloca() as any other `libc' function.
+ 
+     Under MachTen, the builtin version of alloca is implemented with special
+     inline instructions that make runtime adjustments to the stack pointer,
+     calling _alloca_no_stack() when the stack is insufficient for a request.
+     This later action should only happen in a physical memory environment.
+     (95/12/04 dsr) */
+ 
+  int flag_no_builtin_alloca;
+ #endif
+ 
  /* Nonzero means do some things the same way PCC does.  */
  
  int flag_traditional;
*************** c_decode_option (p)
*** 642,647 ****
--- 655,666 ----
      flag_no_builtin = 0;
    else if (!strcmp (p, "-fno-builtin"))
      flag_no_builtin = 1;
+ #ifdef REAL_MEMORY_TARGET
+   else if( !strcmp( p,"-fbuiltin-alloca" ) )
+     flag_no_builtin_alloca = 0;
+   else if( !strcmp( p,"-fno-builtin-alloca" ) ) 
+     flag_no_builtin_alloca = 1;
+ #endif
    else if (!strcmp (p, "-fno-ident"))
      flag_no_ident = 1;
    else if (!strcmp (p, "-fident"))
*************** init_decl_processing ()
*** 3223,3228 ****
--- 3242,3250 ----
  						endlink))),
       BUILT_IN_SET_EH_REGS, NULL_PTR);
  
+ #ifdef REAL_MEMORY_TARGET
+   if( !flag_no_builtin_alloca )
+ #endif
    builtin_function ("__builtin_alloca",
  		    build_function_type (ptr_type_node,
  					 tree_cons (NULL_TREE,
*************** init_decl_processing ()
*** 3234,3239 ****
--- 3256,3265 ----
       Declare _exit just to mark it as volatile.  */
    if (! flag_no_builtin && !flag_no_nonansi_builtin)
      {
+ #ifdef REAL_MEMORY_TARGET
+       if( !flag_no_builtin_alloca )
+       {
+ #endif
        temp = builtin_function ("alloca",
  			       build_function_type (ptr_type_node,
  						    tree_cons (NULL_TREE,
*************** init_decl_processing ()
*** 3242,3247 ****
--- 3268,3276 ----
  			       BUILT_IN_ALLOCA, NULL_PTR);
        /* Suppress error if redefined as a non-function.  */
        DECL_BUILT_IN_NONANSI (temp) = 1;
+ #ifdef REAL_MEMORY_TARGET
+       }
+ #endif
        temp = builtin_function ("ffs", int_ftype_int, BUILT_IN_FFS, NULL_PTR);
        /* Suppress error if redefined as a non-function.  */
        DECL_BUILT_IN_NONANSI (temp) = 1;
diff -r -c3p egcs-1.0.3a.orig/gcc/c-pragma.c egcs-1.0.3a/gcc/c-pragma.c
*** egcs-1.0.3a.orig/gcc/c-pragma.c	Mon Aug 11 08:57:03 1997
--- egcs-1.0.3a/gcc/c-pragma.c	Wed Jul  1 18:03:12 1998
*************** handle_pragma_token (string, token)
*** 59,64 ****
--- 59,90 ----
  	  else
  	    warning ("malformed `#pragma pack'");
  	}
+ #ifdef __MACHTEN__
+       else if( type == ps_align ) {
+           if( state == ps_right )
+             maximum_field_alignment = align * 8;
+           else
+             warning( "malformed `#pragma align`" );
+       } else if( type == ps_options ) {
+           /* a great deal of the source already supports this form of pragma */
+           /* simply cheaper to modify the compiler than to fix everything */
+           if( state == ps_value ) {
+                 if( strcmp( value,"native" ) == 0  ||
+                     strcmp( value,"power" ) == 0 )
+                         maximum_field_alignment = 32;
+                 else
+                 if( strcmp( value,"mac68k" ) == 0  ||
+                     strcmp( value,"m68k" ) == 0 )
+                         maximum_field_alignment = 16;
+                 else
+                 if( strcmp( value,"reset" ) == 0 )
+                         maximum_field_alignment = TARGET_ALIGN_M68K ? 16 : 32;
+                 else
+                         maximum_field_alignment = 32;
+           } else
+             warning( "malformed `#pragma options align = <reset|mac68k|native|power>`" );
+       }
+ #endif
        else if (type == ps_weak)
  	{
  #ifdef HANDLE_PRAGMA_WEAK
*************** handle_pragma_token (string, token)
*** 81,92 ****
--- 107,140 ----
  	    type = state = ps_pack;
  	  else if (strcmp (IDENTIFIER_POINTER (token), "weak") == 0)
  	    type = state = ps_weak;
+ #ifdef __MACHTEN__
+           else if( strcmp( IDENTIFIER_POINTER (token), "align") == 0 ) {
+             type = ps_align;
+             state = ps_pack;
+           }
+           else if( strcmp( IDENTIFIER_POINTER (token), "options" ) == 0 ) {
+             type = ps_options;
+             state = ps_options;
+           }
+ #endif
  	  else
+ 
  	    type = state = ps_done;
  	}
        else
  	type = state = ps_done;
        break;
+ #ifdef __MACHTEN__
+     case ps_options:
+       if( token && TREE_CODE (token) == IDENTIFIER_NODE ) {
+       if( strcmp( IDENTIFIER_POINTER(token),"align" ) == 0 )
+         state = ps_opt_align;
+       else
+         state = ps_bad;
+       } else
+       type = state = ps_done;
+       break;
+ #endif
  
      case ps_weak:
        if (token && TREE_CODE (token) == IDENTIFIER_NODE)
*************** handle_pragma_token (string, token)
*** 97,103 ****
        else
  	state = ps_bad;
        break;
! 
      case ps_name:
        state = (strcmp (string, "=") ? ps_bad : ps_equals);
        break;
--- 145,153 ----
        else
  	state = ps_bad;
        break;
! #ifdef __MACHTEN__
!     case ps_opt_align:
! #endif
      case ps_name:
        state = (strcmp (string, "=") ? ps_bad : ps_equals);
        break;
*************** handle_pragma_token (string, token)
*** 131,136 ****
--- 181,189 ----
  	  case 1:
  	  case 2:
  	  case 4:
+ #ifdef __MACHTEN__
+ 	  case 8:
+ #endif
  	    align = TREE_INT_CST_LOW (token);
  	    state = ps_align;
  	    break;
diff -r -c3p egcs-1.0.3a.orig/gcc/c-pragma.h egcs-1.0.3a/gcc/c-pragma.h
*** egcs-1.0.3a.orig/gcc/c-pragma.h	Mon Aug 11 08:57:03 1997
--- egcs-1.0.3a/gcc/c-pragma.h	Wed Jul  1 10:12:23 1998
*************** enum pragma_state
*** 36,41 ****
--- 36,45 ----
    ps_pack,
    ps_left,
    ps_align,
+ #ifdef __MACHTEN__
+   ps_options,
+   ps_opt_align,
+ #endif
    ps_right
  };
  
diff -r -c3p egcs-1.0.3a.orig/gcc/config/rs6000/rs6000.c egcs-1.0.3a/gcc/config/rs6000/rs6000.c
*** egcs-1.0.3a.orig/gcc/config/rs6000/rs6000.c	Sat Apr 18 15:24:37 1998
--- egcs-1.0.3a/gcc/config/rs6000/rs6000.c	Wed Jul  1 17:33:01 1998
*************** static char alt_reg_names[][8] =
*** 150,155 ****
--- 150,159 ----
  #define MASK_STRICT_ALIGN 0
  #endif
  
+ #ifdef __MACHTEN__
+ extern int maximum_field_alignment;
+ #endif
+ 
  /* Override command line options.  Mostly we process the processor
     type and sometimes adjust other TARGET_ options.  */
  
*************** rs6000_override_options (default_cpu)
*** 183,188 ****
--- 187,197 ----
  	 {"power2", PROCESSOR_POWER,
  	    MASK_POWER | MASK_POWER2 | MASK_MULTIPLE | MASK_STRING,
  	    POWERPC_MASKS | MASK_NEW_MNEMONICS},
+ #ifdef __MACHTEN__
+ 	 {"ppc", PROCESSOR_POWERPC,
+ 	    MASK_POWERPC | MASK_NEW_MNEMONICS,
+ 	    POWER_MASKS | POWERPC_OPT_MASKS | MASK_POWERPC64},
+ #endif
  	 {"powerpc", PROCESSOR_POWERPC,
  	    MASK_POWERPC | MASK_NEW_MNEMONICS,
  	    POWER_MASKS | POWERPC_OPT_MASKS | MASK_POWERPC64},
*************** rs6000_override_options (default_cpu)
*** 328,333 ****
--- 337,349 ----
  #ifdef SUBTARGET_OVERRIDE_OPTIONS
    SUBTARGET_OVERRIDE_OPTIONS;
  #endif
+ #ifdef __MACHTEN__
+   if( TARGET_ALIGN_M68K )
+     maximum_field_alignment = 16;
+   if( TARGET_ALIGN_PPC )
+     maximum_field_alignment = 32;
+ #endif
+ 
  }
  
  /* Do anything needed at the start of the asm file.  */
*************** output_prolog (file, size)
*** 3666,3671 ****
--- 3682,3750 ----
  	sp_reg = 12;
        rs6000_allocate_stack_space (file, info->total_size, sp_reg == 12);
      }
+ #ifdef REAL_MEMORY_TARGET
+   /* If -fstack-check was specified and we will create a stack frame, emit
+      code to verify that available space is sufficient for this function's
+      direct need, plus a red zone if it calls other functions, before
+      writing to new stack area (i.e. beneath current stack pointer).
+      R13 contains the threshold the stack must not grow below.  */
+   if (flag_stack_check && info->push_p)
+     {
+       int stk_size;
+       char buf[32];
+       static int overrun_defined;
+       static stack_check_labelno;
+ 
+       if (! overrun_defined)
+       {
+         fputs ("\t.extern ._stack_overrun\n", file);
+         overrun_defined = 1;
+       }
+ 
+       ASM_GENERATE_INTERNAL_LABEL (buf, "LSC", ++stack_check_labelno);
+ 
+ #define RED_ZONE 224
+       /* Stack space required by this function.  If it calls other
+        functions, also provide a red zone on the stack for possible
+        use by any leaf functions.  */
+       stk_size = -info->total_size;
+       if (info->calls_p)
+       stk_size -= RED_ZONE;
+ 
+       /* Preserve the link register; we may need to call the stack overrun
+        handler and we want a complete call history.  */
+       asm_fprintf (file, "\tmflr %s\n", reg_names[0]);
+ 
+       /* Calculate adjusted stack pointer.  */
+       if (stk_size < -32767)
+       {
+         asm_fprintf (file, "\t{liu|lis} %s,%d\n\t{oril|ori} %s,%s,%d\n",
+                      reg_names[12], (stk_size >> 16) & 0xFFFF,
+                      reg_names[12], reg_names[12], stk_size & 0xFFFF);
+         asm_fprintf (file, "\t{a|addc} %s,%s,%s\n",
+                      reg_names[12], reg_names[1], reg_names[12]);
+       }
+       else
+       asm_fprintf (file, "\t{ai|addic} %s,%s,%d\n",
+                    reg_names[12], reg_names[1], stk_size);
+ 
+       /* Save the link register now.  */
+       asm_fprintf (file, store_reg, reg_names[0],
+                  info->lr_save_offset + sp_offset, reg_names[sp_reg]);
+ 
+       /* If the stack exceeds the threshold, establish a minimal stack frame
+        and dispatch to the overrun handler which is statically linked.  */
+       asm_fprintf (file, "\tcmpl %s,%s,%s\n\tble ",
+                  reg_names[68], reg_names[13], reg_names[12]);
+       assemble_name (file, buf);
+       asm_fprintf (file, (TARGET_64BIT) ? "\n\tstdu" : "\n\t{stu|stwu}");
+       asm_fprintf (file, " %s,%d(%s)\n\tbl ._stack_overrun\n",
+                  reg_names[1], -RS6000_SAVE_AREA-RS6000_REG_SAVE, reg_names[1]);
+       assemble_name (file, buf);
+       fprintf (file, ":\n");
+     }
+   else
+ #endif	/* REAL_MEMORY_TARGET */
  
    /* If we use the link register, get it into r0.  */
    if (info->lr_save_p)
*************** output_prolog (file, size)
*** 3720,3726 ****
--- 3799,3809 ----
  #endif
  
    /* Save lr if we used it.  */
+ #ifdef REAL_MEMORY_TARGET
+   if( info->lr_save_p && !(flag_stack_check && info->push_p) )
+ #else
    if (info->lr_save_p)
+ #endif
      asm_fprintf (file, store_reg, reg_names[0], info->lr_save_offset + sp_offset,
  		 reg_names[sp_reg]);
  
diff -r -c3p egcs-1.0.3a.orig/gcc/config/rs6000/rs6000.h egcs-1.0.3a/gcc/config/rs6000/rs6000.h
*** egcs-1.0.3a.orig/gcc/config/rs6000/rs6000.h	Tue Feb 17 15:02:53 1998
--- egcs-1.0.3a/gcc/config/rs6000/rs6000.h	Wed Jul  1 17:33:11 1998
*************** extern int target_flags;
*** 265,270 ****
--- 265,278 ----
  /* Disable fused multiply/add operations */
  #define MASK_NO_FUSED_MADD	0x00020000
  
+ #ifdef __MACHTEN__
+ /* Enable 16-bit M68000 data structure alignment */
+ #define MASK_ALIGNM68K          0x00040000
+ 
+ /* Enable 32-bit PPC data structure alignment */
+ #define MASK_ALIGNPPC           0x00080000
+ #endif
+ 
  #define TARGET_POWER		(target_flags & MASK_POWER)
  #define TARGET_POWER2		(target_flags & MASK_POWER2)
  #define TARGET_POWERPC		(target_flags & MASK_POWERPC)
*************** extern int target_flags;
*** 283,288 ****
--- 291,301 ----
  #define TARGET_STRING_SET	(target_flags & MASK_STRING_SET)
  #define TARGET_NO_UPDATE	(target_flags & MASK_NO_UPDATE)
  #define TARGET_NO_FUSED_MADD	(target_flags & MASK_NO_FUSED_MADD)
+ #ifdef __MACHTEN__
+ #define TARGET_ALIGN_M68K       (target_flags & MASK_ALIGNM68K)
+ #define TARGET_ALIGN_PPC        (target_flags & MASK_ALIGNPPC)
+ #endif
+ 
  
  #define TARGET_32BIT		(! TARGET_64BIT)
  #define TARGET_HARD_FLOAT	(! TARGET_SOFT_FLOAT)
*************** extern int target_flags;
*** 374,379 ****
--- 387,394 ----
    {"no-update",		MASK_NO_UPDATE},				\
    {"fused-madd",	- MASK_NO_FUSED_MADD},				\
    {"no-fused-madd",	MASK_NO_FUSED_MADD},				\
+   {"align68k",          MASK_ALIGNM68K},                                \
+   {"alignppc",          MASK_ALIGNPPC},                                 \
    SUBTARGET_SWITCHES							\
    {"",			TARGET_DEFAULT}}
  
diff -r -c3p egcs-1.0.3a.orig/gcc/config.sub egcs-1.0.3a/gcc/config.sub
*** egcs-1.0.3a.orig/gcc/config.sub	Wed Sep 10 14:18:25 1997
--- egcs-1.0.3a/gcc/config.sub	Wed Jul  1 10:29:24 1998
*************** case $basic_machine in
*** 181,186 ****
--- 181,188 ----
  	      | sparc64-* | mips64-* | mipsel-* \
  	      | mips64el-* | mips64orion-* | mips64orionel-* | f301-*)
  		;;
+ 	m68*-mac* | ppc*-mac* )
+ 		;;
  	# Recognize the various machine names and aliases which stand
  	# for a CPU type and a company and sometimes even an OS.
  	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
diff -r -c3p egcs-1.0.3a.orig/gcc/configure egcs-1.0.3a/gcc/configure
*** egcs-1.0.3a.orig/gcc/configure	Fri May 15 10:24:26 1998
--- egcs-1.0.3a/gcc/configure	Wed Jul  1 18:22:27 1998
*************** for machine in $build $host $target; do
*** 2739,2744 ****
--- 2739,2753 ----
  		fi
  		tm_file="${tm_file} m68k/a-ux.h"
  		;;
+ 	m68*-mac-machten*)
+                tm_file=m68k/machten68k.h
+                xm_file=m68k/xm-machten68k.h
+                tmake_file=m68k/t-machten68k
+                xmake_file=m68k/x-machten68k
+                extra_headers=math-68881.h
+                # On MachTen, the headers are already ok.
+                fixincludes=Makefile.in
+                ;;
  	m68k-apollo-*)
  		tm_file=m68k/apollo68.h
  		xmake_file=m68k/x-apollo68
*************** for machine in $build $host $target; do
*** 3624,3629 ****
--- 3633,3663 ----
  		xmake_file=pyr/x-pyr
  		use_collect2=yes
  		;;
+  
+         powerpc-apple-machten*)
+                 cpu_type=rs6000
+                 tm_file=rs6000/machtenppc.h
+                 out_file=rs6000/machtenppc.c
+                 xm_file=rs6000/xm-machtenppc.h
+                 tmake_file=rs6000/t-machtenppc
+                 xmake_file=rs6000/x-machtenppc
+                 # On MachTen, the headers are already ok.
+                 fixincludes=Makefile.in
+ 		use_collect2=no
+                 ;;
+  
  	romp-*-aos*)
  		use_collect2=yes
  		;;
diff -r -c3p egcs-1.0.3a.orig/gcc/cp/decl.c egcs-1.0.3a/gcc/cp/decl.c
*** egcs-1.0.3a.orig/gcc/cp/decl.c	Mon Mar  2 16:55:34 1998
--- egcs-1.0.3a/gcc/cp/decl.c	Wed Jul  1 10:37:06 1998
*************** extern int flag_no_builtin;
*** 490,495 ****
--- 490,508 ----
  
  extern int flag_no_nonansi_builtin;
  
+ #ifdef REAL_MEMORY_TARGET
+ /* Nonzero means to disable the usual behavior of __builtin_alloca(),
+    i.e. treat __builtin_alloca() as any other `libc' function.
+ 
+    Under MachTen, the builtin version of alloca is implemented with special
+    inline instructions that make runtime adjustments to the stack pointer,
+    calling _alloca_no_stack() when the stack is insufficient for a request.
+    This later action should only happen in a physical memory environment.
+    (95/12/04 dsr) */
+ 
+ extern int flag_no_builtin_alloca;
+ #endif
+ 
  /* Nonzero means enable obscure ANSI features and disable GNU extensions
     that might cause ANSI-compliant code to be miscompiled.  */
  
*************** init_decl_processing ()
*** 5165,5170 ****
--- 5178,5186 ----
    builtin_function ("__builtin_fp", ptr_ftype_void, BUILT_IN_FP, NULL_PTR);
    builtin_function ("__builtin_sp", ptr_ftype_void, BUILT_IN_SP, NULL_PTR);
  
+ #ifdef REAL_MEMORY_TARGET
+   if( !flag_no_builtin_alloca )
+ #endif
    builtin_function ("__builtin_alloca", ptr_ftype_sizetype,
  		    BUILT_IN_ALLOCA, "alloca");
    builtin_function ("__builtin_ffs", int_ftype_int, BUILT_IN_FFS, NULL_PTR);
*************** init_decl_processing ()
*** 5172,5181 ****
--- 5188,5203 ----
       Declare _exit just to mark it as volatile.  */
    if (! flag_no_builtin && !flag_no_nonansi_builtin)
      {
+ #ifdef REAL_MEMORY_TARGET
+       if( ! flag_no_builtin_alloca )
+ #endif
        temp = builtin_function ("alloca", ptr_ftype_sizetype,
  			       BUILT_IN_ALLOCA, NULL_PTR);
        /* Suppress error if redefined as a non-function.  */
        DECL_BUILT_IN_NONANSI (temp) = 1;
+ #ifdef REAL_MEMORY_TARGET
+       }
+ #endif
        temp = builtin_function ("ffs", int_ftype_int, BUILT_IN_FFS, NULL_PTR);
        /* Suppress error if redefined as a non-function.  */
        DECL_BUILT_IN_NONANSI (temp) = 1;
diff -r -c3p egcs-1.0.3a.orig/gcc/cp/decl2.c egcs-1.0.3a/gcc/cp/decl2.c
*** egcs-1.0.3a.orig/gcc/cp/decl2.c	Thu Feb 12 11:57:23 1998
--- egcs-1.0.3a/gcc/cp/decl2.c	Wed Jul  1 10:39:38 1998
*************** int flag_no_builtin;
*** 119,124 ****
--- 119,137 ----
  
  int flag_no_nonansi_builtin;
  
+ #ifdef REAL_MEMORY_TARGET
+ /* Nonzero means to disable the usual behavior of __builtin_alloca(),
+    i.e. treat __builtin_alloca() as any other `libc' function.
+ 
+    Under MachTen, the builtin version of alloca is implemented with special
+    inline instructions that make runtime adjustments to the stack pointer,
+    calling _alloca_no_stack() when the stack is insufficient for a request.
+    This later action should only happen in a physical memory environment.
+    (95/12/04 dsr) */
+ 
+ int flag_no_builtin_alloca;
+ #endif
+ 
  /* Nonzero means do some things the same way PCC does.  Only provided so
     the compiler will link.  */
  
*************** static struct { char *string; int *varia
*** 434,439 ****
--- 447,455 ----
    {"cond-mismatch", &flag_cond_mismatch, 1},
    {"asm", &flag_no_asm, 0},
    {"builtin", &flag_no_builtin, 0},
+ #ifdef REAL_MEMORY_TARGET
+   {"builtin-alloca", &flag_no_builtin_alloca, 0},
+ #endif
    {"ident", &flag_no_ident, 0},
    {"labels-ok", &flag_labels_ok, 1},
    {"stats", &flag_detailed_statistics, 1},
diff -r -c3p egcs-1.0.3a.orig/gcc/expr.c egcs-1.0.3a/gcc/expr.c
*** egcs-1.0.3a.orig/gcc/expr.c	Tue Feb 24 00:33:46 1998
--- egcs-1.0.3a/gcc/expr.c	Wed Jul  1 10:40:37 1998
*************** expand_builtin (exp, target, subtarget, 
*** 8700,8706 ****
--- 8700,8710 ----
        op0 = expand_expr (TREE_VALUE (arglist), NULL_RTX, VOIDmode, 0);
  
        /* Allocate the desired space.  */
+ #ifdef TARGET_BUILT_IN_ALLOCA
+       TARGET_BUILT_IN_ALLOCA
+ #else
        return allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
+ #endif
  
      case BUILT_IN_FFS:
        /* If not optimizing, call the library function.  */
diff -r -c3p egcs-1.0.3a.orig/gcc/function.c egcs-1.0.3a/gcc/function.c
*** egcs-1.0.3a.orig/gcc/function.c	Sun Feb  8 15:01:35 1998
--- egcs-1.0.3a/gcc/function.c	Wed Jul  1 10:48:17 1998
*************** assign_parms (fndecl, second_time)
*** 3343,3348 ****
--- 3343,3351 ----
    /* Nonzero if the last arg is named `__builtin_va_alist',
       which is used on some machines for old-fashioned non-ANSI varargs.h;
       this should be stuck onto the stack as if it had arrived there.  */
+ #ifdef __MACHTEN__
+   int hide_last_arg;
+ #else
    int hide_last_arg
      = (current_function_varargs
         && fnargs
*************** assign_parms (fndecl, second_time)
*** 3350,3356 ****
         && DECL_NAME (parm)
         && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (parm)),
  		     "__builtin_va_alist")));
! 
    /* Nonzero if function takes extra anonymous args.
       This means the last named arg must be on the stack
       right before the anonymous ones.  */
--- 3353,3359 ----
         && DECL_NAME (parm)
         && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (parm)),
  		     "__builtin_va_alist")));
! #endif
    /* Nonzero if function takes extra anonymous args.
       This means the last named arg must be on the stack
       right before the anonymous ones.  */
*************** assign_parms (fndecl, second_time)
*** 3358,3363 ****
--- 3361,3381 ----
      = (TYPE_ARG_TYPES (fntype) != 0
         && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
  	   != void_type_node));
+ 
+ #ifdef __MACHTEN__
+   /* If the last arg is named `__builtin_va_alist', assume that this
+      function is using the services of varargs.h and set appropriate
+      local and global parameters */
+   if (fnargs
+       && (parm = tree_last (fnargs)) != 0
+       && DECL_NAME (parm)
+       && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (parm)),
+                    "__builtin_va_alist")))
+     {
+       hide_last_arg = 1;
+       current_function_varargs = 1;
+     }
+ #endif
  
    current_function_stdarg = stdarg;
  
diff -r -c3p egcs-1.0.3a.orig/gcc/gcc.c egcs-1.0.3a/gcc/gcc.c
*** egcs-1.0.3a.orig/gcc/gcc.c	Mon Sep  1 10:02:40 1997
--- egcs-1.0.3a/gcc/gcc.c	Wed Jul  1 10:59:04 1998
*************** compilation is specified by a string cal
*** 45,50 ****
--- 45,54 ----
  #include "obstack.h"
  #include "gansidecl.h"
  
+ #ifdef __MACHTEN__
+ #define PRAGMA_ALIGN_SUPPORTED	1
+ #endif
+ 
  #ifdef __STDC__
  #include <stdarg.h>
  #else
*************** static int n_default_compilers
*** 702,707 ****
--- 706,722 ----
  /* We want %{T*} after %{L*} and %D so that it can be used to specify linker
     scripts which exist in user specified directories, or in standard
     directories.  */
+ #ifdef __MACHTEN__
+ /* Generate -L options (as usual) and additional MachTen options;
+    libgcc.a absorbed into libc.a.  */
+ static char *link_command_spec = "\
+ %{!fsyntax-only: \
+  %{!c:%{!M:%{!MM:%{!E:%{!S:ld %l %X %{o*} %{A} %{c} %{cross} %{d} %{e*} %{m}\
+                       %{N} %{n} %{r} %{S} %{s} %{stack} %{t} %{u*}\
+                       %{X} %{x} %{y*} %{z}\
+                       %{!A:%{!nostartfiles:%{!nostdlib:%S}}} %{static:}\
+                       %{L*} %D %{T*} %o %{!nostdlib:%L %{!A:%E}}\n }}}}}}";
+ #else
  #ifdef LINK_LIBGCC_SPECIAL
  /* Don't generate -L options.  */
  static char *link_command_spec = "\
*************** static char *link_command_spec = "\
*** 727,732 ****
--- 742,748 ----
  			%{T*}\
  			\n }}}}}}";
  #endif
+ #endif
  
  /* A vector of options to give to the linker.
     These options are accumulated by %x,
*************** process_command (argc, argv)
*** 2585,2590 ****
--- 2601,2620 ----
  	  n_infiles++;
  	  i++;
  	}
+ #ifdef REAL_MEMORY_TARGET
+       else if (strncmp (argv[i], "-Xl", 3) == 0)
+       {
+         n_linker_options++;
+         if (!linker_options)
+           linker_options
+             = (char **) xmalloc (n_linker_options * sizeof (char **));
+         else
+           linker_options
+             = (char **) xrealloc (linker_options,
+                                   n_linker_options * sizeof (char **));
+         linker_options[n_linker_options - 1] = argv[i];
+       }
+ #endif
        else if (strncmp (argv[i], "-l", 2) == 0)
  	n_infiles++;
        else if (strcmp (argv[i], "-save-temps") == 0)
*************** process_command (argc, argv)
*** 2870,2875 ****
--- 2900,2909 ----
  	  infiles[n_infiles].language = 0;
  	  infiles[n_infiles++].name = argv[++i];
  	}
+ #ifdef REAL_MEMORY_TARGET
+       else if( strncmp( argv[i],"-Xl",3) == 0 )
+ 	;
+ #endif
        else if (strncmp (argv[i], "-l", 2) == 0)
  	{
  	  infiles[n_infiles].language = 0;
diff -r -c3p egcs-1.0.3a.orig/gcc/invoke.texi egcs-1.0.3a/gcc/invoke.texi
*** egcs-1.0.3a.orig/gcc/invoke.texi	Tue Dec  2 22:02:05 1997
--- egcs-1.0.3a/gcc/invoke.texi	Wed Jul  1 11:03:13 1998
*************** in the following sections.
*** 93,100 ****
--- 93,106 ----
  @item C Language Options
  @xref{C Dialect Options,,Options Controlling C Dialect}.
  @smallexample
+ @ifclear REAL_MEMORY_TARGET
  -ansi  -fallow-single-precision  -fcond-mismatch  -fno-asm
  -fno-builtin  -ffreestanding  -fhosted  -fsigned-bitfields  -fsigned-char
+ @end ifclear
+ @ifset REAL_MEMORY_TARGET
+ -ansi -fallow-single-precision -fbuiltin-alloca -fcond-mismatch
+ -fno-asm -fno-builtin -ffreestanding -fhosted -fsigned-bitfields -fsigned char
+ @end ifset
  -funsigned-bitfields  -funsigned-char  -fwritable-strings
  -traditional  -traditional-cpp  -trigraphs
  @end smallexample
*************** The preprocessor considers a string cons
*** 787,792 ****
--- 793,807 ----
  the newline is escaped with @samp{\}).  (Without @w{@samp{-traditional}},
  string constants can contain the newline character as typed.)
  @end itemize
+ 
+ @ifset REAL_MEMORY_TARGET
+ @item -fbuiltin-alloca
+ Recognize @code{__builtin_alloca} as a built-in function and emit code which
+ directly manipulates the stack.  This is not recommended for systems not
+ providing virtual memory; instead use __builtin_alloca function supplied
+ in libc.a, which determines at runtime how best to satisfy the request.
+ 
+ @end ifset
  
  @item -fcond-mismatch
  Allow conditional expressions with mismatched types in the second and
Only in egcs-1.0.3a/gcc: mt-diffs-2.8.1
diff -r -c3p egcs-1.0.3a.orig/gcc/toplev.c egcs-1.0.3a/gcc/toplev.c
*** egcs-1.0.3a.orig/gcc/toplev.c	Sun Feb  8 16:56:08 1998
--- egcs-1.0.3a/gcc/toplev.c	Wed Jul  1 12:39:01 1998
*************** char *lang_options[] =
*** 775,780 ****
--- 775,784 ----
    "-fno-asm",
    "-fbuiltin",
    "-fno-builtin",
+ #ifdef REAL_MEMORY_TARGET
+   "-fbuiltin-alloca",
+   "-fno-builtin-alloca",
+ #endif
    "-fhosted",
    "-fno-hosted",
    "-ffreestanding",
diff -r -c3p egcs-1.0.3a.orig/gcc/tree.c egcs-1.0.3a/gcc/tree.c
*** egcs-1.0.3a.orig/gcc/tree.c	Fri Nov 14 06:30:00 1997
--- egcs-1.0.3a/gcc/tree.c	Wed Jul  1 11:09:09 1998
*************** gcc_obstack_init (obstack)
*** 327,332 ****
--- 327,340 ----
  #ifndef OBSTACK_CHUNK_SIZE
  #define OBSTACK_CHUNK_SIZE 0
  #endif
+ 
+ #ifdef REAL_MEMORY_TARGET
+   /* Let them override the alignment within a chunk. */
+ #ifndef OBSTACK_CHUNK_ALIGNMENT
+ #define OBSTACK_CHUNK_ALIGNMENT 0
+ #endif
+ #endif
+ 
    /* Let them override the alloc and free routines too.  */
  #ifndef OBSTACK_CHUNK_ALLOC
  #define OBSTACK_CHUNK_ALLOC xmalloc
*************** gcc_obstack_init (obstack)
*** 334,340 ****
--- 342,353 ----
  #ifndef OBSTACK_CHUNK_FREE
  #define OBSTACK_CHUNK_FREE free
  #endif
+ 
+ #ifdef REAL_MEMORY_TARGET
+   _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, OBSTACK_CHUNK_ALIGNMENT,
+ #else
    _obstack_begin (obstack, OBSTACK_CHUNK_SIZE, 0,
+ #endif
  		  (void *(*) ()) OBSTACK_CHUNK_ALLOC,
  		  (void (*) ()) OBSTACK_CHUNK_FREE);
  }


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