OSDN Git Service

moxie EH fixes
[pf3gnuchains/gcc-fork.git] / gcc / config / moxie / moxie.h
index 73a1a51..c3b3454 100644 (file)
@@ -1,5 +1,5 @@
 /* Target Definitions for moxie.
-   Copyright (C) 2008, 2009  Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
    Contributed by Anthony Green.
 
    This file is part of GCC.
@@ -127,7 +127,7 @@ enum reg_class
   NO_REGS,
   GENERAL_REGS,
   SPECIAL_REGS,
-  CC_REG,
+  CC_REGS,
   ALL_REGS,
   LIM_REG_CLASSES
 };
@@ -144,7 +144,7 @@ enum reg_class
 
 #define REG_CLASS_CONTENTS \
 { { 0x00000000 }, /* Empty */                     \
-  { 0x0003FFFF }, /* $fp, $sp, $r0 to $r5, ?fp */  \
+  { 0x0003FFFF }, /* $fp, $sp, $r0 to $r13, ?fp */ \
   { 0x00040000 }, /* $pc */                       \
   { 0x00080000 }, /* ?cc */                        \
   { 0x000FFFFF }  /* All registers */              \
@@ -156,7 +156,7 @@ enum reg_class
     "NO_REGS", \
     "GENERAL_REGS", \
     "SPECIAL_REGS", \
-    "CC_REG", \
+    "CC_REGS", \
     "ALL_REGS" }
 
 #define FIXED_REGISTERS     { 1, 1, 0, 0, \
@@ -166,7 +166,7 @@ enum reg_class
                               1, 1, 1, 1 }
 
 #define CALL_USED_REGISTERS { 1, 1, 1, 1, \
-                             0, 0, 0, 0, \
+                             1, 1, 1, 1, \
                              0, 0, 0, 0, \
                              0, 0, 1, 1, \
                               1, 1, 1, 1 }
@@ -182,8 +182,8 @@ enum reg_class
 
 /* A C expression whose value is a register class containing hard
    register REGNO.  */
-#define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS : \
-                            (R == MOXIE_CC ? CC_REG : SPECIAL_REGS))
+#define REGNO_REG_CLASS(R) ((R < MOXIE_PC) ? GENERAL_REGS :            \
+                            (R == MOXIE_CC ? CC_REGS : SPECIAL_REGS))
 
 /* A C expression for the number of consecutive hard registers,
    starting at register number REGNO, required to hold a value of mode
@@ -201,11 +201,6 @@ enum reg_class
 #define CLASS_MAX_NREGS(CLASS, MODE) \
   ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
 
-/* A C expression that places additional restrictions on the register
-   class to use when it is necessary to copy value X into a register
-   in class CLASS.  */
-#define PREFERRED_RELOAD_CLASS(X,CLASS) CLASS
-
 /* The Overall Framework of an Assembler File */
 
 #undef  ASM_SPEC
@@ -236,11 +231,6 @@ enum reg_class
 
 /* Passing Arguments in Registers */
 
-/* A C expression that controls whether a function argument is passed
-   in a register, and which register.  */
-#define FUNCTION_ARG(CUM,MODE,TYPE,NAMED) \
-  moxie_function_arg(CUM,MODE,TYPE,NAMED)
-
 /* A C type for declaring a variable that is used as the first
    argument of `FUNCTION_ARG' and other related values.  */
 #define CUMULATIVE_ARGS unsigned int
@@ -258,28 +248,8 @@ enum reg_class
 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,FNDECL,N_NAMED_ARGS) \
   (CUM = MOXIE_R0)
 
-#define MOXIE_FUNCTION_ARG_SIZE(MODE, TYPE)    \
-  ((MODE) != BLKmode ? GET_MODE_SIZE (MODE)    \
-   : (unsigned) int_size_in_bytes (TYPE))
-
-#define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
-  (CUM = (CUM < MOXIE_R2 ?                        \
-          CUM + ((3 + MOXIE_FUNCTION_ARG_SIZE(MODE,TYPE))/4) : CUM ))
-
 /* How Scalar Function Values Are Returned */
 
-/* These macros are deprecated, but we still need them for now since
-   the version of gcc we're using doesn't fully support
-   TARGET_FUNCTION_VALUE.  */
-#define FUNCTION_VALUE(VALTYPE, FUNC) \
-  moxie_function_value (VALTYPE, FUNC, 0)
-#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
-  moxie_function_value (VALTYPE, FUNC, 1)
-
-/* A C expression to create an RTX representing the place where a
-   library function returns a value of mode MODE.  */
-#define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, 2)
-
 /* STACK AND CALLING */
 
 /* Define this macro if pushing a word onto the stack moves the stack
@@ -299,7 +269,7 @@ enum reg_class
 
 /* Define this if it is the responsibility of the caller to allocate
    the area reserved for arguments passed in registers.  */
-#define REG_PARM_STACK_SPACE(FNDECL) (2 * UNITS_PER_WORD)
+#define REG_PARM_STACK_SPACE(FNDECL) (6 * UNITS_PER_WORD)
 
 /* Offset from the argument pointer register to the first argument's
    address.  On some machines it may depend on the data type of the
@@ -315,7 +285,20 @@ enum reg_class
    pointer registers are already assumed to be used as needed.  */
 #define EPILOGUE_USES(R) (R == MOXIE_R5)
 
-#define OVERRIDE_OPTIONS moxie_override_options ()
+/* A C expression whose value is RTL representing the location of the
+   incoming return address at the beginning of any function, before
+   the prologue.  */
+#define INCOMING_RETURN_ADDR_RTX                                       \
+  gen_frame_mem (Pmode,                                                        \
+                plus_constant (stack_pointer_rtx, UNITS_PER_WORD))
+
+/* Describe how we implement __builtin_eh_return.  */
+#define EH_RETURN_DATA_REGNO(N)        ((N) < 4 ? (N+2) : INVALID_REGNUM)
+
+/* Store the return handler into the call frame.  */
+#define EH_RETURN_HANDLER_RTX                                          \
+  gen_frame_mem (Pmode,                                                        \
+                plus_constant (frame_pointer_rtx, UNITS_PER_WORD))
 
 /* Storage Layout */
 
@@ -386,35 +369,10 @@ enum reg_class
 #define FUNCTION_PROFILER(FILE,LABELNO) (abort (), 0)
 
 /* Trampolines for Nested Functions.  */
-#define TRAMPOLINE_SIZE (2 + 6 + 6 + 2 + 6)
+#define TRAMPOLINE_SIZE (2 + 6 + 6 + 2 + 2 + 6)
 
 /* Alignment required for trampolines, in bits.  */
-#define TRAMPOLINE_ALIGNMENT 16
-
-/* A C statement to initialize the variable parts of a trampoline.  ADDR is an
-   RTX for the address of the trampoline; FNADDR is an RTX for the address of
-   the nested function; STATIC_CHAIN is an RTX for the static chain value that
-   should be passed to the function when it is called.  */
-#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN)                    \
-do                                                                           \
-{                                                                            \
-  emit_move_insn (gen_rtx_MEM (SImode,                                        \
-                               plus_constant (ADDR, 4)), STATIC_CHAIN);       \
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant (ADDR, 18)), FNADDR);    \
-} while (0);
-
-/* A C statement to output, on the stream FILE, assembler code for a
-   block of data that contains the constant parts of a trampoline.
-   This code should not include a label--the label is taken care of
-   automatically.  */
-#define TRAMPOLINE_TEMPLATE(FILE)              \
-{                                              \
-  fprintf (FILE, "\tpush  $sp, $r0\n");         \
-  fprintf (FILE, "\tldi.l $r0, 0x0\n");        \
-  fprintf (FILE, "\tsto.l 0x8($fp), $r0\n");   \
-  fprintf (FILE, "\tpop   $sp, $r0\n");                \
-  fprintf (FILE, "\tjmpa  0x0\n");             \
-}
+#define TRAMPOLINE_ALIGNMENT 32
 
 /* An alias for the machine mode for pointers.  */
 #define Pmode         SImode
@@ -425,7 +383,7 @@ do                                                                        \
 
 /* The register number of the stack pointer register, which must also
    be a fixed register according to `FIXED_REGISTERS'.  */
-#define STACK_POINTER_REGNUM 1
+#define STACK_POINTER_REGNUM MOXIE_SP
 
 /* The register number of the frame pointer register, which is used to
    access automatic variables in the stack frame.  */
@@ -435,38 +393,11 @@ do                                                                              \
    access the function's argument list.  */
 #define ARG_POINTER_REGNUM MOXIE_QAP
 
-/* If the static chain is passed in memory, these macros provide rtx
-   giving 'mem' expressions that denote where they are stored.
-   'STATIC_CHAIN' and 'STATIC_CHAIN_INCOMING' give the locations as
-   seen by the calling and called functions, respectively.  */
-
-#define STATIC_CHAIN                                                   \
-  gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, -UNITS_PER_WORD))
-
-#define STATIC_CHAIN_INCOMING                                          \
-  gen_rtx_MEM (Pmode, plus_constant (arg_pointer_rtx, 2 * UNITS_PER_WORD))
-
 #define HARD_FRAME_POINTER_REGNUM MOXIE_FP
 
-#if 0
-#define ELIMINABLE_REGS                                                        \
-{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },                       \
- { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM },                  \
- { ARG_POINTER_REGNUM,  STACK_POINTER_REGNUM },                        \
- { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM }}                  
-#else
 #define ELIMINABLE_REGS                                                        \
 {{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM },                  \
  { ARG_POINTER_REGNUM,   HARD_FRAME_POINTER_REGNUM }}                  
-#endif
-
-/* A C expression that returns nonzero if the compiler is allowed to
-   try to replace register number FROM-REG with register number
-   TO-REG.  This macro need only be defined if `ELIMINABLE_REGS' is
-   defined, and will usually be the constant 1, since most of the
-   cases preventing register elimination are things that the compiler
-   already knows about.  */
-#define CAN_ELIMINATE(FROM, TO) 1
 
 /* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'.  It
    specifies the initial difference between the specified pair of
@@ -479,11 +410,7 @@ do                                                                       \
 
 /* A C expression that is nonzero if REGNO is the number of a hard
    register in which function arguments are sometimes passed.  */
-#define FUNCTION_ARG_REGNO_P(r) (r == MOXIE_R0 || r == MOXIE_R1)
-
-/* A C expression that is nonzero if REGNO is the number of a hard
-   register in which the values of called function may come back.  */
-#define FUNCTION_VALUE_REGNO_P(r) (r == MOXIE_R0)
+#define FUNCTION_ARG_REGNO_P(r) (r >= MOXIE_R0 && r <= MOXIE_R5)
 
 /* A macro whose definition is the name of the class to which a valid
    base register must belong.  A base register is one used in an
@@ -493,7 +420,7 @@ do                                                                        \
 #define INDEX_REG_CLASS NO_REGS
 
 #define HARD_REGNO_OK_FOR_BASE_P(NUM) \
-  ((NUM) >= 0 && (NUM) < FIRST_PSEUDO_REGISTER \
+  ((unsigned) (NUM) < FIRST_PSEUDO_REGISTER \
    && (REGNO_REG_CLASS(NUM) == GENERAL_REGS \
        || (NUM) == HARD_FRAME_POINTER_REGNUM))
 
@@ -521,18 +448,10 @@ do                                                                              \
 /* All load operations zero extend.  */
 #define LOAD_EXTEND_OP(MEM) ZERO_EXTEND
 
-#define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
-
 /* A C expression that is nonzero if X is a legitimate constant for
    an immediate operand on the target machine.  */
 #define LEGITIMATE_CONSTANT_P(X) 1
 
-#define FRAME_POINTER_REQUIRED 1
-
-/* A C expression that is 1 if the RTX X is a constant which is a
-   valid address.  */
-#define CONSTANT_ADDRESS_P(X) CONSTANT_P(X)
-
 /* A number, the maximum number of registers that can appear in a
    valid memory address.  */
 #define MAX_REGS_PER_ADDRESS 1