[PATCH v8] Add macros to get opcode of instructions appropriately
ywgrit
wangxin03@loongson.cn
Thu Aug 29 06:55:26 GMT 2024
在 2024/8/28 下午3:33, Lulu Cai 写道:
> I noticed that there was a gas test failure.
> FAIL: loongarch illegal-operand
>
>
> On 8/27/24 8:25 PM, Xin Wang wrote:
>> LoongArch: Add macros to get opcode and register of instructions
>> appropriately
>>
>> Currently, we get opcode of an instruction by manipulate the binary with
>> it's mask, it's a bit of a pain. Now a macro is defined to do this and a
>> macro to get the RD and RJ registers which is applicable to most
>> instructions
>> of LoongArch are added.
>>
>
> /* Snip. */
>
>> diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
>> index 5ca33c6e2e8..df417313e9e 100644
>> --- a/gas/config/tc-loongarch.c
>> +++ b/gas/config/tc-loongarch.c
>> @@ -1078,34 +1078,32 @@ check_this_insn_before_appending (struct
>> loongarch_cl_insn *ip)
>> ip->reloc_info[ip->reloc_num].value = const_0;
>> ip->reloc_num++;
>> }
>> - else if (ip->insn->mask == 0xffff8000
>> - /* amcas.b rd, rk, rj */
>> - && ((ip->insn_bin & 0xfff80000) == 0x38580000
>> - /* amswap.w rd, rk, rj */
>> - || (ip->insn_bin & 0xfff00000) == 0x38600000
>> - /* ammax_db.wu rd, rk, rj */
>> - || (ip->insn_bin & 0xffff0000) == 0x38700000
>> - /* ammin_db.wu rd, rk, rj */
>> - || (ip->insn_bin & 0xffff0000) == 0x38710000))
>> + /* check all atomic memory insns */
>> + else if (ip->insn->mask == LARCH_MK_ATOMIC_MEM
>> + && LARCH_INSN_ATOMIC_MEM(ip->insn_bin))
>> {
>> /* For AMO insn amswap.[wd], amadd.[wd], etc. */
>> if (ip->args[0] != 0
>> && (ip->args[0] == ip->args[1] || ip->args[0] == ip->args[2]))
>> - as_bad (_("automic memory operations insns require rd != rj"
>> + as_bad (_("atomic memory operations insns require rd != rj"
>> " && rd != rk when rd isn't r0"));
>> }
>> - else if ((ip->insn->mask == 0xffe08000
>> + else if ((ip->insn->mask == LARCH_MK_BSTRINS_W
>> /* bstrins.w rd, rj, msbw, lsbw */
>> - && (ip->insn_bin & 0xffe00000) == 0x00600000)
>> - || (ip->insn->mask == 0xffc00000
>> + && LARCH_INSN_BSTRINS_W(ip->insn_bin))
>> + || (ip->insn->mask == LARCH_MK_BSTRINS_D
>> /* bstrins.d rd, rj, msbd, lsbd */
>> - && (ip->insn_bin & 0xff800000) == 0x00800000))
>> + && LARCH_INSN_BSTRINS_D(ip->insn_bin)))
>
> Here bstr(ins|pick).[wd] is checked instead of just bstrins.[wd].
>
I'll fix this and correct the comments.
>> {
>> /* For bstr(ins|pick).[wd]. */
>> if (ip->args[2] < ip->args[3])
>> as_bad (_("bstr(ins|pick).[wd] require msbd >= lsbd"));
>> }
>>
>
More information about the Binutils
mailing list