From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id A3C60385841C for ; Fri, 18 Nov 2022 17:49:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A3C60385841C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,175,1665475200"; d="scan'208";a="87554296" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 18 Nov 2022 09:49:46 -0800 IronPort-SDR: Aip0VIyQ3/s225Tk5xSjBu5iV12hG8ObMBwaCR/WZrKx0Le+E35RdacGk07TaS/m3/ZJKwHRnv toU+E98JejxJwVKMmIjCkM9XaGtdV7ZGjQU8MxelxEM+XQGdeRZllmel5pRIpYvDnp+roZ3fiP YW9Bq/g46ebJFp0mwG8JAfpXxEmnqXNQu1wV1Y74hIlZW06jQyCagtI1JExRVz2aX6ALf+3yUz zqizVnRUUocYvS32oyTg3Gmhbt+0twa4LYxCMBaD8PBR70tVM2rZ8NnwZd9TgB5km9CaSoD1ZB Lqo= Message-ID: Date: Fri, 18 Nov 2022 17:49:41 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [Patch] gcn: Add __builtin_gcn_{get_stack_limit,first_call_this_thread_p} To: Tobias Burnus , gcc-patches References: <1bec26d6-e2c5-3408-4f61-0fb17e730b3e@codesourcery.com> Content-Language: en-GB From: Andrew Stubbs In-Reply-To: <1bec26d6-e2c5-3408-4f61-0fb17e730b3e@codesourcery.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 18/11/2022 17:20, Tobias Burnus wrote: > This patch adds two builtins (getting end-of-stack pointer and > a Boolean answer whether it was the first call to the builtin on this > thread). > > The idea is to replace some hard-coded values in newlib, permitting to move > later to a manually allocated stack on the compiler side without the > need to > modify newlib again. The GCC patch matches what newlib did in reent; I > could > imagine that we change this later on. > > Lightly tested (especially by visual inspection). > Currently doing a final regtest, OK when it passes? > > Any  comments to this patch - or the attached newlib patch?* > > Tobias > > (*) I also included a patch to newlib to see where were are heading > + to actually use them for regtesting ... This looks wrong: > + /* stackbase = (stack_segment_decr & 0x0000ffffffffffff) > + + stack_wave_offset); > + seg_size = dispatch_ptr->private_segment_size; > + stacklimit = stackbase + seg_size*64; > + with segsize = dispatch_ptr + 6*sizeof(int16_t) + 3*sizeof(int32_t); > + cf. struct hsa_kernel_dispatch_packet_s in the HSA doc. */ > + rtx ptr; > + if (cfun->machine->args.reg[DISPATCH_PTR_ARG] >= 0 > + && cfun->machine->args.reg[PRIVATE_SEGMENT_BUFFER_ARG] >= 0) > + { > + rtx size_rtx = gen_rtx_REG (DImode, > + cfun->machine->args.reg[DISPATCH_PTR_ARG]); > + size_rtx = gen_rtx_MEM (DImode, > + gen_rtx_PLUS (DImode, size_rtx, > + GEN_INT (6*16 + 3*32))); > + size_rtx = gen_rtx_MULT (DImode, size_rtx, GEN_INT (64)); > + seg_size is calculated from the private_segment_size loaded from the dispatch_ptr, not calculated from the dispatch_ptr itself. Andrew