some assembler tweaks, and a fix for indirect literal load relocation

cvs
Slava Pestov 2005-12-23 06:41:33 +00:00
parent 6f0e1c6bb9
commit df230e7cd9
4 changed files with 18 additions and 5 deletions

View File

@ -1,5 +1,6 @@
+ 0.80: + 0.80:
- make-image leaks memory if there is an error while parsing files
- runtime primitives like fopen: check for null input - runtime primitives like fopen: check for null input
- make = for sequences more efficient - make = for sequences more efficient
- zero-height gadgets mess up hit testing - zero-height gadgets mess up hit testing

View File

@ -1,6 +1,6 @@
IN: compiler-backend IN: compiler-backend
USING: alien assembler compiler compiler-backend kernel USING: alien arrays assembler compiler compiler-backend kernel
sequences ; math sequences ;
! AMD64 register assignments ! AMD64 register assignments
! RAX RCX RDX RSI RDI R8 R9 R10 R11 vregs ! RAX RCX RDX RSI RDI R8 R9 R10 R11 vregs
@ -48,3 +48,8 @@ M: float-regs fastcall-regs drop 0 ;
: compile-prologue RSP 8 SUB ; inline : compile-prologue RSP 8 SUB ; inline
: compile-epilogue RSP 8 ADD ; inline : compile-epilogue RSP 8 ADD ; inline
: load-indirect ( dest literal -- )
#! We use RIP-relative addressing. The '3' is a hardcoded
#! instruction length.
add-literal from 3 - 1array MOV ; inline

View File

@ -1,5 +1,5 @@
IN: compiler-backend IN: compiler-backend
USING: alien assembler compiler compiler-backend kernel USING: alien arrays assembler compiler compiler-backend kernel
sequences ; sequences ;
! x86 register assignments ! x86 register assignments
@ -45,3 +45,6 @@ M: float-regs fastcall-regs drop 0 ;
: compile-prologue ; inline : compile-prologue ; inline
: compile-epilogue ; inline : compile-epilogue ; inline
: load-indirect ( dest literal -- )
add-literal 1array MOV rel-absolute-cell rel-address ; inline

View File

@ -6,6 +6,10 @@ lists math namespaces parser sequences words ;
! A postfix assembler for x86 and AMD64. ! A postfix assembler for x86 and AMD64.
! In 32-bit mode, { 1234 } is absolute indirect addressing.
! In 64-bit mode, { 1234 } is RIP-relative.
! Beware!
: byte? -128 127 between? ; : byte? -128 127 between? ;
GENERIC: modifier ( op -- mod ) GENERIC: modifier ( op -- mod )
@ -76,7 +80,7 @@ PREDICATE: array displaced
M: displaced modifier second byte? BIN: 01 BIN: 10 ? ; M: displaced modifier second byte? BIN: 01 BIN: 10 ? ;
M: displaced register first register ; M: displaced register first register ;
M: displaced displacement M: displaced displacement
second dup byte? [ assemble-1 ] [ assemble-cell ] if ; second dup byte? [ assemble-1 ] [ assemble-4 ] if ;
M: displaced canonicalize M: displaced canonicalize
dup first EBP = not over second 0 = and dup first EBP = not over second 0 = and
[ first 1array ] when ; [ first 1array ] when ;
@ -92,7 +96,7 @@ M: disp-only register
#! x86 encodes displacement-only as { EBP }. #! x86 encodes displacement-only as { EBP }.
drop BIN: 101 ; drop BIN: 101 ;
M: disp-only displacement M: disp-only displacement
first assemble-cell ; first assemble-4 ;
( Utilities ) ( Utilities )
UNION: operand register indirect displaced disp-only ; UNION: operand register indirect displaced disp-only ;