This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH v3] Work around the NOP issue of Loongson2F
- From: Wu Zhangjin <wuzhangjin at gmail dot com>
- To: Richard Sandiford <rdsandiford at googlemail dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, "Alfred M. Szmidt" <ams at gnu dot org>, zhangfx at lemote dot com, yanh at lemote dot com, binutils at sourceware dot org
- Date: Wed, 18 Nov 2009 13:35:19 +0800
- Subject: Re: [PATCH v3] Work around the NOP issue of Loongson2F
- References: <1258470143-1797-1-git-send-email-wuzhangjin@gmail.com> <87aaykrg7j.fsf@firetop.home> <1258506656.2907.12.camel@falcon.domain.org>
- Reply-to: wuzhangjin at gmail dot com
[...]
> >
> > Even if the answer's no, I'm uncomfortable with one kind of nop being
> > treated differently.
>
> The same to me, I will try to find out how does the .align and .fill
> works and why it uses the 0 as the nop but doesn't use the NOP_INSN
> initialized in md_begin(). what about your suggestion here? I have tried
> to return NOP_INSN->insn_opcode in mips_nop_opcode() and modify
> mips_handle_align():
>
> - md_number_to_chars (p, mips16_nop_insn.insn_opcode, 2);
> + md_number_to_chars (p, NOP_INSN->insn_opcode, 2);
>
> It did generate the source code like this: 8250825,
If do the following change:
- fragp->fr_var = 2;
+ fragp->fr_var = 4;
It works, so, the final solution:
gas/config/tc-mips.c:
@@ -14779,11 +14801,18 @@ static procS *cur_proc_ptr;
static int numprocs;
/* Implement NOP_OPCODE. We encode a MIPS16 nop as "1" and a normal
- nop as "0". */
+ nop as "0".
+
+ If -mfix-loongson2f is passed, we encode the nop as "1". This is
+ needed to enable the work around in mips_handle_align() for
+ loongson2f.
+ */
char
char
mips_nop_opcode (void)
{
+ if (mips_fix_loongson2f)
+ return 1;
return seg_info (now_seg)->tc_segment_info_data.mips16;
}
@@ -14809,8 +14838,13 @@ mips_handle_align (fragS *fragp)
*p++ = 0;
fragp->fr_fix++;
}
- md_number_to_chars (p, mips16_nop_insn.insn_opcode, 2);
- fragp->fr_var = 2;
+ if (mips_fix_loongson2f && !mips_opts.mips16) {
+ md_number_to_chars (p, nop_insn.insn_opcode, 4);
+ fragp->fr_var = 4;
+ } else {
+ md_number_to_chars (p, mips16_nop_insn.insn_opcode, 2);
+ fragp->fr_var = 2;
+ }
}
}
Regards,
Wu Zhangjin