bpf: correct pseudo-C template for add3 and sub3
The pseudo-C output templates for these instructions were incorrectly using operand 1 rather than operand 2 on the RHS, which led to some very incorrect assembly generation with -masm=pseudoc. gcc/ * config/bpf/bpf.md (add<AM:mode>3): Use %w2 instead of %w1 in pseudo-C dialect output template. (sub<AM:mode>3): Likewise. gcc/testsuite/ * gcc.target/bpf/alu-2.c: New test. * gcc.target/bpf/alu-pseudoc-2.c: Likewise.
This commit is contained in:
parent
d023775c11
commit
31d18ff442
3 changed files with 27 additions and 2 deletions
|
@ -131,7 +131,7 @@
|
|||
(plus:AM (match_operand:AM 1 "register_operand" " 0,0")
|
||||
(match_operand:AM 2 "reg_or_imm_operand" " r,I")))]
|
||||
"1"
|
||||
"{add<msuffix>\t%0,%2|%w0 += %w1}"
|
||||
"{add<msuffix>\t%0,%2|%w0 += %w2}"
|
||||
[(set_attr "type" "<mtype>")])
|
||||
|
||||
;;; Subtraction
|
||||
|
@ -144,7 +144,7 @@
|
|||
(minus:AM (match_operand:AM 1 "register_operand" " 0")
|
||||
(match_operand:AM 2 "register_operand" " r")))]
|
||||
""
|
||||
"{sub<msuffix>\t%0,%2|%w0 -= %w1}"
|
||||
"{sub<msuffix>\t%0,%2|%w0 -= %w2}"
|
||||
[(set_attr "type" "<mtype>")])
|
||||
|
||||
;;; Negation
|
||||
|
|
12
gcc/testsuite/gcc.target/bpf/alu-2.c
Normal file
12
gcc/testsuite/gcc.target/bpf/alu-2.c
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* Check add and sub instructions. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
long foo (long x, long y)
|
||||
{
|
||||
return y - x + 4;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-not {sub\t(%r.),\1\n} } } */
|
||||
/* { dg-final { scan-assembler {sub\t(\%r.),(\%r.)\n} } } */
|
||||
/* { dg-final { scan-assembler {add\t(\%r.),4\n} } } */
|
13
gcc/testsuite/gcc.target/bpf/alu-pseudoc-2.c
Normal file
13
gcc/testsuite/gcc.target/bpf/alu-pseudoc-2.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* Check add and sub instructions (pseudoc asm dialect). */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-masm=pseudoc" } */
|
||||
|
||||
long foo (long x, long y)
|
||||
{
|
||||
return y - x + 4;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler-not {\t(r.) -= \1\n} } } */
|
||||
/* { dg-final { scan-assembler {\t(r.) -= (r.)\n} } } */
|
||||
/* { dg-final { scan-assembler {\t(r.) \+= 4\n} } } */
|
||||
|
Loading…
Add table
Reference in a new issue