stub out a new X86 encoder, which can be tried with
-enable-new-x86-encoder until its stable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95256 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/CMakeLists.txt b/lib/Target/X86/CMakeLists.txt
index 4186fec..8f4ff17 100644
--- a/lib/Target/X86/CMakeLists.txt
+++ b/lib/Target/X86/CMakeLists.txt
@@ -25,6 +25,7 @@
   X86InstrInfo.cpp
   X86JITInfo.cpp
   X86MCAsmInfo.cpp
+  X86MCCodeEmitter.cpp 
   X86RegisterInfo.cpp
   X86Subtarget.cpp
   X86TargetMachine.cpp
diff --git a/lib/Target/X86/X86.h b/lib/Target/X86/X86.h
index 001a189..e39551b 100644
--- a/lib/Target/X86/X86.h
+++ b/lib/Target/X86/X86.h
@@ -50,6 +50,7 @@
                                           JITCodeEmitter &JCE);
 
 MCCodeEmitter *createHeinousX86MCCodeEmitter(const Target &, TargetMachine &TM);
+MCCodeEmitter *createX86MCCodeEmitter(const Target &, TargetMachine &TM);
 
 /// createX86EmitCodeToMemory - Returns a pass that converts a register
 /// allocated function into raw machine code in a dynamically
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index 567f180..304613a 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -1099,8 +1099,19 @@
 };
 }
 
+#include "llvm/Support/CommandLine.h"
+
+static cl::opt<bool> EnableNewEncoder("enable-new-x86-encoder",
+                                      cl::ReallyHidden);
+
+
 // Ok, now you can look.
-MCCodeEmitter *llvm::createHeinousX86MCCodeEmitter(const Target &,
+MCCodeEmitter *llvm::createHeinousX86MCCodeEmitter(const Target &T,
                                                    TargetMachine &TM) {
+  
+  // FIXME: Remove the heinous one when the new one works.
+  if (EnableNewEncoder)
+    return createX86MCCodeEmitter(T, TM);
+
   return new X86MCCodeEmitter(static_cast<X86TargetMachine&>(TM));
 }
diff --git a/lib/Target/X86/X86MCCodeEmitter.cpp b/lib/Target/X86/X86MCCodeEmitter.cpp
new file mode 100644
index 0000000..0578c6d
--- /dev/null
+++ b/lib/Target/X86/X86MCCodeEmitter.cpp
@@ -0,0 +1,41 @@
+//===-- X86/X86MCCodeEmitter.cpp - Convert X86 code to machine code -------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the X86MCCodeEmitter class.
+//
+//===----------------------------------------------------------------------===//
+
+#define DEBUG_TYPE "x86-emitter"
+#include "X86.h"
+#include "X86TargetMachine.h"
+#include "llvm/MC/MCCodeEmitter.h"
+using namespace llvm;
+
+namespace {
+class X86MCCodeEmitter : public MCCodeEmitter {
+  X86MCCodeEmitter(const X86MCCodeEmitter &); // DO NOT IMPLEMENT
+  void operator=(const X86MCCodeEmitter &); // DO NOT IMPLEMENT
+  X86TargetMachine &TM;
+public:
+  X86MCCodeEmitter(X86TargetMachine &tm) : TM(tm) {
+  }
+
+  ~X86MCCodeEmitter() {}
+  
+  void EncodeInstruction(const MCInst &MI, raw_ostream &OS) const {
+  }
+};
+
+} // end anonymous namespace
+
+
+MCCodeEmitter *llvm::createX86MCCodeEmitter(const Target &,
+                                            TargetMachine &TM) {
+  return new X86MCCodeEmitter(static_cast<X86TargetMachine&>(TM));
+}
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index d6ad48e..2e7febc 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -48,6 +48,7 @@
   RegisterAsmInfoFn B(TheX86_64Target, createMCAsmInfo);
 
   // Register the code emitter.
+  // FIXME: Remove the heinous one when the new one works.
   TargetRegistry::RegisterCodeEmitter(TheX86_32Target,
                                       createHeinousX86MCCodeEmitter);
   TargetRegistry::RegisterCodeEmitter(TheX86_64Target,