It is pointless to turn a UINT_TO_FP into an
[oota-llvm.git] / tools / llc / llc.cpp
index 052242054c40351c3c92573b4e9df21e5ceabb41..d179efc03831c7cf22f4f344f5fb1655d54d223a 100644 (file)
@@ -2,14 +2,14 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
 // This is the llc code generator driver. It provides a convenient
 // command-line interface for generating native assembly-language code
-// or C code, given LLVM bytecode.
+// or C code, given LLVM bitcode.
 //
 //===----------------------------------------------------------------------===//
 
@@ -44,7 +44,7 @@ using namespace llvm;
 // and back-end code generation options are specified with the target machine.
 //
 static cl::opt<std::string>
-InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-"));
+InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
 
 static cl::opt<std::string>
 OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
@@ -57,7 +57,8 @@ static cl::opt<bool> Fast("fast",
 static cl::opt<std::string>
 TargetTriple("mtriple", cl::desc("Override target triple for module"));
 
-static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
+static cl::opt<const TargetMachineRegistry::entry*, false,
+               TargetMachineRegistry::Parser>
 MArch("march", cl::desc("Architecture to generate code for:"));
 
 static cl::opt<std::string>
@@ -133,10 +134,15 @@ static std::ostream *GetOutputStream(const char *ProgName) {
     
   switch (FileType) {
   case TargetMachine::AssemblyFile:
-    if (MArch->Name[0] != 'c' || MArch->Name[1] != 0)  // not CBE
+    if (MArch->Name[0] == 'c') {
+      if (MArch->Name[1] == 0)
+        OutputFilename += ".cbe.c";
+      else if (MArch->Name[1] == 'p' && MArch->Name[2] == 'p')
+        OutputFilename += ".cpp";
+      else
+        OutputFilename += ".s";
+    } else
       OutputFilename += ".s";
-    else
-      OutputFilename += ".cbe.c";
     break;
   case TargetMachine::ObjectFile:
     OutputFilename += ".o";
@@ -172,23 +178,19 @@ static std::ostream *GetOutputStream(const char *ProgName) {
 //
 int main(int argc, char **argv) {
   llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
-  cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
+  cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
   sys::PrintStackTraceOnErrorSignal();
 
   // Load the module to be compiled...
   std::string ErrorMessage;
   std::auto_ptr<Module> M;
   
-  {
   std::auto_ptr<MemoryBuffer> Buffer(
-       MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
+                   MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage));
   if (Buffer.get())
     M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
-  else
-    ErrorMessage = "Error reading file '" + InputFilename + "'";
-  }
   if (M.get() == 0) {
-    std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
+    std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
     std::cerr << "Reason: " << ErrorMessage << "\n";
     return 1;
   }
@@ -249,7 +251,8 @@ int main(int argc, char **argv) {
     PM.run(mod);
   } else {
     // Build up all of the passes that we want to do to the module.
-    FunctionPassManager Passes(new ExistingModuleProvider(M.get()));
+    ExistingModuleProvider Provider(M.release());
+    FunctionPassManager Passes(&Provider);
     Passes.add(new TargetData(*Target.getTargetData()));
     
 #ifndef NDEBUG