From f7e5eca1a25565ea296ef6c55b1743aa74815793 Mon Sep 17 00:00:00 2001 From: Nelson Chu Date: Wed, 22 Aug 2018 15:51:24 +0800 Subject: [PATCH 06/13] NDS32: Update assemble-time relaxations (branch patterns). NDS32 has two main assemble-time relaxations, one is for branch, the other is for pseudo instructions and load-store patterns (with .relax_hint directives). This patch focuses on the update for the branch patterns with different code models. Additionally, use XNEW macro to allocate `insn.info' in md_assemble, and then remember to free it. gas/ * config/tc-nds32.c (relax_table): Updated. (md_begin): Updated. (md_assemble): Use XNEW macro to allocate space for `insn.info', and then remember to free it. (md_section_align): Cast (-1) to ValueT. (nds32_get_align): Cast (~0U) to addressT. (nds32_relax_branch_instructions): Updated. (md_convert_frag): Add new local variable `final_r_type'. (invalid_prev_frag): Add new bfd_boolean parameter `relax'. All callers changed. --- gas/config/tc-nds32.c | 3002 ++++++++++++++++++++++++----------------- 1 file changed, 1735 insertions(+), 1267 deletions(-) diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c index 85a4026e81..1d8f9287e2 100644 --- a/gas/config/tc-nds32.c +++ b/gas/config/tc-nds32.c @@ -106,60 +106,78 @@ enum ict_option { }; static enum ict_option ict_flag = ICT_NONE; + static struct hash_control *nds32_relax_info_hash; + +/* Branch patterns. */ static relax_info_t relax_table[] = { { - "jal", /* opcode */ - BR_RANGE_S16M, /* br_range */ - {{0, 0, 0, FALSE}}, /* cond_field */ - { + .opcode = "jal", + .br_range = BR_RANGE_S16M, + .cond_field = { - INSN_JAL /* jal label */ - }, /* BR_RANGE_S256 */ + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = { - INSN_JAL /* jal label */ - }, /* BR_RANGE_S16K */ + INSN_JAL /* jal label */ + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_JAL /* jal label */ - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_JAL /* jal label */ - }, /* BR_RANGE_S16M */ + INSN_JAL /* jal label */ + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JRAL_TA - }, /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - {{0, 0, 0, FALSE}}, /* BR_RANGE_S256 */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S64K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16M */ - {{0, 0, 0, FALSE}} /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 4, 12}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_JAL /* jal label */ + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + INSN_JAL /* jal label */ + }, + .relax_code_size[BR_RANGE_S16M] = 4, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JRAL_TA /* jral $ta */ + }, + .relax_code_size[BR_RANGE_U4G] = 12, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, 0, BFD_RELOC_NDS32_HI20}, + {0, 4, 0, BFD_RELOC_NDS32_HI20}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL4}, {4, 4, NDS32_HINT | NDS32_FIX, BFD_RELOC_NDS32_LO12S0_ORI}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -167,169 +185,213 @@ static relax_info_t relax_table[] = {8, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {8, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bltzal", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BLTZAL /* bltzal $rt, label */ - }, /* BR_RANGE_S256 */ + .opcode = "bgezal", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BGEZAL /* bgezal $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BLTZAL /* bltzal $rt, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BLTZAL /* bltzal $rt, label */ - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BGEZ, /* bgez $rt, $1 */ - INSN_JAL /* jal label */ - }, /* BR_RANGE_S16M */ + INSN_BGEZAL /* bgezal $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BGEZ, /* bgez $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JRAL_TA /* jral $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + INSN_BGEZAL /* bgezal $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + INSN_BLTZ, /* bltz $rt, $1 */ + INSN_JAL /* jal label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL5}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + INSN_BLTZ, /* bltz $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JRAL_TA /* jral $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL5}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL6}, - {4, 4, 0, BFD_RELOC_NDS32_HI20}, + {4, 4, 0, BFD_RELOC_NDS32_HI20}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, {8, 4, NDS32_FIX | NDS32_HINT, BFD_RELOC_NDS32_LO12S0_ORI}, {8, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, {12, 4, NDS32_ABS | NDS32_HINT, BFD_RELOC_NDS32_PTR_RESOLVED}, {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + {0, 0, 0, 0} + }, }, { - "bgezal", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BGEZAL /* bgezal $rt, label */ - }, /* BR_RANGE_S256 */ + .opcode = "bltzal", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BLTZAL /* bltzal $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BGEZAL /* bgezal $rt, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BGEZAL /* bgezal $rt, label */ - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BLTZ, /* bltz $rt, $1 */ - INSN_JAL /* jal label */ - }, /* BR_RANGE_S16M */ + INSN_BLTZAL /* bltzal $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BLTZ, /* bltz $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JRAL_TA /* jral $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + INSN_BLTZAL /* bltzal $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + INSN_BGEZ, /* bgez $rt, $1 */ + INSN_JAL /* jal label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL5}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + INSN_BGEZ, /* bgez $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JRAL_TA /* jral $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL5}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGCALL6}, - {4, 4, 0, BFD_RELOC_NDS32_HI20}, + {4, 4, 0, BFD_RELOC_NDS32_HI20}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, {8, 4, NDS32_FIX | NDS32_HINT, BFD_RELOC_NDS32_LO12S0_ORI}, {8, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -337,60 +399,74 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "j", /* opcode */ - BR_RANGE_S16M, /* br_range */ - {{0, 0, 0, FALSE}}, /* cond_field */ - { + .opcode = "j", + .br_range = BR_RANGE_S16M, + .cond_field = { - (INSN_J8 << 16) /* j8 label */ - }, /* BR_RANGE_S256 */ + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = { - INSN_J /* j label */ - }, /* BR_RANGE_S16K */ + (INSN_J8 << 16) /* j8 label */ + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + INSN_J /* j label */ + }, + . relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - }, /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - {{0, 0, 0, FALSE}}, /* BR_RANGE_S256 */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S64K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16M */ - {{0, 0, 0, FALSE}} /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 4, 4, 12}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = + { + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S16M] = 4, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_size[BR_RANGE_U4G] = 12, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, 0, BFD_RELOC_NDS32_HI20}, + {0, 4, 0, BFD_RELOC_NDS32_HI20}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP4}, {4, 4, NDS32_HINT | NDS32_FIX, BFD_RELOC_NDS32_LO12S0_ORI}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -398,60 +474,74 @@ static relax_info_t relax_table[] = {8, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {8, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "j8", /* opcode */ - BR_RANGE_S256, /* br_range */ - {{0, 0, 0, FALSE}}, /* cond_field */ - { + .opcode = "j8", + .br_range = BR_RANGE_S256, + .cond_field = { - (INSN_J8 << 16) /* j8 label */ - }, /* BR_RANGE_S256 */ + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = { - INSN_J /* j label */ - }, /* BR_RANGE_S16K */ + (INSN_J8 << 16) /* j8 label */ + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - }, /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - {{0, 0, 0, FALSE}}, /* BR_RANGE_S256 */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S64K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16M */ - {{0, 0, 0, FALSE}} /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 4, 4, 12}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = + { + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S16M] = 4, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_size[BR_RANGE_U4G] = 12, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, 0, BFD_RELOC_NDS32_HI20}, + {0, 4, 0, BFD_RELOC_NDS32_HI20}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP4}, {4, 4, NDS32_HINT | NDS32_FIX, BFD_RELOC_NDS32_LO12S0_ORI}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -459,85 +549,113 @@ static relax_info_t relax_table[] = {8, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {8, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "beqz", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BEQZ /* beqz $rt, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BEQZ /* beqz $rt, label */ - }, /* BR_RANGE_S16K */ + .opcode = "beqz", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + /* We do not use beqz38 and beqzs8 here directly because we + don't want to check register number for specail condition. */ + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BEQZ /* beqz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BEQZ /* beqz $rt, label */ - }, /* BR_RANGE_S64K */ - { - INSN_BNEZ, /* bnez $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BNEZ, /* bnez $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 4, NDS32_INSN16 , BFD_RELOC_NDS32_INSN16}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BEQZ /* beqz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 4, NDS32_INSN16 , BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BEQZ /* beqz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = + { + INSN_BNEZ, /* bnez $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = + { + /* bnez range is 17 pcrel, but it use 15 pcrel here since link time + relaxtion. If 17 pcrel can reach, it do not have to use S16M. + Therefore, 15 pcrel is just for linker to distinguish LONGJUMP5 + and LONGJUMP6. */ {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BNEZ, /* bnez $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -547,83 +665,104 @@ static relax_info_t relax_table[] = {12, 4, NDS32_ABS | NDS32_HINT, BFD_RELOC_NDS32_PTR_RESOLVED}, {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + {0, 0, 0, 0} + }, }, { - "bgez", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BGEZ /* bgez $rt, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BGEZ /* bgez $rt, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BGEZ /* bgez $rt, label */ - }, /* BR_RANGE_S64K */ + .opcode = "bgez", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BGEZ /* bgez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BLTZ, /* bltz $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BLTZ, /* bltz $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BGEZ /* bgez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BGEZ /* bgez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BLTZ, /* bltz $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BLTZ, /* bltz $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -633,85 +772,107 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bnez", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BNEZ /* bnez $rt, label */ - }, /* BR_RANGE_S256 */ + .opcode = "bnez", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BNEZ /* bnez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BNEZ /* bnez $rt, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BNEZ /* bnez $rt, label */ - }, /* BR_RANGE_S64K */ - { - INSN_BEQZ, /* beqz $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BEQZ, /* beqz $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BNEZ /* bnez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BNEZ /* bnez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 4, NDS32_INSN16 , BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BEQZ, /* beqz $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BEQZ, /* beqz $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -722,82 +883,104 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bgtz", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BGTZ /* bgtz $rt, label */ - }, /* BR_RANGE_S256 */ + .opcode = "bgtz", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BGTZ /* bgtz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BGTZ /* bgtz $rt, label */ - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BGTZ /* bgtz $rt, label */ - }, /* BR_RANGE_S64K */ + INSN_BGTZ /* bgtz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BLEZ, /* blez $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_BLEZ, /* blez $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BGTZ /* bgtz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BLEZ, /* blez $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BLEZ, /* blez $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -807,82 +990,104 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "blez", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BLEZ /* blez $rt, label */ - }, /* BR_RANGE_S256 */ + .opcode = "blez", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BLEZ /* blez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BLEZ /* blez $rt, label */ - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BLEZ /* blez $rt, label */ - }, /* BR_RANGE_S64K */ + INSN_BLEZ /* blez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BGTZ, /* bgtz $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_BGTZ, /* bgtz $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BLEZ /* blez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BGTZ, /* bgtz $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BGTZ, /* bgtz $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -892,82 +1097,104 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bltz", /* opcode */ - BR_RANGE_S64K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BLTZ /* bltz $rt, label */ - }, /* BR_RANGE_S256 */ + .opcode = "bltz", + .br_range = BR_RANGE_S64K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BLTZ /* bltz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = { - INSN_BLTZ /* bltz $rt, label */ - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BLTZ /* bltz $rt, label */ - }, /* BR_RANGE_S64K */ + INSN_BLTZ /* bltz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BGEZ, /* bgez $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_BGEZ, /* bgez $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BLTZ /* bltz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BGEZ, /* bgez $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 4, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BGEZ, /* bgez $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE}, + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, {4, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_PTR}, @@ -977,97 +1204,118 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "beq", /* opcode */ - BR_RANGE_S16K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BEQ /* beq $rt, $ra, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BEQ /* beq $rt, $ra, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BNE, /* bne $rt, $ra, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ - { - INSN_BNE, /* bne $rt, $ra, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BNE, /* bne $rt, $ra, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ - { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + .opcode = "beq", + .br_range = BR_RANGE_S16K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BEQ /* beq $rt, $ra, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = + { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + INSN_BEQ /* beq $rt, $ra, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 8, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_BNE, /* bne $rt, $ra, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 8, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = + { + INSN_BNE, /* bne $rt, $ra, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {4, 4, NDS32_ABS, BFD_RELOC_NDS32_EMPTY}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BNE, /* bne $rt, $ra, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1078,96 +1326,118 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bne", /* opcode */ - BR_RANGE_S16K, /* br_range */ - { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BNE /* bne $rt, $ra, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BNE /* bne $rt, $ra, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BEQ, /* beq $rt, $ra, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ - { - INSN_BEQ, /* beq $rt, $ra, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BEQ, /* beq $rt, $ra, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ - { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + .opcode = "bne", + .br_range = BR_RANGE_S16K, + .cond_field = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BNE /* bne $rt, $ra, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = + { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + INSN_BNE /* bne $rt, $ra, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 15, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 4, 8, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_BEQ, /* beq $rt, $ra, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 8, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = + { + INSN_BEQ, /* beq $rt, $ra, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + INSN_BEQ, /* beq $rt, $ra, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 15, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = + { + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1178,84 +1448,106 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "beqz38", /* opcode */ - BR_RANGE_S256, /* br_range */ - { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BEQZ38 << 16 /* beqz $rt, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BEQZ /* beqz $rt, label */ - }, /* BR_RANGE_S16K */ + .opcode = "beqz38", + .br_range = BR_RANGE_S256, + .cond_field = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BEQZ38 << 16 /* beqz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_BEQZ /* beqz $rt, label */ - }, /* BR_RANGE_S64K */ - { - INSN_BNEZ, /* bnez $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BNEZ, /* bnez $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BEQZ /* beqz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BEQZ /* beqz $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 4, 8, 16}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BNEZ, /* bnez $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BNEZ, /* bnez $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1266,84 +1558,106 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bnez38", /* opcode */ - BR_RANGE_S256, /* br_range */ - { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BNEZ38 << 16 /* bnez $rt, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BNEZ /* bnez $rt, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BNEZ /* bnez $rt, label */ - }, /* BR_RANGE_S64K */ - { - INSN_BEQZ, /* beqz $rt, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + .opcode = "bnez38", + .br_range = BR_RANGE_S256, + .cond_field = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BNEZ38 << 16 /* bnez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_BEQZ, /* beqz $rt, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + INSN_BNEZ /* bnez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + INSN_BNEZ /* bnez $rt, label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 4, 8, 16}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + INSN_BEQZ, /* beqz $rt, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BEQZ, /* beqz $rt, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = + { + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1354,66 +1668,80 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "beqzs8", /* opcode */ - BR_RANGE_S256, /* br_range */ - {{0, 0, 0, FALSE}}, /* cond_field */ - { + .opcode = "beqzs8", + .br_range = BR_RANGE_S256, + .cond_field = { - INSN_BEQZS8 << 16 /* beqz $r15, label */ - }, /* BR_RANGE_S256 */ + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = { - INSN_BEQZ_TA /* bnez $rt, label */ - }, /* BR_RANGE_S16K */ + INSN_BEQZS8 << 16 /* beqz $r15, label */ + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_BEQZ_TA /* bnez $rt, label */ - }, /* BR_RANGE_S64K */ + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BNEZ_TA, /* bnez $r15, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + INSN_BEQZ_TA /* beqz $r15, label */ + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_BNEZ_TA, /* bnez $r15, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - {{0, 0, 0, FALSE}}, /* BR_RANGE_S256 */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S64K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16M */ - {{0, 0, 0, FALSE}} /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 4, 8, 16}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_BEQZ_TA /* beqz $r15, label */ + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + INSN_BNEZ_TA, /* bnez $r15, $1 */ + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BNEZ_TA, /* bnez $r15, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1423,67 +1751,81 @@ static relax_info_t relax_table[] = {12, 4, NDS32_ABS | NDS32_HINT, BFD_RELOC_NDS32_PTR_RESOLVED}, {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + {0, 0, 0, 0} + }, }, { - "bnezs8", /* opcode */ - BR_RANGE_S256, /* br_range */ - {{0, 0, 0, FALSE}}, /* cond_field */ - { + .opcode = "bnezs8", + .br_range = BR_RANGE_S256, + .cond_field = { - INSN_BNEZS8 << 16 /* bnez $r15, label */ - }, /* BR_RANGE_S256 */ + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = { - INSN_BNEZ_TA /* bnez $r15, label */ - }, /* BR_RANGE_S16K */ + INSN_BNEZS8 << 16 /* bnez $r15, label */ + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_BNEZ_TA /* bnez $r15, label */ - }, /* BR_RANGE_S64K */ + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BEQZ_TA, /* beqz $r15, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + INSN_BNEZ_TA /* bnez $r15, label */ + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - INSN_BEQZ_TA, /* beqz $r15, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - {{0, 0, 0, FALSE}}, /* BR_RANGE_S256 */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S64K */ - {{0, 0, 0, FALSE}}, /* BR_RANGE_S16M */ - {{0, 0, 0, FALSE}} /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 4, 8, 16}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_BNEZ_TA /* bnez $r15, label */ + }, + .relax_code_size[BR_RANGE_S64K] = 4, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_17_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + INSN_BEQZ_TA, /* beqz $r15, $1 */ + INSN_J /* j label */ + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BEQZ_TA, /* beqz $r15, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1494,89 +1836,111 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "bnes38", /* opcode */ - BR_RANGE_S256, /* br_range */ - { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BNES38 << 16 /* bne $rt, $R5, label */ - }, /* BR_RANGE_S256 */ - { - INSN_BNE_R5 /* bne $rt, $R5, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BEQ_R5, /* beq $rt, $R5, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ - { - INSN_BEQ_R5, /* beq $rt, $R5, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + .opcode = "bnes38", + .br_range = BR_RANGE_S256, + .cond_field = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BNES38 << 16 /* bne $rt, $r5, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_BEQ_R5, /* beq $rt, $R5, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + INSN_BNE_R5 /* bne $rt, $r5, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 8, 8, 16}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_BEQ_R5, /* beq $rt, $r5, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 8, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = + { + INSN_BEQ_R5, /* beq $rt, $r5, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BEQ_R5, /* beq $rt, $r5, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = + { + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1587,89 +1951,111 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "beqs38", /* opcode */ - BR_RANGE_S256, /* br_range */ - { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BEQS38 << 16 /* beq $rt, $R5, label */ - }, /* BR_RANGE_S256 */ + .opcode = "beqs38", + .br_range = BR_RANGE_S256, + .cond_field = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BEQS38 << 16 /* beq $rt, $r5, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 8, 0x7, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 2, + .relax_branch_isize[BR_RANGE_S256] = 2, + .relax_fixup[BR_RANGE_S256] = { - INSN_BEQ_R5 /* beq $rt, $R5, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BNE_R5, /* bne $rt, $R5, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ - { - INSN_BNE_R5, /* bne $rt, $R5, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ - { - INSN_BNE_R5, /* bne $rt, $R5, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { - { - {0, 8, 0x7, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ - { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + INSN_BEQ_R5 /* beq $rt, $r5, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 4, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {2, 4, 8, 8, 16}, /* relax_code_size */ - {2, 4, 4, 4, 4}, /* relax_branch_isize */ - { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 2, NDS32_PCREL, BFD_RELOC_NDS32_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + INSN_BNE_R5, /* bne $rt, $r5, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 8, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = + { + INSN_BNE_R5, /* bne $rt, $r5, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP5}, {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, {4, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + INSN_BNE_R5, /* bne $rt, $r5, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = + { + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP6}, {4, 4, 0, BFD_RELOC_NDS32_HI20}, @@ -1680,191 +2066,238 @@ static relax_info_t relax_table[] = {12, 4, NDS32_SYM | NDS32_HINT, BFD_RELOC_NDS32_EMPTY}, {12, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + }, }, { - "beqc", /* opcode */ - BR_RANGE_S256, /* br_range */ - { - {0, 8, 0x7FF, TRUE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BEQC /* beqc $rt, imm11s, label */ - }, /* BR_RANGE_S256 */ - { - INSN_MOVI_TA, /* movi $ta, imm11s */ - INSN_BEQ_TA /* beq $rt, $ta, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BNEC, /* bnec $rt, imm11s, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ + .opcode = "beqc", + .br_range = BR_RANGE_S256, + .cond_field = + { + {0, 8, 0x7FF, TRUE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BEQC /* beqc $rt, imm11s, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = + { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BNEC, /* bnec $rt, imm11s, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + INSN_MOVI_TA, /* movi $ta, imm11s */ + INSN_BEQ_TA /* beq $rt, $ta, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BNEC, /* bnec $rt, imm11s, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 0, 0xFFFFF, FALSE}, + {4, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 8, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 8, 0x7FF, TRUE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP7}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 0, 0xFFFFF, FALSE}, - {4, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + INSN_BNEC, /* bnec $rt, imm11s, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 8, 0x7FF, FALSE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 8, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 8, 0x7FF, FALSE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 8, 0x7FF, FALSE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 8, 8, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + INSN_BNEC, /* bnec $rt, imm11s, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP7}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {4, 4, 0, BFD_RELOC_NDS32_HI20}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BNEC, /* bnec $rt, imm11s, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = + { + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {4, 4, 0, BFD_RELOC_NDS32_HI20}, {8, 4, 0, BFD_RELOC_NDS32_LO12S0_ORI}, {12, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ + {0, 0, 0, 0} + }, }, { - "bnec", /* opcode */ - BR_RANGE_S256, /* br_range */ - { - {0, 8, 0x7FF, TRUE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* cond_field */ - { - { - INSN_BNEC /* bnec $rt, imm11s, label */ - }, /* BR_RANGE_S256 */ - { - INSN_MOVI_TA, /* movi $ta, imm11s */ - INSN_BNE_TA /* bne $rt, $ta, label */ - }, /* BR_RANGE_S16K */ - { - INSN_BEQC, /* beqc $rt, imm11s, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S64K */ + .opcode = "bnec", + .br_range = BR_RANGE_S256, + .cond_field = + { + {0, 8, 0x7FF, TRUE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_seq[BR_RANGE_S256] = + { + INSN_BNEC /* bnec $rt, imm11s, label */ + }, + .relax_code_condition[BR_RANGE_S256] = + { + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S256] = 4, + .relax_branch_isize[BR_RANGE_S256] = 4, + .relax_fixup[BR_RANGE_S256] = + { + {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16K] = { - INSN_BEQC, /* beqc $rt, imm11s, $1 */ - INSN_J /* j label */ - }, /* BR_RANGE_S16M */ + INSN_MOVI_TA, /* movi $ta, imm11s */ + INSN_BNE_TA /* bne $rt, $ta, label */ + }, + .relax_code_condition[BR_RANGE_S16K] = { - INSN_BEQC, /* beqc $rt, imm11s, $1 */ - INSN_SETHI_TA, /* sethi $ta, label */ - INSN_ORI_TA, /* ori $ta, $ta, label */ - INSN_JR_TA /* jr $ta */ - } /* BR_RANGE_U4G */ - }, /* relax_code_seq */ - { + {0, 0, 0xFFFFF, FALSE}, + {4, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16K] = 8, + .relax_branch_isize[BR_RANGE_S16K] = 4, + .relax_fixup[BR_RANGE_S16K] = { - {0, 8, 0x7FF, TRUE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S256 */ + {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, + {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP7}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S64K] = { - {0, 0, 0xFFFFF, FALSE}, - {4, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16K */ + INSN_BEQC, /* beqc $rt, imm11s, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S64K] = { - {0, 8, 0x7FF, FALSE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S64K */ + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S64K] = 8, + .relax_branch_isize[BR_RANGE_S64K] = 4, + .relax_fixup[BR_RANGE_S64K] = { - {0, 8, 0x7FF, FALSE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - }, /* BR_RANGE_S16M */ + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_S16M] = { - {0, 8, 0x7FF, FALSE}, - {0, 20, 0x1F, FALSE}, - {0, 0, 0, FALSE} - } /* BR_RANGE_U4G */ - }, /* relax_code_condition */ - {4, 8, 8, 8, 16}, /* relax_code_size */ - {4, 4, 4, 4, 4}, /* relax_branch_isize */ - { + INSN_BEQC, /* beqc $rt, imm11s, $1 */ + INSN_J /* j label */ + }, + .relax_code_condition[BR_RANGE_S16M] = { - {0, 4, NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S256 */ + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_S16M] = 8, + .relax_branch_isize[BR_RANGE_S16M] = 4, + .relax_fixup[BR_RANGE_S16M] = { - {0, 4, NDS32_INSN16 | NDS32_HINT, BFD_RELOC_NDS32_INSN16}, - {0, 4, NDS32_PTR | NDS32_HINT, BFD_RELOC_NDS32_LONGJUMP7}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_15_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16K */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S64K */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, - {0, 0, 0, 0} - }, /* BR_RANGE_S16M */ - { - {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, - {4, 4, 0, BFD_RELOC_NDS32_HI20}, - {8, 4, 0, BFD_RELOC_NDS32_LO12S0_ORI}, + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {4, 4, NDS32_PCREL, BFD_RELOC_NDS32_25_PCREL}, + {0, 0, 0, 0} + }, + + .relax_code_seq[BR_RANGE_U4G] = + { + INSN_BEQC, /* beqc $rt, imm11s, $1 */ + INSN_SETHI_TA, /* sethi $ta, label */ + INSN_ORI_TA, /* ori $ta, $ta, label */ + INSN_JR_TA /* jr $ta */ + }, + .relax_code_condition[BR_RANGE_U4G] = + { + {0, 8, 0x7FF, FALSE}, + {0, 20, 0x1F, FALSE}, + {0, 0, 0, FALSE} + }, + .relax_code_size[BR_RANGE_U4G] = 16, + .relax_branch_isize[BR_RANGE_U4G] = 4, + .relax_fixup[BR_RANGE_U4G] = + { + {0, 4, NDS32_CREATE_LABEL | NDS32_PCREL, BFD_RELOC_NDS32_WORD_9_PCREL}, + {4, 4, 0, BFD_RELOC_NDS32_HI20}, + {8, 4, 0, BFD_RELOC_NDS32_LO12S0_ORI}, {12, 4, NDS32_INSN16, BFD_RELOC_NDS32_INSN16}, - {0, 0, 0, 0} - } /* BR_RANGE_U4G */ - } /* relax_fixup */ - } + {0, 0, 0, 0} + }, + }, + { + .opcode = NULL, + }, }; + /* GAS definitions for command-line options. */ enum options { @@ -4096,13 +4529,16 @@ void md_begin (void) { struct nds32_keyword *k; - unsigned int i; + relax_info_t *relax_info; + int flags = 0; bfd_set_arch_mach (stdoutput, TARGET_ARCH, nds32_baseline); nds32_init_nds32_pseudo_opcodes (); asm_desc.parse_operand = nds32_asm_parse_operand; - nds32_asm_init (&asm_desc, 0); + if (nds32_gpr16) + flags |= NASM_OPEN_REDUCED_REG; + nds32_asm_init (&asm_desc, flags); /* Initial general purpose registers hash table. */ nds32_gprs_hash = hash_new (); @@ -4111,9 +4547,8 @@ md_begin (void) /* Initial branch hash table. */ nds32_relax_info_hash = hash_new (); - for (i = 0; i < ARRAY_SIZE (relax_table); i++) - hash_insert (nds32_relax_info_hash, relax_table[i].opcode, - &relax_table[i]); + for (relax_info = relax_table; relax_info->opcode; relax_info++) + hash_insert (nds32_relax_info_hash, relax_info->opcode, relax_info); /* Initial relax hint hash table. */ nds32_hint_hash = hash_new (); @@ -5344,14 +5779,12 @@ void md_assemble (char *str) { struct nds32_asm_insn insn; - expressionS insn_expr; char *out; struct nds32_pseudo_opcode *popcode; const struct nds32_field *fld = NULL; fixS *fixP; uint16_t insn_16; struct nds32_relocs_pattern *relocs_temp; - expressionS *pexp; fragS *fragP; int label = label_exist; @@ -5380,7 +5813,7 @@ md_assemble (char *str) } label_exist = 0; - insn.info = &insn_expr; + insn.info = XNEW (expressionS); asm_desc.result = NASM_OK; nds32_assemble (&asm_desc, &insn, str); @@ -5441,8 +5874,8 @@ md_assemble (char *str) /* Get branch range type. */ dwarf2_emit_insn (0); enum nds32_br_range range_type; + expressionS *pexp = insn.info; - pexp = insn.info; range_type = get_range_type (fld); out = frag_var (rs_machine_dependent, NDS32_MAXCHAR, @@ -5458,6 +5891,8 @@ md_assemble (char *str) else if (insn.opcode->isize == 2) bfd_putb16 (insn.insn, out); fragP->tc_frag_data.flag |= NDS32_FRAG_BRANCH; + + free (insn.info); return; /* md_convert_frag will insert relocations. */ } @@ -5468,7 +5903,7 @@ md_assemble (char *str) && nds32_convert_16_to_32 (stdoutput, insn.insn, NULL)))) { /* Record this one is relaxable. */ - pexp = insn.info; + expressionS *pexp = insn.info; dwarf2_emit_insn (0); if (fld) { @@ -5498,6 +5933,8 @@ md_assemble (char *str) bfd_putb16 (insn_16, out); else if (insn.opcode->isize == 2) bfd_putb16 (insn.insn, out); + + free (insn.info); return; } else if ((verbatim || !relaxing) && optimize && label) @@ -5527,18 +5964,20 @@ md_assemble (char *str) if (insn.opcode->isize == 4) bfd_putb32 (insn.insn, out); - if (insn.opcode->isize == 2) + else if (insn.opcode->isize == 2) bfd_putb16 (insn.insn, out); dwarf2_emit_insn (insn.opcode->isize); /* Compiler generating code and user assembly pseudo load-store, insert fixup here. */ - pexp = insn.info; + expressionS *pexp = insn.info; fixP = nds32_elf_record_fixup_exp (fragP, str, fld, pexp, out, &insn); /* Build relaxation pattern when relaxing is enable. */ if (relaxing) nds32_elf_build_relax_relation (fixP, pexp, out, insn.opcode, fragP, fld); + + free (insn.info); } /* md_macro_start */ @@ -5586,7 +6025,7 @@ md_section_align (segT segment, valueT size) { int align = bfd_get_section_alignment (stdoutput, segment); - return ((size + (1 << align) - 1) & -(1 << align)); + return ((size + (1 << align) - 1) & ((valueT) -1 << align)); } /* GAS will call this function when a symbol table lookup fails, before it @@ -5718,15 +6157,36 @@ nds32_relax_branch_instructions (segT segment, fragS *fragP, if (opcode == NULL) return adjust; + /* Use U4G mode for b and bal in verbatim mode because lto may combine + functions into a file. And order the file in the last when linking. + Once there is multiple definition, the same function will be kicked. + This may cause relocation truncated error. */ + if (verbatim && !nds32_pic + && (strcmp (opcode->opcode, "j") == 0 + || strcmp (opcode->opcode, "jal") == 0)) + { + fragP->fr_subtype = BR_RANGE_U4G; + if (init) + return 8; + else + return 0; + } + relax_info = hash_find (nds32_relax_info_hash, opcode->opcode); if (relax_info == NULL) return adjust; if (init) - branch_range_type = relax_info->br_range; + { + branch_range_type = relax_info->br_range; + i = BR_RANGE_S256; + } else - branch_range_type = fragP->fr_subtype; + { + branch_range_type = fragP->fr_subtype; + i = branch_range_type; + } offset = nds32_calc_branch_offset (segment, fragP, stretch, relax_info, branch_range_type); @@ -5735,15 +6195,21 @@ nds32_relax_branch_instructions (segT segment, fragS *fragP, /* If actual range is equal to instruction jump range, do nothing. */ if (real_range_type == branch_range_type) - return adjust; + { + fragP->fr_subtype = real_range_type; + return adjust; + } /* Find out proper relaxation code sequence. */ - for (i = BR_RANGE_S256; i < BR_RANGE_NUM; i++) + for (; i < BR_RANGE_NUM; i++) { if (real_range_type <= (unsigned int) i) { if (init) diff = relax_info->relax_code_size[i] - opcode->isize; + else if (real_range_type < (unsigned int) i) + diff = relax_info->relax_code_size[real_range_type] + - relax_info->relax_code_size[branch_range_type]; else diff = relax_info->relax_code_size[i] - relax_info->relax_code_size[branch_range_type]; @@ -5776,7 +6242,7 @@ nds32_relax_branch_instructions (segT segment, fragS *fragP, } /* Update fr_subtype to new NDS32_BR_RANGE. */ - fragP->fr_subtype = i; + fragP->fr_subtype = real_range_type; break; } } @@ -5815,19 +6281,19 @@ nds32_get_align (addressT address, int align) { addressT mask, new_address; - mask = ~((~0U) << align); + mask = ~((addressT) (~0) << align); new_address = (address + mask) & (~mask); return (new_address - address); } /* Check the prev_frag is legal. */ static void -invalid_prev_frag (fragS * fragP, fragS **prev_frag) +invalid_prev_frag (fragS * fragP, fragS **prev_frag, bfd_boolean relax) { addressT address; fragS *frag_start = *prev_frag; - if (!frag_start) + if (!frag_start || !relax) return; if (frag_start->last_fr_address >= fragP->last_fr_address) @@ -5895,7 +6361,7 @@ nds32_relax_frag (segT segment, fragS *fragP, long stretch ATTRIBUTE_UNUSED) static fragS *prev_frag = NULL; int adjust = 0; - invalid_prev_frag (fragP, &prev_frag); + invalid_prev_frag (fragP, &prev_frag, TRUE); if (fragP->tc_frag_data.flag & NDS32_FRAG_BRANCH) adjust = nds32_relax_branch_instructions (segment, fragP, stretch, 0); @@ -5932,7 +6398,7 @@ md_estimate_size_before_relax (fragS *fragP, segT segment) static fragS *prev_frag = NULL; int adjust = 0; - invalid_prev_frag (fragP, &prev_frag); + invalid_prev_frag (fragP, &prev_frag, FALSE); if (fragP->tc_frag_data.flag & NDS32_FRAG_BRANCH) adjust = nds32_relax_branch_instructions (segment, fragP, 0, 1); @@ -5982,6 +6448,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec, fragS *fragP) nds32_relax_fixup_info_t fixup_info[MAX_RELAX_FIX]; /* Save the 1st instruction is converted to 16 bit or not. */ unsigned int branch_size; + enum bfd_reloc_code_real final_r_type; /* Replace with gas_assert (branch_symbol != NULL); */ if (branch_symbol == NULL && !(fragP->tc_frag_data.flag & NDS32_FRAG_RELAXED)) @@ -6162,9 +6629,10 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT sec, fragS *fragP) if (fixup_info[i].r_type != 0) { + final_r_type = fixup_info[i].r_type; fixP = fix_new_exp (fragP, fr_where + fixup_info[i].offset, fixup_size, &exp, pcrel, - fixup_info[i].r_type); + final_r_type); fixP->fx_addnumber = fixP->fx_offset; } } -- 2.19.0