x86
Factor handbook > The implementation > System interface > Processor detection

Prev:arm


Vocabulary
system

Definition


Methods




























M:: x86 %alien-assembly
( varargs? reg-inputs stack-inputs reg-outputs dead-outputs cleanup stack-size quot -- )
stack-inputs [ first3 %store-stack-param ] each reg-inputs
[ first3 %store-reg-param ] each varargs?
[ reg-inputs %prepare-var-args ] when
quot ( -- ) call-effect cleanup %cleanup reg-outputs
[ first3 %load-reg-param ] each dead-outputs
[ first2 %discard-reg-param ] each ;






M:: x86 %alien-indirect
( src varargs? reg-inputs stack-inputs reg-outputs dead-outputs cleanup stack-size gc-map -- )
varargs? reg-inputs stack-inputs reg-outputs dead-outputs
cleanup stack-size
[ src ?spill-slot CALL gc-map gc-map-here ] %alien-assembly
;









M:: x86 %allot ( dst size class nursery-ptr -- )
nursery-ptr dst load-allot-ptr dst class store-header
dst class store-tagged nursery-ptr size inc-allot-ptr ;






























M:: x86 %bit-test ( dst src1 src2 temp -- )
src1 src2 BT dst temp \ CMOVB (%boolean) ;



M:: x86 %box-alien ( dst src temp -- )
<label> :> end dst \ f type-number MOV src src TEST end JE
dst 5 cells alien temp %allot dst 1 alien@
\ f type-number MOV dst 2 alien@ \ f type-number MOV
dst 3 alien@ src MOV dst 4 alien@ src MOV end resolve-label
;



M:: x86 %box-displaced-alien
( dst displacement base temp base-class -- )
<label> :> end dst base MOV displacement displacement TEST
end JE dst 5 cells alien temp %allot dst 2 alien@
\ f type-number MOV dst displacement base temp {
{
[ base-class \ f class<= ]
[ 2drop %box-displaced-alien/f ]
}
{
[ base-class \ alien class<= ]
[ %box-displaced-alien/alien ]
}
{
[ base-class \ byte-array class<= ]
[ %box-displaced-alien/byte-array ]
}
[ end %box-displaced-alien/dynamic ]
} cond end resolve-label ;















M:: x86 %check-nursery-branch
( label size cc temp1 temp2 -- )
temp1 load-zone-offset temp2 temp1 [] MOV temp2 size ADD
temp2 temp1 2 cells [+] CMP cc
{ { cc<= [ label JLE ] } { cc/<= [ label JG ] } } case ;






M:: x86 %compare ( dst src1 src2 cc temp -- )
src1 src2 CMP dst cc temp %boolean ;



M:: x86 %compare-branch ( label src1 src2 cc -- )
src1 src2 CMP label cc %branch ;















M:: x86 %compare-imm ( dst src1 src2 cc temp -- )
src1 src2 (%compare-imm) dst cc temp %boolean ;



M:: x86 %compare-imm-branch ( label src1 src2 cc -- )
src1 src2 (%compare-imm) label cc %branch ;



M:: x86 %compare-integer-imm ( dst src1 src2 cc temp -- )
src1 src2 CMP dst cc temp %boolean ;



M:: x86 %compare-integer-imm-branch
( label src1 src2 cc -- ) src1 src2 CMP label cc %branch ;








































































M:: x86 %gather-int-vector-4
( dst src1 src2 src3 src4 rep -- )
dst rep %zero-vector dst src1 32-bit-version-of 0 PINSRD
dst src2 32-bit-version-of 1 PINSRD
dst src3 32-bit-version-of 2 PINSRD
dst src4 32-bit-version-of 3 PINSRD ;






M:: x86 %gather-vector-2 ( dst src1 src2 rep -- )
rep signed-rep {
{
double-2-rep
[ dst src1 double-2-rep %copy dst src2 MOVLHPS ]
}
{
longlong-2-rep
[
dst src1 longlong-2-rep %copy
dst src2 PUNPCKLQDQ
]
}
} case ;






M:: x86 %gather-vector-4 ( dst src1 src2 src3 src4 rep -- )
rep signed-rep {
{
float-4-rep
[
dst src1 float-4-rep %copy dst src2 UNPCKLPS
src3 src4 UNPCKLPS dst src3 MOVLHPS
]
}
{
int-4-rep
[
dst src1 int-4-rep %copy dst src2 PUNPCKLDQ
src3 src4 PUNPCKLDQ dst src3 PUNPCKLQDQ
]
}
} case ;































































M:: x86 %local-allot ( dst size align offset -- )
dst offset local-allot-offset special-offset stack@ LEA ;




































































































































M:: x86 %save-context ( temp1 temp2 -- )
temp1 %context temp2 stack-reg cell neg [+] LEA
temp1 "callstack-top" context offset-of [+] temp2 MOV
temp1 "datastack" context offset-of [+] ds-reg MOV
temp1 "retainstack" context offset-of [+] rs-reg MOV ;



















































M:: x86 %shuffle-vector-halves-imm
( dst src1 src2 shuffle rep -- )
dst src1 src2 rep two-operand shuffle rep {
{ double-2-rep [ >float-4-shuffle SHUFPS ] }
{ float-4-rep [ SHUFPS ] }
} case ;


































































M:: x86 %test ( dst src1 src2 cc temp -- )
src1 src2 TEST dst cc temp %boolean ;



M:: x86 %test-branch ( label src1 src2 cc -- )
src1 src2 TEST label cc %branch ;



M:: x86 %test-imm ( dst src1 src2 cc temp -- )
src1 src2 TEST dst cc temp %boolean ;



M:: x86 %test-imm-branch ( label src1 src2 cc -- )
src1 src2 TEST label cc %branch ;



M:: x86 %test-vector ( dst src temp rep vcc -- )
dst src rep (%move-vector-mask)
:> mask dst temp mask vcc %test-vector-mask ;



M:: x86 %test-vector-branch ( label src temp rep vcc -- )
temp src rep (%move-vector-mask)
:> mask label temp mask vcc %test-vector-mask-branch ;









M:: x86 %unbox-any-c-ptr ( dst src -- )
<label> :> end dst dst XOR src \ f type-number CMP end JE
dst src MOV dst tag-mask get AND dst alien type-number CMP
dst src byte-array-offset [+] LEA end JNE
dst src alien-offset [+] MOV end resolve-label ;


















M:: x86 %write-barrier ( src slot scale tag temp1 temp2 -- )
temp1 src slot scale tag (%slot) LEA
temp1 temp2 (%write-barrier) ;



M:: x86 %write-barrier-imm ( src slot tag temp1 temp2 -- )
temp1 src slot tag (%slot-imm) LEA
temp1 temp2 (%write-barrier) ;







































M: x86 immediate-arithmetic? -2147483648 2147483647 between? ;



M: x86 immediate-bitwise? -2147483648 2147483647 between? ;