[PATCH] D113894: [x86] Make assembler variant selection work when outputting intel-style asm

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 08:45:32 PST 2021


thakis updated this revision to Diff 387286.
thakis edited the summary of this revision.
thakis added a comment.
Herald added subscribers: steven.zhang, kbarton, nemanjai.

new approach to unbreak powerpc


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
@@ -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/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.387286.patch
Type: text/x-patch
Size: 2619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/2c4be18b/attachment.bin>


More information about the llvm-commits mailing list