OSDN Git Service

* doc/tm.texi (INIT_CUMULATIVE_ARGS): Update doco.
[pf3gnuchains/gcc-fork.git] / gcc / config / mips / mips.h
index 23fe285..d899143 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler.  MIPS version.
    Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
-   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by A. Lichnewsky (lich@inria.inria.fr).
    Changed by Michael Meissner (meissner@osf.org).
    64 bit r4000 support by Ian Lance Taylor (ian@cygnus.com) and
@@ -169,7 +169,7 @@ extern const struct mips_cpu_info *mips_tune_info;
 #define MASK_UNINIT_CONST_IN_RODATA \
                           0x00800000   /* Store uninitialized
                                           consts in rodata */
-#define MASK_FIX_SB1       0x01000000   /* Work around SB-1 errata. */
+#define MASK_FIX_SB1       0x01000000   /* Work around SB-1 errata.  */
 
                                        /* Debug switches, not documented */
 #define MASK_DEBUG     0               /* unused */
@@ -336,6 +336,11 @@ extern const struct mips_cpu_info *mips_tune_info;
 
 #define TARGET_NEWABI              (mips_abi == ABI_N32 || mips_abi == ABI_64)
 
+/* IRIX specific stuff.  */
+#define TARGET_IRIX       0
+#define TARGET_IRIX5      0
+#define TARGET_SGI_O32_AS  (TARGET_IRIX && mips_abi == ABI_32 && !TARGET_GAS)
+
 /* Define preprocessor macros for the -march and -mtune options.
    PREFIX is either _MIPS_ARCH or _MIPS_TUNE, INFO is the selected
    processor.  If INFO's canonical name is "foo", define PREFIX to
@@ -471,7 +476,7 @@ extern const struct mips_cpu_info *mips_tune_info;
         {                                                      \
          builtin_define ("_LANGUAGE_OBJECTIVE_C");             \
           builtin_define ("__LANGUAGE_OBJECTIVE_C");           \
-         /* Bizzare, but needed at least for Irix.  */         \
+         /* Bizarre, but needed at least for Irix.  */         \
          builtin_define_std ("LANGUAGE_C");                    \
          builtin_define ("_LANGUAGE_C");                       \
         }                                                      \
@@ -937,9 +942,21 @@ extern const struct mips_cpu_info *mips_tune_info;
 #define ISA_HAS_FCMP_DELAY     (mips_isa <= 3)
 
 /* True if mflo and mfhi can be immediately followed by instructions
-   which write to the HI and LO registers.  Most targets require a
-   two-instruction gap.  */
-#define ISA_HAS_HILO_INTERLOCKS        (TARGET_MIPS5500 || TARGET_SB1)
+   which write to the HI and LO registers.
+
+   According to MIPS specifications, MIPS ISAs I, II, and III need
+   (at least) two instructions between the reads of HI/LO and
+   instructions which write them, and later ISAs do not.  Contradicting
+   the MIPS specifications, some MIPS IV processor user manuals (e.g.
+   the UM for the NEC Vr5000) document needing the instructions between
+   HI/LO reads and writes, as well.  Therefore, we declare only MIPS32,
+   MIPS64 and later ISAs to have the interlocks, plus any specific
+   earlier-ISA CPUs for which CPU documentation declares that the
+   instructions are really interlocked.  */
+#define ISA_HAS_HILO_INTERLOCKS        (ISA_MIPS32                             \
+                                || ISA_MIPS32R2                        \
+                                || ISA_MIPS64                          \
+                                || TARGET_MIPS5500)
 \f
 /* Add -G xx support.  */
 
@@ -1061,10 +1078,11 @@ extern const struct mips_cpu_info *mips_tune_info;
 #endif
 
 /* Beginning with gas 2.13, -mdebug must be passed to correctly handle COFF
-   and stabs debugging info.  */
+   debugging info.  */
 #if ((TARGET_CPU_DEFAULT | TARGET_DEFAULT) & MASK_GAS) != 0
 /* GAS */
-#define MDEBUG_ASM_SPEC "%{!gdwarf*:-mdebug} %{gdwarf*:-no-mdebug}"
+#define MDEBUG_ASM_SPEC "%{gcoff*:-mdebug} \
+                         %{!gcoff*:-no-mdebug}"
 #else /* not GAS */
 #define MDEBUG_ASM_SPEC ""
 #endif /* not GAS */
@@ -1179,6 +1197,11 @@ extern const struct mips_cpu_info *mips_tune_info;
 \f
 #define DBX_DEBUGGING_INFO 1           /* generate stabs (OSF/rose) */
 #define MIPS_DEBUGGING_INFO 1          /* MIPS specific debugging info */
+#define DWARF2_DEBUGGING_INFO 1         /* dwarf2 debugging info */
+
+#ifndef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
+#endif
 
 /* By default, turn on GDB extensions.  */
 #define DEFAULT_GDB_EXTENSIONS 1
@@ -1239,8 +1262,6 @@ extern const struct mips_cpu_info *mips_tune_info;
    SFmode register saves.  */
 #define DWARF_CIE_DATA_ALIGNMENT 4
 
-#define FIND_BASE_TERM(X) mips_delegitimize_address (X)
-
 /* Correct the offset of automatic variables and arguments.  Note that
    the MIPS debug format wants all automatic variables and arguments
    to be in terms of the virtual frame pointer (stack pointer before
@@ -1415,10 +1436,6 @@ extern const struct mips_cpu_info *mips_tune_info;
 #define PAD_VARARGS_DOWN \
   (FUNCTION_ARG_PADDING (TYPE_MODE (type), type) == downward)
 
-/* Arguments declared as 'char' or 'short' in a prototype should be
-   passed as 'int's.  */
-#define PROMOTE_PROTOTYPES 1
-
 /* Define if operations between registers always perform the operation
    on the full register even if a narrower mode is specified.  */
 #define WORD_REGISTER_OPERATIONS
@@ -1446,15 +1463,6 @@ extern const struct mips_cpu_info *mips_tune_info;
 
 /* Define if loading short immediate values into registers sign extends.  */
 #define SHORT_IMMEDIATES_SIGN_EXTEND
-
-
-/* Define this if function arguments should also be promoted using the above
-   procedure.  */
-#define PROMOTE_FUNCTION_ARGS
-
-/* Likewise, if the function return value is promoted.  */
-#define PROMOTE_FUNCTION_RETURN
-
 \f
 /* Standard register usage.  */
 
@@ -1465,7 +1473,11 @@ extern const struct mips_cpu_info *mips_tune_info;
    - 8 condition code registers
    - 2 accumulator registers (hi and lo)
    - 32 registers each for coprocessors 0, 2 and 3
-   - 6 dummy entries that were used at various times in the past.  */
+   - 3 fake registers:
+       - ARG_POINTER_REGNUM
+       - FRAME_POINTER_REGNUM
+       - FAKE_CALL_REGNO (see the comment above load_callsi for details)
+   - 3 dummy entries that were used at various times in the past.  */
 
 #define FIRST_PSEUDO_REGISTER 176
 
@@ -1651,11 +1663,10 @@ extern char mips_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
 /* Register to use for pushing function arguments.  */
 #define STACK_POINTER_REGNUM (GP_REG_FIRST + 29)
 
-/* Base register for access to local variables of the function.  We
-   pretend that the frame pointer is $1, and then eliminate it to
-   HARD_FRAME_POINTER_REGNUM.  We can get away with this because $1 is
-   a fixed register, and will not be used for anything else.  */
-#define FRAME_POINTER_REGNUM (GP_REG_FIRST + 1)
+/* These two registers don't really exist: they get eliminated to either
+   the stack or hard frame pointer.  */
+#define ARG_POINTER_REGNUM 77
+#define FRAME_POINTER_REGNUM 78
 
 /* $30 is not available on the mips16, so we use $17 as the frame
    pointer.  */
@@ -1668,15 +1679,9 @@ extern char mips_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
    This is computed in `reload', in reload1.c.  */
 #define FRAME_POINTER_REQUIRED (current_function_calls_alloca)
 
-/* Base register for access to arguments of the function.  */
-#define ARG_POINTER_REGNUM GP_REG_FIRST
-
 /* Register in which static-chain is passed to a function.  */
 #define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 2)
 
-/* Pass structure addresses as an "invisible" first argument.  */
-#define STRUCT_VALUE 0
-
 /* Registers used as temporaries in prologue/epilogue code.  If we're
    generating mips16 code, these registers must come from the core set
    of 8.  The prologue register mustn't conflict with any incoming
@@ -2018,15 +2023,6 @@ extern enum reg_class mips_char_to_class[256];
   ((C) == 'G'                                                          \
    && (VALUE) == CONST0_RTX (GET_MODE (VALUE)))
 
-/* True if OP is a constant that should not be moved into $25.
-   We need this because many versions of gas treat 'la $25,foo' as
-   part of a call sequence and allow a global 'foo' to be lazily bound.  */
-
-#define DANGEROUS_FOR_LA25_P(OP)                                       \
-  (TARGET_ABICALLS                                                     \
-   && !TARGET_EXPLICIT_RELOCS                                          \
-   && mips_global_pic_constant_p (OP))
-
 /* Letters in the range `Q' through `U' may be defined in a
    machine-dependent fashion to stand for arbitrary operand types.
    The machine description macro `EXTRA_CONSTRAINT' is passed the
@@ -2052,10 +2048,10 @@ extern enum reg_class mips_char_to_class[256];
                             && call_insn_operand (OP, VOIDmode))       \
    : ((CODE) == 'T')     ? (CONSTANT_P (OP)                            \
                             && move_operand (OP, VOIDmode)             \
-                            && DANGEROUS_FOR_LA25_P (OP))              \
+                            && mips_dangerous_for_la25_p (OP))         \
    : ((CODE) == 'U')     ? (CONSTANT_P (OP)                            \
                             && move_operand (OP, VOIDmode)             \
-                            && !DANGEROUS_FOR_LA25_P (OP))             \
+                            && !mips_dangerous_for_la25_p (OP))        \
    : ((CODE) == 'W')     ? (GET_CODE (OP) == MEM                       \
                             && memory_operand (OP, VOIDmode)           \
                             && (!TARGET_MIPS16                         \
@@ -2066,27 +2062,8 @@ extern enum reg_class mips_char_to_class[256];
 /* Say which of the above are memory constraints.  */
 #define EXTRA_MEMORY_CONSTRAINT(C, STR) ((C) == 'R' || (C) == 'W')
 
-/* Given an rtx X being reloaded into a reg required to be
-   in class CLASS, return the class of reg to actually use.
-   In general this is just CLASS; but on some machines
-   in some cases it is preferable to use a more restrictive class.  */
-
 #define PREFERRED_RELOAD_CLASS(X,CLASS)                                        \
-  ((CLASS) != ALL_REGS                                                 \
-   ? (! TARGET_MIPS16                                                  \
-      ? (CLASS)                                                                \
-      : ((CLASS) != GR_REGS                                            \
-        ? (CLASS)                                                      \
-        : M16_REGS))                                                   \
-   : ((GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT                     \
-       || GET_MODE_CLASS (GET_MODE (X)) == MODE_COMPLEX_FLOAT)         \
-      ? (TARGET_SOFT_FLOAT                                             \
-        ? (TARGET_MIPS16 ? M16_REGS : GR_REGS)                         \
-        : FP_REGS)                                                     \
-      : ((GET_MODE_CLASS (GET_MODE (X)) == MODE_INT                    \
-         || GET_MODE (X) == VOIDmode)                                  \
-        ? (TARGET_MIPS16 ? M16_REGS : GR_REGS)                         \
-        : (CLASS))))
+  mips_preferred_reload_class (X, CLASS)
 
 /* Certain machines have the property that some registers cannot be
    copied to some other registers without using memory.  Define this
@@ -2229,7 +2206,7 @@ extern enum reg_class mips_char_to_class[256];
 
 /* 1 if N is a possible register number for a function value.
    On the MIPS, R2 R3 and F0 F2 are the only register thus used.
-   Currently, R2 and F0 are only implemented  here (C has no complex type)  */
+   Currently, R2 and F0 are only implemented here (C has no complex type)  */
 
 #define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN \
   || (LONG_DOUBLE_TYPE_SIZE == 128 && FP_RETURN != GP_RETURN \
@@ -2244,15 +2221,7 @@ extern enum reg_class mips_char_to_class[256];
     || (IN_RANGE((N), FP_ARG_FIRST, FP_ARG_LAST)               \
        && ((N) % FP_INC == 0) && mips_abi != ABI_O64))         \
    && !fixed_regs[N])
-
-#define RETURN_IN_MEMORY(TYPE) mips_return_in_memory (TYPE)
-
-#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)      \
-       (PRETEND_SIZE) = mips_setup_incoming_varargs (&(CUM), (MODE),   \
-                                                     (TYPE), (NO_RTL))
 \f
-#define STRICT_ARGUMENT_NAMING (mips_abi != ABI_32 && mips_abi != ABI_O64)
-
 /* This structure has to cope with two different argument allocation
    schemes.  Most MIPS ABIs view the arguments as a struct, of which the
    first N words go in registers and the rest go on the stack.  If I < N,
@@ -2316,11 +2285,9 @@ typedef struct mips_args {
 
 /* Initialize a variable CUM of type CUMULATIVE_ARGS
    for a call to a function whose data type is FNTYPE.
-   For a library call, FNTYPE is 0.
+   For a library call, FNTYPE is 0.  */
 
-*/
-
-#define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT)              \
+#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
   init_cumulative_args (&CUM, FNTYPE, LIBNAME)                         \
 
 /* Update the data in CUM to advance over an argument
@@ -2407,10 +2374,6 @@ typedef struct mips_args {
    : ((LOC) + 15) & ~15)
 
 \f
-/* Define the `__builtin_va_list' type for the ABI.  */
-#define BUILD_VA_LIST_TYPE(VALIST) \
-  (VALIST) = mips_build_va_list ()
-
 /* Implement `va_start' for varargs and stdarg.  */
 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
   mips_va_start (valist, nextarg)
@@ -2519,10 +2482,8 @@ typedef struct mips_args {
                                                                            \
   func_addr = plus_constant (ADDR, 32);                                            \
   chain_addr = plus_constant (func_addr, GET_MODE_SIZE (ptr_mode));        \
-  emit_move_insn (gen_rtx_MEM (ptr_mode, func_addr),                       \
-                 gen_lowpart (ptr_mode, force_reg (Pmode, FUNC)));         \
-  emit_move_insn (gen_rtx_MEM (ptr_mode, chain_addr),                      \
-                 gen_lowpart (ptr_mode, force_reg (Pmode, CHAIN)));        \
+  emit_move_insn (gen_rtx_MEM (ptr_mode, func_addr), FUNC);                \
+  emit_move_insn (gen_rtx_MEM (ptr_mode, chain_addr), CHAIN);              \
                                                                            \
   /* Flush both caches.  We need to flush the data cache in case           \
      the system has a write-back cache.  */                                \
@@ -2536,31 +2497,9 @@ typedef struct mips_args {
 \f
 /* Addressing modes, and classification of registers for them.  */
 
-/* These assume that REGNO is a hard or pseudo reg number.
-   They give nonzero only if REGNO is a hard reg of the suitable class
-   or a pseudo reg currently allocated to a suitable hard reg.
-   These definitions are NOT overridden anywhere.  */
-
-#define BASE_REG_P(regno, mode)                                        \
-  (TARGET_MIPS16                                               \
-   ? (M16_REG_P (regno)                                                \
-      || (regno) == FRAME_POINTER_REGNUM                       \
-      || (regno) == ARG_POINTER_REGNUM                         \
-      || ((regno) == STACK_POINTER_REGNUM                      \
-         && (GET_MODE_SIZE (mode) == 4                         \
-             || GET_MODE_SIZE (mode) == 8)))                   \
-   : GP_REG_P (regno))
-
-#define GP_REG_OR_PSEUDO_STRICT_P(regno, mode)                             \
-  BASE_REG_P((regno < FIRST_PSEUDO_REGISTER) ? (int) regno : reg_renumber[regno], \
-            (mode))
-
-#define GP_REG_OR_PSEUDO_NONSTRICT_P(regno, mode) \
-  (((regno) >= FIRST_PSEUDO_REGISTER) || (BASE_REG_P ((regno), (mode))))
-
-#define REGNO_OK_FOR_INDEX_P(regno)    0
-#define REGNO_MODE_OK_FOR_BASE_P(regno, mode) \
-  GP_REG_OR_PSEUDO_STRICT_P ((regno), (mode))
+#define REGNO_OK_FOR_INDEX_P(REGNO) 0
+#define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
+  mips_regno_mode_ok_for_base_p (REGNO, MODE, 1)
 
 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
    and check its validity for a certain class.
@@ -2575,10 +2514,10 @@ typedef struct mips_args {
 
 #ifndef REG_OK_STRICT
 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
-  mips_reg_mode_ok_for_base_p (X, MODE, 0)
+  mips_regno_mode_ok_for_base_p (REGNO (X), MODE, 0)
 #else
 #define REG_MODE_OK_FOR_BASE_P(X, MODE) \
-  mips_reg_mode_ok_for_base_p (X, MODE, 1)
+  mips_regno_mode_ok_for_base_p (REGNO (X), MODE, 1)
 #endif
 
 #define REG_OK_FOR_INDEX_P(X) 0
@@ -2667,7 +2606,7 @@ typedef struct mips_args {
 \f
 /* Specify the machine mode that this machine uses
    for the index in the tablejump instruction.
-   ??? Using HImode in mips16 mode can cause overflow. */
+   ??? Using HImode in mips16 mode can cause overflow.  */
 #define CASE_VECTOR_MODE \
   (TARGET_MIPS16 ? HImode : ptr_mode)
 
@@ -2741,7 +2680,7 @@ typedef struct mips_args {
    that the constraints of the insn are met.  Setting a cost of
    other than 2 will allow reload to verify that the constraints are
    met.  You should do this if the `movM' pattern's constraints do
-   not allow such copying. */
+   not allow such copying.  */
 
 #define REGISTER_MOVE_COST(MODE, FROM, TO)                             \
   mips_register_move_cost (MODE, FROM, TO)
@@ -2799,14 +2738,16 @@ typedef struct mips_args {
 #define PREDICATE_CODES                                                        \
   {"uns_arith_operand",                { REG, CONST_INT, SUBREG, ADDRESSOF }}, \
   {"symbolic_operand",         { CONST, SYMBOL_REF, LABEL_REF }},      \
-  {"const_arith_operand",      { CONST, CONST_INT }},                  \
+  {"global_got_operand",       { CONST, SYMBOL_REF, LABEL_REF }},      \
+  {"local_got_operand",                { CONST, SYMBOL_REF, LABEL_REF }},      \
+  {"const_arith_operand",      { CONST_INT }},                         \
+  {"small_data_pattern",       { SET, PARALLEL, UNSPEC,                \
+                                 UNSPEC_VOLATILE }},                   \
   {"arith_operand",            { REG, CONST_INT, CONST, SUBREG, ADDRESSOF }},  \
   {"reg_or_0_operand",         { REG, CONST_INT, CONST_DOUBLE, SUBREG, ADDRESSOF }}, \
   {"small_int",                        { CONST_INT }},                         \
-  {"mips_const_double_ok",     { CONST_DOUBLE }},                      \
   {"const_float_1_operand",    { CONST_DOUBLE }},                      \
   {"reg_or_const_float_1_operand", { CONST_DOUBLE, REG}},               \
-  {"simple_memory_operand",    { MEM, SUBREG }},                       \
   {"equality_op",              { EQ, NE }},                            \
   {"cmp_op",                   { EQ, NE, GT, GE, GTU, GEU, LT, LE,     \
                                  LTU, LEU }},                          \
@@ -3276,7 +3217,6 @@ while (0)
 #define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
   mips_output_external(STREAM,DECL,NAME)
 
-
 /* This is how to declare a function name.  The actual work of
    emitting the label is moved to function_prologue, so that we can
    get the line number correctly emitted before the .ent directive,
@@ -3286,6 +3226,10 @@ while (0)
 #undef ASM_DECLARE_FUNCTION_NAME
 #define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL)
 
+#ifndef FUNCTION_NAME_ALREADY_DECLARED
+#define FUNCTION_NAME_ALREADY_DECLARED 0
+#endif
+
 /* 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.
@@ -3357,7 +3301,7 @@ do {                                                                      \
 /* This is how to output a string.  */
 #undef ASM_OUTPUT_ASCII
 #define ASM_OUTPUT_ASCII(STREAM, STRING, LEN)                          \
-  mips_output_ascii (STREAM, STRING, LEN)
+  mips_output_ascii (STREAM, STRING, LEN, "\t.ascii\t")
 
 /* Output #ident as a in the read-only data section.  */
 #undef  ASM_OUTPUT_IDENT
@@ -3459,7 +3403,7 @@ while (0)
    we need to load our GP.  We don't preserve $gp or $ra, since each
    init/fini chunk is supposed to initialize $gp, and crti/crtn
    already take care of preserving $ra and, when appropriate, $gp.  */
-#if _MIPS_SIM == _MIPS_SIM_ABI32
+#if (defined _ABIO32 && _MIPS_SIM == _ABIO32)
 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)     \
    asm (SECTION_OP "\n\
        .set noreorder\n\