From patchwork Wed Sep 9 18:14:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 515953 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 26EA5140497 for ; Thu, 10 Sep 2015 04:14:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=psq7yCdK; 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=NnnY7c8/8nkkBwzt4XmZDNtoL3Tv8uKqt/h6qFgYwywnNoyxLc 9k4bvZ3gvtorJBEeXjDiOml0Oys9v2J1IJFIpj9phNOSKduQe6je+R/CEn8XoGcp hqM0Z2IosUCoROpKi0jGLJ6QiHAfC8dfHlClr2nmHQi1b1nQ7CIKJHpJc= 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=jCfRQrmyRyp96FclfKaIniZqhxw=; b=psq7yCdKyO6ybkSoSowq VQZ88ik4C0ORkRMT2IwgehuYIOuTREySTj77GNtkaT0bFY2aUHG/1MgUzNRYlTt3 09wTdq1uqsq+SBAc0dsL1Nq+Cuu6EsVwxXzyefqJf1U4AyvxCvaXDjvW96c1Xsfs Bq4T+Sz5Rpn/Y85dlAOtnXw= Received: (qmail 88226 invoked by alias); 9 Sep 2015 18:14:43 -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 88175 invoked by uid 89); 9 Sep 2015 18:14:42 -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-f42.google.com Received: from mail-qg0-f42.google.com (HELO mail-qg0-f42.google.com) (209.85.192.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 09 Sep 2015 18:14:37 +0000 Received: by qgt47 with SMTP id 47so15101881qgt.2 for ; Wed, 09 Sep 2015 11:14:32 -0700 (PDT) X-Received: by 10.140.93.139 with SMTP id d11mr2568532qge.83.1441822472821; Wed, 09 Sep 2015 11:14:32 -0700 (PDT) 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 p93sm4357240qkh.44.2015.09.09.11.14.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 11:14:32 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [gomp4] ptx patches from trunk Message-ID: <55F07707.20807@acm.org> Date: Wed, 9 Sep 2015 14:14:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 I've applied this to gomp4, which ports a bunch of cleanups and fixes from trunk. nathan 2015-09-09 Nathan Sidwell Port from trunk: * config/nvptx/nvptx.md (allocate_stack): Emit sorry. (atomic_compare_and_swap_1): Use sel_truesi. * config/nvptx/nvptx.c (nvptx_write_function_decl): Reformat. (nvptx_reorg_subreg): Pass insn pattern to asm_operands. (walk_args_for_param): Use arg_promotion for both split and non-split args. (nvptx_declare_function_name): Insert formatting tabs for consistency. Look at crtl->stack_alignment_needed to determine alignment. (nvptx_get_drap_rtx): New. (TARGET_GET_DRAP_RTX): Override. * config/nvptx/nvptx.h (MAX_STACK_ALIGNMENT): Set. Index: gcc/config/nvptx/nvptx.c =================================================================== --- gcc/config/nvptx/nvptx.c (revision 227598) +++ gcc/config/nvptx/nvptx.c (working copy) @@ -425,7 +425,8 @@ nvptx_write_function_decl (std::stringst /* Declare argument types. */ if ((args != NULL_TREE - && !(TREE_CODE (args) == TREE_LIST && TREE_VALUE (args) == void_type_node)) + && !(TREE_CODE (args) == TREE_LIST + && TREE_VALUE (args) == void_type_node)) || is_main || return_in_mem || DECL_STATIC_CHAIN (decl)) @@ -509,8 +510,8 @@ walk_args_for_param (FILE *file, tree ar mode = DFmode; } - mode = arg_promotion (mode); } + mode = arg_promotion (mode); while (count-- > 0) { i++; @@ -649,7 +650,7 @@ nvptx_declare_function_name (FILE *file, else if (TYPE_MODE (result_type) != VOIDmode) { machine_mode mode = arg_promotion (TYPE_MODE (result_type)); - fprintf (file, ".reg%s %%retval;\n", + fprintf (file, "\t.reg%s %%retval;\n", nvptx_ptx_type_from_mode (mode, false)); } @@ -701,9 +702,11 @@ nvptx_declare_function_name (FILE *file, sz = get_frame_size (); if (sz > 0 || cfun->machine->has_call_with_sc) { + int alignment = crtl->stack_alignment_needed / BITS_PER_UNIT; + fprintf (file, "\t.reg.u%d %%frame;\n" - "\t.local.align 8 .b8 %%farray[" HOST_WIDE_INT_PRINT_DEC"];\n", - BITS_PER_WORD, sz == 0 ? 1 : sz); + "\t.local.align %d .b8 %%farray[" HOST_WIDE_INT_PRINT_DEC"];\n", + BITS_PER_WORD, alignment, sz == 0 ? 1 : sz); fprintf (file, "\tcvta.local.u%d %%frame, %%farray;\n", BITS_PER_WORD); } @@ -719,10 +722,10 @@ nvptx_declare_function_name (FILE *file, walk_args_for_param (file, TYPE_ARG_TYPES (fntype), DECL_ARGUMENTS (decl), true, return_in_mem); if (return_in_mem) - fprintf (file, "ld.param.u%d %%ar1, [%%in_ar1];\n", + fprintf (file, "\tld.param.u%d %%ar1, [%%in_ar1];\n", GET_MODE_BITSIZE (Pmode)); if (stdarg_p (fntype)) - fprintf (file, "ld.param.u%d %%argp, [%%in_argp];\n", + fprintf (file, "\tld.param.u%d %%argp, [%%in_argp];\n", GET_MODE_BITSIZE (Pmode)); } @@ -830,6 +833,14 @@ nvptx_function_ok_for_sibcall (tree, tre return false; } +/* Return Dynamic ReAlignment Pointer RTX. For PTX there isn't any. */ + +static rtx +nvptx_get_drap_rtx (void) +{ + return NULL_RTX; +} + /* Implement the TARGET_CALL_ARGS hook. Record information about one argument to the next call. */ @@ -4330,6 +4341,8 @@ nvptx_goacc_reduction (gimple call) #define TARGET_LIBCALL_VALUE nvptx_libcall_value #undef TARGET_FUNCTION_OK_FOR_SIBCALL #define TARGET_FUNCTION_OK_FOR_SIBCALL nvptx_function_ok_for_sibcall +#undef TARGET_GET_DRAP_RTX +#define TARGET_GET_DRAP_RTX nvptx_get_drap_rtx #undef TARGET_SPLIT_COMPLEX_ARG #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true #undef TARGET_RETURN_IN_MEMORY Index: gcc/config/nvptx/nvptx.h =================================================================== --- gcc/config/nvptx/nvptx.h (revision 227598) +++ gcc/config/nvptx/nvptx.h (working copy) @@ -58,6 +58,8 @@ #define BIGGEST_ALIGNMENT 64 #define STRICT_ALIGNMENT 1 +#define MAX_STACK_ALIGNMENT (1024 * 8) + /* Copied from elf.h and other places. We'd otherwise use BIGGEST_ALIGNMENT and fail a number of testcases. */ #define MAX_OFILE_ALIGNMENT (32768 * 8) Index: gcc/config/nvptx/nvptx.md =================================================================== --- gcc/config/nvptx/nvptx.md (revision 227598) +++ gcc/config/nvptx/nvptx.md (working copy) @@ -1274,6 +1274,12 @@ (match_operand 1 "nvptx_register_operand")] "" { + /* The ptx documentation specifies an alloca intrinsic (for 32 bit + only) but notes it is not implemented. The assembler emits a + confused error message. Issue a blunt one now instead. */ + sorry ("target cannot support alloca."); + emit_insn (gen_nop ()); + DONE; if (TARGET_ABI64) emit_insn (gen_allocate_stack_di (operands[0], operands[1])); else @@ -1498,14 +1504,12 @@ (match_operand:SI 7 "const_int_operand")] ;; failure model "" { - emit_insn (gen_atomic_compare_and_swap_1 (operands[1], operands[2], operands[3], - operands[4], operands[6])); + emit_insn (gen_atomic_compare_and_swap_1 + (operands[1], operands[2], operands[3], operands[4], operands[6])); - rtx tmp = gen_reg_rtx (GET_MODE (operands[0])); - emit_insn (gen_cstore4 (tmp, - gen_rtx_EQ (SImode, operands[1], operands[3]), - operands[1], operands[3])); - emit_insn (gen_andsi3 (operands[0], tmp, GEN_INT (1))); + rtx cond = gen_reg_rtx (BImode); + emit_move_insn (cond, gen_rtx_EQ (BImode, operands[1], operands[3])); + emit_insn (gen_sel_truesi (operands[0], cond, GEN_INT (1), GEN_INT (0))); DONE; })