SafeToolArgv("safe-tool-args", cl::Positional,
cl::desc("<safe-tool arguments>..."),
cl::ZeroOrMore, cl::PositionalEatsArgs);
+
+ cl::list<std::string>
+ GCCToolArgv("gcc-tool-args", cl::Positional,
+ cl::desc("<gcc-tool arguments>..."),
+ cl::ZeroOrMore, cl::PositionalEatsArgs);
}
//===----------------------------------------------------------------------===//
case AutoPick:
InterpreterSel = RunCBE;
Interpreter =
- AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv);
+ AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv,
+ &GCCToolArgv);
if (!Interpreter) {
InterpreterSel = RunJIT;
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
if (!Interpreter) {
InterpreterSel = RunLLC;
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
- &ToolArgv);
+ &ToolArgv, &GCCToolArgv);
}
if (!Interpreter) {
InterpreterSel = RunLLI;
case RunLLC:
case LLC_Safe:
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
- &ToolArgv);
+ &ToolArgv, &GCCToolArgv);
break;
case RunJIT:
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
case RunCBE:
case CBE_bug:
Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
- &ToolArgv);
+ &ToolArgv, &GCCToolArgv);
break;
case Custom:
Interpreter = AbstractInterpreter::createCustom(getToolName(), Message,
SafeInterpreterSel = RunLLC;
SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
- &SafeToolArgs);
+ &SafeToolArgs,
+ &GCCToolArgv);
}
// In "llc-safe" mode, default to using LLC as the "safe" backend.
SafeInterpreterSel = RunLLC;
SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
- &SafeToolArgs);
+ &SafeToolArgs,
+ &GCCToolArgv);
}
// Pick a backend that's different from the test backend. The JIT and
InterpreterSel != RunCBE) {
SafeInterpreterSel = RunCBE;
SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
- &SafeToolArgs);
+ &SafeToolArgs,
+ &GCCToolArgv);
}
if (!SafeInterpreter &&
InterpreterSel != RunLLC &&
SafeInterpreterSel = RunLLC;
SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
- &SafeToolArgs);
+ &SafeToolArgs,
+ &GCCToolArgv);
}
if (!SafeInterpreter) {
SafeInterpreterSel = AutoPick;
case RunLLC:
SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
- &SafeToolArgs);
+ &SafeToolArgs,
+ &GCCToolArgv);
break;
case RunCBE:
SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
- &SafeToolArgs);
+ &SafeToolArgs,
+ &GCCToolArgv);
break;
case Custom:
SafeInterpreter = AbstractInterpreter::createCustom(Path, Message,
}
if (!SafeInterpreter) { std::cout << Message << "\nExiting.\n"; exit(1); }
- gcc = GCC::create(getToolName(), Message);
+ gcc = GCC::create(getToolName(), Message, &GCCToolArgv);
if (!gcc) { std::cout << Message << "\nExiting.\n"; exit(1); }
// If there was an error creating the selected interpreter, quit with error.
}
try {
ReferenceOutputFile = executeProgramSafely(Filename);
- std::cout << "Reference output is: " << ReferenceOutputFile << "\n\n";
+ std::cout << "\nReference output is: " << ReferenceOutputFile << "\n\n";
} catch (ToolExecutionError &TEE) {
std::cerr << TEE.what();
if (Interpreter != SafeInterpreter) {
FileRemover OutFileRemover(OutputAsmFile);
std::vector<std::string> GCCArgs(ArgsForGCC);
- GCCArgs.insert(GCCArgs.end(),SharedLibs.begin(),SharedLibs.end());
+ GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
+ GCCArgs.insert(GCCArgs.end(), gccArgs.begin(), gccArgs.end());
// Assuming LLC worked, compile the result with GCC and run it.
return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile,
///
LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
std::string &Message,
- const std::vector<std::string> *Args) {
+ const std::vector<std::string> *Args,
+ const std::vector<std::string> *GCCArgs) {
std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
if (LLCPath.empty()) {
Message = "Cannot find `llc' in executable directory or PATH!\n";
}
Message = "Found llc: " + LLCPath + "\n";
- GCC *gcc = GCC::create(ProgramPath, Message);
+ GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
if (!gcc) {
std::cerr << Message << "\n";
exit(1);
}
- return new LLC(LLCPath, gcc, Args);
+ return new LLC(LLCPath, gcc, Args, GCCArgs);
}
//===---------------------------------------------------------------------===//
FileRemover CFileRemove(OutputCFile);
std::vector<std::string> GCCArgs(ArgsForGCC);
- GCCArgs.insert(GCCArgs.end(),SharedLibs.begin(),SharedLibs.end());
+ GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
+
return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile,
InputFile, OutputFile, GCCArgs,
Timeout, MemoryLimit);
///
CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
std::string &Message,
- const std::vector<std::string> *Args) {
+ const std::vector<std::string> *Args,
+ const std::vector<std::string> *GCCArgs) {
sys::Path LLCPath = FindExecutable("llc", ProgramPath);
if (LLCPath.isEmpty()) {
Message =
}
Message = "Found llc: " + LLCPath.toString() + "\n";
- GCC *gcc = GCC::create(ProgramPath, Message);
+ GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
if (!gcc) {
std::cerr << Message << "\n";
exit(1);
GCCArgs.push_back(GCCPath.c_str());
+ for (std::vector<std::string>::const_iterator
+ I = gccArgs.begin(), E = gccArgs.end(); I != E; ++I)
+ GCCArgs.push_back(I->c_str());
+
// Specify -x explicitly in case the extension is wonky
GCCArgs.push_back("-x");
if (fileType == CFile) {
/// create - Try to find the `gcc' executable
///
-GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
+GCC *GCC::create(const std::string &ProgramPath, std::string &Message,
+ const std::vector<std::string> *Args) {
sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
if (GCCPath.isEmpty()) {
Message = "Cannot find `gcc' in executable directory or PATH!\n";
RemoteClientPath = FindExecutable(RemoteClient.c_str(), ProgramPath);
Message = "Found gcc: " + GCCPath.toString() + "\n";
- return new GCC(GCCPath, RemoteClientPath);
+ return new GCC(GCCPath, RemoteClientPath, Args);
}
// GCC abstraction
//
class GCC {
- sys::Path GCCPath; // The path to the gcc executable
- sys::Path RemoteClientPath; // The path to the rsh / ssh executable
- GCC(const sys::Path &gccPath, const sys::Path &RemotePath)
- : GCCPath(gccPath), RemoteClientPath(RemotePath) { }
+ sys::Path GCCPath; // The path to the gcc executable.
+ sys::Path RemoteClientPath; // The path to the rsh / ssh executable.
+ std::vector<std::string> gccArgs; // GCC-specific arguments.
+ GCC(const sys::Path &gccPath, const sys::Path &RemotePath,
+ const std::vector<std::string> *GCCArgs)
+ : GCCPath(gccPath), RemoteClientPath(RemotePath) {
+ if (GCCArgs) gccArgs = *GCCArgs;
+ }
public:
enum FileType { AsmFile, CFile };
- static GCC *create(const std::string &ProgramPath, std::string &Message);
+ static GCC *create(const std::string &ProgramPath, std::string &Message,
+ const std::vector<std::string> *Args);
/// ExecuteProgram - Execute the program specified by "ProgramFile" (which is
/// either a .s file, or a .c file, specified by FileType), with the specified
class AbstractInterpreter {
public:
static CBE *createCBE(const std::string &ProgramPath, std::string &Message,
- const std::vector<std::string> *Args = 0);
+ const std::vector<std::string> *Args = 0,
+ const std::vector<std::string> *GCCArgs = 0);
static LLC *createLLC(const std::string &ProgramPath, std::string &Message,
- const std::vector<std::string> *Args = 0);
+ const std::vector<std::string> *Args = 0,
+ const std::vector<std::string> *GCCArgs = 0);
static AbstractInterpreter* createLLI(const std::string &ProgramPath,
std::string &Message,
// CBE Implementation of AbstractIntepreter interface
//
class CBE : public AbstractInterpreter {
- sys::Path LLCPath; // The path to the `llc' executable
- std::vector<std::string> ToolArgs; // Extra args to pass to LLC
+ sys::Path LLCPath; // The path to the `llc' executable.
+ std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
GCC *gcc;
public:
CBE(const sys::Path &llcPath, GCC *Gcc,
- const std::vector<std::string> *Args) : LLCPath(llcPath), gcc(Gcc) {
+ const std::vector<std::string> *Args)
+ : LLCPath(llcPath), gcc(Gcc) {
ToolArgs.clear ();
- if (Args) { ToolArgs = *Args; }
+ if (Args) ToolArgs = *Args;
}
~CBE() { delete gcc; }
// LLC Implementation of AbstractIntepreter interface
//
class LLC : public AbstractInterpreter {
- std::string LLCPath; // The path to the LLC executable
- std::vector<std::string> ToolArgs; // Extra args to pass to LLC
+ std::string LLCPath; // The path to the LLC executable.
+ std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
+ std::vector<std::string> gccArgs; // Extra args to pass to GCC.
GCC *gcc;
public:
LLC(const std::string &llcPath, GCC *Gcc,
- const std::vector<std::string> *Args) : LLCPath(llcPath), gcc(Gcc) {
- ToolArgs.clear ();
- if (Args) { ToolArgs = *Args; }
+ const std::vector<std::string> *Args,
+ const std::vector<std::string> *GCCArgs)
+ : LLCPath(llcPath), gcc(Gcc) {
+ ToolArgs.clear();
+ if (Args) ToolArgs = *Args;
+ if (GCCArgs) gccArgs = *GCCArgs;
}
~LLC() { delete gcc; }