[PATCH] D113894: [x86/asm] Make variants work when converting at&t inline asm input to intel asm output
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 17 10:23:56 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG103cc914d633: [x86/asm] Make variants work when converting at&t inline asm input to intel asm… (authored by thakis).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113894/new/
https://reviews.llvm.org/D113894
Files:
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
llvm/lib/Target/PowerPC/PPCTargetMachine.h
llvm/test/CodeGen/X86/asm-dialect.ll
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
+}
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/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
@@ -276,7 +276,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/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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113894.387979.patch
Type: text/x-patch
Size: 2619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211117/fc9283ba/attachment.bin>
More information about the llvm-commits
mailing list