minor cleanups. Add provisions for a new standard BLOCKINFO_BLOCK
[oota-llvm.git] / tools / bugpoint / ToolRunner.h
index d232cd2e97df84c42f6133ecbb9ba74d031f90c7..a4dc9150ca0b789d8d9f4e6c527dceb09fc388c3 100644 (file)
@@ -1,4 +1,4 @@
-//===-- llvm/Support/ToolRunner.h -------------------------------*- C++ -*-===//
+//===-- tools/bugpoint/ToolRunner.h -----------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,8 +14,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SUPPORT_TOOLRUNNER_H
-#define LLVM_SUPPORT_TOOLRUNNER_H
+#ifndef BUGPOINT_TOOLRUNNER_H
+#define BUGPOINT_TOOLRUNNER_H
 
 #include "llvm/Support/SystemUtils.h"
 #include <exception>
@@ -26,7 +26,6 @@ namespace llvm {
 class CBE;
 class LLC;
 
-
 /// ToolExecutionError - An instance of this class is thrown by the
 /// AbstractInterpreter instances if there is an error running a tool (e.g., LLC
 /// crashes) which prevents execution of the program.
@@ -45,11 +44,13 @@ public:
 //
 class GCC {
   sys::Path GCCPath;          // The path to the gcc executable
-  GCC(const sys::Path &gccPath) : GCCPath(gccPath) { }
+  sys::Path RSHPath;          // The path to the rsh executable
+  GCC(const sys::Path &gccPath, const sys::Path &rshPath)
+    : GCCPath(gccPath), RSHPath(rshPath) { }
 public:
   enum FileType { AsmFile, CFile };
 
-  static GCCcreate(const std::string &ProgramPath, std::string &Message);
+  static GCC *create(const std::string &ProgramPath, std::string &Message);
 
   /// ExecuteProgram - Execute the program specified by "ProgramFile" (which is
   /// either a .s file, or a .c file, specified by FileType), with the specified
@@ -65,13 +66,15 @@ public:
                      const std::string &OutputFile,
                      const std::vector<std::string> &GCCArgs =
                          std::vector<std::string>(), 
-                     unsigned Timeout = 0);
+                     unsigned Timeout = 0,
+                     unsigned MemoryLimit = 0);
 
   /// MakeSharedObject - This compiles the specified file (which is either a .c
   /// file or a .s file) into a shared object.
   ///
   int MakeSharedObject(const std::string &InputFile, FileType fileType,
-                       std::string &OutputFile);
+                       std::string &OutputFile,
+                       const std::vector<std::string> &ArgsForGCC);
 };
 
 
@@ -104,6 +107,15 @@ public:
   /// thrown, otherwise, this function will just return.
   virtual void compileProgram(const std::string &Bytecode) {}
 
+  /// OutputCode - Compile the specified program from bytecode to code
+  /// understood by the GCC driver (either C or asm).  If the code generator
+  /// fails, an exception should be thrown, otherwise, this function returns the
+  /// type of code emitted.
+  virtual GCC::FileType OutputCode(const std::string &Bytecode,
+                                   sys::Path &OutFile) {
+    throw std::string("OutputCode not supported by this AbstractInterpreter!");
+  }
+  
   /// ExecuteProgram - Run the specified bytecode file, emitting output to the
   /// specified filename.  This returns the exit code of the program.
   ///
@@ -115,7 +127,8 @@ public:
                                std::vector<std::string>(),
                              const std::vector<std::string> &SharedLibs =
                                std::vector<std::string>(),
-                             unsigned Timeout = 0) = 0;
+                             unsigned Timeout = 0,
+                             unsigned MemoryLimit = 0) = 0;
 };
 
 //===---------------------------------------------------------------------===//
@@ -147,13 +160,15 @@ public:
                                std::vector<std::string>(),
                              const std::vector<std::string> &SharedLibs =
                                std::vector<std::string>(),
-                             unsigned Timeout = 0);
-
-  // Sometimes we just want to go half-way and only generate the .c file, not
-  // necessarily compile it with GCC and run the program.  This throws an
-  // exception if LLC crashes.
-  //
-  virtual void OutputC(const std::string &Bytecode, sys::Path& OutputCFile);
+                             unsigned Timeout = 0,
+                             unsigned MemoryLimit = 0);
+
+  /// OutputCode - Compile the specified program from bytecode to code
+  /// understood by the GCC driver (either C or asm).  If the code generator
+  /// fails, an exception should be thrown, otherwise, this function returns the
+  /// type of code emitted.
+  virtual GCC::FileType OutputCode(const std::string &Bytecode,
+                                   sys::Path &OutFile);
 };
 
 
@@ -186,13 +201,12 @@ public:
                                std::vector<std::string>(),
                              const std::vector<std::string> &SharedLibs =
                                 std::vector<std::string>(),
-                             unsigned Timeout = 0);
+                             unsigned Timeout = 0,
+                             unsigned MemoryLimit = 0);
 
-  // Sometimes we just want to go half-way and only generate the .s file,
-  // not necessarily compile it all the way and run the program.  This throws
-  // an exception if execution of LLC fails.
-  //
-  void OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile);
+  virtual GCC::FileType OutputCode(const std::string &Bytecode,
+                                   sys::Path &OutFile);
+  
 };
 
 } // End llvm namespace