@@ -0,0 +1,1483 @@
+S/390 TCG code generator as posted before
+
+improvements since last time:
+- don't use R0 (often means "zero", not "register zero")
+- optimized add_i32 immediate
+- formatted for better compliance with the QEMU coding style
+
+Signed-off-by: Ulrich Hecht <uli@suse.de>
+---
+ dyngen-exec.h | 2 +-
+ linux-user/syscall.c | 2 +-
+ s390x.ld | 194 +++++++++
+ tcg/s390/tcg-target.c | 1145 +++++++++++++++++++++++++++++++++++++++++++++++++
+ tcg/s390/tcg-target.h | 76 ++++
+ 5 files changed, 1417 insertions(+), 2 deletions(-)
+ create mode 100644 s390x.ld
+ create mode 100644 tcg/s390/tcg-target.c
+ create mode 100644 tcg/s390/tcg-target.h
+
+diff --git a/dyngen-exec.h b/dyngen-exec.h
+index c007763..606ee11 100644
+--- a/dyngen-exec.h
++++ b/dyngen-exec.h
+@@ -119,7 +119,7 @@ extern int printf(const char *, ...);
+
+ /* The return address may point to the start of the next instruction.
+ Subtracting one gets us the call instruction itself. */
+-#if defined(__s390__)
++#if defined(__s390__) && !defined(__s390x__)
+ # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
+ #elif defined(__arm__)
+ /* Thumb return addresses have the low bit set, so we need to subtract two.
+diff --git a/linux-user/syscall.c b/linux-user/syscall.c
+index 7b57323..4c1961f 100644
+--- a/linux-user/syscall.c
++++ b/linux-user/syscall.c
+@@ -181,7 +181,7 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
+ #define __NR_sys_inotify_add_watch __NR_inotify_add_watch
+ #define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch
+
+-#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__)
++#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__) || defined(__s390x__)
+ #define __NR__llseek __NR_lseek
+ #endif
+
+diff --git a/s390x.ld b/s390x.ld
+new file mode 100644
+index 0000000..7d1f2b7
+--- /dev/null
++++ b/s390x.ld
+@@ -0,0 +1,194 @@
++/* Default linker script, for normal executables */
++OUTPUT_FORMAT("elf64-s390", "elf64-s390",
++ "elf64-s390")
++OUTPUT_ARCH(s390:64-bit)
++ENTRY(_start)
++SEARCH_DIR("/usr/s390x-suse-linux/lib64"); SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/s390x-suse-linux/lib"); SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
++SECTIONS
++{
++ /* Read-only sections, merged into text segment: */
++ PROVIDE (__executable_start = 0x60000000); . = 0x60000000 + SIZEOF_HEADERS;
++ .interp : { *(.interp) }
++ .note.gnu.build-id : { *(.note.gnu.build-id) }
++ .hash : { *(.hash) }
++ .gnu.hash : { *(.gnu.hash) }
++ .dynsym : { *(.dynsym) }
++ .dynstr : { *(.dynstr) }
++ .gnu.version : { *(.gnu.version) }
++ .gnu.version_d : { *(.gnu.version_d) }
++ .gnu.version_r : { *(.gnu.version_r) }
++ .rel.init : { *(.rel.init) }
++ .rela.init : { *(.rela.init) }
++ .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
++ .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
++ .rel.fini : { *(.rel.fini) }
++ .rela.fini : { *(.rela.fini) }
++ .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
++ .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
++ .rel.data.rel.ro : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) }
++ .rela.data.rel.ro : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) }
++ .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
++ .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
++ .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
++ .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
++ .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
++ .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
++ .rel.ctors : { *(.rel.ctors) }
++ .rela.ctors : { *(.rela.ctors) }
++ .rel.dtors : { *(.rel.dtors) }
++ .rela.dtors : { *(.rela.dtors) }
++ .rel.got : { *(.rel.got) }
++ .rela.got : { *(.rela.got) }
++ .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
++ .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
++ .rel.plt : { *(.rel.plt) }
++ .rela.plt : { *(.rela.plt) }
++ .init :
++ {
++ KEEP (*(.init))
++ } =0x07070707
++ .plt : { *(.plt) }
++ .text :
++ {
++ *(.text .stub .text.* .gnu.linkonce.t.*)
++ /* .gnu.warning sections are handled specially by elf32.em. */
++ *(.gnu.warning)
++ } =0x07070707
++ .fini :
++ {
++ KEEP (*(.fini))
++ } =0x07070707
++ PROVIDE (__etext = .);
++ PROVIDE (_etext = .);
++ PROVIDE (etext = .);
++ .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
++ .rodata1 : { *(.rodata1) }
++ .eh_frame_hdr : { *(.eh_frame_hdr) }
++ .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
++ .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
++ /* Adjust the address for the data segment. We want to adjust up to
++ the same address within the page on the next page up. */
++ . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
++ /* Exception handling */
++ .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
++ .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
++ /* Thread Local Storage sections */
++ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
++ .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
++ .preinit_array :
++ {
++ PROVIDE_HIDDEN (__preinit_array_start = .);
++ KEEP (*(.preinit_array))
++ PROVIDE_HIDDEN (__preinit_array_end = .);
++ }
++ .init_array :
++ {
++ PROVIDE_HIDDEN (__init_array_start = .);
++ KEEP (*(SORT(.init_array.*)))
++ KEEP (*(.init_array))
++ PROVIDE_HIDDEN (__init_array_end = .);
++ }
++ .fini_array :
++ {
++ PROVIDE_HIDDEN (__fini_array_start = .);
++ KEEP (*(.fini_array))
++ KEEP (*(SORT(.fini_array.*)))
++ PROVIDE_HIDDEN (__fini_array_end = .);
++ }
++ .ctors :
++ {
++ /* gcc uses crtbegin.o to find the start of
++ the constructors, so we make sure it is
++ first. Because this is a wildcard, it
++ doesn't matter if the user does not
++ actually link against crtbegin.o; the
++ linker won't look for a file to match a
++ wildcard. The wildcard also means that it
++ doesn't matter which directory crtbegin.o
++ is in. */
++ KEEP (*crtbegin.o(.ctors))
++ KEEP (*crtbegin?.o(.ctors))
++ /* We don't want to include the .ctor section from
++ the crtend.o file until after the sorted ctors.
++ The .ctor section from the crtend file contains the
++ end of ctors marker and it must be last */
++ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
++ KEEP (*(SORT(.ctors.*)))
++ KEEP (*(.ctors))
++ }
++ .dtors :
++ {
++ KEEP (*crtbegin.o(.dtors))
++ KEEP (*crtbegin?.o(.dtors))
++ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
++ KEEP (*(SORT(.dtors.*)))
++ KEEP (*(.dtors))
++ }
++ .jcr : { KEEP (*(.jcr)) }
++ .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
++ .dynamic : { *(.dynamic) }
++ . = DATA_SEGMENT_RELRO_END (0, .);
++ .got : { *(.got.plt) *(.got) }
++ .data :
++ {
++ *(.data .data.* .gnu.linkonce.d.*)
++ SORT(CONSTRUCTORS)
++ }
++ .data1 : { *(.data1) }
++ _edata = .; PROVIDE (edata = .);
++ __bss_start = .;
++ .bss :
++ {
++ *(.dynbss)
++ *(.bss .bss.* .gnu.linkonce.b.*)
++ *(COMMON)
++ /* Align here to ensure that the .bss section occupies space up to
++ _end. Align after .bss to ensure correct alignment even if the
++ .bss section disappears because there are no input sections.
++ FIXME: Why do we need it? When there is no .bss section, we don't
|