From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 16765385E01D for ; Thu, 4 Jan 2024 09:33:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16765385E01D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 16765385E01D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704360793; cv=none; b=RUnQPkGx9n0mbZCRshOB9Xa3bFrU7Q3df/ybisBaj8f4U1/M1M5jtKubBff9DXpMYdO2q1RU1yMc/+8cA5/TCrBsmi16EhCc5bsp/HFr6OMPIy2T8EMWyrXSNUo/MG+3wIcrcd7zLAfiAMOiUt9Fl/8Gq2uOuLf+R1Py4ZinYDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704360793; c=relaxed/simple; bh=dLyn+DutxlQ0/GjTnjGILBkrREyGdwvB5dt+bJcwaYY=; h=Subject:From:To:Message-ID:Date:MIME-Version; b=vrxJa7I95EtVAiPuitO2PHJW0Pdc14RjYNCnr5WUwpeEzsQeEYNIsgQieofYAmBHOkTz6vpxQspBOEmewbvWEIqcH0ZVEPKyz3MA85dORgKBsRZnAQ0RoT0ALTWyEyEQxsuWZsxyeY8vcAIhRhfwPyFUaXDyg+FKlG3TU9EsAIc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLK68-00009z-QQ for gcc-patches@gcc.gnu.org; Thu, 04 Jan 2024 04:33:11 -0500 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Cx7+tPe5ZlA+gBAA--.7301S3; Thu, 04 Jan 2024 17:33:04 +0800 (CST) Received: from [10.20.4.107] (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx_4dOe5Zl6n0BAA--.3709S3; Thu, 04 Jan 2024 17:33:03 +0800 (CST) Subject: Re: [PATCH 1/2] LoongArch: Add the macro implementation of mcmodel=extreme. From: chenglulu To: Xi Ruoyao , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn References: <20231227084654.20614-1-chenglulu@loongson.cn> <20231227084654.20614-2-chenglulu@loongson.cn> <734aebe3f8159485e2e823699bf987c2f605eaa5.camel@xry111.site> Message-ID: <71f54a60-c134-a2ee-8d10-b56c5475af03@loongson.cn> Date: Thu, 4 Jan 2024 17:33:02 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8Dx_4dOe5Zl6n0BAA--.3709S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoWxuF1DJF45ur1UWw15JF1fuFX_yoW5Cr4rpr W8GF1UCrWUZrn5tw1xtw1UGryUtF4UKw45XF1rJFy0yw1Dtr1aqa4rZr9I9FyUCw4rWr1U XF1rX347Z3WUJFXCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Sb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv 67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07 AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C2 67AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI 8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWU CwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r 1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBI daVFxhVjvjDU0xZFpf9x07jb_-PUUUUU= Received-SPF: pass client-ip=114.242.206.163; envelope-from=chenglulu@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -36 X-Spam_score: -3.7 X-Spam_bar: --- X-Spam_report: (-3.7 / 5.0 requ) BAYES_00=-1.9,NICE_REPLY_A=-1.771,SPF_HELO_NONE=0.001,SPF_PASS=-0.001,T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,BODY_8BITS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_FAIL,SPF_HELO_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: 在 2024/1/4 下午5:05, chenglulu 写道: > > 在 2024/1/4 下午12:05, Xi Ruoyao 写道: >> On Thu, 2024-01-04 at 11:58 +0800, chenglulu wrote: >>> 在 2024/1/4 上午11:51, Xi Ruoyao 写道: >>>> On Wed, 2023-12-27 at 16:46 +0800, Lulu Cheng wrote: >>>>> +(define_insn "movdi_pcrel64" >>>>> + [(set (match_operand:DI 0 "register_operand" "=&r") >>>>> +       (match_operand:DI 1 "symbolic_pcrel64_operand")) >>>>> +  (unspec:DI [(const_int 0)] >>>>> +    UNSPEC_MOV_PCREL64) >>>>> +  (use (reg:DI T3_REGNUM)) >>>>> +  (clobber (reg:DI T3_REGNUM))] >>>> It's better not to hard code $t3 here.  We can write >>>> >>>> [(set (match_operand:DI 0 "register_operand" "=r") >>>>          (match_operand:DI 1 "symbolic_pcrel64_operand")) >>>>     (clobber (match_operand:DI 2 "register_operand "=&r"))] >>>> >>>> And use >>>> >>>>      gen_movdi_pcrel64 (operands[0], operands[1], gen_reg_rtx(DImode)) >>>> >>>> in expand. >>>> >>> I tried using (clobber (match_scratch)) when implementing it, but it >>> didn't work. >> I tried match_scratch a few times as well in my previous hacks but never >> succeeded :(. >> > In the function loongarch_output_mi_thunk, the address of the symbol > .LTHUNK0 > > will be obtained, but at this time it is no longer possible to apply > for temporary variables. > > So there will be ICE here > > See attachment for test cases. > > The compilation command is as follows: > > $ ./gcc/cc1plus -fpreprocessed example.ii -quiet -dumpbase example.cc > -dumpbase-ext .cc -mexplicit-relocs=none -mno-relax -mabi=lp64d > -march=loongarch64 -mfpu=64 -msimd=lasx -mcmodel=extreme > -mtune=loongarch64 -g3 -O2 -Wno-int-conversion -Wno-implicit-int > -Wno-implicit-function-declaration -Wno-incompatible-pointer-types > -std=c++98 -version -o example.s > > > I have now made the following modifications and are testing for correctness: @@ -7450,12 +7450,22 @@ loongarch_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,       allowed, otherwise load the address into a register first.  */    if (use_sibcall_p)      { -      insn = emit_call_insn (gen_sibcall_internal (fnaddr, const0_rtx)); +      if (TARGET_CMODEL_EXTREME) +       { +         emit_insn (gen_movdi_pcrel64 (temp1, fnaddr, temp2)); +         insn = emit_call_insn (gen_sibcall_internal (temp1, const0_rtx)); +       } +      else +       insn = emit_call_insn (gen_sibcall_internal (fnaddr, const0_rtx));        SIBLING_CALL_P (insn) = 1;      }    else      { -      loongarch_emit_move (temp1, fnaddr); +      if (TARGET_CMODEL_EXTREME) +       emit_insn (gen_movdi_pcrel64 (temp1, fnaddr, temp2)); +      else +       loongarch_emit_move (temp1, fnaddr); +        emit_jump_insn (gen_indirect_jump (temp1));      }