diff options
author | David Faust <david.faust@oracle.com> | 2021-09-08 10:28:59 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2021-09-10 09:06:58 -0700 |
commit | ae1cce71fa689e3991317fcf2bbceecf3b72ea9e (patch) | |
tree | 4ece23bba67d268e8e41c7cd7a584aaf33527a06 | |
parent | 5b2ab1d35e41528ea844c6f5ee030f8e032f4c18 (diff) | |
download | gcc-ae1cce71fa689e3991317fcf2bbceecf3b72ea9e.zip gcc-ae1cce71fa689e3991317fcf2bbceecf3b72ea9e.tar.gz gcc-ae1cce71fa689e3991317fcf2bbceecf3b72ea9e.tar.bz2 |
bpf testsuite: add tests for new feature options
This commit adds tests for the new -mjmpext, -mjmp32 and -malu32 feature
options in the BPF backend.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/alu-1.c: New test.
* gcc.target/bpf/jmp-1.c: New test.
-rw-r--r-- | gcc/testsuite/gcc.target/bpf/alu-1.c | 56 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/bpf/jmp-1.c | 57 |
2 files changed, 113 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/bpf/alu-1.c b/gcc/testsuite/gcc.target/bpf/alu-1.c new file mode 100644 index 0000000..9814930 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/alu-1.c @@ -0,0 +1,56 @@ +/* Ensure 32-bit ALU instructions are not generated if -malu32 is + not enabled. */ + +/* { dg-do compile } */ +/* { dg-options "-mno-alu32" } */ + +int foo (int a, int b) +{ + a += 1; + b += a; + b -= 5; + a -= a; + + a *= 2; + b *= a; + + a |= 0xfafa; + b |= a; + b &= 0x00ffff00; + b &= a; + + a <<= 2; + b <<= a; + b >>= 5; + a >>= b; + + int c = a; + int d = 5; + + d ^= a; + c ^= 0xe5e5e5e5; + c = -c; + + unsigned int x = a; + unsigned int y = b; + x /= 3; + y /= x; + x %= 4; + y %= x; + + return a + b - c + d - x + y; +} + +/* { dg-final { scan-assembler-times "mov32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "add32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "sub32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "mul32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "div32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "mod32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "neg32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "and32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "or32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "xor32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "rsh32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "lsh32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "arsh32\t0" 0 } } */ diff --git a/gcc/testsuite/gcc.target/bpf/jmp-1.c b/gcc/testsuite/gcc.target/bpf/jmp-1.c new file mode 100644 index 0000000..eaf8253 --- /dev/null +++ b/gcc/testsuite/gcc.target/bpf/jmp-1.c @@ -0,0 +1,57 @@ +/* Ensure jlt, jslt, jle and jsle instructions are not generated if + -mjmpext is not enabled, and no 32-bit jump instructions are generated + if -mjmp32 is not enabled. */ + +/* { dg-do compile } */ +/* { dg-options "-mno-jmpext -mno-jmp32" } */ + +int foo (int a, int b) +{ + if (a == 1) + b += 1; + if (a != 3) + b += 2; + if (a > 5) + b += 3; + if (a >= 7) + b += 4; + if (a < 9) + b += 5; + if (a <= 10) + b += 6; + + return a + b; +} + +unsigned int bar (unsigned int a, unsigned int b) +{ + if (a == 1) + b += 1; + if (a != 3) + b += 2; + if (a > 5) + b += 3; + if (a >= 7) + b += 4; + if (a < 9) + b += 5; + if (a <= 10) + b += 6; + + return a + b; +} + +/* { dg-final { scan-assembler-times "jlt\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jslt\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jle\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jsle\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jeq32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jne32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jlt32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jgt32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jle32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jge32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jslt32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jsgt32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jsle32\t0" 0 } } */ +/* { dg-final { scan-assembler-times "jsge32\t0" 0 } } */ |