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,12(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 SAVED_V_REGS_SIZE 208
68 #define FRAME (RESERVED_SIZE + PARAM_SIZE + SAVED_INT_REGS_SIZE + SAVED_FP_REGS_SIZE + SAVED_V_REGS_SIZE + 8)
70 #if defined( __APPLE__)
72 #define RESERVED_SIZE 24
75 #define RESERVED_SIZE 8
78 #define SAVE_LR(reg) stw reg,(LR_SAVE + FRAME)(r1)
80 #define LOAD_LR(reg) lwz reg,(LR_SAVE + FRAME)(r1)
82 #define SAVE_AT(offset) (RESERVED_SIZE + PARAM_SIZE + 4 * offset)
84 #define SAVE_INT(register,offset) stw register,SAVE_AT(offset)(r1)
85 #define RESTORE_INT(register,offset) lwz register,SAVE_AT(offset)(r1)
87 #define SAVE_FP(register,offset) stfd register,SAVE_AT(offset)(r1)
88 #define RESTORE_FP(register,offset) lfd register,SAVE_AT(offset)(r1)
90 #define SAVE_V(register,offset) \
91 li r2,SAVE_AT(offset) XX \
94 #define RESTORE_V(register,offset) \
95 li r2,SAVE_AT(offset) XX \
99 mflr r0 XX /* get caller's return address */ \
100 stwu r1,-FRAME(r1) XX /* create a stack frame to hold non-volatile registers */ \
105 lwz r1,0(r1) XX /* destroy the stack frame */ \
106 mtlr r0 /* get ready to return */
108 /* We have to save and restore nonvolatile registers because
109 the Factor compiler treats the entire register file as volatile. */
110 DEF(void,c_to_factor,(CELL quot)):
113 SAVE_INT(r15,0) /* save GPRs */
131 SAVE_FP(f14,20) /* save FPRs */
175 SAVE_INT(r3,19) /* save quotation since we're about to mangle it */
177 mr r3,r1 /* pass call stack pointer as an argument */
178 bl MANGLE(save_callstack_bottom)
180 RESTORE_INT(r3,19) /* restore quotation */
216 RESTORE_FP(f14,20) /* save FPRs */
218 RESTORE_INT(r31,16) /* restore GPRs */
239 /* We pass a function pointer to memcpy in r6 to work around a Mac OS X ABI
240 limitation which would otherwise require us to do a bizzaro PC-relative
241 trampoline to retrieve the function address */
242 DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
243 sub r1,r3,r5 /* compute new stack pointer */
244 mr r3,r1 /* start of destination of memcpy() */
245 stwu r1,-64(r1) /* setup fake stack frame for memcpy() */
246 mtlr r6 /* prepare to call memcpy() */
248 lwz r1,0(r1) /* tear down fake stack frame */
249 lwz r0,LR_SAVE(r1) /* we have restored the stack; load return address */
250 mtlr r0 /* prepare to return to restored callstack */
253 DEF(void,throw_impl,(CELL quot, F_STACK_FRAME *rewind_to, void *vm)):
254 mr r1,r4 /* compute new stack pointer */
255 mr r4,r5 /* make vm ptr 2nd arg in case quot_xt = lazy_jit_compile */
256 lwz r0,LR_SAVE(r1) /* we have rewound the stack; load return address */
258 JUMP_QUOT /* call the quotation */
260 DEF(void,lazy_jit_compile,(CELL quot, void *vm)):
261 mr r5,r4 /* vm ptr is 3rd arg */
262 mr r4,r1 /* save stack pointer */
264 bl MANGLE(lazy_jit_compile_impl)
266 JUMP_QUOT /* call the quotation */
268 /* Thanks to Joshua Grams for this code.
270 On PowerPC processors, we must flush the instruction cache manually
271 after writing to the code heap. */
273 DEF(void,flush_icache,(void *start, int len)):
274 /* compute number of cache lines to flush */
276 clrrwi r3,r3,5 /* align addr to next lower cache line boundary */
277 sub r4,r4,r3 /* then n_lines = (len + 0x1f) / 0x20 */
279 srwi. r4,r4,5 /* note '.' suffix */
280 beqlr /* if n_lines == 0, just return. */
281 mtctr r4 /* flush cache lines */
282 0: dcbf 0,r3 /* for each line... */
291 DEF(void,primitive_inline_cache_miss,(void)):
293 DEF(void,primitive_inline_cache_miss_tail,(void)):
296 bl MANGLE(inline_cache_miss)
301 DEF(void,get_ppc_fpu_env,(void*)):
306 DEF(void,set_ppc_fpu_env,(const void*)):
311 DEF(void,get_ppc_vmx_env,(void*)):
322 DEF(void,set_ppc_vmx_env,(const void*)):