From 35b40a0f106e4d70f59fc98a6270880b16b4b01a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 7 Dec 2005 05:14:24 +0000 Subject: [PATCH] fix generic word error --- TODO.FACTOR.txt | 2 -- library/compiler/amd64/architecture.factor | 12 +++++------- library/compiler/amd64/load.factor | 1 + library/compiler/x86/architecture.factor | 12 +++++------- library/compiler/x86/assembler.factor | 12 +++++++----- library/test/test.factor | 4 ++-- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 8ae7c828b0..0f1adebdfc 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -16,8 +16,6 @@ word help sections: parsing word sections: - syntax -- sort out types on 64-bit platforms -- on win64, long is 4 bytes, - on linux, 8 - malloc, free, realloc, memcpy: aliens - check 'see' - intrinsic char-slot set-char-slot for x86 diff --git a/library/compiler/amd64/architecture.factor b/library/compiler/amd64/architecture.factor index 54290292e1..30641c5339 100644 --- a/library/compiler/amd64/architecture.factor +++ b/library/compiler/amd64/architecture.factor @@ -6,13 +6,15 @@ USING: assembler compiler-backend kernel sequences ; ! R14 datastack ! R15 callstack -: ds-reg R14 ; inline -: cs-reg R15 ; inline - : fixnum-imm? ( -- ? ) #! Can fixnum operations take immediate operands? f ; inline +: ds-reg R14 ; inline +: cs-reg R15 ; inline +: return-reg RAX ; inline +: remainder-reg RDX ; inline + : vregs { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ; inline ! FIXME @@ -28,7 +30,3 @@ M: float-regs fastcall-regs drop 0 ; 0 scratch [ swap MOV ] keep ; inline : fixnum>slot@ drop ; inline - -: return-register RAX ; inline - -: remainder-reg RDX ; inline diff --git a/library/compiler/amd64/load.factor b/library/compiler/amd64/load.factor index 4b6a2c0add..2493fdd17a 100644 --- a/library/compiler/amd64/load.factor +++ b/library/compiler/amd64/load.factor @@ -7,6 +7,7 @@ USING: io kernel parser sequences ; "/library/compiler/x86/generator.factor" "/library/compiler/x86/slots.factor" "/library/compiler/x86/stack.factor" + "/library/compiler/x86/fixnum.factor" ] [ dup print run-resource ] each diff --git a/library/compiler/x86/architecture.factor b/library/compiler/x86/architecture.factor index a0117cec53..59aa987826 100644 --- a/library/compiler/x86/architecture.factor +++ b/library/compiler/x86/architecture.factor @@ -6,13 +6,15 @@ USING: assembler compiler-backend kernel sequences ; ! ESI datastack ! EBX callstack -: ds-reg ESI ; inline -: cs-reg EBX ; inline - : fixnum-imm? ( -- ? ) #! Can fixnum operations take immediate operands? t ; inline +: ds-reg ESI ; inline +: cs-reg EBX ; inline +: return-register EAX ; inline +: remainder-reg EDX ; inline + : vregs { EAX ECX EDX } ; inline ! On x86, parameters are never passed in registers. @@ -28,7 +30,3 @@ M: float-regs fastcall-regs drop 0 ; ; inline : fixnum>slot@ 1 SHR ; inline - -: return-register EAX ; inline - -: remainder-reg EDX ; inline diff --git a/library/compiler/x86/assembler.factor b/library/compiler/x86/assembler.factor index 5419ad3499..4ce2aa6bda 100644 --- a/library/compiler/x86/assembler.factor +++ b/library/compiler/x86/assembler.factor @@ -148,11 +148,13 @@ UNION: operand register indirect displaced disp-only ; #! Relative to after next 32-bit immediate. compiled-offset - 4 - ; +PREDICATE: word callable register? not ; + ( Moving stuff ) GENERIC: PUSH ( op -- ) M: register PUSH f HEX: 50 short-operand ; M: integer PUSH HEX: 68 assemble-1 assemble-4 ; -M: word PUSH 0 PUSH absolute-4 ; +M: callable PUSH 0 PUSH absolute-4 ; M: operand PUSH BIN: 110 f HEX: ff 1-operand ; GENERIC: POP ( op -- ) @@ -166,24 +168,24 @@ M: operand (MOV-I) BIN: 000 t HEX: c7 1-operand assemble-4 ; GENERIC: MOV ( dst src -- ) M: integer MOV swap (MOV-I) ; -M: word MOV 0 rot (MOV-I) absolute-cell ; +M: callable MOV 0 rot (MOV-I) absolute-cell ; M: operand MOV HEX: 89 2-operand ; ( Control flow ) GENERIC: JMP ( op -- ) M: integer JMP HEX: e9 assemble-1 from assemble-4 ; +M: callable JMP 0 JMP relative-4 ; M: operand JMP BIN: 100 t HEX: ff 1-operand ; -M: word JMP 0 JMP relative-4 ; GENERIC: CALL ( op -- ) M: integer CALL HEX: e8 assemble-1 from assemble-4 ; +M: callable CALL 0 CALL relative-4 ; M: operand CALL BIN: 010 t HEX: ff 1-operand ; -M: word CALL 0 CALL relative-4 ; GENERIC: JUMPcc ( opcode addr -- ) M: integer JUMPcc ( opcode addr -- ) HEX: 0f assemble-1 swap assemble-1 from assemble-4 ; -M: word JUMPcc ( opcode addr -- ) +M: callable JUMPcc ( opcode addr -- ) >r 0 JUMPcc r> relative-4 ; : JO HEX: 80 swap JUMPcc ; diff --git a/library/test/test.factor b/library/test/test.factor index 36fa97ad6a..3763d03cf3 100644 --- a/library/test/test.factor +++ b/library/test/test.factor @@ -108,10 +108,10 @@ SYMBOL: failures : compiler-tests { - "io/buffer" "compiler/optimizer" + "io/buffer" "compiler/simple" "compiler/stack" "compiler/ifte" "compiler/generic" "compiler/bail-out" "compiler/linearizer" "compiler/intrinsics" - "compiler/identities" + "compiler/identities" "compiler/optimizer" } run-tests ;