summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-14 21:34:11 +0000
committerChris Lattner <sabre@nondot.org>2003-10-14 21:34:11 +0000
commit7915a1e764a5472d89a5ea40fbc22515afc5abf2 (patch)
treed9379244ff8904afd841c2d36eedaf9d9a5635a3 /lib/Support
parenta0f5b15e1eb8642d92b3141a6b88a5729ea979dc (diff)
downloadllvm-7915a1e764a5472d89a5ea40fbc22515afc5abf2.tar.gz
llvm-7915a1e764a5472d89a5ea40fbc22515afc5abf2.tar.bz2
llvm-7915a1e764a5472d89a5ea40fbc22515afc5abf2.tar.xz
Substantial cleanups:
* Add header comment * Remove extraneous #includes * Move the FileType enum into the GCC class * The GCC class is not virtual. * Move all of the "constructor" functions into the classes themselves * Stop using cl::list as arguments, use std::vector instead (which cl::list derives from) * Improve comments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/ToolRunner.cpp63
1 files changed, 35 insertions, 28 deletions
diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp
index 2fa5b393bb..a8f99bc08e 100644
--- a/lib/Support/ToolRunner.cpp
+++ b/lib/Support/ToolRunner.cpp
@@ -1,6 +1,14 @@
+//===-- ToolRunner.cpp ----------------------------------------------------===//
+//
+// This file implements the interfaces described in the ToolRunner.h file.
+//
+//===----------------------------------------------------------------------===//
+
#include "llvm/Support/ToolRunner.h"
#include "Support/Debug.h"
#include "Support/FileUtilities.h"
+#include <iostream>
+#include <fstream>
//===---------------------------------------------------------------------===//
// LLI Implementation of AbstractIntepreter interface
@@ -12,14 +20,14 @@ public:
virtual int ExecuteProgram(const std::string &Bytecode,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::string &SharedLib = "");
};
int LLI::ExecuteProgram(const std::string &Bytecode,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::string &SharedLib) {
@@ -50,9 +58,9 @@ int LLI::ExecuteProgram(const std::string &Bytecode,
}
// LLI create method - Try to find the LLI executable
-AbstractInterpreter *createLLItool(const std::string &ProgramPath,
- std::string &Message) {
- std::string LLIPath = FindExecutable("lli", ProgramPath);
+AbstractInterpreter *AbstractInterpreter::createLLI(const std::string &ProgPath,
+ std::string &Message) {
+ std::string LLIPath = FindExecutable("lli", ProgPath);
if (!LLIPath.empty()) {
Message = "Found lli: " + LLIPath + "\n";
return new LLI(LLIPath);
@@ -65,8 +73,7 @@ AbstractInterpreter *createLLItool(const std::string &ProgramPath,
//===----------------------------------------------------------------------===//
// LLC Implementation of AbstractIntepreter interface
//
-int LLC::OutputAsm(const std::string &Bytecode,
- std::string &OutputAsmFile) {
+int LLC::OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile) {
OutputAsmFile = getUniqueFilename(Bytecode+".llc.s");
const char *LLCArgs[] = {
LLCPath.c_str(),
@@ -89,11 +96,10 @@ int LLC::OutputAsm(const std::string &Bytecode,
}
int LLC::ExecuteProgram(const std::string &Bytecode,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::string &SharedLib) {
-
std::string OutputAsmFile;
if (OutputAsm(Bytecode, OutputAsmFile)) {
std::cerr << "Could not generate asm code with `llc', exiting.\n";
@@ -101,16 +107,16 @@ int LLC::ExecuteProgram(const std::string &Bytecode,
}
// Assuming LLC worked, compile the result with GCC and run it.
- int Result = gcc->ExecuteProgram(OutputAsmFile, Args, AsmFile,
+ int Result = gcc->ExecuteProgram(OutputAsmFile, Args, GCC::AsmFile,
InputFile, OutputFile, SharedLib);
removeFile(OutputAsmFile);
return Result;
}
-/// createLLCtool - Try to find the LLC executable
+/// createLLC - Try to find the LLC executable
///
-LLC *createLLCtool(const std::string &ProgramPath, std::string &Message)
-{
+LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
+ std::string &Message) {
std::string LLCPath = FindExecutable("llc", ProgramPath);
if (LLCPath.empty()) {
Message = "Cannot find `llc' in executable directory or PATH!\n";
@@ -118,7 +124,7 @@ LLC *createLLCtool(const std::string &ProgramPath, std::string &Message)
}
Message = "Found llc: " + LLCPath + "\n";
- GCC *gcc = createGCCtool(ProgramPath, Message);
+ GCC *gcc = GCC::create(ProgramPath, Message);
if (!gcc) {
std::cerr << Message << "\n";
exit(1);
@@ -136,14 +142,14 @@ public:
virtual int ExecuteProgram(const std::string &Bytecode,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::string &SharedLib = "");
};
int JIT::ExecuteProgram(const std::string &Bytecode,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::string &SharedLib) {
@@ -173,11 +179,11 @@ int JIT::ExecuteProgram(const std::string &Bytecode,
InputFile, OutputFile, OutputFile);
}
-/// createJITtool - Try to find the LLI executable
+/// createJIT - Try to find the LLI executable
///
-AbstractInterpreter *createJITtool(const std::string &ProgramPath,
- std::string &Message) {
- std::string LLIPath = FindExecutable("lli", ProgramPath);
+AbstractInterpreter *AbstractInterpreter::createJIT(const std::string &ProgPath,
+ std::string &Message) {
+ std::string LLIPath = FindExecutable("lli", ProgPath);
if (!LLIPath.empty()) {
Message = "Found lli: " + LLIPath + "\n";
return new JIT(LLIPath);
@@ -211,7 +217,7 @@ int CBE::OutputC(const std::string &Bytecode,
}
int CBE::ExecuteProgram(const std::string &Bytecode,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
const std::string &InputFile,
const std::string &OutputFile,
const std::string &SharedLib) {
@@ -221,16 +227,17 @@ int CBE::ExecuteProgram(const std::string &Bytecode,
exit(1);
}
- int Result = gcc->ExecuteProgram(OutputCFile, Args, CFile,
+ int Result = gcc->ExecuteProgram(OutputCFile, Args, GCC::CFile,
InputFile, OutputFile, SharedLib);
removeFile(OutputCFile);
return Result;
}
-/// createCBEtool - Try to find the 'dis' executable
+/// createCBE - Try to find the 'llvm-dis' executable
///
-CBE *createCBEtool(const std::string &ProgramPath, std::string &Message) {
+CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
+ std::string &Message) {
std::string DISPath = FindExecutable("llvm-dis", ProgramPath);
if (DISPath.empty()) {
Message =
@@ -239,7 +246,7 @@ CBE *createCBEtool(const std::string &ProgramPath, std::string &Message) {
}
Message = "Found llvm-dis: " + DISPath + "\n";
- GCC *gcc = createGCCtool(ProgramPath, Message);
+ GCC *gcc = GCC::create(ProgramPath, Message);
if (!gcc) {
std::cerr << Message << "\n";
exit(1);
@@ -254,7 +261,7 @@ CBE *createCBEtool(const std::string &ProgramPath, std::string &Message) {
// files, but only input acceptable to GCC, i.e. C, C++, and assembly files
//
int GCC::ExecuteProgram(const std::string &ProgramFile,
- const cl::list<std::string> &Args,
+ const std::vector<std::string> &Args,
FileType fileType,
const std::string &InputFile,
const std::string &OutputFile,
@@ -358,9 +365,9 @@ void GCC::ProcessFailure(const char** GCCArgs) {
removeFile(ErrorFilename);
}
-/// createGCCtool - Try to find the `gcc' executable
+/// create - Try to find the `gcc' executable
///
-GCC *createGCCtool(const std::string &ProgramPath, std::string &Message) {
+GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
std::string GCCPath = FindExecutable("gcc", ProgramPath);
if (GCCPath.empty()) {
Message = "Cannot find `gcc' in executable directory or PATH!\n";