lib/Target/Sparc/Sparc.cpp:
 Move LowerAllocations, PrintFunction, and SymbolStripping passes, and
  the corresponding -disable-strip and -d options, over here to the SPARC
  target-specific bits of llc. Rename -d to -dump-asm.

tools/llc/Makefile:
 Reindent. Add x86 library so that llc compiles again.

tools/llc/llc.cpp:
 Remove support for running arbitrary optimization passes. Use opt instead.
 Remove LowerAllocations, PrintFunction, and SymbolStripping passes, as noted
  above.
 Allow user to select a backend (x86 or SPARC); default to guessing from
  the endianness/pointer size of the input bytecode file.
 Fix typos.
 Delete empty .s file and exit with error status if target does not support
  static compilation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6776 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
index 8304712..f389f93 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineCodeForInstruction.h"
 #include "llvm/Reoptimizer/Mapping/MappingInfo.h" 
 #include "Support/CommandLine.h"
+#include "llvm/Assembly/PrintModulePass.h"
 
 static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */
 // Build the MachineInstruction Description Array...
@@ -46,6 +47,14 @@
 static cl::opt<bool> DisablePeephole("nopeephole",
                                 cl::desc("Disable peephole optimization pass"));
 
+static cl::opt<bool>
+DisableStrip("disable-strip",
+	  cl::desc("Do not strip the LLVM bytecode included in the executable"));
+
+static cl::opt<bool>
+DumpAsm("dump-asm", cl::desc("Print bytecode before native code generation"),
+        cl::Hidden);
+
 //----------------------------------------------------------------------------
 // allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine
 // that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface)
@@ -141,9 +150,21 @@
 //
 bool UltraSparc::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
 {
+  // The following 3 passes used to be inserted specially by llc.
+  // Replace malloc and free instructions with library calls.
+  PM.add(createLowerAllocationsPass());
+  
+  // If LLVM dumping after transformations is requested, add it to the pipeline
+  if (DumpAsm)
+    PM.add(new PrintFunctionPass("Code after xformations: \n", &std::cerr));
+  
+  // Strip all of the symbols from the bytecode so that it will be smaller...
+  if (!DisableStrip)
+    PM.add(createSymbolStrippingPass());
+
   // FIXME: implement the switch instruction in the instruction selector.
   PM.add(createLowerSwitchPass());
-
+  
   // Construct and initialize the MachineFunction object for this fn.
   PM.add(createMachineCodeConstructionPass(*this));