Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support choosing assembly dialect per snippet in clang #101328

Open
dzaima opened this issue Jul 31, 2024 · 2 comments · May be fixed by #101871
Open

Support choosing assembly dialect per snippet in clang #101328

dzaima opened this issue Jul 31, 2024 · 2 comments · May be fixed by #101871

Comments

@dzaima
Copy link

dzaima commented Jul 31, 2024

Currently the primary way to change x86 inline assembly dialect (intel vs AT&T) is -masm=intel & -masm=att. This is a global change, undesired if some #included code assumes AT&T.

Using .intel_syntax breaks on passing operands, as those still get generated with a leading % (#24606; https://godbolt.org/z/1xbfYsWh1). But, even if that were fixed, "m" operands would still likely remain broken due to having a completely different syntax.

A complete solution would be the ability to choose assembly dialect per assembly block. https://reviews.llvm.org/D113707 mentioned a potential option of #pragma clang asm_dialect push "att" & #pragma clang asm_dialect pop, but as far as I can tell nothing like that ever landed.

Motivating use-case is using inline intel assembly in a project which, for valgrind builds, uses <valgrind/valgrind.h> which in turn assumes AT&T assembly.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Jul 31, 2024
@EugeneZelenko EugeneZelenko added inline-asm and removed clang Clang issues not falling into any other category labels Jul 31, 2024
@MitalAshok
Copy link
Contributor

What do you think about the strategy used by #101871? An attribute that can be per-asm statement, or applied to a region of functions with:

#pragma clang attribute push ([[clang::asm_dialect("att")]], apply_to = function)
#include <valgrind/valgrind.h>
#pragma clang attribute pop

Also possibly reach out to Valgrind to allow their headers with both Intel and AT&T syntax: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Multiple-assembler-dialects-in-asm-templates

@dzaima
Copy link
Author

dzaima commented Aug 4, 2024

@MitalAshok Something like that (but worse, i.e. ad-hoc identifiers) was what I was gonna propose if I hadn't found the previous proposal. Your attribute approach would be perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants