Index: llvm/include/llvm/Target/TargetRegistry.h
===================================================================
--- llvm.orig/include/llvm/Target/TargetRegistry.h
+++ llvm/include/llvm/Target/TargetRegistry.h
@@ -73,6 +73,13 @@ namespace llvm {
     typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T,
                                                 TargetMachine &TM,
                                                 MCContext &Ctx);
+    typedef MCStreamer *(*StreamerCtorTy)(const Target &T,
+                                          const std::string &TT,
+                                          MCContext &Ctx,
+                                          TargetAsmBackend &TAB,
+                                          raw_ostream &_OS,
+                                          MCCodeEmitter *_Emitter,
+                                          bool RelaxAll);
 
   private:
     /// Next - The next registered target in the linked list, maintained by the
@@ -126,6 +133,10 @@ namespace llvm {
     /// if registered.
     CodeEmitterCtorTy CodeEmitterCtorFn;
 
+    /// StreamerCtorFn - Construction function for this target's Streamer,
+    /// if registered.
+    StreamerCtorTy StreamerCtorFn;
+
   public:
     /// @name Target Information
     /// @{
@@ -170,6 +181,9 @@ namespace llvm {
     /// hasCodeEmitter - Check if this target supports instruction encoding.
     bool hasCodeEmitter() const { return CodeEmitterCtorFn != 0; }
 
+    /// hasStreamer - Check if this target supports streaming to files.
+    bool hasStreamer() const { return StreamerCtorFn != 0; }
+
     /// @}
     /// @name Feature Constructors
     /// @{
@@ -258,6 +272,24 @@ namespace llvm {
       return CodeEmitterCtorFn(*this, TM, Ctx);
     }
 
+    /// createStreamer - Create a target specific MCStreamer.
+    ///
+    /// \arg TT - The target triple.
+    /// \arg Ctx - The target context.
+    /// \arg TAB - The target assembler backend object.
+    /// \arg _OS - The stream object.
+    /// \arg _Emitter - The target independent assembler object.
+    /// \arg RelaxAll - Relax all fixups?
+    MCStreamer *createStreamer(const std::string &TT, MCContext &Ctx,
+                               TargetAsmBackend &TAB,
+                               raw_ostream &_OS,
+                               MCCodeEmitter *_Emitter,
+                               bool RelaxAll) const {
+      if (!StreamerCtorFn)
+        return 0;
+      return StreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, RelaxAll);
+    }
+
     /// @}
   };
 
@@ -479,6 +511,20 @@ namespace llvm {
         T.CodeEmitterCtorFn = Fn;
     }
 
+    /// RegisterStreamer - Register a MCStreamer implementation for the
+    /// given target.
+    ///
+    /// Clients are responsible for ensuring that registration doesn't occur
+    /// while another thread is attempting to access the registry. Typically
+    /// this is done by initializing all targets at program startup.
+    ///
+    /// @param T - The target being registered.
+    /// @param Fn - A function to construct an MCStreamer for the target.
+    static void RegisterStreamer(Target &T, Target::StreamerCtorTy Fn) {
+      if (!T.StreamerCtorFn)
+        T.StreamerCtorFn = Fn;
+    }
+
     /// @}
   };
 
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===================================================================
--- llvm.orig/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -304,7 +304,8 @@ static int AssembleInput(const char *Pro
     assert(FileType == OFT_ObjectFile && "Invalid file type!");
     CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
     TAB.reset(TheTarget->createAsmBackend(TripleName));
-    Str.reset(createMachOStreamer(Ctx, *TAB, *Out, CE.get(), RelaxAll));
+    Str.reset(TheTarget->createStreamer(TripleName, Ctx, *TAB,
+                                        *Out, CE.get(), RelaxAll));
   }
 
   AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI);
Index: llvm/lib/Target/X86/X86TargetMachine.cpp
===================================================================
--- llvm.orig/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -17,6 +17,8 @@
 #include "llvm/PassManager.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/Passes.h"
+#include "llvm/MC/MCCodeEmitter.h"
+#include "llvm/MC/MCStreamer.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetRegistry.h"
@@ -37,6 +39,18 @@ static MCAsmInfo *createMCAsmInfo(const
   }
 }
 
+static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
+                                    MCContext &Ctx, TargetAsmBackend &TAB,
+                                    raw_ostream &_OS,
+                                    MCCodeEmitter *_Emitter,
+                                    bool RelaxAll) {
+  Triple TheTriple(TT);
+  switch (TheTriple.getOS()) {
+  default:
+    return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
+  }
+}
+
 extern "C" void LLVMInitializeX86Target() { 
   // Register the target.
   RegisterTargetMachine<X86_32TargetMachine> X(TheX86_32Target);
@@ -57,6 +71,12 @@ extern "C" void LLVMInitializeX86Target(
                                      createX86_32AsmBackend);
   TargetRegistry::RegisterAsmBackend(TheX86_64Target,
                                      createX86_64AsmBackend);
+
+  // Register the streamer.
+  TargetRegistry::RegisterStreamer(TheX86_32Target,
+                                   createMCStreamer);
+  TargetRegistry::RegisterStreamer(TheX86_64Target,
+                                   createMCStreamer);
 }
 
 
