OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / sibcall-5.c
1 /* Check that indirect sibcalls understand regparm.  */
2 /* { dg-do run } */
3 /* { dg-require-effective-target ilp32 } */
4 /* { dg-options "-O2" } */
5
6 extern void abort (void);
7
8 int (*f)(int, int) __attribute__((regparm(2)));
9 int (*g)(int, int, int) __attribute__((regparm(3)));
10
11 int __attribute__((noinline))
12 foo(void)
13 {
14   return f(1, 2);
15 }
16
17 int __attribute__((noinline))
18 bar(void)
19 {
20   return g(1, 2, 3);
21 }
22
23 int __attribute__((regparm(2)))
24 f1(int x, int y)
25 {
26   return x*3 + y;
27 }
28
29 int __attribute__((regparm(3)))
30 g1(int x, int y, int z)
31 {
32   return x*9 + y*3 + z;
33 }
34
35 int main()
36 {
37   f = f1;
38   g = g1;
39   if (foo() != 1*3 + 2)
40     abort ();
41   if (bar() != 1*9 + 2*3 + 3)
42     abort ();
43   return 0;
44 }