OSDN Git Service

* config/s390/s390.c (s390_adjust_cost): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / config / s390 / s390.md
index 1a53e71..d7f0e07 100644 (file)
 })
 
 
-; Test-under-Mask (zero_extract) instructions
-
-(define_insn "*tmdi_ext"
-  [(set (reg 33)
-        (compare (zero_extract:DI (match_operand:DI 0 "register_operand" "d")
-                                 (match_operand:DI 1 "const_int_operand" "n")
-                                  (match_operand:DI 2 "const_int_operand" "n"))
-                 (const_int 0)))]
-  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
-   && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
-   && INTVAL (operands[1]) + INTVAL (operands[2]) <= 64
-   && (INTVAL (operands[1]) + INTVAL (operands[2]) - 1) >> 4
-      == INTVAL (operands[2]) >> 4"
-{
-  int part = INTVAL (operands[2]) >> 4;
-  int block = (1 << INTVAL (operands[1])) - 1;
-  int shift = 16 - INTVAL (operands[1]) - (INTVAL (operands[2]) & 15);
-
-  operands[2] = GEN_INT (block << shift);
-
-  switch (part)
-    {
-      case 0: return "tmhh\t%0,%x2";
-      case 1: return "tmhl\t%0,%x2";
-      case 2: return "tmlh\t%0,%x2";
-      case 3: return "tmll\t%0,%x2";
-      default: abort ();
-    }
-}
-  [(set_attr "op_type" "RI")])
-
-(define_insn "*tmsi_ext"
-  [(set (reg 33)
-        (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
-                                 (match_operand:SI 1 "const_int_operand" "n")
-                                  (match_operand:SI 2 "const_int_operand" "n"))
-                 (const_int 0)))]
-  "s390_match_ccmode(insn, CCTmode)
-   && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
-   && INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
-   && (INTVAL (operands[1]) + INTVAL (operands[2]) - 1) >> 4
-      == INTVAL (operands[2]) >> 4"
-{
-  int part = INTVAL (operands[2]) >> 4;
-  int block = (1 << INTVAL (operands[1])) - 1;
-  int shift = 16 - INTVAL (operands[1]) - (INTVAL (operands[2]) & 15);
-
-  operands[2] = GEN_INT (block << shift);
-
-  switch (part)
-    {
-      case 0: return "tmh\t%0,%x2";
-      case 1: return "tml\t%0,%x2";
-      default: abort ();
-    }
-}
-  [(set_attr "op_type" "RI")])
-
-(define_insn "*tmqisi_ext"
-  [(set (reg 33)
-        (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "Q,S")
-                                 (match_operand:SI 1 "const_int_operand" "n,n")
-                                  (match_operand:SI 2 "const_int_operand" "n,n"))
-                 (const_int 0)))]
-  "!TARGET_64BIT && s390_match_ccmode(insn, CCTmode)
-   && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
-   && INTVAL (operands[1]) + INTVAL (operands[2]) <= 8"
-{
-  int block = (1 << INTVAL (operands[1])) - 1;
-  int shift = 8 - INTVAL (operands[1]) - INTVAL (operands[2]);
-
-  operands[2] = GEN_INT (block << shift);
-  return which_alternative == 0 ? "tm\t%0,%b2" : "tmy\t%0,%b2";
-}
-  [(set_attr "op_type" "SI,SIY")])
-
-(define_insn "*tmqidi_ext"
-  [(set (reg 33)
-        (compare (zero_extract:DI (match_operand:QI 0 "memory_operand" "Q,S")
-                                 (match_operand:SI 1 "const_int_operand" "n,n")
-                                  (match_operand:SI 2 "const_int_operand" "n,n"))
-                 (const_int 0)))]
-  "TARGET_64BIT && s390_match_ccmode(insn, CCTmode)
-   && INTVAL (operands[1]) >= 1 && INTVAL (operands[2]) >= 0
-   && INTVAL (operands[1]) + INTVAL (operands[2]) <= 8"
-{
-  int block = (1 << INTVAL (operands[1])) - 1;
-  int shift = 8 - INTVAL (operands[1]) - INTVAL (operands[2]);
-
-  operands[2] = GEN_INT (block << shift);
-  return which_alternative == 0 ? "tm\t%0,%b2" : "tmy\t%0,%b2";
-}
-  [(set_attr "op_type" "SI,SIY")])
-
-
 ; Test-under-Mask instructions
 
-(define_insn "*tmdi_mem"
-  [(set (reg 33)
-        (compare (and:DI (match_operand:DI 0 "memory_operand" "Q,S")
-                         (match_operand:DI 1 "immediate_operand" "n,n"))
-                 (match_operand:DI 2 "immediate_operand" "n,n")))]
-  "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))
-   && s390_single_part (operands[1], DImode, QImode, 0) >= 0"
-{
-  int part = s390_single_part (operands[1], DImode, QImode, 0);
-  operands[1] = GEN_INT (s390_extract_part (operands[1], QImode, 0));
-
-  operands[0] = gen_rtx_MEM (QImode,
-                            plus_constant (XEXP (operands[0], 0), part));
-  return which_alternative == 0 ? "tm\t%0,%b1" : "tmy\t%0,%b1";
-}
-  [(set_attr "op_type" "SI,SIY")])
-
-(define_insn "*tmsi_mem"
-  [(set (reg 33)
-        (compare (and:SI (match_operand:SI 0 "memory_operand" "Q,S")
-                         (match_operand:SI 1 "immediate_operand" "n,n"))
-                 (match_operand:SI 2 "immediate_operand" "n,n")))]
-  "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))
-   && s390_single_part (operands[1], SImode, QImode, 0) >= 0"
-{
-  int part = s390_single_part (operands[1], SImode, QImode, 0);
-  operands[1] = GEN_INT (s390_extract_part (operands[1], QImode, 0));
-
-  operands[0] = gen_rtx_MEM (QImode,
-                            plus_constant (XEXP (operands[0], 0), part));
-  return which_alternative == 0 ? "tm\t%0,%b1" : "tmy\t%0,%b1";
-}
-  [(set_attr "op_type" "SI")])
-
-(define_insn "*tmhi_mem"
-  [(set (reg 33)
-        (compare (and:SI (subreg:SI (match_operand:HI 0 "memory_operand" "Q,S") 0)
-                         (match_operand:SI 1 "immediate_operand" "n,n"))
-                 (match_operand:SI 2 "immediate_operand" "n,n")))]
-  "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))
-   && s390_single_part (operands[1], HImode, QImode, 0) >= 0"
-{
-  int part = s390_single_part (operands[1], HImode, QImode, 0);
-  operands[1] = GEN_INT (s390_extract_part (operands[1], QImode, 0));
-
-  operands[0] = gen_rtx_MEM (QImode,
-                            plus_constant (XEXP (operands[0], 0), part));
-  return which_alternative == 0 ? "tm\t%0,%b1" : "tmy\t%0,%b1";
-}
-  [(set_attr "op_type" "SI")])
-
 (define_insn "*tmqi_mem"
   [(set (reg 33)
-        (compare (and:SI (subreg:SI (match_operand:QI 0 "memory_operand" "Q,S") 0)
-                         (match_operand:SI 1 "immediate_operand" "n,n"))
-                 (match_operand:SI 2 "immediate_operand" "n,n")))]
+        (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
+                         (match_operand:QI 1 "immediate_operand" "n,n"))
+                 (match_operand:QI 2 "immediate_operand" "n,n")))]
   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))"
   "@
    tm\t%0,%b1
           (match_operand:QI 1 "address_operand" ""))
      (clobber (reg:CC 33))])]
   "TARGET_64BIT
-   && strict_memory_address_p (VOIDmode, operands[1])
-   && preferred_la_operand_p (operands[1])"
+   && preferred_la_operand_p (operands[1], const0_rtx)"
   [(set (match_dup 0) (match_dup 1))]
   "")
 
      (clobber (reg:CC 33))])]
   "TARGET_64BIT
    && !reg_overlap_mentioned_p (operands[0], operands[2])
-   && strict_memory_address_p (VOIDmode, gen_rtx_PLUS (DImode, operands[1], operands[2]))
-   && preferred_la_operand_p (gen_rtx_PLUS (DImode, operands[1], operands[2]))"
+   && preferred_la_operand_p (operands[1], operands[2])"
   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
   "")
 
           (match_operand:QI 1 "address_operand" ""))
      (clobber (reg:CC 33))])]
   "!TARGET_64BIT
-   && strict_memory_address_p (VOIDmode, operands[1])
-   && preferred_la_operand_p (operands[1])"
+   && preferred_la_operand_p (operands[1], const0_rtx)"
   [(set (match_dup 0) (match_dup 1))]
   "")
 
      (clobber (reg:CC 33))])]
   "!TARGET_64BIT
    && !reg_overlap_mentioned_p (operands[0], operands[2])
-   && strict_memory_address_p (VOIDmode, gen_rtx_PLUS (SImode, operands[1], operands[2]))
-   && preferred_la_operand_p (gen_rtx_PLUS (SImode, operands[1], operands[2]))"
+   && preferred_la_operand_p (operands[1], operands[2])"
   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
   "")
 
        }
       else
        FAIL;
-
-      if (from == frame_pointer_rtx || from == arg_pointer_rtx)
-       FAIL;
     }
   else
     {
        }
       else
        FAIL;
-
-      if (to == frame_pointer_rtx || to == arg_pointer_rtx)
-       FAIL;
     }
   else
     {
       emit_move_insn (operands[0], const0_rtx);
       emit_insn (gen_cmpsi (operands[2], operands[1]));
       emit_jump_insn (gen_bgtu (label3));
-      emit_insn (gen_cmpsi (operands[2], const1_rtx));
+      emit_insn (gen_cmpsi (operands[2], const0_rtx));
       emit_jump_insn (gen_blt (label2));
       emit_insn (gen_cmpsi (operands[2], const1_rtx));
       emit_jump_insn (gen_beq (label1));
       emit_move_insn(operands[0], operands[1]);
       emit_insn (gen_cmpsi (operands[2], operands[1]));
       emit_jump_insn (gen_bgtu (label3));
-      emit_insn (gen_cmpsi (operands[2], const1_rtx));
+      emit_insn (gen_cmpsi (operands[2], const0_rtx));
       emit_jump_insn (gen_blt (label2));
       emit_insn (gen_cmpsi (operands[2], const1_rtx));
       emit_jump_insn (gen_beq (label1));
                          (match_operand:DI 2 "general_operand" "d,m"))
                  (const_int 0)))
    (clobber (match_scratch:DI 0 "=d,d"))]
-  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
+  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
+   /* Do not steal TM patterns.  */
+   && s390_single_part (operands[2], DImode, HImode, 0) < 0"
   "@
    ngr\t%0,%2
    ng\t%0,%2"
                          (match_operand:SI 2 "general_operand" "d,R,T"))
                  (const_int 0)))
    (clobber (match_scratch:SI 0 "=d,d,d"))]
-  "s390_match_ccmode(insn, CCTmode)"
+  "s390_match_ccmode(insn, CCTmode)
+   /* Do not steal TM patterns.  */
+   && s390_single_part (operands[2], SImode, HImode, 0) < 0"
   "@
    nr\t%0,%2
    n\t%0,%2
 
    emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
 
-   index = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, base, index));
-   RTX_UNCHANGING_P (index) = 1;
-   MEM_NOTRAP_P (index) = 1;
+   index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
    emit_move_insn (target, index);
 
    if (flag_pic)
 ;
 
 (define_expand "allocate_stack"
-  [(set (reg 15)
-        (plus (reg 15) (match_operand 1 "general_operand" "")))
-   (set (match_operand 0 "general_operand" "")
-        (reg 15))]
- "TARGET_BACKCHAIN"
+  [(match_operand 0 "general_operand" "")
+   (match_operand 1 "general_operand" "")]
+ "TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN"
 {
-    rtx stack = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
-    rtx chain = gen_rtx_MEM (Pmode, stack);
-    rtx temp = gen_reg_rtx (Pmode);
-
-    emit_move_insn (temp, chain);
-
-    if (TARGET_64BIT)
-      emit_insn (gen_adddi3 (stack, stack, negate_rtx (Pmode, operands[1])));
-    else
-      emit_insn (gen_addsi3 (stack, stack, negate_rtx (Pmode, operands[1])));
+  rtx temp = gen_reg_rtx (Pmode);
 
-    emit_move_insn (chain, temp);
+  emit_move_insn (temp, s390_back_chain_rtx ());
+  anti_adjust_stack (operands[1]);
+  emit_move_insn (s390_back_chain_rtx (), temp);
 
-    emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
-    DONE;
+  emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
+  DONE;
 })
 
 
   "DONE;")
 
 (define_expand "restore_stack_block"
-  [(use (match_operand 0 "register_operand" ""))
-   (set (match_dup 2) (match_dup 3))
-   (set (match_dup 0) (match_operand 1 "register_operand" ""))
-   (set (match_dup 3) (match_dup 2))]
-  ""
+  [(match_operand 0 "register_operand" "")
+   (match_operand 1 "register_operand" "")]
+  "TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN"
 {
-  operands[2] = gen_reg_rtx (Pmode);
-  operands[3] = gen_rtx_MEM (Pmode, operands[0]);
+  rtx temp = gen_reg_rtx (Pmode);
+
+  emit_move_insn (temp, s390_back_chain_rtx ());
+  emit_move_insn (operands[0], operands[1]);
+  emit_move_insn (s390_back_chain_rtx (), temp);
+
+  DONE;
 })
 
 (define_expand "save_stack_nonlocal"
    (match_operand 1 "register_operand" "")]
   ""
 {
-  rtx temp = gen_reg_rtx (Pmode);
+  enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
+  rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
+
+  /* Copy the backchain to the first word, sp to the second and the
+     literal pool base to the third.  */
+
+  if (TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN)
+    {
+      rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
+      emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
+    }
+
+  emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
+  emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
 
-  /* Copy the backchain to the first word, sp to the second and the literal pool
-     base to the third.  */
-  emit_move_insn (operand_subword (operands[0], 2, 0,
-                  TARGET_64BIT ? OImode : TImode),
-                  gen_rtx_REG (Pmode, BASE_REGISTER));
-  emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
-  emit_move_insn (operand_subword (operands[0], 0, 0,
-                 TARGET_64BIT ? OImode : TImode),
-                 temp);
-  emit_move_insn (operand_subword (operands[0], 1, 0,
-                 TARGET_64BIT ? OImode : TImode),
-                 operands[1]);
   DONE;
 })
 
    (match_operand 1 "memory_operand" "")]
   ""
 {
-  rtx temp = gen_reg_rtx (Pmode);
-  rtx base = gen_rtx_REG (Pmode, BASE_REGISTER);
+  enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
+  rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
+  rtx temp = NULL_RTX;
 
   /* Restore the backchain from the first word, sp from the second and the
      literal pool base from the third.  */
-  emit_move_insn (temp,
-                 operand_subword (operands[1], 0, 0,
-                 TARGET_64BIT ? OImode : TImode));
-  emit_move_insn (operands[0],
-                 operand_subword (operands[1], 1, 0,
-                 TARGET_64BIT ? OImode : TImode));
-  emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
-  emit_move_insn (base,
-                  operand_subword (operands[1], 2, 0,
-                  TARGET_64BIT ? OImode : TImode));
-  emit_insn (gen_rtx_USE (VOIDmode, base));
 
+  if (TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN)
+    temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
+    
+  emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
+  emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
+
+  if (temp)
+    emit_move_insn (s390_back_chain_rtx (), temp);
+
+  emit_insn (gen_rtx_USE (VOIDmode, base));
   DONE;
 })
 
         (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
   "GET_MODE (operands[0]) == Pmode"
   "* abort ();"
-  [(set_attr "op_type" "NN")])
+  [(set_attr "op_type" "NN")
+   (set (attr "type") 
+        (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
+                      (const_string "larl") (const_string "la")))])
 
 (define_insn "reload_base_31"
   [(set (match_operand 0 "register_operand" "=a")
                         GEN_INT (0x7fffffff)));
   DONE;
 })
+
+;; Instruction definition to expand eh_return macro to support
+;; swapping in special linkage return addresses.
+
+(define_expand "eh_return"
+  [(use (match_operand 0 "register_operand" ""))]
+  "TARGET_TPF"
+{
+  s390_emit_tpf_eh_return (operands[0]);
+  DONE;
+})
+