From a58762287e1a75e29df3d6e80e7b22e3ff03a320 Mon Sep 17 00:00:00 2001 From: Chung-Ju Wu Date: Fri, 6 Apr 2018 18:36:28 +0000 Subject: [PATCH] [NDS32] Refine ADJUST_INSN_LENGTH implementation. gcc/ * config/nds32/nds32.c (nds32_adjust_insn_length): Refine. * config/nds32/nds32.h (ADJUST_INSN_LENGTH): Change the location in file. From-SVN: r259187 --- gcc/ChangeLog | 6 ++++ gcc/config/nds32/nds32.c | 60 +++++++++++++++++++--------------------- gcc/config/nds32/nds32.h | 7 ++--- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a261a45986d..f92cd60aed1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-04-06 Chung-Ju Wu + + * config/nds32/nds32.c (nds32_adjust_insn_length): Refine. + * config/nds32/nds32.h (ADJUST_INSN_LENGTH): Change the location in + file. + 2018-04-06 Chung-Ju Wu Kito Cheng diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c index 1070b474d8f..030fb2e0224 100644 --- a/gcc/config/nds32/nds32.c +++ b/gcc/config/nds32/nds32.c @@ -1328,6 +1328,35 @@ nds32_register_passes (void) /* PART 3: Implement target hook stuff definitions. */ +/* Computing the Length of an Insn. + Modifies the length assigned to instruction INSN. + LEN is the initially computed length of the insn. */ +int +nds32_adjust_insn_length (rtx_insn *insn, int length) +{ + int adjust_value = 0; + switch (recog_memoized (insn)) + { + case CODE_FOR_call_internal: + case CODE_FOR_call_value_internal: + { + /* We need insert a nop after a noretun function call + to prevent software breakpoint corrupt the next function. */ + if (find_reg_note (insn, REG_NORETURN, NULL_RTX)) + { + if (TARGET_16_BIT) + adjust_value += 2; + else + adjust_value += 4; + } + } + return length + adjust_value; + + default: + return length; + } +} + /* Register Usage. */ static void @@ -4364,37 +4393,6 @@ nds32_ls_333_p (rtx rt, rtx ra, rtx imm, machine_mode mode) return false; } - -/* Computing the Length of an Insn. - Modifies the length assigned to instruction INSN. - LEN is the initially computed length of the insn. */ -int -nds32_adjust_insn_length (rtx_insn *insn, int length) -{ - rtx src, dst; - - switch (recog_memoized (insn)) - { - case CODE_FOR_move_df: - case CODE_FOR_move_di: - /* Adjust length of movd44 to 2. */ - src = XEXP (PATTERN (insn), 1); - dst = XEXP (PATTERN (insn), 0); - - if (REG_P (src) - && REG_P (dst) - && (REGNO (src) % 2) == 0 - && (REGNO (dst) % 2) == 0) - length = 2; - break; - - default: - break; - } - - return length; -} - bool nds32_split_double_word_load_store_p(rtx *operands, bool load_p) { diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h index c1d389c7d61..934fe03ba17 100644 --- a/gcc/config/nds32/nds32.h +++ b/gcc/config/nds32/nds32.h @@ -24,6 +24,9 @@ /* The following are auxiliary macros or structure declarations that are used all over the nds32.c and nds32.h. */ +#define ADJUST_INSN_LENGTH(INSN, LENGTH) \ + (LENGTH = nds32_adjust_insn_length (INSN, LENGTH)) + /* Use SYMBOL_FLAG_MACH_DEP to define our own symbol_ref flag. It is used in nds32_encode_section_info() to store flag in symbol_ref in case the symbol should be placed in .rodata section. @@ -41,10 +44,6 @@ enum nds32_expand_result_type EXPAND_CREATE_TEMPLATE }; -/* Computing the Length of an Insn. */ -#define ADJUST_INSN_LENGTH(INSN, LENGTH) \ - (LENGTH = nds32_adjust_insn_length (INSN, LENGTH)) - /* Check instruction LS-37-FP-implied form. Note: actually its immediate range is imm9u since it is used for lwi37/swi37 instructions. */ -- 2.30.2