[clang] [llvm] [AsmPrinter,X86] Hard code AT&T syntax input for module-level inline assembly for MSVC triples (PR #85668)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 25 12:02:45 PDT 2024


MaskRay wrote:

> Looks like we were able to fix code on our end and this here isn't needed. But maybe the current behavior isn't 100% ideal.

Thanks. I am abandoning this workaround.

> Here's what I think the situation currently is (please correct me if I'm wrong):
> 
> * With clang-cl, you get intel assembly output by default with `/FA`. That's good.
> * With clang, you get AT&T assembly output by default with `-S`, and intel assembly output with -masm=intel. That's good.
> * With clang, the syntax for `asm()` is AT&T by default, and intel with -masm=intel. That's good.
> * With clang-cl, `__asm { ... }` blocks always use Intel syntax. That's good.
> * With clang-cl, the syntax for `asm()` is intel by default, and there's no way to change this. (This is now consistent between module-level assembly and function-local assembly. It's good that they're consistent, that's better than before.)
> 
> The last point seems suboptimal to me. cl.exe doesn't support `asm()`, only `__asm {}`. So users that use `asm()` with clang-cl probably want to share that code with other platforms where they use `asm()` too.
> 
> Ideally, clang-cl could use intel asm output by default, intel asm input for `__asm {}` blocks, but at&t style asm input for `asm()`. And ideally it could also offer a flag to opt in to intel style asm input for `asm()`. (And the pragma mentioned in [reviews.llvm.org/D113707](https://reviews.llvm.org/D113707) might be nice too.)
> 
> Does that sound right?
> 
> (I'm not saying you have to do any of this! Just want to check if we agree on this assessment of the state of the world.)

I agree with the analysis. The original bug for the improvement appears to be https://github.com/llvm/llvm-project/issues/34830#issuecomment-2000044039

I agree that AT&T input `asm()` and Intel output provides most convenience, but I do feel it slightly strange and wonder whether users need an explicit command line option to indicate this preference. @uweigand's  https://reviews.llvm.org/D95444 (which hasn't landed) seems appealing as well, but I haven't read closely these patches.

https://github.com/llvm/llvm-project/pull/85668


More information about the cfe-commits mailing list