[NDS32] Implement bswapsi2 and bswaphi2 patterns.
authorChung-Ju Wu <jasonwucj@gmail.com>
Sun, 27 May 2018 06:52:48 +0000 (06:52 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Sun, 27 May 2018 06:52:48 +0000 (06:52 +0000)
gcc/
* config/nds32/nds32.md (bswapsi2, bswaphi2): New patterns.

From-SVN: r260804

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

index 73c578165f37874d90130a55dbc4a7034513c06e..293856b0888876f76007382b46868a5043536380 100644 (file)
@@ -1,3 +1,7 @@
+2018-05-27  Chung-Ju Wu  <jasonwucj@gmail.com>
+
+       * config/nds32/nds32.md (bswapsi2, bswaphi2): New patterns.
+
 2018-05-27  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.c (nds32_attribute_table): Add "no_prologue".
index 63e4efe23da175145aeaed2ce9d0d6a1976edb03..66ef03327f4c0a6bc1e7262cf1084563d9f8c766 100644 (file)
   [(set_attr "type"    "alu")
    (set_attr "length"    "4")]
 )
+
+(define_expand "bswapsi2"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+       (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
+  ""
+{
+  emit_insn (gen_unspec_wsbh (operands[0], operands[1]));
+  emit_insn (gen_rotrsi3 (operands[0], operands[0], GEN_INT (16)));
+  DONE;
+})
+
+(define_insn "bswaphi2"
+  [(set (match_operand:HI 0 "register_operand" "=r")
+       (bswap:HI (match_operand:HI 1 "register_operand" "r")))]
+  ""
+  "wsbh\t%0, %1"
+  [(set_attr "type"    "alu")
+   (set_attr "length"    "4")]
+)
+
 ;; ----------------------------------------------------------------------------
 
 ;; Patterns for exception handling