To adopt the m4 macrology used in GMP, for optionally substituting r0-->0, r1-->1, etc, I tried to copy the m4 macros, including an m4 forloop.
But that didn't work out of the box, and it seems that one complication is that Nettle's uses <> as m4 quote characters. I've used them since I introduced m4 preprocessing back in 2002, and I honestly don't remember why I thought that was a good idea at the time. I guess I found `' ugly, and the autoconf choice of [] didn't work well with assembly syntax (in particular on sparc).
In a few places nettle needs to use < as an operator in m4 eval, and there are workarounds for that using local changequote, with the curious hack
define(<W64_ENTRY>, < changequote([,])dnl ifelse(<<<<<<<<<<<<<<<<<< ignored; only for balancing) ifelse(W64_ABI,yes,[ dnl unconditionally push %rdi, making %rsp 16-byte aligned push %rdi dnl Save %xmm6, ..., if needed ifelse(eval($2 > 6), 1, [ sub [$]eval(16*($2 - 6)), %rsp movdqa %xmm6, 0(%rsp) ]) ifelse(eval($2 > 7), 1, [ movdqa %xmm7, 16(%rsp) ]) ...
So I'm considering changing that, and instead stick to m4 default quotes. Opinions?
Regards, /Niels