]> gitweb.factorcode.org Git - factor.git/blob - basis/cpu/ppc/ppc.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / cpu / ppc / ppc.factor
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 ;
11 FROM: cpu.ppc.assembler => B ;
12 IN: cpu.ppc
13
14 ! PowerPC register assignments:
15 ! r2-r12: integer vregs
16 ! r15-r29
17 ! r30: integer scratch
18 ! f0-f29: float vregs
19 ! f30: float scratch
20
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 ;
24
25 enable-float-intrinsics
26
27 <<
28 \ ##integer>float t frame-required? set-word-prop
29 \ ##float>integer t frame-required? set-word-prop
30 >>
31
32 M: ppc machine-registers
33     {
34         { int-regs $[ 2 12 [a,b] 15 29 [a,b] append ] }
35         { float-regs $[ 0 29 [a,b] ] }
36     } ;
37
38 CONSTANT: scratch-reg 30
39 CONSTANT: fp-scratch-reg 30
40
41 M: ppc two-operand? f ;
42
43 M: ppc %load-immediate ( reg n -- ) swap LOAD ;
44
45 M: ppc %load-reference ( reg obj -- )
46     [ 0 swap LOAD32 ] [ rc-absolute-ppc-2/2 rel-immediate ] bi* ;
47
48 M: ppc %alien-global ( register symbol dll -- )
49     [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ;
50
51 CONSTANT: ds-reg 13
52 CONSTANT: rs-reg 14
53
54 GENERIC: loc-reg ( loc -- reg )
55
56 M: ds-loc loc-reg drop ds-reg ;
57 M: rs-loc loc-reg drop rs-reg ;
58
59 : loc>operand ( loc -- reg n )
60     [ loc-reg ] [ n>> cells neg ] bi ; inline
61
62 M: ppc %peek loc>operand LWZ ;
63 M: ppc %replace loc>operand STW ;
64
65 : (%inc) ( n reg -- ) dup rot cells ADDI ; inline
66
67 M: ppc %inc-d ( n -- ) ds-reg (%inc) ;
68 M: ppc %inc-r ( n -- ) rs-reg (%inc) ;
69
70 HOOK: reserved-area-size os ( -- n )
71
72 ! The start of the stack frame contains the size of this frame
73 ! as well as the currently executing XT
74 : factor-area-size ( -- n ) 2 cells ; foldable
75 : next-save ( n -- i ) cell - ;
76 : xt-save ( n -- i ) 2 cells - ;
77
78 ! Next, we have the spill area as well as the FFI parameter area.
79 ! It is safe for them to overlap, since basic blocks with FFI calls
80 ! will never spill -- indeed, basic blocks with FFI calls do not
81 ! use vregs at all, and the FFI call is a stack analysis sync point.
82 ! In the future this will change and the stack frame logic will
83 ! need to be untangled somewhat.
84
85 : param@ ( n -- x ) reserved-area-size + ; inline
86
87 : param-save-size ( -- n ) 8 cells ; foldable
88
89 : local@ ( n -- x )
90     reserved-area-size param-save-size + + ; inline
91
92 : spill@ ( n -- offset )
93     spill-offset local@ ;
94
95 ! Some FP intrinsics need a temporary scratch area in the stack
96 ! frame, 8 bytes in size. This is in the param-save area so it
97 ! does not overlap with spill slots.
98 : scratch@ ( n -- offset )
99     stack-frame get total-size>>
100     factor-area-size -
101     param-save-size -
102     + ;
103
104 ! GC root area
105 : gc-root@ ( n -- offset )
106     gc-root-offset local@ ;
107
108 ! Finally we have the linkage area
109 HOOK: lr-save os ( -- n )
110
111 M: ppc stack-frame-size ( stack-frame -- i )
112     (stack-frame-size)
113     param-save-size +
114     reserved-area-size +
115     factor-area-size +
116     4 cells align ;
117
118 M: ppc %call ( word -- ) 0 BL rc-relative-ppc-3 rel-word-pic ;
119
120 M: ppc %jump ( word -- )
121     0 6 LOAD32 8 rc-absolute-ppc-2/2 rel-here
122     0 B rc-relative-ppc-3 rel-word-pic-tail ;
123
124 M: ppc %jump-label ( label -- ) B ;
125 M: ppc %return ( -- ) BLR ;
126
127 M:: ppc %dispatch ( src temp -- )
128     0 temp LOAD32
129     4 cells rc-absolute-ppc-2/2 rel-here
130     temp temp src LWZX
131     temp MTCTR
132     BCTR ;
133
134 :: (%slot) ( obj slot tag temp -- reg offset )
135     temp slot obj ADD
136     temp tag neg ; inline
137
138 : (%slot-imm) ( obj slot tag -- reg offset )
139     [ cells ] dip - ; inline
140
141 M: ppc %slot ( dst obj slot tag temp -- ) (%slot) LWZ ;
142 M: ppc %slot-imm ( dst obj slot tag -- ) (%slot-imm) LWZ ;
143 M: ppc %set-slot ( src obj slot tag temp -- ) (%slot) STW ;
144 M: ppc %set-slot-imm ( src obj slot tag -- ) (%slot-imm) STW ;
145
146 M:: ppc %string-nth ( dst src index temp -- )
147     [
148         "end" define-label
149         temp src index ADD
150         dst temp string-offset LBZ
151         0 dst HEX: 80 CMPI
152         "end" get BLT
153         temp src string-aux-offset LWZ
154         temp temp index ADD
155         temp temp index ADD
156         temp temp byte-array-offset LHZ
157         temp temp 7 SLWI
158         dst dst temp XOR
159         "end" resolve-label
160     ] with-scope ;
161
162 M:: ppc %set-string-nth-fast ( ch obj index temp -- )
163     temp obj index ADD
164     ch temp string-offset STB ;
165
166 M: ppc %add     ADD ;
167 M: ppc %add-imm ADDI ;
168 M: ppc %sub     swap SUBF ;
169 M: ppc %sub-imm SUBI ;
170 M: ppc %mul     MULLW ;
171 M: ppc %mul-imm MULLI ;
172 M: ppc %and     AND ;
173 M: ppc %and-imm ANDI ;
174 M: ppc %or      OR ;
175 M: ppc %or-imm  ORI ;
176 M: ppc %xor     XOR ;
177 M: ppc %xor-imm XORI ;
178 M: ppc %shl     SLW ;
179 M: ppc %shl-imm swapd SLWI ;
180 M: ppc %shr     SRW ;
181 M: ppc %shr-imm swapd SRWI ;
182 M: ppc %sar     SRAW ;
183 M: ppc %sar-imm SRAWI ;
184 M: ppc %not     NOT ;
185
186 :: overflow-template ( label dst src1 src2 insn -- )
187     0 0 LI
188     0 MTXER
189     dst src2 src1 insn call
190     label BO ; inline
191
192 M: ppc %fixnum-add ( label dst src1 src2 -- )
193     [ ADDO. ] overflow-template ;
194
195 M: ppc %fixnum-sub ( label dst src1 src2 -- )
196     [ SUBFO. ] overflow-template ;
197
198 M: ppc %fixnum-mul ( label dst src1 src2 -- )
199     [ MULLWO. ] overflow-template ;
200
201 : bignum@ ( n -- offset ) cells bignum tag-number - ; inline
202
203 M:: ppc %integer>bignum ( dst src temp -- )
204     [
205         "end" define-label
206         dst 0 >bignum %load-reference
207         ! Is it zero? Then just go to the end and return this zero
208         0 src 0 CMPI
209         "end" get BEQ
210         ! Allocate a bignum
211         dst 4 cells bignum temp %allot
212         ! Write length
213         2 tag-fixnum temp LI
214         temp dst 1 bignum@ STW
215         ! Compute sign
216         temp src MR
217         temp temp cell-bits 1 - SRAWI
218         temp temp 1 ANDI
219         ! Store sign
220         temp dst 2 bignum@ STW
221         ! Make negative value positive
222         temp temp temp ADD
223         temp temp NEG
224         temp temp 1 ADDI
225         temp src temp MULLW
226         ! Store the bignum
227         temp dst 3 bignum@ STW
228         "end" resolve-label
229     ] with-scope ;
230
231 M:: ppc %bignum>integer ( dst src temp -- )
232     [
233         "end" define-label
234         temp src 1 bignum@ LWZ
235         ! if the length is 1, its just the sign and nothing else,
236         ! so output 0
237         0 dst LI
238         0 temp 1 tag-fixnum CMPI
239         "end" get BEQ
240         ! load the value
241         dst src 3 bignum@ LWZ
242         ! load the sign
243         temp src 2 bignum@ LWZ
244         ! branchless arithmetic: we want to turn 0 into 1,
245         ! and 1 into -1
246         temp temp temp ADD
247         temp temp 1 SUBI
248         temp temp NEG
249         ! multiply value by sign
250         dst dst temp MULLW
251         "end" resolve-label
252     ] with-scope ;
253
254 M: ppc %add-float FADD ;
255 M: ppc %sub-float FSUB ;
256 M: ppc %mul-float FMUL ;
257 M: ppc %div-float FDIV ;
258
259 M:: ppc %integer>float ( dst src -- )
260     HEX: 4330 scratch-reg LIS
261     scratch-reg 1 0 scratch@ STW
262     scratch-reg src MR
263     scratch-reg dup HEX: 8000 XORIS
264     scratch-reg 1 4 scratch@ STW
265     dst 1 0 scratch@ LFD
266     scratch-reg 4503601774854144.0 %load-reference
267     fp-scratch-reg scratch-reg float-offset LFD
268     dst dst fp-scratch-reg FSUB ;
269
270 M:: ppc %float>integer ( dst src -- )
271     fp-scratch-reg src FCTIWZ
272     fp-scratch-reg 1 0 scratch@ STFD
273     dst 1 4 scratch@ LWZ ;
274
275 M: ppc %copy ( dst src rep -- )
276     {
277         { int-rep [ MR ] }
278         { double-float-rep [ FMR ] }
279     } case ;
280
281 M: ppc %unbox-float ( dst src -- ) float-offset LFD ;
282
283 M:: ppc %box-float ( dst src temp -- )
284     dst 16 float temp %allot
285     src dst float-offset STFD ;
286
287 M:: ppc %unbox-any-c-ptr ( dst src temp -- )
288     [
289         { "is-byte-array" "end" "start" } [ define-label ] each
290         ! Address is computed in dst
291         0 dst LI
292         ! Load object into scratch-reg
293         scratch-reg src MR
294         ! We come back here with displaced aliens
295         "start" resolve-label
296         ! Is the object f?
297         0 scratch-reg \ f tag-number CMPI
298         ! If so, done
299         "end" get BEQ
300         ! Is the object an alien?
301         0 scratch-reg header-offset LWZ
302         0 0 alien type-number tag-fixnum CMPI
303         "is-byte-array" get BNE
304         ! If so, load the offset
305         0 scratch-reg alien-offset LWZ
306         ! Add it to address being computed
307         dst dst 0 ADD
308         ! Now recurse on the underlying alien
309         scratch-reg scratch-reg underlying-alien-offset LWZ
310         "start" get B
311         "is-byte-array" resolve-label
312         ! Add byte array address to address being computed
313         dst dst scratch-reg ADD
314         ! Add an offset to start of byte array's data area
315         dst dst byte-array-offset ADDI
316         "end" resolve-label
317     ] with-scope ;
318
319 : alien@ ( n -- n' ) cells object tag-number - ;
320
321 M:: ppc %box-alien ( dst src temp -- )
322     [
323         "f" define-label
324         dst \ f tag-number %load-immediate
325         0 src 0 CMPI
326         "f" get BEQ
327         dst 4 cells alien temp %allot
328         ! Store offset
329         src dst 3 alien@ STW
330         ! Store expired slot
331         temp \ f tag-number %load-immediate
332         temp dst 1 alien@ STW
333         ! Store underlying-alien slot
334         temp dst 2 alien@ STW
335         "f" resolve-label
336     ] with-scope ;
337
338 M: ppc %alien-unsigned-1 0 LBZ ;
339 M: ppc %alien-unsigned-2 0 LHZ ;
340
341 M: ppc %alien-signed-1 dupd 0 LBZ dup EXTSB ;
342 M: ppc %alien-signed-2 0 LHA ;
343
344 M: ppc %alien-cell 0 LWZ ;
345
346 M: ppc %alien-float 0 LFS ;
347 M: ppc %alien-double 0 LFD ;
348
349 M: ppc %set-alien-integer-1 swap 0 STB ;
350 M: ppc %set-alien-integer-2 swap 0 STH ;
351
352 M: ppc %set-alien-cell swap 0 STW ;
353
354 M: ppc %set-alien-float swap 0 STFS ;
355 M: ppc %set-alien-double swap 0 STFD ;
356
357 : load-zone-ptr ( reg -- )
358     "nursery" f %alien-global ;
359
360 : load-allot-ptr ( nursery-ptr allot-ptr -- )
361     [ drop load-zone-ptr ] [ swap 4 LWZ ] 2bi ;
362
363 :: inc-allot-ptr ( nursery-ptr allot-ptr n -- )
364     scratch-reg allot-ptr n 8 align ADDI
365     scratch-reg nursery-ptr 4 STW ;
366
367 :: store-header ( dst class -- )
368     class type-number tag-fixnum scratch-reg LI
369     scratch-reg dst 0 STW ;
370
371 : store-tagged ( dst tag -- )
372     dupd tag-number ORI ;
373
374 M:: ppc %allot ( dst size class nursery-ptr -- )
375     nursery-ptr dst load-allot-ptr
376     nursery-ptr dst size inc-allot-ptr
377     dst class store-header
378     dst class store-tagged ;
379
380 : load-cards-offset ( dst -- )
381     [ "cards_offset" f %alien-global ] [ dup 0 LWZ ] bi ;
382
383 : load-decks-offset ( dst -- )
384     [ "decks_offset" f %alien-global ] [ dup 0 LWZ ] bi  ;
385
386 M:: ppc %write-barrier ( src card# table -- )
387     card-mark scratch-reg LI
388
389     ! Mark the card
390     table load-cards-offset
391     src card# card-bits SRWI
392     table scratch-reg card# STBX
393
394     ! Mark the card deck
395     table load-decks-offset
396     src card# deck-bits SRWI
397     table scratch-reg card# STBX ;
398
399 M:: ppc %check-nursery ( label temp1 temp2 -- )
400     temp2 load-zone-ptr
401     temp1 temp2 cell LWZ
402     temp2 temp2 3 cells LWZ
403     ! add ALLOT_BUFFER_ZONE to here
404     temp1 temp1 1024 ADDI
405     ! is here >= end?
406     temp1 0 temp2 CMP
407     label BLE ;
408
409 M:: ppc %save-gc-root ( gc-root register -- )
410     register 1 gc-root gc-root@ STW ;
411
412 M:: ppc %load-gc-root ( gc-root register -- )
413     register 1 gc-root gc-root@ LWZ ;
414
415 M:: ppc %call-gc ( gc-root-count -- )
416     %prepare-alien-invoke
417     3 1 gc-root-base local@ ADDI
418     gc-root-count 4 LI
419     "inline_gc" f %alien-invoke ;
420
421 M: ppc %prologue ( n -- )
422     0 11 LOAD32 rc-absolute-ppc-2/2 rel-this
423     0 MFLR
424     {
425         [ [ 1 1 ] dip neg ADDI ]
426         [ [ 11 1 ] dip xt-save STW ]
427         [ 11 LI ]
428         [ [ 11 1 ] dip next-save STW ]
429         [ [ 0 1 ] dip lr-save + STW ]
430     } cleave ;
431
432 M: ppc %epilogue ( n -- )
433     #! At the end of each word that calls a subroutine, we store
434     #! the previous link register value in r0 by popping it off
435     #! the stack, set the link register to the contents of r0,
436     #! and jump to the link register.
437     [ [ 0 1 ] dip lr-save + LWZ ]
438     [ [ 1 1 ] dip ADDI ] bi
439     0 MTLR ;
440
441 :: (%boolean) ( dst temp word -- )
442     "end" define-label
443     dst \ f tag-number %load-immediate
444     "end" get word execute
445     dst \ t %load-reference
446     "end" get resolve-label ; inline
447
448 : %boolean ( dst temp cc -- )
449     negate-cc {
450         { cc< [ \ BLT (%boolean) ] }
451         { cc<= [ \ BLE (%boolean) ] }
452         { cc> [ \ BGT (%boolean) ] }
453         { cc>= [ \ BGE (%boolean) ] }
454         { cc= [ \ BEQ (%boolean) ] }
455         { cc/= [ \ BNE (%boolean) ] }
456     } case ;
457
458 : (%compare) ( src1 src2 -- ) [ 0 ] dip CMP ; inline
459 : (%compare-imm) ( src1 src2 -- ) [ 0 ] 2dip CMPI ; inline
460 : (%compare-float) ( src1 src2 -- ) [ 0 ] dip FCMPU ; inline
461
462 M: ppc %compare (%compare) %boolean ;
463 M: ppc %compare-imm (%compare-imm) %boolean ;
464 M: ppc %compare-float (%compare-float) %boolean ;
465
466 : %branch ( label cc -- )
467     {
468         { cc< [ BLT ] }
469         { cc<= [ BLE ] }
470         { cc> [ BGT ] }
471         { cc>= [ BGE ] }
472         { cc= [ BEQ ] }
473         { cc/= [ BNE ] }
474     } case ;
475
476 M: ppc %compare-branch (%compare) %branch ;
477 M: ppc %compare-imm-branch (%compare-imm) %branch ;
478 M: ppc %compare-float-branch (%compare-float) %branch ;
479
480 : load-from-frame ( dst n rep -- )
481     {
482         { int-rep [ [ 1 ] dip LWZ ] }
483         { single-float-rep [ [ 1 ] dip LFS ] }
484         { double-float-rep [ [ 1 ] dip LFD ] }
485         { stack-params [ [ 0 1 ] dip LWZ [ 0 1 ] dip param@ STW ] }
486     } case ;
487
488 : next-param@ ( n -- x ) param@ stack-frame get total-size>> + ;
489
490 : store-to-frame ( src n rep -- )
491     {
492         { int-rep [ [ 1 ] dip STW ] }
493         { single-float-rep [ [ 1 ] dip STFS ] }
494         { double-float-rep [ [ 1 ] dip STFD ] }
495         { stack-params [ [ [ 0 1 ] dip next-param@ LWZ 0 1 ] dip STW ] }
496     } case ;
497
498 M: ppc %spill ( src n rep -- )
499     [ spill@ ] dip store-to-frame ;
500
501 M: ppc %reload ( dst n rep -- )
502     [ spill@ ] dip load-from-frame ;
503
504 M: ppc %loop-entry ;
505
506 M: int-regs return-reg drop 3 ;
507 M: int-regs param-regs drop { 3 4 5 6 7 8 9 10 } ;
508 M: float-regs return-reg drop 1 ;
509
510 M:: ppc %save-param-reg ( stack reg rep -- )
511     reg stack local@ rep store-to-frame ;
512
513 M:: ppc %load-param-reg ( stack reg rep -- )
514     reg stack local@ rep load-from-frame ;
515
516 M: ppc %prepare-unbox ( -- )
517     ! First parameter is top of stack
518     3 ds-reg 0 LWZ
519     ds-reg dup cell SUBI ;
520
521 M: ppc %unbox ( n rep func -- )
522     ! Value must be in r3
523     ! Call the unboxer
524     f %alien-invoke
525     ! Store the return value on the C stack
526     over [ [ reg-class-of return-reg ] keep %save-param-reg ] [ 2drop ] if ;
527
528 M: ppc %unbox-long-long ( n func -- )
529     ! Value must be in r3:r4
530     ! Call the unboxer
531     f %alien-invoke
532     ! Store the return value on the C stack
533     [
534         [ [ 3 1 ] dip local@ STW ]
535         [ [ 4 1 ] dip cell + local@ STW ] bi
536     ] when* ;
537
538 M: ppc %unbox-large-struct ( n c-type -- )
539     ! Value must be in r3
540     ! Compute destination address and load struct size
541     [ [ 4 1 ] dip local@ ADDI ] [ heap-size 5 LI ] bi*
542     ! Call the function
543     "to_value_struct" f %alien-invoke ;
544
545 M: ppc %box ( n rep func -- )
546     ! If the source is a stack location, load it into freg #0.
547     ! If the source is f, then we assume the value is already in
548     ! freg #0.
549     [ over [ 0 over reg-class-of param-reg swap %load-param-reg ] [ 2drop ] if ] dip
550     f %alien-invoke ;
551
552 M: ppc %box-long-long ( n func -- )
553     [
554         [
555             [ [ 3 1 ] dip local@ LWZ ]
556             [ [ 4 1 ] dip cell + local@ LWZ ] bi
557         ] when*
558     ] dip f %alien-invoke ;
559
560 : struct-return@ ( n -- n )
561     [ stack-frame get params>> ] unless* local@ ;
562
563 M: ppc %prepare-box-struct ( -- )
564     #! Compute target address for value struct return
565     3 1 f struct-return@ ADDI
566     3 1 0 local@ STW ;
567
568 M: ppc %box-large-struct ( n c-type -- )
569     ! If n = f, then we're boxing a returned struct
570     ! Compute destination address and load struct size
571     [ [ 3 1 ] dip struct-return@ ADDI ] [ heap-size 4 LI ] bi*
572     ! Call the function
573     "box_value_struct" f %alien-invoke ;
574
575 M: ppc %prepare-alien-invoke
576     #! Save Factor stack pointers in case the C code calls a
577     #! callback which does a GC, which must reliably trace
578     #! all roots.
579     scratch-reg "stack_chain" f %alien-global
580     scratch-reg scratch-reg 0 LWZ
581     1 scratch-reg 0 STW
582     ds-reg scratch-reg 8 STW
583     rs-reg scratch-reg 12 STW ;
584
585 M: ppc %alien-invoke ( symbol dll -- )
586     [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
587
588 M: ppc %alien-callback ( quot -- )
589     3 swap %load-reference "c_to_factor" f %alien-invoke ;
590
591 M: ppc %prepare-alien-indirect ( -- )
592     "unbox_alien" f %alien-invoke
593     15 3 MR ;
594
595 M: ppc %alien-indirect ( -- )
596     15 MTLR BLRL ;
597
598 M: ppc %callback-value ( ctype -- )
599     ! Save top of data stack
600     3 ds-reg 0 LWZ
601     3 1 0 local@ STW
602     ! Restore data/call/retain stacks
603     "unnest_stacks" f %alien-invoke
604     ! Restore top of data stack
605     3 1 0 local@ LWZ
606     ! Unbox former top of data stack to return registers
607     unbox-return ;
608
609 M: ppc small-enough? ( n -- ? ) -32768 32767 between? ;
610
611 M: ppc return-struct-in-registers? ( c-type -- ? )
612     c-type return-in-registers?>> ;
613
614 M: ppc %box-small-struct ( c-type -- )
615     #! Box a <= 16-byte struct returned in r3:r4:r5:r6
616     heap-size 7 LI
617     "box_medium_struct" f %alien-invoke ;
618
619 : %unbox-struct-1 ( -- )
620     ! Alien must be in r3.
621     "alien_offset" f %alien-invoke
622     3 3 0 LWZ ;
623
624 : %unbox-struct-2 ( -- )
625     ! Alien must be in r3.
626     "alien_offset" f %alien-invoke
627     4 3 4 LWZ
628     3 3 0 LWZ ;
629
630 : %unbox-struct-4 ( -- )
631     ! Alien must be in r3.
632     "alien_offset" f %alien-invoke
633     6 3 12 LWZ
634     5 3 8 LWZ
635     4 3 4 LWZ
636     3 3 0 LWZ ;
637
638 M: ppc %unbox-small-struct ( size -- )
639     #! Alien must be in EAX.
640     heap-size cell align cell /i {
641         { 1 [ %unbox-struct-1 ] }
642         { 2 [ %unbox-struct-2 ] }
643         { 4 [ %unbox-struct-4 ] }
644     } case ;
645
646 USE: vocabs.loader
647
648 {
649     { [ os macosx? ] [ "cpu.ppc.macosx" require ] }
650     { [ os linux? ] [ "cpu.ppc.linux" require ] }
651 } cond
652
653 "complex-double" c-type t >>return-in-registers? drop
654
655 [
656     <c-type>
657         [ alien-unsigned-4 c-bool> ] >>getter
658         [ [ >c-bool ] 2dip set-alien-unsigned-4 ] >>setter
659         4 >>size
660         4 >>align
661         "box_boolean" >>boxer
662         "to_boolean" >>unboxer
663     "bool" define-primitive-type
664 ] with-compilation-unit