OSDN Git Service

[gcc]
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / rs6000.h
index c2f47f2..63cbdc8 100644 (file)
@@ -1,7 +1,7 @@
 /* Definitions of target machine for GNU compiler, for IBM RS/6000.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010
+   2010, 2011
    Free Software Foundation, Inc.
    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
 
 /* Note that some other tm.h files include this one and then override
    many of the definitions.  */
 
+#ifndef RS6000_OPTS_H
+#include "config/rs6000/rs6000-opts.h"
+#endif
+
 /* Definitions for the object file format.  These are set at
    compile-time.  */
 
@@ -299,16 +303,6 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
 #define TARGET_SECURE_PLT 0
 #endif
 
-/* Code model for 64-bit linux.
-   small: 16-bit toc offsets.
-   medium: 32-bit toc offsets, static data and code within 2G of TOC pointer.
-   large: 32-bit toc offsets, no limit on static data and code.  */
-enum rs6000_cmodel {
-  CMODEL_SMALL,
-  CMODEL_MEDIUM,
-  CMODEL_LARGE
-};
-
 #ifndef TARGET_CMODEL
 #define TARGET_CMODEL CMODEL_SMALL
 #endif
@@ -319,6 +313,14 @@ enum rs6000_cmodel {
 #define HAVE_AS_TLS 0
 #endif
 
+#ifndef TARGET_LINK_STACK
+#define TARGET_LINK_STACK 0
+#endif
+
+#ifndef SET_TARGET_LINK_STACK
+#define SET_TARGET_LINK_STACK(X) do { } while (0)
+#endif
+
 /* Return 1 for a symbol ref for a thread-local storage symbol.  */
 #define RS6000_SYMBOL_REF_TLS_P(RTX) \
   (GET_CODE (RTX) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (RTX) != 0)
@@ -338,40 +340,6 @@ enum rs6000_cmodel {
 
 #define TARGET_DEFAULT (MASK_POWER | MASK_MULTIPLE | MASK_STRING)
 
-/* Processor type.  Order must match cpu attribute in MD file.  */
-enum processor_type
- {
-   PROCESSOR_RIOS1,
-   PROCESSOR_RIOS2,
-   PROCESSOR_RS64A,
-   PROCESSOR_MPCCORE,
-   PROCESSOR_PPC403,
-   PROCESSOR_PPC405,
-   PROCESSOR_PPC440,
-   PROCESSOR_PPC476,
-   PROCESSOR_PPC601,
-   PROCESSOR_PPC603,
-   PROCESSOR_PPC604,
-   PROCESSOR_PPC604e,
-   PROCESSOR_PPC620,
-   PROCESSOR_PPC630,
-   PROCESSOR_PPC750,
-   PROCESSOR_PPC7400,
-   PROCESSOR_PPC7450,
-   PROCESSOR_PPC8540,
-   PROCESSOR_PPCE300C2,
-   PROCESSOR_PPCE300C3,
-   PROCESSOR_PPCE500MC,
-   PROCESSOR_PPCE500MC64,
-   PROCESSOR_POWER4,
-   PROCESSOR_POWER5,
-   PROCESSOR_POWER6,
-   PROCESSOR_POWER7,
-   PROCESSOR_CELL,
-   PROCESSOR_PPCA2,
-   PROCESSOR_TITAN
-};
-
 /* FPU operations supported. 
    Each use of TARGET_SINGLE_FLOAT or TARGET_DOUBLE_FLOAT must 
    also test TARGET_HARD_FLOAT.  */
@@ -381,8 +349,6 @@ enum processor_type
 #define TARGET_SIMPLE_FPU   0
 #define TARGET_XILINX_FPU   0
 
-extern enum processor_type rs6000_cpu;
-
 /* Recast the processor type to the cpu attribute.  */
 #define rs6000_cpu_attr ((enum attr_cpu)rs6000_cpu)
 
@@ -396,95 +362,33 @@ extern enum processor_type rs6000_cpu;
 #define PROCESSOR_DEFAULT   PROCESSOR_RIOS1
 #define PROCESSOR_DEFAULT64 PROCESSOR_RS64A
 
-/* FP processor type.  */
-enum fpu_type_t
-{
-       FPU_NONE,               /* No FPU */
-       FPU_SF_LITE,            /* Limited Single Precision FPU */
-       FPU_DF_LITE,            /* Limited Double Precision FPU */
-       FPU_SF_FULL,            /* Full Single Precision FPU */
-       FPU_DF_FULL             /* Full Double Single Precision FPU */
-};
-
-extern enum fpu_type_t fpu_type;
-
 /* Specify the dialect of assembler to use.  New mnemonics is dialect one
    and the old mnemonics are dialect zero.  */
 #define ASSEMBLER_DIALECT (TARGET_NEW_MNEMONICS ? 1 : 0)
 
-/* Types of costly dependences.  */
-enum rs6000_dependence_cost
- {
-   max_dep_latency = 1000,
-   no_dep_costly,
-   all_deps_costly,
-   true_store_to_load_dep_costly,
-   store_to_load_dep_costly
- };
-
-/* Types of nop insertion schemes in sched target hook sched_finish.  */
-enum rs6000_nop_insertion
-  {
-    sched_finish_regroup_exact = 1000,
-    sched_finish_pad_groups,
-    sched_finish_none
-  };
-
-/* Dispatch group termination caused by an insn.  */
-enum group_termination
-  {
-    current_group,
-    previous_group
-  };
-
-/* rs6000_select[0] is reserved for the default cpu defined via --with-cpu */
-struct rs6000_cpu_select
-{
-  const char *string;
-  const char *name;
-  int set_tune_p;
-  int set_arch_p;
-};
-
-extern struct rs6000_cpu_select rs6000_select[];
-
 /* Debug support */
-extern const char *rs6000_debug_name;  /* Name for -mdebug-xxxx option */
-extern int rs6000_debug_stack;         /* debug stack applications */
-extern int rs6000_debug_arg;           /* debug argument handling */
-extern int rs6000_debug_reg;           /* debug register handling */
-extern int rs6000_debug_addr;          /* debug memory addressing */
-extern int rs6000_debug_cost;          /* debug rtx_costs */
-
-#define        TARGET_DEBUG_STACK      rs6000_debug_stack
-#define        TARGET_DEBUG_ARG        rs6000_debug_arg
-#define TARGET_DEBUG_REG       rs6000_debug_reg
-#define TARGET_DEBUG_ADDR      rs6000_debug_addr
-#define TARGET_DEBUG_COST      rs6000_debug_cost
-
-extern const char *rs6000_traceback_name; /* Type of traceback table.  */
-
-/* These are separate from target_flags because we've run out of bits
-   there.  */
-extern int rs6000_long_double_type_size;
-extern int rs6000_ieeequad;
-extern int rs6000_altivec_abi;
-extern int rs6000_spe_abi;
-extern int rs6000_spe;
-extern int rs6000_float_gprs;
-extern int rs6000_alignment_flags;
-extern const char *rs6000_sched_insert_nops_str;
-extern enum rs6000_nop_insertion rs6000_sched_insert_nops;
-
-/* Describe which vector unit to use for a given machine mode.  */
-enum rs6000_vector {
-  VECTOR_NONE,                 /* Type is not  a vector or not supported */
-  VECTOR_ALTIVEC,              /* Use altivec for vector processing */
-  VECTOR_VSX,                  /* Use VSX for vector processing */
-  VECTOR_PAIRED,               /* Use paired floating point for vectors */
-  VECTOR_SPE,                  /* Use SPE for vector processing */
-  VECTOR_OTHER                 /* Some other vector unit */
-};
+#define MASK_DEBUG_STACK       0x01    /* debug stack applications */
+#define        MASK_DEBUG_ARG          0x02    /* debug argument handling */
+#define MASK_DEBUG_REG         0x04    /* debug register handling */
+#define MASK_DEBUG_ADDR                0x08    /* debug memory addressing */
+#define MASK_DEBUG_COST                0x10    /* debug rtx codes */
+#define MASK_DEBUG_TARGET      0x20    /* debug target attribute/pragma */
+#define MASK_DEBUG_BUILTIN     0x40    /* debug builtins */
+#define MASK_DEBUG_ALL         (MASK_DEBUG_STACK \
+                                | MASK_DEBUG_ARG \
+                                | MASK_DEBUG_REG \
+                                | MASK_DEBUG_ADDR \
+                                | MASK_DEBUG_COST \
+                                | MASK_DEBUG_TARGET \
+                                | MASK_DEBUG_BUILTIN)
+
+#define        TARGET_DEBUG_STACK      (rs6000_debug & MASK_DEBUG_STACK)
+#define        TARGET_DEBUG_ARG        (rs6000_debug & MASK_DEBUG_ARG)
+#define TARGET_DEBUG_REG       (rs6000_debug & MASK_DEBUG_REG)
+#define TARGET_DEBUG_ADDR      (rs6000_debug & MASK_DEBUG_ADDR)
+#define TARGET_DEBUG_COST      (rs6000_debug & MASK_DEBUG_COST)
+#define TARGET_DEBUG_TARGET    (rs6000_debug & MASK_DEBUG_TARGET)
+#define TARGET_DEBUG_BUILTIN   (rs6000_debug & MASK_DEBUG_BUILTIN)
 
 extern enum rs6000_vector rs6000_vector_unit[];
 
@@ -563,10 +467,11 @@ extern int rs6000_vector_align[];
 /* ISA 2.01 allowed FCFID to be done in 32-bit, previously it was 64-bit only.
    Enable 32-bit fcfid's on any of the switches for newer ISA machines or
    XILINX.  */
-#define TARGET_FCFID   (TARGET_POWERPC64 \
-                        || TARGET_POPCNTB      /* ISA 2.02 */ \
-                        || TARGET_CMPB         /* ISA 2.05 */ \
-                        || TARGET_POPCNTD      /* ISA 2.06 */ \
+#define TARGET_FCFID   (TARGET_POWERPC64                               \
+                        || TARGET_PPC_GPOPT    /* 970/power4 */        \
+                        || TARGET_POPCNTB      /* ISA 2.02 */          \
+                        || TARGET_CMPB         /* ISA 2.05 */          \
+                        || TARGET_POPCNTD      /* ISA 2.06 */          \
                         || TARGET_XILINX_FPU)
 
 #define TARGET_FCTIDZ  TARGET_FCFID
@@ -579,6 +484,24 @@ extern int rs6000_vector_align[];
 #define TARGET_FCTIDUZ TARGET_POPCNTD
 #define TARGET_FCTIWUZ TARGET_POPCNTD
 
+/* For power systems, we want to enable Altivec and VSX builtins even if the
+   user did not use -maltivec or -mvsx to allow the builtins to be used inside
+   of #pragma GCC target or the target attribute to change the code level for a
+   given system.  The SPE and Paired builtins are only enabled if you configure
+   the compiler for those builtins, and those machines don't support altivec or
+   VSX.  */
+
+#define TARGET_EXTRA_BUILTINS  (!TARGET_SPE && !TARGET_PAIRED_FLOAT     \
+                                && ((TARGET_POWERPC64                   \
+                                     || TARGET_PPC_GPOPT /* 970/power4 */ \
+                                     || TARGET_POPCNTB   /* ISA 2.02 */ \
+                                     || TARGET_CMPB      /* ISA 2.05 */ \
+                                     || TARGET_POPCNTD   /* ISA 2.06 */ \
+                                     || TARGET_ALTIVEC                  \
+                                     || TARGET_VSX)))
+
+
+
 /* E500 processors only support plain "sync", not lwsync.  */
 #define TARGET_NO_LWSYNC TARGET_E500
 
@@ -625,13 +548,12 @@ extern unsigned char rs6000_recip_bits[];
 /* The default CPU for TARGET_OPTION_OVERRIDE.  */
 #define OPTION_TARGET_CPU_DEFAULT TARGET_CPU_DEFAULT
 
-/* Show we can debug even without a frame pointer.  */
-#define CAN_DEBUG_WITHOUT_FP
-
 /* Target pragma.  */
 #define REGISTER_TARGET_PRAGMAS() do {                         \
   c_register_pragma (0, "longcall", rs6000_pragma_longcall);   \
+  targetm.target_option.pragma_parse = rs6000_pragma_target_parse; \
   targetm.resolve_overloaded_builtin = altivec_resolve_overloaded_builtin; \
+  rs6000_target_modify_macros_ptr = rs6000_target_modify_macros; \
 } while (0)
 
 /* Target #defines.  */
@@ -1003,10 +925,11 @@ extern unsigned rs6000_pointer_size;
        cr1             (not saved, but used for FP operations)
        cr0             (not saved, but used for arithmetic operations)
        cr4, cr3, cr2   (saved)
-       r0              (not saved; cannot be base reg)
        r9              (not saved; best for TImode)
-       r11, r10, r8-r4 (not saved; highest used first to make less conflict)
+       r10, r8-r4      (not saved; highest first for less conflict with params)
        r3              (not saved; return value register)
+       r11             (not saved; later alloc to help shrink-wrap)
+       r0              (not saved; cannot be base reg)
        r31 - r13       (saved; order given to save least number)
        r12             (not saved; if used for DImode or DFmode would use r13)
        mq              (not saved; best to use it if we can)
@@ -1031,6 +954,14 @@ extern unsigned rs6000_pointer_size;
 #define MAYBE_R2_FIXED
 #endif
 
+#if FIXED_R13 == 1
+#define EARLY_R12 12,
+#define LATE_R12
+#else
+#define EARLY_R12
+#define LATE_R12 12,
+#endif
+
 #define REG_ALLOC_ORDER                                                \
   {32,                                                         \
    45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34,             \
@@ -1038,11 +969,11 @@ extern unsigned rs6000_pointer_size;
    63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51,         \
    50, 49, 48, 47, 46,                                         \
    75, 74, 69, 68, 72, 71, 70,                                 \
-   0, MAYBE_R2_AVAILABLE                                       \
-   9, 11, 10, 8, 7, 6, 5, 4,                                   \
-   3,                                                          \
+   MAYBE_R2_AVAILABLE                                          \
+   9, 10, 8, 7, 6, 5, 4,                                       \
+   3, EARLY_R12 11, 0,                                         \
    31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19,         \
-   18, 17, 16, 15, 14, 13, 12,                                 \
+   18, 17, 16, 15, 14, 13, LATE_R12                            \
    64, 66, 65,                                                 \
    73, 1, MAYBE_R2_FIXED 67, 76,                               \
    /* AltiVec registers.  */                                   \
@@ -1101,6 +1032,15 @@ extern unsigned rs6000_pointer_size;
 
 #define HARD_REGNO_NREGS(REGNO, MODE) rs6000_hard_regno_nregs[(MODE)][(REGNO)]
 
+/* When setting up caller-save slots (MODE == VOIDmode) ensure we allocate
+   enough space to account for vectors in FP regs. */
+#define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE)                        \
+  (TARGET_VSX                                                          \
+   && ((MODE) == VOIDmode || ALTIVEC_OR_VSX_VECTOR_MODE (MODE))                \
+   && FP_REGNO_P (REGNO)                               \
+   ? V2DFmode                                          \
+   : choose_hard_reg_mode ((REGNO), (NREGS), false))
+
 #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE)                    \
   (((TARGET_32BIT && TARGET_POWERPC64                                  \
      && (GET_MODE_SIZE (MODE) > 4)                                     \
@@ -1112,25 +1052,16 @@ extern unsigned rs6000_pointer_size;
         ((MODE) == V4SFmode            \
          || (MODE) == V2DFmode)        \
 
-#define VSX_SCALAR_MODE(MODE)          \
-       ((MODE) == DFmode)
-
-#define VSX_MODE(MODE)                 \
-       (VSX_VECTOR_MODE (MODE)         \
-        || VSX_SCALAR_MODE (MODE))
-
-#define VSX_MOVE_MODE(MODE)            \
-       (VSX_VECTOR_MODE (MODE)         \
-        || VSX_SCALAR_MODE (MODE)      \
-        || ALTIVEC_VECTOR_MODE (MODE)  \
-        || (MODE) == TImode)
-
 #define ALTIVEC_VECTOR_MODE(MODE)      \
         ((MODE) == V16QImode           \
          || (MODE) == V8HImode         \
          || (MODE) == V4SFmode         \
          || (MODE) == V4SImode)
 
+#define ALTIVEC_OR_VSX_VECTOR_MODE(MODE)                               \
+  (ALTIVEC_VECTOR_MODE (MODE) || VSX_VECTOR_MODE (MODE)                        \
+   || (MODE) == V2DImode)
+
 #define SPE_VECTOR_MODE(MODE)          \
        ((MODE) == V4HImode             \
          || (MODE) == V2SFmode          \
@@ -1166,10 +1097,10 @@ extern unsigned rs6000_pointer_size;
    ? ALTIVEC_VECTOR_MODE (MODE2)               \
    : ALTIVEC_VECTOR_MODE (MODE2)               \
    ? ALTIVEC_VECTOR_MODE (MODE1)               \
-   : VSX_VECTOR_MODE (MODE1)                   \
-   ? VSX_VECTOR_MODE (MODE2)                   \
-   : VSX_VECTOR_MODE (MODE2)                   \
-   ? VSX_VECTOR_MODE (MODE1)                   \
+   : ALTIVEC_OR_VSX_VECTOR_MODE (MODE1)                \
+   ? ALTIVEC_OR_VSX_VECTOR_MODE (MODE2)                \
+   : ALTIVEC_OR_VSX_VECTOR_MODE (MODE2)                \
+   ? ALTIVEC_OR_VSX_VECTOR_MODE (MODE1)                \
    : 1)
 
 /* Post-reload, we can't use any new AltiVec registers, as we already
@@ -1198,11 +1129,6 @@ extern unsigned rs6000_pointer_size;
 
 #define FIXED_SCRATCH 0
 
-/* Define this macro to change register usage conditional on target
-   flags.  */
-
-#define CONDITIONAL_REGISTER_USAGE rs6000_conditional_register_usage ()
-
 /* Specify the registers used for certain standard purposes.
    The values of these macros are register numbers.  */
 
@@ -1338,39 +1264,11 @@ enum reg_class
   { 0xffffffff, 0x00000000, 0x0000000f, 0x00022000 }, /* SPEC_OR_GEN_REGS */ \
   { 0x00000000, 0x00000000, 0x00000010, 0x00000000 }, /* CR0_REGS */        \
   { 0x00000000, 0x00000000, 0x00000ff0, 0x00000000 }, /* CR_REGS */         \
-  { 0xffffffff, 0x00000000, 0x0000efff, 0x00020000 }, /* NON_FLOAT_REGS */   \
+  { 0xffffffff, 0x00000000, 0x00000fff, 0x00020000 }, /* NON_FLOAT_REGS */   \
   { 0x00000000, 0x00000000, 0x00001000, 0x00000000 }, /* CA_REGS */         \
   { 0xffffffff, 0xffffffff, 0xffffffff, 0x0003ffff }  /* ALL_REGS */        \
 }
 
-/* The following macro defines cover classes for Integrated Register
-   Allocator.  Cover classes is a set of non-intersected register
-   classes covering all hard registers used for register allocation
-   purpose.  Any move between two registers of a cover class should be
-   cheaper than load or store of the registers.  The macro value is
-   array of register classes with LIM_REG_CLASSES used as the end
-   marker.
-
-   We need two IRA_COVER_CLASSES, one for pre-VSX, and the other for VSX to
-   account for the Altivec and Floating registers being subsets of the VSX
-   register set.  */
-
-#define IRA_COVER_CLASSES_PRE_VSX                                           \
-{                                                                           \
-  GENERAL_REGS, SPECIAL_REGS, FLOAT_REGS, ALTIVEC_REGS, /* VSX_REGS, */             \
-  /* VRSAVE_REGS,*/ VSCR_REGS, SPE_ACC_REGS, SPEFSCR_REGS,                  \
-  /* MQ_REGS, LINK_REGS, CTR_REGS, */                                       \
-  CR_REGS, CA_REGS, LIM_REG_CLASSES                                         \
-}
-
-#define IRA_COVER_CLASSES_VSX                                               \
-{                                                                           \
-  GENERAL_REGS, SPECIAL_REGS, /* FLOAT_REGS, ALTIVEC_REGS, */ VSX_REGS,             \
-  /* VRSAVE_REGS,*/ VSCR_REGS, SPE_ACC_REGS, SPEFSCR_REGS,                  \
-  /* MQ_REGS, LINK_REGS, CTR_REGS, */                                       \
-  CR_REGS, CA_REGS, LIM_REG_CLASSES                                         \
-}
-
 /* The same information, inverted:
    Return the class number of the smallest class containing
    reg number REGNO.  This could be a conditional expression
@@ -1468,16 +1366,6 @@ extern enum reg_class rs6000_constraints[RS6000_CONSTRAINT_MAX];
 
 /* Stack layout; function entry, exit and calling.  */
 
-/* Enumeration to give which calling sequence to use.  */
-enum rs6000_abi {
-  ABI_NONE,
-  ABI_AIX,                     /* IBM's AIX */
-  ABI_V4,                      /* System V.4/eabi */
-  ABI_DARWIN                   /* Apple's Darwin (OS X kernel) */
-};
-
-extern enum rs6000_abi rs6000_current_abi;     /* available for use by subtarget */
-
 /* Define this if pushing a word on the stack
    makes the stack pointer a smaller address.  */
 #define STACK_GROWS_DOWNWARD
@@ -1681,25 +1569,29 @@ typedef struct rs6000_args
   int floats_in_gpr;           /* count of SFmode floats taking up
                                   GPR space (darwin64) */
   int named;                   /* false for varargs params */
+  int escapes;                 /* if function visible outside tu */
 } CUMULATIVE_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.  */
 
-#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
-  init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE, FALSE, N_NAMED_ARGS)
+#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
+  init_cumulative_args (&CUM, FNTYPE, LIBNAME, FALSE, FALSE, \
+                       N_NAMED_ARGS, FNDECL, VOIDmode)
 
 /* Similar, but when scanning the definition of a procedure.  We always
    set NARGS_PROTOTYPE large so we never return an EXPR_LIST.  */
 
 #define INIT_CUMULATIVE_INCOMING_ARGS(CUM, FNTYPE, LIBNAME) \
-  init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE, FALSE, 1000)
+  init_cumulative_args (&CUM, FNTYPE, LIBNAME, TRUE, FALSE, \
+                       1000, current_function_decl, VOIDmode)
 
 /* Like INIT_CUMULATIVE_ARGS' but only used for outgoing libcalls.  */
 
 #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
-  init_cumulative_args (&CUM, NULL_TREE, LIBNAME, FALSE, TRUE, 0)
+  init_cumulative_args (&CUM, NULL_TREE, LIBNAME, FALSE, TRUE, \
+                       0, NULL_TREE, MODE)
 
 /* If defined, a C expression which determines whether, and in which
    direction, to pad out an argument with extra space.  The value
@@ -1709,13 +1601,6 @@ typedef struct rs6000_args
 
 #define FUNCTION_ARG_PADDING(MODE, TYPE) function_arg_padding (MODE, TYPE)
 
-/* If defined, a C expression that gives the alignment boundary, in bits,
-   of an argument with the specified mode and type.  If it is not defined,
-   PARM_BOUNDARY is used for all arguments.  */
-
-#define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
-  function_arg_boundary (MODE, TYPE)
-
 #define PAD_VARARGS_DOWN \
    (FUNCTION_ARG_PADDING (TYPE_MODE (type), type) == downward)
 
@@ -1860,22 +1745,6 @@ typedef struct rs6000_args
    || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST               \
    || GET_CODE (X) == HIGH)
 
-/* Nonzero if the constant value X is a legitimate general operand.
-   It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE.
-
-   On the RS/6000, all integer constants are acceptable, most won't be valid
-   for particular insns, though.  Only easy FP constants are
-   acceptable.  */
-
-#define LEGITIMATE_CONSTANT_P(X)                               \
-  (((GET_CODE (X) != CONST_DOUBLE                              \
-     && GET_CODE (X) != CONST_VECTOR)                          \
-    || GET_MODE (X) == VOIDmode                                        \
-    || (TARGET_POWERPC64 && GET_MODE (X) == DImode)            \
-    || easy_fp_constant (X, GET_MODE (X))                      \
-    || easy_vector_constant (X, GET_MODE (X)))                 \
-   && !rs6000_tls_referenced_p (X))
-
 #define EASY_VECTOR_15(n) ((n) >= -16 && (n) <= 15)
 #define EASY_VECTOR_15_ADD_SELF(n) (!EASY_VECTOR_15((n))       \
                                    && EASY_VECTOR_15((n) >> 1) \
@@ -2388,6 +2257,9 @@ extern char rs6000_reg_names[][8];        /* register names (0 vs. %r0).  */
   if ((LOG) != 0)                      \
     fprintf (FILE, "\t.align %d\n", (LOG))
 
+/* How to align the given loop. */
+#define LOOP_ALIGN(LABEL)  rs6000_loop_align(LABEL)
+
 /* Pick up the return address upon entry to a procedure. Used for
    dwarf2 unwind information.  This also enables the table driven
    mechanism.  */
@@ -2422,24 +2294,83 @@ extern char rs6000_reg_names[][8];      /* register names (0 vs. %r0).  */
 /* General flags.  */
 extern int frame_pointer_needed;
 
-/* Classification of the builtin functions to properly set the declaration tree
-   flags.  */
-enum rs6000_btc
-{
-  RS6000_BTC_MISC,             /* assume builtin can do anything */
-  RS6000_BTC_CONST,            /* builtin is a 'const' function.  */
-  RS6000_BTC_PURE,             /* builtin is a 'pure' function.  */
-  RS6000_BTC_FP_PURE           /* builtin is 'pure' if rounding math.  */
-};
+/* Classification of the builtin functions as to which switches enable the
+   builtin, and what attributes it should have.  We used to use the target
+   flags macros, but we've run out of bits, so we now map the options into new
+   settings used here.  */
+
+/* Builtin attributes.  */
+#define RS6000_BTC_SPECIAL     0x00000000      /* Special function.  */
+#define RS6000_BTC_UNARY       0x00000001      /* normal unary function.  */
+#define RS6000_BTC_BINARY      0x00000002      /* normal binary function.  */
+#define RS6000_BTC_TERNARY     0x00000003      /* normal ternary function.  */
+#define RS6000_BTC_PREDICATE   0x00000004      /* predicate function.  */
+#define RS6000_BTC_ABS         0x00000005      /* Altivec/VSX ABS function.  */
+#define RS6000_BTC_EVSEL       0x00000006      /* SPE EVSEL function.  */
+#define RS6000_BTC_DST         0x00000007      /* Altivec DST function.  */
+#define RS6000_BTC_TYPE_MASK   0x0000000f      /* Mask to isolate types */
+
+#define RS6000_BTC_MISC                0x00000000      /* No special attributes.  */
+#define RS6000_BTC_CONST       0x00000100      /* uses no global state.  */
+#define RS6000_BTC_PURE                0x00000200      /* reads global state/mem.  */
+#define RS6000_BTC_FP          0x00000400      /* depends on rounding mode.  */
+#define RS6000_BTC_ATTR_MASK   0x00000700      /* Mask of the attributes.  */
+
+/* Miscellaneous information.  */
+#define RS6000_BTC_OVERLOADED  0x4000000       /* function is overloaded.  */
 
 /* Convenience macros to document the instruction type.  */
-#define RS6000_BTC_MEM RS6000_BTC_MISC /* load/store touches memory */
-#define RS6000_BTC_SAT RS6000_BTC_MISC /* VMX saturate sets VSCR register */
-
-#undef RS6000_BUILTIN
-#undef RS6000_BUILTIN_EQUATE
-#define RS6000_BUILTIN(NAME, TYPE) NAME,
-#define RS6000_BUILTIN_EQUATE(NAME, VALUE) NAME = VALUE,
+#define RS6000_BTC_MEM         RS6000_BTC_MISC /* load/store touches mem.  */
+#define RS6000_BTC_SAT         RS6000_BTC_MISC /* saturate sets VSCR.  */
+
+/* Builtin targets.  For now, we reuse the masks for those options that are in
+   target flags, and pick two random bits for SPE and paired which aren't in
+   target_flags.  */
+#define RS6000_BTM_ALTIVEC     MASK_ALTIVEC    /* VMX/altivec vectors.  */
+#define RS6000_BTM_VSX         MASK_VSX        /* VSX (vector/scalar).  */
+#define RS6000_BTM_SPE         MASK_STRING     /* E500 */
+#define RS6000_BTM_PAIRED      MASK_MULHW      /* 750CL paired insns.  */
+#define RS6000_BTM_FRE         MASK_POPCNTB    /* FRE instruction.  */
+#define RS6000_BTM_FRES                MASK_PPC_GFXOPT /* FRES instruction.  */
+#define RS6000_BTM_FRSQRTE     MASK_PPC_GFXOPT /* FRSQRTE instruction.  */
+#define RS6000_BTM_FRSQRTES    MASK_POPCNTB    /* FRSQRTES instruction.  */
+#define RS6000_BTM_POPCNTD     MASK_POPCNTD    /* Target supports ISA 2.06.  */
+#define RS6000_BTM_POWERPC     MASK_POWERPC    /* Target is powerpc.  */
+#define RS6000_BTM_CELL                MASK_FPRND      /* Target is cell powerpc.  */
+
+#define RS6000_BTM_COMMON      (RS6000_BTM_ALTIVEC                     \
+                                | RS6000_BTM_VSX                       \
+                                | RS6000_BTM_FRE                       \
+                                | RS6000_BTM_FRES                      \
+                                | RS6000_BTM_FRSQRTE                   \
+                                | RS6000_BTM_FRSQRTES                  \
+                                | RS6000_BTM_POPCNTD                   \
+                                | RS6000_BTM_POWERPC                   \
+                                | RS6000_BTM_CELL)
+
+/* Define builtin enum index.  */
+
+#undef RS6000_BUILTIN_1
+#undef RS6000_BUILTIN_2
+#undef RS6000_BUILTIN_3
+#undef RS6000_BUILTIN_A
+#undef RS6000_BUILTIN_D
+#undef RS6000_BUILTIN_E
+#undef RS6000_BUILTIN_P
+#undef RS6000_BUILTIN_Q
+#undef RS6000_BUILTIN_S
+#undef RS6000_BUILTIN_X
+
+#define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
+#define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
 enum rs6000_builtins
 {
@@ -2448,8 +2379,16 @@ enum rs6000_builtins
   RS6000_BUILTIN_COUNT
 };
 
-#undef RS6000_BUILTIN
-#undef RS6000_BUILTIN_EQUATE
+#undef RS6000_BUILTIN_1
+#undef RS6000_BUILTIN_2
+#undef RS6000_BUILTIN_3
+#undef RS6000_BUILTIN_A
+#undef RS6000_BUILTIN_D
+#undef RS6000_BUILTIN_E
+#undef RS6000_BUILTIN_P
+#undef RS6000_BUILTIN_Q
+#undef RS6000_BUILTIN_S
+#undef RS6000_BUILTIN_X
 
 enum rs6000_builtin_type_index
 {
@@ -2483,6 +2422,8 @@ enum rs6000_builtin_type_index
   RS6000_BTI_pixel_V8HI,         /* __vector __pixel */
   RS6000_BTI_long,              /* long_integer_type_node */
   RS6000_BTI_unsigned_long,      /* long_unsigned_type_node */
+  RS6000_BTI_long_long,                 /* long_long_integer_type_node */
+  RS6000_BTI_unsigned_long_long, /* long_long_unsigned_type_node */
   RS6000_BTI_INTQI,             /* intQI_type_node */
   RS6000_BTI_UINTQI,            /* unsigned_intQI_type_node */
   RS6000_BTI_INTHI,             /* intHI_type_node */
@@ -2526,6 +2467,8 @@ enum rs6000_builtin_type_index
 #define bool_V2DI_type_node          (rs6000_builtin_types[RS6000_BTI_bool_V2DI])
 #define pixel_V8HI_type_node         (rs6000_builtin_types[RS6000_BTI_pixel_V8HI])
 
+#define long_long_integer_type_internal_node  (rs6000_builtin_types[RS6000_BTI_long_long])
+#define long_long_unsigned_type_internal_node (rs6000_builtin_types[RS6000_BTI_unsigned_long_long])
 #define long_integer_type_internal_node  (rs6000_builtin_types[RS6000_BTI_long])
 #define long_unsigned_type_internal_node (rs6000_builtin_types[RS6000_BTI_unsigned_long])
 #define intQI_type_internal_node        (rs6000_builtin_types[RS6000_BTI_INTQI])