AT&T inline assembly macros

I would like to add support for AT&T style ASM macros to Clang, but

this will be my first experience changing Clang. Would anybody

volunteer to exchange email related to this topic? I’d like it if

someone could steer me back to the right course if I head down the

wrong path.

There are some unfortunate “features” in asm macros. For instance

they don’t lex the same as C. What constitutes a token in C isn’t

necessarily the same in assembly. Another issue is how asm macros

“return” a result. In the following example the result is “returned”

by writing to the ABI integer result register.

However, one might argue that ASM macros are easier to read than GNU

style inline assembly.

Here’s a link that defines AT&T style ASM macros:

http://www.vxdev.com/docs/vx55man/diab5.0ppc/c-embed_.htm#2999814

An ASM macro behaves similarly to a preprocessor macro. It’s expanded

(or inlined) at the call site. Example:

asm int f(int x) {

%reg x

!“r0”

add r0,x,x

}

int y(int p) {

return f(p);

}

This would be similar to the GNU asm:

int y(int x) {

register int result;

asm (“add %0,%1,%1”

:"=r" (result) /output/

: “r” (x) /input/

);

return result;

}

Thanks in advance

The first question I have is: why? Really -- why is adding this
feature valuable enough to justify the effort and the extra complexity
in Clang? What are the benefits, and the other downsides?

I don't know the answers, or whether it's worthwhile, but the bar to
adding such a feature should be reasonably high if it's expected to be
included in mainline Clang (rather than in a private fork), including
having confidence that there are (and will continue to be) qualified
maintainers.

-- James