From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2437 invoked by alias); 25 Apr 2006 17:19:30 -0000 Received: (qmail 2396 invoked by uid 22791); 25 Apr 2006 17:19:28 -0000 X-Spam-Check-By: sourceware.org Received: from hq.tensilica.com (HELO mailapp.tensilica.com) (65.205.227.29) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Apr 2006 17:19:24 +0000 Received: from localhost ([127.0.0.1] ident=amavis) by mailapp.tensilica.com with esmtp (Exim 4.34) id 1FYRC6-0001Hi-CN for binutils@sources.redhat.com; Tue, 25 Apr 2006 10:19:22 -0700 Received: from mailapp.tensilica.com ([127.0.0.1]) by localhost (mailapp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 04091-09 for ; Tue, 25 Apr 2006 10:19:22 -0700 (PDT) Received: from heron.hq.tensilica.com ([192.168.11.123]) by mailapp.tensilica.com with esmtp (Exim 4.34) id 1FYRC6-0001Hc-2G for binutils@sources.redhat.com; Tue, 25 Apr 2006 10:19:22 -0700 Received: from [192.168.11.123] (heron.hq.tensilica.com [192.168.11.123]) by heron.hq.tensilica.com (8.13.6/8.13.6) with ESMTP id k3PHJLlM011537 for ; Tue, 25 Apr 2006 10:19:21 -0700 Message-ID: <444E5A19.9080400@tensilica.com> Date: Tue, 25 Apr 2006 17:35:00 -0000 From: Bob Wilson User-Agent: Thunderbird 1.5 (X11/20060313) MIME-Version: 1.0 To: binutils@sources.redhat.com Subject: [Xtensa] add support for wide branches with 15-bit offsets Content-Type: multipart/mixed; boundary="------------070305030802050600060006" Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00346.txt.bz2 This is a multi-part message in MIME format. --------------070305030802050600060006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 978 The change on 2005-12-30 to add support for Xtensa wide branches was incomplete: these wide branch opcodes may come in two different sizes, with either 15-bit or 18-bit offsets, but the previous patch only supported the 18-bit versions. This patch generalizes the assembler to handle the 15-bit versions as well. Tested with an xtensa-elf build, as well as with several non-default Xtensa configurations that include both versions of the wide branches. Committed on the mainline and 2.17 branch. (It's debatable whether this is a new feature or bug fix, but I decided to put it on the branch anyway since I'd rather not have a half-baked feature in the release.) 2006-04-25 Bob Wilson * config/xtensa-relax.c (widen_spec_list): Use new "WIDE." syntax instead of hardcoded opcodes with ".w18" suffixes. (wide_branch_opcode): New. (build_transition): Use it to check for wide branch opcodes with either ".w18" or ".w15" suffixes. --------------070305030802050600060006 Content-Type: text/x-patch; name="gas-w15-branch.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gas-w15-branch.diff" Content-length: 5734 Index: config/xtensa-relax.c =================================================================== RCS file: /cvs/src/src/gas/config/xtensa-relax.c,v retrieving revision 1.11 diff -u -p -r1.11 xtensa-relax.c --- config/xtensa-relax.c 25 Apr 2006 15:41:16 -0000 1.11 +++ config/xtensa-relax.c 25 Apr 2006 17:05:24 -0000 @@ -349,30 +349,30 @@ static string_pattern_pair widen_spec_li table since they are more efficient than the branch-around relaxations. */ - {"beqz %as,%label ? IsaUseWideBranches", "beqz.w18 %as,%label"}, - {"bnez %as,%label ? IsaUseWideBranches", "bnez.w18 %as,%label"}, - {"bgez %as,%label ? IsaUseWideBranches", "bgez.w18 %as,%label"}, - {"bltz %as,%label ? IsaUseWideBranches", "bltz.w18 %as,%label"}, - {"beqi %as,%imm,%label ? IsaUseWideBranches", "beqi.w18 %as,%imm,%label"}, - {"bnei %as,%imm,%label ? IsaUseWideBranches", "bnei.w18 %as,%imm,%label"}, - {"bgei %as,%imm,%label ? IsaUseWideBranches", "bgei.w18 %as,%imm,%label"}, - {"blti %as,%imm,%label ? IsaUseWideBranches", "blti.w18 %as,%imm,%label"}, - {"bgeui %as,%imm,%label ? IsaUseWideBranches", "bgeui.w18 %as,%imm,%label"}, - {"bltui %as,%imm,%label ? IsaUseWideBranches", "bltui.w18 %as,%imm,%label"}, - {"bbci %as,%imm,%label ? IsaUseWideBranches", "bbci.w18 %as,%imm,%label"}, - {"bbsi %as,%imm,%label ? IsaUseWideBranches", "bbsi.w18 %as,%imm,%label"}, - {"beq %as,%at,%label ? IsaUseWideBranches", "beq.w18 %as,%at,%label"}, - {"bne %as,%at,%label ? IsaUseWideBranches", "bne.w18 %as,%at,%label"}, - {"bge %as,%at,%label ? IsaUseWideBranches", "bge.w18 %as,%at,%label"}, - {"blt %as,%at,%label ? IsaUseWideBranches", "blt.w18 %as,%at,%label"}, - {"bgeu %as,%at,%label ? IsaUseWideBranches", "bgeu.w18 %as,%at,%label"}, - {"bltu %as,%at,%label ? IsaUseWideBranches", "bltu.w18 %as,%at,%label"}, - {"bany %as,%at,%label ? IsaUseWideBranches", "bany.w18 %as,%at,%label"}, - {"bnone %as,%at,%label ? IsaUseWideBranches", "bnone.w18 %as,%at,%label"}, - {"ball %as,%at,%label ? IsaUseWideBranches", "ball.w18 %as,%at,%label"}, - {"bnall %as,%at,%label ? IsaUseWideBranches", "bnall.w18 %as,%at,%label"}, - {"bbc %as,%at,%label ? IsaUseWideBranches", "bbc.w18 %as,%at,%label"}, - {"bbs %as,%at,%label ? IsaUseWideBranches", "bbs.w18 %as,%at,%label"}, + {"beqz %as,%label ? IsaUseWideBranches", "WIDE.beqz %as,%label"}, + {"bnez %as,%label ? IsaUseWideBranches", "WIDE.bnez %as,%label"}, + {"bgez %as,%label ? IsaUseWideBranches", "WIDE.bgez %as,%label"}, + {"bltz %as,%label ? IsaUseWideBranches", "WIDE.bltz %as,%label"}, + {"beqi %as,%imm,%label ? IsaUseWideBranches", "WIDE.beqi %as,%imm,%label"}, + {"bnei %as,%imm,%label ? IsaUseWideBranches", "WIDE.bnei %as,%imm,%label"}, + {"bgei %as,%imm,%label ? IsaUseWideBranches", "WIDE.bgei %as,%imm,%label"}, + {"blti %as,%imm,%label ? IsaUseWideBranches", "WIDE.blti %as,%imm,%label"}, + {"bgeui %as,%imm,%label ? IsaUseWideBranches", "WIDE.bgeui %as,%imm,%label"}, + {"bltui %as,%imm,%label ? IsaUseWideBranches", "WIDE.bltui %as,%imm,%label"}, + {"bbci %as,%imm,%label ? IsaUseWideBranches", "WIDE.bbci %as,%imm,%label"}, + {"bbsi %as,%imm,%label ? IsaUseWideBranches", "WIDE.bbsi %as,%imm,%label"}, + {"beq %as,%at,%label ? IsaUseWideBranches", "WIDE.beq %as,%at,%label"}, + {"bne %as,%at,%label ? IsaUseWideBranches", "WIDE.bne %as,%at,%label"}, + {"bge %as,%at,%label ? IsaUseWideBranches", "WIDE.bge %as,%at,%label"}, + {"blt %as,%at,%label ? IsaUseWideBranches", "WIDE.blt %as,%at,%label"}, + {"bgeu %as,%at,%label ? IsaUseWideBranches", "WIDE.bgeu %as,%at,%label"}, + {"bltu %as,%at,%label ? IsaUseWideBranches", "WIDE.bltu %as,%at,%label"}, + {"bany %as,%at,%label ? IsaUseWideBranches", "WIDE.bany %as,%at,%label"}, + {"bnone %as,%at,%label ? IsaUseWideBranches", "WIDE.bnone %as,%at,%label"}, + {"ball %as,%at,%label ? IsaUseWideBranches", "WIDE.ball %as,%at,%label"}, + {"bnall %as,%at,%label ? IsaUseWideBranches", "WIDE.bnall %as,%at,%label"}, + {"bbc %as,%at,%label ? IsaUseWideBranches", "WIDE.bbc %as,%at,%label"}, + {"bbs %as,%at,%label ? IsaUseWideBranches", "WIDE.bbs %as,%at,%label"}, /* Widening branch comparisons eq/ne to zero. Prefer relaxing to narrow branches if the density option is available. */ @@ -1554,6 +1554,31 @@ transition_applies (insn_pattern *initia } +static bfd_boolean +wide_branch_opcode (const char *opcode_name, + char *suffix, + xtensa_opcode *popcode) +{ + xtensa_isa isa = xtensa_default_isa; + xtensa_opcode opcode; + static char wbr_name_buf[20]; + + if (strncmp (opcode_name, "WIDE.", 5) != 0) + return FALSE; + + strcpy (wbr_name_buf, opcode_name + 5); + strcat (wbr_name_buf, suffix); + opcode = xtensa_opcode_lookup (isa, wbr_name_buf); + if (opcode != XTENSA_UNDEFINED) + { + *popcode = opcode; + return TRUE; + } + + return FALSE; +} + + static TransitionRule * build_transition (insn_pattern *initial_insn, insn_repl *replace_insns, @@ -1731,13 +1756,19 @@ build_transition (insn_pattern *initial_ else { bi->typ = INSTR_INSTR; - bi->opcode = xtensa_opcode_lookup (isa, r->t.opcode_name); + if (wide_branch_opcode (opcode_name, ".w18", &bi->opcode) + || wide_branch_opcode (opcode_name, ".w15", &bi->opcode)) + opcode_name = xtensa_opcode_name (isa, bi->opcode); + else + bi->opcode = xtensa_opcode_lookup (isa, opcode_name); + if (bi->opcode == XTENSA_UNDEFINED) { as_warn (_("invalid opcode '%s' in transition rule '%s'"), - r->t.opcode_name, to_string); + opcode_name, to_string); return NULL; } + /* Check for the right number of ops. */ if (xtensa_opcode_num_operands (isa, bi->opcode) != (int) operand_count) --------------070305030802050600060006--