arm.64


Vocabulary
system

Definition


Methods






















M:: arm.64 %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 reg-outputs
[ first3 %load-reg-param ] each ;















M:: arm.64 %allot ( DST size class TEMP -- )
VM "nursery" vm offset-of [+] :> operand DST operand LDR
temp DST size data-alignment get align ADD temp operand STR
temp class type-number tag-header MOV temp DST [] STR
DST dup class type-number ADD ;






























M:: arm.64 %bit-test ( DST SRC1 SRC2 TEMP -- )
DST TEMP (%boolean) SRC1 SRC2 2 insns TBZ DST TEMP MOV ;



M:: arm.64 %box ( DST SRC func rep gc-map -- )
rep reg-class-of f param-regs at first SRC rep %copy
rep int-rep? arg2 arg1 ? VM MOV func f gc-map %c-invoke
DST int-rep %load-return ;



M:: arm.64 %box-alien ( DST SRC TEMP -- )
<label> :> end DST \ f type-number MOV SRC end CBZ
DST 5 cells alien TEMP %allot temp \ f type-number MOV
temp DST 1 alien@ STR temp DST 2 alien@ STR SRC DST 3 alien@
STR SRC DST 4 alien@ STR end resolve-label ;



M:: arm.64 %box-displaced-alien
( DST DISP BASE TEMP base-class -- )
<label> :> end DST BASE MOV DISP end CBZ
DST 5 cells alien TEMP %allot temp \ f type-number MOV
temp DST 2 alien@ STR DST DISP 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:: arm.64 %check-nursery-branch
( label size cc TEMP1 TEMP2 -- )
"nursery" vm offset-of :> offset TEMP1 VM offset [+] LDR
TEMP1 TEMP1 size ADD TEMP2 VM offset 2 cells + [+] LDR
TEMP1 TEMP2 CMP cc
{ { cc<= [ label BLE ] } { cc/<= [ label BGT ] } } case ;
























M:: arm.64 %compare-imm ( DST SRC1 SRC2 cc TEMP -- )
SRC1 SRC2 (%compare-imm) DST cc cc>cond TEMP %boolean ;



























M:: arm.64 %dispatch ( SRC TEMP -- )
temp 3 insns ADR temp dup SRC [+] LDR temp BR ;

































M:: arm.64 %fixnum-mul ( label dst src1 src2 cc -- )
temp src1 src2 SMULH dst src1 src2 MUL temp dst 63 <ASR> CMP
label cc { { cc-o [ BNE ] } { cc/o [ BEQ ] } } case ;





















M:: arm.64 %gather-int-vector-2 ( DST SRC1 SRC2 rep -- )
DST SRC1 0 rep INSgen DST SRC2 1 rep INSgen ;






M:: arm.64 %gather-int-vector-4
( DST SRC1 SRC2 SRC3 SRC4 rep -- )
DST SRC1 0 rep INSgen DST SRC2 1 rep INSgen
DST SRC3 2 rep INSgen DST SRC4 3 rep INSgen ;






M:: arm.64 %gather-vector-2 ( DST SRC1 SRC2 rep -- )
DST SRC1 0 0 rep INSelt DST SRC2 1 0 rep INSelt ;






M:: arm.64 %gather-vector-4
( DST SRC1 SRC2 SRC3 SRC4 rep -- )
DST SRC1 0 0 rep INSelt DST SRC1 1 0 rep INSelt
DST SRC1 2 0 rep INSelt DST SRC1 3 0 rep INSelt ;






















































M:: arm.64 %local-allot ( DST size align offset -- )
DST SP offset local-allot-offset special-offset ADD ;



M:: arm.64 %log2 ( DST SRC -- )
DST SRC CLZ DST DST 64 SUB DST DST MVN ;



M:: arm.64 %max ( DST SRC1 SRC2 -- )
SRC1 SRC2 CMP DST SRC1 SRC2 GE CSEL ;





















M:: arm.64 %min ( DST SRC1 SRC2 -- )
SRC1 SRC2 CMP DST SRC1 SRC2 LE CSEL ;



























M:: arm.64 %mul-imm ( DST SRC1 src2 -- )
temp XZR MOV temp dup src2 ADD DST SRC1 temp MUL ;














































































M:: arm.64 %save-context ( TEMP1 TEMP2 -- )
TEMP1 %context TEMP2 SP MOV
TEMP2 TEMP1 "callstack-top" context offset-of [+] STR
DS TEMP1 "datastack" context offset-of [+] STR
RS TEMP1 "retainstack" context offset-of [+] STR ;













































































































































M:: arm.64 %unbox ( DST SRC func rep -- )
arg1 SRC tagged-rep %copy arg2 VM MOV func f f %c-invoke
DST rep %load-return ;

































M:: arm.64 %write-barrier
( SRC SLOT scale tag TEMP1 TEMP2 -- )
TEMP1 SRC SLOT scale tag (%slot) ADD
TEMP1 TEMP2 (%write-barrier) ;



M:: arm.64 %write-barrier-imm
( SRC slot tag TEMP1 TEMP2 -- )
TEMP1 SRC slot tag slot-offset ADD
TEMP1 TEMP2 (%write-barrier) ;





































































M: arm.64 machine-registers
{
{
int-regs
{
X0
X1
X2
X3
X4
X5
X6
X7
X8
X10
X11
X12
X13
X14
X15
}
}
{
float-regs
{
V0
V1
V2
V3
V4
V5
V6
V7
V16
V17
V18
V19
V20
V21
V22
V23
V24
V25
V26
V27
V28
V29
V30
}
}
} ;



M: arm.64 param-regs
drop {
{ int-regs { X0 X1 X2 X3 X4 X5 X6 X7 } }
{ float-regs { V0 V1 V2 V3 V4 V5 V6 V7 } }
} ;