1 ! Copyright (C) 2005, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs sequences kernel combinators
4 classes.algebra byte-arrays make math math.order math.ranges
5 system namespaces locals layouts words alien alien.accessors
6 alien.c-types alien.complex alien.data alien.libraries
7 literals cpu.architecture cpu.ppc.assembler cpu.ppc.assembler.backend
8 compiler.cfg.registers compiler.cfg.instructions
9 compiler.cfg.comparisons compiler.codegen.fixup
10 compiler.cfg.intrinsics compiler.cfg.stack-frame
11 compiler.cfg.build-stack-frame compiler.units compiler.constants
13 QUALIFIED-WITH: alien.c-types c
14 FROM: cpu.ppc.assembler => B ;
15 FROM: layouts => cell ;
19 ! PowerPC register assignments:
20 ! r2-r12: integer vregs
24 ! r16-r29: integer vregs
25 ! r30: integer scratch
29 ! Add some methods to the assembler that are useful to us
30 M: label (B) [ 0 ] 2dip (B) rc-relative-ppc-3 label-fixup ;
31 M: label BC [ 0 BC ] dip rc-relative-ppc-2 label-fixup ;
33 enable-float-intrinsics
35 M: ppc machine-registers
37 { int-regs $[ 2 12 [a,b] 16 29 [a,b] append ] }
38 { float-regs $[ 0 29 [a,b] ] }
41 CONSTANT: scratch-reg 30
42 CONSTANT: fp-scratch-reg 30
44 M: ppc complex-addressing? f ;
46 M: ppc fused-unboxing? f ;
48 M: ppc %load-immediate ( reg n -- ) swap LOAD ;
50 M: ppc %load-reference ( reg obj -- )
51 [ [ 0 swap LOAD32 ] [ rc-absolute-ppc-2/2 rel-literal ] bi* ]
52 [ \ f type-number swap LI ]
55 M: ppc %alien-global ( register symbol dll -- )
56 [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ;
62 : %load-vm-addr ( reg -- ) vm-reg MR ;
64 M: ppc %vm-field ( dst field -- ) [ vm-reg ] dip LWZ ;
66 M: ppc %set-vm-field ( src field -- ) [ vm-reg ] dip STW ;
68 GENERIC: loc-reg ( loc -- reg )
70 M: ds-loc loc-reg drop ds-reg ;
71 M: rs-loc loc-reg drop rs-reg ;
73 : loc>operand ( loc -- reg n )
74 [ loc-reg ] [ n>> cells neg ] bi ; inline
76 M: ppc %peek loc>operand LWZ ;
77 M: ppc %replace loc>operand STW ;
79 :: (%inc) ( n reg -- ) reg reg n cells ADDI ; inline
81 M: ppc %inc-d ( n -- ) ds-reg (%inc) ;
82 M: ppc %inc-r ( n -- ) rs-reg (%inc) ;
84 HOOK: reserved-area-size os ( -- n )
86 ! The start of the stack frame contains the size of this frame
87 ! as well as the currently executing code block
88 : factor-area-size ( -- n ) 2 cells ; foldable
89 : next-save ( n -- i ) cell - ; foldable
90 : xt-save ( n -- i ) 2 cells - ; foldable
92 ! Next, we have the spill area as well as the FFI parameter area.
93 ! It is safe for them to overlap, since basic blocks with FFI calls
94 ! will never spill -- indeed, basic blocks with FFI calls do not
95 ! use vregs at all, and the FFI call is a stack analysis sync point.
96 ! In the future this will change and the stack frame logic will
97 ! need to be untangled somewhat.
99 : param@ ( n -- x ) reserved-area-size + ; inline
101 : param-save-size ( -- n ) 8 cells ; foldable
104 reserved-area-size param-save-size + + ; inline
106 : spill@ ( n -- offset )
107 spill-offset local@ ;
109 ! Some FP intrinsics need a temporary scratch area in the stack
110 ! frame, 8 bytes in size. This is in the param-save area so it
111 ! does not overlap with spill slots.
112 : scratch@ ( n -- offset )
115 ! Finally we have the linkage area
116 HOOK: lr-save os ( -- n )
118 M: ppc stack-frame-size ( stack-frame -- i )
125 M: ppc %call ( word -- ) 0 BL rc-relative-ppc-3 rel-word-pic ;
127 M: ppc %jump ( word -- )
128 0 6 LOAD32 4 rc-absolute-ppc-2/2 rel-here
129 0 B rc-relative-ppc-3 rel-word-pic-tail ;
131 M: ppc %jump-label ( label -- ) B ;
132 M: ppc %return ( -- ) BLR ;
134 M:: ppc %dispatch ( src temp -- )
136 3 cells rc-absolute-ppc-2/2 rel-here
141 : (%slot) ( dst obj slot scale tag -- obj dst slot )
142 [ 0 assert= ] bi@ swapd ;
144 M: ppc %slot ( dst obj slot scale tag -- ) (%slot) LWZX ;
145 M: ppc %slot-imm ( dst obj slot tag -- ) slot-offset LWZ ;
146 M: ppc %set-slot ( src obj slot scale tag -- ) (%slot) STWX ;
147 M: ppc %set-slot-imm ( src obj slot tag -- ) slot-offset STW ;
150 M: ppc %add-imm ADDI ;
151 M: ppc %sub swap SUBF ;
152 M: ppc %sub-imm SUBI ;
154 M: ppc %mul-imm MULLI ;
156 M: ppc %and-imm ANDI ;
160 M: ppc %xor-imm XORI ;
162 M: ppc %shl-imm swapd SLWI ;
164 M: ppc %shr-imm swapd SRWI ;
166 M: ppc %sar-imm SRAWI ;
170 :: overflow-template ( label dst src1 src2 cc insn -- )
173 dst src2 src1 insn call
175 { cc-o [ label BO ] }
176 { cc/o [ label BNO ] }
179 M: ppc %fixnum-add ( label dst src1 src2 cc -- )
180 [ ADDO. ] overflow-template ;
182 M: ppc %fixnum-sub ( label dst src1 src2 cc -- )
183 [ SUBFO. ] overflow-template ;
185 M: ppc %fixnum-mul ( label dst src1 src2 cc -- )
186 [ MULLWO. ] overflow-template ;
188 M: ppc %add-float FADD ;
189 M: ppc %sub-float FSUB ;
190 M: ppc %mul-float FMUL ;
191 M: ppc %div-float FDIV ;
193 M: ppc integer-float-needs-stack-frame? t ;
195 M:: ppc %integer>float ( dst src -- )
196 HEX: 4330 scratch-reg LIS
197 scratch-reg 1 0 scratch@ STW
199 scratch-reg dup HEX: 8000 XORIS
200 scratch-reg 1 4 scratch@ STW
202 scratch-reg 4503601774854144.0 %load-reference
203 fp-scratch-reg scratch-reg float-offset LFD
204 dst dst fp-scratch-reg FSUB ;
206 M:: ppc %float>integer ( dst src -- )
207 fp-scratch-reg src FCTIWZ
208 fp-scratch-reg 1 0 scratch@ STFD
209 dst 1 4 scratch@ LWZ ;
211 M: ppc %copy ( dst src rep -- )
212 2over eq? [ 3drop ] [
214 { tagged-rep [ MR ] }
216 { double-rep [ FMR ] }
220 GENERIC: float-function-param* ( dst src -- )
222 M: spill-slot float-function-param* [ 1 ] dip n>> spill@ LFD ;
223 M: integer float-function-param* FMR ;
225 : float-function-param ( i src -- )
226 [ float-regs cdecl param-regs at nth ] dip float-function-param* ;
228 : float-function-return ( reg -- )
229 float-regs return-regs at first double-rep %copy ;
231 M:: ppc %unary-float-function ( dst src func -- )
232 0 src float-function-param
234 dst float-function-return ;
236 M:: ppc %binary-float-function ( dst src1 src2 func -- )
237 0 src1 float-function-param
238 1 src2 float-function-param
240 dst float-function-return ;
242 ! Internal format is always double-precision on PowerPC
243 M: ppc %single>double-float double-rep %copy ;
244 M: ppc %double>single-float FRSP ;
246 M: ppc %unbox-alien ( dst src -- )
249 M:: ppc %unbox-any-c-ptr ( dst src -- )
254 0 src \ f type-number CMPI
256 ! Compute tag in dst register
257 dst src tag-mask get ANDI
258 ! Is the object an alien?
259 0 dst alien type-number CMPI
260 ! Add an offset to start of byte array's data
261 dst src byte-array-offset ADDI
263 ! If so, load the offset and add it to the address
264 dst src alien-offset LWZ
268 : alien@ ( n -- n' ) cells alien type-number - ;
270 M:: ppc %box-alien ( dst src temp -- )
273 dst \ f type-number %load-immediate
276 dst 5 cells alien temp %allot
277 temp \ f type-number %load-immediate
278 temp dst 1 alien@ STW
279 temp dst 2 alien@ STW
285 :: %box-displaced-alien/f ( dst displacement base -- )
286 base dst 1 alien@ STW
287 displacement dst 3 alien@ STW
288 displacement dst 4 alien@ STW ;
290 :: %box-displaced-alien/alien ( dst displacement base temp -- )
291 ! Set new alien's base to base.base
292 temp base 1 alien@ LWZ
293 temp dst 1 alien@ STW
295 ! Compute displacement
296 temp base 3 alien@ LWZ
297 temp temp displacement ADD
298 temp dst 3 alien@ STW
301 temp base 4 alien@ LWZ
302 temp temp displacement ADD
303 temp dst 4 alien@ STW ;
305 :: %box-displaced-alien/byte-array ( dst displacement base temp -- )
306 base dst 1 alien@ STW
307 displacement dst 3 alien@ STW
308 temp base byte-array-offset ADDI
309 temp temp displacement ADD
310 temp dst 4 alien@ STW ;
312 :: %box-displaced-alien/dynamic ( dst displacement base temp -- )
314 "not-alien" define-label
317 0 base \ f type-number CMPI
320 ! Yes, it is f. Fill in new object
321 dst displacement base %box-displaced-alien/f
325 "not-f" resolve-label
328 temp base tag-mask get ANDI
331 0 temp alien type-number CMPI
334 dst displacement base temp %box-displaced-alien/alien
339 ! Is base a byte array? It has to be, by now...
340 "not-alien" resolve-label
342 dst displacement base temp %box-displaced-alien/byte-array ;
344 M:: ppc %box-displaced-alien ( dst displacement base temp base-class -- )
349 ! If displacement is zero, return the base
351 0 displacement 0 CMPI
354 ! Displacement is non-zero, we're going to be allocating a new
356 dst 5 cells alien temp %allot
359 temp \ f type-number %load-immediate
360 temp dst 2 alien@ STW
362 dst displacement base temp
364 { [ base-class \ f class<= ] [ drop %box-displaced-alien/f ] }
365 { [ base-class \ alien class<= ] [ %box-displaced-alien/alien ] }
366 { [ base-class \ byte-array class<= ] [ %box-displaced-alien/byte-array ] }
367 [ %box-displaced-alien/dynamic ]
373 : (%memory) ( val base displacement scale offset rep c-type -- base val displacement rep c-type )
374 [ [ 0 assert= ] bi@ swapd ] 2dip ; inline
376 M: ppc %load-memory-imm ( dst base offset rep c-type -- )
379 { c:char [ [ dup ] 2dip LBZ dup EXTSB ] }
389 { float-rep [ LFS ] }
390 { double-rep [ LFD ] }
394 M: ppc %load-memory ( dst base displacement scale offset rep c-type -- )
397 { c:char [ [ LBZX ] [ drop dup EXTSB ] 2bi ] }
400 { c:ushort [ LHZX ] }
407 { float-rep [ LFSX ] }
408 { double-rep [ LFDX ] }
412 M: ppc %store-memory-imm ( src base offset rep c-type -- )
425 { float-rep [ STFS ] }
426 { double-rep [ STFD ] }
430 M: ppc %store-memory ( src base displacement scale offset rep c-type -- )
436 { c:ushort [ STHX ] }
443 { float-rep [ STFSX ] }
444 { double-rep [ STFDX ] }
448 : load-zone-ptr ( reg -- )
449 vm-reg "nursery" vm-field-offset ADDI ;
451 : load-allot-ptr ( nursery-ptr allot-ptr -- )
452 [ drop load-zone-ptr ] [ swap 0 LWZ ] 2bi ;
454 :: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
455 scratch-reg allot-ptr n data-alignment get align ADDI
456 scratch-reg nursery-ptr 0 STW ;
458 :: store-header ( dst class -- )
459 class type-number tag-header scratch-reg LI
460 scratch-reg dst 0 STW ;
462 : store-tagged ( dst tag -- )
463 dupd type-number ORI ;
465 M:: ppc %allot ( dst size class nursery-ptr -- )
466 nursery-ptr dst load-allot-ptr
467 nursery-ptr dst size inc-allot-ptr
468 dst class store-header
469 dst class store-tagged ;
471 : load-cards-offset ( dst -- )
472 0 swap LOAD32 rc-absolute-ppc-2/2 rel-cards-offset ;
474 : load-decks-offset ( dst -- )
475 0 swap LOAD32 rc-absolute-ppc-2/2 rel-decks-offset ;
477 :: (%write-barrier) ( temp1 temp2 -- )
478 card-mark scratch-reg LI
481 temp1 temp1 card-bits SRWI
482 temp2 load-cards-offset
483 temp1 scratch-reg temp2 STBX
486 temp1 temp1 deck-bits card-bits - SRWI
487 temp2 load-decks-offset
488 temp1 scratch-reg temp2 STBX ;
490 M:: ppc %write-barrier ( src slot scale tag temp1 temp2 -- )
491 scale 0 assert= tag 0 assert=
493 temp1 temp2 (%write-barrier) ;
495 M:: ppc %write-barrier-imm ( src slot tag temp1 temp2 -- )
496 temp1 src slot tag slot-offset ADDI
497 temp1 temp2 (%write-barrier) ;
499 M:: ppc %check-nursery-branch ( label size cc temp1 temp2 -- )
500 temp1 vm-reg "nursery" vm-field-offset LWZ
501 temp2 vm-reg "nursery" vm-field-offset 2 cells + LWZ
502 temp1 temp1 size ADDI
506 { cc<= [ label BLE ] }
507 { cc/<= [ label BGT ] }
510 : gc-root-offsets ( seq -- seq' )
511 [ n>> spill@ ] map f like ;
513 M: ppc %call-gc ( gc-roots -- )
514 3 swap gc-root-offsets %load-reference
516 "inline_gc" f %c-invoke ;
518 M: ppc %prologue ( n -- )
519 0 11 LOAD32 rc-absolute-ppc-2/2 rel-this
522 [ [ 1 1 ] dip neg ADDI ]
523 [ [ 11 1 ] dip xt-save STW ]
525 [ [ 11 1 ] dip next-save STW ]
526 [ [ 0 1 ] dip lr-save + STW ]
529 M: ppc %epilogue ( n -- )
530 #! At the end of each word that calls a subroutine, we store
531 #! the previous link register value in r0 by popping it off
532 #! the stack, set the link register to the contents of r0,
533 #! and jump to the link register.
534 [ [ 0 1 ] dip lr-save + LWZ ]
535 [ [ 1 1 ] dip ADDI ] bi
538 :: (%boolean) ( dst temp branch1 branch2 -- )
540 dst \ f type-number %load-immediate
541 "end" get branch1 execute( label -- )
542 branch2 [ "end" get branch2 execute( label -- ) ] when
543 dst \ t %load-reference
544 "end" get resolve-label ; inline
546 :: %boolean ( dst cc temp -- )
547 cc negate-cc order-cc {
548 { cc< [ dst temp \ BLT f (%boolean) ] }
549 { cc<= [ dst temp \ BLE f (%boolean) ] }
550 { cc> [ dst temp \ BGT f (%boolean) ] }
551 { cc>= [ dst temp \ BGE f (%boolean) ] }
552 { cc= [ dst temp \ BEQ f (%boolean) ] }
553 { cc/= [ dst temp \ BNE f (%boolean) ] }
556 : (%compare) ( src1 src2 -- ) [ 0 ] dip CMP ; inline
558 : (%compare-integer-imm) ( src1 src2 -- )
559 [ 0 ] 2dip CMPI ; inline
561 : (%compare-imm) ( src1 src2 -- )
562 [ tag-fixnum ] [ \ f type-number ] if* (%compare-integer-imm) ; inline
564 : (%compare-float-unordered) ( src1 src2 -- )
565 [ 0 ] dip FCMPU ; inline
567 : (%compare-float-ordered) ( src1 src2 -- )
568 [ 0 ] dip FCMPO ; inline
570 :: (%compare-float) ( src1 src2 cc compare -- branch1 branch2 )
572 { cc< [ src1 src2 \ compare execute( a b -- ) \ BLT f ] }
573 { cc<= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BEQ ] }
574 { cc> [ src1 src2 \ compare execute( a b -- ) \ BGT f ] }
575 { cc>= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BEQ ] }
576 { cc= [ src1 src2 \ compare execute( a b -- ) \ BEQ f ] }
577 { cc<> [ src1 src2 \ compare execute( a b -- ) \ BLT \ BGT ] }
578 { cc<>= [ src1 src2 \ compare execute( a b -- ) \ BNO f ] }
579 { cc/< [ src1 src2 \ compare execute( a b -- ) \ BGE f ] }
580 { cc/<= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BO ] }
581 { cc/> [ src1 src2 \ compare execute( a b -- ) \ BLE f ] }
582 { cc/>= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BO ] }
583 { cc/= [ src1 src2 \ compare execute( a b -- ) \ BNE f ] }
584 { cc/<> [ src1 src2 \ compare execute( a b -- ) \ BEQ \ BO ] }
585 { cc/<>= [ src1 src2 \ compare execute( a b -- ) \ BO f ] }
588 M: ppc %compare [ (%compare) ] 2dip %boolean ;
590 M: ppc %compare-imm [ (%compare-imm) ] 2dip %boolean ;
592 M: ppc %compare-integer-imm [ (%compare-integer-imm) ] 2dip %boolean ;
594 M:: ppc %compare-float-ordered ( dst src1 src2 cc temp -- )
595 src1 src2 cc negate-cc \ (%compare-float-ordered) (%compare-float) :> ( branch1 branch2 )
596 dst temp branch1 branch2 (%boolean) ;
598 M:: ppc %compare-float-unordered ( dst src1 src2 cc temp -- )
599 src1 src2 cc negate-cc \ (%compare-float-unordered) (%compare-float) :> ( branch1 branch2 )
600 dst temp branch1 branch2 (%boolean) ;
602 :: %branch ( label cc -- )
604 { cc< [ label BLT ] }
605 { cc<= [ label BLE ] }
606 { cc> [ label BGT ] }
607 { cc>= [ label BGE ] }
608 { cc= [ label BEQ ] }
609 { cc/= [ label BNE ] }
612 M:: ppc %compare-branch ( label src1 src2 cc -- )
616 M:: ppc %compare-imm-branch ( label src1 src2 cc -- )
617 src1 src2 (%compare-imm)
620 M:: ppc %compare-integer-imm-branch ( label src1 src2 cc -- )
621 src1 src2 (%compare-integer-imm)
624 :: (%branch) ( label branch1 branch2 -- )
625 label branch1 execute( label -- )
626 branch2 [ label branch2 execute( label -- ) ] when ; inline
628 M:: ppc %compare-float-ordered-branch ( label src1 src2 cc -- )
629 src1 src2 cc \ (%compare-float-ordered) (%compare-float) :> ( branch1 branch2 )
630 label branch1 branch2 (%branch) ;
632 M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
633 src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> ( branch1 branch2 )
634 label branch1 branch2 (%branch) ;
636 : load-from-frame ( dst n rep -- )
638 { int-rep [ [ 1 ] dip LWZ ] }
639 { tagged-rep [ [ 1 ] dip LWZ ] }
640 { float-rep [ [ 1 ] dip LFS ] }
641 { double-rep [ [ 1 ] dip LFD ] }
642 { stack-params [ [ 0 1 ] dip LWZ [ 0 1 ] dip param@ STW ] }
645 : next-param@ ( n -- reg x )
648 : store-to-frame ( src n rep -- )
650 { int-rep [ [ 1 ] dip STW ] }
651 { tagged-rep [ [ 1 ] dip STW ] }
652 { float-rep [ [ 1 ] dip STFS ] }
653 { double-rep [ [ 1 ] dip STFD ] }
654 { stack-params [ [ [ 0 ] dip next-param@ LWZ 0 1 ] dip STW ] }
657 M: ppc %spill ( src rep dst -- )
658 swap [ n>> spill@ ] dip store-to-frame ;
660 M: ppc %reload ( dst rep src -- )
661 swap [ n>> spill@ ] dip load-from-frame ;
667 { int-regs { 3 4 5 6 } }
671 M:: ppc %save-param-reg ( stack reg rep -- )
672 reg stack local@ rep store-to-frame ;
674 M:: ppc %load-param-reg ( stack reg rep -- )
675 reg stack local@ rep load-from-frame ;
677 GENERIC: load-param ( reg src -- )
679 M: integer load-param int-rep %copy ;
681 M: spill-slot load-param [ 1 ] dip n>> spill@ LWZ ;
683 GENERIC: store-param ( reg dst -- )
685 M: integer store-param swap int-rep %copy ;
687 M: spill-slot store-param [ 1 ] dip n>> spill@ STW ;
689 :: call-unbox-func ( src func -- )
694 M:: ppc %unbox ( src n rep func -- )
695 src func call-unbox-func
696 ! Store the return value on the C stack
697 n [ rep reg-class-of return-regs at first rep %save-param-reg ] when* ;
699 M:: ppc %unbox-long-long ( src n func -- )
700 src func call-unbox-func
701 ! Store the return value on the C stack
704 4 1 n cell + local@ STW
707 M:: ppc %unbox-large-struct ( src n c-type -- )
710 c-type heap-size 5 LI
711 "memcpy" "libc" load-library %c-invoke ;
713 M:: ppc %box ( dst n rep func -- )
714 n [ 0 rep reg-class-of cdecl param-reg rep %load-param-reg ] when*
715 rep double-rep? 5 4 ? %load-vm-addr
719 M:: ppc %box-long-long ( dst n func -- )
722 4 1 n cell + local@ LWZ
728 : struct-return@ ( n -- n )
729 [ stack-frame get params>> ] unless* local@ ;
731 M: ppc %prepare-box-struct ( -- )
732 #! Compute target address for value struct return
733 3 1 f struct-return@ ADDI
736 M:: ppc %box-large-struct ( dst n c-type -- )
737 ! If n = f, then we're boxing a returned struct
738 ! Compute destination address and load struct size
739 3 1 n struct-return@ ADDI
740 c-type heap-size 4 LI
743 "from_value_struct" f %c-invoke
746 M:: ppc %restore-context ( temp1 temp2 -- )
748 ds-reg temp1 "datastack" context-field-offset LWZ
749 rs-reg temp1 "retainstack" context-field-offset LWZ ;
751 M:: ppc %save-context ( temp1 temp2 -- )
753 1 temp1 "callstack-top" context-field-offset STW
754 ds-reg temp1 "datastack" context-field-offset STW
755 rs-reg temp1 "retainstack" context-field-offset STW ;
757 M: ppc %c-invoke ( symbol dll -- )
758 [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
760 M: ppc %alien-indirect ( src -- )
761 [ 11 ] dip load-param 11 MTLR BLRL ;
763 M: ppc immediate-arithmetic? ( n -- ? ) -32768 32767 between? ;
765 M: ppc immediate-bitwise? ( n -- ? ) 0 65535 between? ;
767 M: ppc immediate-store? drop f ;
769 M: ppc return-struct-in-registers? ( c-type -- ? )
770 c-type return-in-registers?>> ;
772 M:: ppc %box-small-struct ( dst c-type -- )
773 #! Box a <= 16-byte struct returned in r3:r4:r5:r6
774 c-type heap-size 7 LI
776 "from_medium_struct" f %c-invoke
779 : %unbox-struct-1 ( -- )
780 ! Alien must be in r3.
783 : %unbox-struct-2 ( -- )
784 ! Alien must be in r3.
788 : %unbox-struct-4 ( -- )
789 ! Alien must be in r3.
795 M:: ppc %unbox-small-struct ( src c-type -- )
798 { [ dup 4 <= ] [ drop %unbox-struct-1 ] }
799 { [ dup 8 <= ] [ drop %unbox-struct-2 ] }
800 { [ dup 16 <= ] [ drop %unbox-struct-4 ] }
803 M: ppc %begin-callback ( -- )
805 "begin_callback" f %c-invoke ;
807 M: ppc %alien-callback ( quot -- )
808 3 swap %load-reference
809 4 3 quot-entry-point-offset LWZ
813 M: ppc %end-callback ( -- )
815 "end_callback" f %c-invoke ;
817 enable-float-functions
822 { [ os macosx? ] [ "cpu.ppc.macosx" require ] }
823 { [ os linux? ] [ "cpu.ppc.linux" require ] }
826 complex-double c-type t >>return-in-registers? drop