From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85605 invoked by alias); 7 Aug 2019 16:15:35 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 85204 invoked by uid 89); 7 Aug 2019 16:15:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=rtx_code, cross-compilers, crosscompilers, tilegx X-HELO: mail-qk1-f173.google.com Received: from mail-qk1-f173.google.com (HELO mail-qk1-f173.google.com) (209.85.222.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Aug 2019 16:15:33 +0000 Received: by mail-qk1-f173.google.com with SMTP id 201so66197634qkm.9 for ; Wed, 07 Aug 2019 09:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:subject:message-id:mime-version :content-disposition:user-agent; bh=aij7UqaOeKeG1wxNbaGAPuYQ9G0Kqwk7+D3Pk0y57CA=; b=iirAt4CAgM01RxmCbYXi+QbWqa8pBtuhP6dYhrkNmBochkbOegq32NU2/HPGhEHN39 AjlcMMtybpXY4puTootPvHNv6GBP7zMpYIBQD5LtbUA73wYWRaA+6mHFPiVo2d1bjKQq PhnF5k9IdxUXVj0uHaIaiAErTNdqWb1GK7ahgB5vSx5mGPjoAnf9/zD5iF7SGUQmp3ql bq9oscz/lsmLFqEaSydue6PNKSUOX3gjGI3db7pSzJr8UxJkPyqcXkym0wsVuB1B4oLF 89tvvZucG1lKmJ2K9BHKxuieulxfeurj0mz4/1LtzxBtN1nTzQ0WAIKMUlys1dI+fLjH qFBA== Return-Path: Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id p3sm58889599qta.12.2019.08.07.09.15.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 09:15:30 -0700 (PDT) From: Arvind Sankar Date: Wed, 07 Aug 2019 16:15:00 -0000 To: gcc@gcc.gnu.org Subject: Use predicates for RTL objects Message-ID: <20190807161528.GA3326377@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-08/txt/msg00024.txt.bz2 Hi, I have posted a patch series [1] for converting some of the RTL code to use predicate macros, as described in the suggestions for beginner GCC projects [2]. Segher was kind enough to give some comments on the initial posting [3]. The code has been bootstrapped natively on x86_64, and I have built cross-compilers for all targets except tilegx which gave build errors even on trunk. The compiler object files are identical with trunk except for *-checksum.o and string tables in build/gen*.o which change from GET_CODE (..) == .. etc to the predicate macro. Not all possible changes have been made yet, I figured I'd send this out to check first. I am hoping one of the maintainers will be able to take some time to review the patches -- a few are quite large but are mechanical. I would also like to get some comments on the following idea to make the code checks more readable: I am thinking of adding bool rtx_def::is_a (enum rtx_code) const This would allow us to make all the rtx_code comparisons more readable without having to define individual macros for each. i.e., REG_P (x) => x->is_a (REG) GET_CODE (x) == PLUS => x->is_a (PLUS) GET_CODE (PATTERN (x)) == SEQUENCE => PATTERN (x)->is_a (SEQUENCE) More complex predicates could be left as macros or additional methods could be defined like rtx_def::is_a_nondebug_insn etc. I think this should mostly be an improvement, although the comparisons around INSN may become slightly more confusing: currently, INSN_P (x) is different from is_a (x), and using something like x->is_a_insn () for the former would probably increase confusion. Thanks. [1] https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00327.html [2] https://gcc.gnu.org/projects/beginner.html [3] https://gcc.gnu.org/ml/gcc-patches/2019-08/msg00171.html