From patchwork Fri Dec 11 18:10:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 555856 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 E61621402D6 for ; Sat, 12 Dec 2015 05:10:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=WUTylM0Y; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=FaOiFngsla0233CzNsPqbFHKzm3TQdOyo7boHZ1URtRFEt8Vfd gsjDIQEKvUVCJzAOX90mfs77jBzlvfiVKr02knNCg8GUdRpMaHJ8f+qzlS+sHANK g4Mo/GEkC7YIxtyTdYXizXF3fIUfLuC1SMlVn5qZoB6ywtinqrKM6jVQU= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=vwi2r9bZ8r4hcIP2V1Iwbwp5BNM=; b=WUTylM0YInIpvB/GF6R7 z26ki79kkIDhriIBMPavoJU+ocgDZURlejNQzKCzoTLEjiThjKJ7bLQnN5KCtDfX hW0qMPfNctsqttHQmrAg1bpbjdXQbA9HJBnROQW1VdiPAdnu1rpZFzyc/tgAb3ij iGKoQLOt6mqH70uaE8/y8Eg= Received: (qmail 38139 invoked by alias); 11 Dec 2015 18:10:08 -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 38126 invoked by uid 89); 11 Dec 2015 18:10:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qg0-f46.google.com Received: from mail-qg0-f46.google.com (HELO mail-qg0-f46.google.com) (209.85.192.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 11 Dec 2015 18:10:06 +0000 Received: by qgcc31 with SMTP id c31so203654205qgc.3 for ; Fri, 11 Dec 2015 10:10:04 -0800 (PST) X-Received: by 10.140.85.102 with SMTP id m93mr25335305qgd.83.1449857404597; Fri, 11 Dec 2015 10:10:04 -0800 (PST) Received: from ?IPv6:2601:181:c000:c497:a2a8:cdff:fe3e:b48? ([2601:181:c000:c497:a2a8:cdff:fe3e:b48]) by smtp.googlemail.com with ESMTPSA id t1sm8652835qki.44.2015.12.11.10.10.04 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Dec 2015 10:10:04 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: [PTX] some more cleanups Message-ID: <566B117B.8060604@acm.org> Date: Fri, 11 Dec 2015 13:10:03 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 This patch: 1) removes unused hard register defines 2) removes unused ASM_OUTPUT_COMMON, ASM_OUTPUT_LOCAL defines (we define the aligned variants) 3) name the static chain registers. 4) formatting and simplification to bunch of function argument/return hooks. In particular I found nvptx_function_arg_boundary quite confusing due to its mixing of BITS_PER_UNIT and BITS_PER_WORD. nathan 2015-12-11 Nathan Sidwell * config/nvptx/nvptx.h (RETURN_ADDR_REGNO): Delete. (OUTGOING_ARG_POINTER_REGNUM): Delete. (ASM_OUTPUT_COMMON, ASM_OUTPUT_LOCAL): Delete. (REGISTER_NAMES): Name static chain regs. * config/nvptx/nvptx.c (nvptx_function_arg): Add ARG_UNUSED, merge ifs. (nvptx_incoming_arg): Merge ifs. (nvptx_function_arg_boundary): Reimplement to avoid mixing units. (nvptx_function_value): Tail call nvptx_libcall_value. (nvptx_pass_by_reference): Add ARG_UNUSED. (nvptx_static_chain): Use conditional op. (nvptx_handle_kernel_attribute): Use VOID_TYPE_P. Index: gcc/config/nvptx/nvptx.c =================================================================== --- gcc/config/nvptx/nvptx.c (revision 231564) +++ gcc/config/nvptx/nvptx.c (working copy) @@ -392,15 +392,13 @@ arg_promotion (machine_mode mode) /* Implement TARGET_FUNCTION_ARG. */ static rtx -nvptx_function_arg (cumulative_args_t, machine_mode mode, +nvptx_function_arg (cumulative_args_t ARG_UNUSED (cum_v), machine_mode mode, const_tree, bool named) { - if (mode == VOIDmode) + if (mode == VOIDmode || !named) return NULL_RTX; - if (named) - return gen_reg_rtx (mode); - return NULL_RTX; + return gen_reg_rtx (mode); } /* Implement TARGET_FUNCTION_INCOMING_ARG. */ @@ -410,10 +408,8 @@ nvptx_function_incoming_arg (cumulative_ const_tree, bool named) { CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); - if (mode == VOIDmode) - return NULL_RTX; - if (!named) + if (mode == VOIDmode || !named) return NULL_RTX; /* No need to deal with split modes here, the only case that can @@ -433,6 +429,7 @@ nvptx_function_arg_advance (cumulative_a bool ARG_UNUSED (named)) { CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); + cum->count++; } @@ -449,6 +446,7 @@ static bool nvptx_strict_argument_naming (cumulative_args_t cum_v) { CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); + return cum->fntype == NULL_TREE || stdarg_p (cum->fntype); } @@ -460,21 +458,19 @@ nvptx_function_arg_boundary (machine_mod unsigned int boundary = type ? TYPE_ALIGN (type) : GET_MODE_BITSIZE (mode); if (boundary > BITS_PER_WORD) - return 2 * BITS_PER_WORD; - - if (mode == BLKmode) + boundary = 2 * BITS_PER_WORD; + else if (mode == BLKmode) { HOST_WIDE_INT size = int_size_in_bytes (type); + if (size > 4) - return 2 * BITS_PER_WORD; - if (boundary < BITS_PER_WORD) - { - if (size >= 3) - return BITS_PER_WORD; - if (size >= 2) - return 2 * BITS_PER_UNIT; - } + boundary = 8 * BITS_PER_UNIT; + else if (size > 2) + boundary = 4 * BITS_PER_UNIT; + else + boundary = size * BITS_PER_UNIT; } + return boundary; } @@ -487,6 +483,7 @@ nvptx_libcall_value (machine_mode mode, /* Pretend to return in a hard reg for early uses before pseudos can be generated. */ return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM); + return gen_reg_rtx (mode); } @@ -503,11 +500,8 @@ nvptx_function_value (const_tree type, c &unsignedp, NULL_TREE, 1); if (outgoing) return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM); - if (cfun->machine->start_call == NULL_RTX) - /* Pretend to return in a hard reg for early uses before pseudos can be - generated. */ - return gen_rtx_REG (mode, NVPTX_RETURN_REGNUM); - return gen_reg_rtx (mode); + + return nvptx_libcall_value (mode, NULL_RTX); } /* Implement TARGET_FUNCTION_VALUE_REGNO_P. */ @@ -522,8 +516,8 @@ nvptx_function_value_regno_p (const unsi reference in memory. */ static bool -nvptx_pass_by_reference (cumulative_args_t, machine_mode mode, - const_tree type, bool) +nvptx_pass_by_reference (cumulative_args_t ARG_UNUSED (cum), machine_mode mode, + const_tree type, bool ARG_UNUSED (named)) { return !PASS_IN_REG_P (mode, type); } @@ -572,10 +566,9 @@ nvptx_static_chain (const_tree fndecl, b if (!DECL_STATIC_CHAIN (fndecl)) return NULL; - if (incoming_p) - return gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM); - else - return gen_rtx_REG (Pmode, OUTGOING_STATIC_CHAIN_REGNUM); + + return gen_rtx_REG (Pmode, (incoming_p ? STATIC_CHAIN_REGNUM + : OUTGOING_STATIC_CHAIN_REGNUM)); } /* Helper for write_arg. Emit a single PTX argument of MODE, either @@ -3829,8 +3822,7 @@ nvptx_handle_kernel_attribute (tree *nod error ("%qE attribute only applies to functions", name); *no_add_attrs = true; } - - else if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node) + else if (!VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl)))) { error ("%qE attribute requires a void return type", name); *no_add_attrs = true; Index: gcc/config/nvptx/nvptx.h =================================================================== --- gcc/config/nvptx/nvptx.h (revision 231564) +++ gcc/config/nvptx/nvptx.h (working copy) @@ -153,10 +153,8 @@ enum reg_class #define NVPTX_RETURN_REGNUM 4 #define FRAME_POINTER_REGNUM 15 #define ARG_POINTER_REGNUM 14 -#define RETURN_ADDR_REGNO 13 #define STATIC_CHAIN_REGNUM 12 -#define OUTGOING_ARG_POINTER_REGNUM 11 #define OUTGOING_STATIC_CHAIN_REGNUM 10 #define FIRST_PARM_OFFSET(FNDECL) ((void)(FNDECL), 0) @@ -251,13 +249,10 @@ struct GTY(()) machine_function #undef ASM_APP_OFF #define ASM_APP_OFF "\t// #NO_APP \n" -#define ASM_OUTPUT_COMMON(stream, name, size, rounded) -#define ASM_OUTPUT_LOCAL(stream, name, size, rounded) - #define REGISTER_NAMES \ { \ - "%hr0", "%outargs", "%hfp", "%hr3", "%retval", "%retval_in", "%hr6", "%hr7", \ - "%hr8", "%hr9", "%hr10", "%hr11", "%hr12", "%hr13", "%argp", "%frame" \ + "%hr0", "%outargs", "%hfp", "%hr3", "%retval", "%hr5", "%hr6", "%hr7", \ + "%hr8", "%hr9", "%chain_out", "%hr11", "%chain_in", "%hr13", "%argp", "%frame" \ } #define DBX_REGISTER_NUMBER(N) N