1 ! Copyright (C) 2005, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs alien alien.c-types arrays strings
4 cpu.x86.assembler cpu.x86.assembler.private cpu.x86.assembler.operands
5 cpu.x86.features cpu.x86.features.private cpu.architecture kernel
6 kernel.private math memory namespaces make sequences words system
7 layouts combinators math.order fry locals compiler.constants
8 byte-arrays io macros quotations compiler compiler.units init vm
10 compiler.cfg.instructions
11 compiler.cfg.intrinsics
12 compiler.cfg.comparisons
13 compiler.cfg.stack-frame
14 compiler.codegen.fixup ;
15 FROM: layouts => cell ;
19 ! Add some methods to the assembler to be more useful to the backend
20 M: label JMP 0 JMP rc-relative label-fixup ;
21 M: label JUMPcc [ 0 ] dip JUMPcc rc-relative label-fixup ;
23 M: x86 vector-regs float-regs ;
25 HOOK: stack-reg cpu ( -- reg )
27 HOOK: reserved-stack-space cpu ( -- n )
29 HOOK: extra-stack-space cpu ( stack-frame -- n )
31 : stack@ ( n -- op ) stack-reg swap [+] ;
33 : special@ ( n -- op )
34 stack-frame get extra-stack-space +
35 reserved-stack-space +
38 : spill@ ( n -- op ) spill-offset special@ ;
40 : gc-root@ ( n -- op ) gc-root-offset special@ ;
42 : decr-stack-reg ( n -- )
43 dup 0 = [ drop ] [ stack-reg swap SUB ] if ;
45 : incr-stack-reg ( n -- )
46 dup 0 = [ drop ] [ stack-reg swap ADD ] if ;
48 : align-stack ( n -- n' )
49 os macosx? cpu x86.64? or [ 16 align ] when ;
51 M: x86 stack-frame-size ( stack-frame -- i )
52 [ (stack-frame-size) ]
53 [ extra-stack-space ] bi +
54 reserved-stack-space +
58 ! Must be a volatile register not used for parameter passing, for safe
59 ! use in calls in and out of C
60 HOOK: temp-reg cpu ( -- reg )
62 HOOK: pic-tail-reg cpu ( -- reg )
64 M: x86 %load-immediate dup 0 = [ drop dup XOR ] [ MOV ] if ;
66 M: x86 %load-reference swap 0 MOV rc-absolute-cell rel-immediate ;
68 HOOK: ds-reg cpu ( -- reg )
69 HOOK: rs-reg cpu ( -- reg )
71 : reg-stack ( n reg -- op ) swap cells neg [+] ;
73 GENERIC: loc>operand ( loc -- operand )
75 M: ds-loc loc>operand n>> ds-reg reg-stack ;
76 M: rs-loc loc>operand n>> rs-reg reg-stack ;
78 M: x86 %peek loc>operand MOV ;
79 M: x86 %replace loc>operand swap MOV ;
80 : (%inc) ( n reg -- ) swap cells dup 0 > [ ADD ] [ neg SUB ] if ; inline
81 M: x86 %inc-d ( n -- ) ds-reg (%inc) ;
82 M: x86 %inc-r ( n -- ) rs-reg (%inc) ;
84 M: x86 %call ( word -- ) 0 CALL rc-relative rel-word-pic ;
86 : xt-tail-pic-offset ( -- n )
87 #! See the comment in vm/cpu-x86.hpp
90 M: x86 %jump ( word -- )
91 pic-tail-reg 0 MOV xt-tail-pic-offset rc-absolute-cell rel-here
92 0 JMP rc-relative rel-word-pic-tail ;
94 M: x86 %jump-label ( label -- ) 0 JMP rc-relative label-fixup ;
96 M: x86 %return ( -- ) 0 RET ;
98 : code-alignment ( align -- n )
99 [ building get length dup ] dip align swap - ;
101 : align-code ( n -- )
104 :: (%slot-imm) ( obj slot tag -- op )
105 obj slot tag slot-offset [+] ; inline
107 M: x86 %slot ( dst obj slot -- ) [+] MOV ;
108 M: x86 %slot-imm ( dst obj slot tag -- ) (%slot-imm) MOV ;
109 M: x86 %set-slot ( src obj slot -- ) [+] swap MOV ;
110 M: x86 %set-slot-imm ( src obj slot tag -- ) (%slot-imm) swap MOV ;
112 :: two-operand ( dst src1 src2 rep -- dst src )
113 dst src2 eq? dst src1 eq? not and [ "Cannot handle this case" throw ] when
117 :: one-operand ( dst src rep -- dst )
121 M: x86 %add 2over eq? [ nip ADD ] [ [+] LEA ] if ;
122 M: x86 %add-imm 2over eq? [ nip ADD ] [ [+] LEA ] if ;
123 M: x86 %sub int-rep two-operand SUB ;
124 M: x86 %sub-imm 2over eq? [ nip SUB ] [ neg [+] LEA ] if ;
125 M: x86 %mul int-rep two-operand swap IMUL2 ;
126 M: x86 %mul-imm IMUL3 ;
127 M: x86 %and int-rep two-operand AND ;
128 M: x86 %and-imm int-rep two-operand AND ;
129 M: x86 %or int-rep two-operand OR ;
130 M: x86 %or-imm int-rep two-operand OR ;
131 M: x86 %xor int-rep two-operand XOR ;
132 M: x86 %xor-imm int-rep two-operand XOR ;
133 M: x86 %shl-imm int-rep two-operand SHL ;
134 M: x86 %shr-imm int-rep two-operand SHR ;
135 M: x86 %sar-imm int-rep two-operand SAR ;
137 M: x86 %min int-rep two-operand [ CMP ] [ CMOVG ] 2bi ;
138 M: x86 %max int-rep two-operand [ CMP ] [ CMOVL ] 2bi ;
140 M: x86 %not int-rep one-operand NOT ;
141 M: x86 %neg int-rep one-operand NEG ;
144 GENERIC: copy-register* ( dst src rep -- )
146 M: int-rep copy-register* drop MOV ;
147 M: tagged-rep copy-register* drop MOV ;
148 M: float-rep copy-register* drop MOVSS ;
149 M: double-rep copy-register* drop MOVSD ;
150 M: float-4-rep copy-register* drop MOVUPS ;
151 M: double-2-rep copy-register* drop MOVUPD ;
152 M: vector-rep copy-register* drop MOVDQU ;
154 M: x86 %copy ( dst src rep -- )
155 2over eq? [ 3drop ] [
156 [ [ dup spill-slot? [ n>> spill@ ] when ] bi@ ] dip
160 M: x86 %fixnum-add ( label dst src1 src2 -- )
161 int-rep two-operand ADD JO ;
163 M: x86 %fixnum-sub ( label dst src1 src2 -- )
164 int-rep two-operand SUB JO ;
166 M: x86 %fixnum-mul ( label dst src1 src2 -- )
167 int-rep two-operand swap IMUL2 JO ;
169 M: x86 %unbox-alien ( dst src -- )
170 alien-offset [+] MOV ;
172 M:: x86 %unbox-any-c-ptr ( dst src temp -- )
174 { "is-byte-array" "end" "start" } [ define-label ] each
177 ! We come back here with displaced aliens
178 "start" resolve-label
180 temp \ f tag-number CMP
182 ! Is the object an alien?
183 temp header-offset [+] alien type-number tag-fixnum CMP
184 "is-byte-array" get JNE
185 ! If so, load the offset and add it to the address
186 dst temp alien-offset [+] ADD
187 ! Now recurse on the underlying alien
188 temp temp underlying-alien-offset [+] MOV
190 "is-byte-array" resolve-label
191 ! Add byte array address to address being computed
193 ! Add an offset to start of byte array's data
194 dst byte-array-offset ADD
198 : alien@ ( reg n -- op ) cells alien tag-number - [+] ;
200 :: %allot-alien ( dst displacement base temp -- )
201 dst 4 cells alien temp %allot
202 dst 1 alien@ base MOV ! alien
203 dst 2 alien@ \ f tag-number MOV ! expired
204 dst 3 alien@ displacement MOV ! displacement
207 M:: x86 %box-alien ( dst src temp -- )
210 dst \ f tag-number MOV
213 dst src \ f tag-number temp %allot-alien
217 M:: x86 %box-displaced-alien ( dst displacement base displacement' base' base-class -- )
221 ! If displacement is zero, return the base
225 ! Quickly use displacement' before its needed for real, as allot temporary
226 dst 4 cells alien displacement' %allot
227 ! If base is already a displaced alien, unpack it
229 displacement' displacement MOV
230 base \ f tag-number CMP
232 base header-offset [+] alien type-number tag-fixnum CMP
234 ! displacement += base.displacement
235 displacement' base 3 alien@ ADD
237 base' base 1 alien@ MOV
239 dst 1 alien@ base' MOV ! alien
240 dst 2 alien@ \ f tag-number MOV ! expired
241 dst 3 alien@ displacement' MOV ! displacement
245 ! The 'small-reg' mess is pretty crappy, but its only used on x86-32.
246 ! On x86-64, all registers have 8-bit versions. However, a similar
247 ! problem arises for shifts, where the shift count must be in CL, and
248 ! so one day I will fix this properly by adding precoloring to the
249 ! register allocator.
251 HOOK: has-small-reg? cpu ( reg size -- ? )
253 CONSTANT: have-byte-regs { EAX ECX EDX EBX }
255 M: x86.32 has-small-reg?
257 { 8 [ have-byte-regs memq? ] }
262 M: x86.64 has-small-reg? 2drop t ;
264 : small-reg-that-isn't ( exclude -- reg' )
265 [ have-byte-regs ] dip
266 [ native-version-of ] map
267 '[ _ memq? not ] find nip ;
269 : with-save/restore ( reg quot -- )
270 [ drop PUSH ] [ call ] [ drop POP ] 2tri ; inline
272 :: with-small-register ( dst exclude size quot: ( new-dst -- ) -- )
273 ! If the destination register overlaps a small register with
274 ! 'size' bits, we call the quot with that. Otherwise, we find a
275 ! small register that is not in exclude, and call quot, saving and
276 ! restoring the small register.
277 dst size has-small-reg? [ dst quot call ] [
278 exclude small-reg-that-isn't
279 [ quot call ] with-save/restore
282 M:: x86 %string-nth ( dst src index temp -- )
283 ! We request a small-reg of size 8 since those of size 16 are
286 dst { src index temp } 8 [| new-dst |
287 ! Load the least significant 7 bits into new-dst.
288 ! 8th bit indicates whether we have to load from
289 ! the aux vector or not.
290 temp src index [+] LEA
291 new-dst 8-bit-version-of temp string-offset [+] MOV
292 new-dst new-dst 8-bit-version-of MOVZX
293 ! Do we have to look at the aux vector?
296 ! Yes, this is a non-ASCII character. Load aux vector
297 temp src string-aux-offset [+] MOV
303 new-dst 16-bit-version-of new-dst byte-array-offset [+] MOV
304 new-dst new-dst 16-bit-version-of MOVZX
309 dst new-dst int-rep %copy
310 ] with-small-register ;
312 M:: x86 %set-string-nth-fast ( ch str index temp -- )
313 ch { index str temp } 8 [| new-ch |
314 new-ch ch int-rep %copy
315 temp str index [+] LEA
316 temp string-offset [+] new-ch 8-bit-version-of MOV
317 ] with-small-register ;
319 :: %alien-integer-getter ( dst src offset size quot -- )
320 dst { src } size [| new-dst |
321 new-dst dup size n-bit-version-of dup src offset [+] MOV
323 dst new-dst int-rep %copy
324 ] with-small-register ; inline
326 : %alien-unsigned-getter ( dst src offset size -- )
327 [ MOVZX ] %alien-integer-getter ; inline
329 : %alien-signed-getter ( dst src offset size -- )
330 [ MOVSX ] %alien-integer-getter ; inline
332 :: %alien-integer-setter ( ptr offset value size -- )
333 value { ptr } size [| new-value |
334 new-value value int-rep %copy
335 ptr offset [+] new-value size n-bit-version-of MOV
336 ] with-small-register ; inline
338 M: x86 %alien-unsigned-1 8 %alien-unsigned-getter ;
339 M: x86 %alien-unsigned-2 16 %alien-unsigned-getter ;
340 M: x86 %alien-unsigned-4 32 [ 2drop ] %alien-integer-getter ;
342 M: x86 %alien-signed-1 8 %alien-signed-getter ;
343 M: x86 %alien-signed-2 16 %alien-signed-getter ;
344 M: x86 %alien-signed-4 32 %alien-signed-getter ;
346 M: x86 %alien-cell [+] MOV ;
347 M: x86 %alien-float [+] MOVSS ;
348 M: x86 %alien-double [+] MOVSD ;
349 M: x86 %alien-vector [ [+] ] dip %copy ;
351 M: x86 %set-alien-integer-1 8 %alien-integer-setter ;
352 M: x86 %set-alien-integer-2 16 %alien-integer-setter ;
353 M: x86 %set-alien-integer-4 32 %alien-integer-setter ;
354 M: x86 %set-alien-cell [ [+] ] dip MOV ;
355 M: x86 %set-alien-float [ [+] ] dip MOVSS ;
356 M: x86 %set-alien-double [ [+] ] dip MOVSD ;
357 M: x86 %set-alien-vector [ [+] ] 2dip %copy ;
359 : shift-count? ( reg -- ? ) { ECX RCX } memq? ;
361 :: emit-shift ( dst src quot -- )
370 ECX native-version-of [
372 drop dst CL quot call
377 M: x86 %shl int-rep two-operand [ SHL ] emit-shift ;
378 M: x86 %shr int-rep two-operand [ SHR ] emit-shift ;
379 M: x86 %sar int-rep two-operand [ SAR ] emit-shift ;
381 : %mov-vm-ptr ( reg -- )
382 0 MOV 0 rc-absolute-cell rel-vm ;
384 M: x86 %vm-field-ptr ( dst field -- )
385 [ 0 MOV ] dip vm-field-offset rc-absolute-cell rel-vm ;
387 : load-allot-ptr ( nursery-ptr allot-ptr -- )
388 [ drop "nursery" %vm-field-ptr ] [ swap [] MOV ] 2bi ;
390 : inc-allot-ptr ( nursery-ptr n -- )
391 [ [] ] dip 8 align ADD ;
393 : store-header ( temp class -- )
394 [ [] ] [ type-number tag-fixnum ] bi* MOV ;
396 : store-tagged ( dst tag -- )
399 M:: x86 %allot ( dst size class nursery-ptr -- )
400 nursery-ptr dst load-allot-ptr
401 dst class store-header
402 dst class store-tagged
403 nursery-ptr size inc-allot-ptr ;
405 HOOK: %mark-card cpu ( card temp -- )
406 HOOK: %mark-deck cpu ( card temp -- )
408 :: (%write-barrier) ( src slot temp1 temp2 -- )
409 temp1 src slot [+] LEA
411 temp1 temp2 %mark-card
412 temp1 deck-bits card-bits - SHR
413 temp1 temp2 %mark-deck ;
415 M: x86 %write-barrier ( src slot temp1 temp2 -- ) (%write-barrier) ;
417 M: x86 %write-barrier-imm ( src slot temp1 temp2 -- ) (%write-barrier) ;
419 M:: x86 %check-nursery ( label size temp1 temp2 -- )
420 temp1 "nursery" %vm-field-ptr
421 ! Load 'here' into temp2
424 ! Load 'end' into temp1
425 temp1 temp1 2 cells [+] MOV
429 M: x86 %save-gc-root ( gc-root register -- ) [ gc-root@ ] dip MOV ;
431 M: x86 %load-gc-root ( gc-root register -- ) swap gc-root@ MOV ;
433 M: x86 %alien-global ( dst symbol library -- )
434 [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
436 M: x86 %epilogue ( n -- ) cell - incr-stack-reg ;
438 :: %boolean ( dst temp word -- )
439 dst \ f tag-number MOV
440 temp 0 MOV \ t rc-absolute-cell rel-immediate
441 dst temp word execute ; inline
443 : (%compare) ( src1 src2 cc -- )
444 2over [ { cc= cc/= } member? ] [ register? ] [ 0 = ] tri* and and
448 M:: x86 %compare ( dst src1 src2 cc temp -- )
449 src1 src2 cc (%compare)
451 { cc< [ dst temp \ CMOVL %boolean ] }
452 { cc<= [ dst temp \ CMOVLE %boolean ] }
453 { cc> [ dst temp \ CMOVG %boolean ] }
454 { cc>= [ dst temp \ CMOVGE %boolean ] }
455 { cc= [ dst temp \ CMOVE %boolean ] }
456 { cc/= [ dst temp \ CMOVNE %boolean ] }
459 M: x86 %compare-imm ( dst src1 src2 cc temp -- )
462 M:: x86 %compare-branch ( label src1 src2 cc -- )
463 src1 src2 cc (%compare)
466 { cc<= [ label JLE ] }
468 { cc>= [ label JGE ] }
470 { cc/= [ label JNE ] }
473 M: x86 %compare-imm-branch ( label src1 src2 cc -- )
476 M: x86 %add-float double-rep two-operand ADDSD ;
477 M: x86 %sub-float double-rep two-operand SUBSD ;
478 M: x86 %mul-float double-rep two-operand MULSD ;
479 M: x86 %div-float double-rep two-operand DIVSD ;
480 M: x86 %min-float double-rep two-operand MINSD ;
481 M: x86 %max-float double-rep two-operand MAXSD ;
482 M: x86 %sqrt SQRTSD ;
484 M: x86 %single>double-float CVTSS2SD ;
485 M: x86 %double>single-float CVTSD2SS ;
487 M: x86 %integer>float CVTSI2SD ;
488 M: x86 %float>integer CVTTSD2SI ;
490 : %cmov-float= ( dst src -- )
492 "no-move" define-label
494 "no-move" get [ JNE ] [ JP ] bi
496 "no-move" resolve-label
499 : %cmov-float/= ( dst src -- )
501 "no-move" define-label
508 "no-move" resolve-label
511 :: (%compare-float) ( dst src1 src2 cc temp compare -- )
513 { cc< [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVA %boolean ] }
514 { cc<= [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVAE %boolean ] }
515 { cc> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVA %boolean ] }
516 { cc>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVAE %boolean ] }
517 { cc= [ src1 src2 \ compare execute( a b -- ) dst temp \ %cmov-float= %boolean ] }
518 { cc<> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVNE %boolean ] }
519 { cc<>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVNP %boolean ] }
520 { cc/< [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVBE %boolean ] }
521 { cc/<= [ src2 src1 \ compare execute( a b -- ) dst temp \ CMOVB %boolean ] }
522 { cc/> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVBE %boolean ] }
523 { cc/>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVB %boolean ] }
524 { cc/= [ src1 src2 \ compare execute( a b -- ) dst temp \ %cmov-float/= %boolean ] }
525 { cc/<> [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVE %boolean ] }
526 { cc/<>= [ src1 src2 \ compare execute( a b -- ) dst temp \ CMOVP %boolean ] }
529 M: x86 %compare-float-ordered ( dst src1 src2 cc temp -- )
530 \ COMISD (%compare-float) ;
532 M: x86 %compare-float-unordered ( dst src1 src2 cc temp -- )
533 \ UCOMISD (%compare-float) ;
535 : %jump-float= ( label -- )
537 "no-jump" define-label
540 "no-jump" resolve-label
543 : %jump-float/= ( label -- )
546 :: (%compare-float-branch) ( label src1 src2 cc compare -- )
548 { cc< [ src2 src1 \ compare execute( a b -- ) label JA ] }
549 { cc<= [ src2 src1 \ compare execute( a b -- ) label JAE ] }
550 { cc> [ src1 src2 \ compare execute( a b -- ) label JA ] }
551 { cc>= [ src1 src2 \ compare execute( a b -- ) label JAE ] }
552 { cc= [ src1 src2 \ compare execute( a b -- ) label %jump-float= ] }
553 { cc<> [ src1 src2 \ compare execute( a b -- ) label JNE ] }
554 { cc<>= [ src1 src2 \ compare execute( a b -- ) label JNP ] }
555 { cc/< [ src2 src1 \ compare execute( a b -- ) label JBE ] }
556 { cc/<= [ src2 src1 \ compare execute( a b -- ) label JB ] }
557 { cc/> [ src1 src2 \ compare execute( a b -- ) label JBE ] }
558 { cc/>= [ src1 src2 \ compare execute( a b -- ) label JB ] }
559 { cc/= [ src1 src2 \ compare execute( a b -- ) label %jump-float/= ] }
560 { cc/<> [ src1 src2 \ compare execute( a b -- ) label JE ] }
561 { cc/<>= [ src1 src2 \ compare execute( a b -- ) label JP ] }
564 M: x86 %compare-float-ordered-branch ( label src1 src2 cc -- )
565 \ COMISD (%compare-float-branch) ;
567 M: x86 %compare-float-unordered-branch ( label src1 src2 cc -- )
568 \ UCOMISD (%compare-float-branch) ;
570 MACRO: available-reps ( alist -- )
571 ! Each SSE version adds new representations and supports
573 unzip { } [ append ] accumulate rest swap suffix
574 [ [ 1quotation ] map ] bi@ zip
575 reverse [ { } ] suffix
578 M: x86 %alien-vector-reps
580 { sse? { float-4-rep } }
581 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
586 { double-2-rep [ dup XORPD ] }
587 { float-4-rep [ dup XORPS ] }
591 M: x86 %zero-vector-reps
593 { sse? { float-4-rep } }
594 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
599 { double-2-rep [ dup [ XORPD ] [ CMPEQPD ] 2bi ] }
600 { float-4-rep [ dup [ XORPS ] [ CMPEQPS ] 2bi ] }
604 M: x86 %fill-vector-reps
606 { sse? { float-4-rep } }
607 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
610 ! M:: x86 %broadcast-vector ( dst src rep -- )
613 ! dst src float-4-rep %copy
614 ! dst dst { 0 0 0 0 } SHUFPS
621 ! [ dst dst PUNPCKLQDQ ]
622 ! [ dst src { 0 1 0 1 } PSHUFD ]
626 ! dst src { 0 0 0 0 } PSHUFD
629 ! dst src { 0 0 0 0 } PSHUFLW
633 ! dst src char-16-rep %copy
635 ! dst dst { 0 0 0 0 } PSHUFLW
640 ! M: x86 %broadcast-vector-reps
642 ! ! Can't do this with sse1 since it will want to unbox
643 ! ! a double-precision float and convert to single precision
644 ! { sse2? { float-4-rep double-2-rep longlong-2-rep ulonglong-2-rep int-4-rep uint-4-rep short-8-rep ushort-8-rep char-16-rep uchar-16-rep } }
647 M:: x86 %gather-vector-4 ( dst src1 src2 src3 src4 rep -- )
650 dst src1 float-4-rep %copy
656 dst src1 int-4-rep %copy
663 M: x86 %gather-vector-4-reps
665 ! Can't do this with sse1 since it will want to unbox
666 ! double-precision floats and convert to single precision
667 { sse2? { float-4-rep int-4-rep uint-4-rep } }
670 M:: x86 %gather-vector-2 ( dst src1 src2 rep -- )
673 dst src1 double-2-rep %copy
677 dst src1 longlong-2-rep %copy
682 M: x86 %gather-vector-2-reps
684 { sse2? { double-2-rep longlong-2-rep ulonglong-2-rep } }
687 : double-2-shuffle ( dst shuffle -- )
690 { { 0 0 } [ dup UNPCKLPD ] }
691 { { 1 1 } [ dup UNPCKHPD ] }
695 : sse1-float-4-shuffle ( dst shuffle -- )
697 { { 0 1 2 3 } [ drop ] }
698 { { 0 1 0 1 } [ dup MOVLHPS ] }
699 { { 2 3 2 3 } [ dup MOVHLPS ] }
700 { { 0 0 1 1 } [ dup UNPCKLPS ] }
701 { { 2 2 3 3 } [ dup UNPCKHPS ] }
705 : float-4-shuffle ( dst shuffle -- )
708 { { 0 0 2 2 } [ dup MOVSLDUP ] }
709 { { 1 1 3 3 } [ dup MOVSHDUP ] }
710 [ sse1-float-4-shuffle ]
712 ] [ sse1-float-4-shuffle ] if ;
714 : int-4-shuffle ( dst shuffle -- )
716 { { 0 1 2 3 } [ drop ] }
717 { { 0 0 1 1 } [ dup PUNPCKLDQ ] }
718 { { 2 2 3 3 } [ dup PUNPCKHDQ ] }
719 { { 0 1 0 1 } [ dup PUNPCKLQDQ ] }
720 { { 2 3 2 3 } [ dup PUNPCKHQDQ ] }
724 : longlong-2-shuffle ( dst shuffle -- )
725 first2 [ 2 * dup 1 + ] bi@ 4array int-4-shuffle ;
727 M:: x86 %shuffle-vector-imm ( dst src shuffle rep -- )
729 dst shuffle rep unsign-rep {
730 { double-2-rep [ double-2-shuffle ] }
731 { float-4-rep [ float-4-shuffle ] }
732 { int-4-rep [ int-4-shuffle ] }
733 { longlong-2-rep [ longlong-2-shuffle ] }
736 M: x86 %shuffle-vector-imm-reps
738 { sse? { float-4-rep } }
739 { sse2? { double-2-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
742 M: x86 %shuffle-vector ( dst src shuffle rep -- )
745 M: x86 %shuffle-vector-reps
747 { ssse3? { float-4-rep double-2-rep longlong-2-rep ulonglong-2-rep int-4-rep uint-4-rep short-8-rep ushort-8-rep char-16-rep uchar-16-rep } }
750 M: x86 %merge-vector-head
753 { double-2-rep [ UNPCKLPD ] }
754 { float-4-rep [ UNPCKLPS ] }
755 { longlong-2-rep [ PUNPCKLQDQ ] }
756 { int-4-rep [ PUNPCKLDQ ] }
757 { short-8-rep [ PUNPCKLWD ] }
758 { char-16-rep [ PUNPCKLBW ] }
761 M: x86 %merge-vector-tail
764 { double-2-rep [ UNPCKHPD ] }
765 { float-4-rep [ UNPCKHPS ] }
766 { longlong-2-rep [ PUNPCKHQDQ ] }
767 { int-4-rep [ PUNPCKHDQ ] }
768 { short-8-rep [ PUNPCKHWD ] }
769 { char-16-rep [ PUNPCKHBW ] }
772 M: x86 %merge-vector-reps
774 { sse? { float-4-rep } }
775 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
778 M: x86 %signed-pack-vector
781 { int-4-rep [ PACKSSDW ] }
782 { short-8-rep [ PACKSSWB ] }
785 M: x86 %signed-pack-vector-reps
787 { sse2? { short-8-rep int-4-rep } }
790 M: x86 %unsigned-pack-vector
793 { int-4-rep [ PACKUSDW ] }
794 { short-8-rep [ PACKUSWB ] }
797 M: x86 %unsigned-pack-vector-reps
799 { sse2? { short-8-rep } }
800 { sse4.1? { int-4-rep } }
803 M: x86 %tail>head-vector ( dst src rep -- )
805 { float-4-rep [ drop MOVHLPS ] }
806 { double-2-rep [ [ %copy ] [ drop UNPCKHPD ] 3bi ] }
807 [ drop [ %copy ] [ drop PUNPCKHQDQ ] 3bi ]
810 M: x86 %unpack-vector-head ( dst src rep -- )
812 { char-16-rep [ PMOVSXBW ] }
813 { uchar-16-rep [ PMOVZXBW ] }
814 { short-8-rep [ PMOVSXWD ] }
815 { ushort-8-rep [ PMOVZXWD ] }
816 { int-4-rep [ PMOVSXDQ ] }
817 { uint-4-rep [ PMOVZXDQ ] }
818 { float-4-rep [ CVTPS2PD ] }
821 M: x86 %unpack-vector-head-reps ( -- reps )
823 { sse2? { float-4-rep } }
824 { sse4.1? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep } }
827 M: x86 %integer>float-vector ( dst src rep -- )
829 { int-4-rep [ CVTDQ2PS ] }
832 M: x86 %integer>float-vector-reps
834 { sse2? { int-4-rep } }
837 M: x86 %float>integer-vector ( dst src rep -- )
839 { float-4-rep [ CVTTPS2DQ ] }
842 M: x86 %float>integer-vector-reps
844 { sse2? { float-4-rep } }
847 : (%compare-float-vector) ( dst src rep double single -- )
848 [ double-2-rep eq? ] 2dip if ; inline
849 : %compare-float-vector ( dst src rep cc -- )
851 { cc< [ [ CMPLTPD ] [ CMPLTPS ] (%compare-float-vector) ] }
852 { cc<= [ [ CMPLEPD ] [ CMPLEPS ] (%compare-float-vector) ] }
853 { cc= [ [ CMPEQPD ] [ CMPEQPS ] (%compare-float-vector) ] }
854 { cc<>= [ [ CMPORDPD ] [ CMPORDPS ] (%compare-float-vector) ] }
855 { cc/< [ [ CMPNLTPD ] [ CMPNLTPS ] (%compare-float-vector) ] }
856 { cc/<= [ [ CMPNLEPD ] [ CMPNLEPS ] (%compare-float-vector) ] }
857 { cc/= [ [ CMPNEQPD ] [ CMPNEQPS ] (%compare-float-vector) ] }
858 { cc/<>= [ [ CMPUNORDPD ] [ CMPUNORDPS ] (%compare-float-vector) ] }
861 :: (%compare-int-vector) ( dst src rep int64 int32 int16 int8 -- )
862 rep unsign-rep :> rep'
864 { longlong-2-rep [ int64 call ] }
865 { int-4-rep [ int32 call ] }
866 { short-8-rep [ int16 call ] }
867 { char-16-rep [ int8 call ] }
869 : %compare-int-vector ( dst src rep cc -- )
871 { cc= [ [ PCMPEQQ ] [ PCMPEQD ] [ PCMPEQW ] [ PCMPEQB ] (%compare-int-vector) ] }
872 { cc> [ [ PCMPGTQ ] [ PCMPGTD ] [ PCMPGTW ] [ PCMPGTB ] (%compare-int-vector) ] }
875 M: x86 %compare-vector ( dst src1 src2 rep cc -- )
876 [ [ two-operand ] keep ] dip
877 over float-vector-rep?
878 [ %compare-float-vector ]
879 [ %compare-int-vector ] if ;
881 : %compare-vector-eq-reps ( -- reps )
883 { sse? { float-4-rep } }
884 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep } }
885 { sse4.1? { longlong-2-rep ulonglong-2-rep } }
887 : %compare-vector-ord-reps ( -- reps )
889 { sse? { float-4-rep } }
890 { sse2? { double-2-rep char-16-rep short-8-rep int-4-rep } }
891 { sse4.2? { longlong-2-rep } }
894 M: x86 %compare-vector-reps
896 { [ dup { cc= cc/= cc/<>= cc<>= } memq? ] [ drop %compare-vector-eq-reps ] }
897 [ drop %compare-vector-ord-reps ]
900 : %compare-float-vector-ccs ( cc -- ccs not? )
902 { cc< [ { { cc< f } } f ] }
903 { cc<= [ { { cc<= f } } f ] }
904 { cc> [ { { cc< t } } f ] }
905 { cc>= [ { { cc<= t } } f ] }
906 { cc= [ { { cc= f } } f ] }
907 { cc<> [ { { cc< f } { cc< t } } f ] }
908 { cc<>= [ { { cc<>= f } } f ] }
909 { cc/< [ { { cc/< f } } f ] }
910 { cc/<= [ { { cc/<= f } } f ] }
911 { cc/> [ { { cc/< t } } f ] }
912 { cc/>= [ { { cc/<= t } } f ] }
913 { cc/= [ { { cc/= f } } f ] }
914 { cc/<> [ { { cc/= f } { cc/<>= f } } f ] }
915 { cc/<>= [ { { cc/<>= f } } f ] }
918 : %compare-int-vector-ccs ( cc -- ccs not? )
920 { cc< [ { { cc> t } } f ] }
921 { cc<= [ { { cc> f } } t ] }
922 { cc> [ { { cc> f } } f ] }
923 { cc>= [ { { cc> t } } t ] }
924 { cc= [ { { cc= f } } f ] }
925 { cc/= [ { { cc= f } } t ] }
930 M: x86 %compare-vector-ccs
931 swap float-vector-rep?
932 [ %compare-float-vector-ccs ]
933 [ %compare-int-vector-ccs ] if ;
935 :: %test-vector-mask ( dst temp mask vcc -- )
937 { vcc-any [ dst dst TEST dst temp \ CMOVNE %boolean ] }
938 { vcc-none [ dst dst TEST dst temp \ CMOVE %boolean ] }
939 { vcc-all [ dst mask CMP dst temp \ CMOVE %boolean ] }
940 { vcc-notall [ dst mask CMP dst temp \ CMOVNE %boolean ] }
943 : %move-vector-mask ( dst src rep -- mask )
945 { double-2-rep [ MOVMSKPD HEX: 3 ] }
946 { float-4-rep [ MOVMSKPS HEX: f ] }
947 [ drop PMOVMSKB HEX: ffff ]
950 M:: x86 %test-vector ( dst src temp rep vcc -- )
951 dst src rep %move-vector-mask :> mask
952 dst temp mask vcc %test-vector-mask ;
954 :: %test-vector-mask-branch ( label temp mask vcc -- )
956 { vcc-any [ temp temp TEST label JNE ] }
957 { vcc-none [ temp temp TEST label JE ] }
958 { vcc-all [ temp mask CMP label JE ] }
959 { vcc-notall [ temp mask CMP label JNE ] }
962 M:: x86 %test-vector-branch ( label src temp rep vcc -- )
963 temp src rep %move-vector-mask :> mask
964 label temp mask vcc %test-vector-mask-branch ;
966 M: x86 %test-vector-reps
968 { sse? { float-4-rep } }
969 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
972 M: x86 %add-vector ( dst src1 src2 rep -- )
975 { float-4-rep [ ADDPS ] }
976 { double-2-rep [ ADDPD ] }
977 { char-16-rep [ PADDB ] }
978 { uchar-16-rep [ PADDB ] }
979 { short-8-rep [ PADDW ] }
980 { ushort-8-rep [ PADDW ] }
981 { int-4-rep [ PADDD ] }
982 { uint-4-rep [ PADDD ] }
983 { longlong-2-rep [ PADDQ ] }
984 { ulonglong-2-rep [ PADDQ ] }
987 M: x86 %add-vector-reps
989 { sse? { float-4-rep } }
990 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
993 M: x86 %saturated-add-vector ( dst src1 src2 rep -- )
996 { char-16-rep [ PADDSB ] }
997 { uchar-16-rep [ PADDUSB ] }
998 { short-8-rep [ PADDSW ] }
999 { ushort-8-rep [ PADDUSW ] }
1002 M: x86 %saturated-add-vector-reps
1004 { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep } }
1007 M: x86 %add-sub-vector ( dst src1 src2 rep -- )
1008 [ two-operand ] keep
1010 { float-4-rep [ ADDSUBPS ] }
1011 { double-2-rep [ ADDSUBPD ] }
1014 M: x86 %add-sub-vector-reps
1016 { sse3? { float-4-rep double-2-rep } }
1019 M: x86 %sub-vector ( dst src1 src2 rep -- )
1020 [ two-operand ] keep
1022 { float-4-rep [ SUBPS ] }
1023 { double-2-rep [ SUBPD ] }
1024 { char-16-rep [ PSUBB ] }
1025 { uchar-16-rep [ PSUBB ] }
1026 { short-8-rep [ PSUBW ] }
1027 { ushort-8-rep [ PSUBW ] }
1028 { int-4-rep [ PSUBD ] }
1029 { uint-4-rep [ PSUBD ] }
1030 { longlong-2-rep [ PSUBQ ] }
1031 { ulonglong-2-rep [ PSUBQ ] }
1034 M: x86 %sub-vector-reps
1036 { sse? { float-4-rep } }
1037 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1040 M: x86 %saturated-sub-vector ( dst src1 src2 rep -- )
1041 [ two-operand ] keep
1043 { char-16-rep [ PSUBSB ] }
1044 { uchar-16-rep [ PSUBUSB ] }
1045 { short-8-rep [ PSUBSW ] }
1046 { ushort-8-rep [ PSUBUSW ] }
1049 M: x86 %saturated-sub-vector-reps
1051 { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep } }
1054 M: x86 %mul-vector ( dst src1 src2 rep -- )
1055 [ two-operand ] keep
1057 { float-4-rep [ MULPS ] }
1058 { double-2-rep [ MULPD ] }
1059 { short-8-rep [ PMULLW ] }
1060 { ushort-8-rep [ PMULLW ] }
1061 { int-4-rep [ PMULLD ] }
1062 { uint-4-rep [ PMULLD ] }
1065 M: x86 %mul-vector-reps
1067 { sse? { float-4-rep } }
1068 { sse2? { double-2-rep short-8-rep ushort-8-rep } }
1069 { sse4.1? { int-4-rep uint-4-rep } }
1072 M: x86 %div-vector ( dst src1 src2 rep -- )
1073 [ two-operand ] keep
1075 { float-4-rep [ DIVPS ] }
1076 { double-2-rep [ DIVPD ] }
1079 M: x86 %div-vector-reps
1081 { sse? { float-4-rep } }
1082 { sse2? { double-2-rep } }
1085 M: x86 %min-vector ( dst src1 src2 rep -- )
1086 [ two-operand ] keep
1088 { char-16-rep [ PMINSB ] }
1089 { uchar-16-rep [ PMINUB ] }
1090 { short-8-rep [ PMINSW ] }
1091 { ushort-8-rep [ PMINUW ] }
1092 { int-4-rep [ PMINSD ] }
1093 { uint-4-rep [ PMINUD ] }
1094 { float-4-rep [ MINPS ] }
1095 { double-2-rep [ MINPD ] }
1098 M: x86 %min-vector-reps
1100 { sse? { float-4-rep } }
1101 { sse2? { uchar-16-rep short-8-rep double-2-rep } }
1102 { sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
1105 M: x86 %max-vector ( dst src1 src2 rep -- )
1106 [ two-operand ] keep
1108 { char-16-rep [ PMAXSB ] }
1109 { uchar-16-rep [ PMAXUB ] }
1110 { short-8-rep [ PMAXSW ] }
1111 { ushort-8-rep [ PMAXUW ] }
1112 { int-4-rep [ PMAXSD ] }
1113 { uint-4-rep [ PMAXUD ] }
1114 { float-4-rep [ MAXPS ] }
1115 { double-2-rep [ MAXPD ] }
1118 M: x86 %max-vector-reps
1120 { sse? { float-4-rep } }
1121 { sse2? { uchar-16-rep short-8-rep double-2-rep } }
1122 { sse4.1? { char-16-rep ushort-8-rep int-4-rep uint-4-rep } }
1126 [ two-operand ] keep
1131 [ [ MULPS ] [ drop dup float-4-rep %horizontal-add-vector ] 2bi ]
1137 [ [ MULPD ] [ drop dup double-2-rep %horizontal-add-vector ] 2bi ]
1142 M: x86 %dot-vector-reps
1144 { sse3? { float-4-rep double-2-rep } }
1147 M: x86 %horizontal-add-vector ( dst src rep -- )
1149 { float-4-rep [ [ float-4-rep %copy ] [ HADDPS ] [ HADDPS ] 2tri ] }
1150 { double-2-rep [ [ double-2-rep %copy ] [ HADDPD ] 2bi ] }
1153 M: x86 %horizontal-add-vector-reps
1155 { sse3? { float-4-rep double-2-rep } }
1158 M: x86 %horizontal-shl-vector ( dst src1 src2 rep -- )
1159 two-operand PSLLDQ ;
1161 M: x86 %horizontal-shl-vector-reps
1163 { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1166 M: x86 %horizontal-shr-vector ( dst src1 src2 rep -- )
1167 two-operand PSRLDQ ;
1169 M: x86 %horizontal-shr-vector-reps
1171 { sse2? { char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1174 M: x86 %abs-vector ( dst src rep -- )
1176 { char-16-rep [ PABSB ] }
1177 { short-8-rep [ PABSW ] }
1178 { int-4-rep [ PABSD ] }
1181 M: x86 %abs-vector-reps
1183 { ssse3? { char-16-rep short-8-rep int-4-rep } }
1186 M: x86 %sqrt-vector ( dst src rep -- )
1188 { float-4-rep [ SQRTPS ] }
1189 { double-2-rep [ SQRTPD ] }
1192 M: x86 %sqrt-vector-reps
1194 { sse? { float-4-rep } }
1195 { sse2? { double-2-rep } }
1198 M: x86 %and-vector ( dst src1 src2 rep -- )
1199 [ two-operand ] keep
1201 { float-4-rep [ ANDPS ] }
1202 { double-2-rep [ ANDPD ] }
1206 M: x86 %and-vector-reps
1208 { sse? { float-4-rep } }
1209 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1212 M: x86 %andn-vector ( dst src1 src2 rep -- )
1213 [ two-operand ] keep
1215 { float-4-rep [ ANDNPS ] }
1216 { double-2-rep [ ANDNPD ] }
1220 M: x86 %andn-vector-reps
1222 { sse? { float-4-rep } }
1223 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1226 M: x86 %or-vector ( dst src1 src2 rep -- )
1227 [ two-operand ] keep
1229 { float-4-rep [ ORPS ] }
1230 { double-2-rep [ ORPD ] }
1234 M: x86 %or-vector-reps
1236 { sse? { float-4-rep } }
1237 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1240 M: x86 %xor-vector ( dst src1 src2 rep -- )
1241 [ two-operand ] keep
1243 { float-4-rep [ XORPS ] }
1244 { double-2-rep [ XORPD ] }
1248 M: x86 %xor-vector-reps
1250 { sse? { float-4-rep } }
1251 { sse2? { double-2-rep char-16-rep uchar-16-rep short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1254 M: x86 %shl-vector ( dst src1 src2 rep -- )
1255 [ two-operand ] keep
1257 { short-8-rep [ PSLLW ] }
1258 { ushort-8-rep [ PSLLW ] }
1259 { int-4-rep [ PSLLD ] }
1260 { uint-4-rep [ PSLLD ] }
1261 { longlong-2-rep [ PSLLQ ] }
1262 { ulonglong-2-rep [ PSLLQ ] }
1265 M: x86 %shl-vector-reps
1267 { sse2? { short-8-rep ushort-8-rep int-4-rep uint-4-rep longlong-2-rep ulonglong-2-rep } }
1270 M: x86 %shr-vector ( dst src1 src2 rep -- )
1271 [ two-operand ] keep
1273 { short-8-rep [ PSRAW ] }
1274 { ushort-8-rep [ PSRLW ] }
1275 { int-4-rep [ PSRAD ] }
1276 { uint-4-rep [ PSRLD ] }
1277 { ulonglong-2-rep [ PSRLQ ] }
1280 M: x86 %shr-vector-reps
1282 { sse2? { short-8-rep ushort-8-rep int-4-rep uint-4-rep ulonglong-2-rep } }
1285 : scalar-sized-reg ( reg rep -- reg' )
1286 rep-size 8 * n-bit-version-of ;
1288 M: x86 %integer>scalar drop MOVD ;
1290 M:: x86 %scalar>integer ( dst src rep -- )
1293 dst 32-bit-version-of src MOVD
1294 dst dst 32-bit-version-of
1295 2dup eq? [ 2drop ] [ MOVSX ] if
1298 dst 32-bit-version-of src MOVD
1300 { short-scalar-rep [
1301 dst 32-bit-version-of src MOVD
1302 dst dst 16-bit-version-of MOVSX
1304 { ushort-scalar-rep [
1305 dst 32-bit-version-of src MOVD
1306 dst dst 16-bit-version-of MOVZX
1309 dst 32-bit-version-of src MOVD
1310 dst { } 8 [| tmp-dst |
1311 tmp-dst dst int-rep %copy
1312 tmp-dst tmp-dst 8-bit-version-of MOVSX
1313 dst tmp-dst int-rep %copy
1314 ] with-small-register
1316 { uchar-scalar-rep [
1317 dst 32-bit-version-of src MOVD
1318 dst { } 8 [| tmp-dst |
1319 tmp-dst dst int-rep %copy
1320 tmp-dst tmp-dst 8-bit-version-of MOVZX
1321 dst tmp-dst int-rep %copy
1322 ] with-small-register
1326 M: x86 %vector>scalar %copy ;
1327 M: x86 %scalar>vector %copy ;
1329 M:: x86 %spill ( src rep dst -- ) dst src rep %copy ;
1330 M:: x86 %reload ( dst rep src -- ) dst src rep %copy ;
1332 M: x86 %loop-entry 16 code-alignment [ NOP ] times ;
1334 M:: x86 %save-context ( temp1 temp2 callback-allowed? -- )
1335 #! Save Factor stack pointers in case the C code calls a
1336 #! callback which does a GC, which must reliably trace
1338 temp1 "stack_chain" %vm-field-ptr
1340 temp2 stack-reg cell neg [+] LEA
1343 temp1 2 cells [+] ds-reg MOV
1344 temp1 3 cells [+] rs-reg MOV
1347 M: x86 value-struct? drop t ;
1349 M: x86 immediate-arithmetic? ( n -- ? )
1350 HEX: -80000000 HEX: 7fffffff between? ;
1352 M: x86 immediate-bitwise? ( n -- ? )
1353 HEX: -80000000 HEX: 7fffffff between? ;
1355 : next-stack@ ( n -- operand )
1356 #! nth parameter from the next stack frame. Used to box
1357 #! input values to callbacks; the callback has its own
1358 #! stack frame set up, and we want to read the frame
1359 #! set up by the caller.
1360 stack-frame get total-size>> + stack@ ;
1366 :: install-sse2-check ( -- )
1369 "This image was built to use SSE2 but your CPU does not support it." print
1370 "You will need to bootstrap Factor again." print
1374 ] "cpu.x86" add-init-hook ;
1376 : enable-sse2 ( version -- )
1378 enable-float-intrinsics
1379 enable-float-functions
1380 enable-float-min/max
1386 [ { sse_version } compile ] with-optimizer
1387 "Checking for multimedia extensions: " write sse-version
1388 [ sse-string write " detected" print ] [ enable-sse2 ] bi ;