[NDS32] Fine-tune memory address type.
authorShiva Chen <shiva0217@gmail.com>
Thu, 5 Apr 2018 03:35:28 +0000 (03:35 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Thu, 5 Apr 2018 03:35:28 +0000 (03:35 +0000)
gcc/
* config/nds32/constraints.md (U33): Fine-tune checking condition.
* config/nds32/nds32-md-auxiliary.c (nds32_mem_format): Ditto.
* config/nds32/nds32.h (nds32_16bit_address_type): Add
ADDRESS_POST_MODIFY_LO_REG_IMM3U.

Co-Authored-By: Kito Cheng <kito.cheng@gmail.com>
From-SVN: r259122

gcc/ChangeLog
gcc/config/nds32/constraints.md
gcc/config/nds32/nds32-md-auxiliary.c
gcc/config/nds32/nds32.h

index 021c0977521ff4eacab3b7334faa04d438de9945..6e299cb33a759654eff98b1ba40ad55f83ef853e 100644 (file)
@@ -1,3 +1,11 @@
+2018-04-05  Shiva Chen  <shiva0217@gmail.com>
+           Kito Cheng  <kito.cheng@gmail.com>
+
+       * config/nds32/constraints.md (U33): Fine-tune checking condition.
+       * config/nds32/nds32-md-auxiliary.c (nds32_mem_format): Ditto.
+       * config/nds32/nds32.h (nds32_16bit_address_type): Add
+       ADDRESS_POST_MODIFY_LO_REG_IMM3U.
+
 2018-04-05  Shiva Chen  <shiva0217@gmail.com>
            Kito Cheng  <kito.cheng@gmail.com>
 
index 46b925f059f96c5c8eeb34857ee9fff58f72659c..7cf18eb5533e38264e549273b73f6592a37f1147 100644 (file)
 (define_memory_constraint "U33"
   "Memory constraint for 333 format"
   (and (match_code "mem")
-       (match_test "nds32_mem_format (op) == ADDRESS_LO_REG_IMM3U")))
+       (match_test "nds32_mem_format (op) == ADDRESS_POST_INC_LO_REG_IMM3U
+                   || nds32_mem_format (op) == ADDRESS_POST_MODIFY_LO_REG_IMM3U
+                   || nds32_mem_format (op) == ADDRESS_LO_REG_IMM3U")))
 
 (define_memory_constraint "U45"
   "Memory constraint for 45 format"
index 38958999c700114687a2cf21965bd18f05434a02..b3673ae72e619b21dee541928799594e97391a3e 100644 (file)
@@ -891,8 +891,8 @@ nds32_mem_format (rtx op)
     {
       regno = REGNO (XEXP (XEXP (op, 1), 0));
       val = INTVAL (XEXP (XEXP (op, 1), 1));
-      if (regno < 8 && val < 32)
-       return ADDRESS_POST_INC_LO_REG_IMM3U;
+      if (regno < 8 && val > 0 && val < 32)
+       return ADDRESS_POST_MODIFY_LO_REG_IMM3U;
     }
 
   if ((GET_CODE (op) == PLUS)
@@ -903,7 +903,7 @@ nds32_mem_format (rtx op)
 
       regno = REGNO(XEXP (op, 0));
 
-      if (regno > 7
+      if (regno > 8
          && regno != SP_REGNUM
          && regno != FP_REGNUM)
        return ADDRESS_NOT_16BIT_FORMAT;
@@ -971,7 +971,11 @@ nds32_output_16bit_store (rtx *operands, int byte)
       output_asm_insn (pattern, operands);
       break;
     case ADDRESS_POST_INC_LO_REG_IMM3U:
-      snprintf (pattern, sizeof (pattern), "s%ci333.bi\t%%1, %%0", size);
+      snprintf (pattern, sizeof (pattern), "swi333.bi\t%%1, %%0, 4");
+      output_asm_insn (pattern, operands);
+      break;
+    case ADDRESS_POST_MODIFY_LO_REG_IMM3U:
+      snprintf (pattern, sizeof (pattern), "swi333.bi\t%%1, %%0");
       output_asm_insn (pattern, operands);
       break;
     case ADDRESS_FP_IMM7U:
@@ -1010,7 +1014,11 @@ nds32_output_16bit_load (rtx *operands, int byte)
       output_asm_insn (pattern, operands);
       break;
     case ADDRESS_POST_INC_LO_REG_IMM3U:
-      snprintf (pattern, sizeof (pattern), "l%ci333.bi\t%%0, %%1", size);
+      snprintf (pattern, sizeof (pattern), "lwi333.bi\t%%0, %%1, 4");
+      output_asm_insn (pattern, operands);
+      break;
+    case ADDRESS_POST_MODIFY_LO_REG_IMM3U:
+      snprintf (pattern, sizeof (pattern), "lwi333.bi\t%%0, %%1");
       output_asm_insn (pattern, operands);
       break;
     case ADDRESS_R8_IMM7U:
index 1f3c48c59bef679a2ff43fe95aa55b1b703c59ab..02b99a17b955c57094032cf97df727ba305fdac8 100644 (file)
@@ -113,6 +113,8 @@ enum nds32_16bit_address_type
   ADDRESS_LO_REG_IMM3U,
   /* post_inc [lo_reg + imm3u]: 333 format address.  */
   ADDRESS_POST_INC_LO_REG_IMM3U,
+  /* post_modify [lo_reg + imm3u]: 333 format address.  */
+  ADDRESS_POST_MODIFY_LO_REG_IMM3U,
   /* [$r8 + imm7u]: r8 imply address.  */
   ADDRESS_R8_IMM7U,
   /* [$fp + imm7u]: fp imply address.  */