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 | |
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')
-rw-r--r-- | translate/grt/config/amd64.S | 51 | ||||
-rwxr-xr-x[-rw-r--r--] | translate/grt/config/clock.c | 0 | ||||
-rw-r--r-- | translate/grt/config/i386.S | 30 |
3 files changed, 55 insertions, 26 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" diff --git a/translate/grt/config/clock.c b/translate/grt/config/clock.c index 038ce22..038ce22 100644..100755 --- a/translate/grt/config/clock.c +++ b/translate/grt/config/clock.c diff --git a/translate/grt/config/i386.S b/translate/grt/config/i386.S index 2490ea1..5c8aa0d 100644 --- a/translate/grt/config/i386.S +++ b/translate/grt/config/i386.S @@ -18,7 +18,7 @@ */ .file "i386.S" .version "01.01" - + .text #ifdef __ELF__ @@ -34,7 +34,7 @@ #define END(func) #define NAME(name) name #endif - + /* Function called to loop on the process. */ ENTRY(grt_stack_loop) call *4(%esp) @@ -50,7 +50,7 @@ ENTRY(grt_stack_create) movl %esp,%ebp /* Keep aligned (call + pushl + 8 = 16 bytes). */ subl $8,%esp - + /* Allocate the stack, and exit in case of failure */ call NAME(grt_stack_allocate) testl %eax,%eax @@ -58,7 +58,7 @@ ENTRY(grt_stack_create) /* Note: %EAX contains the address of the stack_context. This is also the top of the stack. */ - + /* Prepare stack. */ /* The function to be executed. */ movl 8(%ebp), %ecx @@ -67,7 +67,13 @@ ENTRY(grt_stack_create) movl 12(%ebp), %ecx movl %ecx, -8(%eax) /* The return function. */ +#if __APPLE__ + call ___x86.get_pc_thunk.cx +L1$pb: + movl L_grt_stack_loop$non_lazy_ptr-L1$pb(%ecx), %eax +#else movl $NAME(grt_stack_loop), -12(%eax) +#endif /* The context. */ movl %ebx, -16(%eax) movl %esi, -20(%eax) @@ -109,5 +115,19 @@ ENTRY(grt_stack_switch) ret END(grt_stack_switch) - + +#if __APPLE__ + .section __TEXT,__textcoal_nt,coalesced,pure_instructions + .weak_definition ___x86.get_pc_thunk.cx + .private_extern ___x86.get_pc_thunk.cx +___x86.get_pc_thunk.cx: + movl (%esp), %ecx + ret + + .section __IMPORT,__pointers,non_lazy_symbol_pointers +L_grt_stack_loop$non_lazy_ptr: + .indirect_symbol _grt_stack_loop + .long 0 +#endif + .ident "Written by T.Gingold" |