Skip to content

Commit

Permalink
testsuite/small: Adapt tests to s390.
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Paulo de Souza <[email protected]>
  • Loading branch information
marcosps committed Jun 28, 2024
1 parent 52683d1 commit 4094b62
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 10 additions & 1 deletion testsuite/small/attr-1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
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()
{
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" } } */
18 changes: 16 additions & 2 deletions testsuite/small/attr-6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" } } */

0 comments on commit 4094b62

Please sign in to comment.