PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / guality / pr68037-3.c
blob6e054720f47be8fc43d9bd8d0a118c15893b3948
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-g -mgeneral-regs-only" } */
4 #include <stddef.h>
6 extern void exit (int);
8 typedef unsigned int uword_t __attribute__ ((mode (__word__)));
9 typedef int aligned __attribute__((aligned(64)));
11 #define IP 0x12345671
12 #define CS 0x12345672
13 #define FLAGS 0x12345673
14 #define SP 0x12345674
15 #define SS 0x12345675
17 #define STRING(x) XSTRING(x)
18 #define XSTRING(x) #x
19 #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
20 #define ASMNAME2(prefix, cname) XSTRING (prefix) cname
22 struct interrupt_frame
24 uword_t ip;
25 uword_t cs;
26 uword_t flags;
27 uword_t sp;
28 uword_t ss;
31 int
32 check_int (int *i, int align)
34 *i = 20;
35 if ((((ptrdiff_t) i) & (align - 1)) != 0)
36 __builtin_abort ();
37 return *i;
40 __attribute__((interrupt, used))
41 void
42 fn (struct interrupt_frame *frame)
44 aligned i;
45 if (check_int (&i, __alignof__(i)) != i)
46 __builtin_abort ();
48 if (IP != frame->ip) /* BREAK */
49 __builtin_abort ();
50 if (CS != frame->cs)
51 __builtin_abort ();
52 if (FLAGS != frame->flags)
53 __builtin_abort ();
54 if (SP != frame->sp)
55 __builtin_abort ();
56 if (SS != frame->ss)
57 __builtin_abort ();
59 exit (0);
62 int
63 main ()
65 asm ("push $" STRING (SS) "; \
66 push $" STRING (SP) "; \
67 push $" STRING (FLAGS) "; \
68 push $" STRING (CS) "; \
69 push $" STRING (IP) "; \
70 jmp " ASMNAME ("fn"));
71 return 0;
74 /* { dg-final { gdb-test 46 "frame->ip" "0x12345671" } } */
75 /* { dg-final { gdb-test 46 "frame->cs" "0x12345672" } } */
76 /* { dg-final { gdb-test 46 "frame->flags" "0x12345673" } } */
77 /* { dg-final { gdb-test 46 "frame->sp" "0x12345674" } } */
78 /* { dg-final { gdb-test 46 "frame->ss" "0x12345675" } } */