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 alien.data 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 ;
12 FROM: layouts => cell ;
16 ! PowerPC register assignments:
17 ! r2-r12: integer vregs
19 ! r30: integer scratch
23 ! Add some methods to the assembler that are useful to us
24 M: label (B) [ 0 ] 2dip (B) rc-relative-ppc-3 label-fixup ;
25 M: label BC [ 0 BC ] dip rc-relative-ppc-2 label-fixup ;
27 enable-float-intrinsics
30 \ ##integer>float t frame-required? set-word-prop
31 \ ##float>integer t frame-required? set-word-prop
34 : %load-vm-addr ( reg -- )
35 0 swap LOAD32 rc-absolute-ppc-2/2 rt-vm rel-fixup ;
37 : %load-vm-field-addr ( reg symbol -- )
38 [ drop %load-vm-addr ]
39 [ [ dup ] dip vm-field-offset ADDI ] 2bi ;
41 M: ppc %vm-field-ptr ( dst field -- ) %load-vm-field-addr ;
43 M: ppc %vm-invoke-1st-arg ( function -- ) f %alien-invoke ;
44 M: ppc %vm-invoke-3rd-arg ( function -- ) f %alien-invoke ;
46 M: ppc machine-registers
48 { int-regs $[ 2 12 [a,b] 15 29 [a,b] append ] }
49 { float-regs $[ 0 29 [a,b] ] }
52 CONSTANT: scratch-reg 30
53 CONSTANT: fp-scratch-reg 30
55 M: ppc two-operand? f ;
57 M: ppc %load-immediate ( reg n -- ) swap LOAD ;
59 M: ppc %load-reference ( reg obj -- )
60 [ 0 swap LOAD32 ] [ rc-absolute-ppc-2/2 rel-immediate ] bi* ;
62 M: ppc %alien-global ( register symbol dll -- )
63 [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ;
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 XT
88 : factor-area-size ( -- n ) 2 cells ; foldable
89 : next-save ( n -- i ) cell - ;
90 : xt-save ( n -- i ) 2 cells - ;
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 )
116 : gc-root@ ( n -- offset )
117 gc-root-offset local@ ;
119 ! Finally we have the linkage area
120 HOOK: lr-save os ( -- n )
122 M: ppc stack-frame-size ( stack-frame -- i )
129 M: ppc %call ( word -- ) 0 BL rc-relative-ppc-3 rel-word-pic ;
131 M: ppc %jump ( word -- )
132 0 6 LOAD32 8 rc-absolute-ppc-2/2 rel-here
133 0 B rc-relative-ppc-3 rel-word-pic-tail ;
135 M: ppc %jump-label ( label -- ) B ;
136 M: ppc %return ( -- ) BLR ;
138 M:: ppc %dispatch ( src temp -- )
140 4 cells rc-absolute-ppc-2/2 rel-here
145 :: (%slot) ( obj slot tag temp -- reg offset )
147 temp tag neg ; inline
149 : (%slot-imm) ( obj slot tag -- reg offset )
150 [ cells ] dip - ; inline
152 M: ppc %slot ( dst obj slot tag temp -- ) (%slot) LWZ ;
153 M: ppc %slot-imm ( dst obj slot tag -- ) (%slot-imm) LWZ ;
154 M: ppc %set-slot ( src obj slot tag temp -- ) (%slot) STW ;
155 M: ppc %set-slot-imm ( src obj slot tag -- ) (%slot-imm) STW ;
157 M:: ppc %string-nth ( dst src index temp -- )
161 dst temp string-offset LBZ
164 temp src string-aux-offset LWZ
167 temp temp byte-array-offset LHZ
173 M:: ppc %set-string-nth-fast ( ch obj index temp -- )
175 ch temp string-offset STB ;
178 M: ppc %add-imm ADDI ;
179 M: ppc %sub swap SUBF ;
180 M: ppc %sub-imm SUBI ;
182 M: ppc %mul-imm MULLI ;
184 M: ppc %and-imm ANDI ;
188 M: ppc %xor-imm XORI ;
190 M: ppc %shl-imm swapd SLWI ;
192 M: ppc %shr-imm swapd SRWI ;
194 M: ppc %sar-imm SRAWI ;
197 :: overflow-template ( label dst src1 src2 insn -- )
200 dst src2 src1 insn call
203 M: ppc %fixnum-add ( label dst src1 src2 -- )
204 [ ADDO. ] overflow-template ;
206 M: ppc %fixnum-sub ( label dst src1 src2 -- )
207 [ SUBFO. ] overflow-template ;
209 M: ppc %fixnum-mul ( label dst src1 src2 -- )
210 [ MULLWO. ] overflow-template ;
212 : bignum@ ( n -- offset ) cells bignum tag-number - ; inline
214 M:: ppc %integer>bignum ( dst src temp -- )
217 dst 0 >bignum %load-reference
218 ! Is it zero? Then just go to the end and return this zero
222 dst 4 cells bignum temp %allot
225 temp dst 1 bignum@ STW
228 temp temp cell-bits 1 - SRAWI
231 temp dst 2 bignum@ STW
232 ! Make negative value positive
238 temp dst 3 bignum@ STW
242 M:: ppc %bignum>integer ( dst src temp -- )
245 temp src 1 bignum@ LWZ
246 ! if the length is 1, its just the sign and nothing else,
249 0 temp 1 tag-fixnum CMPI
252 dst src 3 bignum@ LWZ
254 temp src 2 bignum@ LWZ
255 ! branchless arithmetic: we want to turn 0 into 1,
260 ! multiply value by sign
265 M: ppc %add-float FADD ;
266 M: ppc %sub-float FSUB ;
267 M: ppc %mul-float FMUL ;
268 M: ppc %div-float FDIV ;
270 M:: ppc %integer>float ( dst src -- )
271 HEX: 4330 scratch-reg LIS
272 scratch-reg 1 0 scratch@ STW
274 scratch-reg dup HEX: 8000 XORIS
275 scratch-reg 1 4 scratch@ STW
277 scratch-reg 4503601774854144.0 %load-reference
278 fp-scratch-reg scratch-reg float-offset LFD
279 dst dst fp-scratch-reg FSUB ;
281 M:: ppc %float>integer ( dst src -- )
282 fp-scratch-reg src FCTIWZ
283 fp-scratch-reg 1 0 scratch@ STFD
284 dst 1 4 scratch@ LWZ ;
286 M: ppc %copy ( dst src rep -- )
289 { double-rep [ FMR ] }
292 M: ppc %unbox-float ( dst src -- ) float-offset LFD ;
294 M:: ppc %box-float ( dst src temp -- )
295 dst 16 float temp %allot
296 src dst float-offset STFD ;
298 : float-function-param ( i spill-slot -- )
299 [ float-regs param-regs nth 1 ] [ n>> spill@ ] bi* LFD ;
301 : float-function-return ( reg -- )
302 float-regs return-reg 2dup = [ 2drop ] [ FMR ] if ;
304 M:: ppc %unary-float-function ( dst src func -- )
305 0 src float-function-param
307 dst float-function-return ;
309 M:: ppc %binary-float-function ( dst src1 src2 func -- )
310 0 src1 float-function-param
311 1 src2 float-function-param
313 dst float-function-return ;
315 ! Internal format is always double-precision on PowerPC
316 M: ppc %single>double-float FMR ;
318 M: ppc %double>single-float FMR ;
320 M: ppc %unbox-alien ( dst src -- )
323 M:: ppc %unbox-any-c-ptr ( dst src temp -- )
325 { "is-byte-array" "end" "start" } [ define-label ] each
326 ! Address is computed in dst
328 ! Load object into scratch-reg
330 ! We come back here with displaced aliens
331 "start" resolve-label
333 0 scratch-reg \ f tag-number CMPI
336 ! Is the object an alien?
337 0 scratch-reg header-offset LWZ
338 0 0 alien type-number tag-fixnum CMPI
339 "is-byte-array" get BNE
340 ! If so, load the offset
341 0 scratch-reg alien-offset LWZ
342 ! Add it to address being computed
344 ! Now recurse on the underlying alien
345 scratch-reg scratch-reg underlying-alien-offset LWZ
347 "is-byte-array" resolve-label
348 ! Add byte array address to address being computed
349 dst dst scratch-reg ADD
350 ! Add an offset to start of byte array's data area
351 dst dst byte-array-offset ADDI
355 : alien@ ( n -- n' ) cells object tag-number - ;
357 :: %allot-alien ( dst displacement base temp -- )
358 dst 4 cells alien temp %allot
359 temp \ f tag-number %load-immediate
360 ! Store underlying-alien slot
361 base dst 1 alien@ STW
363 temp dst 2 alien@ STW
365 displacement dst 3 alien@ STW ;
367 M:: ppc %box-alien ( dst src temp -- )
370 dst \ f tag-number %load-immediate
373 dst src temp temp %allot-alien
377 M:: ppc %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
381 "simple-case" define-label
382 ! If displacement is zero, return the base
384 0 displacement 0 CMPI
386 ! Quickly use displacement' before its needed for real, as allot temporary
387 displacement' :> temp
388 dst 4 cells alien temp %allot
389 ! If base is already a displaced alien, unpack it
390 0 base \ f tag-number CMPI
391 "simple-case" get BEQ
392 temp base header-offset LWZ
393 0 temp alien type-number tag-fixnum CMPI
394 "simple-case" get BNE
395 ! displacement += base.displacement
396 temp base 3 alien@ LWZ
397 displacement' displacement temp ADD
399 base' base 1 alien@ LWZ
401 "simple-case" resolve-label
402 displacement' displacement MR
404 "alloc" resolve-label
405 ! Store underlying-alien slot
406 base' dst 1 alien@ STW
408 displacement' dst 3 alien@ STW
409 ! Store expired slot (its ok to clobber displacement')
410 temp \ f tag-number %load-immediate
411 temp dst 2 alien@ STW
415 M: ppc %alien-unsigned-1 0 LBZ ;
416 M: ppc %alien-unsigned-2 0 LHZ ;
418 M: ppc %alien-signed-1 dupd 0 LBZ dup EXTSB ;
419 M: ppc %alien-signed-2 0 LHA ;
421 M: ppc %alien-cell 0 LWZ ;
423 M: ppc %alien-float 0 LFS ;
424 M: ppc %alien-double 0 LFD ;
426 M: ppc %set-alien-integer-1 swap 0 STB ;
427 M: ppc %set-alien-integer-2 swap 0 STH ;
429 M: ppc %set-alien-cell swap 0 STW ;
431 M: ppc %set-alien-float swap 0 STFS ;
432 M: ppc %set-alien-double swap 0 STFD ;
434 : load-zone-ptr ( reg -- )
435 "nursery" %load-vm-field-addr ;
437 : load-allot-ptr ( nursery-ptr allot-ptr -- )
438 [ drop load-zone-ptr ] [ swap 4 LWZ ] 2bi ;
440 :: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
441 scratch-reg allot-ptr n 8 align ADDI
442 scratch-reg nursery-ptr 4 STW ;
444 :: store-header ( dst class -- )
445 class type-number tag-fixnum scratch-reg LI
446 scratch-reg dst 0 STW ;
448 : store-tagged ( dst tag -- )
449 dupd tag-number ORI ;
451 M:: ppc %allot ( dst size class nursery-ptr -- )
452 nursery-ptr dst load-allot-ptr
453 nursery-ptr dst size inc-allot-ptr
454 dst class store-header
455 dst class store-tagged ;
457 : load-cards-offset ( dst -- )
458 [ "cards_offset" %load-vm-field-addr ] [ dup 0 LWZ ] bi ;
460 : load-decks-offset ( dst -- )
461 [ "decks_offset" %load-vm-field-addr ] [ dup 0 LWZ ] bi ;
463 M:: ppc %write-barrier ( src card# table -- )
464 card-mark scratch-reg LI
467 table load-cards-offset
468 src card# card-bits SRWI
469 table scratch-reg card# STBX
472 table load-decks-offset
473 src card# deck-bits SRWI
474 table scratch-reg card# STBX ;
476 M:: ppc %check-nursery ( label temp1 temp2 -- )
479 temp2 temp2 3 cells LWZ
480 ! add ALLOT_BUFFER_ZONE to here
481 temp1 temp1 1024 ADDI
486 M:: ppc %save-gc-root ( gc-root register -- )
487 register 1 gc-root gc-root@ STW ;
489 M:: ppc %load-gc-root ( gc-root register -- )
490 register 1 gc-root gc-root@ LWZ ;
492 M:: ppc %call-gc ( gc-root-count -- )
493 3 1 gc-root-base local@ ADDI
495 "inline_gc" f %alien-invoke ;
497 M: ppc %prologue ( n -- )
498 0 11 LOAD32 rc-absolute-ppc-2/2 rel-this
501 [ [ 1 1 ] dip neg ADDI ]
502 [ [ 11 1 ] dip xt-save STW ]
504 [ [ 11 1 ] dip next-save STW ]
505 [ [ 0 1 ] dip lr-save + STW ]
508 M: ppc %epilogue ( n -- )
509 #! At the end of each word that calls a subroutine, we store
510 #! the previous link register value in r0 by popping it off
511 #! the stack, set the link register to the contents of r0,
512 #! and jump to the link register.
513 [ [ 0 1 ] dip lr-save + LWZ ]
514 [ [ 1 1 ] dip ADDI ] bi
517 :: (%boolean) ( dst temp branch1 branch2 -- )
519 dst \ f tag-number %load-immediate
520 "end" get branch1 execute( label -- )
521 branch2 [ "end" get branch2 execute( label -- ) ] when
522 dst \ t %load-reference
523 "end" get resolve-label ; inline
525 :: %boolean ( dst cc temp -- )
526 cc negate-cc order-cc {
527 { cc< [ dst temp \ BLT f (%boolean) ] }
528 { cc<= [ dst temp \ BLE f (%boolean) ] }
529 { cc> [ dst temp \ BGT f (%boolean) ] }
530 { cc>= [ dst temp \ BGE f (%boolean) ] }
531 { cc= [ dst temp \ BEQ f (%boolean) ] }
532 { cc/= [ dst temp \ BNE f (%boolean) ] }
535 : (%compare) ( src1 src2 -- ) [ 0 ] dip CMP ; inline
536 : (%compare-imm) ( src1 src2 -- ) [ 0 ] 2dip CMPI ; inline
537 : (%compare-float-unordered) ( src1 src2 -- ) [ 0 ] dip FCMPU ; inline
538 : (%compare-float-ordered) ( src1 src2 -- ) [ 0 ] dip FCMPO ; inline
540 :: (%compare-float) ( src1 src2 cc compare -- branch1 branch2 )
542 { cc< [ src1 src2 \ compare execute( a b -- ) \ BLT f ] }
543 { cc<= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BEQ ] }
544 { cc> [ src1 src2 \ compare execute( a b -- ) \ BGT f ] }
545 { cc>= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BEQ ] }
546 { cc= [ src1 src2 \ compare execute( a b -- ) \ BEQ f ] }
547 { cc<> [ src1 src2 \ compare execute( a b -- ) \ BLT \ BGT ] }
548 { cc<>= [ src1 src2 \ compare execute( a b -- ) \ BNO f ] }
549 { cc/< [ src1 src2 \ compare execute( a b -- ) \ BGE f ] }
550 { cc/<= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BO ] }
551 { cc/> [ src1 src2 \ compare execute( a b -- ) \ BLE f ] }
552 { cc/>= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BO ] }
553 { cc/= [ src1 src2 \ compare execute( a b -- ) \ BNE f ] }
554 { cc/<> [ src1 src2 \ compare execute( a b -- ) \ BEQ \ BO ] }
555 { cc/<>= [ src1 src2 \ compare execute( a b -- ) \ BO f ] }
558 M: ppc %compare [ (%compare) ] 2dip %boolean ;
560 M: ppc %compare-imm [ (%compare-imm) ] 2dip %boolean ;
562 M:: ppc %compare-float-ordered ( dst src1 src2 cc temp -- )
563 src1 src2 cc negate-cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
564 dst temp branch1 branch2 (%boolean) ;
566 M:: ppc %compare-float-unordered ( dst src1 src2 cc temp -- )
567 src1 src2 cc negate-cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
568 dst temp branch1 branch2 (%boolean) ;
570 :: %branch ( label cc -- )
572 { cc< [ label BLT ] }
573 { cc<= [ label BLE ] }
574 { cc> [ label BGT ] }
575 { cc>= [ label BGE ] }
576 { cc= [ label BEQ ] }
577 { cc/= [ label BNE ] }
580 M:: ppc %compare-branch ( label src1 src2 cc -- )
584 M:: ppc %compare-imm-branch ( label src1 src2 cc -- )
585 src1 src2 (%compare-imm)
588 :: (%branch) ( label branch1 branch2 -- )
589 label branch1 execute( label -- )
590 branch2 [ label branch2 execute( label -- ) ] when ; inline
592 M:: ppc %compare-float-ordered-branch ( label src1 src2 cc -- )
593 src1 src2 cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
594 label branch1 branch2 (%branch) ;
596 M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
597 src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
598 label branch1 branch2 (%branch) ;
600 : load-from-frame ( dst n rep -- )
602 { int-rep [ [ 1 ] dip LWZ ] }
603 { float-rep [ [ 1 ] dip LFS ] }
604 { double-rep [ [ 1 ] dip LFD ] }
605 { stack-params [ [ 0 1 ] dip LWZ [ 0 1 ] dip param@ STW ] }
608 : next-param@ ( n -- x ) param@ stack-frame get total-size>> + ;
610 : store-to-frame ( src n rep -- )
612 { int-rep [ [ 1 ] dip STW ] }
613 { float-rep [ [ 1 ] dip STFS ] }
614 { double-rep [ [ 1 ] dip STFD ] }
615 { stack-params [ [ [ 0 1 ] dip next-param@ LWZ 0 1 ] dip STW ] }
618 M: ppc %spill ( src rep n -- )
619 swap [ spill@ ] dip store-to-frame ;
621 M: ppc %reload ( dst rep n -- )
622 swap [ spill@ ] dip load-from-frame ;
626 M: int-regs return-reg drop 3 ;
627 M: int-regs param-regs drop { 3 4 5 6 7 8 9 10 } ;
628 M: float-regs return-reg drop 1 ;
630 M:: ppc %save-param-reg ( stack reg rep -- )
631 reg stack local@ rep store-to-frame ;
633 M:: ppc %load-param-reg ( stack reg rep -- )
634 reg stack local@ rep load-from-frame ;
636 M: ppc %prepare-unbox ( -- )
637 ! First parameter is top of stack
639 ds-reg dup cell SUBI ;
641 M: ppc %unbox ( n rep func -- )
642 ! Value must be in r3
645 ! Store the return value on the C stack
646 over [ [ reg-class-of return-reg ] keep %save-param-reg ] [ 2drop ] if ;
648 M: ppc %unbox-long-long ( n func -- )
649 ! Value must be in r3:r4
652 ! Store the return value on the C stack
654 [ [ 3 1 ] dip local@ STW ]
655 [ [ 4 1 ] dip cell + local@ STW ] bi
658 M: ppc %unbox-large-struct ( n c-type -- )
659 ! Value must be in r3
660 ! Compute destination address and load struct size
661 [ [ 4 1 ] dip local@ ADDI ] [ heap-size 5 LI ] bi*
663 "to_value_struct" f %alien-invoke ;
665 M: ppc %box ( n rep func -- )
666 ! If the source is a stack location, load it into freg #0.
667 ! If the source is f, then we assume the value is already in
669 [ over [ 0 over reg-class-of param-reg swap %load-param-reg ] [ 2drop ] if ] dip
672 M: ppc %box-long-long ( n func -- )
675 [ [ 3 1 ] dip local@ LWZ ]
676 [ [ 4 1 ] dip cell + local@ LWZ ] bi
678 ] dip f %alien-invoke ;
680 : struct-return@ ( n -- n )
681 [ stack-frame get params>> ] unless* local@ ;
683 M: ppc %prepare-box-struct ( -- )
684 #! Compute target address for value struct return
685 3 1 f struct-return@ ADDI
688 M: ppc %box-large-struct ( n c-type -- )
689 ! If n = f, then we're boxing a returned struct
690 ! Compute destination address and load struct size
691 [ [ 3 1 ] dip struct-return@ ADDI ] [ heap-size 4 LI ] bi*
693 "box_value_struct" f %alien-invoke ;
695 M:: ppc %save-context ( temp1 temp2 callback-allowed? -- )
696 #! Save Factor stack pointers in case the C code calls a
697 #! callback which does a GC, which must reliably trace
699 temp1 "stack_chain" %load-vm-field-addr
707 M: ppc %alien-invoke ( symbol dll -- )
708 [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
710 M: ppc %alien-callback ( quot -- )
711 3 swap %load-reference "c_to_factor" f %alien-invoke ;
713 M: ppc %prepare-alien-indirect ( -- )
714 "unbox_alien" f %alien-invoke
717 M: ppc %alien-indirect ( -- )
720 M: ppc %callback-value ( ctype -- )
721 ! Save top of data stack
724 ! Restore data/call/retain stacks
725 "unnest_stacks" f %alien-invoke
726 ! Restore top of data stack
728 ! Unbox former top of data stack to return registers
731 M: ppc small-enough? ( n -- ? ) -32768 32767 between? ;
733 M: ppc return-struct-in-registers? ( c-type -- ? )
734 c-type return-in-registers?>> ;
736 M: ppc %box-small-struct ( c-type -- )
737 #! Box a <= 16-byte struct returned in r3:r4:r5:r6
739 "box_medium_struct" f %alien-invoke ;
741 : %unbox-struct-1 ( -- )
742 ! Alien must be in r3.
743 "alien_offset" f %alien-invoke
746 : %unbox-struct-2 ( -- )
747 ! Alien must be in r3.
748 "alien_offset" f %alien-invoke
752 : %unbox-struct-4 ( -- )
753 ! Alien must be in r3.
754 "alien_offset" f %alien-invoke
760 M: ppc %unbox-small-struct ( size -- )
761 #! Alien must be in EAX.
762 heap-size cell align cell /i {
763 { 1 [ %unbox-struct-1 ] }
764 { 2 [ %unbox-struct-2 ] }
765 { 4 [ %unbox-struct-4 ] }
768 enable-float-functions
773 { [ os macosx? ] [ "cpu.ppc.macosx" require ] }
774 { [ os linux? ] [ "cpu.ppc.linux" require ] }
777 "complex-double" c-type t >>return-in-registers? drop
781 [ alien-unsigned-4 c-bool> ] >>getter
782 [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
785 "box_boolean" >>boxer
786 "to_boolean" >>unboxer
787 bool define-primitive-type
788 ] with-compilation-unit