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] Improved boehm-gc support for s390/s390x


Hello,

this patch adds support for the 64-bit s390x-ibm-linux target to boehm-gc,
and implements the inline assembly for atomic operations for both s390
and s390x.  I've also switched from HEURISTIC1 to LINUX_STACKBOTTOM,
as this appears to work better (at least for s390x).

With this patch, 'gctest' passes on both s390-ibm-linux and
s390x-ibm-linux hosts.

Also, in combination with the (separately posted) s390x libffi patch,
s390x-ibm-linux now completes the libjava regression test suite.

OK to commit to the gcc repository?  (How is the process for boehm-gc
changes, are they supposed to go to the master boehm-gc sources first?)


ChangeLog:

      * include/private/gcconfig: Add machine type S390.  Add s390x support.
      * include/private/gc_locks.h (GC_test_and_set): Implement for S390.
      (GC_compare_and_exchange): Likewise.

Index: boehm-gc/include/private/gc_locks.h
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/include/private/gc_locks.h,v
retrieving revision 1.6
diff -c -p -r1.6 gc_locks.h
*** boehm-gc/include/private/gc_locks.h   10 Jun 2002 17:10:21 -0000    1.6
--- boehm-gc/include/private/gc_locks.h   26 Sep 2002 18:31:47 -0000
***************
*** 209,214 ****
--- 209,227 ----
          }
  #       define GC_TEST_AND_SET_DEFINED
  #    endif /* ARM32 */
+ #    ifdef S390
+     inline static int GC_test_and_set(volatile unsigned int *addr) {
+      int ret;
+      __asm__ __volatile__ (
+           "     l     %0,0(%2)\n"
+           "0:   cs    %0,%1,0(%2)\n"
+           "     jl    0b"
+           : "=&d" (ret)
+           : "d" (1), "a" (addr)
+           : "cc", "memory");
+       return ret;
+     }
+ #    endif
  #  endif /* __GNUC__ */
  #  if (defined(ALPHA) && !defined(__GNUC__))
  #    define GC_test_and_set(addr) __cxx_test_and_set_atomic(addr, 1)
***************
*** 330,335 ****
--- 343,369 ----
          }
  #      endif /* 0 */
  #     endif /* IA64 */
+ #     if defined(S390)
+ #      if !defined(GENERIC_COMPARE_AND_SWAP)
+      inline static GC_bool GC_compare_and_exchange(volatile C_word *addr,
+                                          GC_word old, GC_word new_val)
+      {
+        int retval;
+        __asm__ __volatile__ (
+ #          ifndef __s390x__
+           "     cs  %1,%2,0(%3)\n"
+ #          else
+           "     csg %1,%2,0(%3)\n"
+ #      endif
+           "     ipm %0\n"
+           "     srl %0,28\n"
+           : "=&d" (retval), "+d" (old)
+           : "d" (new_val), "a" (addr)
+           : "cc", "memory");
+        return retval == 0;
+     }
+ #      endif
+ #     endif
  #     if !defined(GENERIC_COMPARE_AND_SWAP)
          /* Returns the original value of *addr.     */
          inline static GC_word GC_atomic_add(volatile GC_word *addr,
Index: boehm-gc/include/private/gcconfig.h
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/include/private/gcconfig.h,v
retrieving revision 1.22
diff -c -p -r1.22 gcconfig.h
*** boehm-gc/include/private/gcconfig.h   19 Jul 2002 11:21:36 -0000    1.22
--- boehm-gc/include/private/gcconfig.h   26 Sep 2002 18:31:49 -0000
***************
*** 373,379 ****
  #   define mach_type_known
  # endif
  # if defined(__s390__) && defined(LINUX)
! #    define S370
  #    define mach_type_known
  # endif
  # if defined(__GNU__)
--- 373,379 ----
  #   define mach_type_known
  # endif
  # if defined(__s390__) && defined(LINUX)
! #    define S390
  #    define mach_type_known
  # endif
  # if defined(__GNU__)
***************
*** 422,428 ****
                /*                    (CX_UX and DGUX)            */
                /*               S370           ==> 370-like machine    */
                /*                  running Amdahl UTS4           */
!               /*                  or a 390 running LINUX        */
                /*               ARM32      ==> Intel StrongARM   */
                /*               IA64           ==> Intel IPF           */
                /*                          (e.g. Itanium)  */
--- 422,429 ----
                /*                    (CX_UX and DGUX)            */
                /*               S370           ==> 370-like machine    */
                /*                  running Amdahl UTS4           */
!               /*               S390       ==> 390-like machine      */
!               /*                  running LINUX                 */
                /*               ARM32      ==> Intel StrongARM   */
                /*               IA64           ==> Intel IPF           */
                /*                          (e.g. Itanium)  */
***************
*** 1532,1543 ****
  #   define DATAEND (_end)
  #   define HEURISTIC2
  #   endif
  #   ifdef LINUX
  #       define OS_TYPE "LINUX"
! #       define HEURISTIC1
  #       define DYNAMIC_LOADING
          extern int __data_start[];
  #       define DATASTART ((ptr_t)(__data_start))
  #   endif
  # endif

--- 1533,1561 ----
  #   define DATAEND (_end)
  #   define HEURISTIC2
  #   endif
+ # endif
+
+ # ifdef S390
+ #   define MACH_TYPE "S390"
+ #   define USE_GENERIC_PUSH_REGS
+ #   ifndef __s390x__
+ #   define ALIGNMENT 4
+ #   define CPP_WORDSZ 32
+ #   else
+ #   define ALIGNMENT 8
+ #   define CPP_WORDSZ 64
+ #   define HBLKSIZE 4096
+ #   endif
  #   ifdef LINUX
  #       define OS_TYPE "LINUX"
! #       define LINUX_STACKBOTTOM
  #       define DYNAMIC_LOADING
          extern int __data_start[];
  #       define DATASTART ((ptr_t)(__data_start))
+     extern int _end[];
+ #   define DATAEND (_end)
+ #   define CACHE_LINE_SIZE 256
+ #   define GETPAGESIZE() 4096
  #   endif
  # endif



Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com


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