[llvm-commits] CVS: llvm/tools/llc/llc.cpp
Bill Wendling
isanbard at gmail.com
Wed Feb 7 17:41:27 PST 2007
Changes in directory llvm/tools/llc:
llc.cpp updated: 1.143 -> 1.144
---
Log message:
The new version of how to add passes to emit files. We explicitly call a
function to add the file writers between calls to add the passes.
---
Diffs of the changes: (+25 -1)
llc.cpp | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletion(-)
Index: llvm/tools/llc/llc.cpp
diff -u llvm/tools/llc/llc.cpp:1.143 llvm/tools/llc/llc.cpp:1.144
--- llvm/tools/llc/llc.cpp:1.143 Wed Feb 7 15:41:02 2007
+++ llvm/tools/llc/llc.cpp Wed Feb 7 19:41:07 2007
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Bytecode/Reader.h"
+#include "llvm/CodeGen/FileWriters.h"
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
#include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetData.h"
@@ -248,7 +249,30 @@
#endif
// Ask the target to add backend passes as necessary.
- if (Target.addPassesToEmitFile(Passes, *Out, FileType, Fast)) {
+ MachineCodeEmitter *MCE = 0;
+
+ switch (Target.addPassesToEmitFile(Passes, *Out, FileType, Fast)) {
+ default:
+ assert(0 && "Invalid file model!");
+ return 1;
+ case FileModel::Error:
+ std::cerr << argv[0] << ": target does not support generation of this"
+ << " file type!\n";
+ if (Out != &std::cout) delete Out;
+ // And the Out file is empty and useless, so remove it now.
+ sys::Path(OutputFilename).eraseFromDisk();
+ return 1;
+ case FileModel::AsmFile:
+ break;
+ case FileModel::MachOFile:
+ MCE = AddMachOWriter(Passes, *Out, Target);
+ break;
+ case FileModel::ElfFile:
+ MCE = AddELFWriter(Passes, *Out, Target);
+ break;
+ }
+
+ if (Target.addPassesToEmitFileFinish(Passes, MCE, Fast)) {
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
if (Out != &std::cout) delete Out;
More information about the llvm-commits
mailing list