From: Shiva Chen Date: Sun, 22 Apr 2018 08:42:18 +0000 (+0000) Subject: [NDS32] Refine CASE_VECTOR_SHORTEN_MODE to function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2f1bb3ca9170534db2cf2df6cf4ff61a4dd6145b;p=gcc.git [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 From-SVN: r259550 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 43c1b3a3d55..b32490e3072 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-04-22 Shiva Chen + Chung-Ju Wu + + * 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 * 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 2dce97ef91b..2d68f131fcf 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 0c4e91758b5..a33567eeff4 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 6c2f1f8f13e..c5d1e27e0eb 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)