]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[NDS32] Refine CASE_VECTOR_SHORTEN_MODE to function.
authorShiva Chen <shiva0217@gmail.com>
Sun, 22 Apr 2018 08:42:18 +0000 (08:42 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Sun, 22 Apr 2018 08:42:18 +0000 (08:42 +0000)
gcc/
* config/nds32/nds32-protos.h (nds32_case_vector_shorten_mode):
Declare.
* config/nds32/nds32.c (nds32_case_vector_shorten_mode): New function.
* config/nds32/nds32.h (CASE_VECTOR_SHORTEN_MODE): Modify.

Co-Authored-By: Chung-Ju Wu <jasonwucj@gmail.com>
From-SVN: r259550

gcc/ChangeLog
gcc/config/nds32/nds32-protos.h
gcc/config/nds32/nds32.c
gcc/config/nds32/nds32.h

index 43c1b3a3d55361ece43dcc3b3b0dcd0cf377007f..b32490e3072ceb008da76089199a24f78e59139a 100644 (file)
@@ -1,3 +1,11 @@
+2018-04-22  Shiva Chen  <shiva0217@gmail.com>
+           Chung-Ju Wu  <jasonwucj@gmail.com>
+
+       * config/nds32/nds32-protos.h (nds32_case_vector_shorten_mode):
+       Declare.
+       * config/nds32/nds32.c (nds32_case_vector_shorten_mode): New function.
+       * config/nds32/nds32.h (CASE_VECTOR_SHORTEN_MODE): Modify.
+
 2018-04-22  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.c (nds32_compute_stack_frame): Fix wrong value.
index 2dce97ef91b8bd1aa4a78ec826b27bc334950a9f..2d68f131fcf49fd1f1a415c4bac7197ef8750abc 100644 (file)
@@ -219,6 +219,7 @@ extern void nds32_expand_constant (machine_mode,
 /* Auxiliary functions to check using return with null epilogue.  */
 
 extern int nds32_can_use_return_insn (void);
+extern scalar_int_mode nds32_case_vector_shorten_mode (int, int, rtx);
 
 /* Auxiliary functions to decide output alignment or not.  */
 
index 0c4e91758b5dcda4adc6296773b3b12dab3ab941..a33567eeff4d22fcef2b135ff37ae4fe6e5343b1 100644 (file)
@@ -4768,6 +4768,23 @@ nds32_can_use_return_insn (void)
   return (cfun->machine->naked_p && (cfun->machine->va_args_size == 0));
 }
 
+scalar_int_mode
+nds32_case_vector_shorten_mode (int min_offset, int max_offset,
+                               rtx body ATTRIBUTE_UNUSED)
+{
+  if (min_offset < 0 || max_offset >= 0x2000)
+    return SImode;
+  else
+    {
+      /* The jump table maybe need to 2 byte alignment,
+        so reserved 1 byte for check max_offset.  */
+      if (max_offset >= 0xff)
+       return HImode;
+      else
+       return QImode;
+    }
+}
+
 /* ------------------------------------------------------------------------ */
 
 /* Function to test 333-form for load/store instructions.
index 6c2f1f8f13ed807cbd11aa9233297688306bec23..c5d1e27e0eb99f4fed488664b92f82b7a5c04d85 100644 (file)
@@ -1331,9 +1331,7 @@ enum reg_class
 /* Return the preferred mode for and addr_diff_vec when the mininum
    and maximum offset are known.  */
 #define CASE_VECTOR_SHORTEN_MODE(min_offset, max_offset, body)  \
-   ((min_offset < 0 || max_offset >= 0x2000 ) ? SImode          \
-   : (max_offset >= 100) ? HImode                               \
-   : QImode)
+  nds32_case_vector_shorten_mode (min_offset, max_offset, body)
 
 /* Generate pc relative jump table when -fpic or -Os.  */
 #define CASE_VECTOR_PC_RELATIVE (flag_pic || optimize_size)