From patchwork Mon Jul 16 12:29:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 944365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481612-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MbvUi1fO"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FRTBJxyF"; dkim-atps=neutral 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 41TjRx0R0Fz9s29 for ; Mon, 16 Jul 2018 22:30:36 +1000 (AEST) 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=ettIZUnDXiyG9/M9jduY+B8RuNiCcynJEGqIZMmXm8tUXE+XTMr5R uzWNhGcOIvLfvImiv2Vo3fCSAxViBbkADGphCqeVdL6rwc/TYNL9hQvXk5LIqOPX GIw4af3UQvXOe2rBQyxlZ3nVCqM6T+llaW8ZEQBPABd69LSNssoMGk= 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=wnU5PgZsVaS8CQyKf9bqJimc8So=; b=MbvUi1fO8OIBF2PFybVT IkTiI5Az1sZ9i+qzMKJxar4ptQYyLOwnJL16qKDVtPzxJt3q2ehDYBK1DqFOIK7P 7VFbLaNYyd3ucRvVKmWJ95Uheoh7Mt9g2Uw6LrScXzx3XbgpNFe6J/XE13W+Z2y6 Tl1hDnsFc+/5g0ZCgk+vObw= Received: (qmail 13896 invoked by alias); 16 Jul 2018 12:29:55 -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 13785 invoked by uid 89); 16 Jul 2018 12:29:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=FIX, TREE_OPERAND, tree_operand X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jul 2018 12:29:53 +0000 Received: by mail-wm0-f42.google.com with SMTP id s9-v6so7648350wmh.3 for ; Mon, 16 Jul 2018 05:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cU0zrnfDmmLlTo5PBFNOmuCaCdomgdnC4p+2vZPdjE4=; b=FRTBJxyF4FY++JG+GvhgK9Md3FxC7fD8s4sak0cbxnrph1KPs3Y6zGhkadiYqmHkWT 23xaIKXUWqJzGvfks7ZneKBmEgS8a4KruoxvQ9V84m5+KsbQKRrdpUrgdwEKRUFiUOcw 45SKE1/80d2OxcWIqrkRrCMzZsectV5U6Q65aLfAD+U+3buEq2uRhPzyY4ng5qnh8gE7 7uTAYEfXoffVc5hcqlgb9xfInP3aZYX7ASHWLtfW02NiTqbTDrHyhk5PP2CqUxU7icui o2luCpuON7HlK+1jCysteGfF1PEiV7kTbncWRfkh0/dS5UlWZ3j0TR5Dr8KqTZfPtQ/3 VCmQ== Received: from localhost.localdomain ([188.241.79.25]) by smtp.gmail.com with ESMTPSA id 73-v6sm6135757wmo.21.2018.07.16.05.29.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 05:29:50 -0700 (PDT) From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Cc: fbedard@synopsys.com, andrew.burgess@embecosm.com Subject: [PATCH 2/4] [ARX][FIX] Fix uncache attribute. Date: Mon, 16 Jul 2018 15:29:43 +0300 Message-Id: <20180716122945.9375-2-claziss@gmail.com> In-Reply-To: <20180716122945.9375-1-claziss@gmail.com> References: <20180716122945.9375-1-claziss@gmail.com> X-IsSubscribed: yes gcc/ 2018-05-09 Claudiu Zissulescu * config/arc/arc.c (compact_memory_operand_p): Check for uncached accesses as well. (arc_is_uncached_mem_p): uncached applies to both the variable and the pointer. testsuite/ 2018-05-09 Claudiu Zissulescu * gcc.target/arc/uncached-1.c: New test. * gcc.target/arc/uncached-2.c: Likewise. --- gcc/config/arc/arc.c | 40 +++++++++++++++-------- gcc/testsuite/gcc.target/arc/uncached-1.c | 11 +++++++ gcc/testsuite/gcc.target/arc/uncached-2.c | 9 +++++ 3 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/uncached-1.c create mode 100644 gcc/testsuite/gcc.target/arc/uncached-2.c diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index f36f88f920b..bf719eab115 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -10450,6 +10450,10 @@ compact_memory_operand_p (rtx op, machine_mode mode, if (MEM_VOLATILE_P (op) && !TARGET_VOLATILE_CACHE_SET) return false; + /* likewise for uncached types. */ + if (arc_is_uncached_mem_p (op)) + return false; + if (mode == VOIDmode) mode = GET_MODE (op); @@ -10733,28 +10737,36 @@ arc_handle_uncached_attribute (tree *node, bool arc_is_uncached_mem_p (rtx pat) { - tree attrs; - tree ttype; - struct mem_attrs *refattrs; + tree attrs = NULL_TREE; + tree addr; if (!MEM_P (pat)) return false; /* Get the memory attributes. */ - refattrs = MEM_ATTRS (pat); - if (!refattrs - || !refattrs->expr) + addr = MEM_EXPR (pat); + if (!addr) return false; - /* Get the type declaration. */ - ttype = TREE_TYPE (refattrs->expr); - if (!ttype) - return false; + /* Get the attributes. */ + if (TREE_CODE (addr) == MEM_REF) + { + attrs = TYPE_ATTRIBUTES (TREE_TYPE (addr)); + if (lookup_attribute ("uncached", attrs)) + return true; - /* Get the type attributes. */ - attrs = TYPE_ATTRIBUTES (ttype); - if (lookup_attribute ("uncached", attrs)) - return true; + attrs = TYPE_ATTRIBUTES (TREE_TYPE (TREE_OPERAND (addr, 0))); + if (lookup_attribute ("uncached", attrs)) + return true; + } + + /* For COMPONENT_REF, use the FIELD_DECL from tree operand 1. */ + if (TREE_CODE (addr) == COMPONENT_REF) + { + attrs = TYPE_ATTRIBUTES (TREE_TYPE (TREE_OPERAND (addr, 1))); + if (lookup_attribute ("uncached", attrs)) + return true; + } return false; } diff --git a/gcc/testsuite/gcc.target/arc/uncached-1.c b/gcc/testsuite/gcc.target/arc/uncached-1.c new file mode 100644 index 00000000000..7a6bade81c4 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/uncached-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +volatile __attribute__((uncached)) int * status = + (volatile __attribute__((uncached)) int *) 0x04 ; + +int get_stat (void) +{ + return *status; +} + +/* { dg-final { scan-assembler-times "ld\.di" 1 } } */ diff --git a/gcc/testsuite/gcc.target/arc/uncached-2.c b/gcc/testsuite/gcc.target/arc/uncached-2.c new file mode 100644 index 00000000000..89eed326e01 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/uncached-2.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void clkgen_switch(unsigned int base, unsigned int offset, int val) +{ + volatile unsigned int __attribute__ ((uncached)) *dest = + (volatile unsigned int __attribute__ ((uncached)) *) (base + offset); + *dest = val; +} +/* { dg-final { scan-assembler-times "st\.di" 1 } } */