Use indirect calls in PowerPC JIT.
[oota-llvm.git] / tools / llvm-as / llvm-as.cpp
index 9027cfc3cf200780c3409a7e95325f5a679da51c..d39d6c8a31f60b57daadca078d06d0a676b4d806 100644 (file)
@@ -50,6 +50,42 @@ static cl::opt<bool>
 DisableVerify("disable-verify", cl::Hidden,
               cl::desc("Do not run verifier on input LLVM (dangerous!)"));
 
+static void WriteOutputFile(const Module *M) {
+  // Infer the output filename if needed.
+  if (OutputFilename.empty()) {
+    if (InputFilename == "-") {
+      OutputFilename = "-";
+    } else {
+      std::string IFN = InputFilename;
+      int Len = IFN.length();
+      if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
+        // Source ends in .ll
+        OutputFilename = std::string(IFN.begin(), IFN.end()-3);
+      } else {
+        OutputFilename = IFN;   // Append a .bc to it
+      }
+      OutputFilename += ".bc";
+    }
+  }
+
+  // Make sure that the Out file gets unlinked from the disk if we get a
+  // SIGINT.
+  if (OutputFilename != "-")
+    sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+
+  std::string ErrorInfo;
+  std::auto_ptr<raw_ostream> Out
+  (new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
+                      raw_fd_ostream::F_Binary));
+  if (!ErrorInfo.empty()) {
+    errs() << ErrorInfo << '\n';
+    exit(1);
+  }
+
+  if (Force || !CheckBitcodeOutputToConsole(*Out, true))
+    WriteBitcodeToFile(M, *Out);
+}
+
 int main(int argc, char **argv) {
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal();
@@ -73,46 +109,13 @@ int main(int argc, char **argv) {
              << ": assembly parsed, but does not verify as correct!\n";
       errs() << Err;
       return 1;
-    } 
+    }
   }
 
   if (DumpAsm) errs() << "Here's the assembly:\n" << *M.get();
 
-  // Infer the output filename if needed.
-  if (OutputFilename.empty()) {
-    if (InputFilename == "-") {
-      OutputFilename = "-";
-    } else {
-      std::string IFN = InputFilename;
-      int Len = IFN.length();
-      if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') {
-        // Source ends in .ll
-        OutputFilename = std::string(IFN.begin(), IFN.end()-3);
-      } else {
-        OutputFilename = IFN;   // Append a .bc to it
-      }
-      OutputFilename += ".bc";
-    }
-  }
-  
-  std::string ErrorInfo;
-  std::auto_ptr<raw_ostream> Out
-  (new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
-                      raw_fd_ostream::F_Binary));
-  if (!ErrorInfo.empty()) {
-    errs() << ErrorInfo << '\n';
-    return 1;
-  }
-  
-  
-  // Make sure that the Out file gets unlinked from the disk if we get a
-  // SIGINT.
-  if (OutputFilename != "-")
-    sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-
   if (!DisableOutput)
-    if (Force || !CheckBitcodeOutputToConsole(*Out, true))
-      WriteBitcodeToFile(M.get(), *Out);
+    WriteOutputFile(M.get());
+
   return 0;
 }
-