Clean up x86 support code
							parent
							
								
									a00432b64e
								
							
						
					
					
						commit
						7ff85dd33e
					
				| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
#include "asm.h"
 | 
			
		||||
 | 
			
		||||
/* Note that primitive word definitions are compiled with
 | 
			
		||||
__attribute__((regparm 2), so the pointer to the word object is passed in EAX,
 | 
			
		||||
and the callstack top is passed in EDX */
 | 
			
		||||
 | 
			
		||||
#define ARG0 %eax
 | 
			
		||||
#define ARG1 %edx
 | 
			
		||||
#define XT_REG %ecx
 | 
			
		||||
#define STACK_REG %esp
 | 
			
		||||
#define DS_REG %edi
 | 
			
		||||
 | 
			
		||||
#define CELL_SIZE 4
 | 
			
		||||
 | 
			
		||||
#define PUSH_NONVOLATILE \
 | 
			
		||||
	push %ebx \
 | 
			
		||||
	push %ebp
 | 
			
		||||
 | 
			
		||||
#define POP_NONVOLATILE \
 | 
			
		||||
	pop %ebp \
 | 
			
		||||
	pop %ebx
 | 
			
		||||
 | 
			
		||||
#define QUOT_XT_OFFSET 5
 | 
			
		||||
#define PROFILING_OFFSET 25
 | 
			
		||||
#define WORD_DEF_OFFSET 13
 | 
			
		||||
#define WORD_XT_OFFSET 29
 | 
			
		||||
 | 
			
		||||
/* We pass a function pointer to memcpy in 16(%esp) to work around a Mac OS X
 | 
			
		||||
ABI limitation which would otherwise require us to do a bizzaro PC-relative
 | 
			
		||||
trampoline to retrieve the function address */
 | 
			
		||||
DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
 | 
			
		||||
	mov 4(%esp),%ebp                   /* to */
 | 
			
		||||
	mov 8(%esp),%edx                   /* from */
 | 
			
		||||
	mov 12(%esp),%ecx                  /* length */
 | 
			
		||||
	mov 16(%esp),%eax                  /* memcpy */
 | 
			
		||||
	sub %ecx,%ebp                      /* compute new stack pointer */
 | 
			
		||||
	mov %ebp,%esp
 | 
			
		||||
	push %ecx                          /* pass length */
 | 
			
		||||
	push %edx                          /* pass src */
 | 
			
		||||
	push %ebp                          /* pass dst */
 | 
			
		||||
	call *%eax                         /* call memcpy */
 | 
			
		||||
	add $12,%esp                       /* pop args from the stack */
 | 
			
		||||
	ret                                /* return _with new stack_ */
 | 
			
		||||
 | 
			
		||||
#include "cpu-x86.S"
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
#define FACTOR_CPU_STRING "x86.32"
 | 
			
		||||
 | 
			
		||||
register CELL ds asm("esi");
 | 
			
		||||
register CELL rs asm("edi");
 | 
			
		||||
 | 
			
		||||
#define FASTCALL __attribute__ ((regparm (2)))
 | 
			
		||||
 | 
			
		||||
void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy);
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
#include "asm.h"
 | 
			
		||||
 | 
			
		||||
#define ARG0 %rdi
 | 
			
		||||
#define ARG1 %rsi
 | 
			
		||||
#define XT_REG %rcx
 | 
			
		||||
#define STACK_REG %rsp
 | 
			
		||||
#define DS_REG %r14
 | 
			
		||||
 | 
			
		||||
#define CELL_SIZE 8
 | 
			
		||||
 | 
			
		||||
#define PUSH_NONVOLATILE \
 | 
			
		||||
	push %rbx \
 | 
			
		||||
	push %rbp \
 | 
			
		||||
	push %r12 \
 | 
			
		||||
	push %r13 \
 | 
			
		||||
	push %r16 \
 | 
			
		||||
	push %rax                          /* Alignment */
 | 
			
		||||
 | 
			
		||||
#define POP_NONVOLATILE \
 | 
			
		||||
	pop %rax                           /* Alignment */ \
 | 
			
		||||
	pop %r16 \
 | 
			
		||||
	pop %r13 \
 | 
			
		||||
	pop %r12 \
 | 
			
		||||
	pop %rbp \
 | 
			
		||||
	pop %rbx
 | 
			
		||||
 | 
			
		||||
#define QUOT_XT_OFFSET 13
 | 
			
		||||
#define PROFILING_OFFSET 53
 | 
			
		||||
#define WORD_DEF_OFFSET 29
 | 
			
		||||
#define WORD_XT_OFFSET 61
 | 
			
		||||
 | 
			
		||||
/* We pass a function pointer to memcpy in 16(%esp) to work around a Mac OS X
 | 
			
		||||
ABI limitation which would otherwise require us to do a bizzaro PC-relative
 | 
			
		||||
trampoline to retrieve the function address */
 | 
			
		||||
DEF(void,set_callstack,(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy)):
 | 
			
		||||
	sub %rdx,%rdi                      /* compute new stack pointer */
 | 
			
		||||
	mov %rdi,%rsp
 | 
			
		||||
	call *%rcx                         /* call memcpy */
 | 
			
		||||
	ret                                /* return _with new stack_ */
 | 
			
		||||
 | 
			
		||||
#include "cpu-x86.S"
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
#define FACTOR_CPU_STRING "x86.64"
 | 
			
		||||
 | 
			
		||||
register CELL ds asm("r14");
 | 
			
		||||
register CELL rs asm("r15");
 | 
			
		||||
 | 
			
		||||
#define FASTCALL
 | 
			
		||||
		Loading…
	
		Reference in New Issue