From patchwork Wed Aug 6 17:19:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 377184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 56366140088 for ; Thu, 7 Aug 2014 03:46:30 +1000 (EST) 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:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=m29Az6laoyrilVVXYw1UcTLmHmiTHG4udkq7dIO4T4J0x26mpS0Km auw2IdUOdgEyEi3d3bWxIGvYKJ0xB6p950kC21U8wr2PjtzNZp3aWeZSamSXlMtQ q45STxTQmsDdnif8UnUuxpFbGibfpQu0xpkxgiXisHxEi80fu3ldKA= 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:cc:subject:date:message-id:in-reply-to:references; s= default; bh=aAf7VLfyskfJvIRmVCafaO/NeoQ=; b=bMqKFTZh+FW3wE1oNn6L PfoOAF1wtl5mpvIoSbjx14tWRIhoMhGktolbXoRIL/miJxdfqWxpgl/hOnsRlUjE 8sbQ2yQHe4bJsSMyf9sdWEB/ojF0W5F4MdtmBqKAzUZfZU1GNoIG9gwFNG1iN4Dl zW6c1gRETkUG3HemxKlV+ns= Received: (qmail 27026 invoked by alias); 6 Aug 2014 17:37:20 -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 26984 invoked by uid 89); 6 Aug 2014 17:37:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 06 Aug 2014 17:37:17 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XF4rq-0000EY-1y for gcc-patches@gcc.gnu.org; Wed, 06 Aug 2014 13:19:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF4rp-0000EJ-Rd for gcc-patches@gcc.gnu.org; Wed, 06 Aug 2014 13:19:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s76HJDb7007979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 6 Aug 2014 13:19:13 -0400 Received: from c64.redhat.com (vpn-239-139.phx2.redhat.com [10.3.239.139]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s76HJ2nr030913; Wed, 6 Aug 2014 13:19:12 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 017/236] Add subclasses for the various kinds of instruction Date: Wed, 6 Aug 2014 13:19:56 -0400 Message-Id: <1407345815-14551-18-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1407345815-14551-1-git-send-email-dmalcolm@redhat.com> References: <1407345815-14551-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-IsSubscribed: yes gcc/ * coretypes.h (class rtx_real_insn): Add forward declaration. (class rtx_debug_insn): Likewise. (class rtx_nonjump_insn): Likewise. (class rtx_jump_insn): Likewise. (class rtx_call_insn): Likewise. (class rtx_jump_table_data): Likewise. (class rtx_barrier): Likewise. (class rtx_code_label): Likewise. (class rtx_note): Likewise. * rtl.h (class rtx_real_insn): New, a subclass of rtx_insn, adding the invariant INSN_P (X). (class rtx_debug_insn): New, a subclass of rtx_real_insn, adding the invariant DEBUG_INSN_P (X). (class rtx_nonjump_insn): New, a subclass of rtx_real_insn, adding the invariant NONJUMP_INSN_P (X). (class rtx_jump_insn): New, a subclass of rtx_real_insn, adding the invariant JUMP_P (X). (class rtx_call_insn): New, a subclass of rtx_real_insn, adding the invariant CALL_P (X). (class rtx_jump_table): New, a subclass of rtx_insn, adding the invariant JUMP_TABLE_DATA_P (X). (class rtx_barrier): New, a subclass of rtx_insn, adding the invariant BARRIER_P (X). (class rtx_code_label): New, a subclass of rtx_real_insn, adding the invariant LABEL_P (X). (class rtx_note): New, a subclass of rtx_real_insn, adding the invariant NOTE_P(X). (is_a_helper ::test): New. (is_a_helper ::test): New. (is_a_helper ::test): New. (is_a_helper ::test): New. (is_a_helper ::test): New. (is_a_helper ::test): New functions, overloaded for both rtx and rtx_insn *. (is_a_helper ::test): New. (is_a_helper ::test): New functions, overloaded for both rtx and rtx_insn *. (is_a_helper ::test): New. --- gcc/coretypes.h | 11 +++- gcc/rtl.h | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+), 1 deletion(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index f22b980..17dc0e6 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -57,10 +57,19 @@ typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; /* Subclasses of rtx_def, using indentation to show the class - hierarchy. + hierarchy, along with the relevant invariant. Where possible, keep this list in the same order as in rtl.def. */ class rtx_def; class rtx_insn; + class rtx_real_insn; /* INSN_P (X) */ + class rtx_debug_insn; /* DEBUG_INSN_P (X) */ + class rtx_nonjump_insn; /* NONJUMP_INSN_P (X) */ + class rtx_jump_insn; /* JUMP_P (X) */ + class rtx_call_insn; /* CALL_P (X) */ + class rtx_jump_table_data; /* JUMP_TABLE_DATA_P (X) */ + class rtx_barrier; /* BARRIER_P (X) */ + class rtx_code_label; /* LABEL_P (X) */ + class rtx_note; /* NOTE_P (X) */ struct rtvec_def; typedef struct rtvec_def *rtvec; diff --git a/gcc/rtl.h b/gcc/rtl.h index 5936829..31df60f 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -421,6 +421,110 @@ class GTY(()) rtx_insn : public rtx_def */ }; +class GTY(()) rtx_real_insn : public rtx_insn +{ + /* No extra fields, but adds the invariant: + INSN_P (X) + i.e. that we have a "real" insn, one of: + (NONJUMP_INSN_P (X) || DEBUG_INSN_P (X) || JUMP_P (X) || CALL_P (X)) + */ +}; + +/* Subclasses of rtx_real_insn. */ + +class GTY(()) rtx_debug_insn : public rtx_real_insn +{ + /* No extra fields, but adds the invariant: + DEBUG_INSN_P (X) aka (GET_CODE (X) == DEBUG_INSN) + i.e. an annotation for tracking variable assignments. + + This is an instance of: + DEF_RTL_EXPR(DEBUG_INSN, "debug_insn", "uuBeiie", RTX_INSN) + from rtl.def. */ +}; + +class GTY(()) rtx_nonjump_insn : public rtx_real_insn +{ + /* No extra fields, but adds the invariant: + NONJUMP_INSN_P (X) aka (GET_CODE (X) == INSN) + i.e an instruction that cannot jump. + + This is an instance of: + DEF_RTL_EXPR(INSN, "insn", "uuBeiie", RTX_INSN) + from rtl.def. */ +}; + +class GTY(()) rtx_jump_insn : public rtx_real_insn +{ + /* No extra fields, but adds the invariant: + JUMP_P (X) aka (GET_CODE (X) == JUMP_INSN) + i.e. an instruction that can possibly jump. + + This is an instance of: + DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "uuBeiie0", RTX_INSN) + from rtl.def. */ +}; + +class GTY(()) rtx_call_insn : public rtx_real_insn +{ + /* No extra fields, but adds the invariant: + CALL_P (X) aka (GET_CODE (X) == CALL_INSN) + i.e. an instruction that can possibly call a subroutine + but which will not change which instruction comes next + in the current function. + + This is an instance of: + DEF_RTL_EXPR(CALL_INSN, "call_insn", "uuBeiiee", RTX_INSN) + from rtl.def. */ +}; + +/* Subclasses of rtx_insn not derived from rtx_real_insn. */ + +class GTY(()) rtx_jump_table_data : public rtx_insn +{ + /* No extra fields, but adds the invariant: + JUMP_TABLE_DATA_P (X) aka (GET_CODE (INSN) == JUMP_TABLE_DATA) + i.e. a data for a jump table, considered an instruction for + historical reasons. + + This is an instance of: + DEF_RTL_EXPR(JUMP_TABLE_DATA, "jump_table_data", "uuBe0000", RTX_INSN) + from rtl.def. */ +}; + +class GTY(()) rtx_barrier : public rtx_insn +{ + /* No extra fields, but adds the invariant: + BARRIER_P (X) aka (GET_CODE (X) == BARRIER) + i.e. a marker that indicates that control will not flow through. + + This is an instance of: + DEF_RTL_EXPR(BARRIER, "barrier", "uu00000", RTX_EXTRA) + from rtl.def. */ +}; + +class GTY(()) rtx_code_label : public rtx_insn +{ + /* No extra fields, but adds the invariant: + LABEL_P (X) aka (GET_CODE (X) == CODE_LABEL) + i.e. a label in the assembler. + + This is an instance of: + DEF_RTL_EXPR(CODE_LABEL, "code_label", "uuB00is", RTX_EXTRA) + from rtl.def. */ +}; + +class GTY(()) rtx_note : public rtx_insn +{ + /* No extra fields, but adds the invariant: + NOTE_P(X) aka (GET_CODE (X) == NOTE) + i.e. a note about the corresponding source code. + + This is an instance of: + DEF_RTL_EXPR(NOTE, "note", "uuB0ni", RTX_EXTRA) + from rtl.def. */ +}; + /* The size in bytes of an rtx header (code, mode and flags). */ #define RTX_HDR_SIZE offsetof (struct rtx_def, u) @@ -606,6 +710,102 @@ is_a_helper ::test (const_rtx rt) || LABEL_P (rt)); } +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return INSN_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return DEBUG_INSN_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return NONJUMP_INSN_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return JUMP_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return CALL_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return JUMP_TABLE_DATA_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx_insn *insn) +{ + return JUMP_TABLE_DATA_P (insn); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return BARRIER_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return LABEL_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx_insn *insn) +{ + return LABEL_P (insn); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx rt) +{ + return NOTE_P (rt); +} + +template <> +template <> +inline bool +is_a_helper ::test (rtx_insn *insn) +{ + return NOTE_P (insn); +} + /* Predicate yielding nonzero iff X is a return or simple_return. */ #define ANY_RETURN_P(X) \ (GET_CODE (X) == RETURN || GET_CODE (X) == SIMPLE_RETURN)