sjlj.S: New file.
authorAndreas Krebbel <Andreas.Krebbel@de.ibm.com>
Tue, 23 Apr 2013 11:33:50 +0000 (11:33 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Tue, 23 Apr 2013 11:33:50 +0000 (11:33 +0000)
2013-04-23  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

* config/s390/sjlj.S: New file.
* config/s390/target.h: New file.
* configure.tgt: Set options for S/390.

From-SVN: r198190

gcc/ChangeLog
libitm/config/s390/sjlj.S [new file with mode: 0644]
libitm/config/s390/target.h [new file with mode: 0644]
libitm/configure.tgt

index 376ca5141eba0054d16cac8f72e74ac81bc4d780..a5e1c236b35a06684dedddde1b6591a08c6d52f3 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-23  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * config/s390/sjlj.S: New file.
+       * config/s390/target.h: New file.
+       * configure.tgt: Set options for S/390.
+
 2013-04-23  Andreas Schwab  <schwab@linux-m68k.org>
 
        * coretypes.h (gimple_stmt_iterator): Add struct to make
diff --git a/libitm/config/s390/sjlj.S b/libitm/config/s390/sjlj.S
new file mode 100644 (file)
index 0000000..592d9af
--- /dev/null
@@ -0,0 +1,108 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel <krebbel@linux.vnet.ibm.com>
+
+   This file is part of the GNU Transactional Memory Library (libitm).
+
+   Libitm is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+
+#include "asmcfi.h"
+
+.text
+       .align 4
+.globl _ITM_beginTransaction
+       .type _ITM_beginTransaction, @function
+
+       /* _ITM_beginTransaction (int props); props -> r2 */
+_ITM_beginTransaction:
+       cfi_startproc
+#ifdef __s390x__
+       lgr     %r3,%r15        /* backup stack pointer */
+       aghi    %r15,-304       /* jump buffer (144) + reg save area (160) */
+       cfi_adjust_cfa_offset(304)
+       stmg    %r6,%r14,160(%r15)
+       stg     %r3,72+160(%r15) /* store the old stack pointer */
+       std     %f8,80+160(%r15)
+       std     %f9,88+160(%r15)
+       std     %f10,96+160(%r15)
+       std     %f11,104+160(%r15)
+       std     %f12,112+160(%r15)
+       std     %f13,120+160(%r15)
+       std     %f14,128+160(%r15)
+       std     %f15,136+160(%r15)
+       la      %r3,160(%r15)   /* second argument to GTM_begin_transaction */
+       brasl   %r14,GTM_begin_transaction
+       lg      %r1,64+160(%r15)
+       aghi    %r15,304
+       cfi_adjust_cfa_offset(-304)
+       br      %r1
+#else
+       lr      %r3,%r15        /* backup stack pointer */
+       ahi     %r15,-152       /* jump buffer (56) + reg save area (96) */
+       cfi_adjust_cfa_offset(152)
+       stm     %r6,%r14,96(%r15)
+       st      %r3,36+96(%r15) /* store the old stack pointer */
+       std     %f4,40+96(%r15)
+       std     %f6,48+96(%r15)
+       la      %r3,96(%r15)    /* second argument to GTM_begin_transaction */
+       /* begin_transaction (uint32_t prop, const gtm_jmpbuf *jb) */
+       brasl   %r14,GTM_begin_transaction /* requires mzarch */
+       l       %r1,32+96(%r15)
+       ahi     %r15,152
+       cfi_adjust_cfa_offset(-152)
+       br      %r1
+#endif
+       cfi_endproc
+
+       .size _ITM_beginTransaction, .-_ITM_beginTransaction
+
+       .align 4
+.globl GTM_longjmp
+       .type GTM_longjmp, @function
+       .hidden GTM_longjmp
+
+       /* uint32_t GTM_longjmp (uint32_t, const gtm_jmpbuf *, uint32_t) */
+GTM_longjmp:
+       /* First parameter becomes the return value of
+          _ITM_beginTransaction (r2).
+          Third parameter is ignored for now.  */
+       cfi_startproc
+#ifdef __s390x__
+       ld      %f8,80(%r3)
+       ld      %f9,88(%r3)
+       ld      %f10,96(%r3)
+       ld      %f11,104(%r3)
+       ld      %f12,112(%r3)
+       ld      %f13,120(%r3)
+       ld      %f14,128(%r3)
+       ld      %f15,136(%r3)
+       lmg     %r6,%r15,0(%r3)
+       br      %r14
+#else
+       ld      %f4,40(%r3)
+       ld      %f6,48(%r3)
+       lm      %r6,%r15,0(%r3)
+       br      %r14
+#endif
+       cfi_endproc
+
+       .size GTM_longjmp, .-GTM_longjmp
+
+       .section .note.GNU-stack, "", @progbits
diff --git a/libitm/config/s390/target.h b/libitm/config/s390/target.h
new file mode 100644 (file)
index 0000000..a102e1e
--- /dev/null
@@ -0,0 +1,55 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel <krebbel@linux.vnet.ibm.com>.
+
+   This file is part of the GNU Transactional Memory Library (libitm).
+
+   Libitm is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+namespace GTM HIDDEN {
+
+#define HW_CACHELINE_SIZE 256
+
+typedef struct gtm_jmpbuf
+{
+  /* We save registers r6-r14.  */
+  long int __gregs[9];
+  /* r15 is stored into cfa field.  It needs to be named that way
+     since tls.h is accessing the field by name.  Be aware that this
+     is not actually what we consider the CFA on s390 (since there is
+     a fix offset between sp and CFA).  It is merely the saved stack
+     pointer.  */
+  void *cfa;
+
+#ifdef __s390x__
+  /* We save fpu registers f8 - f15.  */
+  long __fpregs[8];
+#else
+  /* We save fpu registers f4 and f6.  */
+  long __fpregs[4];
+#endif
+} gtm_jmpbuf;
+
+static inline void
+cpu_relax (void)
+{
+  __asm volatile ("" : : : "memory");
+}
+
+} // namespace GTM
index 84824ca16f0e4b7cd067280fc3e411821b8b47b3..ab3953b16d726962fd1f1b661b3973a9762a7e22 100644 (file)
@@ -105,6 +105,10 @@ case "${target_cpu}" in
        XCFLAGS="${XCFLAGS} -mrtm"
        ARCH=x86
        ;;
+  s390|s390x)
+       ARCH=s390
+       XCFLAGS="${XCFLAGS} -mzarch"
+       ;;
 
   *)
        ARCH="${target_cpu}"