aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShiva Chen <shiva0217@gmail.com>2018-04-22 08:42:18 +0000
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>2018-04-22 08:42:18 +0000
commit2f1bb3ca9170534db2cf2df6cf4ff61a4dd6145b (patch)
tree91e52c3020c6f09fd36314fbb51e8aad4b153d71
parent361292be13045d2ed2812b26bb6c634b60e155df (diff)
downloadgcc-2f1bb3ca9170534db2cf2df6cf4ff61a4dd6145b.zip
gcc-2f1bb3ca9170534db2cf2df6cf4ff61a4dd6145b.tar.gz
gcc-2f1bb3ca9170534db2cf2df6cf4ff61a4dd6145b.tar.bz2
[NDS32] Refine CASE_VECTOR_SHORTEN_MODE to function.
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
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/nds32/nds32-protos.h1
-rw-r--r--gcc/config/nds32/nds32.c17
-rw-r--r--gcc/config/nds32/nds32.h4
4 files changed, 27 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 43c1b3a..b32490e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/config/nds32/nds32-protos.h b/gcc/config/nds32/nds32-protos.h
index 2dce97e..2d68f13 100644
--- a/gcc/config/nds32/nds32-protos.h
+++ b/gcc/config/nds32/nds32-protos.h
@@ -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. */
diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 0c4e917..a33567e 100644
--- a/gcc/config/nds32/nds32.c
+++ b/gcc/config/nds32/nds32.c
@@ -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.
diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h
index 6c2f1f8..c5d1e27 100644
--- a/gcc/config/nds32/nds32.h
+++ b/gcc/config/nds32/nds32.h
@@ -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)