Commit 2f1bb3ca by Shiva Chen Committed by Chung-Ju Wu

[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
parent 361292be
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.
......
......@@ -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. */
......
......@@ -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.
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment