From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123905 invoked by alias); 10 Apr 2019 20:34:27 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 123886 invoked by uid 89); 10 Apr 2019 20:34:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-lf1-f66.google.com Received: from mail-lf1-f66.google.com (HELO mail-lf1-f66.google.com) (209.85.167.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Apr 2019 20:34:21 +0000 Received: by mail-lf1-f66.google.com with SMTP id r25so2811012lfn.13 for ; Wed, 10 Apr 2019 13:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KLvTJZcTwAEJDqkEgE/ctV/M9hYEZbk7IXKBBClu64E=; b=NlAW1SwjIJ4drLhd8DSVGj7R74bSztHY2b2kizG7JuUdcRohL9aq3PsYPdPb7gmmUY nkmSNXyMcUmKdyhg30/XrDB8nEWuitVJYcW8C4lAn3AmMZwUOucUnpQWPfMymV3mQTf/ lV0lifXBH8g6jQSXDRYB/YsfA2p+Y7mrhONYlyFecGgNJqpviNellK4Ifdx0QE7c+Qga kbnjNosNq1UrXYFlk4aO+tRlaBV6r1Nvx+Qz+Je9skXpBmXUIfVhInFHIYVYjFN4RX9G Z+7oKthpuCATp0LVZ+T5CHYEwGOedad2zvCk4dfeTrJgB25sTRW2TDXQ2i/6EBEM68GX 6umA== Return-Path: Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id r77sm7473023ljb.29.2019.04.10.13.34.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 13:34:17 -0700 (PDT) From: Max Filippov To: binutils@sourceware.org Cc: Sterling Augustine , Eric Tsai , linux-xtensa@linux-xtensa.org, Max Filippov Subject: [PATCH] xtensa: gas: clean up literal management code Date: Wed, 10 Apr 2019 20:34:00 -0000 Message-Id: <20190410203402.18285-1-jcmvbkbc@gmail.com> X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00116.txt.bz2 gas/ 2019-04-10 Max Filippov * config/tc-xtensa.c (xtensa_literal_pseudo): Drop code that has no effect. (get_literal_pool_location): Only search for the literal pool when auto litpools is used, otherwise take one recorded in the tc_segment_info_data. (xtensa_assign_litpool_addresses): New function. (xtensa_move_literals): Don't duplicate 'literal pool location required...' error message. Call xtensa_assign_litpool_addresses. --- gas/config/tc-xtensa.c | 114 +++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index 6a80e76fed8c..458cba9bae22 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -1531,7 +1531,6 @@ xtensa_literal_pseudo (int ignored ATTRIBUTE_UNUSED) emit_state state; char *p, *base_name; char c; - segT dest_seg; if (inside_directive (directive_literal)) { @@ -1547,21 +1546,10 @@ xtensa_literal_pseudo (int ignored ATTRIBUTE_UNUSED) saved_insn_labels = insn_labels; insn_labels = NULL; - /* If we are using text-section literals, then this is the right value... */ - dest_seg = now_seg; - base_name = input_line_pointer; xtensa_switch_to_literal_fragment (&state); - /* ...but if we aren't using text-section-literals, then we - need to put them in the section we just switched to. */ - if (use_literal_section || directive_state[directive_absolute_literals]) - dest_seg = now_seg; - - /* FIXME, despite the previous comments, dest_seg is unused... */ - (void) dest_seg; - /* All literals are aligned to four-byte boundaries. */ frag_align (2, 0, 0); record_alignment (now_seg, 2); @@ -4902,29 +4890,32 @@ get_expanded_loop_offset (xtensa_opcode opcode) static fragS * get_literal_pool_location (segT seg) { - struct litpool_seg *lps = litpool_seg_list.next; - struct litpool_frag *lpf; - for ( ; lps && lps->seg->id != seg->id; lps = lps->next) - ; - if (lps) + if (auto_litpools) { - for (lpf = lps->frag_list.prev; lpf->fragP; lpf = lpf->prev) - { /* Skip "candidates" for now. */ - if (lpf->fragP->fr_subtype == RELAX_LITERAL_POOL_BEGIN && - lpf->priority == 1) - return lpf->fragP; - } - /* Must convert a lower-priority pool. */ - for (lpf = lps->frag_list.prev; lpf->fragP; lpf = lpf->prev) + struct litpool_seg *lps = litpool_seg_list.next; + struct litpool_frag *lpf; + for ( ; lps && lps->seg->id != seg->id; lps = lps->next) + ; + if (lps) { - if (lpf->fragP->fr_subtype == RELAX_LITERAL_POOL_BEGIN) - return lpf->fragP; - } - /* Still no match -- try for a low priority pool. */ - for (lpf = lps->frag_list.prev; lpf->fragP; lpf = lpf->prev) - { - if (lpf->fragP->fr_subtype == RELAX_LITERAL_POOL_CANDIDATE_BEGIN) - return lpf->fragP; + for (lpf = lps->frag_list.prev; lpf->fragP; lpf = lpf->prev) + { /* Skip "candidates" for now. */ + if (lpf->fragP->fr_subtype == RELAX_LITERAL_POOL_BEGIN && + lpf->priority == 1) + return lpf->fragP; + } + /* Must convert a lower-priority pool. */ + for (lpf = lps->frag_list.prev; lpf->fragP; lpf = lpf->prev) + { + if (lpf->fragP->fr_subtype == RELAX_LITERAL_POOL_BEGIN) + return lpf->fragP; + } + /* Still no match -- try for a low priority pool. */ + for (lpf = lps->frag_list.prev; lpf->fragP; lpf = lpf->prev) + { + if (lpf->fragP->fr_subtype == RELAX_LITERAL_POOL_CANDIDATE_BEGIN) + return lpf->fragP; + } } } return seg_info (seg)->tc_segment_info_data.literal_pool_loc; @@ -11169,29 +11160,9 @@ static bfd_boolean xtensa_is_init_fini (segT seg) } static void -xtensa_move_literals (void) +xtensa_assign_litpool_addresses (void) { - seg_list *segment; - frchainS *frchain_from, *frchain_to; - fragS *search_frag, *next_frag, *literal_pool, *insert_after; - fragS **frag_splice; - emit_state state; - segT dest_seg; - fixS *fix, *next_fix, **fix_splice; - sym_list *lit; struct litpool_seg *lps; - const char *init_name = INIT_SECTION_NAME; - const char *fini_name = FINI_SECTION_NAME; - int init_name_len = strlen(init_name); - int fini_name_len = strlen(fini_name); - - mark_literal_frags (literal_head->next); - - if (use_literal_section) - return; - - /* Assign addresses (rough estimates) to the potential literal pool locations - and create new ones if the gaps are too large. */ for (lps = litpool_seg_list.next; lps; lps = lps->next) { @@ -11248,7 +11219,35 @@ xtensa_move_literals (void) } } } +} +static void +xtensa_move_literals (void) +{ + seg_list *segment; + frchainS *frchain_from, *frchain_to; + fragS *search_frag, *next_frag, *literal_pool, *insert_after; + fragS **frag_splice; + emit_state state; + segT dest_seg; + fixS *fix, *next_fix, **fix_splice; + sym_list *lit; + const char *init_name = INIT_SECTION_NAME; + const char *fini_name = FINI_SECTION_NAME; + int init_name_len = strlen(init_name); + int fini_name_len = strlen(fini_name); + + mark_literal_frags (literal_head->next); + + if (use_literal_section) + return; + + /* Assign addresses (rough estimates) to the potential literal pool locations + and create new ones if the gaps are too large. */ + + xtensa_assign_litpool_addresses (); + + /* Walk through the literal segments. */ for (segment = literal_head->next; segment; segment = segment->next) { const char *seg_name = segment_name (segment->seg); @@ -11274,12 +11273,7 @@ xtensa_move_literals (void) } if (!search_frag) - { - search_frag = frchain_from->frch_root; - as_bad_where (search_frag->fr_file, search_frag->fr_line, - _("literal pool location required for text-section-literals; specify with .literal_position")); - continue; - } + continue; gas_assert (search_frag->tc_frag_data.literal_frag->fr_subtype == RELAX_LITERAL_POOL_BEGIN); -- 2.11.0