diff options
author | Tristan Gingold | 2013-12-17 06:25:53 +0100 |
---|---|---|
committer | Tristan Gingold | 2013-12-17 06:25:53 +0100 |
commit | 48448a12ef628218db298d8b7c6879e28cdd019a (patch) | |
tree | 7e612d41dc01c435cf32e3cee029b429c9362bb9 /translate/grt/config/amd64.S | |
parent | 04ad1cd54d99fc3ac3d82c69ee5f7c2db7e2275a (diff) | |
download | ghdl-48448a12ef628218db298d8b7c6879e28cdd019a.tar.gz ghdl-48448a12ef628218db298d8b7c6879e28cdd019a.tar.bz2 ghdl-48448a12ef628218db298d8b7c6879e28cdd019a.zip |
Sync tree: add parsing of AMS-VHDL, add Darwin syntax in asm files.
Diffstat (limited to 'translate/grt/config/amd64.S')
-rw-r--r-- | translate/grt/config/amd64.S | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/translate/grt/config/amd64.S b/translate/grt/config/amd64.S index 76475ac..aa9a8c2 100644 --- a/translate/grt/config/amd64.S +++ b/translate/grt/config/amd64.S @@ -18,26 +18,34 @@ */ .file "amd64.S" .version "01.01" - + +#ifdef __ELF__ +#define ENTRY(func) .align 4; .globl func; .type func,@function; func: +#define END(func) .size func, . - func +#define NAME(name) name +#elif __APPLE__ +#define ENTRY(func) .align 4; .globl _##func; _##func: +#define END(func) +#define NAME(name) _##name +#else +#define ENTRY(func) .align 4; func: +#define END(func) +#define NAME(name) name +#endif .text - /* Function called to loop on the process. */ - .align 4 - .type grt_stack_loop,@function -grt_stack_loop: + /* Function called to loop on the process. */ +ENTRY(grt_stack_loop) mov 0(%rsp),%rdi call *8(%rsp) - jmp grt_stack_loop - .size grt_stack_loop, . - grt_stack_loop + jmp NAME(grt_stack_loop) +END(grt_stack_loop) /* function Stack_Create (Func : Address; Arg : Address) return Stack_Type; Args: FUNC (RDI), ARG (RSI) */ - .align 4 - .globl grt_stack_create - .type grt_stack_create,@function -grt_stack_create: +ENTRY(grt_stack_create) /* Standard prologue. */ pushq %rbp movq %rsp,%rbp @@ -45,15 +53,15 @@ grt_stack_create: sub $0x10,%rsp mov %rdi,-8(%rbp) mov %rsi,-16(%rbp) - + /* Allocate the stack, and exit in case of failure */ - callq grt_stack_allocate + callq NAME(grt_stack_allocate) test %rax,%rax je .Ldone /* Note: %RAX contains the address of the stack_context. This is also the top of the stack. */ - + /* Prepare stack. */ /* The function to be executed. */ mov -8(%rbp), %rdi @@ -62,7 +70,12 @@ grt_stack_create: mov -16(%rbp), %rsi mov %rsi, -16(%rax) /* The return function. Must be 8 mod 16. */ +#if __APPLE__ + movq _grt_stack_loop@GOTPCREL(%rip), %rsi + movq %rsi, -24(%rax) +#else movq $grt_stack_loop, -24(%rax) +#endif /* The context. */ mov %rbp, -32(%rax) mov %rbx, -40(%rax) @@ -78,16 +91,13 @@ grt_stack_create: .Ldone: leave ret - .size grt_stack_create,. - grt_stack_create +END(grt_stack_create) - .align 4 - .globl grt_stack_switch /* Arguments: TO (RDI), FROM (RSI) [VAL (RDX)] Both are pointers to a stack_context. */ - .type grt_stack_switch,@function -grt_stack_switch: +ENTRY(grt_stack_switch) /* Save call-used registers. */ pushq %rbp pushq %rbx @@ -110,7 +120,6 @@ grt_stack_switch: movq %rdx, %rax /* Run. */ ret - .size grt_stack_switch, . - grt_stack_switch +END(grt_stack_switch) - .ident "Written by T.Gingold" |