mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Add a "-gcc-tool-args" option. This option acts like the "-tool-args" option,
but passes the arguments to the "gcc" invocation instead of to the "llc" invocation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65896 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0b82f77e66
commit
38efa38c86
@ -111,6 +111,11 @@ namespace {
|
|||||||
SafeToolArgv("safe-tool-args", cl::Positional,
|
SafeToolArgv("safe-tool-args", cl::Positional,
|
||||||
cl::desc("<safe-tool arguments>..."),
|
cl::desc("<safe-tool arguments>..."),
|
||||||
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
||||||
|
|
||||||
|
cl::list<std::string>
|
||||||
|
GCCToolArgv("gcc-tool-args", cl::Positional,
|
||||||
|
cl::desc("<gcc-tool arguments>..."),
|
||||||
|
cl::ZeroOrMore, cl::PositionalEatsArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -132,7 +137,8 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
case AutoPick:
|
case AutoPick:
|
||||||
InterpreterSel = RunCBE;
|
InterpreterSel = RunCBE;
|
||||||
Interpreter =
|
Interpreter =
|
||||||
AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv);
|
AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv,
|
||||||
|
&GCCToolArgv);
|
||||||
if (!Interpreter) {
|
if (!Interpreter) {
|
||||||
InterpreterSel = RunJIT;
|
InterpreterSel = RunJIT;
|
||||||
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
|
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
|
||||||
@ -141,7 +147,7 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
if (!Interpreter) {
|
if (!Interpreter) {
|
||||||
InterpreterSel = RunLLC;
|
InterpreterSel = RunLLC;
|
||||||
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
|
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
|
||||||
&ToolArgv);
|
&ToolArgv, &GCCToolArgv);
|
||||||
}
|
}
|
||||||
if (!Interpreter) {
|
if (!Interpreter) {
|
||||||
InterpreterSel = RunLLI;
|
InterpreterSel = RunLLI;
|
||||||
@ -160,7 +166,7 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
case RunLLC:
|
case RunLLC:
|
||||||
case LLC_Safe:
|
case LLC_Safe:
|
||||||
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
|
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
|
||||||
&ToolArgv);
|
&ToolArgv, &GCCToolArgv);
|
||||||
break;
|
break;
|
||||||
case RunJIT:
|
case RunJIT:
|
||||||
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
|
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
|
||||||
@ -169,7 +175,7 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
case RunCBE:
|
case RunCBE:
|
||||||
case CBE_bug:
|
case CBE_bug:
|
||||||
Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
|
Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
|
||||||
&ToolArgv);
|
&ToolArgv, &GCCToolArgv);
|
||||||
break;
|
break;
|
||||||
case Custom:
|
case Custom:
|
||||||
Interpreter = AbstractInterpreter::createCustom(getToolName(), Message,
|
Interpreter = AbstractInterpreter::createCustom(getToolName(), Message,
|
||||||
@ -196,7 +202,8 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
SafeInterpreterSel = RunLLC;
|
SafeInterpreterSel = RunLLC;
|
||||||
SafeToolArgs.push_back("--relocation-model=pic");
|
SafeToolArgs.push_back("--relocation-model=pic");
|
||||||
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
||||||
&SafeToolArgs);
|
&SafeToolArgs,
|
||||||
|
&GCCToolArgv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In "llc-safe" mode, default to using LLC as the "safe" backend.
|
// In "llc-safe" mode, default to using LLC as the "safe" backend.
|
||||||
@ -205,7 +212,8 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
SafeInterpreterSel = RunLLC;
|
SafeInterpreterSel = RunLLC;
|
||||||
SafeToolArgs.push_back("--relocation-model=pic");
|
SafeToolArgs.push_back("--relocation-model=pic");
|
||||||
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
||||||
&SafeToolArgs);
|
&SafeToolArgs,
|
||||||
|
&GCCToolArgv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick a backend that's different from the test backend. The JIT and
|
// Pick a backend that's different from the test backend. The JIT and
|
||||||
@ -215,7 +223,8 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
InterpreterSel != RunCBE) {
|
InterpreterSel != RunCBE) {
|
||||||
SafeInterpreterSel = RunCBE;
|
SafeInterpreterSel = RunCBE;
|
||||||
SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
|
||||||
&SafeToolArgs);
|
&SafeToolArgs,
|
||||||
|
&GCCToolArgv);
|
||||||
}
|
}
|
||||||
if (!SafeInterpreter &&
|
if (!SafeInterpreter &&
|
||||||
InterpreterSel != RunLLC &&
|
InterpreterSel != RunLLC &&
|
||||||
@ -223,7 +232,8 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
SafeInterpreterSel = RunLLC;
|
SafeInterpreterSel = RunLLC;
|
||||||
SafeToolArgs.push_back("--relocation-model=pic");
|
SafeToolArgs.push_back("--relocation-model=pic");
|
||||||
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
||||||
&SafeToolArgs);
|
&SafeToolArgs,
|
||||||
|
&GCCToolArgv);
|
||||||
}
|
}
|
||||||
if (!SafeInterpreter) {
|
if (!SafeInterpreter) {
|
||||||
SafeInterpreterSel = AutoPick;
|
SafeInterpreterSel = AutoPick;
|
||||||
@ -233,11 +243,13 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
case RunLLC:
|
case RunLLC:
|
||||||
SafeToolArgs.push_back("--relocation-model=pic");
|
SafeToolArgs.push_back("--relocation-model=pic");
|
||||||
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createLLC(Path, Message,
|
||||||
&SafeToolArgs);
|
&SafeToolArgs,
|
||||||
|
&GCCToolArgv);
|
||||||
break;
|
break;
|
||||||
case RunCBE:
|
case RunCBE:
|
||||||
SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createCBE(Path, Message,
|
||||||
&SafeToolArgs);
|
&SafeToolArgs,
|
||||||
|
&GCCToolArgv);
|
||||||
break;
|
break;
|
||||||
case Custom:
|
case Custom:
|
||||||
SafeInterpreter = AbstractInterpreter::createCustom(Path, Message,
|
SafeInterpreter = AbstractInterpreter::createCustom(Path, Message,
|
||||||
@ -250,7 +262,7 @@ bool BugDriver::initializeExecutionEnvironment() {
|
|||||||
}
|
}
|
||||||
if (!SafeInterpreter) { std::cout << Message << "\nExiting.\n"; exit(1); }
|
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 (!gcc) { std::cout << Message << "\nExiting.\n"; exit(1); }
|
||||||
|
|
||||||
// If there was an error creating the selected interpreter, quit with error.
|
// If there was an error creating the selected interpreter, quit with error.
|
||||||
@ -406,7 +418,7 @@ bool BugDriver::createReferenceFile(Module *M, const std::string &Filename) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ReferenceOutputFile = executeProgramSafely(Filename);
|
ReferenceOutputFile = executeProgramSafely(Filename);
|
||||||
std::cout << "Reference output is: " << ReferenceOutputFile << "\n\n";
|
std::cout << "\nReference output is: " << ReferenceOutputFile << "\n\n";
|
||||||
} catch (ToolExecutionError &TEE) {
|
} catch (ToolExecutionError &TEE) {
|
||||||
std::cerr << TEE.what();
|
std::cerr << TEE.what();
|
||||||
if (Interpreter != SafeInterpreter) {
|
if (Interpreter != SafeInterpreter) {
|
||||||
|
@ -344,7 +344,8 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
|
|||||||
FileRemover OutFileRemover(OutputAsmFile);
|
FileRemover OutFileRemover(OutputAsmFile);
|
||||||
|
|
||||||
std::vector<std::string> GCCArgs(ArgsForGCC);
|
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.
|
// Assuming LLC worked, compile the result with GCC and run it.
|
||||||
return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile,
|
return gcc->ExecuteProgram(OutputAsmFile.toString(), Args, GCC::AsmFile,
|
||||||
@ -356,7 +357,8 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
|
|||||||
///
|
///
|
||||||
LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
|
LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
|
||||||
std::string &Message,
|
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();
|
std::string LLCPath = FindExecutable("llc", ProgramPath).toString();
|
||||||
if (LLCPath.empty()) {
|
if (LLCPath.empty()) {
|
||||||
Message = "Cannot find `llc' in executable directory or PATH!\n";
|
Message = "Cannot find `llc' in executable directory or PATH!\n";
|
||||||
@ -364,12 +366,12 @@ LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Message = "Found llc: " + LLCPath + "\n";
|
Message = "Found llc: " + LLCPath + "\n";
|
||||||
GCC *gcc = GCC::create(ProgramPath, Message);
|
GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
|
||||||
if (!gcc) {
|
if (!gcc) {
|
||||||
std::cerr << Message << "\n";
|
std::cerr << Message << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return new LLC(LLCPath, gcc, Args);
|
return new LLC(LLCPath, gcc, Args, GCCArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
@ -509,7 +511,8 @@ int CBE::ExecuteProgram(const std::string &Bitcode,
|
|||||||
FileRemover CFileRemove(OutputCFile);
|
FileRemover CFileRemove(OutputCFile);
|
||||||
|
|
||||||
std::vector<std::string> GCCArgs(ArgsForGCC);
|
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,
|
return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile,
|
||||||
InputFile, OutputFile, GCCArgs,
|
InputFile, OutputFile, GCCArgs,
|
||||||
Timeout, MemoryLimit);
|
Timeout, MemoryLimit);
|
||||||
@ -519,7 +522,8 @@ int CBE::ExecuteProgram(const std::string &Bitcode,
|
|||||||
///
|
///
|
||||||
CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
|
CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
|
||||||
std::string &Message,
|
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);
|
sys::Path LLCPath = FindExecutable("llc", ProgramPath);
|
||||||
if (LLCPath.isEmpty()) {
|
if (LLCPath.isEmpty()) {
|
||||||
Message =
|
Message =
|
||||||
@ -528,7 +532,7 @@ CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Message = "Found llc: " + LLCPath.toString() + "\n";
|
Message = "Found llc: " + LLCPath.toString() + "\n";
|
||||||
GCC *gcc = GCC::create(ProgramPath, Message);
|
GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
|
||||||
if (!gcc) {
|
if (!gcc) {
|
||||||
std::cerr << Message << "\n";
|
std::cerr << Message << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -551,6 +555,10 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
|
|||||||
|
|
||||||
GCCArgs.push_back(GCCPath.c_str());
|
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
|
// Specify -x explicitly in case the extension is wonky
|
||||||
GCCArgs.push_back("-x");
|
GCCArgs.push_back("-x");
|
||||||
if (fileType == CFile) {
|
if (fileType == CFile) {
|
||||||
@ -725,7 +733,8 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
|
|||||||
|
|
||||||
/// create - Try to find the `gcc' executable
|
/// 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);
|
sys::Path GCCPath = FindExecutable("gcc", ProgramPath);
|
||||||
if (GCCPath.isEmpty()) {
|
if (GCCPath.isEmpty()) {
|
||||||
Message = "Cannot find `gcc' in executable directory or PATH!\n";
|
Message = "Cannot find `gcc' in executable directory or PATH!\n";
|
||||||
@ -737,5 +746,5 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) {
|
|||||||
RemoteClientPath = FindExecutable(RemoteClient.c_str(), ProgramPath);
|
RemoteClientPath = FindExecutable(RemoteClient.c_str(), ProgramPath);
|
||||||
|
|
||||||
Message = "Found gcc: " + GCCPath.toString() + "\n";
|
Message = "Found gcc: " + GCCPath.toString() + "\n";
|
||||||
return new GCC(GCCPath, RemoteClientPath);
|
return new GCC(GCCPath, RemoteClientPath, Args);
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,19 @@ public:
|
|||||||
// GCC abstraction
|
// GCC abstraction
|
||||||
//
|
//
|
||||||
class GCC {
|
class GCC {
|
||||||
sys::Path GCCPath; // The path to the gcc executable
|
sys::Path GCCPath; // The path to the gcc executable.
|
||||||
sys::Path RemoteClientPath; // The path to the rsh / ssh executable
|
sys::Path RemoteClientPath; // The path to the rsh / ssh executable.
|
||||||
GCC(const sys::Path &gccPath, const sys::Path &RemotePath)
|
std::vector<std::string> gccArgs; // GCC-specific arguments.
|
||||||
: GCCPath(gccPath), RemoteClientPath(RemotePath) { }
|
GCC(const sys::Path &gccPath, const sys::Path &RemotePath,
|
||||||
|
const std::vector<std::string> *GCCArgs)
|
||||||
|
: GCCPath(gccPath), RemoteClientPath(RemotePath) {
|
||||||
|
if (GCCArgs) gccArgs = *GCCArgs;
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
enum FileType { AsmFile, CFile };
|
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
|
/// ExecuteProgram - Execute the program specified by "ProgramFile" (which is
|
||||||
/// either a .s file, or a .c file, specified by FileType), with the specified
|
/// either a .s file, or a .c file, specified by FileType), with the specified
|
||||||
@ -86,9 +91,11 @@ public:
|
|||||||
class AbstractInterpreter {
|
class AbstractInterpreter {
|
||||||
public:
|
public:
|
||||||
static CBE *createCBE(const std::string &ProgramPath, std::string &Message,
|
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,
|
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,
|
static AbstractInterpreter* createLLI(const std::string &ProgramPath,
|
||||||
std::string &Message,
|
std::string &Message,
|
||||||
@ -139,14 +146,15 @@ public:
|
|||||||
// CBE Implementation of AbstractIntepreter interface
|
// CBE Implementation of AbstractIntepreter interface
|
||||||
//
|
//
|
||||||
class CBE : public AbstractInterpreter {
|
class CBE : public AbstractInterpreter {
|
||||||
sys::Path LLCPath; // The path to the `llc' executable
|
sys::Path LLCPath; // The path to the `llc' executable.
|
||||||
std::vector<std::string> ToolArgs; // Extra args to pass to LLC
|
std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
|
||||||
GCC *gcc;
|
GCC *gcc;
|
||||||
public:
|
public:
|
||||||
CBE(const sys::Path &llcPath, GCC *Gcc,
|
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 ();
|
ToolArgs.clear ();
|
||||||
if (Args) { ToolArgs = *Args; }
|
if (Args) ToolArgs = *Args;
|
||||||
}
|
}
|
||||||
~CBE() { delete gcc; }
|
~CBE() { delete gcc; }
|
||||||
|
|
||||||
@ -180,14 +188,18 @@ public:
|
|||||||
// LLC Implementation of AbstractIntepreter interface
|
// LLC Implementation of AbstractIntepreter interface
|
||||||
//
|
//
|
||||||
class LLC : public AbstractInterpreter {
|
class LLC : public AbstractInterpreter {
|
||||||
std::string LLCPath; // The path to the LLC executable
|
std::string LLCPath; // The path to the LLC executable.
|
||||||
std::vector<std::string> ToolArgs; // Extra args to pass to LLC
|
std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
|
||||||
|
std::vector<std::string> gccArgs; // Extra args to pass to GCC.
|
||||||
GCC *gcc;
|
GCC *gcc;
|
||||||
public:
|
public:
|
||||||
LLC(const std::string &llcPath, GCC *Gcc,
|
LLC(const std::string &llcPath, GCC *Gcc,
|
||||||
const std::vector<std::string> *Args) : LLCPath(llcPath), gcc(Gcc) {
|
const std::vector<std::string> *Args,
|
||||||
ToolArgs.clear ();
|
const std::vector<std::string> *GCCArgs)
|
||||||
if (Args) { ToolArgs = *Args; }
|
: LLCPath(llcPath), gcc(Gcc) {
|
||||||
|
ToolArgs.clear();
|
||||||
|
if (Args) ToolArgs = *Args;
|
||||||
|
if (GCCArgs) gccArgs = *GCCArgs;
|
||||||
}
|
}
|
||||||
~LLC() { delete gcc; }
|
~LLC() { delete gcc; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user