Debug flag for target's info was added

This commit is contained in:
Vsevolod Livinskiy
2015-05-21 11:33:05 +03:00
parent ebe165dff8
commit bd65df8ad4
4 changed files with 18 additions and 5 deletions

View File

@@ -418,7 +418,7 @@ public:
};
Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, std::string genericAsSmth) :
Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, bool printTarget, std::string genericAsSmth) :
m_target(NULL),
m_targetMachine(NULL),
m_dataLayout(NULL),
@@ -1049,6 +1049,12 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, std
m_valid = !error;
if (printTarget) {
printf("Target Triple: %s\n", m_targetMachine->getTargetTriple().str().c_str());
printf("Target CPU: %s\n", m_targetMachine->getTargetCPU().str().c_str());
printf("Target Feature String: %s\n", m_targetMachine->getTargetFeatureString().str().c_str());
}
return;
}
@@ -1379,6 +1385,7 @@ Globals::Globals() {
includeStdlib = true;
runCPP = true;
debugPrint = false;
printTarget = false;
debugIR = -1;
disableWarnings = false;
warningsAsErrors = false;

5
ispc.h
View File

@@ -207,7 +207,7 @@ public:
/** Initializes the given Target pointer for a target of the given
name, if the name is a known target. Returns true if the
target was initialized and false if the name is unknown. */
Target(const char *arch, const char *cpu, const char *isa, bool pic, std::string genenricAsSmth = "");
Target(const char *arch, const char *cpu, const char *isa, bool pic, bool printTarget, std::string genenricAsSmth = "");
/** Returns a comma-delimited string giving the names of the currently
supported compilation targets. */
@@ -559,6 +559,9 @@ struct Globals {
ispc's execution. */
bool debugPrint;
/** When \c true, target ISA will be printed during ispc's execution. */
bool printTarget;
/** Indicates which stages of optimization we want to dump. */
std::set<int> debug_stages;

View File

@@ -153,6 +153,7 @@ devUsage(int ret) {
lPrintVersion();
printf("\nusage (developer options): ispc\n");
printf(" [--debug]\t\t\t\tPrint information useful for debugging ispc\n");
printf(" [--print-target]\t\t\tPrint target's information\n");
printf(" [--dllexport]\t\t\tMake non-static functions DLL exported. Windows only.\n");
printf(" [--fuzz-test]\t\t\tRandomly perturb program input to test error conditions\n");
printf(" [--fuzz-seed=<value>]\t\tSeed value for RNG for fuzz testing\n");
@@ -382,6 +383,8 @@ int main(int Argc, char *Argv[]) {
g->debugPrint = true;
else if (!strcmp(argv[i], "--dllexport"))
g->dllExport = true;
else if (!strcmp(argv[i], "--print-target"))
g->printTarget = true;
else if (!strcmp(argv[i], "--instrument"))
g->emitInstrumentation = true;
else if (!strcmp(argv[i], "-g")) {

View File

@@ -3055,7 +3055,7 @@ Module::CompileAndOutput(const char *srcFile,
{
if (target == NULL || strchr(target, ',') == NULL) {
// We're only compiling to a single target
g->target = new Target(arch, cpu, target, generatePIC);
g->target = new Target(arch, cpu, target, generatePIC, g->printTarget);
if (!g->target->isValid())
return 1;
@@ -3198,7 +3198,7 @@ Module::CompileAndOutput(const char *srcFile,
std::string treatGenericAsSmth = "";
for (unsigned int i = 0; i < targets.size(); ++i) {
g->target = new Target(arch, cpu, targets[i].c_str(), generatePIC);
g->target = new Target(arch, cpu, targets[i].c_str(), generatePIC, g->printTarget);
if (!g->target->isValid())
return 1;
@@ -3293,7 +3293,7 @@ Module::CompileAndOutput(const char *srcFile,
}
Assert(firstTargetMachine != NULL);
g->target = new Target(arch, cpu, firstISA, generatePIC, treatGenericAsSmth);
g->target = new Target(arch, cpu, firstISA, generatePIC, false, treatGenericAsSmth);
if (!g->target->isValid()) {
return 1;
}