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 */
121 SAVE_FP(f14,20) /* save FPRs */
140 SAVE_INT(r3,19) /* save quotation since we're about to mangle it */
142 mr r3,r1 /* pass call stack pointer as an argument */
143 bl MANGLE(save_callstack_bottom)
145 RESTORE_INT(r3,19) /* restore quotation */
165 RESTORE_FP(f14,20) /* save FPRs */
167 RESTORE_INT(r31,16) /* restore GPRs */
188 /* We pass a function pointer to memcpy in r6 to work around a Mac OS X ABI
189 limitation which would otherwise require us to do a bizzaro PC-relative
190 trampoline to retrieve the function address */
191 DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
192 sub r1,r3,r5 /* compute new stack pointer */
193 mr r3,r1 /* start of destination of memcpy() */
194 stwu r1,-64(r1) /* setup fake stack frame for memcpy() */
195 mtlr r6 /* prepare to call memcpy() */
197 lwz r1,0(r1) /* tear down fake stack frame */
198 lwz r0,LR_SAVE(r1) /* we have restored the stack; load return address */
199 mtlr r0 /* prepare to return to restored callstack */
202 DEF(void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to)):
203 mr r1,r4 /* compute new stack pointer */
204 lwz r0,LR_SAVE(r1) /* we have rewound the stack; load return address */
206 JUMP_QUOT /* call the quotation */
208 DEF(void,lazy_jit_compile,(CELL quot)):
209 mr r4,r1 /* save stack pointer */
211 bl MANGLE(lazy_jit_compile_impl)
213 JUMP_QUOT /* call the quotation */
215 /* Thanks to Joshua Grams for this code.
217 On PowerPC processors, we must flush the instruction cache manually
218 after writing to the code heap. */
220 DEF(void,flush_icache,(void *start, int len)):
221 /* compute number of cache lines to flush */
223 clrrwi r3,r3,5 /* align addr to next lower cache line boundary */
224 sub r4,r4,r3 /* then n_lines = (len + 0x1f) / 0x20 */
226 srwi. r4,r4,5 /* note '.' suffix */
227 beqlr /* if n_lines == 0, just return. */
228 mtctr r4 /* flush cache lines */
229 0: dcbf 0,r3 /* for each line... */