public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: liuzhensong <liuzhensong@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, binutils@sourceware.org
Cc: i.swmail@xen0n.name, maskray@google.com, xuchenghua@loongson.cn,
	mengqinggang@loongson.cn, huangpei@loongson.cn,
	chenglulu@loongson.cn, caiyinyu@loongson.cn
Subject: Re: [PATCH v2 2/6] LoongArch:opcodes: Add new reloc types.
Date: Thu, 21 Jul 2022 14:02:30 +0800	[thread overview]
Message-ID: <ca165756-e2c2-00f6-0737-0158e389266e@loongson.cn> (raw)
In-Reply-To: <78913d16dde639083a318f62facc30713deec3fb.camel@xry111.site>


在 2022/7/21 上午10:30, Xi Ruoyao 写道:
> On Thu, 2022-07-21 at 09:37 +0800, liuzhensong wrote:
>> +#define INSN_LA_ABS64                  \
>> +  "lu12i.w %1,%%abs_hi20(%2);"         \
>> +  "ori %1,%1,%%abs_lo12(%2);"          \
>> +  "lu32i.d %1,%%abs64_lo20(%2);"       \
>> +  "lu52i.d %1,%1,%%abs64_hi12(%2);",   \
>> +  &LARCH_opts.ase_lp64, 0
> Is it possible to use
>
> lu12i.w %1, %%abs_hi20(%2)
> lu32i.d %1, %%abs_lo12(%2)
> lu52i.d %1, %1, %%abs64_hi12(%2)
> addi.d  %1, %1, %%abs64_lo12(%2)
>
> so a future linker relaxation (or some optimization, anyway) may combine
> the last addi.d instruction with a following ld instruction?  Like
>
> la.abs64 $t0, foo
> ld.d     $t0, $t0, 0
>
> =>
>
> lu12i.w $t0, %abs_hi20(foo)
> lu32i.d $t0, %abs_lo12(foo)
> lu52i.d $t0, $t0, %abs64_hi12(foo)
> ld.d    $t0, $t0, %abs64_lo12(foo)
>
> (Doing so will need to take the highest bit of lo12 as a carry into the
> higher 52 bits.)
>
It seems default for addi.d/ld.d to access extreme address.

Simple example of abs32:

address range of abs32 : 0~0xffffffff

sym address: 0xfffff800

lui12.w $rd, 0xfffff

ori $rd, $d, 0x800

$rd is 0xfffff800

Obviously, lu12i.w and addi.w/ld.w can not get address > 0xfffff7fc abs64 is exactly same as abs32.
However, it is good idea to replace (lu12i.w,ori,ld.w) with (lu12i.w ld.w) if sym address in range -2G-2k  ~~  +2G-2k?





  reply	other threads:[~2022-07-21  6:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21  1:37 [PATCH v2 0/6] Add new relocations for LoongArch liuzhensong
2022-07-21  1:37 ` [PATCH v2 1/6] bfd: Add supported for LoongArch new relocations liuzhensong
2022-07-21  1:37 ` [PATCH v2 2/6] LoongArch:opcodes: Add new reloc types liuzhensong
2022-07-21  2:30   ` Xi Ruoyao
2022-07-21  6:02     ` liuzhensong [this message]
2022-07-21  7:51       ` Xi Ruoyao
2022-07-21  8:26         ` liuzhensong
2022-07-21  1:37 ` [PATCH v2 3/6] LoongArch: gas: " liuzhensong
2022-07-21  1:37 ` [PATCH v2 4/6] LoongArch: Move ifunc info to rela.dyn from rela.plt liuzhensong
2022-07-21  1:37 ` [PATCH v2 5/6] bfd: Delete R_LARCH_NONE from dyn info of LoongArch liuzhensong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca165756-e2c2-00f6-0737-0158e389266e@loongson.cn \
    --to=liuzhensong@loongson.cn \
    --cc=binutils@sourceware.org \
    --cc=caiyinyu@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=huangpei@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=maskray@google.com \
    --cc=mengqinggang@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).