261 lines
7.4 KiB
Diff
261 lines
7.4 KiB
Diff
|
|
From c506f4995a68274efbd31ede3751b14dc0fa0718 Mon Sep 17 00:00:00 2001
|
||
|
|
From: swcompiler <lc@wxiat.com>
|
||
|
|
Date: Mon, 25 Nov 2024 16:53:43 +0800
|
||
|
|
Subject: [PATCH 11/16] Sw64 Port: libitm
|
||
|
|
|
||
|
|
---
|
||
|
|
libitm/config/linux/sw_64/futex_bits.h | 56 +++++++++++++
|
||
|
|
libitm/config/sw_64/sjlj.S | 112 +++++++++++++++++++++++++
|
||
|
|
libitm/config/sw_64/target.h | 44 ++++++++++
|
||
|
|
libitm/configure.tgt | 1 +
|
||
|
|
4 files changed, 213 insertions(+)
|
||
|
|
create mode 100644 libitm/config/linux/sw_64/futex_bits.h
|
||
|
|
create mode 100644 libitm/config/sw_64/sjlj.S
|
||
|
|
create mode 100644 libitm/config/sw_64/target.h
|
||
|
|
|
||
|
|
diff --git a/libitm/config/linux/sw_64/futex_bits.h b/libitm/config/linux/sw_64/futex_bits.h
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..478a3078a
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/libitm/config/linux/sw_64/futex_bits.h
|
||
|
|
@@ -0,0 +1,56 @@
|
||
|
|
+/* Copyright (C) 2008-2022 Free Software Foundation, Inc.
|
||
|
|
+ Contributed by Richard Henderson <rth@redhat.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/>. */
|
||
|
|
+
|
||
|
|
+/* Provide target-specific access to the futex system call. */
|
||
|
|
+
|
||
|
|
+#ifndef SYS_futex
|
||
|
|
+#define SYS_futex 394
|
||
|
|
+#endif
|
||
|
|
+
|
||
|
|
+static inline long
|
||
|
|
+sys_futex0 (std::atomic<int> *addr, int op, int val)
|
||
|
|
+{
|
||
|
|
+ register long sc_0 __asm__("$0");
|
||
|
|
+ register long sc_16 __asm__("$16");
|
||
|
|
+ register long sc_17 __asm__("$17");
|
||
|
|
+ register long sc_18 __asm__("$18");
|
||
|
|
+ register long sc_19 __asm__("$19");
|
||
|
|
+ long res;
|
||
|
|
+
|
||
|
|
+ sc_0 = SYS_futex;
|
||
|
|
+ sc_16 = (long) addr;
|
||
|
|
+ sc_17 = op;
|
||
|
|
+ sc_18 = val;
|
||
|
|
+ sc_19 = 0;
|
||
|
|
+ __asm volatile("callsys"
|
||
|
|
+ : "=r"(sc_0), "=r"(sc_19)
|
||
|
|
+ : "0"(sc_0), "r"(sc_16), "r"(sc_17), "r"(sc_18), "1"(sc_19)
|
||
|
|
+ : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$22", "$23",
|
||
|
|
+ "$24", "$25", "$27", "$28", "memory");
|
||
|
|
+
|
||
|
|
+ res = sc_0;
|
||
|
|
+ if (__builtin_expect (sc_19, 0))
|
||
|
|
+ res = -res;
|
||
|
|
+ return res;
|
||
|
|
+}
|
||
|
|
diff --git a/libitm/config/sw_64/sjlj.S b/libitm/config/sw_64/sjlj.S
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..c4b74d76b
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/libitm/config/sw_64/sjlj.S
|
||
|
|
@@ -0,0 +1,112 @@
|
||
|
|
+/* Copyright (C) 2009-2022 Free Software Foundation, Inc.
|
||
|
|
+ Contributed by Richard Henderson <rth@redhat.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/>. */
|
||
|
|
+
|
||
|
|
+ .text
|
||
|
|
+ .align 4
|
||
|
|
+ .globl _ITM_beginTransaction
|
||
|
|
+ .ent _ITM_beginTransaction
|
||
|
|
+
|
||
|
|
+#define FRAME 144
|
||
|
|
+
|
||
|
|
+_ITM_beginTransaction:
|
||
|
|
+ ldgp $29, 0($27)
|
||
|
|
+ subl $30, FRAME, $30
|
||
|
|
+ .frame $30, FRAME, $26, 0
|
||
|
|
+ .mask 0x04000000, 0
|
||
|
|
+ stl $26, 0($30)
|
||
|
|
+ .prologue 1
|
||
|
|
+
|
||
|
|
+ stl $9, 8($30)
|
||
|
|
+ stl $10, 16($30)
|
||
|
|
+ addl $30, FRAME, $0
|
||
|
|
+ stl $11, 24($30)
|
||
|
|
+
|
||
|
|
+ stl $12, 32($30)
|
||
|
|
+ stl $13, 40($30)
|
||
|
|
+ stl $14, 48($30)
|
||
|
|
+ stl $15, 56($30)
|
||
|
|
+
|
||
|
|
+ stl $0, 64($30)
|
||
|
|
+ fstd $f2, 72($30)
|
||
|
|
+ fstd $f3, 80($30)
|
||
|
|
+ fstd $f4, 88($30)
|
||
|
|
+
|
||
|
|
+ fstd $f5, 96($30)
|
||
|
|
+ fstd $f6, 104($30)
|
||
|
|
+ fstd $f7, 112($30)
|
||
|
|
+ fstd $f8, 120($30)
|
||
|
|
+
|
||
|
|
+ fstd $f9, 128($30)
|
||
|
|
+ mov $30, $17
|
||
|
|
+#ifdef __PIC__
|
||
|
|
+ unop
|
||
|
|
+ bsr $26, GTM_begin_transaction !samegp
|
||
|
|
+#else
|
||
|
|
+ call $26, GTM_begin_transaction
|
||
|
|
+ ldgp $29, 0($26)
|
||
|
|
+#endif
|
||
|
|
+
|
||
|
|
+ ldl $26, 0($30)
|
||
|
|
+ addl $30, FRAME, $30
|
||
|
|
+ ret
|
||
|
|
+.end _ITM_beginTransaction
|
||
|
|
+
|
||
|
|
+ .align 4
|
||
|
|
+ .globl GTM_longjmp
|
||
|
|
+#ifdef __ELF__
|
||
|
|
+ .hidden GTM_longjmp
|
||
|
|
+#endif
|
||
|
|
+ .ent GTM_longjmp
|
||
|
|
+
|
||
|
|
+GTM_longjmp:
|
||
|
|
+ .prologue 0
|
||
|
|
+ ldl $26, 0($17)
|
||
|
|
+ ldl $9, 8($17)
|
||
|
|
+ ldl $10, 16($17)
|
||
|
|
+ ldl $11, 24($17)
|
||
|
|
+
|
||
|
|
+ ldl $12, 32($17)
|
||
|
|
+ ldl $13, 40($17)
|
||
|
|
+ ldl $14, 48($17)
|
||
|
|
+ ldl $15, 56($17)
|
||
|
|
+
|
||
|
|
+ ldl $1, 64($17)
|
||
|
|
+ fldd $f2, 72($17)
|
||
|
|
+ fldd $f3, 80($17)
|
||
|
|
+ fldd $f4, 88($17)
|
||
|
|
+
|
||
|
|
+ fldd $f5, 96($17)
|
||
|
|
+ fldd $f6, 104($17)
|
||
|
|
+ fldd $f7, 112($17)
|
||
|
|
+ fldd $f8, 120($17)
|
||
|
|
+
|
||
|
|
+ fldd $f9, 128($17)
|
||
|
|
+ mov $16, $0
|
||
|
|
+ mov $1, $30
|
||
|
|
+ ret
|
||
|
|
+.end GTM_longjmp
|
||
|
|
+
|
||
|
|
+#ifdef __linux__
|
||
|
|
+.section .note.GNU-stack, "", @progbits
|
||
|
|
+#endif
|
||
|
|
diff --git a/libitm/config/sw_64/target.h b/libitm/config/sw_64/target.h
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..7c3f1e3bd
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/libitm/config/sw_64/target.h
|
||
|
|
@@ -0,0 +1,44 @@
|
||
|
|
+/* Copyright (C) 2009-2022 Free Software Foundation, Inc.
|
||
|
|
+ Contributed by Richard Henderson <rth@redhat.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 {
|
||
|
|
+
|
||
|
|
+typedef struct gtm_jmpbuf
|
||
|
|
+{
|
||
|
|
+ unsigned long pc;
|
||
|
|
+ unsigned long s[7];
|
||
|
|
+ void *cfa;
|
||
|
|
+ unsigned long f[8];
|
||
|
|
+} gtm_jmpbuf;
|
||
|
|
+
|
||
|
|
+/* The size of one line in hardware caches (in bytes). */
|
||
|
|
+#define HW_CACHELINE_SIZE 64
|
||
|
|
+
|
||
|
|
+static inline void
|
||
|
|
+cpu_relax (void)
|
||
|
|
+{
|
||
|
|
+ __asm volatile ("" : : : "memory");
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+} // namespace HIDDEN
|
||
|
|
diff --git a/libitm/configure.tgt b/libitm/configure.tgt
|
||
|
|
index 06e90973e..d831da5b0 100644
|
||
|
|
--- a/libitm/configure.tgt
|
||
|
|
+++ b/libitm/configure.tgt
|
||
|
|
@@ -118,6 +118,7 @@ EOF
|
||
|
|
*)
|
||
|
|
ARCH="${target_cpu}"
|
||
|
|
;;
|
||
|
|
+ sw_64*) ARCH=sw_64 ;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
# For the benefit of top-level configure, determine if the cpu is supported.
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|