aboutsummaryrefslogtreecommitdiffstats
path: root/translate/grt
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2013-12-17 06:25:53 +0100
committerTristan Gingold <tgingold@free.fr>2013-12-17 06:25:53 +0100
commit48448a12ef628218db298d8b7c6879e28cdd019a (patch)
tree7e612d41dc01c435cf32e3cee029b429c9362bb9 /translate/grt
parent04ad1cd54d99fc3ac3d82c69ee5f7c2db7e2275a (diff)
downloadghdl-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')
-rw-r--r--translate/grt/Makefile.inc2
-rw-r--r--translate/grt/config/amd64.S51
-rwxr-xr-x[-rw-r--r--]translate/grt/config/clock.c0
-rw-r--r--translate/grt/config/i386.S30
-rw-r--r--translate/grt/grt-values.adb4
-rw-r--r--translate/grt/grt-vcd.adb4
6 files changed, 61 insertions, 30 deletions
diff --git a/translate/grt/Makefile.inc b/translate/grt/Makefile.inc
index f0bdf61c6..2cd6722cd 100644
--- a/translate/grt/Makefile.inc
+++ b/translate/grt/Makefile.inc
@@ -62,7 +62,7 @@ ifeq ($(filter-out i%86 darwin%,$(arch) $(osys)),)
GRT_TARGET_OBJS=i386.o linux.o times.o
GRT_EXTRA_LIB=
endif
-ifeq ($(filter-out x84_64 darwin%,$(arch) $(osys)),)
+ifeq ($(filter-out x86_64 darwin%,$(arch) $(osys)),)
GRT_TARGET_OBJS=amd64.o linux.o times.o
GRT_EXTRA_LIB=
endif
diff --git a/translate/grt/config/amd64.S b/translate/grt/config/amd64.S
index 76475acdb..aa9a8c2ae 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 038ce2210..038ce2210 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 2490ea1dd..5c8aa0d3a 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"
diff --git a/translate/grt/grt-values.adb b/translate/grt/grt-values.adb
index 336cf4e0a..97a36ae17 100644
--- a/translate/grt/grt-values.adb
+++ b/translate/grt/grt-values.adb
@@ -350,7 +350,7 @@ package body Grt.Values is
S.Bounds := To_Std_String_Boundp(Bound'Address);
-- find characters at the end...
- Finish := Ghdl_Index_Type(Bound.Dim_1.Length)-1;
+ Finish := Bound.Dim_1.Length - 1;
while White(S.Base.all(Finish)) loop
Finish := Finish - 1;
end loop;
@@ -389,7 +389,7 @@ package body Grt.Values is
end;
if Rti.Kind = Ghdl_Rtik_Type_P64 then
- Mult := Ghdl_I64(Multiple.Unit_64);
+ Mult := Multiple.Unit_64;
else
Mult := Ghdl_I64(Multiple.Unit_32);
end if;
diff --git a/translate/grt/grt-vcd.adb b/translate/grt/grt-vcd.adb
index b262560c6..aa7f352ea 100644
--- a/translate/grt/grt-vcd.adb
+++ b/translate/grt/grt-vcd.adb
@@ -604,7 +604,9 @@ package body Grt.Vcd is
Fact := 0.1;
Delta_Exp := 1;
end if;
- while 1 = 1 loop -- Seek the first digit
+
+ -- Seek the first digit
+ loop
Digit := Digit_Floor(Val_tmp);
if Digit > 0 then
exit;