On 2026-03-03 12:19, Andrew Stubbs wrote:
On 03/03/2026 11:02, Jakub Jelinek wrote:
On Tue, Mar 03, 2026 at 10:47:07AM +0000, Richard Earnshaw (foss) wrote:
I expect the problem to be non-gas assemblers.  Specifically Sparc/solaris.

I'd code this as minimally as possible, perhaps something like

#ifdef __ELF__
#ifdef __sparc__  // For Solaris assembler --  Check spelling (of __sparc__) 
here
#define TYPE_PFX "@"

Actually, the prefix for SPARC is "#" rather than "@".

#else
#define TYPE_PFX "%%"
#endif

And % is only used on arm/aarch64.  So I think it should be something like:
#ifdef __sparc__
#define TYPE_PFX "#"
#elif defined (__arm__) || defined (__aarch64__)
#define TYPE_PFX "%%"
#else
#define TYPE_PFX "@"
#endif
That will match what GCC actually emits itself.

    Jakub


We're using @ for GCN, but I believe llvm-mc will accept any of #, %, or " too 
(except when one of those is the comment character, but GCN is using ; for comments, 
so that's irrelevant here).

So, to combine all the different remarks, maybe something like this would work 
for all targets?

#ifdef __ELF__
#ifdef __sparc__
#define TYPE_PFX "#"
#elif defined (__arm__) || defined (__aarch64__)
#define TYPE_PFX "%%"
#else
#define TYPE_PFX "@"
#endif

#define ASM_FUNCTION ".global %cc0\n\t.type %cc0, " TYPE_PFX "function\n%cc0:"
#else
#define ASM_FUNCTION ".global %cc0\n%cc0:"
#endif

asm(ASM_FUNCTION :: ":" (asm_fn));
asm(ASM_FUNCTION :: ":" (asm_fn_used));


Kind regards,
Torbjörn

Reply via email to