Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
switch_ppc_macosx.h
1/*
2 * this is the internal transfer function.
3 *
4 * HISTORY
5 * 07-Sep-05 (py-dev mailing list discussion)
6 * removed 'r31' from the register-saved. !!!! WARNING !!!!
7 * It means that this file can no longer be compiled statically!
8 * It is now only suitable as part of a dynamic library!
9 * 14-Jan-04 Bob Ippolito <bob@redivi.com>
10 * added cr2-cr4 to the registers to be saved.
11 * Open questions: Should we save FP registers?
12 * What about vector registers?
13 * Differences between darwin and unix?
14 * 24-Nov-02 Christian Tismer <tismer@tismer.com>
15 * needed to add another magic constant to insure
16 * that f in slp_eval_frame(PyFrameObject *f)
17 * STACK_REFPLUS will probably be 1 in most cases.
18 * gets included into the saved stack area.
19 * 17-Sep-02 Christian Tismer <tismer@tismer.com>
20 * after virtualizing stack save/restore, the
21 * stack size shrunk a bit. Needed to introduce
22 * an adjustment STACK_MAGIC per platform.
23 * 15-Sep-02 Gerd Woetzel <gerd.woetzel@GMD.DE>
24 * slightly changed framework for sparc
25 * 29-Jun-02 Christian Tismer <tismer@tismer.com>
26 * Added register 13-29, 31 saves. The same way as
27 * Armin Rigo did for the x86_unix version.
28 * This seems to be now fully functional!
29 * 04-Mar-02 Hye-Shik Chang <perky@fallin.lv>
30 * Ported from i386.
31 */
32
33#define STACK_REFPLUS 1
34
35#ifdef SLP_EVAL
36
37#define STACK_MAGIC 3
38
39/* !!!!WARNING!!!! need to add "r31" in the next line if this header file
40 * is meant to be compiled non-dynamically!
41 */
42#define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", \
43 "r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", \
44 "cr2", "cr3", "cr4"
45
46static int
47slp_switch(void)
48{
49 int err;
50 int *stackref, stsizediff;
51 __asm__ volatile ("" : : : REGS_TO_SAVE);
52 __asm__ ("; asm block 2\n\tmr %0, r1" : "=r" (stackref) : );
53 {
54 SLP_SAVE_STATE(stackref, stsizediff);
55 __asm__ volatile (
56 "; asm block 3\n"
57 "\tmr r11, %0\n"
58 "\tadd r1, r1, r11\n"
59 "\tadd r30, r30, r11\n"
60 : /* no outputs */
61 : "r" (stsizediff)
62 : "r11"
63 );
64 SLP_RESTORE_STATE();
65 }
66 __asm__ volatile ("" : : : REGS_TO_SAVE);
67 __asm__ volatile ("li %0, 0" : "=r" (err));
68 return err;
69}
70
71#endif
72
73/*
74 * further self-processing support
75 */
76
77/*
78 * if you want to add self-inspection tools, place them
79 * here. See the x86_msvc for the necessary defines.
80 * These features are highly experimental und not
81 * essential yet.
82 */