From patchwork Fri Mar 24 11:14:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 743144 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 3vqLRD0DyXz9s83 for ; Fri, 24 Mar 2017 22:14:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lVn+PwE5"; 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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=LqbNNjU7hqVysY2EAnPtLH4odlMV0PLbJwgs/voQX3r dVm/SkPIQv0Q8kLcuGp/NBWhHnUwOYTMTB4SgIR+uIE3nq6reP93q4fY3GTOMSI1 b7L7hXIkZxlfiOf1lAi0adsqlP629jYky20ZPHRYXPGNLlBbElU99DUFg3NUSIFs = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=Sr7gjiFJTAtyhbTltaJ2CROPZGM=; b=lVn+PwE5OR/fNVjr2 EmtE0uoHttqS3AlTYOwyfhmmycVxhlsHEDXtGVRcypab+l4oXHhQWwtCisCqM4O6 +PCstsrRp6i4qp0FWISZVEnHOsVjdU3yWVQYwY5JXxqqPXpVULCJLeLiwu9lzVQs Qba4T35vQLaiMHFHiaIqvaOWLM= Received: (qmail 44275 invoked by alias); 24 Mar 2017 11:14:22 -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 44243 invoked by uid 89); 24 Mar 2017 11:14:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=complains, inclusive, HIGH, dubious X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Mar 2017 11:14:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 36306344; Fri, 24 Mar 2017 04:14:16 -0700 (PDT) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 881393F3E1; Fri, 24 Mar 2017 04:14:15 -0700 (PDT) Message-ID: <58D4FF86.8080902@foss.arm.com> Date: Fri, 24 Mar 2017 11:14:14 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Richard Earnshaw , Ramana Radhakrishnan Subject: [PATCH][ARM] PR target/79871: Clean up lane/constant bounds checking errors for translation Hi all, This PR complains that the bounds checking error strings contain a string placeholder for "constant" or "lane" which makes it hard for translators (who may want to move words around in a different language for syntactical reasons). This patch cleans that up. The bunching up of common functionality between neon_lane_bounds and arm_const_bounds was a bit dubious in any case as arm_const_bounds never passed down a non-NULL tree anyway, so one of the paths of bonds_check was always used in only the neon_lane_bounds case anyway. I also add some function comments and use IN_RANGE for range checking. Bootstrapped and tested on arm-none-linux-gnueabihf. Ok for trunk? (I believe such translation improvements fall under the documentation rule at this stage). Thanks, Kyrill 2017-03-24 Kyrylo Tkachov PR target/79871 * config/arm/arm.c (bounds_check): Delete. (neon_lane_bounds): Adjust. Make sure error string template doesn't use string placeholder. (arm_const_bounds): Likewise. commit 102b86a782297c725c4796c4dd36d33fdf024ee7 Author: Kyrylo Tkachov Date: Thu Mar 23 10:50:32 2017 +0000 PR target/79871: Clean up lane/constant bounds checking errors for translation diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 7b2d3d5..98059da 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -12186,13 +12186,16 @@ neon_expand_vector_init (rtx target, rtx vals) emit_move_insn (target, mem); } -/* Ensure OPERAND lies between LOW (inclusive) and HIGH (exclusive). Raise - ERR if it doesn't. EXP indicates the source location, which includes the - inlining history for intrinsics. */ +/* Bounds-check lanes. + Ensure OPERAND lies between LOW (inclusive) and HIGH (exclusive). Emit an + an error if it doesn't. EXP indicates the source location, which includes + the inlining history for intrinsics. + We don't unify this and arm_const_bounds because the error string needs to + explicity contain "constant" or "lane" for translation purposes. */ -static void -bounds_check (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high, - const_tree exp, const char *desc) +void +neon_lane_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high, + const_tree exp) { HOST_WIDE_INT lane; @@ -12200,31 +12203,34 @@ bounds_check (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high, lane = INTVAL (operand); - if (lane < low || lane >= high) + if (!IN_RANGE (lane, low, high - 1)) { if (exp) - error ("%K%s %wd out of range %wd - %wd", - exp, desc, lane, low, high - 1); + error ("%Klane %wd out of range %wd - %wd", + exp, lane, low, high - 1); else - error ("%s %wd out of range %wd - %wd", desc, lane, low, high - 1); + error ("lane %wd out of range %wd - %wd", + lane, low, high - 1); } } -/* Bounds-check lanes. */ +/* Bounds-check constants. + Ensure OPERAND lies between LOW (inclusive) and HIGH (exclusive). Emit an + an error if it doesn't. See neon_lane_bounds comment for + translation comment. */ void -neon_lane_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high, - const_tree exp) +arm_const_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high) { - bounds_check (operand, low, high, exp, "lane"); -} + HOST_WIDE_INT constant; -/* Bounds-check constants. */ + gcc_assert (CONST_INT_P (operand)); -void -arm_const_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high) -{ - bounds_check (operand, low, high, NULL_TREE, "constant"); + constant = INTVAL (operand); + + if (!IN_RANGE (constant, low, high - 1)) + error ("constant %wd out of range %wd - %wd", + constant, low, high - 1); } HOST_WIDE_INT