diff --git a/0001-Sw64-Add-Sw64-target-support-for-openmp.patch b/0001-Sw64-Add-Sw64-target-support-for-openmp.patch new file mode 100755 index 0000000000000000000000000000000000000000..776b490a8c27a4873c42794acc068694d38b9948 --- /dev/null +++ b/0001-Sw64-Add-Sw64-target-support-for-openmp.patch @@ -0,0 +1,522 @@ +From 42a468c9affe977935ca27c13612abca3b8fdc26 Mon Sep 17 00:00:00 2001 +From: xiaol +Date: Tue, 20 May 2025 17:16:58 +0800 +Subject: [PATCH 4/5] openmp + +--- + openmp/README.rst | 2 +- + openmp/runtime/CMakeLists.txt | 9 +- + openmp/runtime/README.txt | 1 + + .../runtime/cmake/LibompGetArchitecture.cmake | 2 + + openmp/runtime/cmake/LibompMicroTests.cmake | 3 + + openmp/runtime/cmake/LibompUtils.cmake | 2 + + openmp/runtime/cmake/config-ix.cmake | 3 +- + openmp/runtime/src/kmp_affinity.h | 11 ++ + openmp/runtime/src/kmp_os.h | 8 +- + openmp/runtime/src/kmp_platform.h | 6 +- + openmp/runtime/src/kmp_runtime.cpp | 3 +- + openmp/runtime/src/z_Linux_asm.S | 157 +++++++++++++++++- + openmp/runtime/src/z_Linux_util.cpp | 2 +- + openmp/runtime/test/ompt/callback.h | 10 ++ + openmp/runtime/tools/lib/Platform.pm | 7 +- + openmp/runtime/tools/lib/Uname.pm | 2 + + 16 files changed, 215 insertions(+), 13 deletions(-) + +diff --git a/openmp/README.rst b/openmp/README.rst +index 2cdd38220..103cc0dd5 100644 +--- a/openmp/README.rst ++++ b/openmp/README.rst +@@ -137,7 +137,7 @@ Options for all Libraries + Options for ``libomp`` + ---------------------- + +-**LIBOMP_ARCH** = ``aarch64|arm|i386|loongarch64|mic|mips|mips64|ppc64|ppc64le|x86_64|riscv64`` ++**LIBOMP_ARCH** = ``aarch64|arm|i386|loongarch64|mic|mips|mips64|ppc64|ppc64le|x86_64|riscv64|sw_64`` + The default value for this option is chosen based on probing the compiler for + architecture macros (e.g., is ``__x86_64__`` predefined by compiler?). + +diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt +index 2b7a3eb5b..58265a9ea 100644 +--- a/openmp/runtime/CMakeLists.txt ++++ b/openmp/runtime/CMakeLists.txt +@@ -30,7 +30,7 @@ if(${OPENMP_STANDALONE_BUILD}) + # If adding a new architecture, take a look at cmake/LibompGetArchitecture.cmake + libomp_get_architecture(LIBOMP_DETECTED_ARCH) + set(LIBOMP_ARCH ${LIBOMP_DETECTED_ARCH} CACHE STRING +- "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic/mips/mips64/riscv64/loongarch64).") ++ "The architecture to build for (x86_64/i386/arm/ppc64/ppc64le/aarch64/mic/mips/mips64/riscv64/loongarch64/sw_64).") + # Should assertions be enabled? They are on by default. + set(LIBOMP_ENABLE_ASSERTIONS TRUE CACHE BOOL + "enable assertions?") +@@ -63,6 +63,8 @@ else() # Part of LLVM build + set(LIBOMP_ARCH riscv64) + elseif(LIBOMP_NATIVE_ARCH MATCHES "loongarch64") + set(LIBOMP_ARCH loongarch64) ++ elseif(LIBOMP_NATIVE_ARCH MATCHES "sw_64") ++ set(LIBOMP_ARCH sw_64) + else() + # last ditch effort + libomp_get_architecture(LIBOMP_ARCH) +@@ -83,7 +85,7 @@ if(LIBOMP_ARCH STREQUAL "aarch64") + endif() + endif() + +-libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 aarch64_a64fx mic mips mips64 riscv64 loongarch64) ++libomp_check_variable(LIBOMP_ARCH 32e x86_64 32 i386 arm ppc64 ppc64le aarch64 aarch64_a64fx mic mips mips64 riscv64 loongarch64 sw_64) + + set(LIBOMP_LIB_TYPE normal CACHE STRING + "Performance,Profiling,Stubs library (normal/profile/stubs)") +@@ -162,6 +164,7 @@ set(MIPS64 FALSE) + set(MIPS FALSE) + set(RISCV64 FALSE) + set(LOONGARCH64 FALSE) ++set(SW64 FALSE) + if("${LIBOMP_ARCH}" STREQUAL "i386" OR "${LIBOMP_ARCH}" STREQUAL "32") # IA-32 architecture + set(IA32 TRUE) + elseif("${LIBOMP_ARCH}" STREQUAL "x86_64" OR "${LIBOMP_ARCH}" STREQUAL "32e") # Intel(R) 64 architecture +@@ -188,6 +191,8 @@ elseif("${LIBOMP_ARCH}" STREQUAL "riscv64") # RISCV64 architecture + set(RISCV64 TRUE) + elseif("${LIBOMP_ARCH}" STREQUAL "loongarch64") # LoongArch64 architecture + set(LOONGARCH64 TRUE) ++elseif("${LIBOMP_ARCH}" STREQUAL "sw_64") # SW64 architecture ++ set(SW64 TRUE) + endif() + + # Set some flags based on build_type +diff --git a/openmp/runtime/README.txt b/openmp/runtime/README.txt +index ddd8b0e42..2ecc429d9 100644 +--- a/openmp/runtime/README.txt ++++ b/openmp/runtime/README.txt +@@ -55,6 +55,7 @@ Architectures Supported + * MIPS and MIPS64 architecture + * RISCV64 architecture + * LoongArch64 architecture ++* SW64 architecture + + Supported RTL Build Configurations + ================================== +diff --git a/openmp/runtime/cmake/LibompGetArchitecture.cmake b/openmp/runtime/cmake/LibompGetArchitecture.cmake +index c338493ba..9ca2dfc5d 100644 +--- a/openmp/runtime/cmake/LibompGetArchitecture.cmake ++++ b/openmp/runtime/cmake/LibompGetArchitecture.cmake +@@ -49,6 +49,8 @@ function(libomp_get_architecture return_arch) + #error ARCHITECTURE=riscv64 + #elif defined(__loongarch__) && __loongarch_grlen == 64 + #error ARCHITECTURE=loongarch64 ++ #elif defined(__sw_64__) ++ #error ARCHITECTURE=sw_64 + #else + #error ARCHITECTURE=UnknownArchitecture + #endif +diff --git a/openmp/runtime/cmake/LibompMicroTests.cmake b/openmp/runtime/cmake/LibompMicroTests.cmake +index 88deb461d..ff911af4b 100644 +--- a/openmp/runtime/cmake/LibompMicroTests.cmake ++++ b/openmp/runtime/cmake/LibompMicroTests.cmake +@@ -217,6 +217,9 @@ else() + elseif(${LOONGARCH64}) + libomp_append(libomp_expected_library_deps libc.so.6) + libomp_append(libomp_expected_library_deps ld.so.1) ++ elseif(${SW64}) ++ libomp_append(libomp_expected_library_deps libc.so.6.1) ++ libomp_append(libomp_expected_library_deps ld-linux.so.2) + endif() + libomp_append(libomp_expected_library_deps libpthread.so.0 IF_FALSE STUBS_LIBRARY) + libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC) +diff --git a/openmp/runtime/cmake/LibompUtils.cmake b/openmp/runtime/cmake/LibompUtils.cmake +index b5ffc97fc..ce62b077b 100644 +--- a/openmp/runtime/cmake/LibompUtils.cmake ++++ b/openmp/runtime/cmake/LibompUtils.cmake +@@ -111,6 +111,8 @@ function(libomp_get_legal_arch return_arch_string) + set(${return_arch_string} "RISCV64" PARENT_SCOPE) + elseif(${LOONGARCH64}) + set(${return_arch_string} "LOONGARCH64" PARENT_SCOPE) ++ elseif(${SW64}) ++ set(${return_arch_string} "SW64" PARENT_SCOPE) + else() + set(${return_arch_string} "${LIBOMP_ARCH}" PARENT_SCOPE) + libomp_warning_say("libomp_get_legal_arch(): Warning: Unknown architecture: Using ${LIBOMP_ARCH}") +diff --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake +index 9869aeab0..6cbac229e 100644 +--- a/openmp/runtime/cmake/config-ix.cmake ++++ b/openmp/runtime/cmake/config-ix.cmake +@@ -325,7 +325,8 @@ else() + (LIBOMP_ARCH STREQUAL ppc64le) OR + (LIBOMP_ARCH STREQUAL ppc64) OR + (LIBOMP_ARCH STREQUAL riscv64) OR +- (LIBOMP_ARCH STREQUAL loongarch64)) ++ (LIBOMP_ARCH STREQUAL loongarch64)) OR ++ (LIBOMP_ARCH STREQUAL sw_64) + AND # OS supported? + ((WIN32 AND LIBOMP_HAVE_PSAPI) OR APPLE OR (NOT WIN32 AND LIBOMP_HAVE_WEAK_ATTRIBUTE))) + set(LIBOMP_HAVE_OMPT_SUPPORT TRUE) +diff --git a/openmp/runtime/src/kmp_affinity.h b/openmp/runtime/src/kmp_affinity.h +index f27dd9a53..bb9fdc410 100644 +--- a/openmp/runtime/src/kmp_affinity.h ++++ b/openmp/runtime/src/kmp_affinity.h +@@ -281,6 +281,17 @@ public: + #elif __NR_sched_getaffinity != 123 + #error Wrong code for getaffinity system call. + #endif /* __NR_sched_getaffinity */ ++#elif KMP_ARCH_SW64 ++#ifndef __NR_sched_setaffinity ++#define __NR_sched_setaffinity 395 ++#elif __NR_sched_setaffinity != 395 ++#error Wrong code for setaffinity system call. ++#endif /* __NR_sched_setaffinity */ ++#ifndef __NR_sched_getaffinity ++#define __NR_sched_getaffinity 396 ++#elif __NR_sched_getaffinity != 396 ++#error Wrong code for getaffinity system call. ++#endif /* __NR_sched_getaffinity */ + #else + #error Unknown or unsupported architecture + #endif /* KMP_ARCH_* */ +diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h +index fec589ab6..ee1d2c7e3 100644 +--- a/openmp/runtime/src/kmp_os.h ++++ b/openmp/runtime/src/kmp_os.h +@@ -178,7 +178,8 @@ typedef unsigned long long kmp_uint64; + #if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS + #define KMP_SIZE_T_SPEC KMP_UINT32_SPEC + #elif KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \ +- KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 ++ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \ ++ KMP_ARCH_SW64 + #define KMP_SIZE_T_SPEC KMP_UINT64_SPEC + #else + #error "Can't determine size_t printf format specifier." +@@ -213,7 +214,7 @@ typedef kmp_uint32 kmp_uint; + #define KMP_INT_MIN ((kmp_int32)0x80000000) + + // stdarg handling +-#if (KMP_ARCH_ARM || KMP_ARCH_X86_64 || KMP_ARCH_AARCH64) && \ ++#if (KMP_ARCH_ARM || KMP_ARCH_X86_64 || KMP_ARCH_AARCH64 || KMP_ARCH_SW64) && \ + (KMP_OS_FREEBSD || KMP_OS_LINUX) + typedef va_list *kmp_va_list; + #define kmp_va_deref(ap) (*(ap)) +@@ -1043,7 +1044,8 @@ extern kmp_real64 __kmp_xchg_real64(volatile kmp_real64 *p, kmp_real64 v); + #endif /* KMP_OS_WINDOWS */ + + #if KMP_ARCH_PPC64 || KMP_ARCH_ARM || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS || \ +- KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 ++ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \ ++ KMP_ARCH_SW64 + #if KMP_OS_WINDOWS + #undef KMP_MB + #define KMP_MB() std::atomic_thread_fence(std::memory_order_seq_cst) +diff --git a/openmp/runtime/src/kmp_platform.h b/openmp/runtime/src/kmp_platform.h +index fcfd8bc5d..780ff3b18 100644 +--- a/openmp/runtime/src/kmp_platform.h ++++ b/openmp/runtime/src/kmp_platform.h +@@ -93,6 +93,7 @@ + #define KMP_ARCH_MIPS64 0 + #define KMP_ARCH_RISCV64 0 + #define KMP_ARCH_LOONGARCH64 0 ++#define KMP_ARCH_SW64 0 + + #if KMP_OS_WINDOWS + #if defined(_M_AMD64) || defined(__x86_64) +@@ -142,6 +143,9 @@ + #elif defined __loongarch__ && __loongarch_grlen == 64 + #undef KMP_ARCH_LOONGARCH64 + #define KMP_ARCH_LOONGARCH64 1 ++#elif defined __sw_64__ ++#undef KMP_ARCH_SW64 ++#define KMP_ARCH_SW64 1 + #endif + #endif + +@@ -206,7 +210,7 @@ + // TODO: Fixme - This is clever, but really fugly + #if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \ + KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \ +- KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64) ++ KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64 + KMP_ARCH_SW64) + #error Unknown or unsupported architecture + #endif + +diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp +index c63bd1c63..e86d132fe 100644 +--- a/openmp/runtime/src/kmp_runtime.cpp ++++ b/openmp/runtime/src/kmp_runtime.cpp +@@ -8827,7 +8827,8 @@ __kmp_determine_reduction_method( + int atomic_available = FAST_REDUCTION_ATOMIC_METHOD_GENERATED; + + #if KMP_ARCH_X86_64 || KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || \ +- KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 ++ KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \ ++ KMP_ARCH_SW64 + + #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \ + KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD +diff --git a/openmp/runtime/src/z_Linux_asm.S b/openmp/runtime/src/z_Linux_asm.S +index 27b063f09..be3494f95 100644 +--- a/openmp/runtime/src/z_Linux_asm.S ++++ b/openmp/runtime/src/z_Linux_asm.S +@@ -2060,6 +2060,159 @@ __kmp_invoke_microtask: + + #endif /* KMP_ARCH_LOONGARCH64 */ + ++#if KMP_ARCH_SW64 ++ ++//------------------------------------------------------------------------ ++// ++// typedef void (*microtask_t)(int *gtid, int *tid, ...); ++// ++// int __kmp_invoke_microtask(microtask_t pkfn, int gtid, int tid, int argc, ++// void *p_argv[] ++// #if OMPT_SUPPORT ++// , ++// void **exit_frame_ptr ++// #endif ++// ) { ++// #if OMPT_SUPPORT ++// *exit_frame_ptr = OMPT_GET_FRAME_ADDRESS(0); ++// #endif ++// ++// (*pkfn)(>id, &tid, argv[0], ...); ++// ++// return 1; ++// } ++// ++// Parameters: ++// $16: pkfn ++// $17: gtid ++// $18: tid ++// $19: argc ++// $20: p_argv ++// $21: exit_frame_ptr ++// ++// Locals: ++// __gtid: gtid param pushed on stack so can pass >id to pkfn ++// __tid: tid param pushed on stack so can pass &tid to pkfn ++// ++// Temp. registers: ++// ++// $1: used to calculate the dynamic stack size / used to hold pkfn address ++// $2: used as temporary for stack placement calculation ++// $3: used as temporary for stack arguments ++// $4: used as temporary for number of remaining pkfn parms ++// $5: used to traverse p_argv array ++// ++// return: $0 (always 1/TRUE) ++ ++__gtid = -20 ++__tid = -24 ++// -- Begin __kmp_invoke_microtask ++// mark_begin; ++ .text ++ .globl __kmp_invoke_microtask ++ .p2align 1 ++ .type __kmp_invoke_microtask,@function ++__kmp_invoke_microtask: ++ .cfi_startproc ++ ++ // First, save $26 and $15 ++ ldi $30,-16($30) ++ stl $26, 8($30) ++ stl $15, 0($30) ++ ldi $15,16($30) ++ .cfi_def_cfa $15, 0 ++ .cfi_offset $26, -8 ++ .cfi_offset $15, -16 ++ ++ // Compute the dynamic stack size: ++ // ++ // - We need 8 bytes for storing 'gtid' and 'tid', so we can pass them by ++ // reference ++ // - We need 8 bytes for each argument that cannot be passed to the 'pkfn' ++ // function by register. Given that we have 8 of such registers (a[0-5]) ++ // and two + 'argc' arguments (consider >id and &tid), we need to ++ // reserve max(0, argc - 4)*8 extra bytes ++ // ++ // The total number of bytes is then max(0, argc - 4)*8 + 8 ++ ++ // Compute max(0, argc - 4) using the following bithack: ++ // max(0, x) = x - (x & (x >> 31)), where x := argc - 4 ++ // Source: http://graphics.stanford.edu/~seander/bithacks.html//IntegerMinOrMax ++ subw $19, 4, $1 ++ sellt $1, 0, $1, $1 ++ ++ ldi $1,1($1) ++ s8addl $1,0,$1 ++ subl $30, $1, $30 ++ ++ // Align the stack to 16 bytes ++ bic $30, 0xf, $30 ++ mov $16, $27 ++ mov $19, $4 ++ mov $20, $5 ++ ++#if OMPT_SUPPORT ++ // Save frame pointer into exit_frame ++ stl $15, 0($21) ++#endif ++ ++ // Prepare arguments for the pkfn function (first 6 using $16-$21 registers) ++ ++ stw $17, __gtid($15) ++ stw $18, __tid($15) ++ ++ ldi $16, __gtid($15) ++ ldi $17, __tid($15) ++ ++ beq $4, .L_kmp_3 ++ ldl $18, 0($5) ++ ++ ldi $4,-1($4) ++ beq $4, .L_kmp_3 ++ ldl $19, 8($5) ++ ++ ldi $4,-1($4) ++ beq $4, .L_kmp_3 ++ ldl $20, 16($5) ++ ++ ldi $4,-1($4) ++ beq $4, .L_kmp_3 ++ ldl $21, 24($5) ++ ++ // Prepare any additional argument passed through the stack ++ ldi $5, 32($5) ++ mov $30, $2 ++ br $31, .L_kmp_2 ++.L_kmp_1: ++ ldl $3, 0($5) ++ stl $3, 0($2) ++ ldi $5, 8($5) ++ ldi $2, 8($2) ++.L_kmp_2: ++ ldi $4, -1($4) ++ bne $4, .L_kmp_1 ++ ++.L_kmp_3: ++ // Call pkfn function ++ call $26, ($27), 0 ++ ++ // Restore stack and return ++ ++ ldi $0, 1($31) ++ ++ ldi $30,-16($15) ++ ldl $15, 0($30) ++ ldl $26, 8($30) ++ ldi $30,16($30) ++ ret $31,($26),1 ++.Lfunc_end0: ++ .size __kmp_invoke_microtask, .Lfunc_end0-__kmp_invoke_microtask ++ .cfi_endproc ++ ++// -- End __kmp_invoke_microtask ++ ++#endif /* KMP_ARCH_SW64 */ ++ + #if KMP_ARCH_ARM || KMP_ARCH_MIPS + .data + COMMON .gomp_critical_user_, 32, 3 +@@ -2073,7 +2226,7 @@ __kmp_unnamed_critical_addr: + #endif + #endif /* KMP_ARCH_ARM */ + +-#if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 ++#if KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || KMP_ARCH_SW64 + #ifndef KMP_PREFIX_UNDERSCORE + # define KMP_PREFIX_UNDERSCORE(x) x + #endif +@@ -2088,7 +2241,7 @@ KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr): + .size KMP_PREFIX_UNDERSCORE(__kmp_unnamed_critical_addr),8 + #endif + #endif /* KMP_ARCH_PPC64 || KMP_ARCH_AARCH64 || KMP_ARCH_MIPS64 || +- KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 */ ++ KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || KMP_ARCH_SW64 */ + + #if KMP_OS_LINUX + # if KMP_ARCH_ARM || KMP_ARCH_AARCH64 +diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp +index 260b982af..cdfb14687 100644 +--- a/openmp/runtime/src/z_Linux_util.cpp ++++ b/openmp/runtime/src/z_Linux_util.cpp +@@ -2452,7 +2452,7 @@ finish: // Clean up and exit. + #if !(KMP_ARCH_X86 || KMP_ARCH_X86_64 || KMP_MIC || \ + ((KMP_OS_LINUX || KMP_OS_DARWIN) && KMP_ARCH_AARCH64) || \ + KMP_ARCH_PPC64 || KMP_ARCH_RISCV64 || KMP_ARCH_LOONGARCH64 || \ +- KMP_ARCH_ARM) ++ KMP_ARCH_ARM || KMP_ARCH_SW64) + + // we really only need the case with 1 argument, because CLANG always build + // a struct of pointers to shared variables referenced in the outlined function +diff --git a/openmp/runtime/test/ompt/callback.h b/openmp/runtime/test/ompt/callback.h +index 8180b3d26..32af133ad 100644 +--- a/openmp/runtime/test/ompt/callback.h ++++ b/openmp/runtime/test/ompt/callback.h +@@ -212,6 +212,16 @@ ompt_label_##id: + printf("%" PRIu64 ": current_address=%p or %p\n", \ + ompt_get_thread_data()->value, ((char *)addr) - 8, ((char *)addr) - 12) + #endif ++#elif KMP_ARCH_SW64 ++// On SW64 the NOP instruction is 4 bytes long, can be followed by some other ++// instructions (more bytes). ++#define print_possible_return_addresses(addr) \ ++ printf("%" PRIu64 ": current_address=%p or %p or %p or %p or %p or %p or " \ ++ "%p or %p or %p or %p\n", \ ++ ompt_get_thread_data()->value, ((char *)addr) - 16, \ ++ ((char *)addr) - 20, ((char *)addr) - 24, ((char *)addr) - 28, \ ++ ((char *)addr) - 32, ((char *)addr) - 36, ((char *)addr) - 40, \ ++ ((char *)addr) - 44, ((char *)addr) - 48, ((char *)addr) - 52) + #elif KMP_ARCH_LOONGARCH64 + // On LoongArch64 the NOP instruction is 4 bytes long, can be followed by + // inserted jump instruction (another 4 bytes long). And an additional jump +diff --git a/openmp/runtime/tools/lib/Platform.pm b/openmp/runtime/tools/lib/Platform.pm +index d62d450e9..c7da02499 100644 +--- a/openmp/runtime/tools/lib/Platform.pm ++++ b/openmp/runtime/tools/lib/Platform.pm +@@ -65,6 +65,8 @@ sub canon_arch($) { + $arch = "riscv64"; + } elsif ( $arch =~ m{\Aloongarch64} ) { + $arch = "loongarch64"; ++ } elsif ( $arch =~ m{\Asw_64} ) { ++ $arch = "sw_64"; + } else { + $arch = undef; + }; # if +@@ -100,6 +102,7 @@ sub canon_mic_arch($) { + "mips" => "MIPS", + "mips64" => "MIPS64", + "riscv64" => "RISC-V (64-bit)", ++ "sw_64" => "SW64", + ); + + sub legal_arch($) { +@@ -230,6 +233,8 @@ sub target_options() { + $_host_arch = "riscv64"; + } elsif ( $hardware_platform eq "loongarch64" ) { + $_host_arch = "loongarch64"; ++ } elsif ( $hardware_platform eq "sw_64" ) { ++ $_host_arch = "sw_64"; + } else { + die "Unsupported host hardware platform: \"$hardware_platform\"; stopped"; + }; # if +@@ -419,7 +424,7 @@ the script assumes host architecture is target one. + + Input string is an architecture name to canonize. The function recognizes many variants, for example: + C<32e>, C, C, etc. Returned string is a canonized architecture name, +-one of: C<32>, C<32e>, C<64>, C, C, C, C, C, C, C, C or C is input string is not recognized. ++one of: C<32>, C<32e>, C<64>, C, C, C, C, C, C, C, C, C or C is input string is not recognized. + + =item B + +diff --git a/openmp/runtime/tools/lib/Uname.pm b/openmp/runtime/tools/lib/Uname.pm +index 8a976addc..d21550711 100644 +--- a/openmp/runtime/tools/lib/Uname.pm ++++ b/openmp/runtime/tools/lib/Uname.pm +@@ -160,6 +160,8 @@ if ( 0 ) { + $values{ hardware_platform } = "riscv64"; + } elsif ( $values{ machine } =~ m{\Aloongarch64\z} ) { + $values{ hardware_platform } = "loongarch64"; ++ } elsif ( $values{ machine } =~ m{\Asw_64\z} ) { ++ $values{ hardware_platform } = "sw_64"; + } else { + die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped"; + }; # if +-- +2.33.0 + diff --git a/libomp.spec b/libomp.spec index 65fa1ee52caa60c630f16d9e98a2f8f59741b5db..e9ceb4a17fea3059b8adfe75b507bcc24054cb71 100644 --- a/libomp.spec +++ b/libomp.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 %global toolchain clang %undefine _include_frame_pointers @@ -20,6 +20,9 @@ URL: http://openmp.llvm.org Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{libomp_version}/%{libomp_srcdir}.tar.xz Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{libomp_version}/%{cmake_srcdir}.tar.xz +# Patches for Sw64 +Patch1: 0001-Sw64-Add-Sw64-target-support-for-openmp.patch + BuildRequires: clang # For clang-offload-packager BuildRequires: clang-tools-extra @@ -108,6 +111,9 @@ rm -rf %{buildroot}%{_libdir}/libarcher_static.a %changelog +* Fri May 16 2025 swcompiler - 17.0.6-2 +- Add Sw64 support for libomp + * Thu Mar 28 2024 Xiaoping Liu - 17.0.6-1 - update to 17.0.6