[NDS32] Add new instruction attribute: feature.
authorKito Cheng <kito.cheng@gmail.com>
Thu, 5 Apr 2018 01:43:05 +0000 (01:43 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Thu, 5 Apr 2018 01:43:05 +0000 (01:43 +0000)
gcc/
* config/nds32/nds32.md (feature): New attribute.

From-SVN: r259113

gcc/ChangeLog
gcc/config/nds32/nds32.md

index d07fe81..f8f4530 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-05  Kito Cheng  <kito.cheng@gmail.com>
+
+       * config/nds32/nds32.md (feature): New attribute.
+
 2018-04-05  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.md (subtype): New attribute.
index a216507..245a0c8 100644 (file)
   "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25"
   (const_string "1"))
 
+;; Insn in which feature set, it is used to enable/disable insn alternatives.
+;; v1  : Baseline Instructions
+;; v2  : Baseline Version 2 Instructions
+;; v3m : Baseline Version 3m Instructions
+;; v3  : Baseline Version 3 Instructions
+;; pe1 : Performance Extension Instructions
+;; pe2 : Performance Extension Version 2 Instructions
+;; se  : String Extension instructions
+(define_attr "feature"
+  "v1,v2,v3m,v3,pe1,pe2,se"
+  (const_string "v1"))
+
 ;; Enabled, which is used to enable/disable insn alternatives.
 ;; Note that we use length and TARGET_16_BIT here as criteria.
-;; If the instruction pattern already check TARGET_16_BIT to
-;; determine the length by itself, its enabled attribute should be
-;; always 1 to avoid the conflict with the settings here.
+;; If the instruction pattern already check TARGET_16_BIT to determine
+;; the length by itself, its enabled attribute should be customized to
+;; avoid the conflict between length attribute and this default setting.
 (define_attr "enabled" "no,yes"
-  (cond [(and (eq_attr "length" "2")
-             (match_test "!TARGET_16_BIT"))
-        (const_string "no")]
-       (const_string "yes")))
+  (if_then_else
+    (and (eq_attr "length" "2")
+        (match_test "!TARGET_16_BIT"))
+    (const_string "no")
+    (cond [(eq_attr "feature" "v1")   (const_string "yes")
+          (eq_attr "feature" "v2")   (if_then_else (match_test "TARGET_ISA_V2 || TARGET_ISA_V3 || TARGET_ISA_V3M")
+                                                   (const_string "yes")
+                                                   (const_string "no"))
+          (eq_attr "feature" "v3")   (if_then_else (match_test "TARGET_ISA_V3")
+                                                   (const_string "yes")
+                                                   (const_string "no"))
+          (eq_attr "feature" "v3m")  (if_then_else (match_test "TARGET_ISA_V3 || TARGET_ISA_V3M")
+                                                   (const_string "yes")
+                                                   (const_string "no"))
+          (eq_attr "feature" "pe1")  (if_then_else (match_test "TARGET_EXT_PERF")
+                                                   (const_string "yes")
+                                                   (const_string "no"))
+          (eq_attr "feature" "pe2")  (if_then_else (match_test "TARGET_EXT_PERF2")
+                                                   (const_string "yes")
+                                                   (const_string "no"))
+          (eq_attr "feature" "se")   (if_then_else (match_test "TARGET_EXT_STRING")
+                                                   (const_string "yes")
+                                                   (const_string "no"))]
+          (const_string "yes"))))
 
 
 ;; ----------------------------------------------------------------------------
       gcc_unreachable ();
     }
 }
-  [(set_attr "type"   "alu,alu,alu,alu,alu,alu,alu,alu,alu,alu")
-   (set_attr "length" "  2,  2,  2,  2,  2,  2,  2,  2,  4,  4")])
+  [(set_attr "type"    "alu,alu,alu,alu,alu,alu,alu,alu,alu,alu")
+   (set_attr "length"  "  2,  2,  2,  2,  2,  2,  2,  2,  4,  4")
+   (set_attr "feature" " v1, v1, v1, v1, v1, v1, v2, v1, v1, v1")])
 
 (define_insn "sub<mode>3"
   [(set (match_operand:QIHISI 0 "register_operand"                    "=d, l,    r, r")
   mul33\t%0, %2
   mul\t%0, %1, %2"
   [(set_attr "type"    "mul,mul")
-   (set_attr "length" "  2,  4")])
+   (set_attr "length"  "  2,  4")
+   (set_attr "feature" "v3m, v1")])
 
 (define_insn "mulsidi3"
   [(set (match_operand:DI 0 "register_operand"                          "=r")
       gcc_unreachable ();
     }
 }
-  [(set_attr "type"   "alu,alu,alu,alu,alu,alu,alu,alu,alu,alu,alu,alu,alu")
-   (set_attr "length" "  2,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,  4,  4")])
+  [(set_attr "type"    "alu,alu,alu,alu,alu,alu,alu,alu,alu,alu,alu,alu,alu")
+   (set_attr "length"  "  2,  4,  2,  2,  2,  2,  2,  2,  4,  4,  4,  4,  4")
+   (set_attr "feature" "v3m, v1, v1, v1, v1, v1,v3m,v3m, v1, v1, v1, v3,pe1")])
 
 (define_insn "*and_slli"
   [(set (match_operand:SI 0 "register_operand"                      "=   r")
       gcc_unreachable ();
     }
 }
-  [(set_attr "type"   "alu,alu,alu,alu")
-   (set_attr "length" "  2,  4,  4,  4")])
+  [(set_attr "type"    "alu,alu,alu,alu")
+   (set_attr "length"  "  2,  4,  4,  4")
+   (set_attr "feature" "v3m, v1, v1,pe1")])
 
 (define_insn "*xor_slli"
   [(set (match_operand:SI 0 "register_operand"                     "=   r")
   "@
    not33\t%0, %1
    nor\t%0, %1, %1"
-  [(set_attr "type"   "alu,alu")
-   (set_attr "length" "  2,  4")])
+  [(set_attr "type"    "alu,alu")
+   (set_attr "length"  "  2,  4")
+   (set_attr "feature" "v3m, v1")])
 
 
 ;; ----------------------------------------------------------------------------