public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] bpf: neg instruction does not accept an immediate
@ 2023-08-21 21:03 David Faust
  2023-08-21 22:07 ` Jose E. Marchesi
  0 siblings, 1 reply; 2+ messages in thread
From: David Faust @ 2023-08-21 21:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: jose.marchesi

The BPF virtual machine does not support neg nor neg32 instructions with
an immediate.

The erroneous instructions were removed from binutils:
https://sourceware.org/pipermail/binutils/2023-August/129135.html

Change the define_insn so that an immediate cannot be accepted.

From testing, a neg-immediate was probably never chosen over a
mov-immediate anyway.

Tested on x86_64-linux-gnu host for bpf-unknown-none target.

gcc/

	* config/bpf/bpf.md (neg): Second operand must be a register.
---
 gcc/config/bpf/bpf.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md
index a64de1095ed..e87d72182bb 100644
--- a/gcc/config/bpf/bpf.md
+++ b/gcc/config/bpf/bpf.md
@@ -163,8 +163,8 @@ (define_insn "sub<AM:mode>3"
 
 ;;; Negation
 (define_insn "neg<AM:mode>2"
-  [(set (match_operand:AM         0 "register_operand"   "=r,r")
-        (neg:AM (match_operand:AM 1 "reg_or_imm_operand" " 0,I")))]
+  [(set (match_operand:AM         0 "register_operand" "=r")
+        (neg:AM (match_operand:AM 1 "register_operand" " 0")))]
   ""
   "{neg<msuffix>\t%0|%w0 = -%w1}"
   [(set_attr "type" "<mtype>")])
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] bpf: neg instruction does not accept an immediate
  2023-08-21 21:03 [PATCH] bpf: neg instruction does not accept an immediate David Faust
@ 2023-08-21 22:07 ` Jose E. Marchesi
  0 siblings, 0 replies; 2+ messages in thread
From: Jose E. Marchesi @ 2023-08-21 22:07 UTC (permalink / raw)
  To: David Faust; +Cc: gcc-patches


> The BPF virtual machine does not support neg nor neg32 instructions with
> an immediate.
>
> The erroneous instructions were removed from binutils:
> https://sourceware.org/pipermail/binutils/2023-August/129135.html
>
> Change the define_insn so that an immediate cannot be accepted.
>
> From testing, a neg-immediate was probably never chosen over a
> mov-immediate anyway.

OK.
Thanks!

>
> Tested on x86_64-linux-gnu host for bpf-unknown-none target.
>
> gcc/
>
> 	* config/bpf/bpf.md (neg): Second operand must be a register.
> ---
>  gcc/config/bpf/bpf.md | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config/bpf/bpf.md b/gcc/config/bpf/bpf.md
> index a64de1095ed..e87d72182bb 100644
> --- a/gcc/config/bpf/bpf.md
> +++ b/gcc/config/bpf/bpf.md
> @@ -163,8 +163,8 @@ (define_insn "sub<AM:mode>3"
>  
>  ;;; Negation
>  (define_insn "neg<AM:mode>2"
> -  [(set (match_operand:AM         0 "register_operand"   "=r,r")
> -        (neg:AM (match_operand:AM 1 "reg_or_imm_operand" " 0,I")))]
> +  [(set (match_operand:AM         0 "register_operand" "=r")
> +        (neg:AM (match_operand:AM 1 "register_operand" " 0")))]
>    ""
>    "{neg<msuffix>\t%0|%w0 = -%w1}"
>    [(set_attr "type" "<mtype>")])

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-21 22:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21 21:03 [PATCH] bpf: neg instruction does not accept an immediate David Faust
2023-08-21 22:07 ` Jose E. Marchesi

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).