Debian Codegraph @

gcc/testsuite/gcc.target/avr/torture/isr-04-regs.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-std=c99" } */
3
4 /* Test ISR psologue / epilogue generation in various situations. */
5
6 #include "../isr-test.h"
7
8 #define SI __attribute((signal,noipa)) void
9
10 #define S0(x) if (x & 1) __asm ("swap __tmp_reg__")
11 #define S1(x) if (x & 2) __asm ("swap __zero_reg__")
12 #define S2(x) if (x & 4) __asm ("swap 26" ::: "26")
13 #define S3(x) if (x & 8) __asm ("clh")
14 #define S(x) S0(x); S1(x); S2(x); S3(x)
15
16 /* Clobber some GPRs but not SREG */
17 SI __vector_8 () { S(0); }
18 SI __vector_1 () { S(1); }
19 SI __vector_2 () { S(2); }
20 SI __vector_3 () { S(3); }
21 SI __vector_4 () { S(4); }
22 SI __vector_5 () { S(5); }
23 SI __vector_6 () { S(6); }
24 SI __vector_7 () { S(7); }
25
26 /* Clobber some GPRs and SREG */
27 SI __vector_10 () { S(8); }
28 SI __vector_11 () { S(9); }
29 SI __vector_12 () { S(10); }
30 SI __vector_13 () { S(11); }
31 SI __vector_14 () { S(12); }
32 SI __vector_15 () { S(13); }
33 SI __vector_16 () { S(14); }
34 SI __vector_17 () { S(15); }
35
36 MK_RUN_ISR (8, 0)
37 MK_RUN_ISR (1, 0)
38 MK_RUN_ISR (2, 0)
39 MK_RUN_ISR (3, 0)
40 MK_RUN_ISR (4, 0)
41 MK_RUN_ISR (5, 0)
42 MK_RUN_ISR (6, 0)
43 MK_RUN_ISR (7, 0)
44
45 MK_RUN_ISR (10, 0)
46 MK_RUN_ISR (11, 0)
47 MK_RUN_ISR (12, 0)
48 MK_RUN_ISR (13, 0)
49 MK_RUN_ISR (14, 0)
50 MK_RUN_ISR (15, 0)
51 MK_RUN_ISR (16, 0)
52 MK_RUN_ISR (17, 0)
53
54 __attribute__((unused, naked, noipa))
55 static void host_clobbers (void)
56 {
57 __asm __volatile__
58 ("nop"
59 CR ".global do_clobbers"
60 CR ".type do_clobbers,@function"
61 CR "do_clobbers:"
62
63 CR ".irp x,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31"
64 /* No value is a multiple of 0x11 so SWAP is not a no-op. */
65 CR "ldi \\x, lo8(17 + 7*\\x)"
66 CR ".endr"
67
68 #ifndef __AVR_TINY__
69 CR "ldi r17, 100"
70 CR ".irp x,0,2,3,4,5,6,7,8,9,10,11,12,13,14,15"
71 CR "mov \\x, 31-\\x"
72 CR ".endr"
73 #endif
74
75 CR "ret");
76 }
77
78 #define clobbers \
79 __asm volatile ("%~call do_clobbers" :: "s" (host_clobbers) : "memory")
80
81 __attribute__((noipa))
82 void tests (void)
83 {
84 clobbers; run_isr_8 ();
85 clobbers; run_isr_1 ();
86 clobbers; run_isr_2 ();
87 clobbers; run_isr_3 ();
88 clobbers; run_isr_4 ();
89 clobbers; run_isr_5 ();
90 clobbers; run_isr_6 ();
91 clobbers; run_isr_7 ();
92
93 clobbers; run_isr_10 ();
94 clobbers; run_isr_11 ();
95 clobbers; run_isr_12 ();
96 clobbers; run_isr_13 ();
97 clobbers; run_isr_14 ();
98 clobbers; run_isr_15 ();
99 clobbers; run_isr_16 ();
100 clobbers; run_isr_17 ();
101 }
102
103 int main (void)
104 {
105 tests ();
106 return 0;
107 }