]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.target/rx/interrupts.c
MAINTAINERS: Add myself as a maintainer for the RX port.
[thirdparty/gcc.git] / gcc / testsuite / gcc.target / rx / interrupts.c
1 /* { dg-do compile } */
2 /* { dg-options "-mint-register=3" } */
3
4 /* Verify that the RX specific function attributes work. */
5
6 void interrupt (void) __attribute__((__interrupt__));
7 void exception (void) __attribute__((__exception__));
8 int naked (int) __attribute__((__naked__));
9
10 int flag = 0;
11
12 /* Fast interrupt handler. Only uses registers marked as fixed
13 by the -fixed-xxx gcc command line option. Returns via RTFI. */
14
15 void
16 interrupt (void)
17 {
18 flag = 1;
19 }
20
21 /* Exception handler. Must preserve any register it uses, even
22 call clobbered ones. Returns via RTE. */
23
24 void
25 exception (void)
26 {
27 switch (flag)
28 {
29 case 0:
30 flag = -1;
31 break;
32 case 1:
33 case 2:
34 case 4:
35 flag = flag - 2;
36 break;
37 case 5:
38 case 7:
39 case 6:
40 flag ^= 3;
41 break;
42 default:
43 naked (flag * 2);
44 break;
45 }
46 }
47
48 /* Naked function. The programmer must supply the function's
49 prologue and epilogue instructions. */
50
51 int
52 naked (int arg)
53 {
54 flag = arg;
55 }
56
57 /* { dg-final { scan-assembler "rtfi" } } */
58 /* { dg-final { scan-assembler "rte" } } */