//
// The LLVM Compiler Infrastructure
//
-// 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.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the llc code generator driver. It provides a convenient
// command-line interface for generating native assembly-language code
-// or C code, given LLVM bytecode.
+// or C code, given LLVM bitcode.
//
//===----------------------------------------------------------------------===//
// 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 bitcode>"), cl::init("-"));
static cl::opt<std::string>
OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"));
static cl::opt<std::string>
TargetTriple("mtriple", cl::desc("Override target triple for module"));
-static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
+static cl::opt<const TargetMachineRegistry::entry*, false,
+ TargetMachineRegistry::Parser>
MArch("march", cl::desc("Architecture to generate code for:"));
static cl::opt<std::string>
switch (FileType) {
case TargetMachine::AssemblyFile:
- if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE
+ if (MArch->Name[0] == 'c') {
+ if (MArch->Name[1] == 0)
+ OutputFilename += ".cbe.c";
+ else if (MArch->Name[1] == 'p' && MArch->Name[2] == 'p')
+ OutputFilename += ".cpp";
+ else
+ OutputFilename += ".s";
+ } else
OutputFilename += ".s";
- else
- OutputFilename += ".cbe.c";
break;
case TargetMachine::ObjectFile:
OutputFilename += ".o";
//
int main(int argc, char **argv) {
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
- cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
+ cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
sys::PrintStackTraceOnErrorSignal();
// Load the module to be compiled...
std::string ErrorMessage;
std::auto_ptr<Module> M;
- {
std::auto_ptr<MemoryBuffer> Buffer(
- MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
+ MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage));
if (Buffer.get())
M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
- else
- ErrorMessage = "Error reading file '" + InputFilename + "'";
- }
if (M.get() == 0) {
- std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
+ std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
std::cerr << "Reason: " << ErrorMessage << "\n";
return 1;
}
PM.run(mod);
} else {
// Build up all of the passes that we want to do to the module.
- FunctionPassManager Passes(new ExistingModuleProvider(M.get()));
+ ExistingModuleProvider Provider(M.release());
+ FunctionPassManager Passes(&Provider);
Passes.add(new TargetData(*Target.getTargetData()));
#ifndef NDEBUG