Index: llvm/include/llvm/Target/TargetMachine.h =================================================================== --- llvm/include/llvm/Target/TargetMachine.h +++ llvm/include/llvm/Target/TargetMachine.h @@ -485,6 +485,10 @@ virtual bool useIPRA() const { return false; } + + /// The default variant to use in unqualified `asm` instructions. + /// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`. + virtual int unqualifiedInlineAsmVariant() const { return 0; } }; /// Helper method for getting the code model, returning Default if Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -277,7 +277,7 @@ int CurVariant = -1; // The number of the {.|.|.} region we are in. const char *LastEmitted = AsmStr; // One past the last character emitted. unsigned NumOperands = MI->getNumOperands(); - int AsmPrinterVariant = MAI->getAssemblerDialect(); + int AsmPrinterVariant = MMI->getTarget().unqualifiedInlineAsmVariant(); if (MAI->getEmitGNUAsmStartIndentationMarker()) OS << '\t'; Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h =================================================================== --- llvm/lib/Target/PowerPC/PPCTargetMachine.h +++ llvm/lib/Target/PowerPC/PPCTargetMachine.h @@ -68,6 +68,8 @@ } bool isLittleEndian() const; + + int unqualifiedInlineAsmVariant() const override { return 1; } }; } // end namespace llvm Index: llvm/test/CodeGen/X86/asm-dialect.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/asm-dialect.ll @@ -0,0 +1,24 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -o - \ +; RUN: | FileCheck --check-prefix=OUTPUT_ATT %s +; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -x86-asm-syntax=intel -o - \ +; RUN: | FileCheck --check-prefix=OUTPUT_INTEL %s + +define void @f() { +; OUTPUT_ATT-LABEL: f: +; OUTPUT_ATT: # %bb.0: +; OUTPUT_ATT-NEXT: #APP +; OUTPUT_ATT-NEXT: movq %rbx, %rax +; OUTPUT_ATT-NEXT: #NO_APP +; OUTPUT_ATT-NEXT: retq +; +; OUTPUT_INTEL-LABEL: f: +; OUTPUT_INTEL: # %bb.0: +; OUTPUT_INTEL-NEXT: #APP +; OUTPUT_INTEL-NEXT: mov rax, rbx +; OUTPUT_INTEL-NEXT: #NO_APP +; OUTPUT_INTEL-NEXT: ret + call void asm sideeffect "$(movq %rbx, %rax $|mov rax, rbx$)", "~{dirflag},~{fpsr},~{flags}"() + + ret void +}