From 19641646646179422a72dc2869630dca3eaa1774 Mon Sep 17 00:00:00 2001 From: slava Date: Thu, 4 May 2006 22:08:52 +0000 Subject: [PATCH] vregs now delegate to a register class --- library/compiler/amd64/architecture.factor | 14 ++++++-------- library/compiler/generator/architecture.factor | 13 ++++++++----- library/compiler/generator/generator.factor | 8 ++++---- library/compiler/generator/templates.factor | 6 +++--- library/compiler/optimizer/class-infer.factor | 2 +- library/compiler/ppc/architecture.factor | 5 ++--- library/compiler/x86/alien.factor | 2 +- library/compiler/x86/architecture.factor | 10 ++++++---- library/compiler/x86/intrinsics.factor | 12 ++++++++---- library/test/compiler/callbacks.factor | 4 ++-- 10 files changed, 41 insertions(+), 35 deletions(-) diff --git a/library/compiler/amd64/architecture.factor b/library/compiler/amd64/architecture.factor index 4922f704d5..59be8dfbe9 100644 --- a/library/compiler/amd64/architecture.factor +++ b/library/compiler/amd64/architecture.factor @@ -5,7 +5,8 @@ USING: alien arrays assembler kernel kernel-internals math namespaces sequences ; ! AMD64 register assignments -! RAX RCX RDX RSI RDI R8 R9 R10 R11 vregs +! RAX RCX RDX RSI RDI R8 R9 R10 R11 integer vregs +! XMM0 - XMM7 float vregs ! R13 cards_offset ! R14 datastack ! R15 callstack @@ -14,11 +15,9 @@ kernel-internals math namespaces sequences ; : cs-reg R15 ; inline : remainder-reg RDX ; inline -: vregs { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ; inline - M: int-regs return-reg drop RAX ; - -M: int-regs fastcall-regs drop { RDI RSI RDX RCX R8 R9 } ; +M: int-regs vregs { RAX RCX RDX RSI RDI R8 R9 R10 R11 } ; +M: int-regs fastcall-regs { RDI RSI RDX RCX R8 R9 } ; : compile-c-call ( symbol dll -- ) 2dup dlsym R10 swap MOV @@ -29,9 +28,8 @@ M: int-regs fastcall-regs drop { RDI RSI RDX RCX R8 R9 } ; swap [ MOV ] 2each compile-c-call ; M: float-regs return-reg drop XMM0 ; - -M: float-regs fastcall-regs - drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ; +M: float-regs vregs drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ; +M: float-regs fastcall-regs vregs ; : address-operand ( address -- operand ) #! On AMD64, we have to load 64-bit addresses into a diff --git a/library/compiler/generator/architecture.factor b/library/compiler/generator/architecture.factor index c1224d442f..e464b8e443 100644 --- a/library/compiler/generator/architecture.factor +++ b/library/compiler/generator/architecture.factor @@ -5,10 +5,16 @@ sequences ; ! A scratch register for computations TUPLE: vreg n ; +C: vreg ( n reg-class -- vreg ) + [ set-delegate ] keep [ set-vreg-n ] keep ; + ! Register classes TUPLE: int-regs ; TUPLE: float-regs size ; +: ( n -- vreg ) T{ int-regs } ; +: ( n -- vreg ) T{ float-regs f 8 } ; + ! A pseudo-register class for parameters spilled on the stack TUPLE: stack-params ; @@ -19,7 +25,7 @@ GENERIC: return-reg ( register-class -- reg ) GENERIC: fastcall-regs ( register-class -- regs ) ! Sequence mapping vreg-n to native assembler registers -DEFER: vregs ( -- regs ) +GENERIC: vregs ( register-class -- regs ) ! Load a literal (immediate or indirect) G: load-literal ( obj vreg -- ) 1 standard-combination ; @@ -105,9 +111,6 @@ M: float-regs inc-reg-class macosx? [ reg-size 4 / int-regs +@ ] [ drop ] if ; GENERIC: v>operand - M: integer v>operand tag-bits shift ; - -M: vreg v>operand vreg-n vregs nth ; - +M: vreg v>operand dup vreg-n swap vregs nth ; M: f v>operand address ; diff --git a/library/compiler/generator/generator.factor b/library/compiler/generator/generator.factor index d52eb6f959..d4c0ece09b 100644 --- a/library/compiler/generator/generator.factor +++ b/library/compiler/generator/generator.factor @@ -140,12 +140,12 @@ M: #if generate-node ( node -- next ) : if>boolean-intrinsic ( label -- )