#include "Support/Signals.h"
#include <memory>
#include <fstream>
#include "Support/Signals.h"
#include <memory>
#include <fstream>
-using std::string;
-using std::cerr;
//------------------------------------------------------------------------------
// Option declarations for LLC.
//------------------------------------------------------------------------------
// Option declarations for LLC.
// within the corresponding llc passes, and target-specific options
// and back-end code generation options are specified with the target machine.
//
// within the corresponding llc passes, and target-specific options
// and back-end code generation options are specified with the target machine.
//
+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>
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
static cl::opt<bool> Force("f", cl::desc("Overwrite output files"));
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
static cl::opt<bool> Force("f", cl::desc("Overwrite output files"));
DumpAsm("d", cl::desc("Print bytecode before native code generation"),
cl::Hidden);
DumpAsm("d", cl::desc("Print bytecode before native code generation"),
cl::Hidden);
+static cl::opt<std::string>
TraceLibPath("tracelibpath", cl::desc("Path to libinstr for trace code"),
cl::value_desc("directory"), cl::Hidden);
TraceLibPath("tracelibpath", cl::desc("Path to libinstr for trace code"),
cl::value_desc("directory"), cl::Hidden);
// GetFileNameRoot - Helper function to get the basename of a filename...
// GetFileNameRoot - Helper function to get the basename of a filename...
-static inline string
-GetFileNameRoot(const string &InputFilename)
+static inline std::string
+GetFileNameRoot(const std::string &InputFilename)
- string IFN = InputFilename;
- string outputFilename;
+ std::string IFN = InputFilename;
+ std::string outputFilename;
int Len = IFN.length();
if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
int Len = IFN.length();
if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') {
- outputFilename = string(IFN.begin(), IFN.end()-3); // s/.bc/.s/
+ outputFilename = std::string(IFN.begin(), IFN.end()-3); // s/.bc/.s/
} else {
outputFilename = IFN;
}
} else {
outputFilename = IFN;
}
// If we still didn't get it, cancel trying to link it in...
if (TraceModule == 0)
// If we still didn't get it, cancel trying to link it in...
if (TraceModule == 0)
- cerr << "Warning, could not load trace routines to link into program!\n";
+ std::cerr <<"WARNING: couldn't load trace routines to link into program!\n";
else
{
// Link in the trace routines... if this fails, don't panic, because the
else
{
// Link in the trace routines... if this fails, don't panic, because the
//
std::auto_ptr<Module> TraceRoutines(TraceModule);
if (LinkModules(&M, TraceRoutines.get(), &ErrorMessage))
//
std::auto_ptr<Module> TraceRoutines(TraceModule);
if (LinkModules(&M, TraceRoutines.get(), &ErrorMessage))
- cerr << "Warning: Error linking in trace routines: "
- << ErrorMessage << "\n";
+ std::cerr << "WARNING: Error linking in trace routines: "
+ << ErrorMessage << "\n";
}
// Write out the module with tracing code just before code generation
assert (InputFilename != "-"
&& "Cannot write out traced bytecode when reading input from stdin");
}
// Write out the module with tracing code just before code generation
assert (InputFilename != "-"
&& "Cannot write out traced bytecode when reading input from stdin");
- string TraceFilename = GetFileNameRoot(InputFilename) + ".trace.bc";
+ std::string TraceFilename = GetFileNameRoot(InputFilename) + ".trace.bc";
std::ofstream Out(TraceFilename.c_str());
if (!Out.good())
std::ofstream Out(TraceFilename.c_str());
if (!Out.good())
- cerr << "Error opening '" << TraceFilename
- << "'!: Skipping output of trace code as bytecode\n";
+ std::cerr << "Error opening '" << TraceFilename
+ << "'!: Skipping output of trace code as bytecode\n";
- cerr << "Emitting trace code to '" << TraceFilename
- << "' for comparison...\n";
+ std::cerr << "Emitting trace code to '" << TraceFilename
+ << "' for comparison...\n";
WriteBytecodeToFile(&M, Out);
}
WriteBytecodeToFile(&M, Out);
}
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
if (M.get() == 0)
{
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
if (M.get() == 0)
{
- cerr << argv[0] << ": bytecode didn't read correctly.\n";
+ std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
else if (Opt->getTargetCtor())
Passes.add(Opt->getTargetCtor()(Target));
else
else if (Opt->getTargetCtor())
Passes.add(Opt->getTargetCtor()(Target));
else
- cerr << argv[0] << ": cannot create pass: "
- << Opt->getPassName() << "\n";
+ std::cerr << argv[0] << ": cannot create pass: "
+ << Opt->getPassName() << "\n";
// If LLVM dumping after transformations is requested, add it to the pipeline
if (DumpAsm)
// If LLVM dumping after transformations is requested, add it to the pipeline
if (DumpAsm)
- Passes.add(new PrintFunctionPass("Code after xformations: \n", &cerr));
+ Passes.add(new PrintFunctionPass("Code after xformations: \n", &std::cerr));
// Strip all of the symbols from the bytecode so that it will be smaller...
Passes.add(createSymbolStrippingPass());
// Strip all of the symbols from the bytecode so that it will be smaller...
Passes.add(createSymbolStrippingPass());
{ // Specified an output filename?
if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
{ // Specified an output filename?
if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
- cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
+ std::cerr << argv[0] << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
return 1;
}
Out = new std::ofstream(OutputFilename.c_str());
return 1;
}
Out = new std::ofstream(OutputFilename.c_str());
- string OutputFilename = GetFileNameRoot(InputFilename);
+ std::string OutputFilename = GetFileNameRoot(InputFilename);
OutputFilename += ".s";
if (!Force && std::ifstream(OutputFilename.c_str()))
{
// If force is not specified, make sure not to overwrite a file!
OutputFilename += ".s";
if (!Force && std::ifstream(OutputFilename.c_str()))
{
// If force is not specified, make sure not to overwrite a file!
- cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
+ std::cerr << argv[0] << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
return 1;
}
Out = new std::ofstream(OutputFilename.c_str());
if (!Out->good())
{
return 1;
}
Out = new std::ofstream(OutputFilename.c_str());
if (!Out->good())
{
- cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
+ std::cerr << argv[0] << ": error opening " << OutputFilename
+ << "!\n";
// Ask the target to add backend passes as neccesary
if (Target.addPassesToEmitAssembly(Passes, *Out)) {
// Ask the target to add backend passes as neccesary
if (Target.addPassesToEmitAssembly(Passes, *Out)) {
- cerr << argv[0] << ": target '" << Target.getName()
- << " does not support static compilation!\n";
+ std::cerr << argv[0] << ": target '" << Target.getName()
+ << " does not support static compilation!\n";
} else {
// Run our queue of passes all at once now, efficiently.
Passes.run(*M.get());
} else {
// Run our queue of passes all at once now, efficiently.
Passes.run(*M.get());