From 4094b6228d3b40df6c8a90090ed61907e1b72d87 Mon Sep 17 00:00:00 2001 From: Marcos Paulo de Souza Date: Thu, 27 Jun 2024 23:12:30 -0300 Subject: [PATCH] testsuite/small: Adapt tests to s390. Signed-off-by: Marcos Paulo de Souza --- testsuite/small/attr-1.c | 11 ++++++++++- testsuite/small/attr-6.c | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/testsuite/small/attr-1.c b/testsuite/small/attr-1.c index a05b608..5464b5e 100644 --- a/testsuite/small/attr-1.c +++ b/testsuite/small/attr-1.c @@ -3,6 +3,15 @@ register unsigned long current_stack_pointer asm("rsp"); #elif __aarch64__ register unsigned long current_stack_pointer asm("sp"); +#elif __s390x__ +static inline unsigned long __current_stack_pointer(void) +{ + unsigned long sp; + + asm volatile("lgr %0,15" : "=d" (sp)); + return sp; +} +#define current_stack_pointer (__current_stack_pointer()) #endif unsigned long f() @@ -10,5 +19,5 @@ unsigned long f() return current_stack_pointer; } -/* { dg-final { scan-tree-dump "current_stack_pointer asm" } } */ +/* { dg-final { scan-tree-dump "current_stack_pointer asm|current_stack_pointer;" } } */ /* { dg-final { scan-tree-dump "unsigned long f" } } */ diff --git a/testsuite/small/attr-6.c b/testsuite/small/attr-6.c index b8a1018..4331832 100644 --- a/testsuite/small/attr-6.c +++ b/testsuite/small/attr-6.c @@ -3,15 +3,29 @@ #define REG "rsp" #elif __aarch64__ #define REG "sp" +#elif __s390x__ +#define REG "lgr" #endif +#if defined(__x86_64__) || defined(__aarch64__) register unsigned long current_stack_pointer asm(REG); +#elif __s390x__ +static inline unsigned long __current_stack_pointer(void) +{ + unsigned long sp; + + asm volatile(REG" %0,15" : "=d" (sp)); + return sp; +} +#define current_stack_pointer (__current_stack_pointer()) +#endif + unsigned long f() { return current_stack_pointer; } -/* { dg-final { scan-tree-dump "#define REG \"(rsp|sp)\"" } } */ -/* { dg-final { scan-tree-dump "current_stack_pointer asm\(REG\)" } } */ +/* { dg-final { scan-tree-dump "#define REG \"(rsp|sp|lgr)\"" } } */ +/* { dg-final { scan-tree-dump "current_stack_pointer asm\(REG\)|volatile\(REG" } } */ /* { dg-final { scan-tree-dump "unsigned long f" } } */