[cfe-dev] asm directive: symbolic label syntax

Alexander von Below via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 10 03:27:28 PDT 2021


Helllo,

I have tried to adapt gnu as code for Apple Silicon, and I have found explanations for most differences. There is one issue I still have:

In inline C assembly, the following works on the GNU toolchain:

asm (
	"MOV	X4, %2\n"
	"loop:	LDRB	W5, [%1], #1\n"
	"CMP	W5, #'z'\n"
	"BGT	cont\n"
	"CMP	W5, #'a'\n"
	"BLT	cont\n"
	"SUB	W5, W5, #('a'-'A')\n"
	"cont:	STRB	W5, [%2], #1\n"
	"CMP	W5, #0\n"
	"B.NE	loop\n“
// …
);

However, on the clang toolchain, I apparently must replace the forward label ‚cont‘ with a numeric value, like this (note: the backward label 'loop‘ still works):

asm
(
	"MOV	X4, %2\n"
	"loop:	LDRB	W5, [%1], #1\n"
	"CMP	W5, #'z'\n"
	"BGT	2f\n"
	"CMP	W5, #'a'\n"
	"BLT	2f\n"
	"SUB	W5, W5, #('a'-'A')\n"
	"2:		STRB	W5, [%2], #1\n"
	"CMP	W5, #0\n"
	"B.NE	loop\n“
//…
);

When using as by itself and not in inline assembly, the numeric label works.

Is there a reason for this? Is this a bug? Can I find any sort of documentation on the (inline) assembly syntax for clang?

Thanks a lot!

Alex


https://github.com/below/HelloSilicon#listing-9-8




More information about the cfe-dev mailing list