[Openmcl-cvs-notifications] r8575 - in /trunk/source/lisp-kernel: pmcl-kernel.c x86-asmutils64.s x86-constants64.s x86-exceptions.c
andreas at clozure.com
andreas at clozure.com
Sat Feb 23 09:02:46 EST 2008
Author: andreas
Date: Sat Feb 23 09:02:46 2008
New Revision: 8575
Log:
Make C-callable X86-64 assembler functions platform independent by introduc=
ing symbolic register =
names. Also fix some of the C prototypes for these functions that used "un=
signed" when they =
really meant "natural" (unsigned is 32 bits on Windows).
Modified:
trunk/source/lisp-kernel/pmcl-kernel.c
trunk/source/lisp-kernel/x86-asmutils64.s
trunk/source/lisp-kernel/x86-constants64.s
trunk/source/lisp-kernel/x86-exceptions.c
Modified: trunk/source/lisp-kernel/pmcl-kernel.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/pmcl-kernel.c (original)
+++ trunk/source/lisp-kernel/pmcl-kernel.c Sat Feb 23 09:02:46 2008
@@ -1367,7 +1367,7 @@
This should determine the cache block size. It should also
probably complain if we don't have (at least) SSE2.
*/
-extern int cpuid(int, int*, int*, int*);
+extern int cpuid(natural, natural*, natural*, natural*);
=
#define X86_FEATURE_CMOV (1<<15)
#define X86_FEATURE_CLFLUSH (1<<19)
@@ -1380,7 +1380,7 @@
Boolean
check_x86_cpu()
{
- int eax, ebx, ecx, edx;
+ natural eax, ebx, ecx, edx;
=
eax =3D cpuid(0, &ebx, &ecx, &edx);
=
Modified: trunk/source/lisp-kernel/x86-asmutils64.s
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/x86-asmutils64.s (original)
+++ trunk/source/lisp-kernel/x86-asmutils64.s Sat Feb 23 09:02:46 2008
@@ -19,34 +19,34 @@
=
_beginfile
=
-/* Flush %rsi cache lines, starting at address in %rdi. Each line is */
-/* assumed to be %rdx bytes wide. */
+/* Flush %carg1 cache lines, starting at address in %carg0. Each line is =
*/
+/* assumed to be %carg2 bytes wide. */
_exportfn(C(flush_cache_lines))
- __(cmpq $0,%rsi)
+ __(cmpq $0,%carg1)
__(jmp 2f)
-1: __(clflush (%rdi))
- __(addq %rdx,%rdi)
- __(subq $1,%rsi)
+1: __(clflush (%carg0))
+ __(addq %carg2,%carg0)
+ __(subq $1,%carg1)
2: __(jg 1b) =
__(repret)
_endfn
=
_exportfn(C(current_stack_pointer))
- __(movq %rsp,%rax)
+ __(movq %rsp,%cret)
__(ret)
_endfn
=
_exportfn(C(touch_page))
- __(movq %rdi,(%rdi))
- __(movq $0,(%rdi))
- __(movl $1,%eax)
+ __(movq %carg0,(%carg0))
+ __(movq $0,(%carg0))
+ __(movl $1,%cret_l)
.globl C(touch_page_end)
C(touch_page_end): =
__(ret)
=
_exportfn(C(count_leading_zeros))
- __(bsrq %rdi,%rax)
- __(xorq $63,%rax)
+ __(bsrq %carg0,%cret)
+ __(xorq $63,%cret)
__(ret)
_endfn
=
@@ -55,7 +55,7 @@
_endfn
=
_exportfn(C(set_mxcsr))
- __(pushq %rdi)
+ __(pushq %carg0)
__(ldmxcsr (%rsp))
__(addq $8,%rsp)
__(ret)
@@ -64,7 +64,7 @@
_exportfn(C(get_mxcsr))
__(pushq $0)
__(stmxcsr (%rsp))
- __(popq %rax)
+ __(popq %cret)
__(ret)
_endfn
=
@@ -74,52 +74,52 @@
_exportfn(C(restore_fp_context))
_endfn =
=
-/* Atomically store new value (%rdx) in *%rdi, if old value =3D=3D %rsi. =
*/
+/* Atomically store new value (%carg2) in *%carg0, if old value =3D=3D %c=
arg1. */
/* Return actual old value. */
_exportfn(C(store_conditional))
- __(mov %rsi,%rax)
+ __(mov %carg1,%cret)
__(lock) =
- __(cmpxchgq %rdx,(%rdi))
- __(cmovne %rdx,%rax)
+ __(cmpxchgq %carg2,(%carg0))
+ __(cmovne %carg2,%cret)
__(ret) =
_endfn
=
-/* Atomically store new_value(%rsi) in *%rdi ; return previous contents */
-/* of *%rdi. */
+/* Atomically store new_value(%carg1) in *%carg0 ; return previous conten=
ts */
+/* of *%carg0. */
=
_exportfn(C(atomic_swap))
__(lock) =
- __(xchg %rsi,(%rdi))
- __(mov %rsi,%rax)
- __(ret)
-_endfn
-
-/* Logior the value in *%rdi with the value in %rsi (presumably a */
+ __(xchg %carg1,(%carg0))
+ __(mov %carg1,%cret)
+ __(ret)
+_endfn
+
+/* Logior the value in *%carg0 with the value in %carg1 (presumably=
a */
/* bitmask with exactly 1 bit set.) Return non-zero if any of */
/* the bits in that bitmask were already set. */
_exportfn(C(atomic_ior))
-0: __(movq (%rdi), %rax)
- __(movq %rax,%rcx)
- __(orq %rsi,%rcx)
+0: __(movq (%carg0),%cret)
+ __(movq %cret,%carg2)
+ __(orq %carg1,%carg2)
__(lock)
- __(cmpxchg %rcx,(%rdi))
+ __(cmpxchg %carg2,(%carg0))
__(jnz 0b)
- __(andq %rsi,%rax)
- __(ret)
-_endfn
- =
- =
-/* Logand the value in *rdi with the value in rsi (presumably a bitmask wi=
th exactly 1 */
-/* bit set.) Return the value now in *rdi (for some value of "now" */
+ __(andq %carg1,%cret)
+ __(ret)
+_endfn
+ =
+ =
+/* Logand the value in *carg0 with the value in carg1 (presumably a bitmas=
k with exactly 1 */
+/* bit set.) Return the value now in *carg0 (for some value of "now" */
=
_exportfn(C(atomic_and))
-0: __(movq (%rdi), %rax)
- __(movq %rax,%rcx)
- __(and %rsi,%rcx)
+0: __(movq (%carg0),%cret)
+ __(movq %cret,%carg2)
+ __(and %carg1,%carg2)
__(lock)
- __(cmpxchg %rcx,(%rdi))
+ __(cmpxchg %carg2,(%carg0))
__(jnz 0b)
- __(movq %rcx,%rax)
+ __(movq %carg2,%cret)
__(ret)
_endfn
=
@@ -131,43 +131,42 @@
_endfn
__endif =
=
-/* int cpuid (int code, int *pebx, int *pecx, int *pedx) */
-/* UNIX %rdi, %rsi, %rdx, %rcx */
-/* WIN %ecx, %rdx, %r8, %r9 */ =
+/* int cpuid (natural code, natural *pebx, natural *pecx, natural *pedx) =
*/
_exportfn(C(cpuid))
- __ifdef([WINDOWS])
- __(pushq %r8) /* pecx */
- __(pushq %r9) /* pedx */
- __(movq %rdx, %rsi) /* pebx */
- __(pushq %rbx) /* %rbx is non-volatile */
- __(xorq %rax, %rax)
- __(movl %ecx,%eax)
- __else
- __(pushq %rdx) /* pecx */
- __(pushq %rcx) /* pedx */
- __(pushq %rbx) /* %rbx is non-volatile */
- __(movq %rdi,%rax)
- __endif
- __(xorl %ecx,%ecx)
+ __(pushq %carg2)
+ __(pushq %carg3)
+ __(movq %carg1, %ctemp0)
+ __(pushq %rbx) /* non-volatile reg, clobbered by CPUID */
+ __(movq %carg0, %rax)
+ __(xorq %rcx,%rcx)
__(cpuid)
- __(movl %ebx,(%rsi))
+ __(movq %rbx,(%ctemp0))
__(popq %rbx)
- __(popq %rsi) /* recover pedx */
- __(movl %edx,(%rsi))
- __(popq %rsi) /* recover pecx */
- __(movl %ecx,(%rsi))
+ __(popq %ctemp0) /* recover pedx */
+ __(movq %rdx,(%ctemp0))
+ __(popq %ctemp0) /* recover pecx */
+ __(movq %rcx,(%ctemp0))
__(ret)
_endfn
=
/* switch_to_foreign_stack(new_sp, func, arg_0, arg_1, arg_2, arg_3) */
/* Not fully general, but should get us off of the signal stack */
_exportfn(C(switch_to_foreign_stack))
- __(movq %rdi,%rsp)
- __(movq %rsi,%rax)
- __(movq %rdx,%rdi)
- __(movq %rcx,%rsi)
- __(movq %r8,%rdx)
- __(movq %r9,%rcx)
+ __ifdef([WINDOWS])
+ __(movq 8(%rsp), %ctemp0)
+ __(movq 16(%rsp), %ctemp1)
+ __endif
+ __(movq %carg0,%rsp)
+ __(movq %carg1,%rax)
+ __(movq %carg2,%carg0)
+ __(movq %carg3,%carg1)
+ __ifdef([WINDOWS])
+ __(movq %ctemp0, %carg2)
+ __(movq %ctemp1, %carg3)
+ __else
+ __(movq %carg4,%carg2)
+ __(movq %carg5,%carg3)
+ __endif
__(jmp *%rax)
_endfn
=
@@ -182,7 +181,7 @@
=
=
__ifdef([DARWIN_GS_HACK])
-/* Check (in and ugly, non-portable way) to see if %gs is addressing
+/* Check (in an ugly, non-portable way) to see if %gs is addressing
pthreads data. If it was, return 0; otherwise, assume that it's
addressing a lisp tcr and set %gs to point to the tcr's tcr.osid,
then return 1. */
Modified: trunk/source/lisp-kernel/x86-constants64.s
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/x86-constants64.s (original)
+++ trunk/source/lisp-kernel/x86-constants64.s Sat Feb 23 09:02:46 2008
@@ -80,7 +80,11 @@
temp0..temp2: RBX, R9, R10
save0..save3: R15, R14, R12, R11
arg_x, arg_y, arg_z: R8, RDI, RSI
- fn: R13 =
+ fn: R13
+ rcontext_reg: GS
+
+ Win64 specifics:
+ rcontext_reg: R11
=
*/
=
@@ -130,6 +134,8 @@
define([r15_w],[r15w]) =
define([r15_b],[r15b]) =
=
+/* Registers when using Lisp calling conventions */
+ =
define([imm0],[rax]) =
define([imm0_l],[eax])
define([imm0_w],[ax])
@@ -256,6 +262,132 @@
define([fp15],[xmm15]) =
define([fpzero],[fp15])
=
+/* Registers when running with native C calling conventions */
+
+define([cret],[rax]) =
+ define([cret_l],[eax])
+ define([cret_w],[ax])
+ define([cret_b],[al])
+ define([Rcret],[0])
+ =
+define([ctemp0],[r10])
+ define([ctemp0_l],[r10d])
+ define([ctemp0_w],[r10w])
+ define([ctemp0_b],[r10b])
+ define([Rctemp0],[10])
+ =
+define([ctemp1],[r11]) =
+ define([ctemp1_l],[r11d])
+ define([ctemp1_w],[r11w])
+ define([ctemp1_b],[r11b])
+ define([Rctemp1],[11])
+ =
+define([csave0],[rbx])
+ define([csave0_l],[ebx])
+ define([csave0_w],[bx])
+ define([csave0_b],[bl])
+ define([Rcsave0],[3])
+
+define([csave1],[r12])
+ define([csave1_l],[r12d])
+ define([csave1_w],[r12w])
+ define([csave1_b],[r12b])
+ define([Rcsave1],[12])
+ =
+define([csave2],[r13])
+ define([csave2_l],[r13d])
+ define([csave2_w],[r13w])
+ define([csave2_b],[r13b])
+ define([Rcsave2],[13])
+ =
+define([csave3],[r14])
+ define([csave3_l],[r14d])
+ define([csave3_w],[r14w])
+ define([csave3_b],[r14b])
+ define([Rcsave3],[14])
+ =
+define([csave4],[r15])
+ define([csave4_l],[r15d])
+ define([csave4_w],[r15w])
+ define([csave4_b],[r15b])
+ define([Rcsave4],[15]) =
+
+ifdef([WINDOWS],[
+
+define([carg0],[rcx])
+ define([carg0_l],[ecx])
+ define([carg0_w],[cx])
+ define([carg0_b],[cl])
+ define([Rcarg0],[1])
+ =
+define([carg1],[rdx])
+ define([carg1_l],[edx])
+ define([carg1_w],[dx])
+ define([carg1_b],[dl])
+ define([Rcarg1],[2])
+ =
+define([carg2],[r8])
+ define([carg2_l],[r8d])
+ define([carg2_w],[r8w])
+ define([carg2_b],[r8b])
+ define([Rcarg2],[8])
+
+define([carg3],[r9])
+ define([carg3_l],[r9d])
+ define([carg3_w],[r9w])
+ define([carg3_b],[r9b])
+ define([Rcarg3],[9])
+
+define([csave5],[rsi])
+ define([csave5_l],[esi])
+ define([csave5_w],[si])
+ define([csave5_b],[sil])
+ define([csave5_z],[6])
+
+define([csave6],[rdi])
+ define([csave6_l],[edi])
+ define([csave6_w],[di])
+ define([csave6_b],[dil])
+ define([Rcsave6],[7])
+
+],[
+ =
+define([carg0],[rdi])
+ define([carg0_l],[edi])
+ define([carg0_w],[di])
+ define([carg0_b],[dil])
+ define([Rcarg0],[7])
+
+define([carg1],[rsi])
+ define([carg1_l],[esi])
+ define([carg1_w],[si])
+ define([carg1_b],[sil])
+ define([carg1_z],[6])
+
+define([carg2],[rdx])
+ define([carg2_l],[edx])
+ define([carg2_w],[dx])
+ define([carg2_b],[dl])
+ define([Rcarg2],[2])
+ =
+define([carg3],[rcx])
+ define([carg3_l],[ecx])
+ define([carg3_w],[cx])
+ define([carg3_b],[cl])
+ define([Rcarg3],[1])
+ =
+define([carg4],[r8])
+ define([carg4_l],[r8d])
+ define([carg4_w],[r8w])
+ define([carg4_b],[r8b])
+ define([Rcarg4],[8])
+
+define([carg5],[r9])
+ define([carg5_l],[r9d])
+ define([carg5_w],[r9w])
+ define([carg5_b],[r9b])
+ define([Rcarg5],[9]) =
+])
=
nbits_in_word =3D 64
nbits_in_byte =3D 8
Modified: trunk/source/lisp-kernel/x86-exceptions.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/x86-exceptions.c (original)
+++ trunk/source/lisp-kernel/x86-exceptions.c Sat Feb 23 09:02:46 2008
@@ -433,8 +433,8 @@
return true;
}
=
-extern unsigned get_mxcsr();
-extern void set_mxcsr(unsigned);
+extern natural get_mxcsr();
+extern void set_mxcsr(natural);
=
int
callback_to_lisp (TCR * tcr, LispObj callback_macptr, ExceptionInformation=
*xp,
More information about the Openmcl-cvs-notifications
mailing list