From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by sourceware.org (Postfix) with ESMTPS id 2F71E385843C for ; Tue, 24 Aug 2021 19:52:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F71E385843C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f177.google.com with SMTP id w68so19304948pfd.0 for ; Tue, 24 Aug 2021 12:52:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HPKyazMWD6PBB8PCOYKgwYu1iA1uANbJDGCtWAIX+64=; b=tidxe/EjplBqfRR819xfKLjZGWt/syxRUIeLAfX4bS+GrOVOqNhv3C4GeF2A2LVgS0 lKYTy7jgQ5gY5Zg4W8FgNIQdrEeAk7bg10KPfr86qlb/yhzBZU5eYn58NZdiI4dgHKXL VH25e9o1EiULafJ8DsSBItxkcfF2Q7lp1XBOSxkNTOHmXIUTeSdVxwyf44CJ2WAWe20/ RtMjfrt9kmrH/3OcOFzrZ5P5jIvJULLFLbHpqw5DfNe5mAThrhsYYvhsmx0AOpJvTmkN 5Q5zLF7Df6GDaYYLufbw9TzdVj0VB741nnRUiACBMTfm9s3XJD6XAu/6bo84ObpxZW0/ aLSA== X-Gm-Message-State: AOAM533Fyem2HHFPAJsql3a6y/4kGU0yrp5AOQRzMJ0lQ07vt14CDX0R jIrS/6DkApxxgvzqTYUXhn4= X-Google-Smtp-Source: ABdhPJzvqR3IVmX2b55ZXJGmCmT5qUI9puTm1QZAp0H+ZBaFbsZ1gyy6oGzDYp1HorGvATz/fvuhqA== X-Received: by 2002:a65:689a:: with SMTP id e26mr39062059pgt.193.1629834770276; Tue, 24 Aug 2021 12:52:50 -0700 (PDT) Received: from localhost ([2601:647:4b01:ae80:1252:3b28:77d0:1fa2]) by smtp.gmail.com with ESMTPSA id c24sm23926928pgj.11.2021.08.24.12.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 12:52:49 -0700 (PDT) Date: Tue, 24 Aug 2021 12:52:48 -0700 From: Fangrui Song To: Paul Hua Cc: binutils , Xu Chenghua , caiyinyu@loongson.cn, chenglulu@loongson.cn, huangpei@loongson.cn, liuzhensong@loongson.cn, WANG Xuerui , Alan Modra Subject: Re: [PATCH 7/7][LoongArch] Opcodes support Message-ID: <20210824195248.rsjzz6kwc7qevowg@gmail.com> References: <20210814175843.lrk5eck6b5vs7sg6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210814175843.lrk5eck6b5vs7sg6@gmail.com> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 19:53:01 -0000 I filed https://github.com/loongson/LoongArch-Documentation/issues/9 so that the stack machine relocation concerns won't be buried in dust. On 2021-08-14, Fangrui Song wrote: >>+static struct loongarch_opcode loongarch_macro_opcodes[] = >>+{ >>[...] >>+ { 0, 0, "la.pcrel", "r,la", >>+ "pcaddu12i %1,%%pcrel(%2+0x800)>>12;" >>+ "addi.d %1,%1,%%pcrel(%2+4)-(%%pcrel(%2+4+0x800)>>12<<12);", >>+ &LARCH_opts.addrwidth_is_64, 0, 0 }, >>+ { 0, 0, "la.pcrel", "r,r,la", >>+ "pcaddu12i %1,(%%pcrel(%3)-(%%pcrel(%3+0x80000000)>>32<<32))<<32>>44;" >>+ "ori %2,$r0,(%%pcrel(%3+4)-(%%pcrel(%3+4+0x80000000)>>32<<32))&0xfff;" >>+ "lu32i.d %2,%%pcrel(%3+8+0x80000000)<<12>>44;" >>+ "lu52i.d %2,%2,%%pcrel(%3+12+0x80000000)>>52;" >>+ "add.d %1,%1,%2;", >>+ &LARCH_opts.addrwidth_is_64, 0, 0 }, >>+ >>+ { 0, 0, "la.got", "r,l", >>+ "pcaddu12i %1,(%%pcrel(_GLOBAL_OFFSET_TABLE_+0x800)+%%gprel(%2))<<32>>44;" >>+ "ld.w " >>+ "%1,%1,%%pcrel(_GLOBAL_OFFSET_TABLE_+4)+%%gprel(%2)-((%%pcrel(_GLOBAL_" >>+ "OFFSET_TABLE_+4+0x800)+%%gprel(%2))>>12<<12);", >>+ &LARCH_opts.addrwidth_is_32, 0, 0 }, > >Relocations don't need support for arbitrary shifts. Just hard code the >possible shift variants and the implementation will be much cleaner, no >need for a long list of R_LARCH_SOP_PUSH_*. > >See xen0n's comment on https://github.com/loongson/LoongArch-Documentation/pull/3#issuecomment-894672071 > >>Plus it seems there's a stack machine implemented with relocation records. I think this is bad for these reasons: >> >>Fragility could ensue due to tools not respecting relative order of relocation records on the same address; >>It's superficial, conveying actions and not motivations, which is generally bad smell in software engineering; >>Not much complexity is shed by the introduction of intended flexibility here, so it wasn't exactly profitable either; >>No prior cases wheresoever found in public code, so it's not sure if the scheme is to be appreciated universally. > >Tests nearly do not exist. There is only a nop test. > >% ls gas/testsuite/gas/loongarch/ >nop.d loongarch.exp nop.s