1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

Remove trailing whitespace

llvm-svn: 21428
This commit is contained in:
Misha Brukman 2005-04-22 00:00:37 +00:00
parent 53e199440e
commit 960a8d47d7
62 changed files with 549 additions and 549 deletions

View File

@ -1,10 +1,10 @@
//===- AnalysisWrappers.cpp - Wrappers around non-pass analyses -----------===// //===- AnalysisWrappers.cpp - Wrappers around non-pass analyses -----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines pass wrappers around LLVM analyses that don't make sense to // This file defines pass wrappers around LLVM analyses that don't make sense to
@ -56,7 +56,7 @@ namespace {
} }
void print(std::ostream &OS) const {} void print(std::ostream &OS) const {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll(); AU.setPreservesAll();
} }

View File

@ -1,10 +1,10 @@
//===- GraphPrinters.cpp - DOT printers for various graph types -----------===// //===- GraphPrinters.cpp - DOT printers for various graph types -----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines several printers for various different types of graphs used // This file defines several printers for various different types of graphs used
@ -27,7 +27,7 @@ static void WriteGraphToFile(std::ostream &O, const std::string &GraphName,
std::string Filename = GraphName + ".dot"; std::string Filename = GraphName + ".dot";
O << "Writing '" << Filename << "'..."; O << "Writing '" << Filename << "'...";
std::ofstream F(Filename.c_str()); std::ofstream F(Filename.c_str());
if (F.good()) if (F.good())
WriteGraph(F, GT); WriteGraph(F, GT);
else else
@ -46,7 +46,7 @@ namespace llvm {
static std::string getGraphName(CallGraph *F) { static std::string getGraphName(CallGraph *F) {
return "Call Graph"; return "Call Graph";
} }
static std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) { static std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) {
if (Node->getFunction()) if (Node->getFunction())
return ((Value*)Node->getFunction())->getName(); return ((Value*)Node->getFunction())->getName();
@ -65,7 +65,7 @@ namespace {
} }
void print(std::ostream &OS) const {} void print(std::ostream &OS) const {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<CallGraph>(); AU.addRequired<CallGraph>();
AU.setPreservesAll(); AU.setPreservesAll();

View File

@ -1,14 +1,14 @@
//===- analyze.cpp - The LLVM analyze utility -----------------------------===// //===- analyze.cpp - The LLVM analyze utility -----------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility is designed to print out the results of running various analysis // This utility is designed to print out the results of running various analysis
// passes on a program. This is useful for understanding a program, or for // passes on a program. This is useful for understanding a program, or for
// debugging an analysis pass. // debugging an analysis pass.
// //
// analyze --help - Output information about command line switches // analyze --help - Output information about command line switches
@ -37,11 +37,11 @@ struct ModulePassPrinter : public ModulePass {
virtual bool runOnModule(Module &M) { virtual bool runOnModule(Module &M) {
std::cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n"; std::cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
getAnalysisID<Pass>(PassToPrint).print(std::cout, &M); getAnalysisID<Pass>(PassToPrint).print(std::cout, &M);
// Get and print pass... // Get and print pass...
return false; return false;
} }
virtual const char *getPassName() const { return "'Pass' Printer"; } virtual const char *getPassName() const { return "'Pass' Printer"; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
@ -150,7 +150,7 @@ int main(int argc, char **argv) {
// Create a new optimization pass for each one specified on the command line // Create a new optimization pass for each one specified on the command line
for (unsigned i = 0; i < AnalysesList.size(); ++i) { for (unsigned i = 0; i < AnalysesList.size(); ++i) {
const PassInfo *Analysis = AnalysesList[i]; const PassInfo *Analysis = AnalysesList[i];
if (Analysis->getNormalCtor()) { if (Analysis->getNormalCtor()) {
Pass *P = Analysis->getNormalCtor()(); Pass *P = Analysis->getNormalCtor()();
Passes.add(P); Passes.add(P);

View File

@ -1,10 +1,10 @@
//===- BugDriver.cpp - Top-Level BugPoint class implementation ------------===// //===- BugDriver.cpp - Top-Level BugPoint class implementation ------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This class contains all of the shared state and information that is used by // This class contains all of the shared state and information that is used by
@ -35,7 +35,7 @@ namespace {
// otherwise the raw input run through an interpreter is used as the reference // otherwise the raw input run through an interpreter is used as the reference
// source. // source.
// //
cl::opt<std::string> cl::opt<std::string>
OutputFile("output", cl::desc("Specify a reference program output " OutputFile("output", cl::desc("Specify a reference program output "
"(for miscompilation detection)")); "(for miscompilation detection)"));
} }

View File

@ -1,10 +1,10 @@
//===- BugDriver.h - Top-Level BugPoint class -------------------*- C++ -*-===// //===- BugDriver.h - Top-Level BugPoint class -------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This class contains all of the shared state and information that is used by // This class contains all of the shared state and information that is used by
@ -76,7 +76,7 @@ public:
/// reasonable, and figure out exactly which pass is crashing. /// reasonable, and figure out exactly which pass is crashing.
/// ///
bool debugOptimizerCrash(); bool debugOptimizerCrash();
/// debugCodeGeneratorCrash - This method is called when the code generator /// debugCodeGeneratorCrash - This method is called when the code generator
/// crashes on an input. It attempts to reduce the input as much as possible /// crashes on an input. It attempts to reduce the input as much as possible
/// while still causing the code generator to crash. /// while still causing the code generator to crash.
@ -139,7 +139,7 @@ public:
void switchToInterpreter(AbstractInterpreter *AI) { void switchToInterpreter(AbstractInterpreter *AI) {
Interpreter = AI; Interpreter = AI;
} }
/// setNewProgram - If we reduce or update the program somehow, call this /// setNewProgram - If we reduce or update the program somehow, call this
/// method to update bugdriver with it. This deletes the old module and sets /// method to update bugdriver with it. This deletes the old module and sets
/// the specified one as the current program. /// the specified one as the current program.

View File

@ -1,10 +1,10 @@
//===- CrashDebugger.cpp - Debug compilation crashes ----------------------===// //===- CrashDebugger.cpp - Debug compilation crashes ----------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines the bugpoint internals that narrow down compilation crashes // This file defines the bugpoint internals that narrow down compilation crashes
@ -36,7 +36,7 @@ namespace llvm {
BugDriver &BD; BugDriver &BD;
public: public:
ReducePassList(BugDriver &bd) : BD(bd) {} ReducePassList(BugDriver &bd) : BD(bd) {}
// doTest - Return true iff running the "removed" passes succeeds, and // doTest - Return true iff running the "removed" passes succeeds, and
// running the "Kept" passes fail when run on the output of the "removed" // running the "Kept" passes fail when run on the output of the "removed"
// passes. If we return true, we update the current module of bugpoint. // passes. If we return true, we update the current module of bugpoint.
@ -72,7 +72,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
std::cout << "Checking to see if these passes crash: " std::cout << "Checking to see if these passes crash: "
<< getPassesString(Suffix) << ": "; << getPassesString(Suffix) << ": ";
if (BD.runPasses(Suffix)) { if (BD.runPasses(Suffix)) {
delete OrigProgram; // The suffix crashes alone... delete OrigProgram; // The suffix crashes alone...
return KeepSuffix; return KeepSuffix;
@ -94,7 +94,7 @@ namespace llvm {
ReduceCrashingFunctions(BugDriver &bd, ReduceCrashingFunctions(BugDriver &bd,
bool (*testFn)(BugDriver &, Module *)) bool (*testFn)(BugDriver &, Module *))
: BD(bd), TestFn(testFn) {} : BD(bd), TestFn(testFn) {}
virtual TestResult doTest(std::vector<Function*> &Prefix, virtual TestResult doTest(std::vector<Function*> &Prefix,
std::vector<Function*> &Kept) { std::vector<Function*> &Kept) {
if (!Kept.empty() && TestFuncs(Kept)) if (!Kept.empty() && TestFuncs(Kept))
@ -103,7 +103,7 @@ namespace llvm {
return KeepPrefix; return KeepPrefix;
return NoFailure; return NoFailure;
} }
bool TestFuncs(std::vector<Function*> &Prefix); bool TestFuncs(std::vector<Function*> &Prefix);
}; };
} }
@ -111,11 +111,11 @@ namespace llvm {
bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) { bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
// Clone the program to try hacking it apart... // Clone the program to try hacking it apart...
Module *M = CloneModule(BD.getProgram()); Module *M = CloneModule(BD.getProgram());
// Convert list to set for fast lookup... // Convert list to set for fast lookup...
std::set<Function*> Functions; std::set<Function*> Functions;
for (unsigned i = 0, e = Funcs.size(); i != e; ++i) { for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
Function *CMF = M->getFunction(Funcs[i]->getName(), Function *CMF = M->getFunction(Funcs[i]->getName(),
Funcs[i]->getFunctionType()); Funcs[i]->getFunctionType());
assert(CMF && "Function not in module?!"); assert(CMF && "Function not in module?!");
Functions.insert(CMF); Functions.insert(CMF);
@ -157,7 +157,7 @@ namespace {
public: public:
ReduceCrashingBlocks(BugDriver &bd, bool (*testFn)(BugDriver &, Module *)) ReduceCrashingBlocks(BugDriver &bd, bool (*testFn)(BugDriver &, Module *))
: BD(bd), TestFn(testFn) {} : BD(bd), TestFn(testFn) {}
virtual TestResult doTest(std::vector<const BasicBlock*> &Prefix, virtual TestResult doTest(std::vector<const BasicBlock*> &Prefix,
std::vector<const BasicBlock*> &Kept) { std::vector<const BasicBlock*> &Kept) {
if (!Kept.empty() && TestBlocks(Kept)) if (!Kept.empty() && TestBlocks(Kept))
@ -166,7 +166,7 @@ namespace {
return KeepPrefix; return KeepPrefix;
return NoFailure; return NoFailure;
} }
bool TestBlocks(std::vector<const BasicBlock*> &Prefix); bool TestBlocks(std::vector<const BasicBlock*> &Prefix);
}; };
} }
@ -174,7 +174,7 @@ namespace {
bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) { bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// Clone the program to try hacking it apart... // Clone the program to try hacking it apart...
Module *M = CloneModule(BD.getProgram()); Module *M = CloneModule(BD.getProgram());
// Convert list to set for fast lookup... // Convert list to set for fast lookup...
std::set<BasicBlock*> Blocks; std::set<BasicBlock*> Blocks;
for (unsigned i = 0, e = BBs.size(); i != e; ++i) { for (unsigned i = 0, e = BBs.size(); i != e; ++i) {
@ -214,7 +214,7 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
// Delete the old terminator instruction... // Delete the old terminator instruction...
BB->getInstList().pop_back(); BB->getInstList().pop_back();
// Add a new return instruction of the appropriate type... // Add a new return instruction of the appropriate type...
const Type *RetTy = BB->getParent()->getReturnType(); const Type *RetTy = BB->getParent()->getReturnType();
new ReturnInst(RetTy == Type::VoidTy ? 0 : new ReturnInst(RetTy == Type::VoidTy ? 0 :
@ -274,7 +274,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
I->setLinkage(GlobalValue::ExternalLinkage); I->setLinkage(GlobalValue::ExternalLinkage);
DeletedInit = true; DeletedInit = true;
} }
if (!DeletedInit) { if (!DeletedInit) {
delete M; // No change made... delete M; // No change made...
} else { } else {
@ -290,7 +290,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
} }
} }
} }
// Now try to reduce the number of functions in the module to something small. // Now try to reduce the number of functions in the module to something small.
std::vector<Function*> Functions; std::vector<Function*> Functions;
for (Module::iterator I = BD.getProgram()->begin(), for (Module::iterator I = BD.getProgram()->begin(),
@ -343,7 +343,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
// //
unsigned InstructionsToSkipBeforeDeleting = 0; unsigned InstructionsToSkipBeforeDeleting = 0;
TryAgain: TryAgain:
// Loop over all of the (non-terminator) instructions remaining in the // Loop over all of the (non-terminator) instructions remaining in the
// function, attempting to delete them. // function, attempting to delete them.
unsigned CurInstructionNum = 0; unsigned CurInstructionNum = 0;
@ -359,7 +359,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
} else { } else {
std::cout << "Checking instruction '" << I->getName() << "': "; std::cout << "Checking instruction '" << I->getName() << "': ";
Module *M = BD.deleteInstructionFromProgram(I, Simplification); Module *M = BD.deleteInstructionFromProgram(I, Simplification);
// Find out if the pass still crashes on this pass... // Find out if the pass still crashes on this pass...
if (TestFn(BD, M)) { if (TestFn(BD, M)) {
// Yup, it does, we delete the old module, and continue trying // Yup, it does, we delete the old module, and continue trying
@ -369,7 +369,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
InstructionsToSkipBeforeDeleting = CurInstructionNum; InstructionsToSkipBeforeDeleting = CurInstructionNum;
goto TryAgain; // I wish I had a multi-level break here! goto TryAgain; // I wish I had a multi-level break here!
} }
// This pass didn't crash without this instruction, try the next // This pass didn't crash without this instruction, try the next
// one. // one.
delete M; delete M;
@ -379,14 +379,14 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
InstructionsToSkipBeforeDeleting = 0; InstructionsToSkipBeforeDeleting = 0;
goto TryAgain; goto TryAgain;
} }
} while (Simplification); } while (Simplification);
// Try to clean up the testcase by running funcresolve and globaldce... // Try to clean up the testcase by running funcresolve and globaldce...
std::cout << "\n*** Attempting to perform final cleanups: "; std::cout << "\n*** Attempting to perform final cleanups: ";
Module *M = CloneModule(BD.getProgram()); Module *M = CloneModule(BD.getProgram());
M = BD.performFinalCleanups(M, true); M = BD.performFinalCleanups(M, true);
// Find out if the pass still crashes on the cleaned up program... // Find out if the pass still crashes on the cleaned up program...
if (TestFn(BD, M)) { if (TestFn(BD, M)) {
BD.setNewProgram(M); // Yup, it does, keep the reduced version... BD.setNewProgram(M); // Yup, it does, keep the reduced version...
@ -398,7 +398,7 @@ static bool DebugACrash(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *)) {
if (AnyReduction) if (AnyReduction)
BD.EmitProgressBytecode("reduced-simplified"); BD.EmitProgressBytecode("reduced-simplified");
return false; return false;
} }
static bool TestForOptimizerCrash(BugDriver &BD, Module *M) { static bool TestForOptimizerCrash(BugDriver &BD, Module *M) {

View File

@ -1,10 +1,10 @@
//===- ExecutionDriver.cpp - Allow execution of LLVM program --------------===// //===- ExecutionDriver.cpp - Allow execution of LLVM program --------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains code used to execute the program utilizing one of the // This file contains code used to execute the program utilizing one of the
@ -276,7 +276,7 @@ std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
#endif #endif
std::string SharedObjectFile; std::string SharedObjectFile;
if (gcc->MakeSharedObject(OutputCFile.toString(), GCC::CFile, if (gcc->MakeSharedObject(OutputCFile.toString(), GCC::CFile,
SharedObjectFile)) SharedObjectFile))
exit(1); exit(1);
@ -303,7 +303,7 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
// If we're checking the program exit code, assume anything nonzero is bad. // If we're checking the program exit code, assume anything nonzero is bad.
if (CheckProgramExitCode && ProgramExitedNonzero) { if (CheckProgramExitCode && ProgramExitedNonzero) {
Output.destroyFile(); Output.destroyFile();
if (RemoveBytecode) if (RemoveBytecode)
sys::Path(BytecodeFile).destroyFile(); sys::Path(BytecodeFile).destroyFile();
return true; return true;
} }
@ -319,7 +319,7 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
} }
FilesDifferent = true; FilesDifferent = true;
} }
// Remove the generated output. // Remove the generated output.
Output.destroyFile(); Output.destroyFile();

View File

@ -1,10 +1,10 @@
//===- ExtractFunction.cpp - Extract a function from Program --------------===// //===- ExtractFunction.cpp - Extract a function from Program --------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements several methods that are used to extract functions, // This file implements several methods that are used to extract functions,
@ -104,7 +104,7 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
// Make all functions external, so GlobalDCE doesn't delete them... // Make all functions external, so GlobalDCE doesn't delete them...
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
I->setLinkage(GlobalValue::ExternalLinkage); I->setLinkage(GlobalValue::ExternalLinkage);
std::vector<const PassInfo*> CleanupPasses; std::vector<const PassInfo*> CleanupPasses;
CleanupPasses.push_back(getPI(createFunctionResolvingPass())); CleanupPasses.push_back(getPI(createFunctionResolvingPass()));
CleanupPasses.push_back(getPI(createGlobalDCEPass())); CleanupPasses.push_back(getPI(createGlobalDCEPass()));
@ -155,7 +155,7 @@ Module *BugDriver::ExtractLoop(Module *M) {
for (unsigned i = 0, e = M->size(); i != e; ++i) for (unsigned i = 0, e = M->size(); i != e; ++i)
++MI; ++MI;
} }
return NewM; return NewM;
} }
@ -251,7 +251,7 @@ bool BlockExtractorPass::runOnModule(Module &M) {
for (unsigned i = 0, e = BlocksToExtract.size(); i != e; ++i) for (unsigned i = 0, e = BlocksToExtract.size(); i != e; ++i)
ExtractBasicBlock(BlocksToExtract[i]); ExtractBasicBlock(BlocksToExtract[i]);
return !BlocksToExtract.empty(); return !BlocksToExtract.empty();
} }

View File

@ -1,10 +1,10 @@
//===- ListReducer.h - Trim down list while retaining property --*- C++ -*-===// //===- ListReducer.h - Trim down list while retaining property --*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This class is to be used as a base class for operations that want to zero in // This class is to be used as a base class for operations that want to zero in
@ -48,7 +48,7 @@ struct ListReducer {
case KeepPrefix: case KeepPrefix:
if (TheList.size() == 1) // we are done, it's the base case and it fails if (TheList.size() == 1) // we are done, it's the base case and it fails
return true; return true;
else else
break; // there's definitely an error, but we need to narrow it down break; // there's definitely an error, but we need to narrow it down
case KeepSuffix: case KeepSuffix:
@ -107,7 +107,7 @@ struct ListReducer {
Changed = true; Changed = true;
} }
} }
// This can take a long time if left uncontrolled. For now, don't // This can take a long time if left uncontrolled. For now, don't
// iterate. // iterate.
break; break;
} }

View File

@ -1,10 +1,10 @@
//===- Miscompilation.cpp - Debug program miscompilations -----------------===// //===- Miscompilation.cpp - Debug program miscompilations -----------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements optimizer and code generation miscompilation debugging // This file implements optimizer and code generation miscompilation debugging
@ -37,7 +37,7 @@ namespace {
BugDriver &BD; BugDriver &BD;
public: public:
ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {} ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {}
virtual TestResult doTest(std::vector<const PassInfo*> &Prefix, virtual TestResult doTest(std::vector<const PassInfo*> &Prefix,
std::vector<const PassInfo*> &Suffix); std::vector<const PassInfo*> &Suffix);
}; };
@ -56,7 +56,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
std::string BytecodeResult; std::string BytecodeResult;
if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) { if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) {
std::cerr << " Error running this sequence of passes" std::cerr << " Error running this sequence of passes"
<< " on the input program!\n"; << " on the input program!\n";
BD.setPassesToRun(Suffix); BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
@ -89,7 +89,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// prefix passes, then discard the prefix passes. // prefix passes, then discard the prefix passes.
// //
if (BD.runPasses(Prefix, BytecodeResult, false/*delete*/, true/*quiet*/)) { if (BD.runPasses(Prefix, BytecodeResult, false/*delete*/, true/*quiet*/)) {
std::cerr << " Error running this sequence of passes" std::cerr << " Error running this sequence of passes"
<< " on the input program!\n"; << " on the input program!\n";
BD.setPassesToRun(Prefix); BD.setPassesToRun(Prefix);
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
@ -118,14 +118,14 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// Don't check if there are no passes in the suffix. // Don't check if there are no passes in the suffix.
if (Suffix.empty()) if (Suffix.empty())
return NoFailure; return NoFailure;
std::cout << "Checking to see if '" << getPassesString(Suffix) std::cout << "Checking to see if '" << getPassesString(Suffix)
<< "' passes compile correctly after the '" << "' passes compile correctly after the '"
<< getPassesString(Prefix) << "' passes: "; << getPassesString(Prefix) << "' passes: ";
Module *OriginalInput = BD.swapProgramIn(PrefixOutput); Module *OriginalInput = BD.swapProgramIn(PrefixOutput);
if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) { if (BD.runPasses(Suffix, BytecodeResult, false/*delete*/, true/*quiet*/)) {
std::cerr << " Error running this sequence of passes" std::cerr << " Error running this sequence of passes"
<< " on the input program!\n"; << " on the input program!\n";
BD.setPassesToRun(Suffix); BD.setPassesToRun(Suffix);
BD.EmitProgressBytecode("pass-error", false); BD.EmitProgressBytecode("pass-error", false);
@ -153,7 +153,7 @@ namespace {
ReduceMiscompilingFunctions(BugDriver &bd, ReduceMiscompilingFunctions(BugDriver &bd,
bool (*F)(BugDriver &, Module *, Module *)) bool (*F)(BugDriver &, Module *, Module *))
: BD(bd), TestFn(F) {} : BD(bd), TestFn(F) {}
virtual TestResult doTest(std::vector<Function*> &Prefix, virtual TestResult doTest(std::vector<Function*> &Prefix,
std::vector<Function*> &Suffix) { std::vector<Function*> &Suffix) {
if (!Suffix.empty() && TestFuncs(Suffix)) if (!Suffix.empty() && TestFuncs(Suffix))
@ -162,7 +162,7 @@ namespace {
return KeepPrefix; return KeepPrefix;
return NoFailure; return NoFailure;
} }
bool TestFuncs(const std::vector<Function*> &Prefix); bool TestFuncs(const std::vector<Function*> &Prefix);
}; };
} }
@ -280,7 +280,7 @@ static bool ExtractLoops(BugDriver &BD,
return MadeChange; return MadeChange;
} }
BD.switchToInterpreter(AI); BD.switchToInterpreter(AI);
std::cout << " Testing after loop extraction:\n"; std::cout << " Testing after loop extraction:\n";
// Clone modules, the tester function will free them. // Clone modules, the tester function will free them.
Module *TOLEBackup = CloneModule(ToOptimizeLoopExtracted); Module *TOLEBackup = CloneModule(ToOptimizeLoopExtracted);
@ -343,7 +343,7 @@ namespace {
bool (*F)(BugDriver &, Module *, Module *), bool (*F)(BugDriver &, Module *, Module *),
const std::vector<Function*> &Fns) const std::vector<Function*> &Fns)
: BD(bd), TestFn(F), FunctionsBeingTested(Fns) {} : BD(bd), TestFn(F), FunctionsBeingTested(Fns) {}
virtual TestResult doTest(std::vector<BasicBlock*> &Prefix, virtual TestResult doTest(std::vector<BasicBlock*> &Prefix,
std::vector<BasicBlock*> &Suffix) { std::vector<BasicBlock*> &Suffix) {
if (!Suffix.empty() && TestFuncs(Suffix)) if (!Suffix.empty() && TestFuncs(Suffix))
@ -352,7 +352,7 @@ namespace {
return KeepPrefix; return KeepPrefix;
return NoFailure; return NoFailure;
} }
bool TestFuncs(const std::vector<BasicBlock*> &Prefix); bool TestFuncs(const std::vector<BasicBlock*> &Prefix);
}; };
} }
@ -506,7 +506,7 @@ DebugAMiscompilation(BugDriver &BD,
// Do the reduction... // Do the reduction...
ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions); ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions);
std::cout << "\n*** The following function" std::cout << "\n*** The following function"
<< (MiscompiledFunctions.size() == 1 ? " is" : "s are") << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
<< " being miscompiled: "; << " being miscompiled: ";
@ -525,7 +525,7 @@ DebugAMiscompilation(BugDriver &BD,
// Do the reduction... // Do the reduction...
ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions); ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions);
std::cout << "\n*** The following function" std::cout << "\n*** The following function"
<< (MiscompiledFunctions.size() == 1 ? " is" : "s are") << (MiscompiledFunctions.size() == 1 ? " is" : "s are")
<< " being miscompiled: "; << " being miscompiled: ";
@ -586,7 +586,7 @@ bool BugDriver::debugMiscompilation() {
ToNotOptimize = swapProgramIn(ToNotOptimize); ToNotOptimize = swapProgramIn(ToNotOptimize);
EmitProgressBytecode("tonotoptimize", true); EmitProgressBytecode("tonotoptimize", true);
setNewProgram(ToNotOptimize); // Delete hacked module. setNewProgram(ToNotOptimize); // Delete hacked module.
std::cout << " Portion that is input to optimizer: "; std::cout << " Portion that is input to optimizer: ";
ToOptimize = swapProgramIn(ToOptimize); ToOptimize = swapProgramIn(ToOptimize);
EmitProgressBytecode("tooptimize"); EmitProgressBytecode("tooptimize");
@ -614,12 +614,12 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Rename it // Rename it
oldMain->setName("llvm_bugpoint_old_main"); oldMain->setName("llvm_bugpoint_old_main");
// Create a NEW `main' function with same type in the test module. // Create a NEW `main' function with same type in the test module.
Function *newMain = new Function(oldMain->getFunctionType(), Function *newMain = new Function(oldMain->getFunctionType(),
GlobalValue::ExternalLinkage, GlobalValue::ExternalLinkage,
"main", Test); "main", Test);
// Create an `oldmain' prototype in the test module, which will // Create an `oldmain' prototype in the test module, which will
// corresponds to the real main function in the same module. // corresponds to the real main function in the same module.
Function *oldMainProto = new Function(oldMain->getFunctionType(), Function *oldMainProto = new Function(oldMain->getFunctionType(),
GlobalValue::ExternalLinkage, GlobalValue::ExternalLinkage,
oldMain->getName(), Test); oldMain->getName(), Test);
// Set up and remember the argument list for the main function. // Set up and remember the argument list for the main function.
@ -634,7 +634,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Call the old main function and return its result // Call the old main function and return its result
BasicBlock *BB = new BasicBlock("entry", newMain); BasicBlock *BB = new BasicBlock("entry", newMain);
CallInst *call = new CallInst(oldMainProto, args, "", BB); CallInst *call = new CallInst(oldMainProto, args, "", BB);
// If the type of old function wasn't void, return value of call // If the type of old function wasn't void, return value of call
new ReturnInst(call, BB); new ReturnInst(call, BB);
} }
@ -643,14 +643,14 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// module cannot directly reference any functions defined in the test // module cannot directly reference any functions defined in the test
// module. Instead, we use a JIT API call to dynamically resolve the // module. Instead, we use a JIT API call to dynamically resolve the
// symbol. // symbol.
// Add the resolver to the Safe module. // Add the resolver to the Safe module.
// Prototype: void *getPointerToNamedFunction(const char* Name) // Prototype: void *getPointerToNamedFunction(const char* Name)
Function *resolverFunc = Function *resolverFunc =
Safe->getOrInsertFunction("getPointerToNamedFunction", Safe->getOrInsertFunction("getPointerToNamedFunction",
PointerType::get(Type::SByteTy), PointerType::get(Type::SByteTy),
PointerType::get(Type::SByteTy), 0); PointerType::get(Type::SByteTy), 0);
// Use the function we just added to get addresses of functions we need. // Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) { for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
if (F->isExternal() && !F->use_empty() && &*F != resolverFunc && if (F->isExternal() && !F->use_empty() && &*F != resolverFunc &&
@ -663,7 +663,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
Constant *InitArray = ConstantArray::get(F->getName()); Constant *InitArray = ConstantArray::get(F->getName());
GlobalVariable *funcName = GlobalVariable *funcName =
new GlobalVariable(InitArray->getType(), true /*isConstant*/, new GlobalVariable(InitArray->getType(), true /*isConstant*/,
GlobalValue::InternalLinkage, InitArray, GlobalValue::InternalLinkage, InitArray,
F->getName() + "_name", Safe); F->getName() + "_name", Safe);
// 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an // 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an
@ -690,7 +690,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Resolve the call to function F via the JIT API: // Resolve the call to function F via the JIT API:
// //
// call resolver(GetElementPtr...) // call resolver(GetElementPtr...)
CallInst *resolve = new CallInst(resolverFunc, ResolverArgs, CallInst *resolve = new CallInst(resolverFunc, ResolverArgs,
"resolver"); "resolver");
Header->getInstList().push_back(resolve); Header->getInstList().push_back(resolve);
// cast the result from the resolver to correctly-typed function // cast the result from the resolver to correctly-typed function

View File

@ -1,10 +1,10 @@
//===- OptimizerDriver.cpp - Allow BugPoint to run passes safely ----------===// //===- OptimizerDriver.cpp - Allow BugPoint to run passes safely ----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines an interface that allows bugpoint to run various passes // This file defines an interface that allows bugpoint to run various passes
@ -195,7 +195,7 @@ Module *BugDriver::runPassesOn(Module *M,
std::string BytecodeResult; std::string BytecodeResult;
if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) { if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) {
if (AutoDebugCrashes) { if (AutoDebugCrashes) {
std::cerr << " Error running this sequence of passes" std::cerr << " Error running this sequence of passes"
<< " on the input program!\n"; << " on the input program!\n";
delete OldProgram; delete OldProgram;
EmitProgressBytecode("pass-error", false); EmitProgressBytecode("pass-error", false);

View File

@ -1,10 +1,10 @@
//===- TestPasses.cpp - "buggy" passes used to test bugpoint --------------===// //===- TestPasses.cpp - "buggy" passes used to test bugpoint --------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains "buggy" passes that are used to test bugpoint, to check // This file contains "buggy" passes that are used to test bugpoint, to check

View File

@ -1,10 +1,10 @@
//===- bugpoint.cpp - The LLVM Bugpoint utility ---------------------------===// //===- bugpoint.cpp - The LLVM Bugpoint utility ---------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This program is an automated compiler debugger tool. It is used to narrow // This program is an automated compiler debugger tool. It is used to narrow

View File

@ -1,10 +1,10 @@
//===- extract.cpp - LLVM function extraction utility ---------------------===// //===- extract.cpp - LLVM function extraction utility ---------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility changes the input module to only contain a single function, // This utility changes the input module to only contain a single function,
@ -28,9 +28,9 @@ using namespace llvm;
static cl::opt<std::string> static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bytecode file>"), InputFilename(cl::Positional, cl::desc("<input bytecode file>"),
cl::init("-"), cl::value_desc("filename")); cl::init("-"), cl::value_desc("filename"));
static cl::opt<std::string> static cl::opt<std::string>
OutputFilename("o", cl::desc("Specify output filename"), OutputFilename("o", cl::desc("Specify output filename"),
cl::value_desc("filename"), cl::init("-")); cl::value_desc("filename"), cl::init("-"));
static cl::opt<bool> static cl::opt<bool>
@ -88,7 +88,7 @@ int main(int argc, char **argv) {
Out = new std::ofstream(OutputFilename.c_str(), io_mode); Out = new std::ofstream(OutputFilename.c_str(), io_mode);
} else { // Specified stdout } else { // Specified stdout
// FIXME: cout is not binary! // FIXME: cout is not binary!
Out = &std::cout; Out = &std::cout;
} }
Passes.add(new WriteBytecodePass(Out)); // Write bytecode to file... Passes.add(new WriteBytecodePass(Out)); // Write bytecode to file...

View File

@ -1,10 +1,10 @@
//===-- gccas.cpp - The "optimizing assembler" used by the GCC frontend ---===// //===-- gccas.cpp - The "optimizing assembler" used by the GCC frontend ---===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility is designed to be used by the GCC frontend for creating bytecode // This utility is designed to be used by the GCC frontend for creating bytecode
@ -33,11 +33,11 @@ namespace {
cl::opt<std::string> cl::opt<std::string>
InputFilename(cl::Positional,cl::desc("<input llvm assembly>"),cl::init("-")); InputFilename(cl::Positional,cl::desc("<input llvm assembly>"),cl::init("-"));
cl::opt<std::string> cl::opt<std::string>
OutputFilename("o", cl::desc("Override output filename"), OutputFilename("o", cl::desc("Override output filename"),
cl::value_desc("filename")); cl::value_desc("filename"));
cl::opt<bool> cl::opt<bool>
Verify("verify", cl::desc("Verify each pass result")); Verify("verify", cl::desc("Verify each pass result"));
cl::opt<bool> cl::opt<bool>
@ -51,7 +51,7 @@ namespace {
StripDebug("strip-debug", StripDebug("strip-debug",
cl::desc("Strip debugger symbol info from translation unit")); cl::desc("Strip debugger symbol info from translation unit"));
cl::opt<bool> cl::opt<bool>
NoCompress("disable-compression", cl::init(false), NoCompress("disable-compression", cl::init(false),
cl::desc("Don't compress the generated bytecode")); cl::desc("Don't compress the generated bytecode"));
@ -63,7 +63,7 @@ namespace {
static inline void addPass(PassManager &PM, Pass *P) { static inline void addPass(PassManager &PM, Pass *P) {
// Add the pass to the pass manager... // Add the pass to the pass manager...
PM.add(P); PM.add(P);
// If we are verifying all of the intermediate steps, add the verifier... // If we are verifying all of the intermediate steps, add the verifier...
if (Verify) PM.add(createVerifierPass()); if (Verify) PM.add(createVerifierPass());
} }
@ -128,7 +128,7 @@ void AddConfiguredTransformationPasses(PassManager &PM) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
try { try {
cl::ParseCommandLineOptions(argc, argv, cl::ParseCommandLineOptions(argc, argv,
" llvm .s -> .o assembler for GCC\n"); " llvm .s -> .o assembler for GCC\n");
sys::PrintStackTraceOnErrorSignal(); sys::PrintStackTraceOnErrorSignal();
@ -175,7 +175,7 @@ int main(int argc, char **argv) {
sys::RemoveFileOnSignal(sys::Path(OutputFilename)); sys::RemoveFileOnSignal(sys::Path(OutputFilename));
} }
if (!Out->good()) { if (!Out->good()) {
std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
return 1; return 1;

View File

@ -1,10 +1,10 @@
//===- GenerateCode.cpp - Functions for generating executable files ------===// //===- GenerateCode.cpp - Functions for generating executable files ------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains functions for generating executable files once linking // This file contains functions for generating executable files once linking
@ -154,8 +154,8 @@ static bool isBytecodeLPath(const std::string &LibPath) {
// Make sure the -L path has a '/' character // Make sure the -L path has a '/' character
// because llvm-g++ passes them without the ending // because llvm-g++ passes them without the ending
// '/' char and sys::Path doesn't think it is a // '/' char and sys::Path doesn't think it is a
// directory (see: sys::Path::isDirectory) without it // directory (see: sys::Path::isDirectory) without it
std::string dir = LibPath; std::string dir = LibPath;
if ( dir[dir.length()-1] != '/' ) if ( dir[dir.length()-1] != '/' )
dir.append("/"); dir.append("/");
@ -406,7 +406,7 @@ int llvm::GenerateNative(const std::string &OutputFilename,
// //
// Note: // Note:
// When gccld is called from the llvm-gxx frontends, the -L paths for // When gccld is called from the llvm-gxx frontends, the -L paths for
// the LLVM cfrontend install paths are appended. We don't want the // the LLVM cfrontend install paths are appended. We don't want the
// native linker to use these -L paths as they contain bytecode files. // native linker to use these -L paths as they contain bytecode files.
// Further, we don't want any -L paths that contain bytecode shared // Further, we don't want any -L paths that contain bytecode shared
// libraries or true bytecode archive files. We omit them in all such // libraries or true bytecode archive files. We omit them in all such
@ -417,7 +417,7 @@ int llvm::GenerateNative(const std::string &OutputFilename,
args.push_back(LibPaths[index].c_str()); args.push_back(LibPaths[index].c_str());
} }
} }
// Add in the libraries to link. // Add in the libraries to link.
for (unsigned index = 0; index < Libraries.size(); index++) { for (unsigned index = 0; index < Libraries.size(); index++) {
if (Libraries[index] != "crtend") { if (Libraries[index] != "crtend") {

View File

@ -1,10 +1,10 @@
//===- gccld.cpp - LLVM 'ld' compatible linker ----------------------------===// //===- gccld.cpp - LLVM 'ld' compatible linker ----------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility is intended to be compatible with GCC, and follows standard // This utility is intended to be compatible with GCC, and follows standard
@ -38,22 +38,22 @@
using namespace llvm; using namespace llvm;
namespace { namespace {
cl::list<std::string> cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input bytecode files>"), InputFilenames(cl::Positional, cl::desc("<input bytecode files>"),
cl::OneOrMore); cl::OneOrMore);
cl::opt<std::string> cl::opt<std::string>
OutputFilename("o", cl::desc("Override output filename"), cl::init("a.out"), OutputFilename("o", cl::desc("Override output filename"), cl::init("a.out"),
cl::value_desc("filename")); cl::value_desc("filename"));
cl::opt<bool> cl::opt<bool>
Verbose("v", cl::desc("Print information about actions taken")); Verbose("v", cl::desc("Print information about actions taken"));
cl::list<std::string> cl::list<std::string>
LibPaths("L", cl::desc("Specify a library search path"), cl::Prefix, LibPaths("L", cl::desc("Specify a library search path"), cl::Prefix,
cl::value_desc("directory")); cl::value_desc("directory"));
cl::list<std::string> cl::list<std::string>
Libraries("l", cl::desc("Specify libraries to link to"), cl::Prefix, Libraries("l", cl::desc("Specify libraries to link to"), cl::Prefix,
cl::value_desc("library prefix")); cl::value_desc("library prefix"));
@ -91,13 +91,13 @@ namespace {
cl::opt<std::string> cl::opt<std::string>
RPath("rpath", RPath("rpath",
cl::desc("Set runtime shared library search path (requires -native or" cl::desc("Set runtime shared library search path (requires -native or"
" -native-cbe)"), " -native-cbe)"),
cl::Prefix, cl::value_desc("directory")); cl::Prefix, cl::value_desc("directory"));
cl::opt<std::string> cl::opt<std::string>
SOName("soname", SOName("soname",
cl::desc("Set internal name of shared library (requires -native or" cl::desc("Set internal name of shared library (requires -native or"
" -native-cbe)"), " -native-cbe)"),
cl::Prefix, cl::value_desc("name")); cl::Prefix, cl::value_desc("name"));
// Compatibility options that are ignored but supported by LD // Compatibility options that are ignored but supported by LD
@ -155,12 +155,12 @@ static void EmitShellScript(char **argv) {
// We don't need to link in libc! In fact, /usr/lib/libc.so may not be a // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
// shared object at all! See RH 8: plain text. // shared object at all! See RH 8: plain text.
std::vector<std::string>::iterator libc = std::vector<std::string>::iterator libc =
std::find(Libraries.begin(), Libraries.end(), "c"); std::find(Libraries.begin(), Libraries.end(), "c");
if (libc != Libraries.end()) Libraries.erase(libc); if (libc != Libraries.end()) Libraries.erase(libc);
// List all the shared object (native) libraries this executable will need // List all the shared object (native) libraries this executable will need
// on the command line, so that we don't have to do this manually! // on the command line, so that we don't have to do this manually!
for (std::vector<std::string>::iterator i = Libraries.begin(), for (std::vector<std::string>::iterator i = Libraries.begin(),
e = Libraries.end(); i != e; ++i) { e = Libraries.end(); i != e; ++i) {
sys::Path FullLibraryPath = sys::Path::FindLibrary(*i); sys::Path FullLibraryPath = sys::Path::FindLibrary(*i);
if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary()) if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary())
@ -178,7 +178,7 @@ static void BuildLinkItems(
const cl::list<std::string>& Files, const cl::list<std::string>& Files,
const cl::list<std::string>& Libraries) { const cl::list<std::string>& Libraries) {
// Build the list of linkage items for LinkItems. // Build the list of linkage items for LinkItems.
cl::list<std::string>::const_iterator fileIt = Files.begin(); cl::list<std::string>::const_iterator fileIt = Files.begin();
cl::list<std::string>::const_iterator libIt = Libraries.begin(); cl::list<std::string>::const_iterator libIt = Libraries.begin();
@ -231,7 +231,7 @@ int main(int argc, char **argv, char **envp ) {
// The libraries aren't linked in but are noted as "dependent" in the // The libraries aren't linked in but are noted as "dependent" in the
// module. // module.
for (cl::list<std::string>::const_iterator I = Libraries.begin(), for (cl::list<std::string>::const_iterator I = Libraries.begin(),
E = Libraries.end(); I != E ; ++I) { E = Libraries.end(); I != E ; ++I) {
TheLinker.getModule()->addLibrary(*I); TheLinker.getModule()->addLibrary(*I);
} }
@ -267,7 +267,7 @@ int main(int argc, char **argv, char **envp ) {
// strip debug info. // strip debug info.
int StripLevel = Strip ? 2 : (StripDebug ? 1 : 0); int StripLevel = Strip ? 2 : (StripDebug ? 1 : 0);
// Internalize the module if neither -disable-internalize nor // Internalize the module if neither -disable-internalize nor
// -link-as-library are passed in. // -link-as-library are passed in.
bool ShouldInternalize = !NoInternalize & !LinkAsLibrary; bool ShouldInternalize = !NoInternalize & !LinkAsLibrary;
@ -281,8 +281,8 @@ int main(int argc, char **argv, char **envp ) {
Out.close(); Out.close();
// Generate either a native file or a JIT shell script. If the user wants // Generate either a native file or a JIT shell script. If the user wants
// to generate a native file, compile it from the bytecode file. Otherwise, // to generate a native file, compile it from the bytecode file. Otherwise,
// if the target is not a library, create a script that will run the // if the target is not a library, create a script that will run the
// bytecode through the JIT. // bytecode through the JIT.
if (Native) { if (Native) {
// Name of the Assembly Language output file // Name of the Assembly Language output file
@ -304,10 +304,10 @@ int main(int argc, char **argv, char **envp ) {
// Generate an assembly language file for the bytecode. // Generate an assembly language file for the bytecode.
if (Verbose) std::cout << "Generating Assembly Code\n"; if (Verbose) std::cout << "Generating Assembly Code\n";
GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc, GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc,
Verbose); Verbose);
if (Verbose) std::cout << "Generating Native Code\n"; if (Verbose) std::cout << "Generating Native Code\n";
GenerateNative(OutputFilename, AssemblyFile.toString(), GenerateNative(OutputFilename, AssemblyFile.toString(),
LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath, LibPaths, Libraries, gcc, envp, LinkAsLibrary, RPath,
SOName, Verbose); SOName, Verbose);

View File

@ -1,10 +1,10 @@
//===- gccld.h - Utility functions header file ------------------*- C++ -*-===// //===- gccld.h - Utility functions header file ------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains function prototypes for the functions in util.cpp. // This file contains function prototypes for the functions in util.cpp.
@ -32,8 +32,8 @@ GenerateAssembly (const std::string &OutputFilename,
const sys::Path &llc, const sys::Path &llc,
bool Verbose=false); bool Verbose=false);
int int
GenerateCFile (const std::string &OutputFile, GenerateCFile (const std::string &OutputFile,
const std::string &InputFile, const std::string &InputFile,
const sys::Path &llc, const sys::Path &llc,
bool Verbose=false); bool Verbose=false);

View File

@ -1,14 +1,14 @@
//===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===// //===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This is the llc code generator driver. It provides a convenient // This is the llc code generator driver. It provides a convenient
// command-line interface for generating native assembly-language code // command-line interface for generating native assembly-language code
// or C code, given LLVM bytecode. // or C code, given LLVM bytecode.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -32,7 +32,7 @@ using namespace llvm;
// General options for llc. Other pass-specific options are specified // General options for llc. Other pass-specific options are specified
// within the corresponding llc passes, and target-specific options // within the corresponding llc passes, and target-specific options
// and back-end code generation options are specified with the target machine. // and back-end code generation options are specified with the target machine.
// //
static cl::opt<std::string> static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-")); InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-"));
@ -43,7 +43,7 @@ static cl::opt<bool> Force("f", cl::desc("Overwrite output files"));
static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser> static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
MArch("march", cl::desc("Architecture to generate assembly for:")); MArch("march", cl::desc("Architecture to generate assembly for:"));
// GetFileNameRoot - Helper function to get the basename of a filename... // GetFileNameRoot - Helper function to get the basename of a filename...
static inline std::string static inline std::string
GetFileNameRoot(const std::string &InputFilename) { GetFileNameRoot(const std::string &InputFilename) {
@ -125,13 +125,13 @@ int main(int argc, char **argv) {
OutputFilename = "-"; OutputFilename = "-";
Out = &std::cout; Out = &std::cout;
} else { } else {
OutputFilename = GetFileNameRoot(InputFilename); OutputFilename = GetFileNameRoot(InputFilename);
if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE
OutputFilename += ".s"; OutputFilename += ".s";
else else
OutputFilename += ".cbe.c"; OutputFilename += ".cbe.c";
if (!Force && std::ifstream(OutputFilename.c_str())) { if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file! // If force is not specified, make sure not to overwrite a file!
std::cerr << argv[0] << ": error opening '" << OutputFilename std::cerr << argv[0] << ": error opening '" << OutputFilename
@ -139,14 +139,14 @@ int main(int argc, char **argv) {
<< "Use -f command line argument to force output\n"; << "Use -f command line argument to force output\n";
return 1; return 1;
} }
Out = new std::ofstream(OutputFilename.c_str()); Out = new std::ofstream(OutputFilename.c_str());
if (!Out->good()) { if (!Out->good()) {
std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
delete Out; delete Out;
return 1; return 1;
} }
// Make sure that the Out file gets unlinked from the disk if we get a // Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT // SIGINT
sys::RemoveFileOnSignal(sys::Path(OutputFilename)); sys::RemoveFileOnSignal(sys::Path(OutputFilename));

View File

@ -1,10 +1,10 @@
//===- lli.cpp - LLVM Interpreter / Dynamic compiler ----------------------===// //===- lli.cpp - LLVM Interpreter / Dynamic compiler ----------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility provides a simple wrapper around the LLVM Execution Engines, // This utility provides a simple wrapper around the LLVM Execution Engines,

View File

@ -1,13 +1,13 @@
//===-- llvm-ar.cpp - LLVM archive librarian utility ----------------------===// //===-- llvm-ar.cpp - LLVM archive librarian utility ----------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// Builds up (relatively) standard unix archive files (.a) containing LLVM // Builds up (relatively) standard unix archive files (.a) containing LLVM
// bytecode or other files. // bytecode or other files.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -24,24 +24,24 @@
using namespace llvm; using namespace llvm;
// Option for compatibility with ASIX, not used but must allow it to be present. // Option for compatibility with ASIX, not used but must allow it to be present.
static cl::opt<bool> static cl::opt<bool>
X32Option ("X32_64", cl::Hidden, X32Option ("X32_64", cl::Hidden,
cl::desc("Ignored option for compatibility with AIX")); cl::desc("Ignored option for compatibility with AIX"));
// llvm-ar operation code and modifier flags. This must come first. // llvm-ar operation code and modifier flags. This must come first.
static cl::opt<std::string> static cl::opt<std::string>
Options(cl::Positional, cl::Required, cl::desc("{operation}[modifiers]...")); Options(cl::Positional, cl::Required, cl::desc("{operation}[modifiers]..."));
// llvm-ar remaining positional arguments. // llvm-ar remaining positional arguments.
static cl::list<std::string> static cl::list<std::string>
RestOfArgs(cl::Positional, cl::OneOrMore, RestOfArgs(cl::Positional, cl::OneOrMore,
cl::desc("[relpos] [count] <archive-file> [members]...")); cl::desc("[relpos] [count] <archive-file> [members]..."));
// MoreHelp - Provide additional help output explaining the operations and // MoreHelp - Provide additional help output explaining the operations and
// modifiers of llvm-ar. This object instructs the CommandLine library // modifiers of llvm-ar. This object instructs the CommandLine library
// to print the text of the constructor when the --help option is given. // to print the text of the constructor when the --help option is given.
static cl::extrahelp MoreHelp( static cl::extrahelp MoreHelp(
"\nOPERATIONS:\n" "\nOPERATIONS:\n"
" d[NsS] - delete file(s) from the archive\n" " d[NsS] - delete file(s) from the archive\n"
" m[abiSs] - move file(s) in the archive\n" " m[abiSs] - move file(s) in the archive\n"
" p[kN] - print file(s) found in the archive\n" " p[kN] - print file(s) found in the archive\n"
@ -85,7 +85,7 @@ enum ArchiveOperation {
// Modifiers to follow operation to vary behavior // Modifiers to follow operation to vary behavior
bool AddAfter = false; ///< 'a' modifier bool AddAfter = false; ///< 'a' modifier
bool AddBefore = false; ///< 'b' modifier bool AddBefore = false; ///< 'b' modifier
bool Create = false; ///< 'c' modifier bool Create = false; ///< 'c' modifier
bool TruncateNames = false; ///< 'f' modifier bool TruncateNames = false; ///< 'f' modifier
bool InsertBefore = false; ///< 'i' modifier bool InsertBefore = false; ///< 'i' modifier
bool DontSkipBytecode = false; ///< 'k' modifier bool DontSkipBytecode = false; ///< 'k' modifier
@ -135,7 +135,7 @@ void getRelPos() {
throw "Expected [relpos] for a, b, or i modifier"; throw "Expected [relpos] for a, b, or i modifier";
} }
// getCount - Extract the [count] argument associated with the N modifier // getCount - Extract the [count] argument associated with the N modifier
// from the command line and check its value. // from the command line and check its value.
void getCount() { void getCount() {
if(RestOfArgs.size() > 0) { if(RestOfArgs.size() > 0) {
@ -164,11 +164,11 @@ void getArchive() {
// This is just for clarity. // This is just for clarity.
void getMembers() { void getMembers() {
if(RestOfArgs.size() > 0) if(RestOfArgs.size() > 0)
Members = std::vector<std::string>(RestOfArgs); Members = std::vector<std::string>(RestOfArgs);
} }
// parseCommandLine - Parse the command line options as presented and return the // parseCommandLine - Parse the command line options as presented and return the
// operation specified. Process all modifiers and check to make sure that // operation specified. Process all modifiers and check to make sure that
// constraints on modifier/operation pairs have not been violated. // constraints on modifier/operation pairs have not been violated.
ArchiveOperation parseCommandLine() { ArchiveOperation parseCommandLine() {
@ -188,7 +188,7 @@ ArchiveOperation parseCommandLine() {
case 'd': ++NumOperations; Operation = Delete; break; case 'd': ++NumOperations; Operation = Delete; break;
case 'm': ++NumOperations; Operation = Move ; break; case 'm': ++NumOperations; Operation = Move ; break;
case 'p': ++NumOperations; Operation = Print; break; case 'p': ++NumOperations; Operation = Print; break;
case 'r': ++NumOperations; Operation = ReplaceOrInsert; break; case 'r': ++NumOperations; Operation = ReplaceOrInsert; break;
case 't': ++NumOperations; Operation = DisplayTable; break; case 't': ++NumOperations; Operation = DisplayTable; break;
case 'x': ++NumOperations; Operation = Extract; break; case 'x': ++NumOperations; Operation = Extract; break;
case 'c': Create = true; break; case 'c': Create = true; break;
@ -220,7 +220,7 @@ ArchiveOperation parseCommandLine() {
NumPositional++; NumPositional++;
break; break;
case 'N': case 'N':
getCount(); getCount();
UseCount = true; UseCount = true;
break; break;
default: default:
@ -228,7 +228,7 @@ ArchiveOperation parseCommandLine() {
} }
} }
// At this point, the next thing on the command line must be // At this point, the next thing on the command line must be
// the archive name. // the archive name.
getArchive(); getArchive();
@ -274,7 +274,7 @@ std::set<sys::Path> recurseDirectories(const sys::Path& path) {
if (RecurseDirectories) { if (RecurseDirectories) {
std::set<sys::Path> content; std::set<sys::Path> content;
path.getDirectoryContents(content); path.getDirectoryContents(content);
for (std::set<sys::Path>::iterator I = content.begin(), E = content.end(); for (std::set<sys::Path>::iterator I = content.begin(), E = content.end();
I != E; ++I) { I != E; ++I) {
if (I->isDirectory()) { if (I->isDirectory()) {
std::set<sys::Path> moreResults = recurseDirectories(*I); std::set<sys::Path> moreResults = recurseDirectories(*I);
@ -288,7 +288,7 @@ std::set<sys::Path> recurseDirectories(const sys::Path& path) {
} }
// buildPaths - Convert the strings in the Members vector to sys::Path objects // buildPaths - Convert the strings in the Members vector to sys::Path objects
// and make sure they are valid and exist exist. This check is only needed for // and make sure they are valid and exist exist. This check is only needed for
// the operations that add/replace files to the archive ('q' and 'r') // the operations that add/replace files to the archive ('q' and 'r')
void buildPaths(bool checkExistence = true) { void buildPaths(bool checkExistence = true) {
for (unsigned i = 0; i < Members.size(); i++) { for (unsigned i = 0; i < Members.size(); i++) {
@ -316,7 +316,7 @@ void buildPaths(bool checkExistence = true) {
void printSymbolTable() { void printSymbolTable() {
std::cout << "\nArchive Symbol Table:\n"; std::cout << "\nArchive Symbol Table:\n";
const Archive::SymTabType& symtab = TheArchive->getSymbolTable(); const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end(); for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
I != E; ++I ) { I != E; ++I ) {
unsigned offset = TheArchive->getFirstFileOffset() + I->second; unsigned offset = TheArchive->getFirstFileOffset() + I->second;
std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n"; std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
@ -330,16 +330,16 @@ void printSymbolTable() {
void doPrint() { void doPrint() {
buildPaths(false); buildPaths(false);
unsigned countDown = Count; unsigned countDown = Count;
for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end(); for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
I != E; ++I ) { I != E; ++I ) {
if (Paths.empty() || if (Paths.empty() ||
(std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) { (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
if (countDown == 1) { if (countDown == 1) {
const char* data = reinterpret_cast<const char*>(I->getData()); const char* data = reinterpret_cast<const char*>(I->getData());
// Skip things that don't make sense to print // Skip things that don't make sense to print
if (I->isLLVMSymbolTable() || I->isSVR4SymbolTable() || if (I->isLLVMSymbolTable() || I->isSVR4SymbolTable() ||
I->isBSD4SymbolTable() || (!DontSkipBytecode && I->isBSD4SymbolTable() || (!DontSkipBytecode &&
(I->isBytecode() || I->isCompressedBytecode()))) (I->isBytecode() || I->isCompressedBytecode())))
continue; continue;
@ -364,7 +364,7 @@ void doPrint() {
// putMode - utility function for printing out the file mode when the 't' // putMode - utility function for printing out the file mode when the 't'
// operation is in verbose mode. // operation is in verbose mode.
void printMode(unsigned mode) { void printMode(unsigned mode) {
if (mode & 004) if (mode & 004)
std::cout << "r"; std::cout << "r";
else else
std::cout << "-"; std::cout << "-";
@ -384,9 +384,9 @@ void printMode(unsigned mode) {
// modification time are also printed. // modification time are also printed.
void doDisplayTable() { void doDisplayTable() {
buildPaths(false); buildPaths(false);
for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end(); for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
I != E; ++I ) { I != E; ++I ) {
if (Paths.empty() || if (Paths.empty() ||
(std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) { (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
if (Verbose) { if (Verbose) {
// FIXME: Output should be this format: // FIXME: Output should be this format:
@ -406,7 +406,7 @@ void doDisplayTable() {
std::cout << " " << std::setw(4) << I->getUser(); std::cout << " " << std::setw(4) << I->getUser();
std::cout << "/" << std::setw(4) << I->getGroup(); std::cout << "/" << std::setw(4) << I->getGroup();
std::cout << " " << std::setw(8) << I->getSize(); std::cout << " " << std::setw(8) << I->getSize();
std::cout << " " << std::setw(20) << std::cout << " " << std::setw(20) <<
I->getModTime().toString().substr(4); I->getModTime().toString().substr(4);
std::cout << " " << I->getPath().toString() << "\n"; std::cout << " " << I->getPath().toString() << "\n";
} else { } else {
@ -423,7 +423,7 @@ void doDisplayTable() {
void doExtract() { void doExtract() {
buildPaths(false); buildPaths(false);
unsigned countDown = Count; unsigned countDown = Count;
for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end(); for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
I != E; ++I ) { I != E; ++I ) {
if (Paths.empty() || if (Paths.empty() ||
(std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) { (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
@ -468,7 +468,7 @@ void doDelete() {
buildPaths(false); buildPaths(false);
if (Paths.empty()) return; if (Paths.empty()) return;
unsigned countDown = Count; unsigned countDown = Count;
for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end(); for (Archive::iterator I = TheArchive->begin(), E = TheArchive->end();
I != E; ) { I != E; ) {
if (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end()) { if (std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end()) {
if (countDown == 1) { if (countDown == 1) {
@ -504,7 +504,7 @@ void doMove() {
// the archive to find the member in question. If we don't find it, its no // the archive to find the member in question. If we don't find it, its no
// crime, we just move to the end. // crime, we just move to the end.
if (AddBefore || InsertBefore || AddAfter) { if (AddBefore || InsertBefore || AddAfter) {
for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end(); for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
I != E; ++I ) { I != E; ++I ) {
if (RelPos == I->getPath().toString()) { if (RelPos == I->getPath().toString()) {
if (AddAfter) { if (AddAfter) {
@ -523,12 +523,12 @@ void doMove() {
// Scan the archive again, this time looking for the members to move to the // Scan the archive again, this time looking for the members to move to the
// moveto_spot. // moveto_spot.
for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end(); for (Archive::iterator I = TheArchive->begin(), E= TheArchive->end();
I != E && !remaining.empty(); ++I ) { I != E && !remaining.empty(); ++I ) {
std::set<sys::Path>::iterator found = std::set<sys::Path>::iterator found =
std::find(remaining.begin(),remaining.end(),I->getPath()); std::find(remaining.begin(),remaining.end(),I->getPath());
if (found != remaining.end()) { if (found != remaining.end()) {
if (I != moveto_spot) if (I != moveto_spot)
TheArchive->splice(moveto_spot,*TheArchive,I); TheArchive->splice(moveto_spot,*TheArchive,I);
remaining.erase(found); remaining.erase(found);
} }
@ -560,7 +560,7 @@ void doQuickAppend() {
} }
// doReplaceOrInsert - Implements the 'r' operation. This function will replace // doReplaceOrInsert - Implements the 'r' operation. This function will replace
// any existing files or insert new ones into the archive. // any existing files or insert new ones into the archive.
void doReplaceOrInsert() { void doReplaceOrInsert() {
// Build the list of files to be added/replaced. // Build the list of files to be added/replaced.
@ -581,7 +581,7 @@ void doReplaceOrInsert() {
// to replace. // to replace.
std::set<sys::Path>::iterator found = remaining.end(); std::set<sys::Path>::iterator found = remaining.end();
for (std::set<sys::Path>::iterator RI = remaining.begin(), for (std::set<sys::Path>::iterator RI = remaining.begin(),
RE = remaining.end(); RI != RE; ++RI ) { RE = remaining.end(); RI != RE; ++RI ) {
std::string compare(RI->toString()); std::string compare(RI->toString());
if (TruncateNames && compare.length() > 15) { if (TruncateNames && compare.length() > 15) {
@ -592,7 +592,7 @@ void doReplaceOrInsert() {
nm += slashpos + 1; nm += slashpos + 1;
len -= slashpos +1; len -= slashpos +1;
} }
if (len > 15) if (len > 15)
len = 15; len = 15;
compare.assign(nm,len); compare.assign(nm,len);
} }
@ -634,7 +634,7 @@ void doReplaceOrInsert() {
// If we didn't replace all the members, some will remain and need to be // If we didn't replace all the members, some will remain and need to be
// inserted at the previously computed insert-spot. // inserted at the previously computed insert-spot.
if (!remaining.empty()) { if (!remaining.empty()) {
for (std::set<sys::Path>::iterator PI = remaining.begin(), for (std::set<sys::Path>::iterator PI = remaining.begin(),
PE = remaining.end(); PI != PE; ++PI) { PE = remaining.end(); PI != PE; ++PI) {
TheArchive->addFileBefore(*PI,insert_spot); TheArchive->addFileBefore(*PI,insert_spot);
} }

View File

@ -1,10 +1,10 @@
//===--- llvm-as.cpp - The low-level LLVM assembler -----------------------===// //===--- llvm-as.cpp - The low-level LLVM assembler -----------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility may be invoked in the following manner: // This utility may be invoked in the following manner:
@ -12,7 +12,7 @@
// llvm-as [options] - Read LLVM asm from stdin, write bytecode to stdout // llvm-as [options] - Read LLVM asm from stdin, write bytecode to stdout
// llvm-as [options] x.ll - Read LLVM asm from the x.ll file, write bytecode // llvm-as [options] x.ll - Read LLVM asm from the x.ll file, write bytecode
// to the x.bc file. // to the x.bc file.
// //
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
#include "llvm/Module.h" #include "llvm/Module.h"
@ -28,7 +28,7 @@
using namespace llvm; using namespace llvm;
static cl::opt<std::string> static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input .llvm file>"), cl::init("-")); InputFilename(cl::Positional, cl::desc("<input .llvm file>"), cl::init("-"));
static cl::opt<std::string> static cl::opt<std::string>
@ -41,7 +41,7 @@ Force("f", cl::desc("Overwrite output files"));
static cl::opt<bool> static cl::opt<bool>
DumpAsm("d", cl::desc("Print assembly as parsed"), cl::Hidden); DumpAsm("d", cl::desc("Print assembly as parsed"), cl::Hidden);
static cl::opt<bool> static cl::opt<bool>
NoCompress("disable-compression", cl::init(false), NoCompress("disable-compression", cl::init(false),
cl::desc("Don't compress the generated bytecode")); cl::desc("Don't compress the generated bytecode"));
@ -72,7 +72,7 @@ int main(int argc, char **argv) {
std::cerr << Err; std::cerr << Err;
return 1; return 1;
} }
if (DumpAsm) std::cerr << "Here's the assembly:\n" << *M.get(); if (DumpAsm) std::cerr << "Here's the assembly:\n" << *M.get();
if (OutputFilename != "") { // Specified an output filename? if (OutputFilename != "") { // Specified an output filename?
@ -84,7 +84,7 @@ int main(int argc, char **argv) {
<< "Use -f command line argument to force output\n"; << "Use -f command line argument to force output\n";
return 1; return 1;
} }
Out = new std::ofstream(OutputFilename.c_str(), std::ios::out | Out = new std::ofstream(OutputFilename.c_str(), std::ios::out |
std::ios::trunc | std::ios::binary); std::ios::trunc | std::ios::binary);
} else { // Specified stdout } else { // Specified stdout
// FIXME: cout is not binary! // FIXME: cout is not binary!
@ -113,19 +113,19 @@ int main(int argc, char **argv) {
return 1; return 1;
} }
Out = new std::ofstream(OutputFilename.c_str(), std::ios::out | Out = new std::ofstream(OutputFilename.c_str(), std::ios::out |
std::ios::trunc | std::ios::binary); std::ios::trunc | std::ios::binary);
// Make sure that the Out file gets unlinked from the disk if we get a // Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT // SIGINT
sys::RemoveFileOnSignal(sys::Path(OutputFilename)); sys::RemoveFileOnSignal(sys::Path(OutputFilename));
} }
} }
if (!Out->good()) { if (!Out->good()) {
std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
return 1; return 1;
} }
if (Force || !CheckBytecodeOutputToConsole(Out,true)) { if (Force || !CheckBytecodeOutputToConsole(Out,true)) {
WriteBytecodeToFile(M.get(), *Out, !NoCompress); WriteBytecodeToFile(M.get(), *Out, !NoCompress);
} }

View File

@ -1,10 +1,10 @@
//===-- llvm-bcanalyzer.cpp - Byte Code Analyzer --------------------------===// //===-- llvm-bcanalyzer.cpp - Byte Code Analyzer --------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tool may be invoked in the following manner: // This tool may be invoked in the following manner:
@ -13,20 +13,20 @@
// //
// Options: // Options:
// --help - Output information about command line switches // --help - Output information about command line switches
// --nodetails - Don't print out detailed informaton about individual // --nodetails - Don't print out detailed informaton about individual
// blocks and functions // blocks and functions
// --dump - Dump low-level bytecode structure in readable format // --dump - Dump low-level bytecode structure in readable format
// //
// This tool provides analytical information about a bytecode file. It is // This tool provides analytical information about a bytecode file. It is
// intended as an aid to developers of bytecode reading and writing software. It // intended as an aid to developers of bytecode reading and writing software. It
// produces on std::out a summary of the bytecode file that shows various // produces on std::out a summary of the bytecode file that shows various
// statistics about the contents of the file. By default this information is // statistics about the contents of the file. By default this information is
// detailed and contains information about individual bytecode blocks and the // detailed and contains information about individual bytecode blocks and the
// functions in the module. To avoid this more detailed output, use the // functions in the module. To avoid this more detailed output, use the
// -nodetails option to limit the output to just module level information. // -nodetails option to limit the output to just module level information.
// The tool is also able to print a bytecode file in a straight forward text // The tool is also able to print a bytecode file in a straight forward text
// format that shows the containment and relationships of the information in // format that shows the containment and relationships of the information in
// the bytecode file (-dump option). // the bytecode file (-dump option).
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Analysis/Verifier.h" #include "llvm/Analysis/Verifier.h"
@ -48,10 +48,10 @@ static cl::opt<bool> NoDetails ("nodetails", cl::desc("Skip detailed output"));
static cl::opt<bool> Dump ("dump", cl::desc("Dump low level bytecode trace")); static cl::opt<bool> Dump ("dump", cl::desc("Dump low level bytecode trace"));
static cl::opt<bool> Verify ("verify", cl::desc("Progressively verify module")); static cl::opt<bool> Verify ("verify", cl::desc("Progressively verify module"));
int int
main(int argc, char **argv) { main(int argc, char **argv) {
try { try {
cl::ParseCommandLineOptions(argc, argv, cl::ParseCommandLineOptions(argc, argv,
" llvm-bcanalyzer Analysis of ByteCode Dumper\n"); " llvm-bcanalyzer Analysis of ByteCode Dumper\n");
sys::PrintStackTraceOnErrorSignal(); sys::PrintStackTraceOnErrorSignal();
@ -78,7 +78,7 @@ main(int argc, char **argv) {
} catch (std::string& errmsg ) { } catch (std::string& errmsg ) {
verificationMsg = errmsg; verificationMsg = errmsg;
} }
if ( verificationMsg.length() > 0 ) if ( verificationMsg.length() > 0 )
std::cerr << "Final Verification Message: " << verificationMsg << "\n"; std::cerr << "Final Verification Message: " << verificationMsg << "\n";
} }
@ -88,7 +88,7 @@ main(int argc, char **argv) {
std::cerr << argv[0] << ": " << ErrorMessage << "\n"; std::cerr << argv[0] << ": " << ErrorMessage << "\n";
return 1; return 1;
} }
if (Out != &std::cout) { if (Out != &std::cout) {
((std::ofstream*)Out)->close(); ((std::ofstream*)Out)->close();

View File

@ -1,10 +1,10 @@
//===- CLICommand.h - Classes used to represent commands --------*- C++ -*-===// //===- CLICommand.h - Classes used to represent commands --------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines a small class hierarchy used to represent the various types // This file defines a small class hierarchy used to represent the various types
@ -74,7 +74,7 @@ namespace llvm {
/// removeOptionName - Eliminate one of the names for this option. /// removeOptionName - Eliminate one of the names for this option.
/// ///
void removeOptionName(const std::string &Name) { void removeOptionName(const std::string &Name) {
unsigned i = 0; unsigned i = 0;
for (; OptionNames[i] != Name; ++i) for (; OptionNames[i] != Name; ++i)
assert(i+1 < OptionNames.size() && "Didn't find option name!"); assert(i+1 < OptionNames.size() && "Didn't find option name!");
OptionNames.erase(OptionNames.begin()+i); OptionNames.erase(OptionNames.begin()+i);
@ -101,7 +101,7 @@ namespace llvm {
BuiltinCLICommand(const std::string &ShortHelp, const std::string &LongHelp, BuiltinCLICommand(const std::string &ShortHelp, const std::string &LongHelp,
void (CLIDebugger::*impl)(std::string&)) void (CLIDebugger::*impl)(std::string&))
: CLICommand(ShortHelp, LongHelp), Impl(impl) {} : CLICommand(ShortHelp, LongHelp), Impl(impl) {}
void runCommand(CLIDebugger &D, std::string &Arguments) { void runCommand(CLIDebugger &D, std::string &Arguments) {
(D.*Impl)(Arguments); (D.*Impl)(Arguments);
} }

View File

@ -1,12 +1,12 @@
//===-- CLIDebugger.cpp - Command Line Interface to the Debugger ----------===// //===-- CLIDebugger.cpp - Command Line Interface to the Debugger ----------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file contains the main implementation of the Command Line Interface to // This file contains the main implementation of the Command Line Interface to
// the debugger. // the debugger.
// //
@ -77,7 +77,7 @@ CLIDebugger::CLIDebugger()
addCommand("next", C = new BuiltinCLICommand( addCommand("next", C = new BuiltinCLICommand(
"Step program until it reaches a new source line, stepping over calls", "", "Step program until it reaches a new source line, stepping over calls", "",
&CLIDebugger::nextCommand)); &CLIDebugger::nextCommand));
addCommand("n", C); addCommand("n", C);
addCommand("finish", new BuiltinCLICommand( addCommand("finish", new BuiltinCLICommand(
"Execute until the selected stack frame returns", "Execute until the selected stack frame returns",
@ -91,8 +91,8 @@ CLIDebugger::CLIDebugger()
"Print backtrace of all stack frames, or innermost COUNT frames", "Print backtrace of all stack frames, or innermost COUNT frames",
"FIXME: describe. Takes 'n', '-n' or 'full'\n", "FIXME: describe. Takes 'n', '-n' or 'full'\n",
&CLIDebugger::backtraceCommand)); &CLIDebugger::backtraceCommand));
addCommand("bt", C); addCommand("bt", C);
addCommand("up", new BuiltinCLICommand( addCommand("up", new BuiltinCLICommand(
"Select and print stack frame that called this one", "Select and print stack frame that called this one",
"An argument says how many frames up to go.\n", "An argument says how many frames up to go.\n",
@ -108,7 +108,7 @@ CLIDebugger::CLIDebugger()
"With no argument, print the selected stack frame. (See also 'info frame').\n" "With no argument, print the selected stack frame. (See also 'info frame').\n"
"An argument specifies the frame to select.\n", "An argument specifies the frame to select.\n",
&CLIDebugger::frameCommand)); &CLIDebugger::frameCommand));
addCommand("f", C); addCommand("f", C);
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Breakpoint related commands // Breakpoint related commands
@ -117,7 +117,7 @@ CLIDebugger::CLIDebugger()
"Set breakpoint at specified line or function", "Set breakpoint at specified line or function",
"FIXME: describe.\n", "FIXME: describe.\n",
&CLIDebugger::breakCommand)); &CLIDebugger::breakCommand));
addCommand("b", C); addCommand("b", C);
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@ -187,7 +187,7 @@ CLICommand *CLIDebugger::getCommand(const std::string &Command) {
// Look up the command in the table. // Look up the command in the table.
std::map<std::string, CLICommand*>::iterator CI = std::map<std::string, CLICommand*>::iterator CI =
CommandTable.lower_bound(Command); CommandTable.lower_bound(Command);
if (Command == "") { if (Command == "") {
throw "Null command should not get here!"; throw "Null command should not get here!";
} else if (CI == CommandTable.end() || } else if (CI == CommandTable.end() ||
@ -207,7 +207,7 @@ CLICommand *CLIDebugger::getCommand(const std::string &Command) {
// If the next command is a valid completion of this one, we are // If the next command is a valid completion of this one, we are
// ambiguous. // ambiguous.
if (++CI2 != CommandTable.end() && isValidPrefix(Command, CI2->first)) { if (++CI2 != CommandTable.end() && isValidPrefix(Command, CI2->first)) {
std::string ErrorMsg = std::string ErrorMsg =
"Ambiguous command '" + Command + "'. Options: " + CI->first; "Ambiguous command '" + Command + "'. Options: " + CI->first;
for (++CI; CI != CommandTable.end() && for (++CI; CI != CommandTable.end() &&
isValidPrefix(Command, CI->first); ++CI) isValidPrefix(Command, CI->first); ++CI)
@ -242,7 +242,7 @@ int CLIDebugger::run() {
try { try {
CLICommand *CurCommand; CLICommand *CurCommand;
if (Command == "") { if (Command == "") {
CurCommand = LastCommand; CurCommand = LastCommand;
Arguments = LastArgs; Arguments = LastArgs;
@ -257,7 +257,7 @@ int CLIDebugger::run() {
// Finally, execute the command. // Finally, execute the command.
if (CurCommand) if (CurCommand)
CurCommand->runCommand(*this, Arguments); CurCommand->runCommand(*this, Arguments);
} catch (int RetVal) { } catch (int RetVal) {
// The quit command exits the command loop by throwing an integer return // The quit command exits the command loop by throwing an integer return
@ -273,7 +273,7 @@ int CLIDebugger::run() {
std::cout << "ERROR: Debugger caught unexpected exception!\n"; std::cout << "ERROR: Debugger caught unexpected exception!\n";
// Attempt to continue. // Attempt to continue.
} }
// Write the prompt to get the next bit of user input // Write the prompt to get the next bit of user input
std::cout << Prompt; std::cout << Prompt;
} }
@ -302,7 +302,7 @@ bool CLIDebugger::askYesNo(const std::string &Message) const {
std::cout << "Please answer y or n.\n" << Message << " (y or n) " std::cout << "Please answer y or n.\n" << Message << " (y or n) "
<< std::flush; << std::flush;
} }
// Ran out of input? // Ran out of input?
return false; return false;
} }

View File

@ -1,10 +1,10 @@
//===- CLIDebugger.h - LLVM Command Line Interface Debugger -----*- C++ -*-===// //===- CLIDebugger.h - LLVM Command Line Interface Debugger -----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines the CLIDebugger class, which implements a command line // This file defines the CLIDebugger class, which implements a command line
@ -62,11 +62,11 @@ namespace llvm {
// //
std::string Prompt; // set prompt, show prompt std::string Prompt; // set prompt, show prompt
unsigned ListSize; // set listsize, show listsize unsigned ListSize; // set listsize, show listsize
//===------------------------------------------------------------------===// //===------------------------------------------------------------------===//
// Data to support user interaction // Data to support user interaction
// //
/// CurrentFile - The current source file we are inspecting, or null if /// CurrentFile - The current source file we are inspecting, or null if
/// none. /// none.
const SourceFile *CurrentFile; const SourceFile *CurrentFile;

View File

@ -1,12 +1,12 @@
//===-- Commands.cpp - Implement various commands for the CLI -------------===// //===-- Commands.cpp - Implement various commands for the CLI -------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements many builtin user commands. // This file implements many builtin user commands.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -91,7 +91,7 @@ bool CLIDebugger::printSourceLine(unsigned LineNo) {
std::cout << " ->"; std::cout << " ->";
} }
std::cout << "\t" << std::string(LineStart, LineEnd) << "\n"; std::cout << "\t" << std::string(LineStart, LineEnd) << "\n";
return false; return false;
} }
@ -115,9 +115,9 @@ void CLIDebugger::printProgramLocation(bool PrintLocation) {
std::cout << getProgramInfo().getFunction(FuncDesc).getSymbolicName(); std::cout << getProgramInfo().getFunction(FuncDesc).getSymbolicName();
else else
std::cout << "<unknown function>"; std::cout << "<unknown function>";
CurrentFile = &FileDesc->getSourceText(); CurrentFile = &FileDesc->getSourceText();
std::cout << " at " << CurrentFile->getFilename() << ":" << LineNo; std::cout << " at " << CurrentFile->getFilename() << ":" << LineNo;
if (ColNo) std::cout << ":" << ColNo; if (ColNo) std::cout << ":" << ColNo;
std::cout << "\n"; std::cout << "\n";
@ -167,7 +167,7 @@ static unsigned getUnsignedIntegerOption(const char *Msg, std::string &Val,
std::string Tok = getToken(Val); std::string Tok = getToken(Val);
if (Tok.empty() || (isOnlyOption && !getToken(Val).empty())) if (Tok.empty() || (isOnlyOption && !getToken(Val).empty()))
throw std::string(Msg) + " expects an unsigned integer argument."; throw std::string(Msg) + " expects an unsigned integer argument.";
char *EndPtr; char *EndPtr;
unsigned Result = strtoul(Tok.c_str(), &EndPtr, 0); unsigned Result = strtoul(Tok.c_str(), &EndPtr, 0);
if (EndPtr != Tok.c_str()+Tok.size()) if (EndPtr != Tok.c_str()+Tok.size())
@ -179,7 +179,7 @@ static unsigned getUnsignedIntegerOption(const char *Msg, std::string &Val,
/// getOptionalUnsignedIntegerOption - This method is just like /// getOptionalUnsignedIntegerOption - This method is just like
/// getUnsignedIntegerOption, but if the argument value is not specified, a /// getUnsignedIntegerOption, but if the argument value is not specified, a
/// default is returned instead of causing an error. /// default is returned instead of causing an error.
static unsigned static unsigned
getOptionalUnsignedIntegerOption(const char *Msg, unsigned Default, getOptionalUnsignedIntegerOption(const char *Msg, unsigned Default,
std::string &Val, bool isOnlyOption = true) { std::string &Val, bool isOnlyOption = true) {
// Check to see if the value was specified... // Check to see if the value was specified...
@ -201,13 +201,13 @@ void CLIDebugger::parseProgramOptions(std::string &Options) {
// FIXME: tokenizing by whitespace is clearly incorrect. Instead we should // FIXME: tokenizing by whitespace is clearly incorrect. Instead we should
// honor quotes and other things that a shell would. Also in the future we // honor quotes and other things that a shell would. Also in the future we
// should support redirection of standard IO. // should support redirection of standard IO.
std::vector<std::string> Arguments; std::vector<std::string> Arguments;
for (std::string A = getToken(Options); !A.empty(); A = getToken(Options)) for (std::string A = getToken(Options); !A.empty(); A = getToken(Options))
Arguments.push_back(A); Arguments.push_back(A);
Dbg.setProgramArguments(Arguments.begin(), Arguments.end()); Dbg.setProgramArguments(Arguments.begin(), Arguments.end());
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Program startup and shutdown options // Program startup and shutdown options
@ -477,7 +477,7 @@ void CLIDebugger::breakCommand(std::string &Options) {
// Figure out where the user wants a breakpoint. // Figure out where the user wants a breakpoint.
const SourceFile *File; const SourceFile *File;
unsigned LineNo; unsigned LineNo;
// Check to see if the user specified a line specifier. // Check to see if the user specified a line specifier.
std::string Option = getToken(Options); // strip whitespace std::string Option = getToken(Options); // strip whitespace
if (!Option.empty()) { if (!Option.empty()) {
@ -489,13 +489,13 @@ void CLIDebugger::breakCommand(std::string &Options) {
// Build a line specifier for the current stack frame. // Build a line specifier for the current stack frame.
throw "FIXME: breaking at the current location is not implemented yet!"; throw "FIXME: breaking at the current location is not implemented yet!";
} }
if (!File) File = CurrentFile; if (!File) File = CurrentFile;
if (File == 0) if (File == 0)
throw "Unknown file to place breakpoint!"; throw "Unknown file to place breakpoint!";
std::cerr << "Break: " << File->getFilename() << ":" << LineNo << "\n"; std::cerr << "Break: " << File->getFilename() << ":" << LineNo << "\n";
throw "breakpoints not implemented yet!"; throw "breakpoints not implemented yet!";
} }
@ -542,7 +542,7 @@ void CLIDebugger::infoCommand(std::string &Options) {
<< SF.getLanguage().getSourceLanguageName() << "\n"; << SF.getLanguage().getSourceLanguageName() << "\n";
} else if (What == "sources") { } else if (What == "sources") {
const std::map<const GlobalVariable*, SourceFileInfo*> &SourceFiles = const std::map<const GlobalVariable*, SourceFileInfo*> &SourceFiles =
getProgramInfo().getSourceFiles(); getProgramInfo().getSourceFiles();
std::cout << "Source files for the program:\n"; std::cout << "Source files for the program:\n";
for (std::map<const GlobalVariable*, SourceFileInfo*>::const_iterator I = for (std::map<const GlobalVariable*, SourceFileInfo*>::const_iterator I =
@ -607,7 +607,7 @@ void CLIDebugger::parseLineSpec(std::string &LineSpec,
std::string Name = getToken(FirstPart); std::string Name = getToken(FirstPart);
if (!getToken(FirstPart).empty()) if (!getToken(FirstPart).empty())
throw "Extra junk in line specifier after '" + Name + "'."; throw "Extra junk in line specifier after '" + Name + "'.";
SourceFunctionInfo *SFI = SourceFunctionInfo *SFI =
getCurrentLanguage().lookupFunction(Name, getProgramInfo(), getCurrentLanguage().lookupFunction(Name, getProgramInfo(),
TheRuntimeInfo); TheRuntimeInfo);
if (SFI == 0) if (SFI == 0)
@ -651,7 +651,7 @@ void CLIDebugger::listCommand(std::string &Options) {
// Handle "list foo," correctly, by returning " " as the second token // Handle "list foo," correctly, by returning " " as the second token
Options += " "; Options += " ";
std::string FirstLineSpec = getToken(Options, ","); std::string FirstLineSpec = getToken(Options, ",");
std::string SecondLineSpec = getToken(Options, ","); std::string SecondLineSpec = getToken(Options, ",");
if (!getToken(Options, ",").empty()) if (!getToken(Options, ",").empty())
@ -689,7 +689,7 @@ void CLIDebugger::listCommand(std::string &Options) {
} }
} else { } else {
// Parse two line specifiers... // Parse two line specifiers...
const SourceFile *StartFile, *EndFile; const SourceFile *StartFile, *EndFile;
unsigned StartLineNo, EndLineNo; unsigned StartLineNo, EndLineNo;
parseLineSpec(FirstLineSpec, StartFile, StartLineNo); parseLineSpec(FirstLineSpec, StartFile, StartLineNo);

View File

@ -1,10 +1,10 @@
//===- llvm-db.cpp - LLVM Debugger ----------------------------------------===// //===- llvm-db.cpp - LLVM Debugger ----------------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility implements a simple text-mode front-end to the LLVM debugger // This utility implements a simple text-mode front-end to the LLVM debugger
@ -35,7 +35,7 @@ namespace {
cl::desc("Add directory to the search for source files")); cl::desc("Add directory to the search for source files"));
cl::alias SDA("d", cl::desc("Alias for --directory"), cl::alias SDA("d", cl::desc("Alias for --directory"),
cl::aliasopt(SourceDirectories)); cl::aliasopt(SourceDirectories));
cl::opt<std::string> cl::opt<std::string>
WorkingDirectory("cd", cl::desc("Use directory as current working directory"), WorkingDirectory("cd", cl::desc("Use directory as current working directory"),
cl::value_desc("directory")); cl::value_desc("directory"));
@ -73,7 +73,7 @@ int main(int argc, char **argv, char * const *envp) {
Dbg.setWorkingDirectory(WorkingDirectory); Dbg.setWorkingDirectory(WorkingDirectory);
for (unsigned i = 0, e = SourceDirectories.size(); i != e; ++i) for (unsigned i = 0, e = SourceDirectories.size(); i != e; ++i)
D.addSourceDirectory(SourceDirectories[i]); D.addSourceDirectory(SourceDirectories[i]);
if (!InputArgs.empty()) { if (!InputArgs.empty()) {
try { try {
D.fileCommand(InputArgs[0]); D.fileCommand(InputArgs[0]);

View File

@ -1,10 +1,10 @@
//===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===// //===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility may be invoked in the following manner: // This utility may be invoked in the following manner:
@ -31,7 +31,7 @@ static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-")); InputFilename(cl::Positional, cl::desc("<input bytecode>"), cl::init("-"));
static cl::opt<std::string> static cl::opt<std::string>
OutputFilename("o", cl::desc("Override output filename"), OutputFilename("o", cl::desc("Override output filename"),
cl::value_desc("filename")); cl::value_desc("filename"));
static cl::opt<bool> static cl::opt<bool>
@ -54,7 +54,7 @@ int main(int argc, char **argv) {
std::cerr << "bytecode didn't read correctly.\n"; std::cerr << "bytecode didn't read correctly.\n";
return 1; return 1;
} }
if (OutputFilename != "") { // Specified an output filename? if (OutputFilename != "") { // Specified an output filename?
if (OutputFilename != "-") { // Not stdout? if (OutputFilename != "-") { // Not stdout?
if (!Force && std::ifstream(OutputFilename.c_str())) { if (!Force && std::ifstream(OutputFilename.c_str())) {

View File

@ -1,10 +1,10 @@
//===- Optimize.cpp - Optimize a complete program -------------------------===// //===- Optimize.cpp - Optimize a complete program -------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements all optimization of the linked module for llvm-ld. // This file implements all optimization of the linked module for llvm-ld.
@ -52,7 +52,7 @@ static cl::opt<OptimizationLevels> OptLevel(
) )
); );
static cl::opt<bool> DisableInline("disable-inlining", static cl::opt<bool> DisableInline("disable-inlining",
cl::desc("Do not run the inliner pass")); cl::desc("Do not run the inliner pass"));
static cl::opt<bool> static cl::opt<bool>
@ -62,13 +62,13 @@ DisableOptimizations("disable-opt",
static cl::opt<bool> DisableInternalize("disable-internalize", static cl::opt<bool> DisableInternalize("disable-internalize",
cl::desc("Do not mark all symbols as internal")); cl::desc("Do not mark all symbols as internal"));
static cl::opt<bool> Verify("verify", static cl::opt<bool> Verify("verify",
cl::desc("Verify intermediate results of all passes")); cl::desc("Verify intermediate results of all passes"));
static cl::opt<bool> Strip("s", static cl::opt<bool> Strip("s",
cl::desc("Strip symbol info from executable")); cl::desc("Strip symbol info from executable"));
static cl::alias ExportDynamic("export-dynamic", static cl::alias ExportDynamic("export-dynamic",
cl::aliasopt(DisableInternalize), cl::aliasopt(DisableInternalize),
cl::desc("Alias for -disable-internalize")); cl::desc("Alias for -disable-internalize"));
@ -81,16 +81,16 @@ static cl::list<std::string> LoadableModules("load",
static inline void addPass(PassManager &PM, Pass *P) { static inline void addPass(PassManager &PM, Pass *P) {
// Add the pass to the pass manager... // Add the pass to the pass manager...
PM.add(P); PM.add(P);
// If we are verifying all of the intermediate steps, add the verifier... // If we are verifying all of the intermediate steps, add the verifier...
if (Verify) if (Verify)
PM.add(createVerifierPass()); PM.add(createVerifierPass());
} }
namespace llvm { namespace llvm {
/// Optimize - Perform link time optimizations. This will run the scalar /// Optimize - Perform link time optimizations. This will run the scalar
/// optimizations, any loaded plugin-optimization modules, and then the /// optimizations, any loaded plugin-optimization modules, and then the
/// inter-procedural optimizations if applicable. /// inter-procedural optimizations if applicable.
void Optimize(Module* M) { void Optimize(Module* M) {
@ -98,7 +98,7 @@ void Optimize(Module* M) {
PassManager Passes; PassManager Passes;
// If we're verifying, start off with a verification pass. // If we're verifying, start off with a verification pass.
if (Verify) if (Verify)
Passes.add(createVerifierPass()); Passes.add(createVerifierPass());
// Add an appropriate TargetData instance for this module... // Add an appropriate TargetData instance for this module...
@ -171,14 +171,14 @@ void Optimize(Module* M) {
} }
std::vector<std::string> plugins = LoadableModules; std::vector<std::string> plugins = LoadableModules;
for (std::vector<std::string>::iterator I = plugins.begin(), for (std::vector<std::string>::iterator I = plugins.begin(),
E = plugins.end(); I != E; ++I) { E = plugins.end(); I != E; ++I) {
sys::DynamicLibrary dll(I->c_str()); sys::DynamicLibrary dll(I->c_str());
typedef void (*OptimizeFunc)(PassManager&,int); typedef void (*OptimizeFunc)(PassManager&,int);
OptimizeFunc OF = OptimizeFunc( OptimizeFunc OF = OptimizeFunc(
dll.GetAddressOfSymbol("RunOptimizations")); dll.GetAddressOfSymbol("RunOptimizations"));
if (OF == 0) { if (OF == 0) {
throw std::string("Optimization Module '") + *I + throw std::string("Optimization Module '") + *I +
"' is missing the RunOptimizations symbol"; "' is missing the RunOptimizations symbol";
} }
(*OF)(Passes,OptLevel); (*OF)(Passes,OptLevel);

View File

@ -1,10 +1,10 @@
//===- llvm-ld.cpp - LLVM 'ld' compatible linker --------------------------===// //===- llvm-ld.cpp - LLVM 'ld' compatible linker --------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility is intended to be compatible with GCC, and follows standard // This utility is intended to be compatible with GCC, and follows standard
@ -44,21 +44,21 @@ static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bytecode files>")); cl::desc("<input bytecode files>"));
static cl::opt<std::string> OutputFilename("o", cl::init("a.out"), static cl::opt<std::string> OutputFilename("o", cl::init("a.out"),
cl::desc("Override output filename"), cl::desc("Override output filename"),
cl::value_desc("filename")); cl::value_desc("filename"));
static cl::opt<bool> Verbose("v", static cl::opt<bool> Verbose("v",
cl::desc("Print information about actions taken")); cl::desc("Print information about actions taken"));
static cl::list<std::string> LibPaths("L", cl::Prefix, static cl::list<std::string> LibPaths("L", cl::Prefix,
cl::desc("Specify a library search path"), cl::desc("Specify a library search path"),
cl::value_desc("directory")); cl::value_desc("directory"));
static cl::list<std::string> Libraries("l", cl::Prefix, static cl::list<std::string> Libraries("l", cl::Prefix,
cl::desc("Specify libraries to link to"), cl::desc("Specify libraries to link to"),
cl::value_desc("library prefix")); cl::value_desc("library prefix"));
static cl::opt<bool> LinkAsLibrary("link-as-library", static cl::opt<bool> LinkAsLibrary("link-as-library",
cl::desc("Link the .bc files together as a library, not an executable")); cl::desc("Link the .bc files together as a library, not an executable"));
static cl::alias Relink("r", cl::aliasopt(LinkAsLibrary), static cl::alias Relink("r", cl::aliasopt(LinkAsLibrary),
@ -75,18 +75,18 @@ static cl::opt<bool>NativeCBE("native-cbe",
static cl::opt<bool>DisableCompression("disable-compression",cl::init(false), static cl::opt<bool>DisableCompression("disable-compression",cl::init(false),
cl::desc("Disable writing of compressed bytecode files")); cl::desc("Disable writing of compressed bytecode files"));
// Compatibility options that are ignored but supported by LD // Compatibility options that are ignored but supported by LD
static cl::opt<std::string> CO3("soname", cl::Hidden, static cl::opt<std::string> CO3("soname", cl::Hidden,
cl::desc("Compatibility option: ignored")); cl::desc("Compatibility option: ignored"));
static cl::opt<std::string> CO4("version-script", cl::Hidden, static cl::opt<std::string> CO4("version-script", cl::Hidden,
cl::desc("Compatibility option: ignored")); cl::desc("Compatibility option: ignored"));
static cl::opt<bool> CO5("eh-frame-hdr", cl::Hidden, static cl::opt<bool> CO5("eh-frame-hdr", cl::Hidden,
cl::desc("Compatibility option: ignored")); cl::desc("Compatibility option: ignored"));
static cl::opt<std::string> CO6("h", cl::Hidden, static cl::opt<std::string> CO6("h", cl::Hidden,
cl::desc("Compatibility option: ignored")); cl::desc("Compatibility option: ignored"));
/// This is just for convenience so it doesn't have to be passed around /// This is just for convenience so it doesn't have to be passed around
@ -342,12 +342,12 @@ static void EmitShellScript(char **argv) {
LibPaths.push_back("/usr/X11R6/lib"); LibPaths.push_back("/usr/X11R6/lib");
// We don't need to link in libc! In fact, /usr/lib/libc.so may not be a // We don't need to link in libc! In fact, /usr/lib/libc.so may not be a
// shared object at all! See RH 8: plain text. // shared object at all! See RH 8: plain text.
std::vector<std::string>::iterator libc = std::vector<std::string>::iterator libc =
std::find(Libraries.begin(), Libraries.end(), "c"); std::find(Libraries.begin(), Libraries.end(), "c");
if (libc != Libraries.end()) Libraries.erase(libc); if (libc != Libraries.end()) Libraries.erase(libc);
// List all the shared object (native) libraries this executable will need // List all the shared object (native) libraries this executable will need
// on the command line, so that we don't have to do this manually! // on the command line, so that we don't have to do this manually!
for (std::vector<std::string>::iterator i = Libraries.begin(), for (std::vector<std::string>::iterator i = Libraries.begin(),
e = Libraries.end(); i != e; ++i) { e = Libraries.end(); i != e; ++i) {
sys::Path FullLibraryPath = sys::Path::FindLibrary(*i); sys::Path FullLibraryPath = sys::Path::FindLibrary(*i);
if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary()) if (!FullLibraryPath.isEmpty() && FullLibraryPath.isDynamicLibrary())
@ -365,7 +365,7 @@ static void BuildLinkItems(
const cl::list<std::string>& Files, const cl::list<std::string>& Files,
const cl::list<std::string>& Libraries) { const cl::list<std::string>& Libraries) {
// Build the list of linkage items for LinkItems. // Build the list of linkage items for LinkItems.
cl::list<std::string>::const_iterator fileIt = Files.begin(); cl::list<std::string>::const_iterator fileIt = Files.begin();
cl::list<std::string>::const_iterator libIt = Libraries.begin(); cl::list<std::string>::const_iterator libIt = Libraries.begin();
@ -401,7 +401,7 @@ int main(int argc, char **argv, char **envp) {
// Initial global variable above for convenience printing of program name. // Initial global variable above for convenience printing of program name.
progname = sys::Path(argv[0]).getBasename(); progname = sys::Path(argv[0]).getBasename();
Linker TheLinker(progname, Verbose); Linker TheLinker(progname, Verbose);
// Set up the library paths for the Linker // Set up the library paths for the Linker
TheLinker.addPaths(LibPaths); TheLinker.addPaths(LibPaths);
TheLinker.addSystemPaths(); TheLinker.addSystemPaths();
@ -423,7 +423,7 @@ int main(int argc, char **argv, char **envp) {
// The libraries aren't linked in but are noted as "dependent" in the // The libraries aren't linked in but are noted as "dependent" in the
// module. // module.
for (cl::list<std::string>::const_iterator I = Libraries.begin(), for (cl::list<std::string>::const_iterator I = Libraries.begin(),
E = Libraries.end(); I != E ; ++I) { E = Libraries.end(); I != E ; ++I) {
TheLinker.getModule()->addLibrary(*I); TheLinker.getModule()->addLibrary(*I);
} }
@ -476,7 +476,7 @@ int main(int argc, char **argv, char **envp) {
if (Verbose) std::cout << "Generating Assembly Code\n"; if (Verbose) std::cout << "Generating Assembly Code\n";
GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc); GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc);
if (Verbose) std::cout << "Generating Native Code\n"; if (Verbose) std::cout << "Generating Native Code\n";
GenerateNative(OutputFilename, AssemblyFile.toString(), Libraries, GenerateNative(OutputFilename, AssemblyFile.toString(), Libraries,
gcc, envp); gcc, envp);
// Remove the assembly language file. // Remove the assembly language file.
@ -510,7 +510,7 @@ int main(int argc, char **argv, char **envp) {
} else { } else {
EmitShellScript(argv); EmitShellScript(argv);
} }
// Make the script executable... // Make the script executable...
sys::Path(OutputFilename).makeExecutable(); sys::Path(OutputFilename).makeExecutable();

View File

@ -1,10 +1,10 @@
//===- llvm-link.cpp - Low-level LLVM linker ------------------------------===// //===- llvm-link.cpp - Low-level LLVM linker ------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This utility may be invoked in the following manner: // This utility may be invoked in the following manner:
@ -67,7 +67,7 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
std::cerr << "\n"; std::cerr << "\n";
} }
} else { } else {
std::cerr << "Bytecode file: '" << Filename.c_str() std::cerr << "Bytecode file: '" << Filename.c_str()
<< "' does not exist.\n"; << "' does not exist.\n";
} }

View File

@ -1,16 +1,16 @@
//===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===// //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This program is a utility that works like traditional Unix "nm", // This program is a utility that works like traditional Unix "nm",
// that is, it prints out the names of symbols in a bytecode file, // that is, it prints out the names of symbols in a bytecode file,
// along with some information about each symbol. // along with some information about each symbol.
// //
// This "nm" does not print symbols' addresses. It supports many of // This "nm" does not print symbols' addresses. It supports many of
// the features of GNU "nm", including its different output formats. // the features of GNU "nm", including its different output formats.
// //
@ -35,12 +35,12 @@ namespace {
cl::desc("Specify output format"), cl::desc("Specify output format"),
cl::values(clEnumVal(bsd, "BSD format"), cl::values(clEnumVal(bsd, "BSD format"),
clEnumVal(sysv, "System V format"), clEnumVal(sysv, "System V format"),
clEnumVal(posix, "POSIX.2 format"), clEnumVal(posix, "POSIX.2 format"),
clEnumValEnd), cl::init(bsd)); clEnumValEnd), cl::init(bsd));
cl::alias OutputFormat2("f", cl::desc("Alias for --format"), cl::alias OutputFormat2("f", cl::desc("Alias for --format"),
cl::aliasopt(OutputFormat)); cl::aliasopt(OutputFormat));
cl::list<std::string> cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input bytecode files>"), InputFilenames(cl::Positional, cl::desc("<input bytecode files>"),
cl::ZeroOrMore); cl::ZeroOrMore);

View File

@ -1,10 +1,10 @@
//===- llvm-prof.cpp - Read in and process llvmprof.out data files --------===// //===- llvm-prof.cpp - Read in and process llvmprof.out data files --------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tools is meant for use with the various LLVM profiling instrumentation // This tools is meant for use with the various LLVM profiling instrumentation
@ -28,11 +28,11 @@
using namespace llvm; using namespace llvm;
namespace { namespace {
cl::opt<std::string> cl::opt<std::string>
BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"), BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"),
cl::Required); cl::Required);
cl::opt<std::string> cl::opt<std::string>
ProfileDataFile(cl::Positional, cl::desc("<llvmprof.out file>"), ProfileDataFile(cl::Positional, cl::desc("<llvmprof.out file>"),
cl::Optional, cl::init("llvmprof.out")); cl::Optional, cl::init("llvmprof.out"));
@ -87,7 +87,7 @@ namespace {
// Figure out how many times each successor executed. // Figure out how many times each successor executed.
std::vector<std::pair<const BasicBlock*, unsigned> > SuccCounts; std::vector<std::pair<const BasicBlock*, unsigned> > SuccCounts;
const TerminatorInst *TI = BB->getTerminator(); const TerminatorInst *TI = BB->getTerminator();
std::map<ProfileInfoLoader::Edge, unsigned>::iterator I = std::map<ProfileInfoLoader::Edge, unsigned>::iterator I =
EdgeFreqs.lower_bound(std::make_pair(const_cast<BasicBlock*>(BB), 0U)); EdgeFreqs.lower_bound(std::make_pair(const_cast<BasicBlock*>(BB), 0U));
for (; I != EdgeFreqs.end() && I->first.first == BB; ++I) for (; I != EdgeFreqs.end() && I->first.first == BB; ++I)
@ -142,18 +142,18 @@ int main(int argc, char **argv) {
unsigned long long TotalExecutions = 0; unsigned long long TotalExecutions = 0;
for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i) for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i)
TotalExecutions += FunctionCounts[i].second; TotalExecutions += FunctionCounts[i].second;
std::cout << "===" << std::string(73, '-') << "===\n" std::cout << "===" << std::string(73, '-') << "===\n"
<< "LLVM profiling output for execution"; << "LLVM profiling output for execution";
if (PI.getNumExecutions() != 1) std::cout << "s"; if (PI.getNumExecutions() != 1) std::cout << "s";
std::cout << ":\n"; std::cout << ":\n";
for (unsigned i = 0, e = PI.getNumExecutions(); i != e; ++i) { for (unsigned i = 0, e = PI.getNumExecutions(); i != e; ++i) {
std::cout << " "; std::cout << " ";
if (e != 1) std::cout << i+1 << ". "; if (e != 1) std::cout << i+1 << ". ";
std::cout << PI.getExecution(i) << "\n"; std::cout << PI.getExecution(i) << "\n";
} }
std::cout << "\n===" << std::string(73, '-') << "===\n"; std::cout << "\n===" << std::string(73, '-') << "===\n";
std::cout << "Function execution frequencies:\n\n"; std::cout << "Function execution frequencies:\n\n";
@ -185,7 +185,7 @@ int main(int argc, char **argv) {
// Sort by the frequency, backwards. // Sort by the frequency, backwards.
std::sort(Counts.begin(), Counts.end(), std::sort(Counts.begin(), Counts.end(),
PairSecondSortReverse<BasicBlock*>()); PairSecondSortReverse<BasicBlock*>());
std::cout << "\n===" << std::string(73, '-') << "===\n"; std::cout << "\n===" << std::string(73, '-') << "===\n";
std::cout << "Top 20 most frequently executed basic blocks:\n\n"; std::cout << "Top 20 most frequently executed basic blocks:\n\n";
@ -205,7 +205,7 @@ int main(int argc, char **argv) {
BlockFreqs.insert(Counts.begin(), Counts.end()); BlockFreqs.insert(Counts.begin(), Counts.end());
} }
if (PI.hasAccurateEdgeCounts()) { if (PI.hasAccurateEdgeCounts()) {
std::vector<std::pair<ProfileInfoLoader::Edge, unsigned> > Counts; std::vector<std::pair<ProfileInfoLoader::Edge, unsigned> > Counts;
PI.getEdgeCounts(Counts); PI.getEdgeCounts(Counts);
@ -215,7 +215,7 @@ int main(int argc, char **argv) {
if (PrintAnnotatedLLVM || PrintAllCode) { if (PrintAnnotatedLLVM || PrintAllCode) {
std::cout << "\n===" << std::string(73, '-') << "===\n"; std::cout << "\n===" << std::string(73, '-') << "===\n";
std::cout << "Annotated LLVM code for the module:\n\n"; std::cout << "Annotated LLVM code for the module:\n\n";
ProfileAnnotator PA(FuncFreqs, BlockFreqs, EdgeFreqs); ProfileAnnotator PA(FuncFreqs, BlockFreqs, EdgeFreqs);
if (FunctionsToPrint.empty() || PrintAllCode) if (FunctionsToPrint.empty() || PrintAllCode)

View File

@ -1,10 +1,10 @@
//===-- llvm-ranlib.cpp - LLVM archive index generator --------------------===// //===-- llvm-ranlib.cpp - LLVM archive index generator --------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// Adds or updates an index (symbol table) for an LLVM archive file. // Adds or updates an index (symbol table) for an LLVM archive file.
@ -21,7 +21,7 @@
using namespace llvm; using namespace llvm;
// llvm-ar operation code and modifier flags // llvm-ar operation code and modifier flags
static cl::opt<std::string> static cl::opt<std::string>
ArchiveName(cl::Positional, cl::Optional, cl::desc("<archive-file>")); ArchiveName(cl::Positional, cl::Optional, cl::desc("<archive-file>"));
static cl::opt<bool> static cl::opt<bool>
@ -32,7 +32,7 @@ Verbose("verbose",cl::Optional,cl::init(false),
void printSymbolTable(Archive* TheArchive) { void printSymbolTable(Archive* TheArchive) {
std::cout << "\nArchive Symbol Table:\n"; std::cout << "\nArchive Symbol Table:\n";
const Archive::SymTabType& symtab = TheArchive->getSymbolTable(); const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end(); for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
I != E; ++I ) { I != E; ++I ) {
unsigned offset = TheArchive->getFirstFileOffset() + I->second; unsigned offset = TheArchive->getFirstFileOffset() + I->second;
std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n"; std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
@ -67,7 +67,7 @@ int main(int argc, char **argv) {
throw std::string("Archive file does not exist"); throw std::string("Archive file does not exist");
std::string err_msg; std::string err_msg;
std::auto_ptr<Archive> std::auto_ptr<Archive>
AutoArchive(Archive::OpenAndLoad(ArchivePath,&err_msg)); AutoArchive(Archive::OpenAndLoad(ArchivePath,&err_msg));
Archive* TheArchive = AutoArchive.get(); Archive* TheArchive = AutoArchive.get();
if (!TheArchive) if (!TheArchive)

View File

@ -1,11 +1,11 @@
//===- CompilerDriver.cpp - The LLVM Compiler Driver ------------*- C++ -*-===// //===- CompilerDriver.cpp - The LLVM Compiler Driver ------------*- C++ -*-===//
// //
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements the bulk of the LLVM Compiler Driver (llvmc). // This file implements the bulk of the LLVM Compiler Driver (llvmc).
@ -48,7 +48,7 @@ void DumpAction(CompilerDriver::Action* action) {
} }
void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){ void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){
std::cerr << "Configuration Data For '" << cd->langName << "' (" << type std::cerr << "Configuration Data For '" << cd->langName << "' (" << type
<< ")\n"; << ")\n";
std::cerr << "PreProcessor: "; std::cerr << "PreProcessor: ";
DumpAction(&cd->PreProcessor); DumpAction(&cd->PreProcessor);
@ -64,7 +64,7 @@ void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){
/// This specifies the passes to run for OPT_FAST_COMPILE (-O1) /// This specifies the passes to run for OPT_FAST_COMPILE (-O1)
/// which should reduce the volume of code and make compilation /// which should reduce the volume of code and make compilation
/// faster. This is also safe on any llvm module. /// faster. This is also safe on any llvm module.
static const char* DefaultFastCompileOptimizations[] = { static const char* DefaultFastCompileOptimizations[] = {
"-simplifycfg", "-mem2reg", "-instcombine" "-simplifycfg", "-mem2reg", "-instcombine"
}; };
@ -76,7 +76,7 @@ public:
CompilerDriverImpl(ConfigDataProvider& confDatProv ) CompilerDriverImpl(ConfigDataProvider& confDatProv )
: cdp(&confDatProv) : cdp(&confDatProv)
, finalPhase(LINKING) , finalPhase(LINKING)
, optLevel(OPT_FAST_COMPILE) , optLevel(OPT_FAST_COMPILE)
, Flags(0) , Flags(0)
, machine() , machine()
, LibraryPaths() , LibraryPaths()
@ -108,16 +108,16 @@ public:
/// @name Methods /// @name Methods
/// @{ /// @{
public: public:
virtual void setFinalPhase( Phases phase ) { virtual void setFinalPhase( Phases phase ) {
finalPhase = phase; finalPhase = phase;
} }
virtual void setOptimization( OptimizationLevels level ) { virtual void setOptimization( OptimizationLevels level ) {
optLevel = level; optLevel = level;
} }
virtual void setDriverFlags( unsigned flags ) { virtual void setDriverFlags( unsigned flags ) {
Flags = flags & DRIVER_FLAGS_MASK; Flags = flags & DRIVER_FLAGS_MASK;
} }
virtual void setOutputMachine( const std::string& machineName ) { virtual void setOutputMachine( const std::string& machineName ) {
@ -194,7 +194,7 @@ private:
} }
} }
sys::Path MakeTempFile(const std::string& basename, sys::Path MakeTempFile(const std::string& basename,
const std::string& suffix ) { const std::string& suffix ) {
sys::Path result(TempDir); sys::Path result(TempDir);
if (!result.appendFile(basename)) if (!result.appendFile(basename))
@ -204,8 +204,8 @@ private:
return result; return result;
} }
Action* GetAction(ConfigData* cd, Action* GetAction(ConfigData* cd,
const sys::Path& input, const sys::Path& input,
const sys::Path& output, const sys::Path& output,
Phases phase) Phases phase)
{ {
@ -243,7 +243,7 @@ private:
// Get specific options for each kind of action type // Get specific options for each kind of action type
StringVector& addargs = AdditionalArgs[phase]; StringVector& addargs = AdditionalArgs[phase];
// Add specific options for each kind of action type // Add specific options for each kind of action type
action->args.insert(action->args.end(), addargs.begin(), action->args.insert(action->args.end(), addargs.begin(),
addargs.end()); addargs.end());
} }
} else } else
@ -263,7 +263,7 @@ private:
case 'f': case 'f':
if (*PI == "%fOpts%") { if (*PI == "%fOpts%") {
if (!fOptions.empty()) if (!fOptions.empty())
action->args.insert(action->args.end(), fOptions.begin(), action->args.insert(action->args.end(), fOptions.begin(),
fOptions.end()); fOptions.end());
} else } else
found = false; found = false;
@ -297,13 +297,13 @@ private:
action->args.push_back(output.toString()); action->args.push_back(output.toString());
} else if (*PI == "%opt%") { } else if (*PI == "%opt%") {
if (!isSet(EMIT_RAW_FLAG)) { if (!isSet(EMIT_RAW_FLAG)) {
if (cd->opts.size() > static_cast<unsigned>(optLevel) && if (cd->opts.size() > static_cast<unsigned>(optLevel) &&
!cd->opts[optLevel].empty()) !cd->opts[optLevel].empty())
action->args.insert(action->args.end(), action->args.insert(action->args.end(),
cd->opts[optLevel].begin(), cd->opts[optLevel].begin(),
cd->opts[optLevel].end()); cd->opts[optLevel].end());
else else
throw std::string("Optimization options for level ") + throw std::string("Optimization options for level ") +
utostr(unsigned(optLevel)) + " were not specified"; utostr(unsigned(optLevel)) + " were not specified";
} }
} else } else
@ -335,7 +335,7 @@ private:
case 'M': case 'M':
if (*PI == "%Mopts%") { if (*PI == "%Mopts%") {
if (!MOptions.empty()) if (!MOptions.empty())
action->args.insert(action->args.end(), MOptions.begin(), action->args.insert(action->args.end(), MOptions.begin(),
MOptions.end()); MOptions.end());
} else } else
found = false; found = false;
@ -355,7 +355,7 @@ private:
} }
if (!found) { if (!found) {
// Did it even look like a substitution? // Did it even look like a substitution?
if (PI->length()>1 && (*PI)[0] == '%' && if (PI->length()>1 && (*PI)[0] == '%' &&
(*PI)[PI->length()-1] == '%') { (*PI)[PI->length()-1] == '%') {
throw std::string("Invalid substitution token: '") + *PI + throw std::string("Invalid substitution token: '") + *PI +
"' for command '" + pat->program.toString() + "'"; "' for command '" + pat->program.toString() + "'";
@ -392,7 +392,7 @@ private:
"' is not executable."); "' is not executable.");
// Invoke the program // Invoke the program
const char** Args = (const char**) const char** Args = (const char**)
alloca(sizeof(const char*)*(action->args.size()+2)); alloca(sizeof(const char*)*(action->args.size()+2));
Args[0] = action->program.toString().c_str(); Args[0] = action->program.toString().c_str();
for (unsigned i = 1; i != action->args.size(); ++i) for (unsigned i = 1; i != action->args.size(); ++i)
@ -421,7 +421,7 @@ private:
fullpath.setFile(link_item); fullpath.setFile(link_item);
if (fullpath.readable()) if (fullpath.readable())
return fullpath; return fullpath;
for (PathVector::iterator PI = LibraryPaths.begin(), for (PathVector::iterator PI = LibraryPaths.begin(),
PE = LibraryPaths.end(); PI != PE; ++PI) { PE = LibraryPaths.end(); PI != PE; ++PI) {
fullpath.setDirectory(PI->toString()); fullpath.setDirectory(PI->toString());
fullpath.appendFile(link_item); fullpath.appendFile(link_item);
@ -431,11 +431,11 @@ private:
fullpath.appendSuffix("a"); fullpath.appendSuffix("a");
} else { } else {
fullpath.appendSuffix("bc"); fullpath.appendSuffix("bc");
if (fullpath.readable()) if (fullpath.readable())
return fullpath; return fullpath;
fullpath.elideSuffix(); fullpath.elideSuffix();
fullpath.appendSuffix("o"); fullpath.appendSuffix("o");
if (fullpath.readable()) if (fullpath.readable())
return fullpath; return fullpath;
fullpath = *PI; fullpath = *PI;
fullpath.appendFile(std::string("lib") + link_item); fullpath.appendFile(std::string("lib") + link_item);
@ -472,7 +472,7 @@ private:
// If we didn't find the file in any of the library search paths // If we didn't find the file in any of the library search paths
// we have to bail. No where else to look. // we have to bail. No where else to look.
if (fullpath.isEmpty()) { if (fullpath.isEmpty()) {
err = err =
std::string("Can't find linkage item '") + link_item.toString() + "'"; std::string("Can't find linkage item '") + link_item.toString() + "'";
return false; return false;
} }
@ -494,7 +494,7 @@ private:
while ( LI != LE ) { while ( LI != LE ) {
if (!ProcessLinkageItem(sys::Path(*LI),set,err)) { if (!ProcessLinkageItem(sys::Path(*LI),set,err)) {
if (err.empty()) { if (err.empty()) {
err = std::string("Library '") + *LI + err = std::string("Library '") + *LI +
"' is not valid for linking but is required by file '" + "' is not valid for linking but is required by file '" +
fullpath.toString() + "'"; fullpath.toString() + "'";
} else { } else {
@ -506,7 +506,7 @@ private:
} }
} else if (err.empty()) { } else if (err.empty()) {
err = std::string( err = std::string(
"The dependent libraries could not be extracted from '") + "The dependent libraries could not be extracted from '") +
fullpath.toString(); fullpath.toString();
return false; return false;
} }
@ -534,7 +534,7 @@ public:
std::cerr << "OutputMachine = " << machine << "\n"; std::cerr << "OutputMachine = " << machine << "\n";
InputList::const_iterator I = InpList.begin(); InputList::const_iterator I = InpList.begin();
while ( I != InpList.end() ) { while ( I != InpList.end() ) {
std::cerr << "Input: " << I->first << "(" << I->second std::cerr << "Input: " << I->first << "(" << I->second
<< ")\n"; << ")\n";
++I; ++I;
} }
@ -571,11 +571,11 @@ public:
// Get the suffix of the file name // Get the suffix of the file name
const std::string& ftype = I->second; const std::string& ftype = I->second;
// If its a library, bytecode file, or object file, save // If its a library, bytecode file, or object file, save
// it for linking below and short circuit the // it for linking below and short circuit the
// pre-processing/translation/assembly phases // pre-processing/translation/assembly phases
if (ftype.empty() || ftype == "o" || ftype == "bc" || ftype=="a") { if (ftype.empty() || ftype == "o" || ftype == "bc" || ftype=="a") {
// We shouldn't get any of these types of files unless we're // We shouldn't get any of these types of files unless we're
// later going to link. Enforce this limit now. // later going to link. Enforce this limit now.
if (finalPhase != LINKING) { if (finalPhase != LINKING) {
throw std::string( throw std::string(
@ -593,8 +593,8 @@ public:
// for this kind of file. // for this kind of file.
ConfigData* cd = cdp->ProvideConfigData(I->second); ConfigData* cd = cdp->ProvideConfigData(I->second);
if (cd == 0) if (cd == 0)
throw std::string("Files of type '") + I->second + throw std::string("Files of type '") + I->second +
"' are not recognized."; "' are not recognized.";
if (isSet(DEBUG_FLAG)) if (isSet(DEBUG_FLAG))
DumpConfigData(cd,I->second); DumpConfigData(cd,I->second);
@ -631,11 +631,11 @@ public:
} else if (finalPhase == PREPROCESSING) { } else if (finalPhase == PREPROCESSING) {
throw cd->langName + " does not support pre-processing"; throw cd->langName + " does not support pre-processing";
} else if (action.isSet(REQUIRED_FLAG)) { } else if (action.isSet(REQUIRED_FLAG)) {
throw std::string("Don't know how to pre-process ") + throw std::string("Don't know how to pre-process ") +
cd->langName + " files"; cd->langName + " files";
} }
// Short-circuit remaining actions if all they want is // Short-circuit remaining actions if all they want is
// pre-processing // pre-processing
if (finalPhase == PREPROCESSING) { continue; }; if (finalPhase == PREPROCESSING) { continue; };
@ -653,7 +653,7 @@ public:
actions.push_back(GetAction(cd,InFile,Output,TRANSLATION)); actions.push_back(GetAction(cd,InFile,Output,TRANSLATION));
} }
} else { } else {
sys::Path TempFile(MakeTempFile(I->first.getBasename(),"trans")); sys::Path TempFile(MakeTempFile(I->first.getBasename(),"trans"));
actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION)); actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION));
InFile = TempFile; InFile = TempFile;
} }
@ -674,7 +674,7 @@ public:
} else if (finalPhase == TRANSLATION) { } else if (finalPhase == TRANSLATION) {
throw cd->langName + " does not support translation"; throw cd->langName + " does not support translation";
} else if (action.isSet(REQUIRED_FLAG)) { } else if (action.isSet(REQUIRED_FLAG)) {
throw std::string("Don't know how to translate ") + throw std::string("Don't know how to translate ") +
cd->langName + " files"; cd->langName + " files";
} }
@ -717,7 +717,7 @@ public:
} else if (finalPhase == OPTIMIZATION) { } else if (finalPhase == OPTIMIZATION) {
throw cd->langName + " does not support optimization"; throw cd->langName + " does not support optimization";
} else if (action.isSet(REQUIRED_FLAG)) { } else if (action.isSet(REQUIRED_FLAG)) {
throw std::string("Don't know how to optimize ") + throw std::string("Don't know how to optimize ") +
cd->langName + " files"; cd->langName + " files";
} }
} }
@ -762,7 +762,7 @@ public:
// Put the action on the list // Put the action on the list
actions.push_back(action); actions.push_back(action);
// Short circuit the rest of the loop, we don't want to link // Short circuit the rest of the loop, we don't want to link
continue; continue;
} }
@ -816,7 +816,7 @@ public:
// Add in all the linkage items we generated. This includes the // Add in all the linkage items we generated. This includes the
// output from the translation/optimization phases as well as any // output from the translation/optimization phases as well as any
// -l arguments specified. // -l arguments specified.
for (PathVector::const_iterator I=LinkageItems.begin(), for (PathVector::const_iterator I=LinkageItems.begin(),
E=LinkageItems.end(); I != E; ++I ) E=LinkageItems.end(); I != E; ++I )
link->args.push_back(I->toString()); link->args.push_back(I->toString());

View File

@ -1,10 +1,10 @@
//===- CompilerDriver.h - Compiler Driver -----------------------*- C++ -*-===// //===- CompilerDriver.h - Compiler Driver -----------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file declares the CompilerDriver class which implements the bulk of the // This file declares the CompilerDriver class which implements the bulk of the
@ -23,7 +23,7 @@ namespace llvm {
/// The driver's purpose is to make it easier for compiler writers and users /// The driver's purpose is to make it easier for compiler writers and users
/// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only /// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only
/// the interface of one program (llvmc). /// the interface of one program (llvmc).
/// ///
/// @see llvmc.cpp /// @see llvmc.cpp
/// @brief The interface to the LLVM Compiler Driver. /// @brief The interface to the LLVM Compiler Driver.
class CompilerDriver { class CompilerDriver {
@ -43,7 +43,7 @@ namespace llvm {
enum Phases { enum Phases {
PREPROCESSING, ///< Source language combining, filtering, substitution PREPROCESSING, ///< Source language combining, filtering, substitution
TRANSLATION, ///< Translate source -> LLVM bytecode/assembly TRANSLATION, ///< Translate source -> LLVM bytecode/assembly
OPTIMIZATION, ///< Optimize translation result OPTIMIZATION, ///< Optimize translation result
ASSEMBLY, ///< Convert program to executable ASSEMBLY, ///< Convert program to executable
LINKING, ///< Link bytecode and native code LINKING, ///< Link bytecode and native code
NUM_PHASES ///< Always last! NUM_PHASES ///< Always last!
@ -92,7 +92,7 @@ namespace llvm {
struct ConfigData { struct ConfigData {
ConfigData(); ConfigData();
std::string version; ///< The version number. std::string version; ///< The version number.
std::string langName; ///< The name of the source language std::string langName; ///< The name of the source language
StringTable opts; ///< The o10n options for each level StringTable opts; ///< The o10n options for each level
StringVector libpaths; ///< The library paths StringVector libpaths; ///< The library paths
Action PreProcessor; ///< PreProcessor command line Action PreProcessor; ///< PreProcessor command line
@ -105,7 +105,7 @@ namespace llvm {
/// This pure virtual interface class defines the interface between the /// This pure virtual interface class defines the interface between the
/// CompilerDriver and other software that provides ConfigData objects to /// CompilerDriver and other software that provides ConfigData objects to
/// it. The CompilerDriver must be configured to use an object of this /// it. The CompilerDriver must be configured to use an object of this
/// type so it can obtain the configuration data. /// type so it can obtain the configuration data.
/// @see setConfigDataProvider /// @see setConfigDataProvider
/// @brief Configuration Data Provider interface /// @brief Configuration Data Provider interface
class ConfigDataProvider { class ConfigDataProvider {
@ -116,7 +116,7 @@ namespace llvm {
/// These flags control various actions of the compiler driver. They are /// These flags control various actions of the compiler driver. They are
/// used by adding the needed flag values together and passing them to the /// used by adding the needed flag values together and passing them to the
/// compiler driver's setDriverFlags method. /// compiler driver's setDriverFlags method.
/// @see setDriverFlags /// @see setDriverFlags
/// @brief Driver specific flags /// @brief Driver specific flags
enum DriverFlags { enum DriverFlags {
@ -163,7 +163,7 @@ namespace llvm {
virtual void setOutputMachine(const std::string& machineName) = 0; virtual void setOutputMachine(const std::string& machineName) = 0;
/// @brief Set the options for a given phase. /// @brief Set the options for a given phase.
virtual void setPhaseArgs(Phases phase, const StringVector& opts) = 0; virtual void setPhaseArgs(Phases phase, const StringVector& opts) = 0;
/// @brief Set Library Paths /// @brief Set Library Paths
virtual void setIncludePaths(const StringVector& paths) = 0; virtual void setIncludePaths(const StringVector& paths) = 0;

View File

@ -1,10 +1,10 @@
//===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===// //===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file declares the types and data needed by ConfigLexer.l // This file declares the types and data needed by ConfigLexer.l
@ -37,7 +37,7 @@ class InputProvider {
} }
virtual ~InputProvider(); virtual ~InputProvider();
virtual unsigned read(char *buf, unsigned max_size) = 0; virtual unsigned read(char *buf, unsigned max_size) = 0;
virtual void error(const std::string& msg); virtual void error(const std::string& msg);
virtual void checkErrors(); virtual void checkErrors();
private: private:
@ -62,7 +62,7 @@ enum ConfigLexerTokens {
FOPTS_SUBST, ///< The substitution item %fOpts% FOPTS_SUBST, ///< The substitution item %fOpts%
IN_SUBST, ///< The substitution item %in% IN_SUBST, ///< The substitution item %in%
INCLS_SUBST, ///< The substitution item %incls% INCLS_SUBST, ///< The substitution item %incls%
INTEGER, ///< An integer INTEGER, ///< An integer
LANG, ///< The name "lang" (and variants) LANG, ///< The name "lang" (and variants)
LIBPATHS, ///< The name "libpaths" (and variants) LIBPATHS, ///< The name "libpaths" (and variants)
LIBS, ///< The name "libs" (and variants) LIBS, ///< The name "libs" (and variants)

View File

@ -1,10 +1,10 @@
//===- Configuration.cpp - Configuration Data Mgmt --------------*- C++ -*-===// //===- Configuration.cpp - Configuration Data Mgmt --------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file implements the parsing of configuration files for the LLVM Compiler // This file implements the parsing of configuration files for the LLVM Compiler
@ -34,7 +34,7 @@ namespace llvm {
InputProvider::~InputProvider() {} InputProvider::~InputProvider() {}
void InputProvider::error(const std::string& msg) { void InputProvider::error(const std::string& msg) {
std::cerr << name << ":" << ConfigLexerState.lineNum << ": Error: " << std::cerr << name << ":" << ConfigLexerState.lineNum << ": Error: " <<
msg << "\n"; msg << "\n";
errCount++; errCount++;
} }
@ -53,7 +53,7 @@ namespace {
class FileInputProvider : public InputProvider { class FileInputProvider : public InputProvider {
public: public:
FileInputProvider(const std::string & fname) FileInputProvider(const std::string & fname)
: InputProvider(fname) : InputProvider(fname)
, F(fname.c_str()) { , F(fname.c_str()) {
ConfigLexerInput = this; ConfigLexerInput = this;
} }
@ -71,7 +71,7 @@ namespace {
std::ifstream F; std::ifstream F;
}; };
cl::opt<bool> DumpTokens("dump-tokens", cl::Optional, cl::Hidden, cl::opt<bool> DumpTokens("dump-tokens", cl::Optional, cl::Hidden,
cl::init(false), cl::desc("Dump lexical tokens (debug use only).")); cl::init(false), cl::desc("Dump lexical tokens (debug use only)."));
struct Parser struct Parser
@ -90,14 +90,14 @@ namespace {
InputProvider* provider; InputProvider* provider;
CompilerDriver::ConfigData* confDat; CompilerDriver::ConfigData* confDat;
inline int next() { inline int next() {
token = Configlex(); token = Configlex();
if (DumpTokens) if (DumpTokens)
std::cerr << token << "\n"; std::cerr << token << "\n";
return token; return token;
} }
inline bool next_is_real() { inline bool next_is_real() {
next(); next();
return (token != EOLTOK) && (token != ERRORTOK) && (token != 0); return (token != EOLTOK) && (token != ERRORTOK) && (token != 0);
} }
@ -117,7 +117,7 @@ namespace {
while (next_is_real()) { while (next_is_real()) {
switch (token ) { switch (token ) {
case STRING : case STRING :
case OPTION : case OPTION :
result += ConfigLexerState.StringVal; result += ConfigLexerState.StringVal;
break; break;
case SEPARATOR: case SEPARATOR:
@ -229,27 +229,27 @@ namespace {
case LIBS: case LIBS:
parseLibs(); parseLibs();
break; break;
case NAME: case NAME:
confDat->langName = parseName(); confDat->langName = parseName();
break; break;
case OPT1: case OPT1:
parseOptionList(confDat->opts[CompilerDriver::OPT_FAST_COMPILE]); parseOptionList(confDat->opts[CompilerDriver::OPT_FAST_COMPILE]);
break; break;
case OPT2: case OPT2:
parseOptionList(confDat->opts[CompilerDriver::OPT_SIMPLE]); parseOptionList(confDat->opts[CompilerDriver::OPT_SIMPLE]);
break; break;
case OPT3: case OPT3:
parseOptionList(confDat->opts[CompilerDriver::OPT_AGGRESSIVE]); parseOptionList(confDat->opts[CompilerDriver::OPT_AGGRESSIVE]);
break; break;
case OPT4: case OPT4:
parseOptionList(confDat->opts[CompilerDriver::OPT_LINK_TIME]); parseOptionList(confDat->opts[CompilerDriver::OPT_LINK_TIME]);
break; break;
case OPT5: case OPT5:
parseOptionList( parseOptionList(
confDat->opts[CompilerDriver::OPT_AGGRESSIVE_LINK_TIME]); confDat->opts[CompilerDriver::OPT_AGGRESSIVE_LINK_TIME]);
break; break;
default: default:
error("Expecting 'name' or 'optN' after 'lang.'"); error("Expecting 'name' or 'optN' after 'lang.'");
break; break;
} }
} }
@ -295,7 +295,7 @@ namespace {
break; break;
} }
next(); next();
} while (token != SPACE && token != EOFTOK && token != EOLTOK && } while (token != SPACE && token != EOFTOK && token != EOLTOK &&
token != ERRORTOK); token != ERRORTOK);
return !str.empty(); return !str.empty();
} }
@ -312,7 +312,7 @@ namespace {
case SPACE: case SPACE:
next(); next();
/* FALL THROUGH */ /* FALL THROUGH */
default: default:
{ {
std::string progname; std::string progname;
if (parseProgramName(progname)) if (parseProgramName(progname))
@ -402,7 +402,7 @@ namespace {
if (next() != SEPARATOR) if (next() != SEPARATOR)
error("Expecting '.'"); error("Expecting '.'");
switch (next()) { switch (next()) {
case COMMAND: case COMMAND:
parseCommand(confDat->Translator); parseCommand(confDat->Translator);
break; break;
case REQUIRED: case REQUIRED:
@ -414,7 +414,7 @@ namespace {
case PREPROCESSES: case PREPROCESSES:
if (parseBoolean()) if (parseBoolean())
confDat->Translator.set(CompilerDriver::PREPROCESSES_FLAG); confDat->Translator.set(CompilerDriver::PREPROCESSES_FLAG);
else else
confDat->Translator.clear(CompilerDriver::PREPROCESSES_FLAG); confDat->Translator.clear(CompilerDriver::PREPROCESSES_FLAG);
break; break;
case OUTPUT: case OUTPUT:
@ -464,8 +464,8 @@ namespace {
confDat->Translator.clear(CompilerDriver::OUTPUT_IS_ASM_FLAG); confDat->Translator.clear(CompilerDriver::OUTPUT_IS_ASM_FLAG);
break; break;
default: default:
error(std::string("Expecting 'command', 'preprocesses', " error(std::string("Expecting 'command', 'preprocesses', "
"'translates' or 'output' but found '") + "'translates' or 'output' but found '") +
ConfigLexerState.StringVal + "' instead"); ConfigLexerState.StringVal + "' instead");
break; break;
} }
@ -509,7 +509,7 @@ namespace {
case LINKER: parseLinker(); break; case LINKER: parseLinker(); break;
case EOLTOK: break; // just ignore case EOLTOK: break; // just ignore
case ERRORTOK: case ERRORTOK:
default: default:
error("Invalid top level configuration item"); error("Invalid top level configuration item");
break; break;
} }
@ -548,7 +548,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
confFile.setDirectory(conf); confFile.setDirectory(conf);
confFile.appendFile(ftype); confFile.appendFile(ftype);
if (!confFile.readable()) if (!confFile.readable())
throw std::string("Configuration file for '") + ftype + throw std::string("Configuration file for '") + ftype +
"' is not available."; "' is not available.";
} else { } else {
// Try the user's home directory // Try the user's home directory
@ -569,7 +569,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
confFile = sys::Path::GetLLVMDefaultConfigDir(); confFile = sys::Path::GetLLVMDefaultConfigDir();
confFile.appendFile(ftype); confFile.appendFile(ftype);
if (!confFile.readable()) { if (!confFile.readable()) {
throw std::string("Configuration file for '") + ftype + throw std::string("Configuration file for '") + ftype +
"' is not available."; "' is not available.";
} }
} }
@ -579,12 +579,12 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
confFile = configDir; confFile = configDir;
confFile.appendFile(ftype); confFile.appendFile(ftype);
if (!confFile.readable()) if (!confFile.readable())
throw std::string("Configuration file for '") + ftype + throw std::string("Configuration file for '") + ftype +
"' is not available."; "' is not available.";
} }
FileInputProvider fip( confFile.toString() ); FileInputProvider fip( confFile.toString() );
if (!fip.okay()) { if (!fip.okay()) {
throw std::string("Configuration file for '") + ftype + throw std::string("Configuration file for '") + ftype +
"' is not available."; "' is not available.";
} }
result = new CompilerDriver::ConfigData(); result = new CompilerDriver::ConfigData();
@ -603,7 +603,7 @@ LLVMC_ConfigDataProvider::~LLVMC_ConfigDataProvider()
Configurations.clear(); Configurations.clear();
} }
CompilerDriver::ConfigData* CompilerDriver::ConfigData*
LLVMC_ConfigDataProvider::ProvideConfigData(const std::string& filetype) { LLVMC_ConfigDataProvider::ProvideConfigData(const std::string& filetype) {
CompilerDriver::ConfigData* result = 0; CompilerDriver::ConfigData* result = 0;
if (!Configurations.empty()) { if (!Configurations.empty()) {

View File

@ -1,10 +1,10 @@
//===- Configuration.h - Configuration Data Mgmt ----------------*- C++ -*-===// //===- Configuration.h - Configuration Data Mgmt ----------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file declares the LLVMC_ConfigDataProvider class which implements the // This file declares the LLVMC_ConfigDataProvider class which implements the
@ -22,7 +22,7 @@ namespace llvm {
/// The driver's purpose is to make it easier for compiler writers and users /// The driver's purpose is to make it easier for compiler writers and users
/// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only /// of LLVM to utilize the compiler toolkits and LLVM toolset by learning only
/// the interface of one program (llvmc). /// the interface of one program (llvmc).
/// ///
/// @see llvmc.cpp /// @see llvmc.cpp
/// @brief The interface to the LLVM Compiler Driver. /// @brief The interface to the LLVM Compiler Driver.
class LLVMC_ConfigDataProvider : public CompilerDriver::ConfigDataProvider { class LLVMC_ConfigDataProvider : public CompilerDriver::ConfigDataProvider {
@ -35,12 +35,12 @@ namespace llvm {
/// @{ /// @{
public: public:
/// @brief Provide the configuration data to the CompilerDriver. /// @brief Provide the configuration data to the CompilerDriver.
virtual CompilerDriver::ConfigData* virtual CompilerDriver::ConfigData*
ProvideConfigData(const std::string& filetype); ProvideConfigData(const std::string& filetype);
/// @brief Allow the configuration directory to be set /// @brief Allow the configuration directory to be set
virtual void setConfigDir(const sys::Path& dirName) { virtual void setConfigDir(const sys::Path& dirName) {
configDir = dirName; configDir = dirName;
} }
private: private:

View File

@ -1,17 +1,17 @@
//===--- llvmc.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// //===--- llvmc.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by Reid Spencer and is distributed under the // This file was developed by Reid Spencer and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details. // University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tool provides a single point of access to the LLVM compilation tools. // This tool provides a single point of access to the LLVM compilation tools.
// It has many options. To discover the options supported please refer to the // It has many options. To discover the options supported please refer to the
// tools' manual page (docs/CommandGuide/html/llvmc.html) or run the tool with // tools' manual page (docs/CommandGuide/html/llvmc.html) or run the tool with
// the --help option. // the --help option.
// //
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
#include "CompilerDriver.h" #include "CompilerDriver.h"
@ -28,7 +28,7 @@ namespace {
//=== PHASE OPTIONS //=== PHASE OPTIONS
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional, cl::opt<CompilerDriver::Phases> FinalPhase(cl::Optional,
cl::desc("Choose final phase of compilation:"), cl::desc("Choose final phase of compilation:"),
cl::init(CompilerDriver::LINKING), cl::init(CompilerDriver::LINKING),
cl::values( cl::values(
clEnumValN(CompilerDriver::PREPROCESSING,"E", clEnumValN(CompilerDriver::PREPROCESSING,"E",
@ -71,7 +71,7 @@ cl::opt<CompilerDriver::OptimizationLevels> OptLevel(cl::ZeroOrMore,
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
cl::list<std::string> PreprocessorToolOpts("Tpre", cl::ZeroOrMore, cl::list<std::string> PreprocessorToolOpts("Tpre", cl::ZeroOrMore,
cl::desc("Pass specific options to the pre-processor"), cl::desc("Pass specific options to the pre-processor"),
cl::value_desc("option")); cl::value_desc("option"));
cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore, cl::alias PreprocessorToolOptsAlias("Wp,", cl::ZeroOrMore,
@ -111,7 +111,7 @@ cl::list<std::string> WOpts("W", cl::ZeroOrMore, cl::Prefix,
cl::desc("Pass through -W options to compiler tools"), cl::desc("Pass through -W options to compiler tools"),
cl::value_desc("option")); cl::value_desc("option"));
cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix, cl::list<std::string> BOpt("B", cl::ZeroOrMore, cl::Prefix,
cl::desc("Specify path to find llvmc sub-tools"), cl::desc("Specify path to find llvmc sub-tools"),
cl::value_desc("dir")); cl::value_desc("dir"));
@ -126,7 +126,7 @@ cl::list<std::string> Libraries("l", cl::Prefix,
cl::desc("Specify base name of libraries to link to"), cl::value_desc("lib")); cl::desc("Specify base name of libraries to link to"), cl::value_desc("lib"));
cl::list<std::string> Includes("I", cl::Prefix, cl::list<std::string> Includes("I", cl::Prefix,
cl::desc("Specify location to search for included source"), cl::desc("Specify location to search for included source"),
cl::value_desc("dir")); cl::value_desc("dir"));
cl::list<std::string> Defines("D", cl::Prefix, cl::list<std::string> Defines("D", cl::Prefix,
@ -137,7 +137,7 @@ cl::list<std::string> Defines("D", cl::Prefix,
//=== OUTPUT OPTIONS //=== OUTPUT OPTIONS
//===------------------------------------------------------------------------=== //===------------------------------------------------------------------------===
cl::opt<std::string> OutputFilename("o", cl::opt<std::string> OutputFilename("o",
cl::desc("Override output filename"), cl::value_desc("file")); cl::desc("Override output filename"), cl::value_desc("file"));
cl::opt<std::string> OutputMachine("m", cl::Prefix, cl::opt<std::string> OutputMachine("m", cl::Prefix,
@ -169,10 +169,10 @@ cl::alias DryRunAlias("y", cl::Optional,
cl::opt<bool> Verbose("verbose", cl::Optional, cl::init(false), cl::opt<bool> Verbose("verbose", cl::Optional, cl::init(false),
cl::desc("Print out each action taken")); cl::desc("Print out each action taken"));
cl::alias VerboseAlias("v", cl::Optional, cl::alias VerboseAlias("v", cl::Optional,
cl::desc("Alias for -verbose"), cl::aliasopt(Verbose)); cl::desc("Alias for -verbose"), cl::aliasopt(Verbose));
cl::opt<bool> Debug("debug", cl::Optional, cl::init(false), cl::opt<bool> Debug("debug", cl::Optional, cl::init(false),
cl::Hidden, cl::desc("Print out debugging information")); cl::Hidden, cl::desc("Print out debugging information"));
cl::alias DebugAlias("d", cl::Optional, cl::alias DebugAlias("d", cl::Optional,
@ -258,7 +258,7 @@ int main(int argc, char **argv) {
try { try {
// Parse the command line options // Parse the command line options
cl::ParseCommandLineOptions(argc, argv, cl::ParseCommandLineOptions(argc, argv,
" LLVM Compiler Driver (llvmc)\n\n" " LLVM Compiler Driver (llvmc)\n\n"
" This program provides easy invocation of the LLVM tool set\n" " This program provides easy invocation of the LLVM tool set\n"
" and other compiler tools.\n" " and other compiler tools.\n"

View File

@ -1,10 +1,10 @@
//===- opt.cpp - The LLVM Modular Optimizer -------------------------------===// //===- opt.cpp - The LLVM Modular Optimizer -------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// Optimizations may be specified an arbitrary number of times on the command // Optimizations may be specified an arbitrary number of times on the command
@ -137,7 +137,7 @@ int main(int argc, char **argv) {
// Create a new optimization pass for each one specified on the command line // Create a new optimization pass for each one specified on the command line
for (unsigned i = 0; i < OptimizationList.size(); ++i) { for (unsigned i = 0; i < OptimizationList.size(); ++i) {
const PassInfo *Opt = OptimizationList[i]; const PassInfo *Opt = OptimizationList[i];
if (Opt->getNormalCtor()) if (Opt->getNormalCtor())
Passes.add(Opt->getNormalCtor()()); Passes.add(Opt->getNormalCtor()());
else if (Opt->getTargetCtor()) { else if (Opt->getTargetCtor()) {

View File

@ -1,10 +1,10 @@
//===- AsmWriterEmitter.cpp - Generate an assembly writer -----------------===// //===- AsmWriterEmitter.cpp - Generate an assembly writer -----------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is emits an assembly printer for the current target. // This tablegen backend is emits an assembly printer for the current target.
@ -64,7 +64,7 @@ namespace {
struct AsmWriterInst { struct AsmWriterInst {
std::vector<AsmWriterOperand> Operands; std::vector<AsmWriterOperand> Operands;
const CodeGenInstruction *CGI; const CodeGenInstruction *CGI;
AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant); AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant);
/// MatchesAllButOneOp - If this instruction is exactly identical to the /// MatchesAllButOneOp - If this instruction is exactly identical to the
@ -198,7 +198,7 @@ unsigned AsmWriterInst::MatchesAllButOneOp(const AsmWriterInst &Other)const{
if (Operands[i] != Other.Operands[i]) if (Operands[i] != Other.Operands[i])
if (MismatchOperand != ~0U) // Already have one mismatch? if (MismatchOperand != ~0U) // Already have one mismatch?
return ~1U; return ~1U;
else else
MismatchOperand = i; MismatchOperand = i;
} }
return MismatchOperand; return MismatchOperand;
@ -268,7 +268,7 @@ static void EmitInstructions(std::vector<AsmWriterInst> &Insts,
OpsToPrint.push_back(std::make_pair(Namespace+"::"+ OpsToPrint.push_back(std::make_pair(Namespace+"::"+
FirstInst.CGI->TheDef->getName(), FirstInst.CGI->TheDef->getName(),
FirstInst.Operands[i])); FirstInst.Operands[i]));
for (unsigned si = 0, e = SimilarInsts.size(); si != e; ++si) { for (unsigned si = 0, e = SimilarInsts.size(); si != e; ++si) {
AsmWriterInst &AWI = SimilarInsts[si]; AsmWriterInst &AWI = SimilarInsts[si];
OpsToPrint.push_back(std::make_pair(Namespace+"::"+ OpsToPrint.push_back(std::make_pair(Namespace+"::"+
@ -313,7 +313,7 @@ void AsmWriterEmitter::run(std::ostream &O) {
// If all of the instructions start with a constant string (a very very common // If all of the instructions start with a constant string (a very very common
// occurance), emit all of the constant strings as a big table lookup instead // occurance), emit all of the constant strings as a big table lookup instead
// of requiring a switch for them. // of requiring a switch for them.
bool AllStartWithString = true; bool AllStartWithString = true;
for (unsigned i = 0, e = Instructions.size(); i != e; ++i) for (unsigned i = 0, e = Instructions.size(); i != e; ++i)
@ -323,7 +323,7 @@ void AsmWriterEmitter::run(std::ostream &O) {
AllStartWithString = false; AllStartWithString = false;
break; break;
} }
if (AllStartWithString) { if (AllStartWithString) {
// Compute the CodeGenInstruction -> AsmWriterInst mapping. Note that not // Compute the CodeGenInstruction -> AsmWriterInst mapping. Note that not
// all machine instructions are necessarily being printed, so there may be // all machine instructions are necessarily being printed, so there may be
@ -361,7 +361,7 @@ void AsmWriterEmitter::run(std::ostream &O) {
O << " switch (MI->getOpcode()) {\n" O << " switch (MI->getOpcode()) {\n"
" default: return false;\n"; " default: return false;\n";
while (!Instructions.empty()) while (!Instructions.empty())
EmitInstructions(Instructions, O); EmitInstructions(Instructions, O);

View File

@ -1,10 +1,10 @@
//===- AsmWriterEmitter.h - Generate an assembly writer ---------*- C++ -*-===// //===- AsmWriterEmitter.h - Generate an assembly writer ---------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting an assembly printer for the // This tablegen backend is responsible for emitting an assembly printer for the
@ -23,7 +23,7 @@ namespace llvm {
RecordKeeper &Records; RecordKeeper &Records;
public: public:
AsmWriterEmitter(RecordKeeper &R) : Records(R) {} AsmWriterEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the asmwriter, returning true on failure. // run - Output the asmwriter, returning true on failure.
void run(std::ostream &o); void run(std::ostream &o);
}; };

View File

@ -1,10 +1,10 @@
//===- CodeEmitterGen.cpp - Code Emitter Generator ------------------------===// //===- CodeEmitterGen.cpp - Code Emitter Generator ------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// CodeEmitterGen uses the descriptions of instructions and their fields to // CodeEmitterGen uses the descriptions of instructions and their fields to
@ -112,7 +112,7 @@ void CodeEmitterGen::run(std::ostream &o) {
} }
BI = NewBI; BI = NewBI;
} }
unsigned Value = 0; unsigned Value = 0;
const std::vector<RecordVal> &Vals = R->getValues(); const std::vector<RecordVal> &Vals = R->getValues();
@ -130,16 +130,16 @@ void CodeEmitterGen::run(std::ostream &o) {
DEBUG(o << " // " << *R->getValue("Inst") << "\n"); DEBUG(o << " // " << *R->getValue("Inst") << "\n");
o << " Value = " << Value << "U;\n\n"; o << " Value = " << Value << "U;\n\n";
// Loop over all of the fields in the instruction, determining which are the // Loop over all of the fields in the instruction, determining which are the
// operands to the instruction. // operands to the instruction.
unsigned op = 0; unsigned op = 0;
std::map<std::string, unsigned> OpOrder; std::map<std::string, unsigned> OpOrder;
std::map<std::string, bool> OpContinuous; std::map<std::string, bool> OpContinuous;
for (unsigned i = 0, e = Vals.size(); i != e; ++i) { for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) { if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) {
// Is the operand continuous? If so, we can just mask and OR it in // Is the operand continuous? If so, we can just mask and OR it in
// instead of doing it bit-by-bit, saving a lot in runtime cost. // instead of doing it bit-by-bit, saving a lot in runtime cost.
BitsInit *InstInit = BI; BitsInit *InstInit = BI;
int beginBitInVar = -1, endBitInVar = -1; int beginBitInVar = -1, endBitInVar = -1;
int beginBitInInst = -1, endBitInInst = -1; int beginBitInInst = -1, endBitInInst = -1;
@ -197,20 +197,20 @@ void CodeEmitterGen::run(std::ostream &o) {
// this is not an operand!! // this is not an operand!!
if (beginBitInInst != -1) { if (beginBitInInst != -1) {
o << " // op" << op << ": " << Vals[i].getName() << "\n" o << " // op" << op << ": " << Vals[i].getName() << "\n"
<< " int64_t op" << op << " int64_t op" << op
<<" = getMachineOpValue(MI, MI.getOperand("<<op<<"));\n"; <<" = getMachineOpValue(MI, MI.getOperand("<<op<<"));\n";
//<< " MachineOperand &op" << op <<" = MI.getOperand("<<op<<");\n"; //<< " MachineOperand &op" << op <<" = MI.getOperand("<<op<<");\n";
OpOrder[Vals[i].getName()] = op++; OpOrder[Vals[i].getName()] = op++;
DEBUG(o << " // Var: begin = " << beginBitInVar DEBUG(o << " // Var: begin = " << beginBitInVar
<< ", end = " << endBitInVar << ", end = " << endBitInVar
<< "; Inst: begin = " << beginBitInInst << "; Inst: begin = " << beginBitInInst
<< ", end = " << endBitInInst << "\n"); << ", end = " << endBitInInst << "\n");
if (continuous) { if (continuous) {
DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()] DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()]
<< "\n"); << "\n");
// Mask off the right bits // Mask off the right bits
// Low mask (ie. shift, if necessary) // Low mask (ie. shift, if necessary)
assert(endBitInVar >= 0 && "Negative shift amount in masking!"); assert(endBitInVar >= 0 && "Negative shift amount in masking!");
@ -220,21 +220,21 @@ void CodeEmitterGen::run(std::ostream &o) {
beginBitInVar -= endBitInVar; beginBitInVar -= endBitInVar;
endBitInVar = 0; endBitInVar = 0;
} }
// High mask // High mask
o << " op" << OpOrder[Vals[i].getName()] o << " op" << OpOrder[Vals[i].getName()]
<< " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; << " &= (1<<" << beginBitInVar+1 << ") - 1;\n";
// Shift the value to the correct place (according to place in inst) // Shift the value to the correct place (according to place in inst)
assert(endBitInInst >= 0 && "Negative shift amount!"); assert(endBitInInst >= 0 && "Negative shift amount!");
if (endBitInInst != 0) if (endBitInInst != 0)
o << " op" << OpOrder[Vals[i].getName()] o << " op" << OpOrder[Vals[i].getName()]
<< " <<= " << endBitInInst << ";\n"; << " <<= " << endBitInInst << ";\n";
// Just OR in the result // Just OR in the result
o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n"; o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n";
} }
// otherwise, will be taken care of in the loop below using this // otherwise, will be taken care of in the loop below using this
// value: // value:
OpContinuous[Vals[i].getName()] = continuous; OpContinuous[Vals[i].getName()] = continuous;

View File

@ -1,10 +1,10 @@
//===- CodeEmitterGen.h - Code Emitter Generator ----------------*- C++ -*-===// //===- CodeEmitterGen.h - Code Emitter Generator ----------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// FIXME: document // FIXME: document
@ -26,7 +26,7 @@ class CodeEmitterGen : public TableGenBackend {
RecordKeeper &Records; RecordKeeper &Records;
public: public:
CodeEmitterGen(RecordKeeper &R) : Records(R) {} CodeEmitterGen(RecordKeeper &R) : Records(R) {}
// run - Output the code emitter // run - Output the code emitter
void run(std::ostream &o); void run(std::ostream &o);
private: private:

View File

@ -1,10 +1,10 @@
//===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===// //===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines a wrapper class for the 'Instruction' TableGen class. // This file defines a wrapper class for the 'Instruction' TableGen class.
@ -61,7 +61,7 @@ namespace llvm {
const std::string &PMN, unsigned MION) const std::string &PMN, unsigned MION)
: Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION) {} : Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION) {}
}; };
/// OperandList - The list of declared operands, along with their declared /// OperandList - The list of declared operands, along with their declared
/// type (which is a record). /// type (which is a record).
std::vector<OperandInfo> OperandList; std::vector<OperandInfo> OperandList;

View File

@ -1,10 +1,10 @@
//===- CodeGenRegisters.h - Register and RegisterClass Info -----*- C++ -*-===// //===- CodeGenRegisters.h - Register and RegisterClass Info -----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines structures to encapsulate information gleaned from the // This file defines structures to encapsulate information gleaned from the

View File

@ -1,10 +1,10 @@
//===- CodeGenTarget.cpp - CodeGen Target Class Wrapper ---------*- C++ -*-===// //===- CodeGenTarget.cpp - CodeGen Target Class Wrapper ---------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This class wrap target description classes used by the various code // This class wrap target description classes used by the various code
@ -77,7 +77,7 @@ std::ostream &llvm::operator<<(std::ostream &OS, MVT::ValueType T) {
CodeGenTarget::CodeGenTarget() : PointerType(MVT::Other) { CodeGenTarget::CodeGenTarget() : PointerType(MVT::Other) {
std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target"); std::vector<Record*> Targets = Records.getAllDerivedDefinitions("Target");
if (Targets.size() == 0) if (Targets.size() == 0)
throw std::string("ERROR: No 'Target' subclasses defined!"); throw std::string("ERROR: No 'Target' subclasses defined!");
if (Targets.size() != 1) if (Targets.size() != 1)
throw std::string("ERROR: Multiple subclasses of Target defined!"); throw std::string("ERROR: Multiple subclasses of Target defined!");
TargetRec = Targets[0]; TargetRec = Targets[0];
@ -155,7 +155,7 @@ CodeGenRegisterClass::CodeGenRegisterClass(Record *R) : TheDef(R) {
ListInit *RegList = R->getValueAsListInit("MemberList"); ListInit *RegList = R->getValueAsListInit("MemberList");
for (unsigned i = 0, e = RegList->getSize(); i != e; ++i) { for (unsigned i = 0, e = RegList->getSize(); i != e; ++i) {
DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i)); DefInit *RegDef = dynamic_cast<DefInit*>(RegList->getElement(i));
if (!RegDef) throw "Register class member is not a record!"; if (!RegDef) throw "Register class member is not a record!";
Record *Reg = RegDef->getDef(); Record *Reg = RegDef->getDef();
if (!Reg->isSubClassOf("Register")) if (!Reg->isSubClassOf("Register"))
@ -257,7 +257,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
} else } else
throw "Unknown operand class '" + Rec->getName() + throw "Unknown operand class '" + Rec->getName() +
"' in instruction '" + R->getName() + "' instruction!"; "' in instruction '" + R->getName() + "' instruction!";
OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i), OperandList.push_back(OperandInfo(Rec, Ty, DI->getArgName(i),
PrintMethod, MIOperandNo)); PrintMethod, MIOperandNo));
MIOperandNo += NumOps; MIOperandNo += NumOps;

View File

@ -1,10 +1,10 @@
//===- CodeGenTarget.h - Target Class Wrapper -------------------*- C++ -*-===// //===- CodeGenTarget.h - Target Class Wrapper -------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines wrappers for the Target class and related global // This file defines wrappers for the Target class and related global

View File

@ -1,10 +1,10 @@
//===- InstrInfoEmitter.cpp - Generate a Instruction Set Desc. ------------===// //===- InstrInfoEmitter.cpp - Generate a Instruction Set Desc. ------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting a description of the target // This tablegen backend is responsible for emitting a description of the target
@ -135,13 +135,13 @@ void InstrInfoEmitter::emitRecord(const CodeGenInstruction &Inst, unsigned Num,
LI = Inst.TheDef->getValueAsListInit("Uses"); LI = Inst.TheDef->getValueAsListInit("Uses");
if (!LI->getSize()) if (!LI->getSize())
OS << "EmptyImpUses, "; OS << "EmptyImpUses, ";
else else
OS << Inst.TheDef->getName() << "ImpUses, "; OS << Inst.TheDef->getName() << "ImpUses, ";
LI = Inst.TheDef->getValueAsListInit("Defs"); LI = Inst.TheDef->getValueAsListInit("Defs");
if (!LI->getSize()) if (!LI->getSize())
OS << "EmptyImpDefs "; OS << "EmptyImpDefs ";
else else
OS << Inst.TheDef->getName() << "ImpDefs "; OS << Inst.TheDef->getName() << "ImpDefs ";
OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n"; OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n";

View File

@ -1,10 +1,10 @@
//===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===// //===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting a description of the target // This tablegen backend is responsible for emitting a description of the target
@ -28,7 +28,7 @@ class InstrInfoEmitter : public TableGenBackend {
RecordKeeper &Records; RecordKeeper &Records;
public: public:
InstrInfoEmitter(RecordKeeper &R) : Records(R) {} InstrInfoEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the instruction set description, returning true on failure. // run - Output the instruction set description, returning true on failure.
void run(std::ostream &OS); void run(std::ostream &OS);

View File

@ -1,10 +1,10 @@
//===- InstrInfoEmitter.cpp - Generate a Instruction Set Desc. ------------===// //===- InstrInfoEmitter.cpp - Generate a Instruction Set Desc. ------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting a description of the target // This tablegen backend is responsible for emitting a description of the target
@ -69,7 +69,7 @@ void TreePatternNode::InstantiateNonterminals(InstrSelectorEmitter &ISE) {
getChild(i)->InstantiateNonterminals(ISE); getChild(i)->InstantiateNonterminals(ISE);
return; return;
} }
// If this is a leaf, it might be a reference to a nonterminal! Check now. // If this is a leaf, it might be a reference to a nonterminal! Check now.
Record *R = getValueRecord(); Record *R = getValueRecord();
if (R->isSubClassOf("Nonterminal")) { if (R->isSubClassOf("Nonterminal")) {
@ -78,7 +78,7 @@ void TreePatternNode::InstantiateNonterminals(InstrSelectorEmitter &ISE) {
// We found an unresolved nonterminal reference. Ask the ISE to clone // We found an unresolved nonterminal reference. Ask the ISE to clone
// it for us, then update our reference to the fresh, new, resolved, // it for us, then update our reference to the fresh, new, resolved,
// nonterminal. // nonterminal.
Value = new DefInit(ISE.InstantiateNonterminal(NT, getType())); Value = new DefInit(ISE.InstantiateNonterminal(NT, getType()));
} }
} }
@ -107,12 +107,12 @@ std::ostream &llvm::operator<<(std::ostream &OS, const TreePatternNode &N) {
return OS << N.getType() << ":" << *N.getValue(); return OS << N.getType() << ":" << *N.getValue();
OS << "(" << N.getType() << ":"; OS << "(" << N.getType() << ":";
OS << N.getOperator()->getName(); OS << N.getOperator()->getName();
if (N.getNumChildren() != 0) { if (N.getNumChildren() != 0) {
OS << " " << *N.getChild(0); OS << " " << *N.getChild(0);
for (unsigned i = 1, e = N.getNumChildren(); i != e; ++i) for (unsigned i = 1, e = N.getNumChildren(); i != e; ++i)
OS << ", " << *N.getChild(i); OS << ", " << *N.getChild(i);
} }
return OS << ")"; return OS << ")";
} }
@ -162,7 +162,7 @@ void Pattern::error(const std::string &Msg) const {
case Instruction: M += "instruction "; break; case Instruction: M += "instruction "; break;
case Expander : M += "expander "; break; case Expander : M += "expander "; break;
} }
throw M + TheRecord->getName() + ": " + Msg; throw M + TheRecord->getName() + ": " + Msg;
} }
/// calculateArgs - Compute the list of all of the arguments to this pattern, /// calculateArgs - Compute the list of all of the arguments to this pattern,
@ -205,7 +205,7 @@ TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
// node. // node.
if (Dag->getNumArgs() != 1) if (Dag->getNumArgs() != 1)
error("Type cast only valid for a leaf node!"); error("Type cast only valid for a leaf node!");
Init *Arg = Dag->getArg(0); Init *Arg = Dag->getArg(0);
TreePatternNode *New; TreePatternNode *New;
if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) { if (DefInit *DI = dynamic_cast<DefInit*>(Arg)) {
@ -229,7 +229,7 @@ TreePatternNode *Pattern::ParseTreePattern(DagInit *Dag) {
error("Unrecognized node '" + Operator->getName() + "'!"); error("Unrecognized node '" + Operator->getName() + "'!");
std::vector<std::pair<TreePatternNode*, std::string> > Children; std::vector<std::pair<TreePatternNode*, std::string> > Children;
for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) { for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
Init *Arg = Dag->getArg(i); Init *Arg = Dag->getArg(i);
if (DagInit *DI = dynamic_cast<DagInit*>(Arg)) { if (DagInit *DI = dynamic_cast<DagInit*>(Arg)) {
@ -442,7 +442,7 @@ void InstrSelectorEmitter::ReadNodeTypes() {
DEBUG(std::cerr << "Getting node types: "); DEBUG(std::cerr << "Getting node types: ");
for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
Record *Node = Nodes[i]; Record *Node = Nodes[i];
// Translate the return type... // Translate the return type...
NodeType::ArgResultTypes RetTy = NodeType::ArgResultTypes RetTy =
NodeType::Translate(Node->getValueAsDef("RetType")); NodeType::Translate(Node->getValueAsDef("RetType"));
@ -545,7 +545,7 @@ Record *InstrSelectorEmitter::InstantiateNonterminal(Pattern *NT,
// Check to see if we have already instantiated this pair... // Check to see if we have already instantiated this pair...
Record* &Slot = InstantiatedNTs[std::make_pair(NT, ResultTy)]; Record* &Slot = InstantiatedNTs[std::make_pair(NT, ResultTy)];
if (Slot) return Slot; if (Slot) return Slot;
Record *New = new Record(NT->getRecord()->getName()+"_"+getName(ResultTy)); Record *New = new Record(NT->getRecord()->getName()+"_"+getName(ResultTy));
// Copy over the superclasses... // Copy over the superclasses...
@ -685,7 +685,7 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
unsigned IndentAmt) { unsigned IndentAmt) {
assert(!Patterns.empty() && "No patterns to emit matchers for!"); assert(!Patterns.empty() && "No patterns to emit matchers for!");
std::string Indent(IndentAmt, ' '); std::string Indent(IndentAmt, ' ');
// Load all of the operands of the root node into scalars for fast access // Load all of the operands of the root node into scalars for fast access
const NodeType &ONT = getNodeType(Patterns[0].second->getOperator()); const NodeType &ONT = getNodeType(Patterns[0].second->getOperator());
for (unsigned i = 0, e = ONT.ArgTypes.size(); i != e; ++i) for (unsigned i = 0, e = ONT.ArgTypes.size(); i != e; ++i)
@ -719,7 +719,7 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
std::string LocCostName = VarPrefix + "_Cost"; std::string LocCostName = VarPrefix + "_Cost";
OS << Indent << "unsigned " << LocCostName << "Min = ~0U >> 1;\n" OS << Indent << "unsigned " << LocCostName << "Min = ~0U >> 1;\n"
<< Indent << "unsigned " << VarPrefix << "_PatternMin = NoMatchPattern;\n"; << Indent << "unsigned " << VarPrefix << "_PatternMin = NoMatchPattern;\n";
#if 0 #if 0
// Separate out all of the patterns into groups based on what their top-level // Separate out all of the patterns into groups based on what their top-level
// signature looks like... // signature looks like...
@ -789,7 +789,7 @@ void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
OS << Indent << " if (" << LocCostName << " < " << LocCostName << "Min) { " OS << Indent << " if (" << LocCostName << " < " << LocCostName << "Min) { "
<< LocCostName << "Min = " << LocCostName << "; " << VarPrefix << LocCostName << "Min = " << LocCostName << "; " << VarPrefix
<< "_PatternMin = " << VarPrefix << "_Pattern; }\n"; << "_PatternMin = " << VarPrefix << "_Pattern; }\n";
OS << Indent << "}\n"; OS << Indent << "}\n";
} }
#endif #endif
@ -938,7 +938,7 @@ void InstrSelectorEmitter::PrintExpanderOperand(Init *Arg,
P->error("Unknown operand type to expander!"); P->error("Unknown operand type to expander!");
} }
static std::string getArgName(Pattern *P, const std::string &ArgName, static std::string getArgName(Pattern *P, const std::string &ArgName,
const std::vector<std::pair<TreePatternNode*, std::string> > &Operands) { const std::vector<std::pair<TreePatternNode*, std::string> > &Operands) {
assert(P->getNumArgs() == Operands.size() &&"Argument computation mismatch!"); assert(P->getNumArgs() == Operands.size() &&"Argument computation mismatch!");
if (ArgName.empty()) return ""; if (ArgName.empty()) return "";
@ -957,7 +957,7 @@ static std::string getArgName(Pattern *P, const std::string &ArgName,
void InstrSelectorEmitter::run(std::ostream &OS) { void InstrSelectorEmitter::run(std::ostream &OS) {
// Type-check all of the node types to ensure we "understand" them. // Type-check all of the node types to ensure we "understand" them.
ReadNodeTypes(); ReadNodeTypes();
// Read in all of the nonterminals, instructions, and expanders... // Read in all of the nonterminals, instructions, and expanders...
ReadNonterminals(); ReadNonterminals();
ReadInstructionPatterns(); ReadInstructionPatterns();
@ -977,7 +977,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
DEBUG(std::cerr << " " << *I->second << "\n"); DEBUG(std::cerr << " " << *I->second << "\n");
CalculateComputableValues(); CalculateComputableValues();
OS << "#include \"llvm/CodeGen/MachineInstrBuilder.h\"\n"; OS << "#include \"llvm/CodeGen/MachineInstrBuilder.h\"\n";
EmitSourceFileHeader("Instruction Selector for the " + Target.getName() + EmitSourceFileHeader("Instruction Selector for the " + Target.getName() +
@ -1127,13 +1127,13 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
OS << getNodeName(Operator) << "(SelectionDAGNode *N) {\n" OS << getNodeName(Operator) << "(SelectionDAGNode *N) {\n"
<< " unsigned Pattern = NoMatchPattern;\n" << " unsigned Pattern = NoMatchPattern;\n"
<< " unsigned MinCost = ~0U >> 1;\n"; << " unsigned MinCost = ~0U >> 1;\n";
std::vector<std::pair<Pattern*, TreePatternNode*> > Patterns; std::vector<std::pair<Pattern*, TreePatternNode*> > Patterns;
for (unsigned i = 0, e = J->second.size(); i != e; ++i) for (unsigned i = 0, e = J->second.size(); i != e; ++i)
Patterns.push_back(std::make_pair(J->second[i], Patterns.push_back(std::make_pair(J->second[i],
J->second[i]->getTree())); J->second[i]->getTree()));
EmitMatchCosters(OS, Patterns, "N", 2); EmitMatchCosters(OS, Patterns, "N", 2);
OS << "\n N->setPatternCostFor(" << SlotName OS << "\n N->setPatternCostFor(" << SlotName
<< "_Slot, Pattern, MinCost, NumSlots);\n" << "_Slot, Pattern, MinCost, NumSlots);\n"
<< " return MinCost;\n" << " return MinCost;\n"
@ -1172,7 +1172,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
// Loop over the operands, reducing them... // Loop over the operands, reducing them...
std::vector<std::pair<TreePatternNode*, std::string> > Operands; std::vector<std::pair<TreePatternNode*, std::string> > Operands;
ReduceAllOperands(P->getTree(), "N", Operands, OS); ReduceAllOperands(P->getTree(), "N", Operands, OS);
// Now that we have reduced all of our operands, and have the values // Now that we have reduced all of our operands, and have the values
// that reduction produces, perform the reduction action for this // that reduction produces, perform the reduction action for this
// pattern. // pattern.
@ -1206,7 +1206,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
<< "->Val"; << "->Val";
}); });
DEBUG(OS << " << \"\\n\";\n"); DEBUG(OS << " << \"\\n\";\n");
// Generate the reduction code appropriate to the particular type of // Generate the reduction code appropriate to the particular type of
// pattern that this is... // pattern that this is...
switch (P->getPatternType()) { switch (P->getPatternType()) {
@ -1245,7 +1245,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
Pattern *InstPat = getPattern(InstRec); Pattern *InstPat = getPattern(InstRec);
if (!InstPat || InstPat->getPatternType() != Pattern::Instruction) if (!InstPat || InstPat->getPatternType() != Pattern::Instruction)
P->error("Instruction list must contain Instruction patterns!"); P->error("Instruction list must contain Instruction patterns!");
bool hasResult = InstPat->getResult() != 0; bool hasResult = InstPat->getResult() != 0;
if (InstPat->getNumArgs() != DIInst->getNumArgs()-hasResult) { if (InstPat->getNumArgs() != DIInst->getNumArgs()-hasResult) {
P->error("Incorrect number of arguments specified for inst '" + P->error("Incorrect number of arguments specified for inst '" +
@ -1286,8 +1286,8 @@ void InstrSelectorEmitter::run(std::ostream &OS) {
<< " break;\n" << " break;\n"
<< " }\n"; << " }\n";
} }
OS << " default: assert(0 && \"Unknown " << SlotName << " pattern!\");\n" OS << " default: assert(0 && \"Unknown " << SlotName << " pattern!\");\n"
<< " }\n\n N->addValue(Val); // Do not ever recalculate this\n" << " }\n\n N->addValue(Val); // Do not ever recalculate this\n"
<< " return Val;\n}\n\n"; << " return Val;\n}\n\n";

View File

@ -1,10 +1,10 @@
//===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===// //===- InstrInfoEmitter.h - Generate a Instruction Set Desc. ----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting a description of the target // This tablegen backend is responsible for emitting a description of the target
@ -147,7 +147,7 @@ private:
/// there was a (set) node on the outside level that it has been stripped off. /// there was a (set) node on the outside level that it has been stripped off.
/// ///
TreePatternNode *Tree; TreePatternNode *Tree;
/// Result - If this is an instruction or expander pattern, this is the /// Result - If this is an instruction or expander pattern, this is the
/// register result, specified with a (set) in the pattern. /// register result, specified with a (set) in the pattern.
/// ///
@ -195,7 +195,7 @@ public:
/// getTree - Return the tree pattern which corresponds to this pattern. /// getTree - Return the tree pattern which corresponds to this pattern.
/// ///
TreePatternNode *getTree() const { return Tree; } TreePatternNode *getTree() const { return Tree; }
Record *getResult() const { Record *getResult() const {
return ResultNode ? ResultNode->getValueRecord() : 0; return ResultNode ? ResultNode->getValueRecord() : 0;
} }
@ -319,7 +319,7 @@ class InstrSelectorEmitter : public TableGenBackend {
public: public:
InstrSelectorEmitter(RecordKeeper &R) : Records(R) {} InstrSelectorEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the instruction set description, returning true on failure. // run - Output the instruction set description, returning true on failure.
void run(std::ostream &OS); void run(std::ostream &OS);
@ -369,7 +369,7 @@ private:
// InstantiateNonterminals - Instantiate any unresolved nonterminals with // InstantiateNonterminals - Instantiate any unresolved nonterminals with
// information from the context that they are used in. // information from the context that they are used in.
void InstantiateNonterminals(); void InstantiateNonterminals();
// CalculateComputableValues - Fill in the ComputableValues map through // CalculateComputableValues - Fill in the ComputableValues map through
// analysis of the patterns we are playing with. // analysis of the patterns we are playing with.
void CalculateComputableValues(); void CalculateComputableValues();
@ -381,7 +381,7 @@ private:
void EmitMatchCosters(std::ostream &OS, void EmitMatchCosters(std::ostream &OS,
const std::vector<std::pair<Pattern*, TreePatternNode*> > &Patterns, const std::vector<std::pair<Pattern*, TreePatternNode*> > &Patterns,
const std::string &VarPrefix, unsigned Indent); const std::string &VarPrefix, unsigned Indent);
/// PrintExpanderOperand - Print out Arg as part of the instruction emission /// PrintExpanderOperand - Print out Arg as part of the instruction emission
/// process for the expander pattern P. This argument may be referencing some /// process for the expander pattern P. This argument may be referencing some
/// values defined in P, or may just be physical register references or /// values defined in P, or may just be physical register references or

View File

@ -1,10 +1,10 @@
//===- Record.cpp - Record implementation ---------------------------------===// //===- Record.cpp - Record implementation ---------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// //
@ -32,8 +32,8 @@ bool BitRecTy::baseClassOf(const BitsRecTy *RHS) const {
Init *BitRecTy::convertValue(IntInit *II) { Init *BitRecTy::convertValue(IntInit *II) {
int Val = II->getValue(); int Val = II->getValue();
if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit! if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit!
return new BitInit(Val != 0); return new BitInit(Val != 0);
} }
Init *BitRecTy::convertValue(TypedInit *VI) { Init *BitRecTy::convertValue(TypedInit *VI) {
@ -98,7 +98,7 @@ Init *BitsRecTy::convertValue(TypedInit *VI) {
Ret->setBit(0, VI); Ret->setBit(0, VI);
return Ret; return Ret;
} }
return 0; return 0;
} }
@ -108,7 +108,7 @@ Init *IntRecTy::convertValue(BitInit *BI) {
Init *IntRecTy::convertValue(BitsInit *BI) { Init *IntRecTy::convertValue(BitsInit *BI) {
int Result = 0; int Result = 0;
for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i)
if (BitInit *Bit = dynamic_cast<BitInit*>(BI->getBit(i))) { if (BitInit *Bit = dynamic_cast<BitInit*>(BI->getBit(i))) {
Result |= Bit->getValue() << i; Result |= Bit->getValue() << i;
} else { } else {
@ -230,7 +230,7 @@ void BitsInit::print(std::ostream &OS) const {
bool BitsInit::printInHex(std::ostream &OS) const { bool BitsInit::printInHex(std::ostream &OS) const {
// First, attempt to convert the value into an integer value... // First, attempt to convert the value into an integer value...
int Result = 0; int Result = 0;
for (unsigned i = 0, e = getNumBits(); i != e; ++i) for (unsigned i = 0, e = getNumBits(); i != e; ++i)
if (BitInit *Bit = dynamic_cast<BitInit*>(getBit(i))) { if (BitInit *Bit = dynamic_cast<BitInit*>(getBit(i))) {
Result |= Bit->getValue() << i; Result |= Bit->getValue() << i;
} else { } else {
@ -265,7 +265,7 @@ bool BitsInit::printAsVariable(std::ostream &OS) const {
} }
bool BitsInit::printAsUnset(std::ostream &OS) const { bool BitsInit::printAsUnset(std::ostream &OS) const {
for (unsigned i = 0, e = getNumBits(); i != e; ++i) for (unsigned i = 0, e = getNumBits(); i != e; ++i)
if (!dynamic_cast<UnsetInit*>(getBit(i))) if (!dynamic_cast<UnsetInit*>(getBit(i)))
return true; return true;
OS << "?"; OS << "?";
@ -406,7 +406,7 @@ Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,
assert(RV && "Reference to a non-existant variable?"); assert(RV && "Reference to a non-existant variable?");
assert(dynamic_cast<BitsInit*>(RV->getValue())); assert(dynamic_cast<BitsInit*>(RV->getValue()));
BitsInit *BI = (BitsInit*)RV->getValue(); BitsInit *BI = (BitsInit*)RV->getValue();
assert(Bit < BI->getNumBits() && "Bit reference out of range!"); assert(Bit < BI->getNumBits() && "Bit reference out of range!");
Init *B = BI->getBit(Bit); Init *B = BI->getBit(Bit);
@ -465,7 +465,7 @@ Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) {
return Val->getValue(); return Val->getValue();
return this; return this;
} }
Init *VarBitInit::resolveReferences(Record &R, const RecordVal *RV) { Init *VarBitInit::resolveReferences(Record &R, const RecordVal *RV) {
if (Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) if (Init *I = getVariable()->resolveBitReference(R, RV, getBitNum()))
@ -515,7 +515,7 @@ Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV,
if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) { if (BitsInit *BI = dynamic_cast<BitsInit*>(BitsVal)) {
assert(Bit < BI->getNumBits() && "Bit reference out of range!"); assert(Bit < BI->getNumBits() && "Bit reference out of range!");
Init *B = BI->getBit(Bit); Init *B = BI->getBit(Bit);
if (dynamic_cast<BitInit*>(B)) // If the bit is set... if (dynamic_cast<BitInit*>(B)) // If the bit is set...
return B; // Replace the VarBitInit with it. return B; // Replace the VarBitInit with it.
} }
@ -770,7 +770,7 @@ std::ostream &llvm::operator<<(std::ostream &OS, const RecordKeeper &RK) {
for (std::map<std::string, Record*>::const_iterator I = Classes.begin(), for (std::map<std::string, Record*>::const_iterator I = Classes.begin(),
E = Classes.end(); I != E; ++I) E = Classes.end(); I != E; ++I)
OS << "class " << *I->second; OS << "class " << *I->second;
OS << "------------- Defs -----------------\n"; OS << "------------- Defs -----------------\n";
const std::map<std::string, Record*> &Defs = RK.getDefs(); const std::map<std::string, Record*> &Defs = RK.getDefs();
for (std::map<std::string, Record*>::const_iterator I = Defs.begin(), for (std::map<std::string, Record*>::const_iterator I = Defs.begin(),

View File

@ -1,10 +1,10 @@
//===- Record.h - Classes to represent Table Records ------------*- C++ -*-===// //===- Record.h - Classes to represent Table Records ------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines the main TableGen data structures, including the TableGen // This file defines the main TableGen data structures, including the TableGen
@ -280,7 +280,7 @@ public:
virtual Init *convertValue( TypedInit *TI); virtual Init *convertValue( TypedInit *TI);
virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);}
virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);}
void print(std::ostream &OS) const; void print(std::ostream &OS) const;
bool typeIsConvertibleTo(const RecTy *RHS) const { bool typeIsConvertibleTo(const RecTy *RHS) const {
@ -292,7 +292,7 @@ public:
virtual bool baseClassOf(const IntRecTy *RHS) const { return false; } virtual bool baseClassOf(const IntRecTy *RHS) const { return false; }
virtual bool baseClassOf(const StringRecTy *RHS) const { return false; } virtual bool baseClassOf(const StringRecTy *RHS) const { return false; }
virtual bool baseClassOf(const ListRecTy *RHS) const { virtual bool baseClassOf(const ListRecTy *RHS) const {
return RHS->getElementType()->typeIsConvertibleTo(Ty); return RHS->getElementType()->typeIsConvertibleTo(Ty);
} }
virtual bool baseClassOf(const CodeRecTy *RHS) const { return false; } virtual bool baseClassOf(const CodeRecTy *RHS) const { return false; }
virtual bool baseClassOf(const DagRecTy *RHS) const { return false; } virtual bool baseClassOf(const DagRecTy *RHS) const { return false; }
@ -388,7 +388,7 @@ public:
virtual Init *convertValue(VarBitInit *VB) { return 0; } virtual Init *convertValue(VarBitInit *VB) { return 0; }
virtual Init *convertValue( DefInit *DI); virtual Init *convertValue( DefInit *DI);
virtual Init *convertValue( DagInit *DI) { return 0; } virtual Init *convertValue( DagInit *DI) { return 0; }
virtual Init *convertValue( TypedInit *VI); virtual Init *convertValue( TypedInit *VI);
virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);}
virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);}
@ -464,7 +464,7 @@ struct Init {
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const { virtual Init *getFieldInit(Record &R, const std::string &FieldName) const {
return 0; return 0;
} }
enum BinaryOp { SHL, SRA, SRL }; enum BinaryOp { SHL, SRA, SRL };
virtual Init *getBinaryOp(BinaryOp Op, Init *RHS) { virtual Init *getBinaryOp(BinaryOp Op, Init *RHS) {
return 0; return 0;
@ -645,7 +645,7 @@ public:
/// ///
class TypedInit : public Init { class TypedInit : public Init {
RecTy *Ty; RecTy *Ty;
public: public:
TypedInit(RecTy *T) : Ty(T) {} TypedInit(RecTy *T) : Ty(T) {}
RecTy *getType() const { return Ty; } RecTy *getType() const { return Ty; }
@ -673,7 +673,7 @@ class VarInit : public TypedInit {
std::string VarName; std::string VarName;
public: public:
VarInit(const std::string &VN, RecTy *T) : TypedInit(T), VarName(VN) {} VarInit(const std::string &VN, RecTy *T) : TypedInit(T), VarName(VN) {}
virtual Init *convertInitializerTo(RecTy *Ty) { virtual Init *convertInitializerTo(RecTy *Ty) {
return Ty->convertValue(this); return Ty->convertValue(this);
} }
@ -694,7 +694,7 @@ public:
/// users of the value to allow the value to propagate out. /// users of the value to allow the value to propagate out.
/// ///
virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual Init *resolveReferences(Record &R, const RecordVal *RV);
virtual void print(std::ostream &OS) const { OS << VarName; } virtual void print(std::ostream &OS) const { OS << VarName; }
}; };
@ -717,14 +717,14 @@ public:
TypedInit *getVariable() const { return TI; } TypedInit *getVariable() const { return TI; }
unsigned getBitNum() const { return Bit; } unsigned getBitNum() const { return Bit; }
virtual void print(std::ostream &OS) const { virtual void print(std::ostream &OS) const {
TI->print(OS); OS << "{" << Bit << "}"; TI->print(OS); OS << "{" << Bit << "}";
} }
virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual Init *resolveReferences(Record &R, const RecordVal *RV);
}; };
/// VarListElementInit - List[4] - Represent access to one element of a var or /// VarListElementInit - List[4] - Represent access to one element of a var or
/// field. /// field.
class VarListElementInit : public TypedInit { class VarListElementInit : public TypedInit {
TypedInit *TI; TypedInit *TI;
@ -765,7 +765,7 @@ class DefInit : public Init {
Record *Def; Record *Def;
public: public:
DefInit(Record *D) : Def(D) {} DefInit(Record *D) : Def(D) {}
virtual Init *convertInitializerTo(RecTy *Ty) { virtual Init *convertInitializerTo(RecTy *Ty) {
return Ty->convertValue(this); return Ty->convertValue(this);
} }
@ -776,7 +776,7 @@ public:
virtual RecTy *getFieldType(const std::string &FieldName) const; virtual RecTy *getFieldType(const std::string &FieldName) const;
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const; virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
virtual void print(std::ostream &OS) const; virtual void print(std::ostream &OS) const;
}; };
@ -826,7 +826,7 @@ public:
ArgNames.push_back(args[i].second); ArgNames.push_back(args[i].second);
} }
} }
virtual Init *convertInitializerTo(RecTy *Ty) { virtual Init *convertInitializerTo(RecTy *Ty) {
return Ty->convertValue(this); return Ty->convertValue(this);
} }
@ -1037,7 +1037,7 @@ public:
E = Defs.end(); I != E; ++I) E = Defs.end(); I != E; ++I)
delete I->second; delete I->second;
} }
const std::map<std::string, Record*> &getClasses() const { return Classes; } const std::map<std::string, Record*> &getClasses() const { return Classes; }
const std::map<std::string, Record*> &getDefs() const { return Defs; } const std::map<std::string, Record*> &getDefs() const { return Defs; }

View File

@ -1,10 +1,10 @@
//===- RegisterInfoEmitter.cpp - Generate a Register File Desc. -*- C++ -*-===// //===- RegisterInfoEmitter.cpp - Generate a Register File Desc. -*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting a description of a target // This tablegen backend is responsible for emitting a description of a target
@ -38,7 +38,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) {
for (unsigned i = 0, e = Registers.size(); i != e; ++i) for (unsigned i = 0, e = Registers.size(); i != e; ++i)
OS << " " << Registers[i].getName() << ", \t// " << i+1 << "\n"; OS << " " << Registers[i].getName() << ", \t// " << i+1 << "\n";
OS << " };\n"; OS << " };\n";
if (!Namespace.empty()) if (!Namespace.empty())
OS << "}\n"; OS << "}\n";
@ -162,11 +162,11 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
<< " specified multiple times!\n"; << " specified multiple times!\n";
RegisterAliases[Reg->getDef()].insert(R); RegisterAliases[Reg->getDef()].insert(R);
} }
} }
if (!RegisterAliases.empty()) if (!RegisterAliases.empty())
OS << "\n\n // Register Alias Sets...\n"; OS << "\n\n // Register Alias Sets...\n";
// Emit the empty alias list // Emit the empty alias list
OS << " const unsigned Empty_AliasSet[] = { 0 };\n"; OS << " const unsigned Empty_AliasSet[] = { 0 };\n";
// Loop over all of the registers which have aliases, emitting the alias list // Loop over all of the registers which have aliases, emitting the alias list
@ -223,7 +223,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
Reg.getName() + "'!"; Reg.getName() + "'!";
} }
OS << SpillSize << ", " << SpillAlign << " },\n"; OS << SpillSize << ", " << SpillAlign << " },\n";
} }
OS << " };\n"; // End of register descriptors... OS << " };\n"; // End of register descriptors...
OS << "}\n\n"; // End of anonymous namespace... OS << "}\n\n"; // End of anonymous namespace...
@ -240,21 +240,21 @@ void RegisterInfoEmitter::run(std::ostream &OS) {
std::string ClassName = Target.getName() + "GenRegisterInfo"; std::string ClassName = Target.getName() + "GenRegisterInfo";
// Emit the constructor of the class... // Emit the constructor of the class...
OS << ClassName << "::" << ClassName OS << ClassName << "::" << ClassName
<< "(int CallFrameSetupOpcode, int CallFrameDestroyOpcode)\n" << "(int CallFrameSetupOpcode, int CallFrameDestroyOpcode)\n"
<< " : MRegisterInfo(RegisterDescriptors, " << Registers.size()+1 << " : MRegisterInfo(RegisterDescriptors, " << Registers.size()+1
<< ", RegisterClasses, RegisterClasses+" << RegClassNames.size() << ",\n " << ", RegisterClasses, RegisterClasses+" << RegClassNames.size() << ",\n "
<< " CallFrameSetupOpcode, CallFrameDestroyOpcode) {}\n\n"; << " CallFrameSetupOpcode, CallFrameDestroyOpcode) {}\n\n";
// Emit the getCalleeSaveRegs method... // Emit the getCalleeSaveRegs method...
OS << "const unsigned* " << ClassName << "::getCalleeSaveRegs() const {\n" OS << "const unsigned* " << ClassName << "::getCalleeSaveRegs() const {\n"
<< " static const unsigned CalleeSaveRegs[] = {\n "; << " static const unsigned CalleeSaveRegs[] = {\n ";
const std::vector<Record*> &CSR = Target.getCalleeSavedRegisters(); const std::vector<Record*> &CSR = Target.getCalleeSavedRegisters();
for (unsigned i = 0, e = CSR.size(); i != e; ++i) for (unsigned i = 0, e = CSR.size(); i != e; ++i)
OS << getQualifiedName(CSR[i]) << ", "; OS << getQualifiedName(CSR[i]) << ", ";
OS << " 0\n };\n return CalleeSaveRegs;\n}\n\n"; OS << " 0\n };\n return CalleeSaveRegs;\n}\n\n";
OS << "} // End llvm namespace \n"; OS << "} // End llvm namespace \n";
} }

View File

@ -1,10 +1,10 @@
//===- RegisterInfoEmitter.h - Generate a Register File Desc. ---*- C++ -*-===// //===- RegisterInfoEmitter.h - Generate a Register File Desc. ---*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This tablegen backend is responsible for emitting a description of a target // This tablegen backend is responsible for emitting a description of a target
@ -24,7 +24,7 @@ class RegisterInfoEmitter : public TableGenBackend {
RecordKeeper &Records; RecordKeeper &Records;
public: public:
RegisterInfoEmitter(RecordKeeper &R) : Records(R) {} RegisterInfoEmitter(RecordKeeper &R) : Records(R) {}
// run - Output the register file description, returning true on failure. // run - Output the register file description, returning true on failure.
void run(std::ostream &o); void run(std::ostream &o);

View File

@ -1,10 +1,10 @@
//===- TableGen.cpp - Top-Level TableGen implementation -------------------===// //===- TableGen.cpp - Top-Level TableGen implementation -------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// TableGen is a tool which can be used to build up a description of something, // TableGen is a tool which can be used to build up a description of something,
@ -158,7 +158,7 @@ static void FindInstDifferences(Record *I1, Record *I2,
unsigned LastFixedBit = FirstVaryingBit; unsigned LastFixedBit = FirstVaryingBit;
while (LastFixedBit < MaxBits && BitsAreFixed(I1, I2, LastFixedBit)) while (LastFixedBit < MaxBits && BitsAreFixed(I1, I2, LastFixedBit))
++LastFixedBit; ++LastFixedBit;
if (FirstVaryingBit < FirstVaryingBitOverall) if (FirstVaryingBit < FirstVaryingBitOverall)
FirstVaryingBitOverall = FirstVaryingBit; FirstVaryingBitOverall = FirstVaryingBit;
if (LastFixedBit < LastFixedBitOverall) if (LastFixedBit < LastFixedBitOverall)
@ -187,7 +187,7 @@ struct BitComparator {
} }
}; };
static void PrintRange(std::vector<Record*>::iterator I, static void PrintRange(std::vector<Record*>::iterator I,
std::vector<Record*>::iterator E) { std::vector<Record*>::iterator E) {
while (I != E) std::cerr << **I++; while (I != E) std::cerr << **I++;
} }
@ -210,7 +210,7 @@ static unsigned getFirstFixedBitInSequence(std::vector<Record*>::iterator IB,
// instructions that we may have found. Eventually, this list will get pared // instructions that we may have found. Eventually, this list will get pared
// down to zero or one instruction, in which case we have a match or failure. // down to zero or one instruction, in which case we have a match or failure.
// //
static Record *ParseMachineCode(std::vector<Record*>::iterator InstsB, static Record *ParseMachineCode(std::vector<Record*>::iterator InstsB,
std::vector<Record*>::iterator InstsE, std::vector<Record*>::iterator InstsE,
unsigned char *M) { unsigned char *M) {
assert(InstsB != InstsE && "Empty range?"); assert(InstsB != InstsE && "Empty range?");
@ -269,7 +269,7 @@ static Record *ParseMachineCode(std::vector<Record*>::iterator InstsB,
while (RangeEnd != InstsE && while (RangeEnd != InstsE &&
BitRangesEqual(*RangeBegin, *RangeEnd, FirstVaryingBit, LastFixedBit)) BitRangesEqual(*RangeBegin, *RangeEnd, FirstVaryingBit, LastFixedBit))
++RangeEnd; ++RangeEnd;
// We just identified a range of equal instructions. If this range is the // We just identified a range of equal instructions. If this range is the
// input range, we were not able to distinguish between the instructions in // input range, we were not able to distinguish between the instructions in
// the set. Print an error and exit! // the set. Print an error and exit!
@ -279,7 +279,7 @@ static Record *ParseMachineCode(std::vector<Record*>::iterator InstsB,
PrintRange(InstsB, InstsE); PrintRange(InstsB, InstsE);
exit(1); exit(1);
} }
#if 0 #if 0
std::cerr << "FVB: " << FirstVaryingBit << " - " << LastFixedBit std::cerr << "FVB: " << FirstVaryingBit << " - " << LastFixedBit
<< ": [" << RangeEnd-RangeBegin << "] - "; << ": [" << RangeEnd-RangeBegin << "] - ";
@ -316,7 +316,7 @@ static void PrintValue(Record *I, unsigned char *Ptr, const RecordVal &Val) {
for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i)
if (BitInit *B = dynamic_cast<BitInit*>(BI->getBit(i))) if (BitInit *B = dynamic_cast<BitInit*>(BI->getBit(i)))
Value |= B->getValue() << i; Value |= B->getValue() << i;
// Loop over all of the fields in the instruction adding in any // Loop over all of the fields in the instruction adding in any
// contributions to this value (due to bit references). // contributions to this value (due to bit references).
// //
@ -330,7 +330,7 @@ static void PrintValue(Record *I, unsigned char *Ptr, const RecordVal &Val) {
Value |= getMemoryBit(Ptr, Offset+i) << i; Value |= getMemoryBit(Ptr, Offset+i) << i;
break; break;
} }
// Scan through the field looking for bit initializers of the current // Scan through the field looking for bit initializers of the current
// variable... // variable...
for (unsigned i = 0, e = FieldInitializer->getNumBits(); i != e; ++i) for (unsigned i = 0, e = FieldInitializer->getNumBits(); i != e; ++i)
@ -355,7 +355,7 @@ static void PrintInstruction(Record *I, unsigned char *Ptr) {
std::cout << "Inst " << getNumBits(I)/8 << " bytes: " std::cout << "Inst " << getNumBits(I)/8 << " bytes: "
<< "\t" << I->getName() << "\t" << *I->getValue("Name")->getValue() << "\t" << I->getName() << "\t" << *I->getValue("Name")->getValue()
<< "\t"; << "\t";
const std::vector<RecordVal> &Vals = I->getValues(); const std::vector<RecordVal> &Vals = I->getValues();
for (unsigned i = 0, e = Vals.size(); i != e; ++i) for (unsigned i = 0, e = Vals.size(); i != e; ++i)
if (!Vals[i].getValue()->isComplete()) { if (!Vals[i].getValue()->isComplete()) {
@ -363,7 +363,7 @@ static void PrintInstruction(Record *I, unsigned char *Ptr) {
PrintValue(I, Ptr, Vals[i]); PrintValue(I, Ptr, Vals[i]);
std::cout << "\t"; std::cout << "\t";
} }
std::cout << "\n";// << *I; std::cout << "\n";// << *I;
} }
@ -390,7 +390,7 @@ static void ParseMachineCode() {
#if 0 #if 0
// SparcV9 code // SparcV9 code
unsigned char Buffer[] = { 0xbf, 0xe0, 0x20, 0x1f, 0x1, 0x0, 0x0, 0x1, unsigned char Buffer[] = { 0xbf, 0xe0, 0x20, 0x1f, 0x1, 0x0, 0x0, 0x1,
0x0, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x20, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x20, 0x1, 0x1,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1,

View File

@ -1,10 +1,10 @@
//===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===// //===- TableGenBackend.cpp - Base class for TableGen Backends ---*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file provides useful services for TableGen backends... // This file provides useful services for TableGen backends...

View File

@ -1,10 +1,10 @@
//===- TableGenBackend.h - Base class for TableGen Backends -----*- C++ -*-===// //===- TableGenBackend.h - Base class for TableGen Backends -----*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// The TableGenBackend class is provided as a common interface for all TableGen // The TableGenBackend class is provided as a common interface for all TableGen

View File

@ -1,10 +1,10 @@
//===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===// //===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// fpcmp is a tool that basically works like the 'cmp' tool, except that it can // fpcmp is a tool that basically works like the 'cmp' tool, except that it can