0001-Add-ARCv2-ISA-processors-support-to-Zero.patch 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 9a3c2a0714420186ae8d5159d5416c6fa2009ad9 Mon Sep 17 00:00:00 2001
  2. From: Alexey Brodkin <abrodkin@synopsys.com>
  3. Date: Mon, 18 Oct 2021 05:20:05 -0700
  4. Subject: [PATCH] Add ARCv2 ISA processors support to Zero
  5. This adds ARCv2 processors support in OpenJDK via
  6. "Zero Assembly Project" (see https://openjdk.java.net/projects/zero).
  7. That' a purely interpretive mode, so likely not that fast
  8. as JIT'ed version, but for starters it's much better than nothing.
  9. Once all the logistical problems are solved hopefully this
  10. change will be accepted upstream.
  11. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
  12. ---
  13. make/autoconf/libraries.m4 | 8 ++++++++
  14. make/autoconf/platform.m4 | 8 ++++++++
  15. src/hotspot/os/linux/os_linux.cpp | 8 +++++++-
  16. 3 files changed, 23 insertions(+), 1 deletion(-)
  17. diff --git a/make/autoconf/libraries.m4 b/make/autoconf/libraries.m4
  18. index 5120918aed2..f7a99955874 100644
  19. --- a/make/autoconf/libraries.m4
  20. +++ b/make/autoconf/libraries.m4
  21. @@ -146,6 +146,14 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES],
  22. fi
  23. fi
  24. + # Libatomic library
  25. + # 32-bit ARC needs fallback library for 8-byte atomic ops
  26. + # Inspired by a fix for MIPS, see https://github.com/openjdk/jdk/commit/1b3aa3af
  27. + if test "x$OPENJDK_TARGET_OS" = xlinux &&
  28. + (test "x$OPENJDK_TARGET_CPU" = xarc); then
  29. + BASIC_JVM_LIBS="$BASIC_JVM_LIBS -latomic"
  30. + fi
  31. +
  32. # perfstat lib
  33. if test "x$OPENJDK_TARGET_OS" = xaix; then
  34. BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lperfstat"
  35. diff --git a/make/autoconf/platform.m4 b/make/autoconf/platform.m4
  36. index c0f2446dbd7..dc416ece885 100644
  37. --- a/make/autoconf/platform.m4
  38. +++ b/make/autoconf/platform.m4
  39. @@ -54,6 +54,12 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU],
  40. VAR_CPU_BITS=64
  41. VAR_CPU_ENDIAN=little
  42. ;;
  43. + arc)
  44. + VAR_CPU=arc
  45. + VAR_CPU_ARCH=arc
  46. + VAR_CPU_BITS=32
  47. + VAR_CPU_ENDIAN=little
  48. + ;;
  49. arm*)
  50. VAR_CPU=arm
  51. VAR_CPU_ARCH=arm
  52. @@ -563,6 +569,8 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER],
  53. HOTSPOT_$1_CPU_DEFINE=PPC64
  54. # The cpu defines below are for zero, we don't support them directly.
  55. + elif test "x$OPENJDK_$1_CPU" = xarc; then
  56. + HOTSPOT_$1_CPU_DEFINE=ARC
  57. elif test "x$OPENJDK_$1_CPU" = xsparc; then
  58. HOTSPOT_$1_CPU_DEFINE=SPARC
  59. elif test "x$OPENJDK_$1_CPU" = xppc; then
  60. diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
  61. index b08caf4d5d3..2bf084895ba 100644
  62. --- a/src/hotspot/os/linux/os_linux.cpp
  63. +++ b/src/hotspot/os/linux/os_linux.cpp
  64. @@ -1676,6 +1676,9 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  65. #ifndef EM_AARCH64
  66. #define EM_AARCH64 183 /* ARM AARCH64 */
  67. #endif
  68. +#ifndef EM_ARC_COMPACT2
  69. + #define EM_ARC_COMPACT2 195 /* ARC ARCv2 ISA */
  70. +#endif
  71. #ifndef EM_RISCV
  72. #define EM_RISCV 243 /* RISC-V */
  73. #endif
  74. @@ -1700,6 +1703,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  75. {EM_SH, EM_SH, ELFCLASS32, ELFDATA2MSB, (char*)"SuperH BE"},
  76. #endif
  77. {EM_ARM, EM_ARM, ELFCLASS32, ELFDATA2LSB, (char*)"ARM"},
  78. + {EM_ARC_COMPACT2, EM_ARC_COMPACT2, ELFCLASS32, ELFDATA2LSB, (char*)"ARC"},
  79. // we only support 64 bit z architecture
  80. {EM_S390, EM_S390, ELFCLASS64, ELFDATA2MSB, (char*)"IBM System/390"},
  81. {EM_ALPHA, EM_ALPHA, ELFCLASS64, ELFDATA2LSB, (char*)"Alpha"},
  82. @@ -1728,6 +1732,8 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  83. static Elf32_Half running_arch_code=EM_PPC;
  84. #elif (defined AARCH64)
  85. static Elf32_Half running_arch_code=EM_AARCH64;
  86. +#elif (defined ARC)
  87. + static Elf32_Half running_arch_code=EM_ARC_COMPACT2;
  88. #elif (defined ARM)
  89. static Elf32_Half running_arch_code=EM_ARM;
  90. #elif (defined S390)
  91. @@ -1750,7 +1756,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
  92. static Elf32_Half running_arch_code=EM_LOONGARCH;
  93. #else
  94. #error Method os::dll_load requires that one of following is defined:\
  95. - AARCH64, ALPHA, ARM, AMD64, IA32, IA64, LOONGARCH, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, RISCV, S390, SH, __sparc
  96. + AARCH64, ALPHA, ARC ARM, AMD64, IA32, IA64, LOONGARCH, M68K, MIPS, MIPSEL, PARISC, __powerpc__, __powerpc64__, RISCV, S390, SH, __sparc
  97. #endif
  98. // Identify compatibility class for VM's architecture and library's architecture
  99. --
  100. 2.16.2