/* Definitions of target machine for GNU compiler.  "naked" 68020,
   COFF object files and debugging, version.
   Copyright (C) 1994 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 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 "m68k/m68k-coff.h"
#define  PALMOS 1

/* a5 is fixed as the PIC register */
#undef FIXED_REGISTERS
#define FIXED_REGISTERS        \
 {/* Data registers.  */       \
  0, 0, 0, 0, 0, 0, 0, 0,      \
                               \
  /* Address registers.  */    \
  0, 0, 0, 0, 0, 1, 0, 1,      \
                               \
  /* Floating point registers  \
     (if available).  */       \
  0, 0, 0, 0, 0, 0, 0, 0 }

#undef CALL_USED_REGISTERS
#define CALL_USED_REGISTERS \
 {1, 1, 1, 0, 0, 0, 0, 0,   \
  1, 1, 0, 0, 0, 1, 0, 1,   \
  1, 1, 0, 0, 0, 0, 0, 0 }

/* Under PalmOS/m68k scalars are returned in D0, and pointers 
   are returned in A0.  We do so because CodeWarrior does.*/

#undef FUNCTION_VALUE
#define FUNCTION_VALUE(VALTYPE, FUNC)  \
 gen_rtx (REG, TYPE_MODE (VALTYPE), (FUNC) == 0 ? 0 : \
	  (TREE_CODE (TREE_TYPE (TREE_TYPE (FUNC))) == POINTER_TYPE ? 8 : 0))


/* 1 if N is a possible register number for a function value.
   On the 68000, d0/a0 are the only registers thus used.  */

#undef FUNCTION_VALUE_REGNO_P
#define FUNCTION_VALUE_REGNO_P(N) ((N) == 0 || (N) == 8)

#undef PROMOTE_PROTOTYPES

/* -mpcrel -mshort -m68000 -msoft-float */
#undef TARGET_DEFAULT
#define TARGET_DEFAULT 02040

#undef CPP_PREDEFINES
#define CPP_PREDEFINES \
  "-Dm68000 -Dmc68000 -Dm68k -D__palmos__  \
   -Asystem(palmos) -Acpu(m68k) -Amachine(pilot)"

#undef CPP_SPEC
#define CPP_SPEC ""

/* -l makes the assembler generate .w branches only */
#undef ASM_SPEC
#define ASM_SPEC "-mno-68881 -m68000 -l "

#undef CC1_SPEC
#define CC1_SPEC \
   "-fpic -msoft-float -m68000 -fshort-enums \
    %{!Wmulti-char-const:-Wno-multi-char-const}"

/* Unless explicitly overridden, put both text and data at 0 */
#define LINK_SPEC "-T pilot.ld%s" 

#undef STARTFILE_SPEC

/*  */
#define ENCODE_SECTION_INFO(decl) 					\
 { rtx sym; int decl_code = TREE_CODE(decl);				\
   if ((decl_code == VAR_DECL || decl_code == FUNCTION_DECL)		\
       && (sym = DECL_RTL (decl))  	 	 	 	 	\
       && GET_CODE (sym) == MEM  	 	 	 	 	\
       && GET_CODE (XEXP (sym, 0)) == SYMBOL_REF) 	 		\
   {									\
     if(decl_code == VAR_DECL && TREE_ASM_WRITTEN(decl)) 		\
       SYMBOL_REF_FLAG(XEXP (sym, 0)) = DECL_IN_TEXT_SECTION(decl); 	\
     else if (decl_code == FUNCTION_DECL) 			 	\
       SYMBOL_REF_FLAG(XEXP (sym, 0)) = 1;				\
     else			 					\
       SYMBOL_REF_FLAG(XEXP (DECL_RTL (decl), 0)) = 0; 			\
   } else if ((decl_code == REAL_CST 					\
	       || decl_code == STRING_CST 				\
	       || decl_code == COMPLEX_CST 				\
	       || decl_code == CONSTRUCTOR) 				\
	      && (sym = TREE_CST_RTL (decl)) 				\
	      && GET_CODE (sym) == MEM 					\
	      && GET_CODE (XEXP (sym, 0)) == SYMBOL_REF) 		\
   { SYMBOL_REF_FLAG (XEXP (sym, 0)) = 1; }				\
 }

/* We use %a4 as PIC register */
#undef PIC_OFFSET_TABLE_REGNUM
#define PIC_OFFSET_TABLE_REGNUM 12

#undef SUBTARGET_OVERRIDE_OPTIONS
#define SUBTARGET_OVERRIDE_OPTIONS \
  { if (TARGET_PCREL) { flag_no_function_cse = flag_pic = 1; } }

#undef SUBTARGET_SWITCHES
#define SUBTARGET_SWITCHES \
   { "debug-labels", 04000 }, \
   { "no-debug-labels", -04000 },

#define TARGET_DEBUG_LABELS (target_flags & 04000)

#undef LEGITIMATE_PIC_OPERAND_P
#define LEGITIMATE_PIC_OPERAND_P(X)	\
  ((! symbolic_operand (X, VOIDmode)				\
    && ! (GET_CODE (X) == CONST_DOUBLE && CONST_DOUBLE_MEM (X)	\
	  && GET_CODE (CONST_DOUBLE_MEM (X)) == MEM		\
	  && symbolic_operand (XEXP (CONST_DOUBLE_MEM (X), 0),	\
			       VOIDmode)))	  \
   || (GET_CODE (X) == PLUS \
       && GET_CODE (XEXP (X, 0)) == PC \
       && GET_CODE (XEXP (X, 1)) == SYMBOL_REF \
       && SYMBOL_REF_FLAG (XEXP (X, 1))) \
   || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X)) \
   || (GET_CODE (X) == MEM && GET_CODE (XEXP (X,0) ) == SYMBOL_REF && SYMBOL_REF_FLAG (XEXP (X, 0))))

#define INCLUDE_DEFAULTS \
 {						\
    { GPLUSPLUS_INCLUDE_DIR, 1, 1 }, 		\
    { GCC_INCLUDE_DIR, 0, 0 }, 			\
    { CROSS_INCLUDE_DIR, 0, 0 }, 		\
    { CROSS_INCLUDE_DIR "/System", 0, 0 }, 	\
    { CROSS_INCLUDE_DIR "/UI", 0, 0 }, 		\
    { CROSS_INCLUDE_DIR "/Hardware", 0, 0 }, 	\
    { TOOL_INCLUDE_DIR, 0, 0 }, 		\
    { 0, 0, 0 } 				\
 } 




/* end of palmos.h */
