OSDN Git Service

2003-05-17 Andreas Schwab <schwab@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / linux.h
index ce872d9..7a90756 100644 (file)
@@ -1,11 +1,12 @@
-/* Definitions for Motorola 68k running Linux with ELF format.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+/* Definitions for Motorola 68k running Linux-based GNU systems with
+   ELF format.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 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)
+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,
@@ -22,14 +23,22 @@ Boston, MA 02111-1307, USA.  */
 #define MOTOROLA               /* Use Motorola syntax */
 #define USE_GAS                        /* But GAS wants jbsr instead of jsr */
 
+/* TODO: convert includes to ${tm_file} list in config.gcc.  */
 #include <m68k/m68k.h>
+
+/* Make sure CC1 is undefined.  */
+#undef CC1_SPEC
+
+#include "dbxelf.h"
+#include "elfos.h"
+#include "svr4.h"
 #include <linux.h>             /* some common stuff */
 
 #undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (68k Linux/ELF)");
+#define TARGET_VERSION fprintf (stderr, " (68k GNU/Linux with ELF)");
 
 /* 68020 with 68881 */
-#define TARGET_DEFAULT 7
+#define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
 
 /* for 68k machines this only needs to be TRUE for the 68000 */
 
@@ -37,7 +46,8 @@ Boston, MA 02111-1307, USA.  */
 #define STRICT_ALIGNMENT 0
 
 #undef SUBTARGET_SWITCHES
-#define SUBTARGET_SWITCHES     {"ieee-fp", 0},
+#define SUBTARGET_SWITCHES     {"ieee-fp", 0, \
+  N_("Use IEEE math for fp comparisons")},
 
 /* Here are four prefixes that are used by asm_fprintf to
    facilitate customization for alternate assembler syntaxes.
@@ -52,42 +62,29 @@ Boston, MA 02111-1307, USA.  */
 #define REGISTER_PREFIX "%"
 
 /* The prefix for local (compiler generated) labels.
-   These labels will not appear in the symbol table. */
+   These labels will not appear in the symbol table.  */
 
 #undef LOCAL_LABEL_PREFIX
 #define LOCAL_LABEL_PREFIX "."
 
-/* The prefix to add to user-visible assembler symbols. */
+/* The prefix to add to user-visible assembler symbols.  */
 
 #undef USER_LABEL_PREFIX
 #define USER_LABEL_PREFIX ""
 
+#define ASM_COMMENT_START "|"
+
 /* How to refer to registers in assembler output.
    This sequence is indexed by compiler's hard-register-number.
-   Motorola format uses different register names than defined in m68k.h. */
+   Motorola format uses different register names than defined in m68k.h.  */
 
 #undef REGISTER_NAMES
 
-#ifndef SUPPORT_SUN_FPA
-
 #define REGISTER_NAMES \
 {"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
  "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
  "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7" }
 
-#else /* SUPPORTED_SUN_FPA */
-
-#define REGISTER_NAMES \
-{"%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7", \
- "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%sp", \
- "%fp0", "%fp1", "%fp2", "%fp3", "%fp4", "%fp5", "%fp6", "%fp7", \
- "%fpa0", "%fpa1", "%fpa2", "%fpa3", "%fpa4", "%fpa5", "%fpa6", "%fpa7", \
- "%fpa8", "%fpa9", "%fpa10","%fpa11","%fpa12","%fpa13","%fpa14","%fpa15", \
- "%fpa16","%fpa17","%fpa18","%fpa19","%fpa20","%fpa21","%fpa22","%fpa23", \
- "%fpa24","%fpa25","%fpa26","%fpa27","%fpa28","%fpa29","%fpa30","%fpa31" }
-
-#endif /* defined SUPPORT_SUN_FPA */
-
 #undef SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
  
@@ -101,18 +98,35 @@ Boston, MA 02111-1307, USA.  */
 #define WCHAR_TYPE_SIZE BITS_PER_WORD
 
 #define CPP_PREDEFINES \
-  "-D__ELF__ -Dunix -Dmc68000 -Dmc68020 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(m68k) -Amachine(m68k)"
+  "-D__ELF__ -Dunix -Dmc68000 -Dmc68020 -D__gnu_linux__ -Dlinux -Asystem=unix -Asystem=posix -Acpu=m68k -Amachine=m68k"
 
 #undef CPP_SPEC
-#if TARGET_DEFAULT & 2
+#ifdef USE_GNULIBC_1
+#if TARGET_DEFAULT & MASK_68881
 #define CPP_SPEC \
   "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
 #else
 #define CPP_SPEC \
   "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
 #endif
+#else
+#if TARGET_DEFAULT & MASK_68881
+#define CPP_SPEC \
+  "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#else
+#define CPP_SPEC \
+  "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+#endif
+#endif
+
+/* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
+   to the assembler.  */
+#undef ASM_SPEC
+#define ASM_SPEC \
+  "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
+%{m68040} %{m68060:-m68040}"
 
-/* Provide a LINK_SPEC appropriate for Linux.  Here we provide support
+/* Provide a LINK_SPEC appropriate for GNU/Linux.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
    link things in one of these three modes by applying the appropriate
    combinations of options at link-time.  We like to support here for
@@ -126,9 +140,10 @@ Boston, MA 02111-1307, USA.  */
    When the -shared link option is used a final link is not being
    done.  */
 
-/* If ELF is the default format, we should not use /lib/elf. */
+/* If ELF is the default format, we should not use /lib/elf.  */
 
 #undef LINK_SPEC
+#ifdef USE_GNULIBC_1
 #ifndef LINUX_DEFAULT_ELF
 #define LINK_SPEC "-m m68kelf %{shared} %{symbolic:-shared -Bsymbolic} \
   %{!shared:%{!symbolic: \
@@ -144,6 +159,14 @@ Boston, MA 02111-1307, USA.  */
       %{!dynamic-linker*:-dynamic-linker /lib/ld-linux.so.1}} \
     %{static}}}"
 #endif
+#else
+#define LINK_SPEC "-m m68kelf %{shared} \
+  %{!shared: \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker*:-dynamic-linker /lib/ld.so.1}} \
+    %{static}}"
+#endif
 
 /* For compatibility with linux/a.out */
 
@@ -156,9 +179,18 @@ Boston, MA 02111-1307, USA.  */
 
 /* Use the default action for outputting the case label.  */
 #undef ASM_OUTPUT_CASE_LABEL
-
-#define ASM_RETURN_CASE_JUMP \
-  return "jmp (2,%%pc,%0.w)"
+#define ASM_RETURN_CASE_JUMP                           \
+  do {                                                 \
+    if (TARGET_5200)                                   \
+      {                                                        \
+       if (ADDRESS_REG_P (operands[0]))                \
+         return "jmp %%pc@(2,%0:l)";                   \
+       else                                            \
+         return "ext%.l %0\n\tjmp %%pc@(2,%0:l)";      \
+      }                                                        \
+    else                                               \
+      return "jmp %%pc@(2,%0:w)";                      \
+  } while (0)
 
 /* This is how to output an assembler line that says to advance the
    location counter to a multiple of 2**LOG bytes.  */
@@ -166,21 +198,21 @@ Boston, MA 02111-1307, USA.  */
 #undef ASM_OUTPUT_ALIGN
 #define ASM_OUTPUT_ALIGN(FILE,LOG)                             \
   if ((LOG) > 0)                                               \
-    fprintf ((FILE), "\t%s \t%u\n", ALIGN_ASM_OP, 1 << (LOG));
+    fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));
 
 /* If defined, a C expression whose value is a string containing the
    assembler operation to identify the following data as uninitialized global
    data.  */
 
-#define BSS_SECTION_ASM_OP ".section\t.bss"
+#define BSS_SECTION_ASM_OP "\t.section\t.bss"
 
 /* A C statement (sans semicolon) to output to the stdio stream
-   FILE the assembler definition of an uninitialized global label named
+   FILE the assembler definition of uninitialized global DECL named
    NAME whose size is SIZE bytes and alignment is ALIGN bytes.
    Try to use asm_output_aligned_bss to implement this macro.  */
 
-#define ASM_OUTPUT_ALIGNED_BSS(FILE, NAME, SIZE, ALIGN) \
-  asm_output_aligned_bss (FILE, NAME, SIZE, ALIGN)
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
+  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
 
 /* Output assembler code to FILE to increment profiler label # LABELNO
    for profiling a function entry.  */
@@ -195,19 +227,6 @@ Boston, MA 02111-1307, USA.  */
     fprintf (FILE, "\tjbsr _mcount\n");                                        \
 }
 
-/* Register in which address to store a structure value is passed to a
-   function.  The default in m68k.h is a1.  For m68k/SVR4 it is a0. */
-
-#undef STRUCT_VALUE_REGNUM
-#define STRUCT_VALUE_REGNUM 8
-
-/* Register in which static-chain is passed to a function.  The
-   default in m68k.h is a0, but that is already the struct value
-   regnum.  Make it a1 instead.  */
-
-#undef STATIC_CHAIN_REGNUM
-#define STATIC_CHAIN_REGNUM 9
-
 /* How to renumber registers for dbx and gdb.
    On the Sun-3, the floating point registers have numbers
    18 to 25, not 16 to 23 as they do in the compiler.  */
@@ -218,9 +237,6 @@ Boston, MA 02111-1307, USA.  */
 
 #define DBX_CONTIN_LENGTH 0
 
-/* Allow folding division by zero.  */
-#define REAL_INFINITY
-
 /* 1 if N is a possible register number for a function value.  For
    m68k/SVR4 allow d0, a0, or fp0 as return registers, for integral,
    pointer, or floating types, respectively.  Reject fp0 if not using
@@ -241,15 +257,15 @@ Boston, MA 02111-1307, USA.  */
    function.  VALTYPE is the data type of the value (as a tree).  If
    the precise function being called is known, FUNC is its
    FUNCTION_DECL; otherwise, FUNC is 0.  For m68k/SVR4 generate the
-   result in d0, a0, or fp0 as appropriate. */
+   result in d0, a0, or fp0 as appropriate.  */
    
 #undef FUNCTION_VALUE
 #define FUNCTION_VALUE(VALTYPE, FUNC)                                  \
   (TREE_CODE (VALTYPE) == REAL_TYPE && TARGET_68881                    \
-   ? gen_rtx (REG, TYPE_MODE (VALTYPE), 16)                            \
+   ? gen_rtx_REG (TYPE_MODE (VALTYPE), 16)                             \
    : (POINTER_TYPE_P (VALTYPE)                                         \
-      ? gen_rtx (REG, TYPE_MODE (VALTYPE), 8)                          \
-      : gen_rtx (REG, TYPE_MODE (VALTYPE), 0)))
+      ? gen_rtx_REG (TYPE_MODE (VALTYPE), 8)                           \
+      : gen_rtx_REG (TYPE_MODE (VALTYPE), 0)))
 
 /* For compatibility with the large body of existing code which does
    not always properly declare external functions returning pointer
@@ -258,11 +274,10 @@ Boston, MA 02111-1307, USA.  */
    callers that have neglected to properly declare the callee can
    still find the correct return value.  */
 
-extern int current_function_returns_pointer;
 #define FUNCTION_EXTRA_EPILOGUE(FILE, SIZE)                            \
 do {                                                                   \
-  if ((current_function_returns_pointer) &&                            \
-      ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))       \
+  if (current_function_returns_pointer                                 \
+      && ! find_equiv_reg (0, get_last_insn (), 0, 0, 0, 8, Pmode))    \
     asm_fprintf (FILE, "\tmove.l %Ra0,%Rd0\n");                                \
 } while (0);
 
@@ -275,62 +290,57 @@ do {                                                                      \
 #define LIBCALL_VALUE(MODE)                                            \
   ((((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode)         \
     && TARGET_68881)                                                   \
-   ? gen_rtx (REG, (MODE), 16)                                         \
-   : gen_rtx (REG, (MODE), 0))
+   ? gen_rtx_REG ((MODE), 16)                                          \
+   : gen_rtx_REG ((MODE), 0))
 
 /* In m68k svr4, a symbol_ref rtx can be a valid PIC operand if it is
-   an operand of a function call. */
+   an operand of a function call.  */
 #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) == SYMBOL_REF && SYMBOL_REF_FLAG (X)))
-
-/* Turn off function cse if we are doing PIC. We always want function
-   call to be done as `bsr foo@PLTPC', so it will force the assembler
-   to create the PLT entry for `foo'.  Doing function cse will cause
-   the address of `foo' to be loaded into a register, which is exactly
-   what we want to avoid when we are doing PIC on svr4 m68k.  */
-#undef SUBTARGET_OVERRIDE_OPTIONS
-#define SUBTARGET_OVERRIDE_OPTIONS \
-  if (flag_pic) flag_no_function_cse = 1;
+    && ! (GET_CODE (X) == CONST_DOUBLE && mem_for_const_double (X) != 0        \
+         && GET_CODE (mem_for_const_double (X)) == MEM                 \
+         && symbolic_operand (XEXP (mem_for_const_double (X), 0),      \
+                              VOIDmode)))                              \
+   || (GET_CODE (X) == SYMBOL_REF && SYMBOL_REF_FLAG (X))              \
+   || PCREL_GENERAL_OPERAND_OK)
 
 /* For m68k SVR4, structures are returned using the reentrant
-   technique. */
+   technique.  */
 #undef PCC_STATIC_STRUCT_RETURN
 #define DEFAULT_PCC_STRUCT_RETURN 0
 
-/* Output assembler code for a block containing the constant parts
-   of a trampoline, leaving space for the variable parts.  */
+/* Finalize the trampoline by flushing the insn cache.  */
 
-/* On m68k svr4, the trampoline is different from the generic version
-   in that we use a1 as the static call chain.  */
+#undef FINALIZE_TRAMPOLINE
+#define FINALIZE_TRAMPOLINE(TRAMP)                                     \
+  emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__clear_cache"),      \
+                    0, VOIDmode, 2, TRAMP, Pmode,                      \
+                    plus_constant (TRAMP, TRAMPOLINE_SIZE), Pmode);
 
-#undef TRAMPOLINE_TEMPLATE
-#define TRAMPOLINE_TEMPLATE(FILE)                                      \
-{                                                                      \
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x227a));      \
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 8));           \
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x2f3a));      \
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 8));           \
-  ASM_OUTPUT_SHORT (FILE, gen_rtx (CONST_INT, VOIDmode, 0x4e75));      \
-  ASM_OUTPUT_INT (FILE, const0_rtx);                                   \
-  ASM_OUTPUT_INT (FILE, const0_rtx);                                   \
-}
+/* Clear the instruction cache from `beg' to `end'.  This makes an
+   inline system call to SYS_cacheflush.  The arguments are as
+   follows:
 
-/* Redefine since we are using a different trampoline */
-#undef TRAMPOLINE_SIZE
-#define TRAMPOLINE_SIZE 18
+       cacheflush (addr, scope, cache, len)
 
-/* Emit RTL insns to initialize the variable parts of a trampoline.
-   FNADDR is an RTX for the address of the function's pure code.
-   CXT is an RTX for the static chain value for the function.  */
+   addr          - the start address for the flush
+   scope  - the scope of the flush (see the cpush insn)
+   cache  - which cache to flush (see the cpush insn)
+   len    - a factor relating to the number of flushes to perform:
+           len/16 lines, or len/4096 pages.  */
 
-#undef INITIALIZE_TRAMPOLINE
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                       \
-{                                                                       \
-  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 10)), CXT); \
-  emit_move_insn (gen_rtx (MEM, SImode, plus_constant (TRAMP, 14)), FNADDR); \
+#define CLEAR_INSN_CACHE(BEG, END)                                     \
+{                                                                      \
+  register unsigned long _beg __asm ("%d1") = (unsigned long) (BEG);   \
+  unsigned long _end = (unsigned long) (END);                          \
+  register unsigned long _len __asm ("%d4") = (_end - _beg + 32);      \
+  __asm __volatile                                                     \
+    ("move%.l %#123, %/d0\n\t" /* system call nr */                    \
+     "move%.l %#1, %/d2\n\t"   /* clear lines */                       \
+     "move%.l %#3, %/d3\n\t"   /* insn+data caches */                  \
+     "trap %#0"                                                                \
+     : /* no outputs */                                                        \
+     : "d" (_beg), "d" (_len)                                          \
+     : "%d0", "%d2", "%d3");                                           \
 }