This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] Work around the NOP issue of Loongson2F


[...]
> > 
> > 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]