From patchwork Mon Dec 7 13:53:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 553395 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 0083A1402A0 for ; Tue, 8 Dec 2015 00:53:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=R9IXDrCH; 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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=gcFuVWaN26dj2enTdkECa5H3w2PJ9bRA1pxDA/A6+OqgYp7+It PZgvXaLCD5ag5beb+6xgaM6q6NcmD/Z27Oez4pWlaWIqZ7aaW7/wOSlMrrHL3Alt ZVPcJ9W/JtTwKfiKc5lColgKCfqk/Mgv8K0cvhkGmoSShRFIEeLNbOnKk= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=ZLPYV7+emI+WDvP1ubRexz0JHEg=; b=R9IXDrCHBEHKKB8BMJpd Yuq3LjGpMWpXN+JVqs5bHq3FIoJz9TjWtfcnq3SFNm7GhEqOYtbClAGx/bFIcPGP ps+H3H4xFwlh3HPu4VHDy+4LebVTDTmFWH8yQxIf/QUZ0UjsQJfIndZqsmSKDEY/ VVbe4OfB3vdVFrfXQQynHGQ= Received: (qmail 33698 invoked by alias); 7 Dec 2015 13:53:30 -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 33689 invoked by uid 89); 7 Dec 2015 13:53:29 -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-qk0-f182.google.com Received: from mail-qk0-f182.google.com (HELO mail-qk0-f182.google.com) (209.85.220.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 07 Dec 2015 13:53:28 +0000 Received: by qkdb5 with SMTP id b5so31022449qkd.0 for ; Mon, 07 Dec 2015 05:53:26 -0800 (PST) X-Received: by 10.55.41.138 with SMTP id p10mr22649064qkp.18.1449496406202; Mon, 07 Dec 2015 05:53:26 -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 81sm11620668qhx.15.2015.12.07.05.53.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Dec 2015 05:53:25 -0800 (PST) To: GCC Patches Cc: Alexander Monakov From: Nathan Sidwell Subject: [PTX] Message-ID: <56658F55.2050406@acm.org> Date: Mon, 7 Dec 2015 08:53:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Alex pointed me at his ptx patch https://gcc.gnu.org/ml/gcc-patches/2015-10/msg03393.html but meanwhile I'd reorganized that part of the PTX backend. This patch implements Alex's patch in the new code base. There are some minor additions. 1) we also look inside vector types. 2) we only limit to Pmode, if the type's mode is BLKmode. Those are the structs where we can't tell whether a pointer initialization will happen. I think there's still some cleanup on the init emission -- now the object size is alwasy a multiple of the element size, we don't have to deal with any trailing partial elements. nathan 2015-12-07 Nathan Sidwell gcc/ * config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Look inside complex and vector types. Cope with packed structs. gcc/testsuite/ * gcc.target/nvptx/decl-init.c: New. Index: config/nvptx/nvptx.c =================================================================== --- config/nvptx/nvptx.c (revision 231361) +++ config/nvptx/nvptx.c (working copy) @@ -1643,17 +1644,24 @@ nvptx_assemble_decl_begin (FILE *file, c while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); - if (!INTEGRAL_TYPE_P (type) && !SCALAR_FLOAT_TYPE_P (type)) - type = ptr_type_node; + if (TREE_CODE (type) == VECTOR_TYPE + || TREE_CODE (type) == COMPLEX_TYPE) + /* Neither vector nor complex types can contain the other. */ + type = TREE_TYPE (type); + unsigned elt_size = int_size_in_bytes (type); - if (elt_size > UNITS_PER_WORD) - { - type = ptr_type_node; - elt_size = int_size_in_bytes (type); - } + + /* Largest mode we're prepared to accept. For BLKmode types we + don't know if it'll contain pointer constants, so have to choose + pointer size, otherwise we can choose DImode. */ + machine_mode elt_mode = TYPE_MODE (type) == BLKmode ? Pmode : DImode; + + elt_size |= GET_MODE_SIZE (elt_mode); + elt_size &= -elt_size; /* Extract LSB set. */ + elt_mode = mode_for_size (elt_size * BITS_PER_UNIT, MODE_INT, 0); decl_chunk_size = elt_size; - decl_chunk_mode = int_mode_for_mode (TYPE_MODE (type)); + decl_chunk_mode = elt_mode; decl_offset = 0; init_part = 0; Index: testsuite/gcc.target/nvptx/decl-init.c =================================================================== --- testsuite/gcc.target/nvptx/decl-init.c (revision 0) +++ testsuite/gcc.target/nvptx/decl-init.c (working copy) @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-long-long" } */ + +__extension__ _Complex float cf = 1.0f + 2.0if; +__extension__ _Complex double cd = 3.0 + 4.0i; + +long long la[2] = + {0x0102030405060708ll, + 0x1112131415161718ll}; + +struct six +{ + char a; + short b, c; +}; + +struct six six1 = {1, 2, 3}; +struct six six2[2] = {{4, 5, 6}, {7, 8, 9}}; + +struct __attribute__((packed)) five +{ + char a; + int b; +}; +struct five five1 = {10, 11}; +struct five five2[2] = {{12, 13}, {14, 15}}; + +int __attribute__((vector_size(16))) vi = {16, 17, 18, 19}; + +/* dg-final { scan-assembler ".align 4 .u32 cf\\\[2\\\] = { 1065353216, 1073741824 };" } } */ +/* dg-final { scan-assembler ".align 8 .u64 df\\\[2\\\] = { 4613937818241073152, 4616189618054758400 };" } } */ +/* dg-final { scan-assembler ".align 8 .u64 la\\\[2\\\] = { 72623859790382856, 1230066625199609624 };" } } */ +/* dg-final { scan-assembler ".align 2 .u16 six1\\\[3\\\] = { 1, 2, 3 };" } } */ +/* dg-final { scan-assembler ".align 2 .u16 six2\\\[6\\\] = { 4, 5, 6, 7, 8, 9 };" } } */ +/* dg-final { scan-assembler ".align 1 .u8 five1\\\[5\\\] = { 10, 11, 0, 0, 0 };" } } */ +/* dg-final { scan-assembler ".align 1 .u8 five2\\\[10\\\] = { 12, 13, 0, 0, 0, 14, 15, 0, 0, 0 };" } } */ +/* dg-final { scan-assembler ".align 8 .u32 vi\\\[4\\\] = { 16, 17, 18, 19 };" } } */