[X86] Add .intel_syntax noprefix directive to intel-syntax x86 asm output
authorMichael Kuperstein <michael.m.kuperstein@intel.com>
Wed, 22 Jul 2015 10:49:44 +0000 (10:49 +0000)
committerMichael Kuperstein <michael.m.kuperstein@intel.com>
Wed, 22 Jul 2015 10:49:44 +0000 (10:49 +0000)
Patch by: michael.zuckerman@intel.com
Differential Revision: http://reviews.llvm.org/D11223

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242886 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCStreamer.h
lib/MC/MCAsmStreamer.cpp
lib/MC/MCStreamer.cpp
lib/Target/X86/X86AsmPrinter.cpp
test/MC/X86/intel-syntax-print.ll [new file with mode: 0644]

index 6b9b8a15384554a0a53b1424cdb874c1f63ab8ab..63e30bc3d545beb97fbdbe9bdc980ca403fd4fd8 100644 (file)
@@ -682,6 +682,8 @@ public:
   virtual void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except);
   virtual void EmitWinEHHandlerData();
 
+  virtual void EmitSyntaxDirective();
+
   /// \brief Emit the given \p Instruction into the current section.
   virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);
 
index 227c937e8d1b62e7a6a38825c2dca3d15817a8cd..ec49058407f203fbca40034b1262627f8a53a9d5 100644 (file)
@@ -78,6 +78,9 @@ public:
     }
     EmitCommentsAndEOL();
   }
+
+  virtual void EmitSyntaxDirective();
+
   void EmitCommentsAndEOL();
 
   /// isVerboseAsm - Return true if this streamer supports verbose assembly at
@@ -480,6 +483,14 @@ void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
   EmitEOL();
 }
 
+void MCAsmStreamer::EmitSyntaxDirective() {
+  if (MAI->getAssemblerDialect() == 1)
+    OS << "\t.intel_syntax noprefix\n";
+  // FIXME: Currently emit unprefix'ed registers.
+  // The intel_syntax directive has one optional argument 
+  // with may have a value of prefix or noprefix.
+}
+
 void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
   OS << "\t.def\t ";
   Symbol->print(OS, MAI);
index 7fbbbd95b560f32cb8e101fd7db0417f826dd004..a25cdfa971eb903a461ced037ba97b9340bba73f 100644 (file)
@@ -467,6 +467,8 @@ void MCStreamer::EmitWinEHHandlerData() {
     report_fatal_error("Chained unwind areas can't have handlers!");
 }
 
+void MCStreamer::EmitSyntaxDirective() {}
+
 void MCStreamer::EmitWinCFIPushReg(unsigned Register) {
   EnsureValidWinFrameInfo();
 
index 24149e6e9ce57937af81c5c536727729c49c01b3..9fe849a04ee01b3254561fd8178163c4824afbdf 100644 (file)
@@ -535,6 +535,7 @@ void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
           S, MCConstantExpr::create(int64_t(1), MMI->getContext()));
     }
   }
+  OutStreamer->EmitSyntaxDirective();
 }
 
 static void
diff --git a/test/MC/X86/intel-syntax-print.ll b/test/MC/X86/intel-syntax-print.ll
new file mode 100644 (file)
index 0000000..275e8cd
--- /dev/null
@@ -0,0 +1,9 @@
+; RUN: llc -x86-asm-syntax=intel < %s | FileCheck %s -check-prefix=INTEL
+; RUN: llc -x86-asm-syntax=att < %s | FileCheck %s -check-prefix=ATT
+
+; INTEL: .intel_syntax noprefix
+; ATT-NOT: .intel_syntax noprefix
+define i32 @test() {
+entry:
+  ret i32 0
+}