Skip to content

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

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions clang/test/CodeGen/X86/inline-asm-cl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// REQUIRES: x86-registered-target
/// Some clang-cl users expect AT&T syntax input even if -x86-asm-syntax=intel is set.
// RUN: %clang_cc1 -triple x86_64-windows-msvc -S -fms-extensions -mllvm -x86-asm-syntax=intel %s -o - | FileCheck %s

// CHECK: .intel_syntax noprefix
// CHECK: mov rax, rax
// CHECK-LABEL: foo:
// CHECK: mov rdx, rdx
// CHECK: mov rdx, rdx

asm("movq %rax, %rax");

void foo() {
asm("movq %rdx, %rdx");

__asm {
mov rdx, rdx
}
}
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ bool AsmPrinter::doInitialization(Module &M) {
emitInlineAsm(
M.getModuleInlineAsm() + "\n", *TM.getMCSubtargetInfo(),
TM.Options.MCOptions, nullptr,
InlineAsm::AsmDialect(TM.getMCAsmInfo()->getAssemblerDialect()));
TM.getTargetTriple().isWindowsMSVCEnvironment()
? InlineAsm::AD_ATT
: InlineAsm::AsmDialect(TM.getMCAsmInfo()->getAssemblerDialect()));
OutStreamer->AddComment("End of file scope inline assembly");
OutStreamer->addBlankLine();
}
Expand Down