]> gitweb.factorcode.org Git - factor.git/commitdiff
update M\ int-regs param-regs for x86-32 to give input regs for thiscall/fastcall
authorJoe Groff <arcata@gmail.com>
Thu, 1 Apr 2010 10:35:37 +0000 (03:35 -0700)
committerJoe Groff <arcata@gmail.com>
Thu, 1 Apr 2010 10:35:37 +0000 (03:35 -0700)
basis/cpu/x86/32/32.factor

index df5bdd2bb4396103f14dd085acb9ed6ed3b09f10..c707294e42f85334135d5fa8b374ab8a437b8450 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: locals alien.c-types alien.libraries alien.syntax arrays
-kernel fry math namespaces sequences system layouts io
+USING: locals alien alien.c-types alien.libraries alien.syntax
+arrays kernel fry math namespaces sequences system layouts io
 vocabs.loader accessors init combinators command-line make
 compiler compiler.units compiler.constants compiler.alien
 compiler.codegen compiler.codegen.fixup
@@ -83,11 +83,18 @@ M: x86.32 return-struct-in-registers? ( c-type -- ? )
 : struct-return@ ( n -- operand )
     [ next-stack@ ] [ stack-frame get params>> local@ ] if* ;
 
-! On x86, parameters are never passed in registers.
+! On x86, parameters are usually never passed in registers, except with Microsoft's
+! "thiscall" and "fastcall" abis
 M: int-regs return-reg drop EAX ;
-M: int-regs param-regs 2drop { } ;
 M: float-regs param-regs 2drop { } ;
 
+M: int-regs param-regs
+    nip {
+        { thiscall [ { ECX     } ] }
+        { fastcall [ { ECX EDX } ] }
+        [ drop { } ]
+    } case ;
+
 GENERIC: load-return-reg ( src rep -- )
 GENERIC: store-return-reg ( dst rep -- )