]> gitweb.factorcode.org Git - factor.git/commitdiff
New 'pentium4' architecture
authorslava <slava@factorcode.org>
Fri, 5 May 2006 06:08:37 +0000 (06:08 +0000)
committerslava <slava@factorcode.org>
Fri, 5 May 2006 06:08:37 +0000 (06:08 +0000)
library/bootstrap/boot-stage1.factor
library/bootstrap/image.factor
library/compiler/x86/architecture.factor
library/compiler/x86/intrinsics-sse2.factor [new file with mode: 0644]
library/compiler/x86/intrinsics.factor

index 72ebb79b7925b551897f7876bc25353c2bd42531..bb217acdf689fe62b54c16d00c3a6a6df178a739 100644 (file)
@@ -9,6 +9,10 @@ vectors words ;
 
 "/library/bootstrap/primitives.factor" run-resource
 
+: if-arch ( arch seq -- )
+    architecture rot member?
+    [ [ parse-resource % ] each ] [ drop ] if ;
+
 ! The [ ] make form creates a boot quotation
 [
     \ boot ,
@@ -277,40 +281,34 @@ vectors words ;
         "/doc/handbook/words.facts"
     } [ parse-resource % ] each
     
-    architecture get {
-        {
-            [ dup "x86" = ] [
-                {
-                    "/library/compiler/x86/assembler.factor"
-                    "/library/compiler/x86/architecture.factor"
-                    "/library/compiler/x86/alien.factor"
-                    "/library/compiler/x86/intrinsics.factor"
-                }
-            ]
-        } {
-            [ dup "ppc" = ] [
-                {
-                    "/library/compiler/ppc/assembler.factor"
-                    "/library/compiler/ppc/architecture.factor"
-                    "/library/compiler/ppc/intrinsics.factor"
-                }
-            ]
-        } {
-            [ dup "amd64" = ] [
-                {
-                    "/library/compiler/x86/assembler.factor"
-                    "/library/compiler/amd64/architecture.factor"
-                    "/library/compiler/x86/generator.factor"
-                    "/library/compiler/amd64/generator.factor"
-                    "/library/compiler/x86/slots.factor"
-                    "/library/compiler/amd64/slots.factor"
-                    "/library/compiler/x86/stack.factor"
-                    "/library/compiler/x86/fixnum.factor"
-                    "/library/compiler/amd64/alien.factor"
-                }
-            ]
-        }
-    } cond [ parse-resource % ] each drop
+    { "x86" "pentium4" } {
+        "/library/compiler/x86/assembler.factor"
+        "/library/compiler/x86/architecture.factor"
+        "/library/compiler/x86/alien.factor"
+        "/library/compiler/x86/intrinsics.factor"
+    } if-arch
+    
+    { "pentium4" } {
+        "/library/compiler/x86/intrinsics-sse2.factor"
+    } if-arch
+
+    { "ppc" } {
+        "/library/compiler/ppc/assembler.factor"
+        "/library/compiler/ppc/architecture.factor"
+        "/library/compiler/ppc/intrinsics.factor"
+    } if-arch
+
+    { "amd64" } {
+        "/library/compiler/x86/assembler.factor"
+        "/library/compiler/amd64/architecture.factor"
+        "/library/compiler/x86/generator.factor"
+        "/library/compiler/amd64/generator.factor"
+        "/library/compiler/x86/slots.factor"
+        "/library/compiler/amd64/slots.factor"
+        "/library/compiler/x86/stack.factor"
+        "/library/compiler/x86/fixnum.factor"
+        "/library/compiler/amd64/alien.factor"
+    } if-arch
     
     [
         "/library/bootstrap/boot-stage2.factor" run-resource
@@ -330,3 +328,5 @@ vocabularies get [
 "Building generic words..." print flush
 
 all-words [ generic? ] subset [ make-generic ] each
+
+FORGET: if-arch
index dabb7de804bf878d0e229812ac333c2cbd3926e9..a0ee4204cf652d0e4f63461a728cd5e1b70198b2 100644 (file)
@@ -361,4 +361,4 @@ M: hashtable ' ( hashtable -- pointer )
     ] with-scope ;
 
 : make-images ( -- )
-    { "x86" "ppc" "amd64" } [ make-image ] each ;
+    { "x86" "pentium4" "ppc" "amd64" } [ make-image ] each ;
index 70a0a20614c9c49146574ce8c4bd225a5ea315ee..676a6a2801ac68ee0e37313270c9f3c92b2e36ef 100644 (file)
@@ -47,6 +47,8 @@ M: float-regs vregs drop { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } ;
 : prepare-division CDQ ; inline
 
 : unboxify-float ( obj vreg quot -- | quot: obj int-vreg )
+    #! The SSE2 code here will never be generated unless SSE2
+    #! intrinsics are loaded.
     over [ float-regs? ] is? [
         swap >r T{ int-regs } alloc-reg [ swap call ] keep
         r> swap [ v>operand ] 2apply float-offset [+] MOVSD
@@ -102,6 +104,8 @@ M: object load-literal ( literal vreg -- )
     swap [ swap vreg-mov ] unboxify-float ;
 
 : %replace ( vreg loc -- )
+    #! The SSE2 code here will never be generated unless SSE2
+    #! intrinsics are loaded.
     over [ float-regs? ] is? [
         ! >r
         ! "fp-scratch" operand "allot.here" f dlsym [] MOV
diff --git a/library/compiler/x86/intrinsics-sse2.factor b/library/compiler/x86/intrinsics-sse2.factor
new file mode 100644 (file)
index 0000000..239d63e
--- /dev/null
@@ -0,0 +1,38 @@
+! Copyright (C) 2005, 2006 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien arrays assembler kernel kernel-internals lists math
+math-internals namespaces sequences words ;
+IN: compiler
+
+! Floats
+: define-float-op ( word op -- )
+    [ [ "x" operand "y" operand ] % , ] [ ] make H{
+        { +input { { float "x" } { float "y" } } }
+        { +output { "x" } }
+    } define-intrinsic ;
+
+{
+    { float+ ADDSD }
+    { float- SUBSD }
+    { float* MULSD }
+    { float/f DIVSD }
+} [
+    first2 define-float-op
+] each
+
+: define-float-jump ( word op -- )
+    [
+        [ end-basic-block "x" operand "y" operand COMISD ] % ,
+    ] [ ] make H{
+        { +input { { float "x" } { float "y" } } }
+    } define-if-intrinsic ;
+
+{
+    { float< JL }
+    { float<= JLE }
+    { float> JG }
+    { float>= JGE }
+    { float= JE }
+} [
+    first2 define-float-jump
+] each
index e98ab9ec3300677e51ae92dce67a9fd7af942731..c4aea1c22d6c1a7b406ca8a8198404221ced69a1 100644 (file)
@@ -261,39 +261,6 @@ IN: compiler
     first2 define-fixnum-jump
 ] each
 
-! Floats
-! : define-float-op ( word op -- )
-!     [ [ "x" operand "y" operand ] % , ] [ ] make H{
-!         { +input { { float "x" } { float "y" } } }
-!         { +output { "x" } }
-!     } define-intrinsic ;
-! 
-! {
-!     { float+ ADDSD }
-!     { float- SUBSD }
-!     { float* MULSD }
-!     { float/f DIVSD }
-! } [
-!     first2 define-float-op
-! ] each
-! 
-! : define-float-jump ( word op -- )
-!     [
-!         [ end-basic-block "x" operand "y" operand COMISD ] % ,
-!     ] [ ] make H{
-!         { +input { { float "x" } { float "y" } } }
-!     } define-if-intrinsic ;
-! 
-! {
-!     { float< JL }
-!     { float<= JLE }
-!     { float> JG }
-!     { float>= JGE }
-!     { float= JE }
-! } [
-!     first2 define-float-jump
-! ] each
-
 ! User environment
 : %userenv ( -- )
     "x" operand "userenv" f dlsym MOV