Loop alignment: appears to be a small win for reverse-complement

db4
Slava Pestov 2008-11-03 06:20:51 -06:00
parent cdb5c30bd3
commit 59f4f25b91
6 changed files with 17 additions and 3 deletions
basis
compiler
cpu
x86

View File

@ -100,6 +100,7 @@ GENERIC: emit-node ( node -- next )
basic-block get swap loops get set-at ;
: compile-loop ( node -- next )
##loop-entry
begin-basic-block
[ label>> id>> remember-loop ] [ child>> emit-nodes ] bi
iterate-next ;

View File

@ -160,6 +160,8 @@ INSN: ##epilogue ;
INSN: ##branch ;
INSN: ##loop-entry ;
! Condition codes
SYMBOL: cc<
SYMBOL: cc<=

View File

@ -205,6 +205,8 @@ M: ##write-barrier generate-insn
M: _gc generate-insn drop %gc ;
M: ##loop-entry generate-insn drop %loop-entry ;
! ##alien-invoke
GENERIC: reg-size ( register-class -- n )

View File

@ -130,6 +130,8 @@ HOOK: %spill-float cpu ( src n -- )
HOOK: %reload-integer cpu ( dst n -- )
HOOK: %reload-float cpu ( dst n -- )
HOOK: %loop-entry cpu ( -- )
! FFI stuff
! Is this integer small enough to appear in value template

View File

@ -51,8 +51,8 @@ M: x86 %call ( label -- ) CALL ;
M: x86 %jump-label ( label -- ) JMP ;
M: x86 %return ( -- ) 0 RET ;
: code-alignment ( -- n )
building get length dup cell align swap - ;
: code-alignment ( align -- n )
[ building get [ integer? ] count dup ] dip align swap - ;
: align-code ( n -- )
0 <repetition> % ;
@ -66,7 +66,7 @@ M:: x86 %dispatch ( src temp -- )
src temp ADD
src HEX: 7f [+] JMP
! Fix up the displacement above
code-alignment dup bootstrap-cell 8 = 15 9 ? +
cell code-alignment dup bootstrap-cell 8 = 15 9 ? +
building get dup pop* push
align-code ;
@ -466,6 +466,9 @@ M: x86 %reload-integer ( dst n -- ) spill-integer@ MOV ;
M: x86 %spill-float spill-float@ swap MOVSD ;
M: x86 %reload-float spill-float@ MOVSD ;
M: x86 %loop-entry
16 code-alignment [ NOP ] times ;
M: int-regs %save-param-reg drop >r stack@ r> MOV ;
M: int-regs %load-param-reg drop swap stack@ MOV ;

View File

@ -446,6 +446,10 @@ M: operand IMUL2 OCT: 257 extended-opcode (2-operand) ;
: CPUID ( -- ) HEX: a2 extended-opcode, ;
! Misc
: NOP ( -- ) HEX: 90 , ;
! x87 Floating Point Unit
: FSTPS ( operand -- ) { BIN: 011 f HEX: d9 } 1-operand ;