1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs sequences kernel combinators make math
4 math.order math.ranges system namespaces locals layouts words
5 alien alien.accessors alien.c-types literals cpu.architecture
6 cpu.ppc.assembler cpu.ppc.assembler.backend compiler.cfg.registers
7 compiler.cfg.instructions compiler.cfg.comparisons
8 compiler.codegen.fixup compiler.cfg.intrinsics
9 compiler.cfg.stack-frame compiler.cfg.build-stack-frame
10 compiler.units compiler.constants compiler.codegen vm ;
11 FROM: cpu.ppc.assembler => B ;
14 ! PowerPC register assignments:
15 ! r2-r12: integer vregs
17 ! r30: integer scratch
21 ! Add some methods to the assembler that are useful to us
22 M: label (B) [ 0 ] 2dip (B) rc-relative-ppc-3 label-fixup ;
23 M: label BC [ 0 BC ] dip rc-relative-ppc-2 label-fixup ;
25 enable-float-intrinsics
28 \ ##integer>float t frame-required? set-word-prop
29 \ ##float>integer t frame-required? set-word-prop
32 : %load-vm-addr ( reg -- )
33 0 swap LOAD32 rc-absolute-ppc-2/2 rt-vm rel-fixup ;
35 : %load-vm-field-addr ( reg symbol -- )
36 [ drop %load-vm-addr ]
37 [ [ dup ] dip vm-field-offset ADDI ] 2bi ;
39 M: ppc %vm-field-ptr ( dst field -- ) %load-vm-field-addr ;
41 M: ppc %vm-invoke-1st-arg ( function -- ) f %alien-invoke ;
42 M: ppc %vm-invoke-3rd-arg ( function -- ) f %alien-invoke ;
44 M: ppc machine-registers
46 { int-regs $[ 2 12 [a,b] 15 29 [a,b] append ] }
47 { float-regs $[ 0 29 [a,b] ] }
50 CONSTANT: scratch-reg 30
51 CONSTANT: fp-scratch-reg 30
53 M: ppc two-operand? f ;
55 M: ppc %load-immediate ( reg n -- ) swap LOAD ;
57 M: ppc %load-reference ( reg obj -- )
58 [ 0 swap LOAD32 ] [ rc-absolute-ppc-2/2 rel-immediate ] bi* ;
60 M: ppc %alien-global ( register symbol dll -- )
61 [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ;
66 GENERIC: loc-reg ( loc -- reg )
68 M: ds-loc loc-reg drop ds-reg ;
69 M: rs-loc loc-reg drop rs-reg ;
71 : loc>operand ( loc -- reg n )
72 [ loc-reg ] [ n>> cells neg ] bi ; inline
74 M: ppc %peek loc>operand LWZ ;
75 M: ppc %replace loc>operand STW ;
77 :: (%inc) ( n reg -- ) reg reg n cells ADDI ; inline
79 M: ppc %inc-d ( n -- ) ds-reg (%inc) ;
80 M: ppc %inc-r ( n -- ) rs-reg (%inc) ;
82 HOOK: reserved-area-size os ( -- n )
84 ! The start of the stack frame contains the size of this frame
85 ! as well as the currently executing XT
86 : factor-area-size ( -- n ) 2 cells ; foldable
87 : next-save ( n -- i ) cell - ;
88 : xt-save ( n -- i ) 2 cells - ;
90 ! Next, we have the spill area as well as the FFI parameter area.
91 ! It is safe for them to overlap, since basic blocks with FFI calls
92 ! will never spill -- indeed, basic blocks with FFI calls do not
93 ! use vregs at all, and the FFI call is a stack analysis sync point.
94 ! In the future this will change and the stack frame logic will
95 ! need to be untangled somewhat.
97 : param@ ( n -- x ) reserved-area-size + ; inline
99 : param-save-size ( -- n ) 8 cells ; foldable
102 reserved-area-size param-save-size + + ; inline
104 : spill@ ( n -- offset )
105 spill-offset local@ ;
107 ! Some FP intrinsics need a temporary scratch area in the stack
108 ! frame, 8 bytes in size. This is in the param-save area so it
109 ! does not overlap with spill slots.
110 : scratch@ ( n -- offset )
114 : gc-root@ ( n -- offset )
115 gc-root-offset local@ ;
117 ! Finally we have the linkage area
118 HOOK: lr-save os ( -- n )
120 M: ppc stack-frame-size ( stack-frame -- i )
127 M: ppc %call ( word -- ) 0 BL rc-relative-ppc-3 rel-word-pic ;
129 M: ppc %jump ( word -- )
130 0 6 LOAD32 8 rc-absolute-ppc-2/2 rel-here
131 0 B rc-relative-ppc-3 rel-word-pic-tail ;
133 M: ppc %jump-label ( label -- ) B ;
134 M: ppc %return ( -- ) BLR ;
136 M:: ppc %dispatch ( src temp -- )
138 4 cells rc-absolute-ppc-2/2 rel-here
143 :: (%slot) ( obj slot tag temp -- reg offset )
145 temp tag neg ; inline
147 : (%slot-imm) ( obj slot tag -- reg offset )
148 [ cells ] dip - ; inline
150 M: ppc %slot ( dst obj slot tag temp -- ) (%slot) LWZ ;
151 M: ppc %slot-imm ( dst obj slot tag -- ) (%slot-imm) LWZ ;
152 M: ppc %set-slot ( src obj slot tag temp -- ) (%slot) STW ;
153 M: ppc %set-slot-imm ( src obj slot tag -- ) (%slot-imm) STW ;
155 M:: ppc %string-nth ( dst src index temp -- )
159 dst temp string-offset LBZ
162 temp src string-aux-offset LWZ
165 temp temp byte-array-offset LHZ
171 M:: ppc %set-string-nth-fast ( ch obj index temp -- )
173 ch temp string-offset STB ;
176 M: ppc %add-imm ADDI ;
177 M: ppc %sub swap SUBF ;
178 M: ppc %sub-imm SUBI ;
180 M: ppc %mul-imm MULLI ;
182 M: ppc %and-imm ANDI ;
186 M: ppc %xor-imm XORI ;
188 M: ppc %shl-imm swapd SLWI ;
190 M: ppc %shr-imm swapd SRWI ;
192 M: ppc %sar-imm SRAWI ;
195 :: overflow-template ( label dst src1 src2 insn -- )
198 dst src2 src1 insn call
201 M: ppc %fixnum-add ( label dst src1 src2 -- )
202 [ ADDO. ] overflow-template ;
204 M: ppc %fixnum-sub ( label dst src1 src2 -- )
205 [ SUBFO. ] overflow-template ;
207 M: ppc %fixnum-mul ( label dst src1 src2 -- )
208 [ MULLWO. ] overflow-template ;
210 : bignum@ ( n -- offset ) cells bignum tag-number - ; inline
212 M:: ppc %integer>bignum ( dst src temp -- )
215 dst 0 >bignum %load-reference
216 ! Is it zero? Then just go to the end and return this zero
220 dst 4 cells bignum temp %allot
223 temp dst 1 bignum@ STW
226 temp temp cell-bits 1 - SRAWI
229 temp dst 2 bignum@ STW
230 ! Make negative value positive
236 temp dst 3 bignum@ STW
240 M:: ppc %bignum>integer ( dst src temp -- )
243 temp src 1 bignum@ LWZ
244 ! if the length is 1, its just the sign and nothing else,
247 0 temp 1 tag-fixnum CMPI
250 dst src 3 bignum@ LWZ
252 temp src 2 bignum@ LWZ
253 ! branchless arithmetic: we want to turn 0 into 1,
258 ! multiply value by sign
263 M: ppc %add-float FADD ;
264 M: ppc %sub-float FSUB ;
265 M: ppc %mul-float FMUL ;
266 M: ppc %div-float FDIV ;
268 M:: ppc %integer>float ( dst src -- )
269 HEX: 4330 scratch-reg LIS
270 scratch-reg 1 0 scratch@ STW
272 scratch-reg dup HEX: 8000 XORIS
273 scratch-reg 1 4 scratch@ STW
275 scratch-reg 4503601774854144.0 %load-reference
276 fp-scratch-reg scratch-reg float-offset LFD
277 dst dst fp-scratch-reg FSUB ;
279 M:: ppc %float>integer ( dst src -- )
280 fp-scratch-reg src FCTIWZ
281 fp-scratch-reg 1 0 scratch@ STFD
282 dst 1 4 scratch@ LWZ ;
284 M: ppc %copy ( dst src rep -- )
287 { double-rep [ FMR ] }
290 M: ppc %unbox-float ( dst src -- ) float-offset LFD ;
292 M:: ppc %box-float ( dst src temp -- )
293 dst 16 float temp %allot
294 src dst float-offset STFD ;
296 : float-function-param ( i spill-slot -- )
297 [ float-regs param-regs nth 1 ] [ n>> spill@ ] bi* LFD ;
299 : float-function-return ( reg -- )
300 float-regs return-reg 2dup = [ 2drop ] [ FMR ] if ;
302 M:: ppc %unary-float-function ( dst src func -- )
303 0 src float-function-param
305 dst float-function-return ;
307 M:: ppc %binary-float-function ( dst src1 src2 func -- )
308 0 src1 float-function-param
309 1 src2 float-function-param
311 dst float-function-return ;
313 ! Internal format is always double-precision on PowerPC
314 M: ppc %single>double-float FMR ;
316 M: ppc %double>single-float FMR ;
318 M: ppc %unbox-alien ( dst src -- )
321 M:: ppc %unbox-any-c-ptr ( dst src temp -- )
323 { "is-byte-array" "end" "start" } [ define-label ] each
324 ! Address is computed in dst
326 ! Load object into scratch-reg
328 ! We come back here with displaced aliens
329 "start" resolve-label
331 0 scratch-reg \ f tag-number CMPI
334 ! Is the object an alien?
335 0 scratch-reg header-offset LWZ
336 0 0 alien type-number tag-fixnum CMPI
337 "is-byte-array" get BNE
338 ! If so, load the offset
339 0 scratch-reg alien-offset LWZ
340 ! Add it to address being computed
342 ! Now recurse on the underlying alien
343 scratch-reg scratch-reg underlying-alien-offset LWZ
345 "is-byte-array" resolve-label
346 ! Add byte array address to address being computed
347 dst dst scratch-reg ADD
348 ! Add an offset to start of byte array's data area
349 dst dst byte-array-offset ADDI
353 : alien@ ( n -- n' ) cells object tag-number - ;
355 :: %allot-alien ( dst displacement base temp -- )
356 dst 4 cells alien temp %allot
357 temp \ f tag-number %load-immediate
358 ! Store underlying-alien slot
359 base dst 1 alien@ STW
361 temp dst 2 alien@ STW
363 displacement dst 3 alien@ STW ;
365 M:: ppc %box-alien ( dst src temp -- )
368 dst \ f tag-number %load-immediate
371 dst src temp temp %allot-alien
375 M:: ppc %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
379 "simple-case" define-label
380 ! If displacement is zero, return the base
382 0 displacement 0 CMPI
384 ! Quickly use displacement' before its needed for real, as allot temporary
385 displacement' :> temp
386 dst 4 cells alien temp %allot
387 ! If base is already a displaced alien, unpack it
388 0 base \ f tag-number CMPI
389 "simple-case" get BEQ
390 temp base header-offset LWZ
391 0 temp alien type-number tag-fixnum CMPI
392 "simple-case" get BNE
393 ! displacement += base.displacement
394 temp base 3 alien@ LWZ
395 displacement' displacement temp ADD
397 base' base 1 alien@ LWZ
399 "simple-case" resolve-label
400 displacement' displacement MR
402 "alloc" resolve-label
403 ! Store underlying-alien slot
404 base' dst 1 alien@ STW
406 displacement' dst 3 alien@ STW
407 ! Store expired slot (its ok to clobber displacement')
408 temp \ f tag-number %load-immediate
409 temp dst 2 alien@ STW
413 M: ppc %alien-unsigned-1 0 LBZ ;
414 M: ppc %alien-unsigned-2 0 LHZ ;
416 M: ppc %alien-signed-1 dupd 0 LBZ dup EXTSB ;
417 M: ppc %alien-signed-2 0 LHA ;
419 M: ppc %alien-cell 0 LWZ ;
421 M: ppc %alien-float 0 LFS ;
422 M: ppc %alien-double 0 LFD ;
424 M: ppc %set-alien-integer-1 swap 0 STB ;
425 M: ppc %set-alien-integer-2 swap 0 STH ;
427 M: ppc %set-alien-cell swap 0 STW ;
429 M: ppc %set-alien-float swap 0 STFS ;
430 M: ppc %set-alien-double swap 0 STFD ;
432 : load-zone-ptr ( reg -- )
433 "nursery" %load-vm-field-addr ;
435 : load-allot-ptr ( nursery-ptr allot-ptr -- )
436 [ drop load-zone-ptr ] [ swap 4 LWZ ] 2bi ;
438 :: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
439 scratch-reg allot-ptr n 8 align ADDI
440 scratch-reg nursery-ptr 4 STW ;
442 :: store-header ( dst class -- )
443 class type-number tag-fixnum scratch-reg LI
444 scratch-reg dst 0 STW ;
446 : store-tagged ( dst tag -- )
447 dupd tag-number ORI ;
449 M:: ppc %allot ( dst size class nursery-ptr -- )
450 nursery-ptr dst load-allot-ptr
451 nursery-ptr dst size inc-allot-ptr
452 dst class store-header
453 dst class store-tagged ;
455 : load-cards-offset ( dst -- )
456 [ "cards_offset" %load-vm-field-addr ] [ dup 0 LWZ ] bi ;
458 : load-decks-offset ( dst -- )
459 [ "decks_offset" %load-vm-field-addr ] [ dup 0 LWZ ] bi ;
461 M:: ppc %write-barrier ( src card# table -- )
462 card-mark scratch-reg LI
465 table load-cards-offset
466 src card# card-bits SRWI
467 table scratch-reg card# STBX
470 table load-decks-offset
471 src card# deck-bits SRWI
472 table scratch-reg card# STBX ;
474 M:: ppc %check-nursery ( label temp1 temp2 -- )
477 temp2 temp2 3 cells LWZ
478 ! add ALLOT_BUFFER_ZONE to here
479 temp1 temp1 1024 ADDI
484 M:: ppc %save-gc-root ( gc-root register -- )
485 register 1 gc-root gc-root@ STW ;
487 M:: ppc %load-gc-root ( gc-root register -- )
488 register 1 gc-root gc-root@ LWZ ;
490 M:: ppc %call-gc ( gc-root-count -- )
491 3 1 gc-root-base local@ ADDI
493 "inline_gc" f %alien-invoke ;
495 M: ppc %prologue ( n -- )
496 0 11 LOAD32 rc-absolute-ppc-2/2 rel-this
499 [ [ 1 1 ] dip neg ADDI ]
500 [ [ 11 1 ] dip xt-save STW ]
502 [ [ 11 1 ] dip next-save STW ]
503 [ [ 0 1 ] dip lr-save + STW ]
506 M: ppc %epilogue ( n -- )
507 #! At the end of each word that calls a subroutine, we store
508 #! the previous link register value in r0 by popping it off
509 #! the stack, set the link register to the contents of r0,
510 #! and jump to the link register.
511 [ [ 0 1 ] dip lr-save + LWZ ]
512 [ [ 1 1 ] dip ADDI ] bi
515 :: (%boolean) ( dst temp branch1 branch2 -- )
517 dst \ f tag-number %load-immediate
518 "end" get branch1 execute( label -- )
519 branch2 [ "end" get branch2 execute( label -- ) ] when
520 dst \ t %load-reference
521 "end" get resolve-label ; inline
523 :: %boolean ( dst cc temp -- )
524 cc negate-cc order-cc {
525 { cc< [ dst temp \ BLT f (%boolean) ] }
526 { cc<= [ dst temp \ BLE f (%boolean) ] }
527 { cc> [ dst temp \ BGT f (%boolean) ] }
528 { cc>= [ dst temp \ BGE f (%boolean) ] }
529 { cc= [ dst temp \ BEQ f (%boolean) ] }
530 { cc/= [ dst temp \ BNE f (%boolean) ] }
533 : (%compare) ( src1 src2 -- ) [ 0 ] dip CMP ; inline
534 : (%compare-imm) ( src1 src2 -- ) [ 0 ] 2dip CMPI ; inline
535 : (%compare-float-unordered) ( src1 src2 -- ) [ 0 ] dip FCMPU ; inline
536 : (%compare-float-ordered) ( src1 src2 -- ) [ 0 ] dip FCMPO ; inline
538 :: (%compare-float) ( src1 src2 cc compare -- branch1 branch2 )
540 { cc< [ src1 src2 \ compare execute( a b -- ) \ BLT f ] }
541 { cc<= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BEQ ] }
542 { cc> [ src1 src2 \ compare execute( a b -- ) \ BGT f ] }
543 { cc>= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BEQ ] }
544 { cc= [ src1 src2 \ compare execute( a b -- ) \ BEQ f ] }
545 { cc<> [ src1 src2 \ compare execute( a b -- ) \ BLT \ BGT ] }
546 { cc<>= [ src1 src2 \ compare execute( a b -- ) \ BNO f ] }
547 { cc/< [ src1 src2 \ compare execute( a b -- ) \ BGE f ] }
548 { cc/<= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BO ] }
549 { cc/> [ src1 src2 \ compare execute( a b -- ) \ BLE f ] }
550 { cc/>= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BO ] }
551 { cc/= [ src1 src2 \ compare execute( a b -- ) \ BNE f ] }
552 { cc/<> [ src1 src2 \ compare execute( a b -- ) \ BEQ \ BO ] }
553 { cc/<>= [ src1 src2 \ compare execute( a b -- ) \ BO f ] }
556 M: ppc %compare [ (%compare) ] 2dip %boolean ;
558 M: ppc %compare-imm [ (%compare-imm) ] 2dip %boolean ;
560 M:: ppc %compare-float-ordered ( dst src1 src2 cc temp -- )
561 src1 src2 cc negate-cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
562 dst temp branch1 branch2 (%boolean) ;
564 M:: ppc %compare-float-unordered ( dst src1 src2 cc temp -- )
565 src1 src2 cc negate-cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
566 dst temp branch1 branch2 (%boolean) ;
568 :: %branch ( label cc -- )
570 { cc< [ label BLT ] }
571 { cc<= [ label BLE ] }
572 { cc> [ label BGT ] }
573 { cc>= [ label BGE ] }
574 { cc= [ label BEQ ] }
575 { cc/= [ label BNE ] }
578 M:: ppc %compare-branch ( label src1 src2 cc -- )
582 M:: ppc %compare-imm-branch ( label src1 src2 cc -- )
583 src1 src2 (%compare-imm)
586 :: (%branch) ( label branch1 branch2 -- )
587 label branch1 execute( label -- )
588 branch2 [ label branch2 execute( label -- ) ] when ; inline
590 M:: ppc %compare-float-ordered-branch ( label src1 src2 cc -- )
591 src1 src2 cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
592 label branch1 branch2 (%branch) ;
594 M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
595 src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
596 label branch1 branch2 (%branch) ;
598 : load-from-frame ( dst n rep -- )
600 { int-rep [ [ 1 ] dip LWZ ] }
601 { float-rep [ [ 1 ] dip LFS ] }
602 { double-rep [ [ 1 ] dip LFD ] }
603 { stack-params [ [ 0 1 ] dip LWZ [ 0 1 ] dip param@ STW ] }
606 : next-param@ ( n -- x ) param@ stack-frame get total-size>> + ;
608 : store-to-frame ( src n rep -- )
610 { int-rep [ [ 1 ] dip STW ] }
611 { float-rep [ [ 1 ] dip STFS ] }
612 { double-rep [ [ 1 ] dip STFD ] }
613 { stack-params [ [ [ 0 1 ] dip next-param@ LWZ 0 1 ] dip STW ] }
616 M: ppc %spill ( src rep n -- )
617 swap [ spill@ ] dip store-to-frame ;
619 M: ppc %reload ( dst rep n -- )
620 swap [ spill@ ] dip load-from-frame ;
624 M: int-regs return-reg drop 3 ;
625 M: int-regs param-regs drop { 3 4 5 6 7 8 9 10 } ;
626 M: float-regs return-reg drop 1 ;
628 M:: ppc %save-param-reg ( stack reg rep -- )
629 reg stack local@ rep store-to-frame ;
631 M:: ppc %load-param-reg ( stack reg rep -- )
632 reg stack local@ rep load-from-frame ;
634 M: ppc %prepare-unbox ( -- )
635 ! First parameter is top of stack
637 ds-reg dup cell SUBI ;
639 M: ppc %unbox ( n rep func -- )
640 ! Value must be in r3
643 ! Store the return value on the C stack
644 over [ [ reg-class-of return-reg ] keep %save-param-reg ] [ 2drop ] if ;
646 M: ppc %unbox-long-long ( n func -- )
647 ! Value must be in r3:r4
650 ! Store the return value on the C stack
652 [ [ 3 1 ] dip local@ STW ]
653 [ [ 4 1 ] dip cell + local@ STW ] bi
656 M: ppc %unbox-large-struct ( n c-type -- )
657 ! Value must be in r3
658 ! Compute destination address and load struct size
659 [ [ 4 1 ] dip local@ ADDI ] [ heap-size 5 LI ] bi*
661 "to_value_struct" f %alien-invoke ;
663 M: ppc %box ( n rep func -- )
664 ! If the source is a stack location, load it into freg #0.
665 ! If the source is f, then we assume the value is already in
667 [ over [ 0 over reg-class-of param-reg swap %load-param-reg ] [ 2drop ] if ] dip
670 M: ppc %box-long-long ( n func -- )
673 [ [ 3 1 ] dip local@ LWZ ]
674 [ [ 4 1 ] dip cell + local@ LWZ ] bi
676 ] dip f %alien-invoke ;
678 : struct-return@ ( n -- n )
679 [ stack-frame get params>> ] unless* local@ ;
681 M: ppc %prepare-box-struct ( -- )
682 #! Compute target address for value struct return
683 3 1 f struct-return@ ADDI
686 M: ppc %box-large-struct ( n c-type -- )
687 ! If n = f, then we're boxing a returned struct
688 ! Compute destination address and load struct size
689 [ [ 3 1 ] dip struct-return@ ADDI ] [ heap-size 4 LI ] bi*
691 "box_value_struct" f %alien-invoke ;
693 M:: ppc %save-context ( temp1 temp2 callback-allowed? -- )
694 #! Save Factor stack pointers in case the C code calls a
695 #! callback which does a GC, which must reliably trace
697 temp1 "stack_chain" %load-vm-field-addr
705 M: ppc %alien-invoke ( symbol dll -- )
706 [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
708 M: ppc %alien-callback ( quot -- )
709 3 swap %load-reference "c_to_factor" f %alien-invoke ;
711 M: ppc %prepare-alien-indirect ( -- )
712 "unbox_alien" f %alien-invoke
715 M: ppc %alien-indirect ( -- )
718 M: ppc %callback-value ( ctype -- )
719 ! Save top of data stack
722 ! Restore data/call/retain stacks
723 "unnest_stacks" f %alien-invoke
724 ! Restore top of data stack
726 ! Unbox former top of data stack to return registers
729 M: ppc small-enough? ( n -- ? ) -32768 32767 between? ;
731 M: ppc return-struct-in-registers? ( c-type -- ? )
732 c-type return-in-registers?>> ;
734 M: ppc %box-small-struct ( c-type -- )
735 #! Box a <= 16-byte struct returned in r3:r4:r5:r6
737 "box_medium_struct" f %alien-invoke ;
739 : %unbox-struct-1 ( -- )
740 ! Alien must be in r3.
741 "alien_offset" f %alien-invoke
744 : %unbox-struct-2 ( -- )
745 ! Alien must be in r3.
746 "alien_offset" f %alien-invoke
750 : %unbox-struct-4 ( -- )
751 ! Alien must be in r3.
752 "alien_offset" f %alien-invoke
758 M: ppc %unbox-small-struct ( size -- )
759 #! Alien must be in EAX.
760 heap-size cell align cell /i {
761 { 1 [ %unbox-struct-1 ] }
762 { 2 [ %unbox-struct-2 ] }
763 { 4 [ %unbox-struct-4 ] }
766 enable-float-functions
771 { [ os macosx? ] [ "cpu.ppc.macosx" require ] }
772 { [ os linux? ] [ "cpu.ppc.linux" require ] }
775 "complex-double" c-type t >>return-in-registers? drop
779 [ alien-unsigned-4 c-bool> ] >>getter
780 [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
783 "box_boolean" >>boxer
784 "to_boolean" >>unboxer
785 "bool" define-primitive-type
786 ] with-compilation-unit