From patchwork Mon Aug 21 09:51:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 110509 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp3845357obb; Mon, 21 Aug 2017 02:51:57 -0700 (PDT) X-Received: by 10.84.143.165 with SMTP id 34mr18621181plz.104.1503309116968; Mon, 21 Aug 2017 02:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503309116; cv=none; d=google.com; s=arc-20160816; b=Cpp6lfyLMUnBZeIVDNJbkrzc7ghuV2i3ptD5ABM2hW0LW8iLOb+i8GiH6wq/WJhPAi vDFsq/GZWXuCIDfirKpzNc069bsqYIIcz4ZKMWYoGLP9tx0fOkKLn7iGq5K7mFgHXQKd sT1FvHroNisYbEEs4frpq10NTdUqzfTdyYTCAxS9vt9zFvKJ+maB7bg/5sok9tbi3+n9 UpKPcdmZf1grcW9QQy4CNXSuHmjfsr8X64jZC+7vGuaGYbBw6pRQ4L8ZQSAyH8nFB7hK ClJ1BxXEH0b0SMJreHlQtnn0JTdjzanNX+s8iCszuAH5KOb7Nyfz9iyvRauS+gGrBGhn zCbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=RogmCWGaOvabd4+XpHwdAogkj1YFfw9vpizEtAm/FgE=; b=yruCv6CySaIGq23gvb28DioCHuDERslXnN1VYeD0mHkcG0O2aTx6PaSt1SmZAYndQl pTkOmUK7DUcAw0uMUBgSQfDQQfgzPAffa/cvz9KxSTV5KCgyqGCffqZ8jzrpGJ7BpqXH AGdYSVXNN11lUzYvvVGCs8Fwxo99CbBdtAwhcHsa7+T2vulbN8hod4aJUMp59ZfFtkJo IMhjYz2mceTnjt6ITYPsVOH4rHL7Nc888Y78dvF81VzTLndiH1r9VPHaO5btzSqA+2q7 ryndyb3QTtU2NcFnZ5dLCpqaaE/ZAoGltkfFlrSjW5BSwoG0V331L8l3vJH5rjeius1I MmRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=N/95IJpN; spf=pass (google.com: domain of gcc-patches-return-460624-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460624-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u3si7735941plb.319.2017.08.21.02.51.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 02:51:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460624-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=N/95IJpN; spf=pass (google.com: domain of gcc-patches-return-460624-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460624-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=cCyaZk+RS9tR4CWNfmX181j5F1wOgReS96RxK9YGGLeUwekTQgv2Q p6f5nYPRseDIc2/i7SNtfse/2ZOnWF2OS8SSXv1+q0YmpmQytblHfiM86HdI386x udgIcXuy6ZuHH3ZW8O4I07fHEClI2bbzJAE+fjMeLW6WFbO3OeRQWw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=2UkHORO5tUrxvitExk1Mqyc7O4c=; b=N/95IJpN92qv13Z7InjA ksX/4W694yR1e0R+f2tRZTZmhuakp8RHOPZ/OPx8weSqn+oVXUfIET004fYByuNR 6LfYE6XMJXLCnYYed6ufQqWZk1DEd8IBs79yM58JmuC+VChlOqgawgAGJylwmxrQ Mq+gIdFS7yRtzcbT0oDDw40= Received: (qmail 56494 invoked by alias); 21 Aug 2017 09:51:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 55606 invoked by uid 89); 21 Aug 2017 09:51:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, MEDICAL_SUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=angle, 2019, 13177, subjected X-HELO: mail-wr0-f175.google.com Received: from mail-wr0-f175.google.com (HELO mail-wr0-f175.google.com) (209.85.128.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Aug 2017 09:51:38 +0000 Received: by mail-wr0-f175.google.com with SMTP id z91so92804165wrc.4 for ; Mon, 21 Aug 2017 02:51:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=RogmCWGaOvabd4+XpHwdAogkj1YFfw9vpizEtAm/FgE=; b=QEcDJH7KbDq6hm5+bsLQrMEb6D0GKV6Dlcd8K3X7iPitOfR/5lO5Gbq4oRbBP5xB68 IL0Oh0UlUCqPcw6yOtpPRMEzldHh9PwXXj9puYsmYIBlKf6XMVxdMIAhsXKobf+hytFv GqWeZIjgpvfjKPD4RQSJZJU5u5o9aG+wM3EOIfCVPiEcX0qMaVKhnrPKfJqEM9dZvLWL Om/haH7p5hdhqyTdlrTJSGw1xMnQuHcrYw/b4AqEYHewhwhaESwoLcPB7CDa0yQY4YGC b+5ISk0D0V51UZAKG86ytNMIWtUtGRPLfd1O3rpoy1qiLN2OIiVZ5lnAvsZtALdNoE/f RYmg== X-Gm-Message-State: AHYfb5iiJWQB3Fm9iBKgbGBj2FthotA3u1Jcov7bVqfte6bsorOC1nKp xzsGJOx5fn4fJqfZLBCmyw== X-Received: by 10.28.69.157 with SMTP id l29mr6293504wmi.38.1503309095921; Mon, 21 Aug 2017 02:51:35 -0700 (PDT) Received: from localhost (92.40.249.204.threembb.co.uk. [92.40.249.204]) by smtp.gmail.com with ESMTPSA id s4sm17548628wrc.13.2017.08.21.02.51.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2017 02:51:34 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [committed] Pass rtx and index to read-md.c iterator routines Date: Mon, 21 Aug 2017 10:51:29 +0100 Message-ID: <87o9r9dza6.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 The read-md.c iterator callbacks previously used a void * to record the position at which the iterator value should be installed. This doesn't scale easily to the SUBREG_BYTE representation used by a later patch, so this patch replaces the void * with both an rtx and an operand number. The operand number is ignored for modes and codes. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Applied. Richard 2017-08-21 Richard Sandiford Alan Hayward David Sherwood gcc/ * read-md.h (md_reader::record_potential_iterator_use): Replace pointer argument with an rtx and an index. * read-rtl.c (iterator_group::apply_iterator): Likewise. (apply_mode_iterator): Likewise. (apply_code_iterator): Likewise. (apply_int_iterator): Likewise. (apply_subst_iterator): Likewise. (record_iterator_use): Likewise. (record_attribute_use): Likewise. (md_reader::record_potential_iterator_use): Likewise. Update calls to record_iterator_use and apply_iterator. (iterator_use): Replace ptr with x and index. (attribute_use): Likewise. (apply_attribute_uses): Update calls to apply_iterator. (apply_iterators): Likewise. Update initialization of iterator_use. (rtx_reader::read_rtx_code): Update calls to record_iterator_use and record_potential_iterator_use. (rtx_reader::read_rtx_operand): Likewise. Index: gcc/read-md.h =================================================================== --- gcc/read-md.h 2017-02-23 19:54:20.000000000 +0000 +++ gcc/read-md.h 2017-08-21 10:47:28.924056316 +0100 @@ -162,7 +162,8 @@ struct enum_type { rtx copy_rtx_for_iterators (rtx original); void read_conditions (); void record_potential_iterator_use (struct iterator_group *group, - void *ptr, const char *name); + rtx x, unsigned int index, + const char *name); struct mapping *read_mapping (struct iterator_group *group, htab_t table); const char *get_top_level_filename () const { return m_toplevel_fname; } Index: gcc/read-rtl.c =================================================================== --- gcc/read-rtl.c 2017-02-23 19:54:15.000000000 +0000 +++ gcc/read-rtl.c 2017-08-21 10:47:28.924056316 +0100 @@ -76,8 +76,10 @@ struct iterator_group { return its integer value. */ int (*find_builtin) (const char *); - /* Make the given pointer use the given iterator value. */ - void (*apply_iterator) (void *, int); + /* Make the given rtx use the iterator value given by the third argument. + If the iterator applies to operands, the second argument gives the + operand index, otherwise it is ignored. */ + void (*apply_iterator) (rtx, unsigned int, int); }; /* Records one use of an iterator. */ @@ -85,8 +87,11 @@ struct iterator_use { /* The iterator itself. */ struct mapping *iterator; - /* The location of the use, as passed to the apply_iterator callback. */ - void *ptr; + /* The location of the use, as passed to the apply_iterator callback. + The index is the number of the operand that used the iterator + if applicable, otherwise it is ignored. */ + rtx x; + unsigned int index; }; /* Records one use of an attribute (the "<[iterator:]attribute>" syntax) @@ -98,8 +103,11 @@ struct attribute_use { /* The name of the attribute, possibly with an "iterator:" prefix. */ const char *value; - /* The location of the use, as passed to GROUP's apply_iterator callback. */ - void *ptr; + /* The location of the use, as passed to GROUP's apply_iterator callback. + The index is the number of the operand that used the iterator + if applicable, otherwise it is ignored. */ + rtx x; + unsigned int index; }; /* This struct is used to link subst_attr named ATTR_NAME with @@ -150,9 +158,9 @@ find_mode (const char *name) } static void -apply_mode_iterator (void *loc, int mode) +apply_mode_iterator (rtx x, unsigned int, int mode) { - PUT_MODE ((rtx) loc, (machine_mode) mode); + PUT_MODE (x, (machine_mode) mode); } /* In compact dumps, the code of insns is prefixed with "c", giving "cinsn", @@ -193,9 +201,9 @@ find_code (const char *name) } static void -apply_code_iterator (void *loc, int code) +apply_code_iterator (rtx x, unsigned int, int code) { - PUT_CODE ((rtx) loc, (enum rtx_code) code); + PUT_CODE (x, (enum rtx_code) code); } /* Implementations of the iterator_group callbacks for ints. */ @@ -212,9 +220,9 @@ find_int (const char *name) } static void -apply_int_iterator (void *loc, int value) +apply_int_iterator (rtx x, unsigned int index, int value) { - *(int *)loc = value; + XINT (x, index) = value; } #ifdef GENERATOR_FILE @@ -222,14 +230,13 @@ apply_int_iterator (void *loc, int value /* This routine adds attribute or does nothing depending on VALUE. When VALUE is 1, it does nothing - the first duplicate of original template is kept untouched when it's subjected to a define_subst. - When VALUE isn't 1, the routine modifies RTL-template LOC, adding + When VALUE isn't 1, the routine modifies RTL-template RT, adding attribute, named exactly as define_subst, which later will be applied. If such attribute has already been added, then no the routine has no effect. */ static void -apply_subst_iterator (void *loc, int value) +apply_subst_iterator (rtx rt, unsigned int, int value) { - rtx rt = (rtx)loc; rtx new_attr; rtvec attrs_vec, new_attrs_vec; int i; @@ -516,7 +523,7 @@ apply_attribute_uses (void) v = map_attr_string (ause->value); if (!v) fatal_with_file_and_line ("unknown iterator value `%s'", ause->value); - ause->group->apply_iterator (ause->ptr, + ause->group->apply_iterator (ause->x, ause->index, ause->group->find_builtin (v->string)); } } @@ -583,7 +590,8 @@ apply_iterators (rtx original, vec if (iuse->iterator->group == &substs) continue; v = iuse->iterator->current_value; - iuse->iterator->group->apply_iterator (iuse->ptr, v->number); + iuse->iterator->group->apply_iterator (iuse->x, iuse->index, + v->number); condition = rtx_reader_ptr->join_c_conditions (condition, v->string); } apply_attribute_uses (); @@ -598,9 +606,11 @@ apply_iterators (rtx original, vec v = iuse->iterator->current_value; if (iuse->iterator->group == &substs) { - iuse->ptr = x; + iuse->x = x; + iuse->index = 0; current_iterator_name = iuse->iterator->name; - iuse->iterator->group->apply_iterator (iuse->ptr, v->number); + iuse->iterator->group->apply_iterator (iuse->x, iuse->index, + v->number); } } /* Add the new rtx to the end of the queue. */ @@ -860,33 +870,36 @@ validate_const_wide_int (const char *str fatal_with_file_and_line ("invalid hex constant \"%s\"\n", string); } -/* Record that PTR uses iterator ITERATOR. */ +/* Record that X uses iterator ITERATOR. If the use is in an operand + of X, INDEX is the index of that operand, otherwise it is ignored. */ static void -record_iterator_use (struct mapping *iterator, void *ptr) +record_iterator_use (struct mapping *iterator, rtx x, unsigned int index) { - struct iterator_use iuse = {iterator, ptr}; + struct iterator_use iuse = {iterator, x, index}; iterator_uses.safe_push (iuse); } -/* Record that PTR uses attribute VALUE, which must match a built-in - value from group GROUP. */ +/* Record that X uses attribute VALUE, which must match a built-in + value from group GROUP. If the use is in an operand of X, INDEX + is the index of that operand, otherwise it is ignored. */ static void -record_attribute_use (struct iterator_group *group, void *ptr, - const char *value) +record_attribute_use (struct iterator_group *group, rtx x, + unsigned int index, const char *value) { - struct attribute_use ause = {group, value, ptr}; + struct attribute_use ause = {group, value, x, index}; attribute_uses.safe_push (ause); } /* Interpret NAME as either a built-in value, iterator or attribute - for group GROUP. PTR is the value to pass to GROUP's apply_iterator - callback. */ + for group GROUP. X and INDEX are the values to pass to GROUP's + apply_iterator callback. */ void md_reader::record_potential_iterator_use (struct iterator_group *group, - void *ptr, const char *name) + rtx x, unsigned int index, + const char *name) { struct mapping *m; size_t len; @@ -897,15 +910,16 @@ md_reader::record_potential_iterator_use /* Copy the attribute string into permanent storage, without the angle brackets around it. */ obstack_grow0 (&m_string_obstack, name + 1, len - 2); - record_attribute_use (group, ptr, XOBFINISH (&m_string_obstack, char *)); + record_attribute_use (group, x, index, + XOBFINISH (&m_string_obstack, char *)); } else { m = (struct mapping *) htab_find (group->iterators, &name); if (m != 0) - record_iterator_use (m, ptr); + record_iterator_use (m, x, index); else - group->apply_iterator (ptr, group->find_builtin (name)); + group->apply_iterator (x, index, group->find_builtin (name)); } } @@ -1288,7 +1302,7 @@ rtx_reader::read_rtx_code (const char *c } if (iterator) - record_iterator_use (iterator, return_rtx); + record_iterator_use (iterator, return_rtx, 0); /* Check for flags. */ read_flags (return_rtx); @@ -1317,7 +1331,7 @@ rtx_reader::read_rtx_code (const char *c if (c == ':') { read_name (&name); - record_potential_iterator_use (&modes, return_rtx, name.string); + record_potential_iterator_use (&modes, return_rtx, 0, name.string); } else unread_char (c); @@ -1555,7 +1569,7 @@ rtx_reader::read_rtx_operand (rtx return m = 0; } if (m != 0) - record_iterator_use (m, return_rtx); + record_iterator_use (m, return_rtx, 0); } #endif /* #ifdef GENERATOR_FILE */ @@ -1596,8 +1610,7 @@ rtx_reader::read_rtx_operand (rtx return case 'n': /* Can be an iterator or an integer constant. */ read_name (&name); - record_potential_iterator_use (&ints, &XINT (return_rtx, idx), - name.string); + record_potential_iterator_use (&ints, return_rtx, idx, name.string); break; case 'r':