1 /* Parts of this file were snarfed from SBCL src/runtime/ppc-assem.S, which is
2 in the public domain. */
7 DEF(void,primitive_fixnum_add,(void)):
18 b MANGLE(overflow_fixnum_add)
20 DEF(void,primitive_fixnum_subtract,(void)):
31 b MANGLE(overflow_fixnum_subtract)
33 DEF(void,primitive_fixnum_multiply,(void)):
44 b MANGLE(overflow_fixnum_multiply)
46 /* Note that the XT is passed to the quotation in r11 */
47 #define CALL_OR_JUMP_QUOT \
48 lwz r11,9(r3) /* load quotation-xt slot */ XX \
51 CALL_OR_JUMP_QUOT XX \
52 mtlr r11 /* prepare to call XT with quotation in r3 */ XX \
56 CALL_OR_JUMP_QUOT XX \
57 mtctr r11 /* prepare to call XT with quotation in r3 */ XX \
62 #define SAVED_INT_REGS_SIZE 96
64 #define SAVED_FP_REGS_SIZE 144
66 #define FRAME (RESERVED_SIZE + PARAM_SIZE + SAVED_INT_REGS_SIZE + SAVED_FP_REGS_SIZE + 8)
68 #if defined( __APPLE__)
70 #define RESERVED_SIZE 24
73 #define RESERVED_SIZE 8
76 #define SAVE_LR(reg) stw reg,(LR_SAVE + FRAME)(r1)
78 #define LOAD_LR(reg) lwz reg,(LR_SAVE + FRAME)(r1)
80 #define SAVE_AT(offset) (RESERVED_SIZE + PARAM_SIZE + 4 * offset)
82 #define SAVE_INT(register,offset) stw register,SAVE_AT(offset)(r1)
83 #define RESTORE_INT(register,offset) lwz register,SAVE_AT(offset)(r1)
85 #define SAVE_FP(register,offset) stfd register,SAVE_AT(offset)(r1)
86 #define RESTORE_FP(register,offset) lfd register,SAVE_AT(offset)(r1)
89 mflr r0 XX /* get caller's return address */ \
90 stwu r1,-FRAME(r1) XX /* create a stack frame to hold non-volatile registers */ \
95 lwz r1,0(r1) XX /* destroy the stack frame */ \
96 mtlr r0 /* get ready to return */
98 /* We have to save and restore nonvolatile registers because
99 the Factor compiler treats the entire register file as volatile. */
100 DEF(void,c_to_factor,(CELL quot)):
103 SAVE_INT(r13,0) /* save GPRs */
120 SAVE_FP(f14,20) /* save FPRs */
139 SAVE_INT(r3,19) /* save quotation since we're about to mangle it */
141 mr r3,r1 /* pass call stack pointer as an argument */
142 bl MANGLE(save_callstack_bottom)
144 RESTORE_INT(r3,19) /* restore quotation */
164 RESTORE_FP(f14,20) /* save FPRs */
166 RESTORE_INT(r28,15) /* restore GPRs */
186 /* We pass a function pointer to memcpy in r6 to work around a Mac OS X ABI
187 limitation which would otherwise require us to do a bizzaro PC-relative
188 trampoline to retrieve the function address */
189 DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
190 sub r1,r3,r5 /* compute new stack pointer */
191 mr r3,r1 /* start of destination of memcpy() */
192 stwu r1,-64(r1) /* setup fake stack frame for memcpy() */
193 mtlr r6 /* prepare to call memcpy() */
195 lwz r1,0(r1) /* tear down fake stack frame */
196 lwz r0,LR_SAVE(r1) /* we have restored the stack; load return address */
197 mtlr r0 /* prepare to return to restored callstack */
200 DEF(void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)):
201 mr r1,r4 /* compute new stack pointer */
202 lwz r0,LR_SAVE(r1) /* we have rewound the stack; load return address */
204 JUMP_QUOT /* call the quotation */
206 DEF(void,lazy_jit_compile,(CELL quot)):
207 mr r4,r1 /* save stack pointer */
209 bl MANGLE(lazy_jit_compile_impl)
211 JUMP_QUOT /* call the quotation */
213 /* Thanks to Joshua Grams for this code.
215 On PowerPC processors, we must flush the instruction cache manually
216 after writing to the code heap. */
218 DEF(void,flush_icache,(void *start, int len)):
219 /* compute number of cache lines to flush */
221 clrrwi r3,r3,5 /* align addr to next lower cache line boundary */
222 sub r4,r4,r3 /* then n_lines = (len + 0x1f) / 0x20 */
224 srwi. r4,r4,5 /* note '.' suffix */
225 beqlr /* if n_lines == 0, just return. */
226 mtctr r4 /* flush cache lines */
227 0: dcbf 0,r3 /* for each line... */