From patchwork Mon Apr 14 17:54:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 339027 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 9C75414007B for ; Tue, 15 Apr 2014 03:57:22 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=Fc/BlBjylrOgu9oji5l+SLvHs0926WKcGHEvmEgrz5PGEP IQzdQNIDnx7viaYqCWoxaP//q669zGvtf24a9vRqDp+JSWyiDQ8PpnSkn4Ro4NA5 K97uX7BCR7EkQ7tMiQhsXvJQHJ7HMaReeUMjS1wfB+3UUALrxayqWNRiV7oxA= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=XIF9ffSAdW00yAiMnOAb5vl5vj0=; b=CEcR1YJfX3jDYgLMadhg 6/cQY+tJFI0j7flUGH4Mq54fgXh0yDqgf9yIi9wT08nJ90M8Uo/uNQHULFshsNxs mqrVbDXrR/ognRJTaXTYca/yQlWind8IAYihDwyQ9bQX0CDloTL5s7PMi+auxRvk wt7txGzS9nS5EEm7V8D4snU= Received: (qmail 32300 invoked by alias); 14 Apr 2014 17:54:12 -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 32213 invoked by uid 89); 14 Apr 2014 17:54:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oa0-f45.google.com Received: from mail-oa0-f45.google.com (HELO mail-oa0-f45.google.com) (209.85.219.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 14 Apr 2014 17:54:09 +0000 Received: by mail-oa0-f45.google.com with SMTP id eb12so9593296oac.18 for ; Mon, 14 Apr 2014 10:54:07 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.142.229 with SMTP id rz5mr36069832obb.12.1397498047402; Mon, 14 Apr 2014 10:54:07 -0700 (PDT) Received: by 10.182.89.229 with HTTP; Mon, 14 Apr 2014 10:54:07 -0700 (PDT) Date: Mon, 14 Apr 2014 19:54:07 +0200 Message-ID: Subject: [PATCH, i386]: Some classify_argument and return_in_memory cleanups From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" Hello! Attached patch changes return type of classify_argument to bool and merges a couple of called-once functions to their call sites. The later change removes a bunch of functions, declared with ATTRIBUTE_UNUSED. 2014-04-14 Uros Bizjak * config/i386/i386.c (examine_argument): Return bool. Return true if parameter should be passed in memory. : Adjust. (construct_container): Update calls to examine_argument. (function_arg_advance_64): Ditto. (return_in_memory_32): Merge with ix86_return_in_memory. (return_in_memory_64): Ditto. (return_in_memory_ms_64): Ditto. Bootstrapped and regtested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 209348) +++ config/i386/i386.c (working copy) @@ -6806,8 +6806,9 @@ classify_argument (enum machine_mode mode, const_t } /* Examine the argument and return set number of register required in each - class. Return 0 iff parameter should be passed in memory. */ -static int + class. Return true iff parameter should be passed in memory. */ + +static bool examine_argument (enum machine_mode mode, const_tree type, int in_return, int *int_nregs, int *sse_nregs) { @@ -6816,8 +6817,9 @@ examine_argument (enum machine_mode mode, const_tr *int_nregs = 0; *sse_nregs = 0; + if (!n) - return 0; + return true; for (n--; n >= 0; n--) switch (regclass[n]) { @@ -6835,15 +6837,15 @@ examine_argument (enum machine_mode mode, const_tr break; case X86_64_X87_CLASS: case X86_64_X87UP_CLASS: + case X86_64_COMPLEX_X87_CLASS: if (!in_return) - return 0; + return true; break; - case X86_64_COMPLEX_X87_CLASS: - return in_return ? 2 : 0; case X86_64_MEMORY_CLASS: gcc_unreachable (); } - return 1; + + return false; } /* Construct container for the argument used by GCC interface. See @@ -6873,8 +6875,8 @@ construct_container (enum machine_mode mode, enum n = classify_argument (mode, type, regclass, 0); if (!n) return NULL; - if (!examine_argument (mode, type, in_return, &needed_intregs, - &needed_sseregs)) + if (examine_argument (mode, type, in_return, &needed_intregs, + &needed_sseregs)) return NULL; if (needed_intregs > nintregs || needed_sseregs > nsseregs) return NULL; @@ -7193,7 +7195,7 @@ function_arg_advance_64 (CUMULATIVE_ARGS *cum, enu || VALID_AVX256_REG_MODE (mode))) return; - if (examine_argument (mode, type, 0, &int_nregs, &sse_nregs) + if (!examine_argument (mode, type, 0, &int_nregs, &sse_nregs) && sse_nregs <= cum->sse_nregs && int_nregs <= cum->nregs) { cum->nregs -= int_nregs; @@ -7988,95 +7990,87 @@ ix86_libcall_value (enum machine_mode mode) /* Return true iff type is returned in memory. */ -static bool ATTRIBUTE_UNUSED -return_in_memory_32 (const_tree type, enum machine_mode mode) +static bool +ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { +#ifdef SUBTARGET_RETURN_IN_MEMORY + return SUBTARGET_RETURN_IN_MEMORY (type, fntype); +#else + const enum machine_mode mode = type_natural_mode (type, NULL, true); HOST_WIDE_INT size; - if (mode == BLKmode) - return true; + if (TARGET_64BIT) + { + if (ix86_function_type_abi (fntype) == MS_ABI) + { + size = int_size_in_bytes (type); - size = int_size_in_bytes (type); + /* __m128 is returned in xmm0. */ + if ((!type || VECTOR_INTEGER_TYPE_P (type) + || INTEGRAL_TYPE_P (type) + || VECTOR_FLOAT_TYPE_P (type)) + && (SCALAR_INT_MODE_P (mode) || VECTOR_MODE_P (mode)) + && !COMPLEX_MODE_P (mode) + && (GET_MODE_SIZE (mode) == 16 || size == 16)) + return false; - if (MS_AGGREGATE_RETURN && AGGREGATE_TYPE_P (type) && size <= 8) - return false; + /* Otherwise, the size must be exactly in [1248]. */ + return size != 1 && size != 2 && size != 4 && size != 8; + } + else + { + int needed_intregs, needed_sseregs; - if (VECTOR_MODE_P (mode) || mode == TImode) + return examine_argument (mode, type, 1, + &needed_intregs, &needed_sseregs); + } + } + else { - /* User-created vectors small enough to fit in EAX. */ - if (size < 8) - return false; + if (mode == BLKmode) + return true; - /* MMX/3dNow values are returned in MM0, - except when it doesn't exits or the ABI prescribes otherwise. */ - if (size == 8) - return !TARGET_MMX || TARGET_VECT8_RETURNS; + size = int_size_in_bytes (type); - /* SSE values are returned in XMM0, except when it doesn't exist. */ - if (size == 16) - return !TARGET_SSE; + if (MS_AGGREGATE_RETURN && AGGREGATE_TYPE_P (type) && size <= 8) + return false; - /* AVX values are returned in YMM0, except when it doesn't exist. */ - if (size == 32) - return !TARGET_AVX; + if (VECTOR_MODE_P (mode) || mode == TImode) + { + /* User-created vectors small enough to fit in EAX. */ + if (size < 8) + return false; - /* AVX512F values are returned in ZMM0, except when it doesn't exist. */ - if (size == 64) - return !TARGET_AVX512F; - } + /* Unless ABI prescibes otherwise, + MMX/3dNow values are returned in MM0 if available. */ + + if (size == 8) + return TARGET_VECT8_RETURNS || !TARGET_MMX; - if (mode == XFmode) - return false; + /* SSE values are returned in XMM0 if available. */ + if (size == 16) + return !TARGET_SSE; - if (size > 12) - return true; + /* AVX values are returned in YMM0 if available. */ + if (size == 32) + return !TARGET_AVX; - /* OImode shouldn't be used directly. */ - gcc_assert (mode != OImode); + /* AVX512F values are returned in ZMM0 if available. */ + if (size == 64) + return !TARGET_AVX512F; + } - return false; -} + if (mode == XFmode) + return false; -static bool ATTRIBUTE_UNUSED -return_in_memory_64 (const_tree type, enum machine_mode mode) -{ - int needed_intregs, needed_sseregs; - return !examine_argument (mode, type, 1, &needed_intregs, &needed_sseregs); -} + if (size > 12) + return true; -static bool ATTRIBUTE_UNUSED -return_in_memory_ms_64 (const_tree type, enum machine_mode mode) -{ - HOST_WIDE_INT size = int_size_in_bytes (type); + /* OImode shouldn't be used directly. */ + gcc_assert (mode != OImode); - /* __m128 is returned in xmm0. */ - if ((!type || VECTOR_INTEGER_TYPE_P (type) || INTEGRAL_TYPE_P (type) - || VECTOR_FLOAT_TYPE_P (type)) - && (SCALAR_INT_MODE_P (mode) || VECTOR_MODE_P (mode)) - && !COMPLEX_MODE_P (mode) && (GET_MODE_SIZE (mode) == 16 || size == 16)) - return false; - - /* Otherwise, the size must be exactly in [1248]. */ - return size != 1 && size != 2 && size != 4 && size != 8; -} - -static bool -ix86_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) -{ -#ifdef SUBTARGET_RETURN_IN_MEMORY - return SUBTARGET_RETURN_IN_MEMORY (type, fntype); -#else - const enum machine_mode mode = type_natural_mode (type, NULL, true); - - if (TARGET_64BIT) - { - if (ix86_function_type_abi (fntype) == MS_ABI) - return return_in_memory_ms_64 (type, mode); - else - return return_in_memory_64 (type, mode); + return false; } - else - return return_in_memory_32 (type, mode); #endif }