This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] S/390: Initial libitm support


Hi,

the patch adds initial libitm support for S/390.  For now it is
software only. I'm working on the hardware support.

The libitm testsuite is clean with the patch.

Comments?

I'll apply the patch in a couple of days in case there are no
objections.

Bye,

-Andreas-


2013-04-22  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.

---
 libitm/config/s390/sjlj.S   |  108 ++++++++++++++++++++++++++++++++++++++++++++
 libitm/config/s390/target.h |   55 ++++++++++++++++++++++
 libitm/configure.tgt        |    4 +
 3 files changed, 167 insertions(+)

Index: libitm/configure.tgt
===================================================================
*** libitm/configure.tgt.orig
--- libitm/configure.tgt
*************** case "${target_cpu}" in
*** 105,110 ****
--- 105,114 ----
  	XCFLAGS="${XCFLAGS} -mrtm"
  	ARCH=x86
  	;;
+   s390|s390x)
+ 	ARCH=s390
+ 	XCFLAGS="${XCFLAGS} -mzarch"
+ 	;;
  
    *)
  	ARCH="${target_cpu}"
Index: libitm/config/s390/target.h
===================================================================
*** /dev/null
--- libitm/config/s390/target.h
***************
*** 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 6-15.  */
+   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 4 and 6.  */
+   long __fpregs[4];
+ #endif
+ } gtm_jmpbuf;
+ 
+ static inline void
+ cpu_relax (void)
+ {
+   __asm volatile ("" : : : "memory");
+ }
+ 
+ } // namespace GTM
Index: libitm/config/s390/sjlj.S
===================================================================
*** /dev/null
--- libitm/config/s390/sjlj.S
***************
*** 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+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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]