From patchwork Mon Apr 2 10:57:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 150109 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 70D56B6F6E for ; Mon, 2 Apr 2012 20:58:49 +1000 (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=1333969130; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:User-Agent:Cc:References: In-Reply-To:MIME-Version:Content-Disposition:Content-Type: Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=HNezEFK xU7wWtPz1bZoXpAFRjH4=; b=ncu0eQlWW3X0PtQJe4S73j6wHToH3Xraf5em0lh yAdAMJM/lkYDbFDRAjFNzhJOgQMh8oA+912mh0TUVOvv8sveNclI/+XGu75zBB7E 8Yber6sgrilvfTW+qzsAX6f3J0iNq7b+R3LBpEC8q20UBfAGmum6OPfKaJSSCt+B 76y8= 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:Received:From:To:Subject:Date:User-Agent:Cc:References:In-Reply-To:MIME-Version:Content-Disposition:Content-Type:Message-Id:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=cW7cxDDZ39yKdKDw51n3x5fXrVDp4ylQdUn9RbvPPXI0kErl6sfCtJv2QYIhzD 1hP80lmnexjHzMs89slE0KB7gATEoVHzp/1ixQMzo5Out52TRStYdExmgCwWlF5l hauwp23R2fr5zyXQK5vapAFT2kKXSjPCEn305yUr1Ig1c=; Received: (qmail 15919 invoked by alias); 2 Apr 2012 10:58:46 -0000 Received: (qmail 15910 invoked by uid 22791); 2 Apr 2012 10:58:45 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 02 Apr 2012 10:58:27 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id C2594290051; Mon, 2 Apr 2012 12:58:30 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D53TTH4tseG6; Mon, 2 Apr 2012 12:58:30 +0200 (CEST) Received: from [192.168.1.2] (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 84CB829004F; Mon, 2 Apr 2012 12:58:30 +0200 (CEST) From: Eric Botcazou To: Richard Guenther Subject: Re: [patch] Add support for FP bit fields in varasm.c Date: Mon, 2 Apr 2012 12:57:46 +0200 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org References: <201203281653.25712.ebotcazou@adacore.com> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201204021257.47162.ebotcazou@adacore.com> 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 > You should be able to use fold_unary instead of fold_build1. > make_signed_type should also not be used, but > build_nonstandard_integer_type (or even better, get an integer mode of the > same size of the float mode and then use type_for_mode). Using the mode size wouldn't work directly for XFmode on x86. Moreover the precision seems to be the right property in this bit-field context. Adjusted patch attached, tested on i586-suse-linux, OK for mainline? Index: varasm.c =================================================================== --- varasm.c (revision 186054) +++ varasm.c (working copy) @@ -4420,6 +4420,7 @@ initializer_constant_valid_for_bitfield_ } case INTEGER_CST: + case REAL_CST: return true; case VIEW_CONVERT_EXPR: @@ -5075,10 +5076,7 @@ output_constructor (tree exp, unsigned H /* The element in a union constructor specifies the proper field or index. */ - if ((TREE_CODE (local.type) == RECORD_TYPE - || TREE_CODE (local.type) == UNION_TYPE - || TREE_CODE (local.type) == QUAL_UNION_TYPE) - && ce->index != NULL_TREE) + if (RECORD_OR_UNION_TYPE_P (local.type) && ce->index != NULL_TREE) local.field = ce->index; else if (TREE_CODE (local.type) == ARRAY_TYPE) @@ -5110,9 +5108,18 @@ output_constructor (tree exp, unsigned H || !CONSTRUCTOR_BITFIELD_P (local.field))) output_constructor_regular_field (&local); - /* For a true bitfield or part of an outer one. */ + /* For a true bitfield or part of an outer one. Only INTEGER_CSTs are + supported for scalar fields, so we may need to convert first. */ else - output_constructor_bitfield (&local, outer); + { + if (TREE_CODE (local.val) == REAL_CST) + local.val + = fold_unary (VIEW_CONVERT_EXPR, + build_nonstandard_integer_type + (TYPE_PRECISION (TREE_TYPE (local.val)), 0), + local.val); + output_constructor_bitfield (&local, outer); + } } /* If we are not at toplevel, save the pending data for our caller.