mips.md (define_attr sync_*): Move before "type".
authorMaxim Kuvyrkov <maxim@codesourcery.com>
Sat, 21 Jul 2012 00:01:40 +0000 (00:01 +0000)
committerMaxim Kuvyrkov <mkuvyrkov@gcc.gnu.org>
Sat, 21 Jul 2012 00:01:40 +0000 (00:01 +0000)
* config/mips/mips.md (define_attr sync_*): Move before "type".
(define_attr "type"): New values "atomic" and "syncloop".
* config/mips/sync.md (atomic_exchange<mode>, atomic_fetch_add<mode>):
Set "type" attribute.
* config/mips/generic.md (generic_atomic, generic_syncloop):
New reservations.
* gcc/config/mips/10000.md, gcc/config/mips/20kc.md,
* gcc/config/mips/24k.md, gcc/config/mips/4130.md,
        * gcc/config/mips/4k.md, gcc/config/mips/5400.md,
* gcc/config/mips/5500.md, gcc/config/mips/5k.md,
        * gcc/config/mips/7000.md, gcc/config/mips/74k.md,
* gcc/config/mips/9000.md, gcc/config/mips/loongson2ef.md,
* gcc/config/mips/loongson3a.md, gcc/config/mips/octeon.md,
* gcc/config/mips/sb1.md, gcc/config/mips/sr71k.md,
* gcc/config/mips/xlr.md: Handle "atomic" and "syncloop" types.

From-SVN: r189734

21 files changed:
gcc/ChangeLog
gcc/config/mips/10000.md
gcc/config/mips/20kc.md
gcc/config/mips/24k.md
gcc/config/mips/4130.md
gcc/config/mips/4k.md
gcc/config/mips/5400.md
gcc/config/mips/5500.md
gcc/config/mips/5k.md
gcc/config/mips/7000.md
gcc/config/mips/74k.md
gcc/config/mips/9000.md
gcc/config/mips/generic.md
gcc/config/mips/loongson2ef.md
gcc/config/mips/loongson3a.md
gcc/config/mips/mips.md
gcc/config/mips/octeon.md
gcc/config/mips/sb1.md
gcc/config/mips/sr71k.md
gcc/config/mips/sync.md
gcc/config/mips/xlr.md

index 5b8b210..34c9ac6 100644 (file)
@@ -1,3 +1,21 @@
+2012-07-20  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       * config/mips/mips.md (define_attr sync_*): Move before "type".
+       (define_attr "type"): New values "atomic" and "syncloop".
+       * config/mips/sync.md (atomic_exchange<mode>, atomic_fetch_add<mode>):
+       Set "type" attribute.
+       * config/mips/generic.md (generic_atomic, generic_syncloop):
+       New reservations.
+       * gcc/config/mips/10000.md, gcc/config/mips/20kc.md,
+       * gcc/config/mips/24k.md, gcc/config/mips/4130.md,
+        * gcc/config/mips/4k.md, gcc/config/mips/5400.md,
+       * gcc/config/mips/5500.md, gcc/config/mips/5k.md,
+        * gcc/config/mips/7000.md, gcc/config/mips/74k.md,
+       * gcc/config/mips/9000.md, gcc/config/mips/loongson2ef.md,
+       * gcc/config/mips/loongson3a.md, gcc/config/mips/octeon.md,
+       * gcc/config/mips/sb1.md, gcc/config/mips/sr71k.md,
+       * gcc/config/mips/xlr.md: Handle "atomic" and "syncloop" types.
+
 2012-07-20  Oleg Endo  <olegendo@gcc.gnu.org>
 
        * config/sh/sh.md: Group and sort shift related patterns.
index 589cd1b..ae376b0 100644 (file)
 ;; Handle unknown/multi insns here (this is a guess).
 (define_insn_reservation "r10k_unknown" 1
   (and (eq_attr "cpu" "r10000")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "r10k_alu1 + r10k_alu2")
index 6581f5d..5c0088c 100644 (file)
 ;; Force single-dispatch for unknown or multi.
 (define_insn_reservation "r20kc_unknown" 1 
                         (and (eq_attr "cpu" "20kc")
-                             (eq_attr "type" "unknown,multi"))
+                             (eq_attr "type" "unknown,multi,atomic,syncloop"))
                         "r20kc_single_dispatch")
index 1d701e7..bc4b45b 100644 (file)
 ;;    scheduling via log links, but not used here).
 (define_insn_reservation "r24k_int_unknown" 0
   (and (eq_attr "cpu" "24kc,24kf2_1,24kf1_1")
-       (eq_attr "type" "unknown"))
+       (eq_attr "type" "unknown,atomic,syncloop"))
   "r24k_iss")
 
 
index da9ff7e..fd1001f 100644 (file)
@@ -78,7 +78,7 @@
 
 (define_insn_reservation "vr4130_multi" 1
   (and (eq_attr "cpu" "r4130")
-       (eq_attr "type" "multi,unknown"))
+       (eq_attr "type" "multi,unknown,atomic,syncloop"))
   "vr4130_alu1 + vr4130_alu2 + vr4130_dcache + vr4130_muldiv")
 
 (define_insn_reservation "vr4130_int" 1
index 2494c63..3733047 100644 (file)
 ;; Unknown or multi - single issue
 (define_insn_reservation "r4k_unknown" 1
   (and (eq_attr "cpu" "4kc,4kp")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "r4k_ixu_arith+r4k_ixu_mpydiv")
index 40e7e36..f85a311 100644 (file)
@@ -33,7 +33,7 @@
 
 (define_insn_reservation "ir_vr54_unknown" 1
   (and (eq_attr "cpu" "r5400")
-       (eq_attr "type" "unknown"))
+       (eq_attr "type" "unknown,atomic,syncloop"))
   "vr54_dp0+vr54_dp1+vr54_mem+vr54_mac")
 
 ;; Assume prediction fails.
index 6467fad..b254a9b 100644 (file)
@@ -35,7 +35,7 @@
 
 (define_insn_reservation "ir_vr55_unknown" 1
   (and (eq_attr "cpu" "r5500")
-       (eq_attr "type" "unknown"))
+       (eq_attr "type" "unknown,atomic,syncloop"))
   "vr55_dp0+vr55_dp1+vr55_mem+vr55_mac+vr55_fp+vr55_bru")
 
 ;; Assume prediction fails.
index 956d0e4..7a0689b 100644 (file)
 ;; Unknown or multi - single issue
 (define_insn_reservation "r5k_int_unknown" 1
   (and (eq_attr "cpu" "5kc,5kf")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "r5k_ixu_arith+r5k_ixu_mpydiv")
 
 
index b348f93..d7265f4 100644 (file)
 ;; Force single-dispatch for unknown or multi.
 (define_insn_reservation "rm7_unknown" 1
   (and (eq_attr "cpu" "r7000")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "rm7_single_dispatch")
index b643b65..cd0a76d 100644 (file)
 ;;
 (define_insn_reservation "r74k_unknown" 1 
   (and (eq_attr "cpu" "74kc,74kf2_1,74kf1_1,74kf3_2")
-       (eq_attr "type" "unknown"))
+       (eq_attr "type" "unknown,atomic,syncloop"))
   "r74k_alu")
 
 (define_insn_reservation "r74k_multi" 10
index 6712aeb..09f55b4 100644 (file)
 
 (define_insn_reservation "rm9k_unknown" 1
   (and (eq_attr "cpu" "r9000")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "rm9k_m + rm9k_f_int + rm9k_any1 + rm9k_any2")
index ffbe4eb..c197ecf 100644 (file)
 (define_insn_reservation "generic_frecip_fsqrt_step" 5
   (eq_attr "type" "frdiv1,frdiv2,frsqrt1,frsqrt2")
   "alu")
+
+(define_insn_reservation "generic_atomic" 10
+  (eq_attr "type" "atomic")
+  "alu")
+
+;; Sync loop consists of (in order)
+;; (1) optional sync,
+;; (2) LL instruction,
+;; (3) branch and 1-2 ALU instructions,
+;; (4) SC instruction,
+;; (5) branch and ALU instruction.
+;; The net result of this reservation is a big delay with a flush of
+;; ALU pipeline.
+(define_insn_reservation "generic_sync_loop" 40
+  (eq_attr "type" "syncloop")
+  "alu*39")
index 5b635c9..ef9dd38 100644 (file)
@@ -98,7 +98,7 @@
 ;; ls2_[f]alu{1,2}_turn_enabled units according to this attribute.
 ;; These instructions are used in mips.c: sched_ls2_dfa_post_advance_cycle.
 
-(define_attr "ls2_turn_type" "alu1,alu2,falu1,falu2,unknown"
+(define_attr "ls2_turn_type" "alu1,alu2,falu1,falu2,unknown,atomic,syncloop"
   (const_string "unknown"))
 
 ;; Subscribe ls2_alu1_turn_enabled.
index deaf10e..f1f8762 100644 (file)
 ;; Force single-dispatch for unknown or multi.
 (define_insn_reservation "ls3a_unknown" 1
   (and (eq_attr "cpu" "loongson_3a")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "ls3a_alu1 + ls3a_alu2 + ls3a_falu1 + ls3a_falu2 + ls3a_mem")
 
 ;; End of DFA-based pipeline description for loongson_3a
index 77bc009..b6b2beb 100644 (file)
         (const_string "yes")]
        (const_string "no")))
 
+;; Attributes describing a sync loop.  These loops have the form:
+;;
+;;       if (RELEASE_BARRIER == YES) sync
+;;    1: OLDVAL = *MEM
+;;       if ((OLDVAL & INCLUSIVE_MASK) != REQUIRED_OLDVAL) goto 2
+;;         CMP  = 0 [delay slot]
+;;       $TMP1 = OLDVAL & EXCLUSIVE_MASK
+;;       $TMP2 = INSN1 (OLDVAL, INSN1_OP2)
+;;       $TMP3 = INSN2 ($TMP2, INCLUSIVE_MASK)
+;;       $AT |= $TMP1 | $TMP3
+;;       if (!commit (*MEM = $AT)) goto 1.
+;;         if (INSN1 != MOVE && INSN1 != LI) NEWVAL = $TMP3 [delay slot]
+;;       CMP  = 1
+;;       if (ACQUIRE_BARRIER == YES) sync
+;;    2:
+;;
+;; where "$" values are temporaries and where the other values are
+;; specified by the attributes below.  Values are specified as operand
+;; numbers and insns are specified as enums.  If no operand number is
+;; specified, the following values are used instead:
+;;
+;;    - OLDVAL: $AT
+;;    - CMP: NONE
+;;    - NEWVAL: $AT
+;;    - INCLUSIVE_MASK: -1
+;;    - REQUIRED_OLDVAL: OLDVAL & INCLUSIVE_MASK
+;;    - EXCLUSIVE_MASK: 0
+;;
+;; MEM and INSN1_OP2 are required.
+;;
+;; Ideally, the operand attributes would be integers, with -1 meaning "none",
+;; but the gen* programs don't yet support that.
+(define_attr "sync_mem" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_oldval" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_cmp" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_newval" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_inclusive_mask" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_exclusive_mask" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_required_oldval" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_insn1_op2" "none,0,1,2,3,4,5" (const_string "none"))
+(define_attr "sync_insn1" "move,li,addu,addiu,subu,and,andi,or,ori,xor,xori"
+  (const_string "move"))
+(define_attr "sync_insn2" "nop,and,xor,not"
+  (const_string "nop"))
+;; Memory model specifier.
+;; "0"-"9" values specify the operand that stores the memory model value.
+;; "10" specifies MEMMODEL_ACQ_REL,
+;; "11" specifies MEMMODEL_ACQUIRE.
+(define_attr "sync_memmodel" "" (const_int 10))
+
+
 ;; Classification of each insn.
 ;; branch      conditional branch
 ;; jump                unconditional jump
 ;; frsqrt1      floating point reciprocal square root step1
 ;; frsqrt2      floating point reciprocal square root step2
 ;; multi       multiword sequence (or user asm statements)
+;; atomic      atomic memory update instruction
+;; syncloop    memory atomic operation implemented as a sync loop
 ;; nop         no operation
 ;; ghost       an instruction that produces no real code
 (define_attr "type"
    prefetch,prefetchx,condmove,mtc,mfc,mthi,mtlo,mfhi,mflo,const,arith,logical,
    shift,slt,signext,clz,pop,trap,imul,imul3,imul3nc,imadd,idiv,idiv3,move,
    fmove,fadd,fmul,fmadd,fdiv,frdiv,frdiv1,frdiv2,fabs,fneg,fcmp,fcvt,fsqrt,
-   frsqrt,frsqrt1,frsqrt2,multi,nop,ghost"
+   frsqrt,frsqrt1,frsqrt2,multi,atomic,syncloop,nop,ghost"
   (cond [(eq_attr "jal" "!unset") (const_string "call")
         (eq_attr "got" "load") (const_string "load")
 
              (eq_attr "dword_mode" "yes"))
           (const_string "multi")
         (eq_attr "move_type" "move") (const_string "move")
-        (eq_attr "move_type" "const") (const_string "const")]
+        (eq_attr "move_type" "const") (const_string "const")
+        (eq_attr "sync_mem" "!none") (const_string "syncloop")]
        ;; We classify "lui_movf" as "unknown" rather than "multi"
        ;; because we don't split it.  FIXME: we should split instead.
        (const_string "unknown")))
                (const_string "yes")
                (const_string "no")))
 
-;; Attributes describing a sync loop.  These loops have the form:
-;;
-;;       if (RELEASE_BARRIER == YES) sync
-;;    1: OLDVAL = *MEM
-;;       if ((OLDVAL & INCLUSIVE_MASK) != REQUIRED_OLDVAL) goto 2
-;;         CMP  = 0 [delay slot]
-;;       $TMP1 = OLDVAL & EXCLUSIVE_MASK
-;;       $TMP2 = INSN1 (OLDVAL, INSN1_OP2)
-;;       $TMP3 = INSN2 ($TMP2, INCLUSIVE_MASK)
-;;       $AT |= $TMP1 | $TMP3
-;;       if (!commit (*MEM = $AT)) goto 1.
-;;         if (INSN1 != MOVE && INSN1 != LI) NEWVAL = $TMP3 [delay slot]
-;;       CMP  = 1
-;;       if (ACQUIRE_BARRIER == YES) sync
-;;    2:
-;;
-;; where "$" values are temporaries and where the other values are
-;; specified by the attributes below.  Values are specified as operand
-;; numbers and insns are specified as enums.  If no operand number is
-;; specified, the following values are used instead:
-;;
-;;    - OLDVAL: $AT
-;;    - CMP: NONE
-;;    - NEWVAL: $AT
-;;    - INCLUSIVE_MASK: -1
-;;    - REQUIRED_OLDVAL: OLDVAL & INCLUSIVE_MASK
-;;    - EXCLUSIVE_MASK: 0
-;;
-;; MEM and INSN1_OP2 are required.
-;;
-;; Ideally, the operand attributes would be integers, with -1 meaning "none",
-;; but the gen* programs don't yet support that.
-(define_attr "sync_mem" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_oldval" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_cmp" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_newval" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_inclusive_mask" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_exclusive_mask" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_required_oldval" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_insn1_op2" "none,0,1,2,3,4,5" (const_string "none"))
-(define_attr "sync_insn1" "move,li,addu,addiu,subu,and,andi,or,ori,xor,xori"
-  (const_string "move"))
-(define_attr "sync_insn2" "nop,and,xor,not"
-  (const_string "nop"))
-;; Memory model specifier.
-;; "0"-"9" values specify the operand that stores the memory model value.
-;; "10" specifies MEMMODEL_ACQ_REL,
-;; "11" specifies MEMMODEL_ACQUIRE.
-(define_attr "sync_memmodel" "" (const_int 10))
-
 ;; Length of instruction in bytes.
 (define_attr "length" ""
    (cond [(and (eq_attr "extended_mips16" "yes")
index ff6b657..2a57881 100644 (file)
 
 (define_insn_reservation "octeon_unknown" 1
   (and (eq_attr "cpu" "octeon,octeon2")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "octeon_pipe0 + octeon_pipe1")
index f0df6f9..f4c4f03 100644 (file)
 
 (define_insn_reservation "ir_sb1_unknown" 1
   (and (eq_attr "cpu" "sb1,sb1a")
-       (eq_attr "type" "unknown,multi"))
+       (eq_attr "type" "unknown,multi,atomic,syncloop"))
   "sb1_ls0+sb1_ls1+sb1_ex0+sb1_ex1+sb1_fp0+sb1_fp1")
 
 ;; predicted taken branch causes 2 cycle ifetch bubble.  predicted not
index fb0c853..58013ca 100644 (file)
 
 (define_insn_reservation "ir_sr70_unknown" 1
   (and (eq_attr "cpu" "sr71000")
-       (eq_attr "type" "unknown"))
+       (eq_attr "type" "unknown,atomic,syncloop"))
   "serial_dispatch")
 
 
index 0a7905a..4c8dde9 100644 (file)
        (unspec_volatile:GPR [(match_operand:GPR 2 "register_operand" "0")]
         UNSPEC_ATOMIC_EXCHANGE))]
   "ISA_HAS_SWAP"
-  "swap<size>\t%0,%b1")
+  "swap<size>\t%0,%b1"
+  [(set_attr "type" "atomic")])
 
 (define_expand "atomic_fetch_add<mode>"
   [(match_operand:GPR 0 "register_operand")
                    (match_operand:GPR 2 "register_operand" "0"))]
         UNSPEC_ATOMIC_FETCH_OP))]
   "ISA_HAS_LDADD"
-  "ldadd<size>\t%0,%b1")
+  "ldadd<size>\t%0,%b1"
+  [(set_attr "type" "atomic")])
index e433d85..1420469 100644 (file)
@@ -31,7 +31,7 @@
 ;; Integer arithmetic instructions.
 (define_insn_reservation "ir_xlr_alu" 1
   (and (eq_attr "cpu" "xlr") 
-       (eq_attr "type" "move,arith,shift,clz,logical,signext,const,unknown,multi,nop,trap"))
+       (eq_attr "type" "move,arith,shift,clz,logical,signext,const,unknown,multi,nop,trap,atomic,syncloop"))
   "xlr_main_pipe")
 
 ;; Integer arithmetic instructions.