tune/x86_64.asm: Make work under msys2

David Sparks sparks05 at proton.me
Fri Feb 13 17:49:52 CET 2026


I need it to work under msys2 (mingw), which compiles using
the Microsoft calling convention.

Obviously, passing a pointer in the wrong register doesn't
work so well.

diff --git a/tune/x86_64.asm b/tune/x86_64.asm
index b7ec44c54..91cc4f250 100644
--- a/tune/x86_64.asm
+++ b/tune/x86_64.asm
@@ -40,16 +40,22 @@ C
 C cpuid is used to serialize execution.  On big measurements this won't be
 C significant but it may help make small single measurements more accurate.
 
+ABI_SUPPORT(DOS64)
+ABI_SUPPORT(STD64)
+
+define(`p',       `%rdi')
+IFDOS(`	define(`p',  ``%r9'')	')   C rcx
+
+ASM_START()
+	TEXT
 PROLOGUE(speed_cyclecounter)
-
-	C rdi	p
-
+IFDOS(` movq	%rcx, p		')
 	movq	%rbx, %r10
 	xorl	%eax, %eax
 	cpuid
 	rdtsc
-	movl	%eax, (%rdi)
-	movl	%edx, 4(%rdi)
+	movl	%eax, (p)
+	movl	%edx, 4(p)
 	movq	%r10, %rbx
 	ret
 EPILOGUE()



More information about the gmp-devel mailing list