From patchwork Fri Dec 2 02:00:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 701772 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 3tVGkL1J3yz9sfH for ; Fri, 2 Dec 2016 12:28:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bVDPzZki"; dkim-atps=neutral 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=DfiRByNR8WseBvFSaQcdQ0yQySuEg3a/zdnpQUQmcOWexmNu1UUtI xTHkkD/bFPyBgPxhFQxy6UKhmZ/JvFGpLfltt8Hy7NFrqo/9P8YPRKisb3qzA3FL xMkvDYqHzXRbj92ow6VdN1+qtVMa7rb6xO7yLQ5usojRmUB7QoiEkA= 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=qnQt0sR+n4HN5sVfHxZsziwXCCI=; b=bVDPzZkiBRSEPbfqzC85 R+Qp/GnY37kIaC/vLx7RGd6tsnHYEMoWFQ5/TyIhXK/rQ+yf++h1zkTlvWxMsf9e PviEKvL4eWNfK/2pxB7OnFsgksK8REk2Gs/C7YwNBwkwSrhuDzyJYC6tNP/qpDeT YXThazwxMgbCHvIp7BCjLFY= Received: (qmail 83475 invoked by alias); 2 Dec 2016 01:27:36 -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 83425 invoked by uid 89); 2 Dec 2016 01:27:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.8 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Wire X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 01:27:29 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 624A13F1E5 for ; Fri, 2 Dec 2016 01:27:28 +0000 (UTC) Received: from c64.redhat.com (vpn-227-203.phx2.redhat.com [10.3.227.203]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB21RPm9004592; Thu, 1 Dec 2016 20:27:27 -0500 From: David Malcolm To: Bernd Schmidt , gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 8c/9] Add aarch64-specific selftests for RTL function reader Date: Thu, 1 Dec 2016 21:00:11 -0500 Message-Id: <1480644013-3660-3-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1480644013-3660-1-git-send-email-dmalcolm@redhat.com> References: <1480628601.24224.64.camel@redhat.com> <1480644013-3660-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes This patch adds more selftests for class function_reader, where the dumps to be read contain aarch64-specific features. In an earlier version of the patch kit, these were handled using #ifndef GCC_AARCH64_H to conditionalize running them. This version instead runs them via a target hook for running target-specific selftests, thus putting them within aarch64.c. gcc/ChangeLog: * config/aarch64/aarch64.c: Include selftest.h and selftest-rtl.h. (selftest::aarch64_test_loading_full_dump): New function. (selftest::aarch64_run_selftests): New function. (TARGET_RUN_TARGET_SELFTESTS): Wire it up to selftest::aarch64_run_selftests. gcc/testsuite/ChangeLog: * selftests/aarch64: New subdirectory. * selftests/aarch64/times-two.rtl: New file. --- gcc/config/aarch64/aarch64.c | 49 +++++++++++++++++++++++++++ gcc/testsuite/selftests/aarch64/times-two.rtl | 36 ++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 gcc/testsuite/selftests/aarch64/times-two.rtl diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index bd97c5b..d19bee3 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -64,6 +64,8 @@ #include "sched-int.h" #include "target-globals.h" #include "common/common-target.h" +#include "selftest.h" +#include "selftest-rtl.h" /* This file should be included last. */ #include "target-def.h" @@ -14168,6 +14170,48 @@ aarch64_optab_supported_p (int op, machine_mode mode1, machine_mode, } } +/* Target-specific selftests. */ + +#if CHECKING_P + +namespace selftest { + +/* Selftest for the RTL loader. This test is target-specific and thus + here since the dump contains target-specific hard reg names. + Verify that the RTL loader copes with a dump from print_rtx_function. */ + +static void +aarch64_test_loading_full_dump () +{ + rtl_dump_test t (SELFTEST_LOCATION, locate_file ("aarch64/times-two.rtl")); + + ASSERT_STREQ ("times_two", IDENTIFIER_POINTER (DECL_NAME (cfun->decl))); + + rtx_insn *insn_1 = get_insn_by_uid (1); + ASSERT_EQ (NOTE, GET_CODE (insn_1)); + + rtx_insn *insn_15 = get_insn_by_uid (15); + ASSERT_EQ (INSN, GET_CODE (insn_15)); + ASSERT_EQ (USE, GET_CODE (PATTERN (insn_15))); + + /* Verify crtl->return_rtx. */ + ASSERT_EQ (REG, GET_CODE (crtl->return_rtx)); + ASSERT_EQ (0, REGNO (crtl->return_rtx)); + ASSERT_EQ (SImode, GET_MODE (crtl->return_rtx)); +} + +/* Run all target-specific selftests. */ + +static void +aarch64_run_selftests (void) +{ + aarch64_test_loading_full_dump (); +} + +} // namespace selftest + +#endif /* #if CHECKING_P */ + #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST aarch64_address_cost @@ -14502,6 +14546,11 @@ aarch64_optab_supported_p (int op, machine_mode mode1, machine_mode, #undef TARGET_OMIT_STRUCT_RETURN_REG #define TARGET_OMIT_STRUCT_RETURN_REG true +#if CHECKING_P +#undef TARGET_RUN_TARGET_SELFTESTS +#define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests +#endif /* #if CHECKING_P */ + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-aarch64.h" diff --git a/gcc/testsuite/selftests/aarch64/times-two.rtl b/gcc/testsuite/selftests/aarch64/times-two.rtl new file mode 100644 index 0000000..dbce67e --- /dev/null +++ b/gcc/testsuite/selftests/aarch64/times-two.rtl @@ -0,0 +1,36 @@ +(function "times_two" + (insn-chain + (cnote 1 NOTE_INSN_DELETED) + (block 2 + (edge-from entry (flags "FALLTHRU")) + (cnote 4 [bb 2] NOTE_INSN_BASIC_BLOCK) + (cinsn 2 (set (mem/c:SI (plus:DI (reg/f:DI virtual-stack-vars) + (const_int -4)) [1 i+0 S4 A32]) + (reg:SI x0 [ i ])) "../../src/times-two.c":2 + (nil)) + (cnote 3 NOTE_INSN_FUNCTION_BEG) + (cinsn 6 (set (reg:SI %2) + (mem/c:SI (plus:DI (reg/f:DI virtual-stack-vars) + (const_int -4)) [1 i+0 S4 A32])) "../../src/times-two.c":3 + (nil)) + (cinsn 7 (set (reg:SI %0 [ _2 ]) + (ashift:SI (reg:SI %2) + (const_int 1))) "../../src/times-two.c":3 + (nil)) + (cinsn 10 (set (reg:SI %1 [ ]) + (reg:SI %0 [ _2 ])) "../../src/times-two.c":3 + (nil)) + (cinsn 14 (set (reg/i:SI x0) + (reg:SI %1 [ ])) "../../src/times-two.c":4 + (nil)) + (cinsn 15 (use (reg/i:SI x0)) "../../src/times-two.c":4 + (nil)) + (edge-to exit (flags "FALLTHRU")) + ) ;; block 2 + ) ;; insn-chain + (crtl + (return_rtx + (reg/i:SI x0) + ) ;; return_rtx + ) ;; crtl +) ;; function "times_two"