OSDN Git Service

2005-12-05 Jan Beulich <jbeulich@novell.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / ia64.md
index c12c8f3..afe3e53 100644 (file)
@@ -1,5 +1,5 @@
 ;; IA-64 Machine description template
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
 ;; Free Software Foundation, Inc.
 ;; Contributed by James E. Wilson <wilson@cygnus.com> and
 ;;               David Mosberger <davidm@hpl.hp.com>.
@@ -18,8 +18,8 @@
 
 ;; 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, 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
 
@@ -56,6 +56,7 @@
    (UNSPEC_DTPREL              2)
    (UNSPEC_LTOFF_TPREL         3)
    (UNSPEC_TPREL               4)
+   (UNSPEC_DTPMOD              5)
 
    (UNSPEC_LD_BASE             9)
    (UNSPEC_GR_SPILL            10)
@@ -77,6 +78,9 @@
    (UNSPEC_RET_ADDR            26)
    (UNSPEC_SETF_EXP             27)
    (UNSPEC_FR_SQRT_RECIP_APPROX 28)
+   (UNSPEC_SHRP                        29)
+   (UNSPEC_COPYSIGN            30)
+   (UNSPEC_VECT_EXTR           31)
   ])
 
 (define_constants
@@ -89,6 +93,8 @@
    (UNSPECV_PSAC_NORMAL                6)
    (UNSPECV_SETJMP_RECEIVER    7)
   ])
+
+(include "predicates.md")
 \f
 ;; ::::::::::::::::::::
 ;; ::
 ;; which emit instruction that can go in any slot (e.g. nop).
 
 (define_attr "itanium_class" "unknown,ignore,stop_bit,br,fcmp,fcvtfx,fld,
-       fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,ld,
-       chk_s,long_i,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,st,syst_m0,
-       syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,nop_b,nop_f,
-       nop_i,nop_m,nop_x,lfetch,pre_cycle"
+       fldp,fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,
+       ld,chk_s,long_i,mmalua,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,
+        st,syst_m0, syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,
+        nop_b,nop_f,nop_i,nop_m,nop_x,lfetch,pre_cycle"
   (const_string "unknown"))
 
 ;; chk_s has an I and an M form; use type A for convenience.
 (define_attr "type" "unknown,A,I,M,F,B,L,X,S"
-  (cond [(eq_attr "itanium_class" "ld,st,fld,stf,sem,nop_m") (const_string "M")
+  (cond [(eq_attr "itanium_class" "ld,st,fld,fldp,stf,sem,nop_m") (const_string "M")
         (eq_attr "itanium_class" "rse_m,syst_m,syst_m0") (const_string "M")
         (eq_attr "itanium_class" "frar_m,toar_m,frfr,tofr") (const_string "M")
         (eq_attr "itanium_class" "lfetch") (const_string "M")
-        (eq_attr "itanium_class" "chk_s,ialu,icmp,ilog") (const_string "A")
+        (eq_attr "itanium_class" "chk_s,ialu,icmp,ilog,mmalua")
+          (const_string "A")
         (eq_attr "itanium_class" "fmisc,fmac,fcmp,xmpy") (const_string "F")
         (eq_attr "itanium_class" "fcvtfx,nop_f") (const_string "F")
         (eq_attr "itanium_class" "frar_i,toar_i,frbr,tobr") (const_string "I")
 
 (define_attr "predicable" "no,yes" (const_string "yes"))
 
-\f
+;; Empty.  True iff this insn does not generate any code.
+
+(define_attr "empty" "no,yes" (const_string "no"))
 
+;; True iff this insn must be the first insn of an instruction group.
+;; This is true for the alloc instruction, and will also be true of others
+;; when we have full intrinsics support.
+
+(define_attr "first_insn" "no,yes" (const_string "no"))
+\f
 ;; DFA descriptions of ia64 processors used for insn scheduling and
 ;; bundling.
 
 
 (automata_option "w")
 
-;;(automata_option "no-minimization")
-
-
 (include "itanium1.md")
 (include "itanium2.md")
 
    (set_attr "predicable" "no")])
 
 (define_insn "movbi"
-  [(set (match_operand:BI 0 "nonimmediate_operand" "=c,c,?c,?*r, c,*r,*r,*m,*r")
-       (match_operand:BI 1 "move_operand"         " O,n, c,  c,*r, n,*m,*r,*r"))]
+  [(set (match_operand:BI 0 "destination_operand" "=c,c,?c,?*r, c,*r,*r,*m,*r")
+       (match_operand:BI 1 "move_operand"        " O,n, c,  c,*r, n,*m,*r,*r"))]
   ""
   "@
    cmp.ne %0, %I0 = r0, r0
     "mov pr = %1, -1"
   };
 
-  if (which_alternative == 2 && ! TARGET_NO_PIC
-      && symbolic_operand (operands[1], VOIDmode))
-    abort ();
+  gcc_assert (which_alternative != 2 || TARGET_NO_PIC
+              || !symbolic_operand (operands[1], VOIDmode));
 
   return alt[which_alternative];
 }
 (define_split
   [(set (match_operand 0 "register_operand" "")
        (match_operand 1 "symbolic_operand" ""))]
-  "reload_completed && ! TARGET_NO_PIC"
+  "reload_completed"
   [(const_int 0)]
 {
-  ia64_expand_load_address (operands[0], operands[1]);
-  DONE;
+  if (ia64_expand_load_address (operands[0], operands[1]))
+    DONE;
+  else
+    FAIL;
 })
 
 (define_expand "load_fptr"
-  [(set (match_dup 2)
-       (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "")))
-   (set (match_operand:DI 0 "register_operand" "") (match_dup 3))]
-  ""
+  [(set (match_operand:DI 0 "register_operand" "")
+       (plus:DI (match_dup 2) (match_operand 1 "function_operand" "")))
+   (set (match_dup 0) (match_dup 3))]
+  "reload_completed"
 {
-  operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
-  operands[3] = gen_rtx_MEM (DImode, operands[2]);
-  RTX_UNCHANGING_P (operands[3]) = 1;
+  operands[2] = pic_offset_table_rtx;
+  operands[3] = gen_const_mem (DImode, operands[0]);
 })
 
 (define_insn "*load_fptr_internal1"
   [(set (match_operand:DI 0 "register_operand" "=r")
        (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "s")))]
-  ""
+  "reload_completed"
   "addl %0 = @ltoff(@fptr(%1)), gp"
   [(set_attr "itanium_class" "ialu")])
 
 (define_insn "load_gprel"
   [(set (match_operand:DI 0 "register_operand" "=r")
        (plus:DI (reg:DI 1) (match_operand 1 "sdata_symbolic_operand" "s")))]
-  ""
+  "reload_completed"
   "addl %0 = @gprel(%1), gp"
   [(set_attr "itanium_class" "ialu")])
 
-(define_insn "gprel64_offset"
+(define_insn "*gprel64_offset"
   [(set (match_operand:DI 0 "register_operand" "=r")
        (minus:DI (match_operand:DI 1 "symbolic_operand" "") (reg:DI 1)))]
-  ""
+  "reload_completed"
   "movl %0 = @gprel(%1)"
   [(set_attr "itanium_class" "long_i")])
 
 (define_expand "load_gprel64"
-  [(set (match_dup 2)
-       (minus:DI (match_operand:DI 1 "symbolic_operand" "") (match_dup 3)))
-   (set (match_operand:DI 0 "register_operand" "")
-       (plus:DI (match_dup 3) (match_dup 2)))]
-  ""
+  [(set (match_operand:DI 0 "register_operand" "")
+       (minus:DI (match_operand:DI 1 "symbolic_operand" "") (match_dup 2)))
+   (set (match_dup 0)
+       (plus:DI (match_dup 2) (match_dup 0)))]
+  "reload_completed"
 {
-  operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
-  operands[3] = pic_offset_table_rtx;
+  operands[2] = pic_offset_table_rtx;
 })
 
 ;; This is used as a placeholder for the return address during early
   [(set (match_operand:DI 0 "register_operand" "=r")
        (plus:DI (high:DI (match_operand 1 "got_symbolic_operand" "s"))
                 (match_operand:DI 2 "register_operand" "a")))]
-  ""
+  "reload_completed"
 {
   if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
     return "%,addl %0 = @ltoffx(%1), %2";
   [(set (match_operand:DI 0 "register_operand" "=r")
        (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
                   (match_operand 2 "got_symbolic_operand" "s")))]
-  ""
+  "reload_completed"
 {
   if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
     return "%,ld8.mov %0 = [%1], %2";
 }
   [(set_attr "itanium_class" "ld")])
 
-(define_insn "load_ltoff_dtpmod"
+(define_insn_and_split "load_dtpmod"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (reg:DI 1)
-                (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
-                           UNSPEC_LTOFF_DTPMOD)))]
+       (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
+                  UNSPEC_DTPMOD))]
   ""
-  "addl %0 = @ltoff(@dtpmod(%1)), gp"
-  [(set_attr "itanium_class" "ialu")])
+  "#"
+  "reload_completed"
+  [(set (match_dup 0)
+       (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPMOD)
+                (match_dup 2)))
+   (set (match_dup 0) (match_dup 3))]
+{
+  operands[2] = pic_offset_table_rtx;
+  operands[3] = gen_const_mem (DImode, operands[0]);
+})
 
-(define_insn "load_ltoff_dtprel"
+(define_insn "*load_ltoff_dtpmod"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (reg:DI 1)
-                (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
-                           UNSPEC_LTOFF_DTPREL)))]
-  ""
-  "addl %0 = @ltoff(@dtprel(%1)), gp"
+       (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
+                           UNSPEC_LTOFF_DTPMOD)
+                (match_operand:DI 2 "register_operand" "a")))]
+  "reload_completed"
+  "addl %0 = @ltoff(@dtpmod(%1)), %2"
   [(set_attr "itanium_class" "ialu")])
 
 (define_expand "load_dtprel"
   [(set (match_operand:DI 0 "register_operand" "")
-       (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
+       (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
                   UNSPEC_DTPREL))]
   ""
   "")
 
 (define_insn "*load_dtprel64"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
+       (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
                   UNSPEC_DTPREL))]
   "TARGET_TLS64"
   "movl %0 = @dtprel(%1)"
 
 (define_insn "*load_dtprel22"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
+       (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
                   UNSPEC_DTPREL))]
   ""
   "addl %0 = @dtprel(%1), r0"
   [(set_attr "itanium_class" "ialu")])
 
+(define_insn_and_split "*load_dtprel_gd"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+       (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
+                  UNSPEC_DTPREL))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 0)
+       (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_DTPREL)
+                (match_dup 2)))
+   (set (match_dup 0) (match_dup 3))]
+{
+  operands[2] = pic_offset_table_rtx;
+  operands[3] = gen_const_mem (DImode, operands[0]);
+})
+
+(define_insn "*load_ltoff_dtprel"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+       (plus:DI (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
+                           UNSPEC_LTOFF_DTPREL)
+                (match_operand:DI 2 "register_operand" "a")))]
+  ""
+  "addl %0 = @ltoff(@dtprel(%1)), %2"
+  [(set_attr "itanium_class" "ialu")])
+
 (define_expand "add_dtprel"
   [(set (match_operand:DI 0 "register_operand" "")
-       (plus:DI (match_operand:DI 1 "register_operand" "")
-                (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
-                           UNSPEC_DTPREL)))]
+       (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
+                           UNSPEC_DTPREL)
+                (match_operand:DI 2 "register_operand" "")))]
   "!TARGET_TLS64"
   "")
 
 (define_insn "*add_dtprel14"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (match_operand:DI 1 "register_operand" "r")
-                (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
-                           UNSPEC_DTPREL)))]
+       (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
+                           UNSPEC_DTPREL)
+                (match_operand:DI 2 "register_operand" "r")))]
   "TARGET_TLS14"
-  "adds %0 = @dtprel(%2), %1"
+  "adds %0 = @dtprel(%1), %2"
   [(set_attr "itanium_class" "ialu")])
 
 (define_insn "*add_dtprel22"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (match_operand:DI 1 "register_operand" "a")
-                (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
-                           UNSPEC_DTPREL)))]
+       (plus:DI (unspec:DI [(match_operand 1 "ld_tls_symbolic_operand" "")]
+                           UNSPEC_DTPREL)
+                (match_operand:DI 2 "register_operand" "a")))]
   "TARGET_TLS22"
-  "addl %0 = @dtprel(%2), %1"
-  [(set_attr "itanium_class" "ialu")])
-
-(define_insn "load_ltoff_tprel"
-  [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (reg:DI 1)
-                (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
-                           UNSPEC_LTOFF_TPREL)))]
-  ""
-  "addl %0 = @ltoff(@tprel(%1)), gp"
+  "addl %0 = @dtprel(%1), %2"
   [(set_attr "itanium_class" "ialu")])
 
 (define_expand "load_tprel"
   [(set (match_operand:DI 0 "register_operand" "")
-       (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
+       (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
                   UNSPEC_TPREL))]
   ""
   "")
 
 (define_insn "*load_tprel64"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
+       (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
                   UNSPEC_TPREL))]
   "TARGET_TLS64"
   "movl %0 = @tprel(%1)"
 
 (define_insn "*load_tprel22"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
+       (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
                   UNSPEC_TPREL))]
   ""
   "addl %0 = @tprel(%1), r0"
   [(set_attr "itanium_class" "ialu")])
 
+(define_insn_and_split "*load_tprel_ie"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+       (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
+                  UNSPEC_TPREL))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 0)
+       (plus:DI (unspec:DI [(match_dup 1)] UNSPEC_LTOFF_TPREL)
+                (match_dup 2)))
+   (set (match_dup 0) (match_dup 3))]
+{
+  operands[2] = pic_offset_table_rtx;
+  operands[3] = gen_const_mem (DImode, operands[0]);
+})
+
+(define_insn "*load_ltoff_tprel"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+       (plus:DI (unspec:DI [(match_operand 1 "ie_tls_symbolic_operand" "")]
+                           UNSPEC_LTOFF_TPREL)
+                (match_operand:DI 2 "register_operand" "a")))]
+  ""
+  "addl %0 = @ltoff(@tprel(%1)), %2"
+  [(set_attr "itanium_class" "ialu")])
+
 (define_expand "add_tprel"
   [(set (match_operand:DI 0 "register_operand" "")
-       (plus:DI (match_operand:DI 1 "register_operand" "")
-                (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
-                           UNSPEC_TPREL)))]
+       (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
+                           UNSPEC_TPREL)
+                (match_operand:DI 2 "register_operand" "")))]
   "!TARGET_TLS64"
   "")
 
 (define_insn "*add_tprel14"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (match_operand:DI 1 "register_operand" "r")
-                (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
-                           UNSPEC_TPREL)))]
+       (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
+                           UNSPEC_TPREL)
+                (match_operand:DI 2 "register_operand" "r")))]
   "TARGET_TLS14"
-  "adds %0 = @tprel(%2), %1"
+  "adds %0 = @tprel(%1), %2"
   [(set_attr "itanium_class" "ialu")])
 
 (define_insn "*add_tprel22"
   [(set (match_operand:DI 0 "register_operand" "=r")
-       (plus:DI (match_operand:DI 1 "register_operand" "a")
-                (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
-                           UNSPEC_TPREL)))]
+       (plus:DI (unspec:DI [(match_operand 1 "le_tls_symbolic_operand" "")]
+                           UNSPEC_TPREL)
+                (match_operand:DI 2 "register_operand" "a")))]
   "TARGET_TLS22"
-  "addl %0 = @tprel(%2), %1"
+  "addl %0 = @tprel(%1), %2"
   [(set_attr "itanium_class" "ialu")])
 
 ;; With no offsettable memory references, we've got to have a scratch
 })
 
 (define_insn_and_split "*movti_internal"
-  [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
-       (match_operand:TI 1 "general_operand"      "ri,m,r"))]
+  [(set (match_operand:TI 0 "destination_operand" "=r,   *fm,*x,*f,  Q")
+       (match_operand:TI 1 "general_operand"     "r*fim,r,  Q, *fOQ,*f"))]
   "ia64_move_ok (operands[0], operands[1])"
-  "#"
-  "reload_completed"
+  "@
+   #
+   #
+   ldfp8 %X0 = %1%P1
+   #
+   #"
+  "reload_completed && !ia64_load_pair_ok(operands[0], operands[1])"
   [(const_int 0)]
 {
   ia64_split_tmode_move (operands);
   DONE;
 }
-  [(set_attr "itanium_class" "unknown")
-   (set_attr "predicable" "no")])
+  [(set_attr "itanium_class" "unknown,unknown,fldp,unknown,unknown")])
 
 ;; Floating Point Moves
 ;;
        (match_operand:XF 1 "general_operand" ""))]
   ""
 {
-  /* We must support XFmode loads into general registers for stdarg/vararg
-     and unprototyped calls.  We split them into DImode loads for convenience.
-     We don't need XFmode stores from general regs, because a stdarg/vararg
-     routine does a block store to memory of unnamed arguments.  */
-  if (GET_CODE (operands[0]) == REG
-      && GR_REGNO_P (REGNO (operands[0])))
-    {
-      /* We're hoping to transform everything that deals with XFmode
-        quantities and GR registers early in the compiler.  */
-      if (no_new_pseudos)
-       abort ();
-
-      /* Struct to register can just use TImode instead.  */
-      if ((GET_CODE (operands[1]) == SUBREG
-          && GET_MODE (SUBREG_REG (operands[1])) == TImode)
-         || (GET_CODE (operands[1]) == REG
-             && GR_REGNO_P (REGNO (operands[1]))))
-       {
-         emit_move_insn (gen_rtx_REG (TImode, REGNO (operands[0])),
-                         SUBREG_REG (operands[1]));
-         DONE;
-       }
-
-      if (GET_CODE (operands[1]) == CONST_DOUBLE)
-       {
-         emit_move_insn (gen_rtx_REG (DImode, REGNO (operands[0])),
-                         operand_subword (operands[1], 0, 0, XFmode));
-         emit_move_insn (gen_rtx_REG (DImode, REGNO (operands[0]) + 1),
-                         operand_subword (operands[1], 1, 0, XFmode));
-         DONE;
-       }
-
-      /* If the quantity is in a register not known to be GR, spill it.  */
-      if (register_operand (operands[1], XFmode))
-       operands[1] = spill_xfmode_operand (operands[1], 1);
-
-      if (GET_CODE (operands[1]) == MEM)
-       {
-         rtx out[2];
-
-         out[WORDS_BIG_ENDIAN] = gen_rtx_REG (DImode, REGNO (operands[0]));
-         out[!WORDS_BIG_ENDIAN] = gen_rtx_REG (DImode, REGNO (operands[0])+1);
-
-         emit_move_insn (out[0], adjust_address (operands[1], DImode, 0));
-         emit_move_insn (out[1], adjust_address (operands[1], DImode, 8));
-         DONE;
-       }
-
-      abort ();
-    }
-
-  if (! reload_in_progress && ! reload_completed)
-    {
-      operands[0] = spill_xfmode_operand (operands[0], 0);
-      operands[1] = spill_xfmode_operand (operands[1], 0);
-
-      if (! ia64_move_ok (operands[0], operands[1]))
-       operands[1] = force_reg (XFmode, operands[1]);
-    }
+  if (ia64_expand_movxf_movrf (XFmode, operands))
+    DONE;
 })
 
 ;; ??? There's no easy way to mind volatile acquire/release semantics.
 
 (define_insn "*movxf_internal"
-  [(set (match_operand:XF 0 "destination_xfmode_operand" "=f,f, m")
-       (match_operand:XF 1 "general_xfmode_operand"     "fG,m,fG"))]
+  [(set (match_operand:XF 0 "destination_operand" "=f,f, m")
+       (match_operand:XF 1 "general_operand"     "fG,m,fG"))]
   "ia64_move_ok (operands[0], operands[1])"
   "@
    mov %0 = %F1
    stfe %0 = %F1%P0"
   [(set_attr "itanium_class" "fmisc,fld,stf")])
 
+;; Same as for movxf, but for RFmode.
+(define_expand "movrf"
+  [(set (match_operand:RF 0 "general_operand" "")
+       (match_operand:RF 1 "general_operand" ""))]
+  ""
+{
+  if (ia64_expand_movxf_movrf (RFmode, operands))
+    DONE;
+})
+
+(define_insn "*movrf_internal"
+  [(set (match_operand:RF 0 "destination_operand" "=f,f, m")
+       (match_operand:RF 1 "general_operand"     "fG,m,fG"))]
+  "ia64_move_ok (operands[0], operands[1])"
+  "@
+   mov %0 = %F1
+   ldf.fill %0 = %1%P1
+   stf.spill %0 = %F1%P0"
+  [(set_attr "itanium_class" "fmisc,fld,stf")])
+
 ;; Better code generation via insns that deal with TFmode register pairs
 ;; directly.  Same concerns apply as for TImode.
 (define_expand "movtf"
 })
 
 (define_insn_and_split "*movtf_internal"
-  [(set (match_operand:TF 0 "nonimmediate_operand" "=r,r,m")
+  [(set (match_operand:TF 0 "destination_operand"  "=r,r,m")
        (match_operand:TF 1 "general_operand"      "ri,m,r"))]
   "ia64_move_ok (operands[0], operands[1])"
   "#"
          (match_operand:SI 1 "grfr_nonimmediate_operand" "r,m,f")))]
   ""
   "@
-   zxt4 %0 = %1
+   addp4 %0 = %1, r0
    ld4%O1 %0 = %1%P1
    fmix.r %0 = f0, %1"
-  [(set_attr "itanium_class" "xtd,ld,fmisc")])
+  [(set_attr "itanium_class" "ialu,ld,fmisc")])
 
 ;; Convert between floating point types of different sizes.
 
   [(set_attr "itanium_class" "ishf")])
 
 ;; Combine doesn't like to create bit-field insertions into zero.
+(define_insn "*shladdp4_internal"
+  [(set (match_operand:DI 0 "gr_register_operand" "=r")
+       (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
+                          (match_operand:DI 2 "shladd_log2_operand" "n"))
+               (match_operand:DI 3 "const_int_operand" "n")))]
+  "ia64_depz_field_mask (operands[3], operands[2]) + INTVAL (operands[2]) == 32"
+  "shladdp4 %0 = %1, %2, r0"
+  [(set_attr "itanium_class" "ialu")])
+
 (define_insn "*depz_internal"
   [(set (match_operand:DI 0 "gr_register_operand" "=r")
        (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
   "TARGET_INLINE_INT_DIV"
 {
   rtx op1_xf, op2_xf, op0_xf, op0_di, twon34, twon34_exp;
-  REAL_VALUE_TYPE twon34_r;
 
   op0_xf = gen_reg_rtx (XFmode);
   op0_di = gen_reg_rtx (DImode);
   twon34 = gen_reg_rtx (XFmode);
   emit_insn (gen_setf_exp_xf (twon34, twon34_exp));
 
+  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (SImode),
+                           CONST1_RTX (SImode)));
+  
   emit_insn (gen_divsi3_internal (op0_xf, op1_xf, op2_xf, twon34));
 
   emit_insn (gen_fix_truncxfdi2_alts (op0_di, op0_xf, const1_rtx));
   "TARGET_INLINE_INT_DIV"
 {
   rtx op1_xf, op2_xf, op0_xf, op0_di, twon34, twon34_exp;
-  REAL_VALUE_TYPE twon34_r;
 
   op0_xf = gen_reg_rtx (XFmode);
   op0_di = gen_reg_rtx (DImode);
   twon34 = gen_reg_rtx (XFmode);
   emit_insn (gen_setf_exp_xf (twon34, twon34_exp));
 
+  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (SImode),
+                           CONST1_RTX (SImode)));
+  
   emit_insn (gen_divsi3_internal (op0_xf, op1_xf, op2_xf, twon34));
 
   emit_insn (gen_fixuns_truncxfdi2_alts (op0_di, op0_xf, const1_rtx));
    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
   "")
 
-;; ??? There are highpart multiply and add instructions, but we have no way
-;; to generate them.
-
 (define_insn "smuldi3_highpart"
   [(set (match_operand:DI 0 "fr_register_operand" "=f")
        (truncate:DI
   op2_xf = gen_reg_rtx (XFmode);
   expand_float (op2_xf, operands[2], 0);
 
-  if (TARGET_INLINE_INT_DIV_LAT)
+  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (DImode),
+                           CONST1_RTX (DImode)));
+
+  if (TARGET_INLINE_INT_DIV == INL_MIN_LAT)
     emit_insn (gen_divdi3_internal_lat (op0_xf, op1_xf, op2_xf));
   else
     emit_insn (gen_divdi3_internal_thr (op0_xf, op1_xf, op2_xf));
   op2_xf = gen_reg_rtx (XFmode);
   expand_float (op2_xf, operands[2], 1);
 
-  if (TARGET_INLINE_INT_DIV_LAT)
+  emit_insn (gen_cond_trap (EQ, operands[2], CONST0_RTX (DImode),
+                           CONST1_RTX (DImode)));
+
+  if (TARGET_INLINE_INT_DIV == INL_MIN_LAT)
     emit_insn (gen_divdi3_internal_lat (op0_xf, op1_xf, op2_xf));
   else
     emit_insn (gen_divdi3_internal_thr (op0_xf, op1_xf, op2_xf));
    (clobber (match_scratch:XF 4 "=&f"))
    (clobber (match_scratch:XF 5 "=&f"))
    (clobber (match_scratch:BI 6 "=c"))]
-  "TARGET_INLINE_INT_DIV_LAT"
+  "TARGET_INLINE_INT_DIV == INL_MIN_LAT"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
    (clobber (match_scratch:XF 3 "=&f"))
    (clobber (match_scratch:XF 4 "=f"))
    (clobber (match_scratch:BI 5 "=c"))]
-  "TARGET_INLINE_INT_DIV_THR"
+  "TARGET_INLINE_INT_DIV == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
 \f
 ;; ::::::::::::::::::::
 ;; ::
+;; :: 128 bit Integer arithmetic
+;; ::
+;; ::::::::::::::::::::
+
+(define_insn "addti3"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (plus:TI (match_operand:TI 1 "gr_register_operand" "%r")
+                (match_operand:TI 2 "gr_reg_or_14bit_operand" "rI")))
+   (clobber (match_scratch:BI 3 "=&c"))]
+  ""
+  "#"
+  [(set_attr "itanium_class" "unknown")])
+
+(define_split
+  [(set (match_operand:TI 0 "register_operand" "")
+       (plus:TI (match_operand:TI 1 "register_operand" "")
+                (match_operand:TI 2 "register_operand" "")))
+   (clobber (match_scratch:BI 3 ""))]
+  "reload_completed"
+  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
+   (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
+   (cond_exec (eq (match_dup 3) (const_int 0))
+             (set (match_dup 4) (plus:DI (match_dup 5) (match_dup 6))))
+   (cond_exec (ne (match_dup 3) (const_int 0))
+             (set (match_dup 4)
+                  (plus:DI (plus:DI (match_dup 5) (match_dup 6))
+                           (const_int 1))))]
+{
+  operands[4] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+  operands[5] = gen_highpart (DImode, operands[1]);
+  operands[1] = gen_lowpart (DImode, operands[1]);
+  operands[6] = gen_highpart (DImode, operands[2]);
+  operands[2] = gen_lowpart (DImode, operands[2]);
+})
+
+(define_split
+  [(set (match_operand:TI 0 "register_operand" "")
+       (plus:TI (match_operand:TI 1 "register_operand" "")
+                (match_operand:TI 2 "immediate_operand" "")))
+   (clobber (match_scratch:BI 3 ""))]
+  "reload_completed"
+  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))
+   (set (match_dup 3) (ltu:BI (match_dup 0) (match_dup 1)))
+   (cond_exec (eq (match_dup 3) (const_int 0))
+             (set (match_dup 4)
+                  (plus:DI (match_dup 5) (match_dup 6))))
+   (cond_exec (ne (match_dup 3) (const_int 0))
+             (set (match_dup 4)
+                  (plus:DI (match_dup 5) (match_dup 7))))]
+{
+  operands[4] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+  operands[5] = gen_highpart (DImode, operands[1]);
+  operands[1] = gen_lowpart (DImode, operands[1]);
+  operands[6] = INTVAL (operands[2]) < 0 ? constm1_rtx : const0_rtx;
+  operands[7] = INTVAL (operands[2]) < 0 ? const0_rtx : const1_rtx;
+})
+
+(define_insn "subti3"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (minus:TI (match_operand:TI 1 "gr_reg_or_8bit_operand" "rK")
+                 (match_operand:TI 2 "gr_register_operand" "r")))
+   (clobber (match_scratch:BI 3 "=&c"))]
+  ""
+  "#"
+  [(set_attr "itanium_class" "unknown")])
+
+(define_split
+  [(set (match_operand:TI 0 "register_operand" "")
+       (minus:TI (match_operand:TI 1 "register_operand" "")
+                 (match_operand:TI 2 "register_operand" "")))
+   (clobber (match_scratch:BI 3 "=&c"))]
+  "reload_completed"
+  [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
+   (set (match_dup 3) (ltu:BI (match_dup 1) (match_dup 0)))
+   (cond_exec (eq (match_dup 3) (const_int 0))
+             (set (match_dup 4) (minus:DI (match_dup 5) (match_dup 6))))
+   (cond_exec (ne (match_dup 3) (const_int 0))
+             (set (match_dup 4)
+                  (plus:DI (not:DI (match_dup 6)) (match_dup 5))))]
+{
+  operands[4] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+  operands[5] = gen_highpart (DImode, operands[1]);
+  operands[1] = gen_lowpart (DImode, operands[1]);
+  operands[6] = gen_highpart (DImode, operands[2]);
+  operands[2] = gen_lowpart (DImode, operands[2]);
+})
+
+(define_split
+  [(set (match_operand:TI 0 "register_operand" "")
+       (minus:TI (match_operand:TI 1 "immediate_operand" "")
+                 (match_operand:TI 2 "register_operand" "")))
+   (clobber (match_scratch:BI 3 "=&c"))]
+  "reload_completed && CONST_OK_FOR_K (INTVAL (operands[1]))"
+  [(set (match_dup 0) (minus:DI (match_dup 1) (match_dup 2)))
+   (set (match_dup 3) (gtu:BI (match_dup 0) (match_dup 1)))
+   (cond_exec (ne (match_dup 3) (const_int 0))
+             (set (match_dup 4) (minus:DI (match_dup 6) (match_dup 5))))
+   (cond_exec (eq (match_dup 3) (const_int 0))
+             (set (match_dup 4) (minus:DI (match_dup 7) (match_dup 5))))]
+{
+  operands[4] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+  operands[5] = gen_highpart (DImode, operands[2]);
+  operands[2] = gen_lowpart (DImode, operands[2]);
+  operands[6] = INTVAL (operands[1]) < 0 ? GEN_INT (-2) : constm1_rtx;
+  operands[7] = INTVAL (operands[1]) < 0 ? constm1_rtx : const0_rtx;
+})
+
+(define_expand "mulditi3"
+  [(set (match_operand:TI 0 "fr_register_operand" "")
+       (mult:TI (sign_extend:TI
+                  (match_operand:DI 1 "fr_register_operand" ""))
+                (sign_extend:TI
+                  (match_operand:DI 2 "fr_register_operand" ""))))]
+  ""
+  "")
+
+(define_insn_and_split "*mulditi3_internal"
+  [(set (match_operand:TI 0 "fr_register_operand" "=&f")
+       (mult:TI (sign_extend:TI
+                  (match_operand:DI 1 "fr_register_operand" "%f"))
+                (sign_extend:TI
+                  (match_operand:DI 2 "fr_register_operand" "f"))))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
+   (set (match_dup 3) (truncate:DI
+                       (lshiftrt:TI
+                         (mult:TI (sign_extend:TI (match_dup 1))
+                                  (sign_extend:TI (match_dup 2)))
+                         (const_int 64))))]
+{
+  operands[3] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+}
+  [(set_attr "itanium_class" "unknown")])
+
+(define_expand "umulditi3"
+  [(set (match_operand:TI 0 "fr_register_operand" "")
+       (mult:TI (zero_extend:TI
+                  (match_operand:DI 1 "fr_register_operand" ""))
+                (zero_extend:TI
+                  (match_operand:DI 2 "fr_register_operand" ""))))]
+  ""
+  "")
+
+(define_insn_and_split "*umulditi3_internal"
+  [(set (match_operand:TI 0 "fr_register_operand" "=&f")
+       (mult:TI (zero_extend:TI
+                  (match_operand:DI 1 "fr_register_operand" "%f"))
+                (zero_extend:TI
+                  (match_operand:DI 2 "fr_register_operand" "f"))))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 0) (mult:DI (match_dup 1) (match_dup 2)))
+   (set (match_dup 3) (truncate:DI
+                       (lshiftrt:TI
+                         (mult:TI (zero_extend:TI (match_dup 1))
+                                  (zero_extend:TI (match_dup 2)))
+                         (const_int 64))))]
+{
+  operands[3] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+}
+  [(set_attr "itanium_class" "unknown")])
+
+(define_insn_and_split "negti2"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (neg:TI (match_operand:TI 1 "gr_register_operand" "r")))
+   (clobber (match_scratch:BI 2 "=&c"))]
+  ""
+  "#"
+  "reload_completed"
+  [(set (match_dup 2) (eq:BI (match_dup 1) (const_int 0)))
+   (set (match_dup 0) (minus:DI (const_int 0) (match_dup 1)))
+   (cond_exec (eq (match_dup 2) (const_int 0))
+             (set (match_dup 3) (minus:DI (const_int -1) (match_dup 4))))
+   (cond_exec (ne (match_dup 2) (const_int 0))
+             (set (match_dup 3) (minus:DI (const_int 0) (match_dup 4))))]
+{
+  operands[3] = gen_highpart (DImode, operands[0]);
+  operands[0] = gen_lowpart (DImode, operands[0]);
+  operands[4] = gen_highpart (DImode, operands[1]);
+  operands[1] = gen_lowpart (DImode, operands[1]);
+}
+  [(set_attr "itanium_class" "unknown")])
+\f
+;; ::::::::::::::::::::
+;; ::
 ;; :: 32 bit floating point arithmetic
 ;; ::
 ;; ::::::::::::::::::::
   "fnegabs %0 = %1"
   [(set_attr "itanium_class" "fmisc")])
 
-(define_insn "minsf3"
+(define_insn "copysignsf3"
+  [(set (match_operand:SF 0 "register_operand" "=f")
+       (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
+                   (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
+                  UNSPEC_COPYSIGN))]
+  ""
+  "fmerge.s %0 = %F2, %F1"
+  [(set_attr "itanium_class" "fmisc")])
+
+(define_insn "*ncopysignsf3"
+  [(set (match_operand:SF 0 "register_operand" "=f")
+       (neg:SF (unspec:SF [(match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
+                           (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")]
+                          UNSPEC_COPYSIGN)))]
+  ""
+  "fmerge.ns %0 = %F2, %F1"
+  [(set_attr "itanium_class" "fmisc")])
+
+(define_insn "sminsf3"
   [(set (match_operand:SF 0 "fr_register_operand" "=f")
        (smin:SF (match_operand:SF 1 "fr_register_operand" "f")
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
   "fmin %0 = %1, %F2"
   [(set_attr "itanium_class" "fmisc")])
 
-(define_insn "maxsf3"
+(define_insn "smaxsf3"
   [(set (match_operand:SF 0 "fr_register_operand" "=f")
        (smax:SF (match_operand:SF 1 "fr_register_operand" "f")
                 (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
   "TARGET_INLINE_FLOAT_DIV"
 {
   rtx insn;
-  if (TARGET_INLINE_FLOAT_DIV_LAT)
+  if (TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT)
     insn = gen_divsf3_internal_lat (operands[0], operands[1], operands[2]);
   else
     insn = gen_divsf3_internal_thr (operands[0], operands[1], operands[2]);
    (clobber (match_scratch:XF 3 "=&f"))
    (clobber (match_scratch:XF 4 "=f"))
    (clobber (match_scratch:BI 5 "=c"))]
-  "TARGET_INLINE_FLOAT_DIV_LAT"
+  "TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
              (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
                                            UNSPEC_FR_RECIP_APPROX))
-             (use (const_int 1))])
+             (use (const_int 0))])
    (cond_exec (ne (match_dup 5) (const_int 0))
      (parallel [(set (match_dup 3) (mult:XF (match_dup 7) (match_dup 6)))
                (use (const_int 1))]))
    (clobber (match_scratch:XF 3 "=&f"))
    (clobber (match_scratch:XF 4 "=f"))
    (clobber (match_scratch:BI 5 "=c"))]
-  "TARGET_INLINE_FLOAT_DIV_THR"
+  "TARGET_INLINE_FLOAT_DIV == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
              (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
                                            UNSPEC_FR_RECIP_APPROX))
-             (use (const_int 1))])
+             (use (const_int 0))])
    (cond_exec (ne (match_dup 5) (const_int 0))
      (parallel [(set (match_dup 3)
                     (minus:XF (match_dup 10)
   "TARGET_INLINE_SQRT"
 {
   rtx insn;
-  if (TARGET_INLINE_SQRT_LAT)
 #if 0
+  if (TARGET_INLINE_SQRT == INL_MIN_LAT)
     insn = gen_sqrtsf2_internal_lat (operands[0], operands[1]);
+  else
 #else
-    abort ();
+  gcc_assert (TARGET_INLINE_SQRT != INL_MIN_LAT);
 #endif
-  else
-    insn = gen_sqrtsf2_internal_thr (operands[0], operands[1]);
+  insn = gen_sqrtsf2_internal_thr (operands[0], operands[1]);
   emit_insn (insn);
   DONE;
 })
    (clobber (match_scratch:XF 5 "=&f"))
    ;; Register p6 in optimization guide.
    (clobber (match_scratch:BI 6 "=c"))]
-  "TARGET_INLINE_SQRT_THR"
+  "TARGET_INLINE_SQRT == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [ ;; exponent of +1/2 in r2
   "fnegabs %0 = %1"
   [(set_attr "itanium_class" "fmisc")])
 
-(define_insn "mindf3"
+(define_insn "copysigndf3"
+  [(set (match_operand:DF 0 "register_operand" "=f")
+       (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
+                   (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
+                  UNSPEC_COPYSIGN))]
+  ""
+  "fmerge.s %0 = %F2, %F1"
+  [(set_attr "itanium_class" "fmisc")])
+
+(define_insn "*ncopysigndf3"
+  [(set (match_operand:DF 0 "register_operand" "=f")
+       (neg:DF (unspec:DF [(match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
+                           (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")]
+                          UNSPEC_COPYSIGN)))]
+  ""
+  "fmerge.ns %0 = %F2, %F1"
+  [(set_attr "itanium_class" "fmisc")])
+
+(define_insn "smindf3"
   [(set (match_operand:DF 0 "fr_register_operand" "=f")
        (smin:DF (match_operand:DF 1 "fr_register_operand" "f")
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
   "fmin %0 = %1, %F2"
   [(set_attr "itanium_class" "fmisc")])
 
-(define_insn "maxdf3"
+(define_insn "smaxdf3"
   [(set (match_operand:DF 0 "fr_register_operand" "=f")
        (smax:DF (match_operand:DF 1 "fr_register_operand" "f")
                 (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
   "TARGET_INLINE_FLOAT_DIV"
 {
   rtx insn;
-  if (TARGET_INLINE_FLOAT_DIV_LAT)
+  if (TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT)
     insn = gen_divdf3_internal_lat (operands[0], operands[1], operands[2]);
   else
     insn = gen_divdf3_internal_thr (operands[0], operands[1], operands[2]);
    (clobber (match_scratch:XF 4 "=&f"))
    (clobber (match_scratch:XF 5 "=&f"))
    (clobber (match_scratch:BI 6 "=c"))]
-  "TARGET_INLINE_FLOAT_DIV_LAT"
+  "TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 7) (div:XF (const_int 1) (match_dup 9)))
              (set (match_dup 6) (unspec:BI [(match_dup 8) (match_dup 9)]
                                            UNSPEC_FR_RECIP_APPROX))
-             (use (const_int 1))])
+             (use (const_int 0))])
    (cond_exec (ne (match_dup 6) (const_int 0))
      (parallel [(set (match_dup 3) (mult:XF (match_dup 8) (match_dup 7)))
                (use (const_int 1))]))
    (clobber (match_scratch:XF 3 "=&f"))
    (clobber (match_scratch:DF 4 "=f"))
    (clobber (match_scratch:BI 5 "=c"))]
-  "TARGET_INLINE_FLOAT_DIV_THR"
+  "TARGET_INLINE_FLOAT_DIV == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
              (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
                                            UNSPEC_FR_RECIP_APPROX))
-             (use (const_int 1))])
+             (use (const_int 0))])
    (cond_exec (ne (match_dup 5) (const_int 0))
      (parallel [(set (match_dup 3)
                     (minus:XF (match_dup 10)
   "TARGET_INLINE_SQRT"
 {
   rtx insn;
-  if (TARGET_INLINE_SQRT_LAT)
 #if 0
+  if (TARGET_INLINE_SQRT == INL_MIN_LAT)
     insn = gen_sqrtdf2_internal_lat (operands[0], operands[1]);
+  else
 #else
-    abort ();
+  gcc_assert (TARGET_INLINE_SQRT != INL_MIN_LAT);
 #endif
-  else
-    insn = gen_sqrtdf2_internal_thr (operands[0], operands[1]);
+  insn = gen_sqrtdf2_internal_thr (operands[0], operands[1]);
   emit_insn (insn);
   DONE;
 })
    (clobber (match_scratch:XF 5 "=&f"))
    ;; Register p6 in optimization guide.
    (clobber (match_scratch:BI 6 "=c"))]
-  "TARGET_INLINE_SQRT_THR"
+  "TARGET_INLINE_SQRT == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [ ;; exponent of +1/2 in r2
   "fnegabs %0 = %F1"
   [(set_attr "itanium_class" "fmisc")])
 
-(define_insn "minxf3"
+(define_insn "copysignxf3"
+  [(set (match_operand:XF 0 "register_operand" "=f")
+       (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
+                   (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
+                  UNSPEC_COPYSIGN))]
+  ""
+  "fmerge.s %0 = %F2, %F1"
+  [(set_attr "itanium_class" "fmisc")])
+
+(define_insn "*ncopysignxf3"
+  [(set (match_operand:XF 0 "register_operand" "=f")
+       (neg:XF (unspec:XF [(match_operand:XF 1 "fr_reg_or_fp01_operand" "fG")
+                           (match_operand:XF 2 "fr_reg_or_fp01_operand" "fG")]
+                          UNSPEC_COPYSIGN)))]
+  ""
+  "fmerge.ns %0 = %F2, %F1"
+  [(set_attr "itanium_class" "fmisc")])
+
+(define_insn "sminxf3"
   [(set (match_operand:XF 0 "fr_register_operand" "=f")
        (smin:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
   "fmin %0 = %F1, %F2"
   [(set_attr "itanium_class" "fmisc")])
 
-(define_insn "maxxf3"
+(define_insn "smaxxf3"
   [(set (match_operand:XF 0 "fr_register_operand" "=f")
        (smax:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
                 (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
   "TARGET_INLINE_FLOAT_DIV"
 {
   rtx insn;
-  if (TARGET_INLINE_FLOAT_DIV_LAT)
+  if (TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT)
     insn = gen_divxf3_internal_lat (operands[0], operands[1], operands[2]);
   else
     insn = gen_divxf3_internal_thr (operands[0], operands[1], operands[2]);
    (clobber (match_scratch:XF 5 "=&f"))
    (clobber (match_scratch:XF 6 "=&f"))
    (clobber (match_scratch:BI 7 "=c"))]
-  "TARGET_INLINE_FLOAT_DIV_LAT"
+  "TARGET_INLINE_FLOAT_DIV == INL_MIN_LAT"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
              (set (match_dup 7) (unspec:BI [(match_dup 1) (match_dup 2)]
                                            UNSPEC_FR_RECIP_APPROX))
-             (use (const_int 1))])
+             (use (const_int 0))])
    (cond_exec (ne (match_dup 7) (const_int 0))
      (parallel [(set (match_dup 3)
                     (minus:XF (match_dup 8)
    (clobber (match_scratch:XF 3 "=&f"))
    (clobber (match_scratch:XF 4 "=&f"))
    (clobber (match_scratch:BI 5 "=c"))]
-  "TARGET_INLINE_FLOAT_DIV_THR"
+  "TARGET_INLINE_FLOAT_DIV == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
              (set (match_dup 5) (unspec:BI [(match_dup 1) (match_dup 2)]
                                            UNSPEC_FR_RECIP_APPROX))
-             (use (const_int 1))])
+             (use (const_int 0))])
    (cond_exec (ne (match_dup 5) (const_int 0))
      (parallel [(set (match_dup 3)
                     (minus:XF (match_dup 6)
   "TARGET_INLINE_SQRT"
 {
   rtx insn;
-  if (TARGET_INLINE_SQRT_LAT)
 #if 0
+  if (TARGET_INLINE_SQRT == INL_MIN_LAT)
     insn = gen_sqrtxf2_internal_lat (operands[0], operands[1]);
+  else
 #else
-    abort ();
+  gcc_assert (TARGET_INLINE_SQRT != INL_MIN_LAT);
 #endif
-  else
-    insn = gen_sqrtxf2_internal_thr (operands[0], operands[1]);
+  insn = gen_sqrtxf2_internal_thr (operands[0], operands[1]);
   emit_insn (insn);
   DONE;
 })
    (clobber (match_scratch:XF 6 "=&f"))
    ;; Register p6 in optimization guide.
    (clobber (match_scratch:BI 7 "=c"))]
-  "TARGET_INLINE_SQRT_THR"
+  "TARGET_INLINE_SQRT == INL_MAX_THR"
   "#"
   "&& reload_completed"
   [ ;; exponent of +1/2 in r2
        (rotate:SI (match_operand:SI 1 "gr_register_operand" "r")
                   (match_operand:SI 2 "shift_32bit_count_operand" "n")))]
   ""
-  "#"
-  "reload_completed"
+  "mux2 %0 = %1, 0xe1"
+  "reload_completed && INTVAL (operands[2]) != 16"
   [(set (match_dup 3)
        (ior:DI (zero_extend:DI (match_dup 1))
                (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
 {
   operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));
   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
-})
+}
+  [(set_attr "itanium_class" "mmshf")])
 \f
 ;; ::::::::::::::::::::
 ;; ::
                          (match_operand:DI 3 "nonmemory_operand" "r"))
                 (match_operand:DI 4 "nonmemory_operand" "rI")))]
   "reload_in_progress"
-  "* abort ();"
+  "* gcc_unreachable ();"
   "reload_completed"
   [(set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
                               (match_dup 3)))
 \f
 ;; ::::::::::::::::::::
 ;; ::
+;; :: 128 bit Integer Shifts and Rotates
+;; ::
+;; ::::::::::::::::::::
+
+(define_expand "ashlti3"
+  [(set (match_operand:TI 0 "gr_register_operand" "")
+       (ashift:TI (match_operand:TI 1 "gr_register_operand" "")
+                  (match_operand:DI 2 "nonmemory_operand" "")))]
+  ""
+{
+  if (!dshift_count_operand (operands[2], DImode))
+    FAIL;
+})
+
+(define_insn_and_split "*ashlti3_internal"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (ashift:TI (match_operand:TI 1 "gr_register_operand" "r")
+                  (match_operand:DI 2 "dshift_count_operand" "n")))]
+  ""
+  "#"
+  "reload_completed"
+  [(const_int 0)]
+{
+  HOST_WIDE_INT shift = INTVAL (operands[2]);
+  rtx rl = gen_lowpart (DImode, operands[0]);
+  rtx rh = gen_highpart (DImode, operands[0]);
+  rtx lo = gen_lowpart (DImode, operands[1]);
+  rtx shiftlo = GEN_INT (shift & 63);
+
+  if (shift & 64)
+    {
+      emit_move_insn (rl, const0_rtx);
+      if (shift & 63)
+       emit_insn (gen_ashldi3 (rh, lo, shiftlo));
+      else
+       emit_move_insn (rh, lo);
+    }
+  else
+    {
+      rtx hi = gen_highpart (DImode, operands[1]);
+
+      emit_insn (gen_shrp (rh, hi, lo, GEN_INT (-shift & 63)));
+      emit_insn (gen_ashldi3 (rl, lo, shiftlo));
+    }
+  DONE;
+})
+
+(define_expand "ashrti3"
+  [(set (match_operand:TI 0 "gr_register_operand" "")
+       (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
+                    (match_operand:DI 2 "nonmemory_operand" "")))]
+  ""
+{
+  if (!dshift_count_operand (operands[2], DImode))
+    FAIL;
+})
+
+(define_insn_and_split "*ashrti3_internal"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
+                    (match_operand:DI 2 "dshift_count_operand" "n")))]
+  ""
+  "#"
+  "reload_completed"
+  [(const_int 0)]
+{
+  HOST_WIDE_INT shift = INTVAL (operands[2]);
+  rtx rl = gen_lowpart (DImode, operands[0]);
+  rtx rh = gen_highpart (DImode, operands[0]);
+  rtx hi = gen_highpart (DImode, operands[1]);
+  rtx shiftlo = GEN_INT (shift & 63);
+
+  if (shift & 64)
+    {
+      if (shift & 63)
+       emit_insn (gen_ashrdi3 (rl, hi, shiftlo));
+      else
+       emit_move_insn (rl, hi);
+      emit_insn (gen_ashrdi3 (rh, hi, GEN_INT (63)));
+    }
+  else
+    {
+      rtx lo = gen_lowpart (DImode, operands[1]);
+
+      emit_insn (gen_shrp (rl, hi, lo, shiftlo));
+      emit_insn (gen_ashrdi3 (rh, hi, shiftlo));
+    }
+  DONE;
+})
+
+(define_expand "lshrti3"
+  [(set (match_operand:TI 0 "gr_register_operand" "")
+        (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
+                     (match_operand:DI 2 "nonmemory_operand" "")))]
+  ""
+{ 
+  if (!dshift_count_operand (operands[2], DImode))
+    FAIL;
+}) 
+
+(define_insn_and_split "*lshrti3_internal"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
+                    (match_operand:DI 2 "dshift_count_operand" "n")))]
+  ""
+  "#"
+  "reload_completed"
+  [(const_int 0)]
+{
+  HOST_WIDE_INT shift = INTVAL (operands[2]);
+  rtx rl = gen_lowpart (DImode, operands[0]);
+  rtx rh = gen_highpart (DImode, operands[0]);
+  rtx hi = gen_highpart (DImode, operands[1]);
+  rtx shiftlo = GEN_INT (shift & 63);
+
+  if (shift & 64)
+    {
+      if (shift & 63)
+       emit_insn (gen_lshrdi3 (rl, hi, shiftlo));
+      else
+       emit_move_insn (rl, hi);
+      emit_move_insn (rh, const0_rtx);
+    }
+  else
+    {
+      rtx lo = gen_lowpart (DImode, operands[1]);
+
+      emit_insn (gen_shrp (rl, hi, lo, shiftlo));
+      emit_insn (gen_lshrdi3 (rh, hi, shiftlo));
+    }
+  DONE;
+})
+
+(define_expand "rotlti3"
+  [(set (match_operand:TI 0 "gr_register_operand" "")
+       (rotate:TI (match_operand:TI 1 "gr_register_operand" "")
+                  (match_operand:DI 2 "nonmemory_operand" "")))]
+  ""
+{
+  if (! dshift_count_operand (operands[2], DImode))
+    FAIL;
+})
+
+(define_insn_and_split "*rotlti3_internal"
+  [(set (match_operand:TI 0 "gr_register_operand" "=&r")
+       (rotate:TI (match_operand:TI 1 "gr_register_operand" "r")
+                  (match_operand:DI 2 "dshift_count_operand" "n")))]
+  ""
+  "#"
+  "reload_completed"
+  [(const_int 0)]
+{
+  HOST_WIDE_INT count = INTVAL (operands[2]);
+  rtx rl = gen_lowpart (DImode, operands[0]);
+  rtx rh = gen_highpart (DImode, operands[0]);
+  rtx lo = gen_lowpart (DImode, operands[1]);
+  rtx hi = gen_highpart (DImode, operands[1]);
+  rtx countlo = GEN_INT (-count & 63);
+
+  if (count & 64)
+    {
+      if (count & 63)
+       {
+         emit_insn (gen_shrp (rl, hi, lo, countlo));
+         emit_insn (gen_shrp (rh, lo, hi, countlo));
+       }
+      else
+       {
+         emit_move_insn (rl, hi);
+         emit_move_insn (rh, lo);
+       }
+    }
+  else
+    {
+      emit_insn (gen_shrp (rl, lo, hi, countlo));
+      emit_insn (gen_shrp (rh, hi, lo, countlo));
+    }
+  DONE;
+}
+  [(set_attr "itanium_class" "unknown")])
+
+(define_insn "shrp"
+  [(set (match_operand:DI 0 "gr_register_operand" "=r")
+       (unspec:DI [(match_operand:DI 1 "gr_register_operand" "r")
+                   (match_operand:DI 2 "gr_register_operand" "r")
+                   (match_operand:DI 3 "shift_count_operand" "M")]
+                  UNSPEC_SHRP))]
+  ""
+  "shrp %0 = %1, %2, %3"
+  [(set_attr "itanium_class" "ishf")])
+\f
+;; ::::::::::::::::::::
+;; ::
 ;; :: 32 bit Integer Logical operations
 ;; ::
 ;; ::::::::::::::::::::
           "rim,rim,rim, rim, *f, *b,*d*e,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")))]
   "ia64_move_ok (operands[0], operands[2])
    && ia64_move_ok (operands[0], operands[3])"
-  { abort (); }
+  { gcc_unreachable (); }
   [(set_attr "predicable" "no")])
 
 (define_split
                    "rim*f,rO,rO,0,0,0,rim*f,rO,rO")))]
   "ia64_move_ok (operands[0], operands[2])
    && ia64_move_ok (operands[0], operands[3])"
-  { abort (); }
+  { gcc_unreachable (); }
   [(set_attr "predicable" "no")])
 
 (define_insn "*abssi2_internal"
   [(set_attr "itanium_class" "br,scall")])
 
 (define_insn "call_value_nogp"
-  [(set (match_operand 0 "" "")
+  [(set (match_operand 0 "" "=X,X")
        (call (mem:DI (match_operand:DI 1 "call_operand" "?b,i"))
              (const_int 0)))
    (clobber (match_operand:DI 2 "register_operand" "=b,b"))]
 })
 
 (define_insn "call_value_gp"
-  [(set (match_operand 0 "" "")
+  [(set (match_operand 0 "" "=X,X")
        (call (mem:DI (match_operand:DI 1 "call_operand" "?r,i"))
              (const_int 1)))
    (clobber (match_operand:DI 2 "register_operand" "=b,b"))
       start_sequence ();
       set = single_set (last);
 
-      if (! rtx_equal_p (SET_DEST (set), op0)
-         || GET_CODE (SET_SRC (set)) != MEM)
-       abort ();
+      gcc_assert (rtx_equal_p (SET_DEST (set), op0)
+                 && GET_CODE (SET_SRC (set)) == MEM);
       addr = XEXP (SET_SRC (set), 0);
-      if (rtx_equal_p (addr, op0))
-       abort ();
+      gcc_assert (!rtx_equal_p (addr, op0));
     }
 
   /* Jump table elements are stored pc-relative.  That is, a displacement
   ""
   ""
   [(set_attr "itanium_class" "ignore")
-   (set_attr "predicable" "no")])
+   (set_attr "predicable" "no")
+   (set_attr "empty" "yes")])
 
 ;; Allocate a new register frame.
 
   ""
   "alloc %0 = ar.pfs, %1, %2, %3, %4"
   [(set_attr "itanium_class" "syst_m0")
-   (set_attr "predicable" "no")])
+   (set_attr "predicable" "no")
+   (set_attr "first_insn" "yes")])
 
 ;; Modifies ar.unat
 (define_expand "gr_spill"
   "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
 
 (define_insn "gr_spill_internal"
-  [(set (match_operand:DI 0 "memory_operand" "=m")
+  [(set (match_operand:DI 0 "destination_operand" "=m")
        (unspec:DI [(match_operand:DI 1 "register_operand" "r")
                    (match_operand:DI 2 "const_int_operand" "")]
                   UNSPEC_GR_SPILL))
   [(set_attr "itanium_class" "ld")])
 
 (define_insn "fr_spill"
-  [(set (match_operand:XF 0 "memory_operand" "=m")
+  [(set (match_operand:XF 0 "destination_operand" "=m")
        (unspec:XF [(match_operand:XF 1 "register_operand" "f")]
                   UNSPEC_FR_SPILL))]
   ""
   [(const_int 5)]
   ""
   ""
-  [(set_attr "itanium_class" "nop_x")])
+  [(set_attr "itanium_class" "nop_x")
+   (set_attr "empty" "yes")])
 
 ;; The following insn will be never generated.  It is used only by
 ;; insn scheduler to change state before advancing cycle.
   ""
   ";;"
   [(set_attr "itanium_class" "stop_bit")
-   (set_attr "predicable" "no")])
+   (set_attr "predicable" "no")
+   (set_attr "empty" "yes")])
 
 (define_expand "trap"
   [(trap_if (const_int 1) (const_int 0))]
   int i = (INTVAL (operands[1]));
   int j = (INTVAL (operands[2]));
 
-  if (i != 0 && i != 1)
-    abort ();
-  if (j < 0 || j > 3)
-    abort ();
+  gcc_assert (i == 0 || i == 1);
+  gcc_assert (j >= 0 && j <= 3);
   return alt[i][j];
 }
   [(set_attr "itanium_class" "lfetch")])
 })
 
 \f
-;;; Intrinsics support.
-
-(define_expand "mf"
-  [(set (mem:BLK (match_dup 0))
-       (unspec:BLK [(mem:BLK (match_dup 0))] UNSPEC_MF))]
-  ""
-{
-  operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (DImode));
-  MEM_VOLATILE_P (operands[0]) = 1;
-})
-
-(define_insn "*mf_internal"
-  [(set (match_operand:BLK 0 "" "")
-       (unspec:BLK [(match_operand:BLK 1 "" "")] UNSPEC_MF))]
-  ""
-  "mf"
-  [(set_attr "itanium_class" "syst_m")])
-
-(define_insn "fetchadd_acq_si"
-  [(set (match_operand:SI 0 "gr_register_operand" "=r")
-       (match_operand:SI 1 "not_postinc_memory_operand" "+S"))
-   (set (match_dup 1)
-       (unspec:SI [(match_dup 1)
-                   (match_operand:SI 2 "fetchadd_operand" "n")]
-                  UNSPEC_FETCHADD_ACQ))]
-  ""
-  "fetchadd4.acq %0 = %1, %2"
-  [(set_attr "itanium_class" "sem")])
-
-(define_insn "fetchadd_acq_di"
-  [(set (match_operand:DI 0 "gr_register_operand" "=r")
-       (match_operand:DI 1 "not_postinc_memory_operand" "+S"))
-   (set (match_dup 1)
-       (unspec:DI [(match_dup 1)
-                   (match_operand:DI 2 "fetchadd_operand" "n")]
-                  UNSPEC_FETCHADD_ACQ))]
-  ""
-  "fetchadd8.acq %0 = %1, %2"
-  [(set_attr "itanium_class" "sem")])
-
-(define_insn "cmpxchg_acq_si"
-  [(set (match_operand:SI 0 "gr_register_operand" "=r")
-       (match_operand:SI 1 "not_postinc_memory_operand" "+S"))
-   (set (match_dup 1)
-        (unspec:SI [(match_dup 1)
-                    (match_operand:SI 2 "gr_register_operand" "r")
-                   (match_operand:DI 3 "ar_ccv_reg_operand" "")]
-                  UNSPEC_CMPXCHG_ACQ))]
-  ""
-  "cmpxchg4.acq %0 = %1, %2, %3"
-  [(set_attr "itanium_class" "sem")])
-
-(define_insn "cmpxchg_acq_di"
-  [(set (match_operand:DI 0 "gr_register_operand" "=r")
-       (match_operand:DI 1 "not_postinc_memory_operand" "+S"))
-   (set (match_dup 1)
-        (unspec:DI [(match_dup 1)
-                    (match_operand:DI 2 "gr_register_operand" "r")
-                   (match_operand:DI 3 "ar_ccv_reg_operand" "")]
-                  UNSPEC_CMPXCHG_ACQ))]
-  ""
-  "cmpxchg8.acq %0 = %1, %2, %3"
-  [(set_attr "itanium_class" "sem")])
-
-(define_insn "xchgsi"
-  [(set (match_operand:SI 0 "gr_register_operand" "=r")
-        (match_operand:SI 1 "not_postinc_memory_operand" "+S"))
-   (set (match_dup 1)
-        (match_operand:SI 2 "gr_register_operand" "r"))]
-  ""
-  "xchg4 %0 = %1, %2"
-  [(set_attr "itanium_class" "sem")])
-
-(define_insn "xchgdi"
-  [(set (match_operand:DI 0 "gr_register_operand" "=r")
-        (match_operand:DI 1 "not_postinc_memory_operand" "+S"))
-   (set (match_dup 1)
-        (match_operand:DI 2 "gr_register_operand" "r"))]
-  ""
-  "xchg8 %0 = %1, %2"
-  [(set_attr "itanium_class" "sem")])
-\f
 ;; Predication.
 
 (define_cond_exec
   "addp4_optimize_ok (operands[1], operands[2])"
   "addp4 %0 = %1, %2"
   [(set_attr "itanium_class" "ialu")])
+
+;;
+;; Get instruction pointer
+
+(define_insn "ip_value"
+  [(set (match_operand:DI 0 "register_operand" "=r")
+        (pc))]
+ ""
+ "mov %0 = ip"
+  [(set_attr "itanium_class" "ialu")])
+
+;; Vector operations
+(include "vect.md")
+;; Atomic operations
+(include "sync.md")