OSDN Git Service

* config/bfin/bfin.h (enum reg_class, REG_CLASS_CONTENTS,
[pf3gnuchains/gcc-fork.git] / gcc / config / bfin / bfin.h
index 732a9b8..1d8e8da 100644 (file)
@@ -1,12 +1,12 @@
 /* Definitions for the Blackfin port.
-   Copyright (C) 2005  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
    Contributed by Analog Devices.
 
    This file is part of GCC.
 
    GCC 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
+   by the Free Software Foundation; either version 3, or (at your
    option) any later version.
 
    GCC is distributed in the hope that it will be useful, but WITHOUT
@@ -15,9 +15,8 @@
    License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING.  If not, write to
-   the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _BFIN_CONFIG
 #define _BFIN_CONFIG
 
 extern int target_flags;
 
+#ifndef DEFAULT_CPU_TYPE
+#define DEFAULT_CPU_TYPE BFIN_CPU_BF532
+#endif
+
 /* Predefinition in the preprocessor for this target machine */
 #ifndef TARGET_CPU_CPP_BUILTINS
 #define TARGET_CPU_CPP_BUILTINS()               \
   do                                            \
     {                                           \
-      builtin_define ("bfin");                  \
-      builtin_define ("BFIN");                  \
+      builtin_define_std ("bfin");              \
+      builtin_define_std ("BFIN");              \
       builtin_define ("__ADSPBLACKFIN__");     \
+      builtin_define ("__ADSPLPBLACKFIN__");   \
+                                               \
+      switch (bfin_cpu_type)                   \
+       {                                       \
+       case BFIN_CPU_BF531:                    \
+         builtin_define ("__ADSPBF531__");     \
+         break;                                \
+       case BFIN_CPU_BF532:                    \
+         builtin_define ("__ADSPBF532__");     \
+         break;                                \
+       case BFIN_CPU_BF533:                    \
+         builtin_define ("__ADSPBF533__");     \
+         break;                                \
+       case BFIN_CPU_BF534:                    \
+         builtin_define ("__ADSPBF534__");     \
+         break;                                \
+       case BFIN_CPU_BF536:                    \
+         builtin_define ("__ADSPBF536__");     \
+         break;                                \
+       case BFIN_CPU_BF537:                    \
+         builtin_define ("__ADSPBF537__");     \
+         break;                                \
+       case BFIN_CPU_BF561:                    \
+         builtin_define ("__ADSPBF561__");     \
+         break;                                \
+       }                                       \
+                                               \
       if (TARGET_FDPIC)                                \
        builtin_define ("__BFIN_FDPIC__");      \
       if (TARGET_ID_SHARED_LIBRARY)            \
        builtin_define ("__ID_SHARED_LIB__");   \
+      if (flag_no_builtin)                     \
+       builtin_define ("__NO_BUILTIN");        \
     }                                           \
   while (0)
 #endif
 
 #define DRIVER_SELF_SPECS SUBTARGET_DRIVER_SELF_SPECS  "\
+ %{mleaf-id-shared-library:%{!mid-shared-library:-mid-shared-library}} \
  %{mfdpic:%{!fpic:%{!fpie:%{!fPIC:%{!fPIE:\
            %{!fno-pic:%{!fno-pie:%{!fno-PIC:%{!fno-PIE:-fpie}}}}}}}}} \
 "
@@ -58,9 +91,9 @@ extern int target_flags;
 # define SUBTARGET_DRIVER_SELF_SPECS
 #endif
 
-#define LINK_GCC_C_SEQUENCE_SPEC \
-  "%{mfdpic:%{!static: %L} %{static: %G %L %G}} \
-  %{!mfdpic:%G %L %G}"
+#define LINK_GCC_C_SEQUENCE_SPEC "\
+  %{mfast-fp:-lbffastfp} %G %L %{mfast-fp:-lbffastfp} %G \
+"
 
 /* A C string constant that tells the GCC driver program options to pass to
    the assembler.  It can also specify how to translate options you give to GNU
@@ -179,7 +212,7 @@ extern const char *bfin_library_id_string;
 
 /* Define this if the above stack space is to be considered part of the
  * space allocated by the caller.  */
-#define OUTGOING_REG_PARM_STACK_SPACE
+#define OUTGOING_REG_PARM_STACK_SPACE 1
          
 /* Define this if the maximum size of all the outgoing args is to be
    accumulated and pushed during the prologue.  The amount can be
@@ -195,6 +228,18 @@ extern const char *bfin_library_id_string;
 
 /*#define DATA_ALIGNMENT(TYPE, BASIC-ALIGN) for arrays.. */
 
+/* If defined, a C expression to compute the alignment for a local
+   variable.  TYPE is the data type, and ALIGN is the alignment that
+   the object would ordinarily have.  The value of this macro is used
+   instead of that alignment to align the object.
+
+   If this macro is not defined, then ALIGN is used.
+
+   One use of this macro is to increase alignment of medium-size
+   data to make it all fit in fewer cache lines.  */
+
+#define LOCAL_ALIGNMENT(TYPE, ALIGN) bfin_local_alignment ((TYPE), (ALIGN))
+
 /* Make strings word-aligned so strcpy from constants will be faster.  */
 #define CONSTANT_ALIGNMENT(EXP, ALIGN)  \
   (TREE_CODE (EXP) == STRING_CST        \
@@ -410,7 +455,16 @@ enum reg_class
   CCREGS,
   EVEN_DREGS,
   ODD_DREGS,
+  D0REGS,
+  D1REGS,
+  D2REGS,
+  D3REGS,
+  D4REGS,
+  D5REGS,
+  D6REGS,
+  D7REGS,
   DREGS,
+  P0REGS,
   FDPIC_REGS,
   FDPIC_FPTR_REGS,
   PREGS_CLOBBERED,
@@ -446,7 +500,16 @@ enum reg_class
    "CCREGS",           \
    "EVEN_DREGS",       \
    "ODD_DREGS",                \
+   "D0REGS",           \
+   "D1REGS",           \
+   "D2REGS",           \
+   "D3REGS",           \
+   "D4REGS",           \
+   "D5REGS",           \
+   "D6REGS",           \
+   "D7REGS",           \
    "DREGS",            \
+   "P0REGS",           \
    "FDPIC_REGS",       \
    "FDPIC_FPTR_REGS",  \
    "PREGS_CLOBBERED",  \
@@ -490,7 +553,16 @@ enum reg_class
     { 0x00000000,    0x4 },            /* CCREGS */  \
     { 0x00000055,    0 },              /* EVEN_DREGS */   \
     { 0x000000aa,    0 },              /* ODD_DREGS */   \
+    { 0x00000001,    0 },              /* D0REGS */   \
+    { 0x00000002,    0 },              /* D1REGS */   \
+    { 0x00000004,    0 },              /* D2REGS */   \
+    { 0x00000008,    0 },              /* D3REGS */   \
+    { 0x00000010,    0 },              /* D4REGS */   \
+    { 0x00000020,    0 },              /* D5REGS */   \
+    { 0x00000040,    0 },              /* D6REGS */   \
+    { 0x00000080,    0 },              /* D7REGS */   \
     { 0x000000ff,    0 },              /* DREGS */   \
+    { 0x00000100,    0x000 },          /* P0REGS */   \
     { 0x00000800,    0x000 },          /* FDPIC_REGS */   \
     { 0x00000200,    0x000 },          /* FDPIC_FPTR_REGS */   \
     { 0x00004700,    0x800 },          /* PREGS_CLOBBERED */   \
@@ -536,7 +608,7 @@ enum reg_class
 
 /* Get reg_class from a letter such as appears in the machine description.  */
 
-#define REG_CLASS_FROM_LETTER(LETTER)  \
+#define REG_CLASS_FROM_CONSTRAINT(LETTER, STR) \
   ((LETTER) == 'a' ? PREGS :            \
    (LETTER) == 'Z' ? FDPIC_REGS :      \
    (LETTER) == 'Y' ? FDPIC_FPTR_REGS : \
@@ -548,16 +620,27 @@ enum reg_class
    (LETTER) == 'A' ? EVEN_AREGS :      \
    (LETTER) == 'B' ? ODD_AREGS :       \
    (LETTER) == 'b' ? IREGS :            \
-   (LETTER) == 'B' ? BREGS :            \
+   (LETTER) == 'v' ? BREGS :            \
    (LETTER) == 'f' ? MREGS :           \
    (LETTER) == 'c' ? CIRCREGS :         \
    (LETTER) == 'C' ? CCREGS :          \
    (LETTER) == 't' ? LT_REGS :                 \
    (LETTER) == 'k' ? LC_REGS :                 \
-   (LETTER) == 'l' ? LB_REGS :                 \
+   (LETTER) == 'u' ? LB_REGS :                 \
    (LETTER) == 'x' ? MOST_REGS :       \
    (LETTER) == 'y' ? PROLOGUE_REGS :   \
    (LETTER) == 'w' ? NON_A_CC_REGS :   \
+   (LETTER) == 'q' \
+    ? ((STR)[1] == '0' ? D0REGS \
+       : (STR)[1] == '1' ? D1REGS \
+       : (STR)[1] == '2' ? D2REGS \
+       : (STR)[1] == '3' ? D3REGS \
+       : (STR)[1] == '4' ? D4REGS \
+       : (STR)[1] == '5' ? D5REGS \
+       : (STR)[1] == '6' ? D6REGS \
+       : (STR)[1] == '7' ? D7REGS \
+       : (STR)[1] == 'A' ? P0REGS \
+       : NO_REGS) : \
    NO_REGS)
 
 /* The same information, inverted:
@@ -566,7 +649,15 @@ enum reg_class
    or could index an array.  */
 
 #define REGNO_REG_CLASS(REGNO) \
- ((REGNO) < REG_P0 ? DREGS                             \
+((REGNO) == REG_R0 ? D0REGS                            \
+ : (REGNO) == REG_R1 ? D1REGS                          \
+ : (REGNO) == REG_R2 ? D2REGS                          \
+ : (REGNO) == REG_R3 ? D3REGS                          \
+ : (REGNO) == REG_R4 ? D4REGS                          \
+ : (REGNO) == REG_R5 ? D5REGS                          \
+ : (REGNO) == REG_R6 ? D6REGS                          \
+ : (REGNO) == REG_R7 ? D7REGS                          \
+ : (REGNO) == REG_P0 ? P0REGS                          \
  : (REGNO) < REG_I0 ? PREGS                            \
  : (REGNO) == REG_ARGP ? PREGS                         \
  : (REGNO) >= REG_I0 && (REGNO) <= REG_I3 ? IREGS      \
@@ -589,6 +680,10 @@ enum reg_class
 #define CLASS_LIKELY_SPILLED_P(CLASS) \
     ((CLASS) == PREGS_CLOBBERED \
      || (CLASS) == PROLOGUE_REGS \
+     || (CLASS) == P0REGS \
+     || (CLASS) == D0REGS \
+     || (CLASS) == D1REGS \
+     || (CLASS) == D2REGS \
      || (CLASS) == CCREGS)
 
 /* Do not allow to store a value in REG_CC for any mode */
@@ -617,14 +712,25 @@ enum reg_class
    If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R,
    MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1,
    MODE2)' must be zero. */
-#define MODES_TIEABLE_P(MODE1, MODE2) ((MODE1) == (MODE2))
+#define MODES_TIEABLE_P(MODE1, MODE2)                  \
+ ((MODE1) == (MODE2)                                   \
+  || ((GET_MODE_CLASS (MODE1) == MODE_INT              \
+       || GET_MODE_CLASS (MODE1) == MODE_FLOAT)                \
+      && (GET_MODE_CLASS (MODE2) == MODE_INT           \
+         || GET_MODE_CLASS (MODE2) == MODE_FLOAT)      \
+      && (MODE1) != BImode && (MODE2) != BImode                \
+      && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD       \
+      && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD))
 
 /* `PREFERRED_RELOAD_CLASS (X, CLASS)'
    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.  The value is a register class; perhaps CLASS, or
    perhaps another, smaller class.  */
-#define PREFERRED_RELOAD_CLASS(X, CLASS) (CLASS)
+#define PREFERRED_RELOAD_CLASS(X, CLASS)               \
+  (GET_CODE (X) == POST_INC                            \
+   || GET_CODE (X) == POST_DEC                         \
+   || GET_CODE (X) == PRE_DEC ? PREGS : (CLASS))
 
 /* Function Calling Conventions. */
 
@@ -717,7 +823,7 @@ typedef struct {
 #define EH_RETURN_DATA_REGNO(N)        ((N) < 2 ? (N) : INVALID_REGNUM)
 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, REG_P2)
 #define EH_RETURN_HANDLER_RTX \
-    gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx, UNITS_PER_WORD))
+    gen_frame_mem (Pmode, plus_constant (frame_pointer_rtx, UNITS_PER_WORD))
 
 /* Addressing Modes */
 
@@ -729,7 +835,7 @@ typedef struct {
    See force_const_mem().
    If -mno-pool, all constants are legitimate.
  */
-#define LEGITIMATE_CONSTANT_P(x) 1
+#define LEGITIMATE_CONSTANT_P(X) bfin_legitimate_constant_p (X)
 
 /*   A number, the maximum number of registers that can appear in a
      valid memory address.  Note that it is up to you to specify a
@@ -826,13 +932,7 @@ do {                                              \
 
      You may assume that ADDR is a valid address for the machine.
 */
-#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)  \
-do {                                              \
- if (GET_CODE (ADDR) == POST_INC                  \
-     || GET_CODE (ADDR) == POST_DEC               \
-     || GET_CODE (ADDR) == PRE_DEC)               \
-   goto LABEL;                                   \
-} while (0)
+#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
 
 #define NOTICE_UPDATE_CC(EXPR, INSN) 0
 
@@ -844,6 +944,10 @@ do {                                              \
    in one reasonably fast instruction.  */
 #define MOVE_MAX UNITS_PER_WORD
 
+/* If a memory-to-memory move would take MOVE_RATIO or more simple
+   move-instruction pairs, we will do a movmem or libcall instead.  */
+
+#define MOVE_RATIO 5
 
 /* STORAGE LAYOUT: target machine storage layout
    Define this macro as a C expression which is nonzero if accessing
@@ -1035,7 +1139,7 @@ do {                                              \
 #define CONST_3UBIT_IMM_P(VALUE) ((VALUE) >= 0 && (VALUE) <= 7)
 
 #define CONSTRAINT_LEN(C, STR)                 \
-    ((C) == 'P' || (C) == 'M' || (C) == 'N' ? 2        \
+    ((C) == 'P' || (C) == 'M' || (C) == 'N' || (C) == 'q' ? 2  \
      : (C) == 'K' ? 3                          \
      : DEFAULT_CONSTRAINT_LEN ((C), (STR)))
 
@@ -1045,6 +1149,8 @@ do {                                              \
      : (STR)[1] == '2' ? (VALUE) == 2 \
      : (STR)[1] == '3' ? (VALUE) == 3 \
      : (STR)[1] == '4' ? (VALUE) == 4 \
+     : (STR)[1] == 'A' ? (VALUE) != MACFLAG_M && (VALUE) != MACFLAG_IS_M \
+     : (STR)[1] == 'B' ? (VALUE) == MACFLAG_M || (VALUE) == MACFLAG_IS_M \
      : 0)
 
 #define CONST_OK_FOR_K(VALUE, STR)                     \
@@ -1063,6 +1169,9 @@ do {                                              \
      : (STR)[1] == 'n'                                 \
      ? ((STR)[2] == '7' ? CONST_7NBIT_IMM_P (VALUE)    \
        : 0)                                            \
+     : (STR)[1] == 'N'                                 \
+     ? ((STR)[2] == '7' ? CONST_7BIT_IMM_P (-(VALUE))  \
+       : 0)                                            \
      : 0)
 
 #define CONST_OK_FOR_M(VALUE, STR)                     \
@@ -1101,6 +1210,17 @@ do {                                              \
 #define EXTRA_CONSTRAINT(VALUE, D) \
     ((D) == 'Q' ? GET_CODE (VALUE) == SYMBOL_REF : 0)
 
+/* Evaluates to true if A and B are mac flags that can be used
+   together in a single multiply insn.  That is the case if they are
+   both the same flag not involving M, or if one is a combination of
+   the other with M.  */
+#define MACFLAGS_MATCH_P(A, B) \
+ ((A) == (B) \
+  || ((A) == MACFLAG_NONE && (B) == MACFLAG_M) \
+  || ((A) == MACFLAG_M && (B) == MACFLAG_NONE) \
+  || ((A) == MACFLAG_IS && (B) == MACFLAG_IS_M) \
+  || ((A) == MACFLAG_IS_M && (B) == MACFLAG_IS))
+
 /* Switch into a generic section.  */
 #define TARGET_ASM_NAMED_SECTION  default_elf_asm_named_section
 
@@ -1207,12 +1327,14 @@ do {                                            \
 
 #define ASM_COMMENT_START "//"
 
-#define FUNCTION_PROFILER(FILE, LABELNO) \
-  do {\
-    fprintf (FILE, "\tP1.l =LP$%d; P1.h =LP$%d; call mcount;\n", \
-       LABELNO, LABELNO);\
+#define FUNCTION_PROFILER(FILE, LABELNO)       \
+  do {                                         \
+    fprintf (FILE, "\tCALL __mcount;\n");      \
   } while(0)
 
+#undef NO_PROFILE_COUNTERS
+#define NO_PROFILE_COUNTERS 1
+
 #define ASM_OUTPUT_REG_PUSH(FILE, REGNO) fprintf (FILE, "[SP--] = %s;\n", reg_names[REGNO])
 #define ASM_OUTPUT_REG_POP(FILE, REGNO)  fprintf (FILE, "%s = [SP++];\n", reg_names[REGNO])
 
@@ -1227,4 +1349,8 @@ extern struct rtx_def *bfin_cc_rtx, *bfin_rets_rtx;
 
 #define SIZE_ASM_OP     "\t.size\t"
 
+extern int splitting_for_sched;
+
+#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) ((CHAR) == '!')
+
 #endif /*  _BFIN_CONFIG */