Commit: Gas: Add .nop directive.
Jose E. Marchesi
jose.marchesi@oracle.com
Mon Sep 14 15:27:00 GMT 2020
Hi Nick.
> I am checking in the attached patch to add a ".nop" directive to the
> assembler. This directive creates a single no-op instruction. It is
> similar to the already existing ".nops" directive, apart from two
> important differences:
>
> 1. It is implemented for all architectures, not just x86.
> 2. The instruction it generates counts as a real instruction for the
> purposes of DWARF line number table generation.
>
> Fact 1 is important as it allows the directive to be used to generate
> architecture neutral test cases containing real instructions.
>
> Tested with a large variety of different targets.
Very nice!
In the same spirit, it would be awesome to be able to generate
architecture-neutral data directives as well, for DWARF and CTF and the
like :)
> diff --git a/gas/config/tc-bpf.h b/gas/config/tc-bpf.h
> index 5765833997..cb02d6c133 100644
> --- a/gas/config/tc-bpf.h
> +++ b/gas/config/tc-bpf.h
> @@ -48,3 +48,4 @@
> /* Values passed to md_apply_fix don't include the symbol value. */
> #define MD_APPLY_SYM_VALUE(FIX) 0
>
> +#define md_single_noop_insn "mov %r1,%r1"
For BPF we have this in GCC:
(define_insn "nop"
[(const_int 0)]
""
"mov\t%%r0,%%r0"
[(set_attr "type" "alu")])
I think it would be good to settle on the same way to encode nops in
both GCC and binutils.
More information about the Binutils
mailing list