From patchwork Wed Nov 14 13:51:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 198914 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]) by ozlabs.org (Postfix) with SMTP id 7C5172C008E for ; Thu, 15 Nov 2012 00:52:29 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353505949; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=49MCAL2l3FEgyjuWodQF 5v9YWkE=; b=EFdyIWUELGs1qLwvI5hX8EyiTkUn1eiaZUQePXeGZZ89R5Ww3QJS 7nd25zlbXOokDfFoJ8Y7DupG2pvn20furdxRhJhGMpPPO1XTpW/qUiNQhYr+AvD4 v/KtFHmO1wtutJCvHbJrbe7Z0X01aOkH501om+J4UXa5US3McLfJB0o= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:From:To:Cc:Subject:Date:Message-ID:MIME-Version:X-MC-Unique:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lkzKPKV1A0F9dioanZM1Tc+h+rGDgPnIffxOsV4RV8mJwz54Rjw5ObK5uyxX4t ITJUJE3y1CzleNcs1l1T34CgGspzZtb7qxDrHIp0IIzIdQJjS39tNdNAhvK4QqJI 8hjT1Mr8b67C1ixgIkrKx/+XmRt98upuurkiM3VlBgwKY=; Received: (qmail 31587 invoked by alias); 14 Nov 2012 13:52:24 -0000 Received: (qmail 31569 invoked by uid 22791); 14 Nov 2012 13:52:22 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, MSGID_MULTIPLE_AT, RCVD_IN_DNSWL_LOW, TW_VF X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 14 Nov 2012 13:52:13 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 14 Nov 2012 13:52:12 +0000 Received: from e106372vm ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.0); Wed, 14 Nov 2012 13:52:10 +0000 From: "Kyrylo Tkachov" To: Cc: "Richard Earnshaw" , "Ramana Radhakrishnan" Subject: [PATCH][ARM][1/2] ARMv8 aarch32 round to integral instructions Date: Wed, 14 Nov 2012 13:51:57 -0000 Message-ID: <003901cdc26f$36b432f0$a41c98d0$@tkachov@arm.com> MIME-Version: 1.0 X-MC-Unique: 112111413521202201 X-IsSubscribed: yes 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 Hi all, This patch adds support for the vrint family of instructions in aarch32 (the 32-bit execution state in ARMv8). These are rounding instructions that can be used to implement round to integral functions from the math library such as: trunc, ceil, round, floor, nearbyint, rint. This patch implements the single and double precision variants of these functions. There is only one pattern for them in the machine description because it uses some new iterators to generate the correct variant for each function. The tests for this are coming in a second patch soon. These changes have been tested using AEM for the new functionality. Also, no regressions when testing for ARMv7-a (for which these changes should not have any effect) on qemu. Ok for trunk? Thanks, Kyrill gcc/ChangeLog 2012-11-14 Kyrylo Tkachov * config/arm/arm.h (TARGET_FPU_ARMV8): New macro. * config/arm/arm.md (UNSPEC_VRINTZ, UNSPEC_VRINTP, UNSPEC_VRINTM, UNSPEC_VRINTR, UNSPEC_VRINTX, UNSPEC_VRINTA): New unspecs. (f_rints, f_rintd): New types. * config/arm/iterators.md (VRINT): New int iterator. (F_fma_type): Remove. (vfp_type): New mode attribute. (vfp_double_cond): Likewise. (vrint_pattern, vrint_variant, vrint_predicable): New int attribute. * config/arm/vfp.md (fma4, *fmsub4, *fnmsub4, *fnmadd4): Use vfp_type iterator instead of F_fma_type. (2): New pattern. --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -296,6 +296,9 @@ extern void (*arm_lang_output_object_att /* FPU supports fused-multiply-add operations. */ #define TARGET_FMA (TARGET_VFP && arm_fpu_desc->rev >= 4) +/* FPU is ARMv8 compatible. */ +#define TARGET_FPU_ARMV8 (TARGET_VFP && arm_fpu_desc->rev >= 8) + /* FPU supports Crypto extensions. */ #define TARGET_CRYPTO (TARGET_VFP && arm_fpu_desc->crypto) diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 7e92b69ad861fe90ed409494d451854f30888462..0000000000000000000000000000000000000000 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -111,6 +111,18 @@ (define_c_enum "unspec" [ UNSPEC_UNALIGNED_STORE ; Same for str/strh. UNSPEC_PIC_UNIFIED ; Create a common pic addressing form. UNSPEC_LL ; Represent an unpaired load-register-exclusive. + UNSPEC_VRINTZ ; Represent a float to integral float rounding + ; towards zero. + UNSPEC_VRINTP ; Represent a float to integral float rounding + ; towards +Inf. + UNSPEC_VRINTM ; Represent a float to integral float rounding + ; towards -Inf. + UNSPEC_VRINTR ; Represent a float to integral float rounding + ; FPSCR rounding mode. + UNSPEC_VRINTX ; Represent a float to integral float rounding + ; FPSCR rounding mode and signal inexactness. + UNSPEC_VRINTA ; Represent a float to integral float rounding + ; towards nearest, ties away from zero. ]) ;; UNSPEC_VOLATILE Usage: @@ -366,6 +378,8 @@ (define_attr "type" fmuld,\ fmacs,\ fmacd,\ + f_rints,\ + f_rintd,\ f_flag,\ f_loads,\ f_loadd,\ diff --git a/gcc/config/arm/iterators.md b/gcc/config/arm/iterators.md index 0a34c82974a4b3f65bbd40032c5d33cc862be095..0000000000000000000000000000000000000000 100644 --- a/gcc/config/arm/iterators.md +++ b/gcc/config/arm/iterators.md @@ -192,6 +192,13 @@ (define_code_iterator SE [sign_extend ze (define_code_iterator rshifts [ashiftrt lshiftrt]) ;;---------------------------------------------------------------------------- +;; Int iterators +;;---------------------------------------------------------------------------- + +(define_int_iterator VRINT [UNSPEC_VRINTZ UNSPEC_VRINTP UNSPEC_VRINTM + UNSPEC_VRINTR UNSPEC_VRINTX UNSPEC_VRINTA]) + +;;---------------------------------------------------------------------------- ;; Mode attributes ;;---------------------------------------------------------------------------- @@ -431,9 +438,10 @@ (define_mode_attr qaddsub_suf [(V4UQQ "8 ;; Mode attribute for vshll. (define_mode_attr V_innermode [(V8QI "QI") (V4HI "HI") (V2SI "SI")]) -;; Mode attributes used for fused-multiply-accumulate VFP support +;; Mode attributes used for VFP support. (define_mode_attr F_constraint [(SF "t") (DF "w")]) -(define_mode_attr F_fma_type [(SF "fmacs") (DF "fmacd")]) +(define_mode_attr vfp_type [(SF "s") (DF "d")]) +(define_mode_attr vfp_double_cond [(SF "") (DF "&& TARGET_VFP_DOUBLE")]) ;;---------------------------------------------------------------------------- ;; Code attributes @@ -457,3 +465,21 @@ (define_code_attr US [(sign_extend "s") (define_code_attr shift [(ashiftrt "ashr") (lshiftrt "lshr")]) (define_code_attr shifttype [(ashiftrt "signed") (lshiftrt "unsigned")]) +;;---------------------------------------------------------------------------- +;; Int attributes +;;---------------------------------------------------------------------------- + +;; Standard names for floating point to integral rounding instructions. +(define_int_attr vrint_pattern [(UNSPEC_VRINTZ "btrunc") (UNSPEC_VRINTP "ceil") + (UNSPEC_VRINTA "round") (UNSPEC_VRINTM "floor") + (UNSPEC_VRINTR "nearbyint") (UNSPEC_VRINTX "rint")]) + +;; Suffixes for vrint instructions specifying rounding modes. +(define_int_attr vrint_variant [(UNSPEC_VRINTZ "z") (UNSPEC_VRINTP "p") + (UNSPEC_VRINTA "a") (UNSPEC_VRINTM "m") + (UNSPEC_VRINTR "r") (UNSPEC_VRINTX "x")]) + +;; Some of the vrint instuctions are predicable. +(define_int_attr vrint_predicable [(UNSPEC_VRINTZ "yes") (UNSPEC_VRINTP "no") + (UNSPEC_VRINTA "no") (UNSPEC_VRINTM "no") + (UNSPEC_VRINTR "yes") (UNSPEC_VRINTX "yes")]) diff --git a/gcc/config/arm/vfp.md b/gcc/config/arm/vfp.md index d48d4e66a6c827ec6d471a218a175537f038d798..0000000000000000000000000000000000000000 100644 --- a/gcc/config/arm/vfp.md +++ b/gcc/config/arm/vfp.md @@ -908,7 +908,7 @@ (define_insn "fma4" "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_FMA" "vfma%?.\\t%0, %1, %2" [(set_attr "predicable" "yes") - (set_attr "type" "")] + (set_attr "type" "fmac")] ) (define_insn "*fmsub4" @@ -920,7 +920,7 @@ (define_insn "*fmsub4" "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_FMA" "vfms%?.\\t%0, %1, %2" [(set_attr "predicable" "yes") - (set_attr "type" "")] + (set_attr "type" "fmac")] ) (define_insn "*fnmsub4" @@ -931,7 +931,7 @@ (define_insn "*fnmsub4" "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_FMA" "vfnms%?.\\t%0, %1, %2" [(set_attr "predicable" "yes") - (set_attr "type" "")] + (set_attr "type" "fmac")] ) (define_insn "*fnmadd4" @@ -943,7 +943,7 @@ (define_insn "*fnmadd4" "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_FMA" "vfnma%?.\\t%0, %1, %2" [(set_attr "predicable" "yes") - (set_attr "type" "")] + (set_attr "type" "fmac")] ) @@ -1248,6 +1248,20 @@ (define_insn "*push_multi_vfp" [(set_attr "type" "f_stored")] ) +;; VRINT round to integral instructions. +;; Invoked for the patterns: btruncsf2, btruncdf2, ceilsf2, ceildf2, +;; roundsf2, rounddf2, floorsf2, floordf2, nearbyintsf2, nearbyintdf2, +;; rintsf2, rintdf2. +(define_insn "2" + [(set (match_operand:SDF 0 "register_operand" "=") + (unspec:SDF [(match_operand:SDF 1 + "register_operand" "")] + VRINT))] + "TARGET_HARD_FLOAT && TARGET_FPU_ARMV8 " + "vrint%?.\\t%0, %1" + [(set_attr "predicable" "") + (set_attr "type" "f_rint")] +) ;; Unimplemented insns: ;; fldm*