diff options
Diffstat (limited to 'gcc/testsuite/c-c++-common')
12 files changed, 159 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-1.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-1.c new file mode 100644 index 0000000..2463353 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-1.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=skip" } */ + +volatile int result = 0; +int +__attribute__((noipa)) +foo (int x) +{ + return x; +} +int main() +{ + result = foo (2); + return 0; +} diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-10.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-10.c new file mode 100644 index 0000000..bdaf8e7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-10.c @@ -0,0 +1,92 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include <assert.h> +int result = 0; + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("skip"))) +foo1 (int x) +{ + return (x + 1); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("used-gpr-arg"))) +foo2 (int x) +{ + return (x + 2); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("used-gpr"))) +foo3 (int x) +{ + return (x + 3); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("used-arg"))) +foo4 (int x) +{ + return (x + 4); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("used"))) +foo5 (int x) +{ + return (x + 5); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("all-gpr-arg"))) +foo6 (int x) +{ + return (x + 6); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("all-gpr"))) +foo7 (int x) +{ + return (x + 7); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("all-arg"))) +foo8 (int x) +{ + return (x + 8); +} + +int +__attribute__((noipa)) +__attribute__ ((zero_call_used_regs("all"))) +foo9 (int x) +{ + return (x + 9); +} + +int main() +{ + result = foo1 (1); + result += foo2 (1); + result += foo3 (1); + result += foo4 (1); + result += foo5 (1); + result += foo6 (1); + result += foo7 (1); + result += foo8 (1); + result += foo9 (1); + assert (result == 54); + return 0; +} diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-11.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-11.c new file mode 100644 index 0000000..7721e39 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-11.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=all" } */ + +#include "zero-scratch-regs-10.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-2.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-2.c new file mode 100644 index 0000000..25891ac --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-2.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=used-gpr-arg" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-3.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-3.c new file mode 100644 index 0000000..7c3d286 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-3.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=used-gpr" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-4.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-4.c new file mode 100644 index 0000000..ba28c06 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-4.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=used-arg" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-5.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-5.c new file mode 100644 index 0000000..26679a4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-5.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=used" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-6.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-6.c new file mode 100644 index 0000000..80f5bbb --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-6.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=all-gpr-arg" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-7.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-7.c new file mode 100644 index 0000000..159f35c --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-7.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=all-gpr" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-8.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-8.c new file mode 100644 index 0000000..c1faaf0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-8.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=all-arg" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-9.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-9.c new file mode 100644 index 0000000..3f14bac --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-9.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fzero-call-used-regs=all" } */ + +#include "zero-scratch-regs-1.c" diff --git a/gcc/testsuite/c-c++-common/zero-scratch-regs-attr-usages.c b/gcc/testsuite/c-c++-common/zero-scratch-regs-attr-usages.c new file mode 100644 index 0000000..1e75795 --- /dev/null +++ b/gcc/testsuite/c-c++-common/zero-scratch-regs-attr-usages.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int result __attribute__ ((zero_call_used_regs("all"))); /* { dg-error "attribute applies only to functions" } */ +int +__attribute__ ((zero_call_used_regs("gpr-arg-all"))) +foo1 (int x) /* { dg-error "unrecognized 'zero_call_used_regs' attribute argument" } */ +{ + return (x + 1); +} +int +__attribute__ ((zero_call_used_regs(1))) +foo2 (int x) /* { dg-error "argument not a string" } */ +{ + return (x + 2); +} |