OSDN Git Service

* gcc.dg/altivec-vec-merge.c: Make test usable on GNU/Linux targets
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / 20000724-1.c
1 /* { dg-do run { target i?86-*-linux* } } */
2 /* { dg-options "-O2 -fomit-frame-pointer" } */
3
4 extern void abort (void);
5 extern void exit (int);
6
7 struct s {
8   struct { int a; } a;
9   int b;
10   struct { struct { int a; } a; struct t { struct t *a, *b; } b; } c;
11 };
12
13 int bar(int (*fn)(void *), void *arg, unsigned long flags)
14 {
15   return 0;
16 }
17
18 int baz(void *x)
19 {
20   return 0;
21 }
22
23 void do_check (struct s *) asm ("do_check") __attribute__((regparm(1)));
24
25 void __attribute__((regparm(1))) do_check(struct s *x)
26 {
27   if (x->a.a || x->b || x->c.a.a)
28     abort();
29   if (x->c.b.a != &x->c.b || x->c.b.b != &x->c.b)
30     abort();
31 }
32
33 #define NT "\n\t"
34
35 asm ("\n"
36 "___checkme:"
37 NT      "pushl %eax; pushl %ebx; pushl %ecx; pushl %edx; pushl %esi; pushl %edi"
38
39 NT      "pushl $0; pushl $0; pushl $0; pushl $0; pushl $0"
40 NT      "pushl $0; pushl $0; pushl $0; pushl $0; pushl $0"
41
42 NT      "movl %ecx, %eax"
43 NT      "call do_check"
44
45 NT      "popl %eax; popl %eax; popl %eax; popl %eax; popl %eax"
46 NT      "popl %eax; popl %eax; popl %eax; popl %eax; popl %eax"
47
48 NT      "popl %edi; popl %esi; popl %edx; popl %ecx; popl %ebx; popl %eax"
49 NT      "ret"
50 );
51
52 extern inline void do_asm(struct s * x)
53 {
54   asm volatile("call ___checkme" : : "c" (x) : "memory");
55 }
56
57 int foo(void)
58 {
59   struct s x = { { 0 }, 0, { { 0 }, { &x.c.b, &x.c.b } } };
60   bar(baz, &x, 1);
61   do_asm(&x);
62   bar(baz, &x, 1);
63   do_asm(&x);
64   return 0;
65 }
66
67 int main()
68 {
69   foo();
70   exit(0);
71 }