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 ;
15 ! PowerPC register assignments:
16 ! r2-r12: integer vregs
18 ! r30: integer scratch
22 ! Add some methods to the assembler that are useful to us
23 M: label (B) [ 0 ] 2dip (B) rc-relative-ppc-3 label-fixup ;
24 M: label BC [ 0 BC ] dip rc-relative-ppc-2 label-fixup ;
26 enable-float-intrinsics
29 \ ##integer>float t frame-required? set-word-prop
30 \ ##float>integer t frame-required? set-word-prop
33 : %load-vm-addr ( reg -- )
34 0 swap LOAD32 rc-absolute-ppc-2/2 rt-vm rel-fixup ;
36 : %load-vm-field-addr ( reg symbol -- )
37 [ drop %load-vm-addr ]
38 [ [ dup ] dip vm-field-offset ADDI ] 2bi ;
40 M: ppc %vm-field-ptr ( dst field -- ) %load-vm-field-addr ;
42 M: ppc %vm-invoke-1st-arg ( function -- ) f %alien-invoke ;
43 M: ppc %vm-invoke-3rd-arg ( function -- ) f %alien-invoke ;
45 M: ppc machine-registers
47 { int-regs $[ 2 12 [a,b] 15 29 [a,b] append ] }
48 { float-regs $[ 0 29 [a,b] ] }
51 CONSTANT: scratch-reg 30
52 CONSTANT: fp-scratch-reg 30
54 M: ppc two-operand? f ;
56 M: ppc %load-immediate ( reg n -- ) swap LOAD ;
58 M: ppc %load-reference ( reg obj -- )
59 [ 0 swap LOAD32 ] [ rc-absolute-ppc-2/2 rel-immediate ] bi* ;
61 M: ppc %alien-global ( register symbol dll -- )
62 [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ;
67 GENERIC: loc-reg ( loc -- reg )
69 M: ds-loc loc-reg drop ds-reg ;
70 M: rs-loc loc-reg drop rs-reg ;
72 : loc>operand ( loc -- reg n )
73 [ loc-reg ] [ n>> cells neg ] bi ; inline
75 M: ppc %peek loc>operand LWZ ;
76 M: ppc %replace loc>operand STW ;
78 :: (%inc) ( n reg -- ) reg reg n cells ADDI ; inline
80 M: ppc %inc-d ( n -- ) ds-reg (%inc) ;
81 M: ppc %inc-r ( n -- ) rs-reg (%inc) ;
83 HOOK: reserved-area-size os ( -- n )
85 ! The start of the stack frame contains the size of this frame
86 ! as well as the currently executing XT
87 : factor-area-size ( -- n ) 2 cells ; foldable
88 : next-save ( n -- i ) cell - ;
89 : xt-save ( n -- i ) 2 cells - ;
91 ! Next, we have the spill area as well as the FFI parameter area.
92 ! It is safe for them to overlap, since basic blocks with FFI calls
93 ! will never spill -- indeed, basic blocks with FFI calls do not
94 ! use vregs at all, and the FFI call is a stack analysis sync point.
95 ! In the future this will change and the stack frame logic will
96 ! need to be untangled somewhat.
98 : param@ ( n -- x ) reserved-area-size + ; inline
100 : param-save-size ( -- n ) 8 cells ; foldable
103 reserved-area-size param-save-size + + ; inline
105 : spill@ ( n -- offset )
106 spill-offset local@ ;
108 ! Some FP intrinsics need a temporary scratch area in the stack
109 ! frame, 8 bytes in size. This is in the param-save area so it
110 ! does not overlap with spill slots.
111 : scratch@ ( n -- offset )
115 : gc-root@ ( n -- offset )
116 gc-root-offset local@ ;
118 ! Finally we have the linkage area
119 HOOK: lr-save os ( -- n )
121 M: ppc stack-frame-size ( stack-frame -- i )
128 M: ppc %call ( word -- ) 0 BL rc-relative-ppc-3 rel-word-pic ;
130 M: ppc %jump ( word -- )
131 0 6 LOAD32 8 rc-absolute-ppc-2/2 rel-here
132 0 B rc-relative-ppc-3 rel-word-pic-tail ;
134 M: ppc %jump-label ( label -- ) B ;
135 M: ppc %return ( -- ) BLR ;
137 M:: ppc %dispatch ( src temp -- )
139 4 cells rc-absolute-ppc-2/2 rel-here
144 :: (%slot) ( obj slot tag temp -- reg offset )
146 temp tag neg ; inline
148 : (%slot-imm) ( obj slot tag -- reg offset )
149 [ cells ] dip - ; inline
151 M: ppc %slot ( dst obj slot tag temp -- ) (%slot) LWZ ;
152 M: ppc %slot-imm ( dst obj slot tag -- ) (%slot-imm) LWZ ;
153 M: ppc %set-slot ( src obj slot tag temp -- ) (%slot) STW ;
154 M: ppc %set-slot-imm ( src obj slot tag -- ) (%slot-imm) STW ;
156 M:: ppc %string-nth ( dst src index temp -- )
160 dst temp string-offset LBZ
163 temp src string-aux-offset LWZ
166 temp temp byte-array-offset LHZ
172 M:: ppc %set-string-nth-fast ( ch obj index temp -- )
174 ch temp string-offset STB ;
177 M: ppc %add-imm ADDI ;
178 M: ppc %sub swap SUBF ;
179 M: ppc %sub-imm SUBI ;
181 M: ppc %mul-imm MULLI ;
183 M: ppc %and-imm ANDI ;
187 M: ppc %xor-imm XORI ;
189 M: ppc %shl-imm swapd SLWI ;
191 M: ppc %shr-imm swapd SRWI ;
193 M: ppc %sar-imm SRAWI ;
196 :: overflow-template ( label dst src1 src2 insn -- )
199 dst src2 src1 insn call
202 M: ppc %fixnum-add ( label dst src1 src2 -- )
203 [ ADDO. ] overflow-template ;
205 M: ppc %fixnum-sub ( label dst src1 src2 -- )
206 [ SUBFO. ] overflow-template ;
208 M: ppc %fixnum-mul ( label dst src1 src2 -- )
209 [ MULLWO. ] overflow-template ;
211 : bignum@ ( n -- offset ) cells bignum tag-number - ; inline
213 M:: ppc %integer>bignum ( dst src temp -- )
216 dst 0 >bignum %load-reference
217 ! Is it zero? Then just go to the end and return this zero
221 dst 4 cells bignum temp %allot
224 temp dst 1 bignum@ STW
227 temp temp cell-bits 1 - SRAWI
230 temp dst 2 bignum@ STW
231 ! Make negative value positive
237 temp dst 3 bignum@ STW
241 M:: ppc %bignum>integer ( dst src temp -- )
244 temp src 1 bignum@ LWZ
245 ! if the length is 1, its just the sign and nothing else,
248 0 temp 1 tag-fixnum CMPI
251 dst src 3 bignum@ LWZ
253 temp src 2 bignum@ LWZ
254 ! branchless arithmetic: we want to turn 0 into 1,
259 ! multiply value by sign
264 M: ppc %add-float FADD ;
265 M: ppc %sub-float FSUB ;
266 M: ppc %mul-float FMUL ;
267 M: ppc %div-float FDIV ;
269 M:: ppc %integer>float ( dst src -- )
270 HEX: 4330 scratch-reg LIS
271 scratch-reg 1 0 scratch@ STW
273 scratch-reg dup HEX: 8000 XORIS
274 scratch-reg 1 4 scratch@ STW
276 scratch-reg 4503601774854144.0 %load-reference
277 fp-scratch-reg scratch-reg float-offset LFD
278 dst dst fp-scratch-reg FSUB ;
280 M:: ppc %float>integer ( dst src -- )
281 fp-scratch-reg src FCTIWZ
282 fp-scratch-reg 1 0 scratch@ STFD
283 dst 1 4 scratch@ LWZ ;
285 M: ppc %copy ( dst src rep -- )
288 { double-rep [ FMR ] }
291 M: ppc %unbox-float ( dst src -- ) float-offset LFD ;
293 M:: ppc %box-float ( dst src temp -- )
294 dst 16 float temp %allot
295 src dst float-offset STFD ;
297 : float-function-param ( i spill-slot -- )
298 [ float-regs param-regs nth 1 ] [ n>> spill@ ] bi* LFD ;
300 : float-function-return ( reg -- )
301 float-regs return-reg 2dup = [ 2drop ] [ FMR ] if ;
303 M:: ppc %unary-float-function ( dst src func -- )
304 0 src float-function-param
306 dst float-function-return ;
308 M:: ppc %binary-float-function ( dst src1 src2 func -- )
309 0 src1 float-function-param
310 1 src2 float-function-param
312 dst float-function-return ;
314 ! Internal format is always double-precision on PowerPC
315 M: ppc %single>double-float FMR ;
317 M: ppc %double>single-float FMR ;
319 M: ppc %unbox-alien ( dst src -- )
322 M:: ppc %unbox-any-c-ptr ( dst src temp -- )
324 { "is-byte-array" "end" "start" } [ define-label ] each
325 ! Address is computed in dst
327 ! Load object into scratch-reg
329 ! We come back here with displaced aliens
330 "start" resolve-label
332 0 scratch-reg \ f tag-number CMPI
335 ! Is the object an alien?
336 0 scratch-reg header-offset LWZ
337 0 0 alien type-number tag-fixnum CMPI
338 "is-byte-array" get BNE
339 ! If so, load the offset
340 0 scratch-reg alien-offset LWZ
341 ! Add it to address being computed
343 ! Now recurse on the underlying alien
344 scratch-reg scratch-reg underlying-alien-offset LWZ
346 "is-byte-array" resolve-label
347 ! Add byte array address to address being computed
348 dst dst scratch-reg ADD
349 ! Add an offset to start of byte array's data area
350 dst dst byte-array-offset ADDI
354 : alien@ ( n -- n' ) cells object tag-number - ;
356 :: %allot-alien ( dst displacement base temp -- )
357 dst 4 cells alien temp %allot
358 temp \ f tag-number %load-immediate
359 ! Store underlying-alien slot
360 base dst 1 alien@ STW
362 temp dst 2 alien@ STW
364 displacement dst 3 alien@ STW ;
366 M:: ppc %box-alien ( dst src temp -- )
369 dst \ f tag-number %load-immediate
372 dst src temp temp %allot-alien
376 M:: ppc %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
380 "simple-case" define-label
381 ! If displacement is zero, return the base
383 0 displacement 0 CMPI
385 ! Quickly use displacement' before its needed for real, as allot temporary
386 displacement' :> temp
387 dst 4 cells alien temp %allot
388 ! If base is already a displaced alien, unpack it
389 0 base \ f tag-number CMPI
390 "simple-case" get BEQ
391 temp base header-offset LWZ
392 0 temp alien type-number tag-fixnum CMPI
393 "simple-case" get BNE
394 ! displacement += base.displacement
395 temp base 3 alien@ LWZ
396 displacement' displacement temp ADD
398 base' base 1 alien@ LWZ
400 "simple-case" resolve-label
401 displacement' displacement MR
403 "alloc" resolve-label
404 ! Store underlying-alien slot
405 base' dst 1 alien@ STW
407 displacement' dst 3 alien@ STW
408 ! Store expired slot (its ok to clobber displacement')
409 temp \ f tag-number %load-immediate
410 temp dst 2 alien@ STW
414 M: ppc %alien-unsigned-1 0 LBZ ;
415 M: ppc %alien-unsigned-2 0 LHZ ;
417 M: ppc %alien-signed-1 dupd 0 LBZ dup EXTSB ;
418 M: ppc %alien-signed-2 0 LHA ;
420 M: ppc %alien-cell 0 LWZ ;
422 M: ppc %alien-float 0 LFS ;
423 M: ppc %alien-double 0 LFD ;
425 M: ppc %set-alien-integer-1 swap 0 STB ;
426 M: ppc %set-alien-integer-2 swap 0 STH ;
428 M: ppc %set-alien-cell swap 0 STW ;
430 M: ppc %set-alien-float swap 0 STFS ;
431 M: ppc %set-alien-double swap 0 STFD ;
433 : load-zone-ptr ( reg -- )
434 "nursery" %load-vm-field-addr ;
436 : load-allot-ptr ( nursery-ptr allot-ptr -- )
437 [ drop load-zone-ptr ] [ swap 4 LWZ ] 2bi ;
439 :: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
440 scratch-reg allot-ptr n 8 align ADDI
441 scratch-reg nursery-ptr 4 STW ;
443 :: store-header ( dst class -- )
444 class type-number tag-fixnum scratch-reg LI
445 scratch-reg dst 0 STW ;
447 : store-tagged ( dst tag -- )
448 dupd tag-number ORI ;
450 M:: ppc %allot ( dst size class nursery-ptr -- )
451 nursery-ptr dst load-allot-ptr
452 nursery-ptr dst size inc-allot-ptr
453 dst class store-header
454 dst class store-tagged ;
456 : load-cards-offset ( dst -- )
457 [ "cards_offset" %load-vm-field-addr ] [ dup 0 LWZ ] bi ;
459 : load-decks-offset ( dst -- )
460 [ "decks_offset" %load-vm-field-addr ] [ dup 0 LWZ ] bi ;
462 M:: ppc %write-barrier ( src card# table -- )
463 card-mark scratch-reg LI
466 table load-cards-offset
467 src card# card-bits SRWI
468 table scratch-reg card# STBX
471 table load-decks-offset
472 src card# deck-bits SRWI
473 table scratch-reg card# STBX ;
475 M:: ppc %check-nursery ( label temp1 temp2 -- )
478 temp2 temp2 3 cells LWZ
479 ! add ALLOT_BUFFER_ZONE to here
480 temp1 temp1 1024 ADDI
485 M:: ppc %save-gc-root ( gc-root register -- )
486 register 1 gc-root gc-root@ STW ;
488 M:: ppc %load-gc-root ( gc-root register -- )
489 register 1 gc-root gc-root@ LWZ ;
491 M:: ppc %call-gc ( gc-root-count -- )
492 3 1 gc-root-base local@ ADDI
494 "inline_gc" f %alien-invoke ;
496 M: ppc %prologue ( n -- )
497 0 11 LOAD32 rc-absolute-ppc-2/2 rel-this
500 [ [ 1 1 ] dip neg ADDI ]
501 [ [ 11 1 ] dip xt-save STW ]
503 [ [ 11 1 ] dip next-save STW ]
504 [ [ 0 1 ] dip lr-save + STW ]
507 M: ppc %epilogue ( n -- )
508 #! At the end of each word that calls a subroutine, we store
509 #! the previous link register value in r0 by popping it off
510 #! the stack, set the link register to the contents of r0,
511 #! and jump to the link register.
512 [ [ 0 1 ] dip lr-save + LWZ ]
513 [ [ 1 1 ] dip ADDI ] bi
516 :: (%boolean) ( dst temp branch1 branch2 -- )
518 dst \ f tag-number %load-immediate
519 "end" get branch1 execute( label -- )
520 branch2 [ "end" get branch2 execute( label -- ) ] when
521 dst \ t %load-reference
522 "end" get resolve-label ; inline
524 :: %boolean ( dst cc temp -- )
525 cc negate-cc order-cc {
526 { cc< [ dst temp \ BLT f (%boolean) ] }
527 { cc<= [ dst temp \ BLE f (%boolean) ] }
528 { cc> [ dst temp \ BGT f (%boolean) ] }
529 { cc>= [ dst temp \ BGE f (%boolean) ] }
530 { cc= [ dst temp \ BEQ f (%boolean) ] }
531 { cc/= [ dst temp \ BNE f (%boolean) ] }
534 : (%compare) ( src1 src2 -- ) [ 0 ] dip CMP ; inline
535 : (%compare-imm) ( src1 src2 -- ) [ 0 ] 2dip CMPI ; inline
536 : (%compare-float-unordered) ( src1 src2 -- ) [ 0 ] dip FCMPU ; inline
537 : (%compare-float-ordered) ( src1 src2 -- ) [ 0 ] dip FCMPO ; inline
539 :: (%compare-float) ( src1 src2 cc compare -- branch1 branch2 )
541 { cc< [ src1 src2 \ compare execute( a b -- ) \ BLT f ] }
542 { cc<= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BEQ ] }
543 { cc> [ src1 src2 \ compare execute( a b -- ) \ BGT f ] }
544 { cc>= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BEQ ] }
545 { cc= [ src1 src2 \ compare execute( a b -- ) \ BEQ f ] }
546 { cc<> [ src1 src2 \ compare execute( a b -- ) \ BLT \ BGT ] }
547 { cc<>= [ src1 src2 \ compare execute( a b -- ) \ BNO f ] }
548 { cc/< [ src1 src2 \ compare execute( a b -- ) \ BGE f ] }
549 { cc/<= [ src1 src2 \ compare execute( a b -- ) \ BGT \ BO ] }
550 { cc/> [ src1 src2 \ compare execute( a b -- ) \ BLE f ] }
551 { cc/>= [ src1 src2 \ compare execute( a b -- ) \ BLT \ BO ] }
552 { cc/= [ src1 src2 \ compare execute( a b -- ) \ BNE f ] }
553 { cc/<> [ src1 src2 \ compare execute( a b -- ) \ BEQ \ BO ] }
554 { cc/<>= [ src1 src2 \ compare execute( a b -- ) \ BO f ] }
557 M: ppc %compare [ (%compare) ] 2dip %boolean ;
559 M: ppc %compare-imm [ (%compare-imm) ] 2dip %boolean ;
561 M:: ppc %compare-float-ordered ( dst src1 src2 cc temp -- )
562 src1 src2 cc negate-cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
563 dst temp branch1 branch2 (%boolean) ;
565 M:: ppc %compare-float-unordered ( dst src1 src2 cc temp -- )
566 src1 src2 cc negate-cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
567 dst temp branch1 branch2 (%boolean) ;
569 :: %branch ( label cc -- )
571 { cc< [ label BLT ] }
572 { cc<= [ label BLE ] }
573 { cc> [ label BGT ] }
574 { cc>= [ label BGE ] }
575 { cc= [ label BEQ ] }
576 { cc/= [ label BNE ] }
579 M:: ppc %compare-branch ( label src1 src2 cc -- )
583 M:: ppc %compare-imm-branch ( label src1 src2 cc -- )
584 src1 src2 (%compare-imm)
587 :: (%branch) ( label branch1 branch2 -- )
588 label branch1 execute( label -- )
589 branch2 [ label branch2 execute( label -- ) ] when ; inline
591 M:: ppc %compare-float-ordered-branch ( label src1 src2 cc -- )
592 src1 src2 cc \ (%compare-float-ordered) (%compare-float) :> branch2 :> branch1
593 label branch1 branch2 (%branch) ;
595 M:: ppc %compare-float-unordered-branch ( label src1 src2 cc -- )
596 src1 src2 cc \ (%compare-float-unordered) (%compare-float) :> branch2 :> branch1
597 label branch1 branch2 (%branch) ;
599 : load-from-frame ( dst n rep -- )
601 { int-rep [ [ 1 ] dip LWZ ] }
602 { float-rep [ [ 1 ] dip LFS ] }
603 { double-rep [ [ 1 ] dip LFD ] }
604 { stack-params [ [ 0 1 ] dip LWZ [ 0 1 ] dip param@ STW ] }
607 : next-param@ ( n -- x ) param@ stack-frame get total-size>> + ;
609 : store-to-frame ( src n rep -- )
611 { int-rep [ [ 1 ] dip STW ] }
612 { float-rep [ [ 1 ] dip STFS ] }
613 { double-rep [ [ 1 ] dip STFD ] }
614 { stack-params [ [ [ 0 1 ] dip next-param@ LWZ 0 1 ] dip STW ] }
617 M: ppc %spill ( src rep n -- )
618 swap [ spill@ ] dip store-to-frame ;
620 M: ppc %reload ( dst rep n -- )
621 swap [ spill@ ] dip load-from-frame ;
625 M: int-regs return-reg drop 3 ;
626 M: int-regs param-regs drop { 3 4 5 6 7 8 9 10 } ;
627 M: float-regs return-reg drop 1 ;
629 M:: ppc %save-param-reg ( stack reg rep -- )
630 reg stack local@ rep store-to-frame ;
632 M:: ppc %load-param-reg ( stack reg rep -- )
633 reg stack local@ rep load-from-frame ;
635 M: ppc %prepare-unbox ( -- )
636 ! First parameter is top of stack
638 ds-reg dup cell SUBI ;
640 M: ppc %unbox ( n rep func -- )
641 ! Value must be in r3
644 ! Store the return value on the C stack
645 over [ [ reg-class-of return-reg ] keep %save-param-reg ] [ 2drop ] if ;
647 M: ppc %unbox-long-long ( n func -- )
648 ! Value must be in r3:r4
651 ! Store the return value on the C stack
653 [ [ 3 1 ] dip local@ STW ]
654 [ [ 4 1 ] dip cell + local@ STW ] bi
657 M: ppc %unbox-large-struct ( n c-type -- )
658 ! Value must be in r3
659 ! Compute destination address and load struct size
660 [ [ 4 1 ] dip local@ ADDI ] [ heap-size 5 LI ] bi*
662 "to_value_struct" f %alien-invoke ;
664 M: ppc %box ( n rep func -- )
665 ! If the source is a stack location, load it into freg #0.
666 ! If the source is f, then we assume the value is already in
668 [ over [ 0 over reg-class-of param-reg swap %load-param-reg ] [ 2drop ] if ] dip
671 M: ppc %box-long-long ( n func -- )
674 [ [ 3 1 ] dip local@ LWZ ]
675 [ [ 4 1 ] dip cell + local@ LWZ ] bi
677 ] dip f %alien-invoke ;
679 : struct-return@ ( n -- n )
680 [ stack-frame get params>> ] unless* local@ ;
682 M: ppc %prepare-box-struct ( -- )
683 #! Compute target address for value struct return
684 3 1 f struct-return@ ADDI
687 M: ppc %box-large-struct ( n c-type -- )
688 ! If n = f, then we're boxing a returned struct
689 ! Compute destination address and load struct size
690 [ [ 3 1 ] dip struct-return@ ADDI ] [ heap-size 4 LI ] bi*
692 "box_value_struct" f %alien-invoke ;
694 M:: ppc %save-context ( temp1 temp2 callback-allowed? -- )
695 #! Save Factor stack pointers in case the C code calls a
696 #! callback which does a GC, which must reliably trace
698 temp1 "stack_chain" %load-vm-field-addr
706 M: ppc %alien-invoke ( symbol dll -- )
707 [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
709 M: ppc %alien-callback ( quot -- )
710 3 swap %load-reference "c_to_factor" f %alien-invoke ;
712 M: ppc %prepare-alien-indirect ( -- )
713 "unbox_alien" f %alien-invoke
716 M: ppc %alien-indirect ( -- )
719 M: ppc %callback-value ( ctype -- )
720 ! Save top of data stack
723 ! Restore data/call/retain stacks
724 "unnest_stacks" f %alien-invoke
725 ! Restore top of data stack
727 ! Unbox former top of data stack to return registers
730 M: ppc small-enough? ( n -- ? ) -32768 32767 between? ;
732 M: ppc return-struct-in-registers? ( c-type -- ? )
733 c-type return-in-registers?>> ;
735 M: ppc %box-small-struct ( c-type -- )
736 #! Box a <= 16-byte struct returned in r3:r4:r5:r6
738 "box_medium_struct" f %alien-invoke ;
740 : %unbox-struct-1 ( -- )
741 ! Alien must be in r3.
742 "alien_offset" f %alien-invoke
745 : %unbox-struct-2 ( -- )
746 ! Alien must be in r3.
747 "alien_offset" f %alien-invoke
751 : %unbox-struct-4 ( -- )
752 ! Alien must be in r3.
753 "alien_offset" f %alien-invoke
759 M: ppc %unbox-small-struct ( size -- )
760 #! Alien must be in EAX.
761 heap-size cell align cell /i {
762 { 1 [ %unbox-struct-1 ] }
763 { 2 [ %unbox-struct-2 ] }
764 { 4 [ %unbox-struct-4 ] }
767 enable-float-functions
772 { [ os macosx? ] [ "cpu.ppc.macosx" require ] }
773 { [ os linux? ] [ "cpu.ppc.linux" require ] }
776 "complex-double" c-type t >>return-in-registers? drop
780 [ alien-unsigned-4 c-bool> ] >>getter
781 [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
784 "box_boolean" >>boxer
785 "to_boolean" >>unboxer
786 bool define-primitive-type
787 ] with-compilation-unit