From patchwork Sun Jul 5 07:50:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 491278 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 780961409A0 for ; Sun, 5 Jul 2015 17:50:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=uxFI1qOS; 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=iqHXveT1oDTHbnlA htbDc0O8m9vWuwQH6qDvgIunP7ZgWUvVDRxCycPhD6blayulJI9z77y7i9o+nCGk VKnkeG+f5JmbFomTRayW658kGJYjxStyXfMEjYK4OabR+JBsMgLpFaSKaK/X9ycI JG1xUCvXGrep/jntjdaL5ixOTIw= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=dVZlM6uyBQomAVSi6D755f gBYvo=; b=uxFI1qOSw8Ak1ecVgqLXZg1lX8viVRAI+OxckQgevpp/Enue7lWD8/ cy9lfh0sbA9Ti2OB9ibUKb8eZvpSImKX+7KsWHvhzKBUqA9pP7g2wEi0kdFJ0kYk KRYn4/DYMpL55iEk3EF4ms9TpSCAB1AG+PMsV6HuLibBRfGbnkazs= Received: (qmail 113042 invoked by alias); 5 Jul 2015 07:50:15 -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 113030 invoked by uid 89); 5 Jul 2015 07:50:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL, BAYES_20, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 Jul 2015 07:50:13 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-30-ERM8ipo6QSWNmjy6LoeAuw-1 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 5 Jul 2015 08:50:03 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] Use target-insns.def for prefetch Date: Sun, 05 Jul 2015 08:50:04 +0100 Message-ID: <87egknm4b7.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: ERM8ipo6QSWNmjy6LoeAuw-1 Bootstrapped & regression-tested on x86_64-linux-gnu and aarch64-linux-gnu. Also tested via config-list.mk. Committed as preapproved. Thanks, Richard gcc/ * target-insns.def (prefetch): New targetm instruction pattern. * tree-ssa-loop-prefetch.c: Include targeth. (tree_ssa_prefetch_arrays): Use prefetch targetm pattern instead of HAVE_*/gen_* interface. * builtins.c (expand_builtin_prefetch): Likewise. * toplev.c (process_options): Likewise. Index: gcc/target-insns.def =================================================================== --- gcc/target-insns.def 2015-07-05 08:49:32.128750538 +0100 +++ gcc/target-insns.def 2015-07-05 08:49:32.120750686 +0100 @@ -44,6 +44,7 @@ DEF_TARGET_INSN (mem_thread_fence, (rtx DEF_TARGET_INSN (memory_barrier, (void)) DEF_TARGET_INSN (nonlocal_goto, (rtx x0, rtx x1, rtx x2, rtx x3)) DEF_TARGET_INSN (nonlocal_goto_receiver, (void)) +DEF_TARGET_INSN (prefetch, (rtx x0, rtx x1, rtx x2)) DEF_TARGET_INSN (prologue, (void)) DEF_TARGET_INSN (return, (void)) DEF_TARGET_INSN (sibcall_epilogue, (void)) Index: gcc/tree-ssa-loop-prefetch.c =================================================================== --- gcc/tree-ssa-loop-prefetch.c 2015-07-05 08:49:32.128750538 +0100 +++ gcc/tree-ssa-loop-prefetch.c 2015-07-05 08:49:32.124750587 +0100 @@ -57,6 +57,7 @@ Free Software Foundation; either version #include "langhooks.h" #include "tree-inline.h" #include "tree-data-ref.h" +#include "target.h" /* FIXME: Needed for optabs, but this should all be moved to a TBD interface @@ -216,10 +217,6 @@ #define HAVE_BACKWARD_PREFETCH 0 #define ACCEPTABLE_MISS_RATE 50 #endif -#ifndef HAVE_prefetch -#define HAVE_prefetch 0 -#endif - #define L1_CACHE_SIZE_BYTES ((unsigned) (L1_CACHE_SIZE * 1024)) #define L2_CACHE_SIZE_BYTES ((unsigned) (L2_CACHE_SIZE * 1024)) @@ -1954,11 +1951,11 @@ tree_ssa_prefetch_arrays (void) bool unrolled = false; int todo_flags = 0; - if (!HAVE_prefetch + if (!targetm.have_prefetch () /* It is possible to ask compiler for say -mtune=i486 -march=pentium4. -mtune=i486 causes us having PREFETCH_BLOCK 0, since this is part of processor costs and i486 does not have prefetch, but - -march=pentium4 causes HAVE_prefetch to be true. Ugh. */ + -march=pentium4 causes targetm.have_prefetch to be true. Ugh. */ || PREFETCH_BLOCK == 0) return 0; Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2015-07-05 08:49:32.128750538 +0100 +++ gcc/builtins.c 2015-07-05 08:49:32.120750686 +0100 @@ -1282,18 +1282,16 @@ expand_builtin_prefetch (tree exp) op2 = const0_rtx; } -#ifdef HAVE_prefetch - if (HAVE_prefetch) + if (targetm.have_prefetch ()) { struct expand_operand ops[3]; create_address_operand (&ops[0], op0); create_integer_operand (&ops[1], INTVAL (op1)); create_integer_operand (&ops[2], INTVAL (op2)); - if (maybe_expand_insn (CODE_FOR_prefetch, 3, ops)) + if (maybe_expand_insn (targetm.code_for_prefetch, 3, ops)) return; } -#endif /* Don't do anything with direct references to volatile memory, but generate code to handle other side effects. */ Index: gcc/toplev.c =================================================================== --- gcc/toplev.c 2015-07-05 08:49:32.128750538 +0100 +++ gcc/toplev.c 2015-07-05 08:49:32.124750587 +0100 @@ -1571,19 +1571,16 @@ process_options (void) } } -#ifndef HAVE_prefetch - if (flag_prefetch_loop_arrays > 0) + if (flag_prefetch_loop_arrays > 0 && !targetm.code_for_prefetch) { warning (0, "-fprefetch-loop-arrays not supported for this target"); flag_prefetch_loop_arrays = 0; } -#else - if (flag_prefetch_loop_arrays > 0 && !HAVE_prefetch) + else if (flag_prefetch_loop_arrays > 0 && !targetm.have_prefetch ()) { warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)"); flag_prefetch_loop_arrays = 0; } -#endif /* This combination of options isn't handled for i386 targets and doesn't make much sense anyway, so don't allow it. */