[Openmp-commits] [openmp] [openmp] Add initial ARM64EC support (PR #138769)

Martin Storsjö via Openmp-commits openmp-commits at lists.llvm.org
Wed May 7 13:57:33 PDT 2025


================
@@ -1301,6 +1302,106 @@ KMP_LABEL(kmp_no_args):
 // '
 #if (KMP_OS_LINUX || KMP_OS_DARWIN || KMP_OS_WINDOWS) && (KMP_ARCH_AARCH64 || KMP_ARCH_AARCH64_32)
 
+#ifdef __arm64ec__
+
+//------------------------------------------------------------------------
+// int
+// __kmp_invoke_microtask( void (*pkfn) (int gtid, int tid, ...),
+//                         int gtid, int tid,
+//                         int argc, void *p_argv[]) {
+//   (*pkfn)( & gtid, & tid, argv[0], ... );
+//   return 1;
+// }
+//
+// parameters:
+//	x0:	pkfn
+//	w1:	gtid
+//	w2:	tid
+//	w3:	argc
+//	x4:	p_argv
+//
+// locals:
+//	__gtid:	gtid parm pushed on stack so can pass &gtid to pkfn
+//	__tid:	tid parm pushed on stack so can pass &tid to pkfn
+//
+// reg temps:
+//	 x8:	used as temporary for stack placement calculation
+//	 w9:	used as temporary for number of pkfn parms
+//	x10:	used to traverse p_argv array
+//	x11:	used to hold pkfn address
+//	x12:	used as temporary for stack parameters
+//	x19:	used to preserve exit_frame_ptr, callee-save
+//
+// return:	w0	(always 1/TRUE)
+//
+
+__gtid = 4
+__tid = 8
+
+// -- Begin __kmp_invoke_microtask
+// mark_begin;
+	.section .text,"xr",discard,"#__kmp_invoke_microtask"
+	.globl "#__kmp_invoke_microtask"
+	ALIGN 2
+"#__kmp_invoke_microtask":
+	stp	x29, x30, [sp, #-16]!
+	mov	x29, sp
+
+	mov	w9, #1
+	add	w9, w9, w3, lsr #1
+	sub	sp, sp, w9, uxtw #4
+	mov	x8, sp
+
+	mov	x11, x0
+	str	w1, [x29, #-__gtid]
+	str	w2, [x29, #-__tid]
+	mov	w9, w3
+	mov	x10, x4
+
+	sub	x0, x29, #__gtid
+	sub	x1, x29, #__tid
+	mov     x4, sp
+	mov     w5, #0
+
+	cbz	w9, KMP_LABEL(kmp_1)
+	ldr	x2, [x10]
+
+	sub	w9, w9, #1
+	cbz	w9, KMP_LABEL(kmp_1)
+	ldr	x3, [x10, #8]!
----------------
mstorsjo wrote:

Another aspect overall here, is that openmp involves a lot of compiler generated calls to the helper functions; I'm curious about whether all of that really works out correctly without any further touches anywhere; both for the simple case of everything compiled as arm64ec (which would be fine if as such as a first step, if that works). Mixing in object files built as x86_64 would be the advanced case...

https://github.com/llvm/llvm-project/pull/138769


More information about the Openmp-commits mailing list