From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 68842 invoked by alias); 21 Oct 2016 22:16:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 68831 invoked by uid 89); 21 Oct 2016 22:16:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=Human, Within, duty, Natural X-HELO: out28-99.mail.aliyun.com Received: from out28-99.mail.aliyun.com (HELO out28-99.mail.aliyun.com) (115.124.28.99) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Oct 2016 22:16:42 +0000 X-Alimail-AntiSpam:AC=CONTINUE;BC=0.07715496|-1;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03311;MF=chengang@emindsoft.com.cn;NM=1;PH=DS;RN=8;RT=8;SR=0;TI=SMTPD_---.74rwrKJ_1477088192; Received: from ShengShiZhuChengdeMacBook-Pro.local(mailfrom:chengang@emindsoft.com.cn ip:223.72.82.71) by smtp.aliyun-inc.com(10.147.41.231); Sat, 22 Oct 2016 06:16:33 +0800 Message-ID: <580A95A6.10308@emindsoft.com.cn> Date: Fri, 21 Oct 2016 22:16:00 -0000 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Jeff Law CC: rth@redhat.com, mikestump@comcast.net, gcc-patches@gcc.gnu.org, cmetcalf@ezchip.com, walt@tilera.com, peter.maydell@linaro.org, Chen Gang Subject: Re: [PATCH v3] gcc/config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 to stack before call mcount References: <1465046750-3021-1-git-send-email-chengang@emindsoft.com.cn> <57F6573F.5010003@emindsoft.com.cn> <6cafbf03-21ed-059c-4c4a-e9429ab3ad97@redhat.com> In-Reply-To: <6cafbf03-21ed-059c-4c4a-e9429ab3ad97@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-10/txt/msg01814.txt.bz2 On 10/20/16 06:42, Jeff Law wrote: >> On 6/4/16 21:25, chengang@emindsoft.com.cn wrote: >>> From: Chen Gang >>> >>> r10 may also be as parameter stack pointer for the nested function, so >>> need save it before call mcount. >>> >>> Also clean up code: use '!' instead of "== 0" for checking >>> static_chain_decl and compute_total_frame_size. >>> >>> 2016-06-04 Chen Gang >>> >>> gcc/ >>> PR target/71331 >>> * config/tilegx/tilegx.c (tilegx_function_profiler): Save r10 >>> to stack before call mcount. >>> (tilegx_can_use_return_insn_p): Clean up code. > So if I understand the tilegx architecture correctly, you're issuing the r10 save & sp adjustment as a bundle, and the restore & sp adjustment as a bundle. > > The problem is the semantics of bunding on the tilegx effectively mean that all source operands are read in parallel, then all outputs occur in parallel. > > So if we take the bundle > > {addi sp,sp,-8 ; st sp, r10} > > The address used for the st is the value of the stack pointer before the addi instruction. > > Similarly for the restore r10 bundle. The address used for the load is sp before adjustment. > > Given my understanding of the tilegx bundling semantics, that seems wrong. > > Jeff > The comments on 1st page of "TILE-Gx Instruction Set Architecture": Individual instructions within a bundle must comply with certain register semantics. Read-after-write (RAW) dependencies are enforced between instruction bundles. There is no ordering within a bundle, and the numbering of pipelines or instruction slots within a bundle is only used for convenience and does not imply any ordering. Within an instruction bundle, it is valid to encode an output operand that is the same as an input operand. Because there is explicitly no implied dependency within a bundle, the semantics for this specify that the input operands for all instructions in a bundle are read before any of the output operands are written. Write-after-write (WAW) semantics between two bundles are defined as: the latest write over-writes earlier writes. Within a bundle, WAW dependencies are forbidden. If more than one instruction in a bundle writes to the same output operand register, unpredictable results for any destination operand within that bundle can occur. Also, implementations are free to signal this case as an illegal instruction. There is one exception to this rule—multiple instructions within a bundle may legally target the zero register. Lastly, some instructions, such as instructions that implicitly write the link register, implicitly write registers. If an instruction implicitly writes to a register that another instruction in the same bundle writes to, unpredictable results can occur for any output register used by that bundle and/or an illegal instruction interrupt can occur. On Page 221, ld instruction is: ld Dest, Src On Page 251, st instruction is: st SrcA, SrcB So for me: Bundle {addi sp, sp, 8; ld r10, sp} is OK, it is RAW. Bundle {addi sp, sp, -8; st sp, r10} is OK, too, it is RAW (not WAW -- both SrcA and SrcB are input operands). Please help check, if need the related document, please let me know. Thanks. -- Chen Gang (陈刚) Managing Natural Environments is the Duty of Human Beings.