Finegrainify namespacification

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10464 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-12-14 21:35:53 +00:00
parent b6d465f813
commit 2cdd21c2e4
18 changed files with 106 additions and 152 deletions

View File

@ -25,8 +25,7 @@
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/Instruction.h" #include "llvm/Instruction.h"
#include "llvm/ConstantHandling.h" #include "llvm/ConstantHandling.h"
using namespace llvm;
namespace llvm {
/// Initialize a full (the default) or empty set for the specified type. /// Initialize a full (the default) or empty set for the specified type.
/// ///
@ -250,5 +249,3 @@ void ConstantRange::print(std::ostream &OS) const {
void ConstantRange::dump() const { void ConstantRange::dump() const {
print(std::cerr); print(std::cerr);
} }
} // End llvm namespace

View File

@ -13,8 +13,7 @@
#include <map> #include <map>
#include "Support/Annotation.h" #include "Support/Annotation.h"
using namespace llvm;
namespace llvm {
typedef std::map<const std::string, unsigned> IDMapType; typedef std::map<const std::string, unsigned> IDMapType;
static unsigned IDCounter = 0; // Unique ID counter static unsigned IDCounter = 0; // Unique ID counter
@ -96,5 +95,3 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID,
if (I == getFactMap().end()) return 0; if (I == getFactMap().end()) return 0;
return I->second.first(ID, Obj, I->second.second); return I->second.first(ID, Obj, I->second.second);
} }
} // End llvm namespace

View File

@ -23,8 +23,7 @@
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
#include <cerrno> #include <cerrno>
using namespace llvm;
namespace llvm {
using namespace cl; using namespace cl;
@ -889,5 +888,3 @@ HHOp("help-hidden", cl::desc("display all available options"),
cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed);
} // End anonymous namespace } // End anonymous namespace
} // End llvm namespace

View File

@ -25,8 +25,7 @@
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/Instruction.h" #include "llvm/Instruction.h"
#include "llvm/ConstantHandling.h" #include "llvm/ConstantHandling.h"
using namespace llvm;
namespace llvm {
/// Initialize a full (the default) or empty set for the specified type. /// Initialize a full (the default) or empty set for the specified type.
/// ///
@ -250,5 +249,3 @@ void ConstantRange::print(std::ostream &OS) const {
void ConstantRange::dump() const { void ConstantRange::dump() const {
print(std::cerr); print(std::cerr);
} }
} // End llvm namespace

View File

@ -23,12 +23,11 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "Support/Statistic.h" #include "Support/Debug.h"
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
using namespace llvm;
namespace llvm { bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option
bool DebugFlag; // DebugFlag - Exported boolean set by the -debug option
namespace { namespace {
#ifndef NDEBUG #ifndef NDEBUG
@ -57,12 +56,10 @@ namespace {
// specified on the command line, or if none was specified on the command line // specified on the command line, or if none was specified on the command line
// with the -debug-only=X option. // with the -debug-only=X option.
// //
bool isCurrentDebugType(const char *DebugType) { bool llvm::isCurrentDebugType(const char *DebugType) {
#ifndef NDEBUG #ifndef NDEBUG
return CurrentDebugType.empty() || DebugType == CurrentDebugType; return CurrentDebugType.empty() || DebugType == CurrentDebugType;
#else #else
return false; return false;
#endif #endif
} }
} // End llvm namespace

View File

@ -22,10 +22,9 @@
#include "Support/DynamicLinker.h" #include "Support/DynamicLinker.h"
#include "Config/dlfcn.h" #include "Config/dlfcn.h"
#include <cassert> #include <cassert>
using namespace llvm;
namespace llvm { bool llvm::LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
#if defined (HAVE_DLOPEN) #if defined (HAVE_DLOPEN)
if (dlopen (filename, RTLD_NOW | RTLD_GLOBAL) == 0) { if (dlopen (filename, RTLD_NOW | RTLD_GLOBAL) == 0) {
if (ErrorMessage) *ErrorMessage = dlerror (); if (ErrorMessage) *ErrorMessage = dlerror ();
@ -37,7 +36,7 @@ bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) {
#endif #endif
} }
void *GetAddressOfSymbol (const char *symbolName) { void *llvm::GetAddressOfSymbol (const char *symbolName) {
#if defined (HAVE_DLOPEN) #if defined (HAVE_DLOPEN)
#ifdef RTLD_DEFAULT #ifdef RTLD_DEFAULT
return dlsym (RTLD_DEFAULT, symbolName); return dlsym (RTLD_DEFAULT, symbolName);
@ -51,8 +50,6 @@ void *GetAddressOfSymbol (const char *symbolName) {
} }
// soft, cushiony C++ interface. // soft, cushiony C++ interface.
void *GetAddressOfSymbol (const std::string &symbolName) { void *llvm::GetAddressOfSymbol (const std::string &symbolName) {
return GetAddressOfSymbol (symbolName.c_str ()); return GetAddressOfSymbol (symbolName.c_str ());
} }
} // End llvm namespace

View File

@ -19,14 +19,12 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
using namespace llvm;
namespace llvm
{
/// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must
/// name a readable file. /// name a readable file.
/// ///
bool CheckMagic (const std::string &FN, const std::string &Magic) { bool llvm::CheckMagic(const std::string &FN, const std::string &Magic) {
char buf[1 + Magic.size ()]; char buf[1 + Magic.size ()];
std::ifstream f (FN.c_str ()); std::ifstream f (FN.c_str ());
f.read (buf, Magic.size ()); f.read (buf, Magic.size ());
@ -37,7 +35,7 @@ bool CheckMagic (const std::string &FN, const std::string &Magic) {
/// IsArchive - Returns true IFF the file named FN appears to be a "ar" library /// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
/// archive. The file named FN must exist. /// archive. The file named FN must exist.
/// ///
bool IsArchive(const std::string &FN) { bool llvm::IsArchive(const std::string &FN) {
// Inspect the beginning of the file to see if it contains the "ar" // Inspect the beginning of the file to see if it contains the "ar"
// library archive format magic string. // library archive format magic string.
return CheckMagic (FN, "!<arch>\012"); return CheckMagic (FN, "!<arch>\012");
@ -46,7 +44,7 @@ bool IsArchive(const std::string &FN) {
/// IsBytecode - Returns true IFF the file named FN appears to be an LLVM /// IsBytecode - Returns true IFF the file named FN appears to be an LLVM
/// bytecode file. The file named FN must exist. /// bytecode file. The file named FN must exist.
/// ///
bool IsBytecode(const std::string &FN) { bool llvm::IsBytecode(const std::string &FN) {
// Inspect the beginning of the file to see if it contains the LLVM // Inspect the beginning of the file to see if it contains the LLVM
// bytecode format magic string. // bytecode format magic string.
return CheckMagic (FN, "llvm"); return CheckMagic (FN, "llvm");
@ -55,7 +53,7 @@ bool IsBytecode(const std::string &FN) {
/// IsSharedObject - Returns trus IFF the file named FN appears to be a shared /// IsSharedObject - Returns trus IFF the file named FN appears to be a shared
/// object with an ELF header. The file named FN must exist. /// object with an ELF header. The file named FN must exist.
/// ///
bool IsSharedObject(const std::string &FN) { bool llvm::IsSharedObject(const std::string &FN) {
// Inspect the beginning of the file to see if it contains the ELF shared // Inspect the beginning of the file to see if it contains the ELF shared
// object magic string. // object magic string.
static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' }; static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' };
@ -65,7 +63,7 @@ bool IsSharedObject(const std::string &FN) {
/// FileOpenable - Returns true IFF Filename names an existing regular /// FileOpenable - Returns true IFF Filename names an existing regular
/// file which we can successfully open. /// file which we can successfully open.
/// ///
bool FileOpenable (const std::string &Filename) { bool llvm::FileOpenable(const std::string &Filename) {
struct stat s; struct stat s;
if (stat (Filename.c_str (), &s) == -1) if (stat (Filename.c_str (), &s) == -1)
return false; // Cannot stat file return false; // Cannot stat file
@ -83,8 +81,8 @@ bool FileOpenable (const std::string &Filename) {
/// occurs, allowing the caller to distinguish between a failed diff and a file /// occurs, allowing the caller to distinguish between a failed diff and a file
/// system error. /// system error.
/// ///
bool DiffFiles(const std::string &FileA, const std::string &FileB, bool llvm::DiffFiles(const std::string &FileA, const std::string &FileB,
std::string *Error) { std::string *Error) {
std::ifstream FileAStream(FileA.c_str()); std::ifstream FileAStream(FileA.c_str());
if (!FileAStream) { if (!FileAStream) {
if (Error) *Error = "Couldn't open file '" + FileA + "'"; if (Error) *Error = "Couldn't open file '" + FileA + "'";
@ -113,7 +111,8 @@ bool DiffFiles(const std::string &FileA, const std::string &FileB,
/// or if Old does not exist, move the New file over the Old file. Otherwise, /// or if Old does not exist, move the New file over the Old file. Otherwise,
/// remove the New file. /// remove the New file.
/// ///
void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { void llvm::MoveFileOverIfUpdated(const std::string &New,
const std::string &Old) {
if (DiffFiles(New, Old)) { if (DiffFiles(New, Old)) {
if (std::rename(New.c_str(), Old.c_str())) if (std::rename(New.c_str(), Old.c_str()))
std::cerr << "Error renaming '" << New << "' to '" << Old << "'!\n"; std::cerr << "Error renaming '" << New << "' to '" << Old << "'!\n";
@ -124,7 +123,7 @@ void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) {
/// removeFile - Delete the specified file /// removeFile - Delete the specified file
/// ///
void removeFile(const std::string &Filename) { void llvm::removeFile(const std::string &Filename) {
std::remove(Filename.c_str()); std::remove(Filename.c_str());
} }
@ -132,7 +131,7 @@ void removeFile(const std::string &Filename) {
/// file does not exist yet, return it, otherwise add a suffix to make it /// file does not exist yet, return it, otherwise add a suffix to make it
/// unique. /// unique.
/// ///
std::string getUniqueFilename(const std::string &FilenameBase) { std::string llvm::getUniqueFilename(const std::string &FilenameBase) {
if (!std::ifstream(FilenameBase.c_str())) if (!std::ifstream(FilenameBase.c_str()))
return FilenameBase; // Couldn't open the file? Use it! return FilenameBase; // Couldn't open the file? Use it!
@ -183,8 +182,8 @@ static bool AddPermissionsBits (const std::string &Filename, mode_t bits) {
/// umask would allow. Filename must name an existing file or /// umask would allow. Filename must name an existing file or
/// directory. Returns true on success, false on error. /// directory. Returns true on success, false on error.
/// ///
bool MakeFileExecutable (const std::string &Filename) { bool llvm::MakeFileExecutable(const std::string &Filename) {
return AddPermissionsBits (Filename, 0111); return AddPermissionsBits(Filename, 0111);
} }
/// MakeFileReadable - Make the file named Filename readable by /// MakeFileReadable - Make the file named Filename readable by
@ -192,8 +191,6 @@ bool MakeFileExecutable (const std::string &Filename) {
/// umask would allow. Filename must name an existing file or /// umask would allow. Filename must name an existing file or
/// directory. Returns true on success, false on error. /// directory. Returns true on success, false on error.
/// ///
bool MakeFileReadable (const std::string &Filename) { bool llvm::MakeFileReadable(const std::string &Filename) {
return AddPermissionsBits (Filename, 0444); return AddPermissionsBits(Filename, 0444);
} }
} // End llvm namespace

View File

@ -14,8 +14,7 @@
#include "Support/LeakDetector.h" #include "Support/LeakDetector.h"
#include "llvm/Value.h" #include "llvm/Value.h"
#include <set> #include <set>
using namespace llvm;
namespace llvm {
// Lazily allocate set so that release build doesn't have to do anything. // Lazily allocate set so that release build doesn't have to do anything.
static std::set<const void*> *Objects = 0; static std::set<const void*> *Objects = 0;
@ -89,5 +88,3 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) {
Objects = 0; LLVMObjects = 0; Objects = 0; LLVMObjects = 0;
} }
} }
} // End llvm namespace

View File

@ -15,8 +15,7 @@
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "Support/StringExtras.h" #include "Support/StringExtras.h"
using namespace llvm;
namespace llvm {
static char HexDigit(int V) { static char HexDigit(int V) {
return V < 10 ? V+'0' : V+'A'-10; return V < 10 ? V+'0' : V+'A'-10;
@ -100,5 +99,3 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix)
else else
FoundNames.insert(I->getName()); // Otherwise, keep track of name FoundNames.insert(I->getName()); // Otherwise, keep track of name
} }
} // End llvm namespace

View File

@ -22,8 +22,7 @@
#include "Config/dlfcn.h" #include "Config/dlfcn.h"
#include "Config/link.h" #include "Config/link.h"
#include <iostream> #include <iostream>
using namespace llvm;
namespace llvm {
namespace { namespace {
struct PluginLoader { struct PluginLoader {
@ -40,5 +39,3 @@ namespace {
static cl::opt<PluginLoader, false, cl::parser<std::string> > static cl::opt<PluginLoader, false, cl::parser<std::string> >
LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"), LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"),
cl::desc("Load the specified plugin")); cl::desc("Load the specified plugin"));
} // End llvm namespace

View File

@ -19,8 +19,7 @@
#include <cstdio> #include <cstdio>
#include <signal.h> #include <signal.h>
#include "Config/config.h" // Get the signal handler return type #include "Config/config.h" // Get the signal handler return type
using namespace llvm;
namespace llvm {
static std::vector<std::string> FilesToRemove; static std::vector<std::string> FilesToRemove;
@ -58,11 +57,9 @@ static RETSIGTYPE SignalHandler(int Sig) {
static void RegisterHandler(int Signal) { signal(Signal, SignalHandler); } static void RegisterHandler(int Signal) { signal(Signal, SignalHandler); }
// RemoveFileOnSignal - The public API // RemoveFileOnSignal - The public API
void RemoveFileOnSignal(const std::string &Filename) { void llvm::RemoveFileOnSignal(const std::string &Filename) {
FilesToRemove.push_back(Filename); FilesToRemove.push_back(Filename);
std::for_each(IntSigs, IntSigsEnd, RegisterHandler); std::for_each(IntSigs, IntSigsEnd, RegisterHandler);
std::for_each(KillSigs, KillSigsEnd, RegisterHandler); std::for_each(KillSigs, KillSigsEnd, RegisterHandler);
} }
} // End llvm namespace

View File

@ -23,13 +23,12 @@
#include "Config/sys/wait.h" #include "Config/sys/wait.h"
#include "Config/unistd.h" #include "Config/unistd.h"
#include "Config/errno.h" #include "Config/errno.h"
using namespace llvm;
namespace llvm {
/// isExecutableFile - This function returns true if the filename specified /// isExecutableFile - This function returns true if the filename specified
/// exists and is executable. /// exists and is executable.
/// ///
bool isExecutableFile(const std::string &ExeFileName) { bool llvm::isExecutableFile(const std::string &ExeFileName) {
struct stat Buf; struct stat Buf;
if (stat(ExeFileName.c_str(), &Buf)) if (stat(ExeFileName.c_str(), &Buf))
return false; // Must not be executable! return false; // Must not be executable!
@ -51,8 +50,8 @@ bool isExecutableFile(const std::string &ExeFileName) {
/// directory, nor in the PATH. If the executable cannot be found, return an /// directory, nor in the PATH. If the executable cannot be found, return an
/// empty string. /// empty string.
/// ///
std::string FindExecutable(const std::string &ExeName, std::string llvm::FindExecutable(const std::string &ExeName,
const std::string &ProgramPath) { const std::string &ProgramPath) {
// First check the directory that bugpoint is in. We can do this if // First check the directory that bugpoint is in. We can do this if
// BugPointPath contains at least one / character, indicating that it is a // BugPointPath contains at least one / character, indicating that it is a
// relative path to bugpoint itself. // relative path to bugpoint itself.
@ -116,11 +115,11 @@ static void RedirectFD(const std::string &File, int FD) {
/// the calling program if there is an error executing the specified program. /// the calling program if there is an error executing the specified program.
/// It returns the return value of the program, or -1 if a timeout is detected. /// It returns the return value of the program, or -1 if a timeout is detected.
/// ///
int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, int llvm::RunProgramWithTimeout(const std::string &ProgramPath,
const std::string &StdInFile, const char **Args,
const std::string &StdOutFile, const std::string &StdInFile,
const std::string &StdErrFile) { const std::string &StdOutFile,
const std::string &StdErrFile) {
// FIXME: install sigalarm handler here for timeout... // FIXME: install sigalarm handler here for timeout...
int Child = fork(); int Child = fork();
@ -204,9 +203,8 @@ int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args,
// //
// This function does not use $PATH to find programs. // This function does not use $PATH to find programs.
// //
int int llvm::ExecWait(const char * const old_argv[],
ExecWait (const char * const old_argv[], const char * const old_envp[]) const char * const old_envp[]) {
{
// Child process ID // Child process ID
register int child; register int child;
@ -273,5 +271,3 @@ ExecWait (const char * const old_argv[], const char * const old_envp[])
// //
return 1; return 1;
} }
} // End llvm namespace

View File

@ -18,25 +18,26 @@
#include "Support/FileUtilities.h" #include "Support/FileUtilities.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace llvm;
namespace llvm {
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
// LLI Implementation of AbstractIntepreter interface // LLI Implementation of AbstractIntepreter interface
// //
class LLI : public AbstractInterpreter { namespace {
std::string LLIPath; // The path to the LLI executable class LLI : public AbstractInterpreter {
public: std::string LLIPath; // The path to the LLI executable
LLI(const std::string &Path) : LLIPath(Path) { } public:
LLI(const std::string &Path) : LLIPath(Path) { }
virtual int ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, virtual int ExecuteProgram(const std::string &Bytecode,
const std::string &InputFile, const std::vector<std::string> &Args,
const std::string &OutputFile, const std::string &InputFile,
const std::vector<std::string> &SharedLibs = const std::string &OutputFile,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>()); std::vector<std::string>());
}; };
}
int LLI::ExecuteProgram(const std::string &Bytecode, int LLI::ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, const std::vector<std::string> &Args,
@ -148,19 +149,21 @@ LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
// JIT Implementation of AbstractIntepreter interface // JIT Implementation of AbstractIntepreter interface
// //
class JIT : public AbstractInterpreter { namespace {
std::string LLIPath; // The path to the LLI executable class JIT : public AbstractInterpreter {
public: std::string LLIPath; // The path to the LLI executable
JIT(const std::string &Path) : LLIPath(Path) { } public:
JIT(const std::string &Path) : LLIPath(Path) { }
virtual int ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, virtual int ExecuteProgram(const std::string &Bytecode,
const std::string &InputFile, const std::vector<std::string> &Args,
const std::string &OutputFile, const std::string &InputFile,
const std::vector<std::string> &SharedLibs = const std::string &OutputFile,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>()); std::vector<std::string>());
}; };
}
int JIT::ExecuteProgram(const std::string &Bytecode, int JIT::ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, const std::vector<std::string> &Args,
@ -396,5 +399,3 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
Message = "Found gcc: " + GCCPath + "\n"; Message = "Found gcc: " + GCCPath + "\n";
return new GCC(GCCPath); return new GCC(GCCPath);
} }
} // End llvm namespace

View File

@ -18,10 +18,8 @@
#include "llvm/Support/ValueHolder.h" #include "llvm/Support/ValueHolder.h"
#include "llvm/Type.h" #include "llvm/Type.h"
namespace llvm { using namespace llvm;
ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) { ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) {
Operands.push_back(Use(V, this)); Operands.push_back(Use(V, this));
} }
} // End llvm namespace

View File

@ -25,8 +25,7 @@
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/Instruction.h" #include "llvm/Instruction.h"
#include "llvm/ConstantHandling.h" #include "llvm/ConstantHandling.h"
using namespace llvm;
namespace llvm {
/// Initialize a full (the default) or empty set for the specified type. /// Initialize a full (the default) or empty set for the specified type.
/// ///
@ -250,5 +249,3 @@ void ConstantRange::print(std::ostream &OS) const {
void ConstantRange::dump() const { void ConstantRange::dump() const {
print(std::cerr); print(std::cerr);
} }
} // End llvm namespace

View File

@ -14,8 +14,7 @@
#include "Support/LeakDetector.h" #include "Support/LeakDetector.h"
#include "llvm/Value.h" #include "llvm/Value.h"
#include <set> #include <set>
using namespace llvm;
namespace llvm {
// Lazily allocate set so that release build doesn't have to do anything. // Lazily allocate set so that release build doesn't have to do anything.
static std::set<const void*> *Objects = 0; static std::set<const void*> *Objects = 0;
@ -89,5 +88,3 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) {
Objects = 0; LLVMObjects = 0; Objects = 0; LLVMObjects = 0;
} }
} }
} // End llvm namespace

View File

@ -15,8 +15,7 @@
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "Support/StringExtras.h" #include "Support/StringExtras.h"
using namespace llvm;
namespace llvm {
static char HexDigit(int V) { static char HexDigit(int V) {
return V < 10 ? V+'0' : V+'A'-10; return V < 10 ? V+'0' : V+'A'-10;
@ -100,5 +99,3 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix)
else else
FoundNames.insert(I->getName()); // Otherwise, keep track of name FoundNames.insert(I->getName()); // Otherwise, keep track of name
} }
} // End llvm namespace

View File

@ -18,25 +18,26 @@
#include "Support/FileUtilities.h" #include "Support/FileUtilities.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace llvm;
namespace llvm {
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
// LLI Implementation of AbstractIntepreter interface // LLI Implementation of AbstractIntepreter interface
// //
class LLI : public AbstractInterpreter { namespace {
std::string LLIPath; // The path to the LLI executable class LLI : public AbstractInterpreter {
public: std::string LLIPath; // The path to the LLI executable
LLI(const std::string &Path) : LLIPath(Path) { } public:
LLI(const std::string &Path) : LLIPath(Path) { }
virtual int ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, virtual int ExecuteProgram(const std::string &Bytecode,
const std::string &InputFile, const std::vector<std::string> &Args,
const std::string &OutputFile, const std::string &InputFile,
const std::vector<std::string> &SharedLibs = const std::string &OutputFile,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>()); std::vector<std::string>());
}; };
}
int LLI::ExecuteProgram(const std::string &Bytecode, int LLI::ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, const std::vector<std::string> &Args,
@ -148,19 +149,21 @@ LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
// JIT Implementation of AbstractIntepreter interface // JIT Implementation of AbstractIntepreter interface
// //
class JIT : public AbstractInterpreter { namespace {
std::string LLIPath; // The path to the LLI executable class JIT : public AbstractInterpreter {
public: std::string LLIPath; // The path to the LLI executable
JIT(const std::string &Path) : LLIPath(Path) { } public:
JIT(const std::string &Path) : LLIPath(Path) { }
virtual int ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, virtual int ExecuteProgram(const std::string &Bytecode,
const std::string &InputFile, const std::vector<std::string> &Args,
const std::string &OutputFile, const std::string &InputFile,
const std::vector<std::string> &SharedLibs = const std::string &OutputFile,
const std::vector<std::string> &SharedLibs =
std::vector<std::string>()); std::vector<std::string>());
}; };
}
int JIT::ExecuteProgram(const std::string &Bytecode, int JIT::ExecuteProgram(const std::string &Bytecode,
const std::vector<std::string> &Args, const std::vector<std::string> &Args,
@ -396,5 +399,3 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
Message = "Found gcc: " + GCCPath + "\n"; Message = "Found gcc: " + GCCPath + "\n";
return new GCC(GCCPath); return new GCC(GCCPath);
} }
} // End llvm namespace