Skip to content

Commit 9de7fc3

Browse files
committed
ARC: entry: SAVE_ABI_CALLEE_REG: ISA/ABI specific helper
And for ARcompact variant replace the PUSH/POP macros with gas provided push/pop pseudo-instructions This allows ISA specific implementation e.g. Current ARCv2 PUSH/POP could be replaced with STD/LDL to save 2 registers at a time (w/o bothering with SP update each time) or perhaps use ENTER_S/LEAVE_S to reduce code size For ARCv3 ABI changed so callee regs are now r14-r26 (vs. r13-r25) thus would need a different implementation. Signed-off-by: Vineet Gupta <[email protected]>
1 parent 33cc938 commit 9de7fc3

File tree

4 files changed

+76
-46
lines changed

4 files changed

+76
-46
lines changed

arch/arc/include/asm/entry-arcv2.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,36 @@
291291
/* M = 8-1 N = 8 */
292292
.endm
293293

294+
.macro SAVE_ABI_CALLEE_REGS
295+
push r13
296+
push r14
297+
push r15
298+
push r16
299+
push r17
300+
push r18
301+
push r19
302+
push r20
303+
push r21
304+
push r22
305+
push r23
306+
push r24
307+
push r25
308+
.endm
309+
310+
.macro RESTORE_ABI_CALLEE_REGS
311+
pop r25
312+
pop r24
313+
pop r23
314+
pop r22
315+
pop r21
316+
pop r20
317+
pop r19
318+
pop r18
319+
pop r17
320+
pop r16
321+
pop r15
322+
pop r14
323+
pop r13
324+
.endm
325+
294326
#endif

arch/arc/include/asm/entry-compact.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,38 @@
3333
#include <asm/irqflags-compact.h>
3434
#include <asm/thread_info.h> /* For THREAD_SIZE */
3535

36+
.macro SAVE_ABI_CALLEE_REGS
37+
push r13
38+
push r14
39+
push r15
40+
push r16
41+
push r17
42+
push r18
43+
push r19
44+
push r20
45+
push r21
46+
push r22
47+
push r23
48+
push r24
49+
push r25
50+
.endm
51+
52+
.macro RESTORE_ABI_CALLEE_REGS
53+
pop r25
54+
pop r24
55+
pop r23
56+
pop r22
57+
pop r21
58+
pop r20
59+
pop r19
60+
pop r18
61+
pop r17
62+
pop r16
63+
pop r15
64+
pop r14
65+
pop r13
66+
.endm
67+
3668
/*--------------------------------------------------------------
3769
* Switch to Kernel Mode stack if SP points to User Mode stack
3870
*

arch/arc/include/asm/entry.h

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -87,67 +87,31 @@
8787

8888
.endm
8989

90-
/*--------------------------------------------------------------
91-
* Helpers to save/restore callee-saved regs:
92-
* used by several macros below
93-
*-------------------------------------------------------------*/
94-
.macro SAVE_R13_TO_R25
95-
PUSH r13
96-
PUSH r14
97-
PUSH r15
98-
PUSH r16
99-
PUSH r17
100-
PUSH r18
101-
PUSH r19
102-
PUSH r20
103-
PUSH r21
104-
PUSH r22
105-
PUSH r23
106-
PUSH r24
107-
PUSH r25
108-
.endm
109-
110-
.macro RESTORE_R25_TO_R13
111-
POP r25
112-
POP r24
113-
POP r23
114-
POP r22
115-
POP r21
116-
POP r20
117-
POP r19
118-
POP r18
119-
POP r17
120-
POP r16
121-
POP r15
122-
POP r14
123-
POP r13
124-
.endm
125-
12690
/*
12791
* save user mode callee regs as struct callee_regs
12892
* - needed by fork/do_signal/unaligned-access-emulation.
12993
*/
13094
.macro SAVE_CALLEE_SAVED_USER
131-
SAVE_R13_TO_R25
95+
SAVE_ABI_CALLEE_REGS
13296
.endm
13397

13498
/*
13599
* restore user mode callee regs as struct callee_regs
136100
* - could have been changed by ptrace tracer or unaligned-access fixup
137101
*/
138102
.macro RESTORE_CALLEE_SAVED_USER
139-
RESTORE_R25_TO_R13
103+
RESTORE_ABI_CALLEE_REGS
140104
.endm
141105

142106
/*
143107
* save/restore kernel mode callee regs at the time of context switch
144108
*/
145109
.macro SAVE_CALLEE_SAVED_KERNEL
146-
SAVE_R13_TO_R25
110+
SAVE_ABI_CALLEE_REGS
147111
.endm
148112

149113
.macro RESTORE_CALLEE_SAVED_KERNEL
150-
RESTORE_R25_TO_R13
114+
RESTORE_ABI_CALLEE_REGS
151115
.endm
152116

153117
/*--------------------------------------------------------------

arch/arc/include/asm/ptrace.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ struct pt_regs {
5454
ecr_reg ecr;
5555
};
5656

57+
struct callee_regs {
58+
unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
59+
};
60+
5761
#define MAX_REG_OFFSET offsetof(struct pt_regs, ecr)
5862

5963
#else
@@ -92,16 +96,14 @@ struct pt_regs {
9296
unsigned long status32;
9397
};
9498

95-
#define MAX_REG_OFFSET offsetof(struct pt_regs, status32)
96-
97-
#endif
98-
99-
/* Callee saved registers - need to be saved only when you are scheduled out */
100-
10199
struct callee_regs {
102100
unsigned long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
103101
};
104102

103+
#define MAX_REG_OFFSET offsetof(struct pt_regs, status32)
104+
105+
#endif
106+
105107
#define instruction_pointer(regs) ((regs)->ret)
106108
#define profile_pc(regs) instruction_pointer(regs)
107109

0 commit comments

Comments
 (0)