[llvm-commits] [llvm] r95124 - in /llvm/trunk: include/llvm/Target/TargetMachine.h lib/CodeGen/LLVMTargetMachine.cpp lib/Target/CBackend/CBackend.cpp lib/Target/CppBackend/CPPBackend.cpp lib/Target/MSIL/MSILWriter.cpp tools/llc/llc.cpp tools/lto/LTOCodeGenerator.cpp
Chris Lattner
sabre at nondot.org
Tue Feb 2 13:06:45 PST 2010
Author: lattner
Date: Tue Feb 2 15:06:45 2010
New Revision: 95124
URL: http://llvm.org/viewvc/llvm-project?rev=95124&view=rev
Log:
eliminate FileModel::Model, just use CodeGenFileType. The client
of the code generator shouldn't care what object format a target
uses.
Modified:
llvm/trunk/include/llvm/Target/TargetMachine.h
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
llvm/trunk/lib/Target/CBackend/CBackend.cpp
llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
llvm/trunk/lib/Target/MSIL/MSILWriter.cpp
llvm/trunk/tools/llc/llc.cpp
llvm/trunk/tools/lto/LTOCodeGenerator.cpp
Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Tue Feb 2 15:06:45 2010
@@ -60,16 +60,6 @@
};
}
-namespace FileModel {
- enum Model {
- Error,
- None,
- AsmFile,
- MachOFile,
- ElfFile
- };
-}
-
// Code generation optimization level.
namespace CodeGenOpt {
enum Level {
@@ -206,9 +196,13 @@
}
/// CodeGenFileType - These enums are meant to be passed into
- /// addPassesToEmitFile to indicate what type of file to emit.
+ /// addPassesToEmitFile to indicate what type of file to emit, and returned by
+ /// it to indicate what type of file could actually be made.
enum CodeGenFileType {
- AssemblyFile, ObjectFile, DynamicLibrary
+ CGFT_AssemblyFile,
+ CGFT_ObjectFile,
+ CGFT_DynamicLibrary,
+ CGFT_ErrorOccurred
};
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
@@ -218,14 +212,14 @@
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
/// specified file emitted. Typically this will involve several steps of code
/// generation.
- /// This method should return FileModel::Error if emission of this file type
+ /// This method should return InvalidFile if emission of this file type
/// is not supported.
///
- virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
- formatted_raw_ostream &,
- CodeGenFileType,
- CodeGenOpt::Level) {
- return FileModel::None;
+ virtual CodeGenFileType addPassesToEmitFile(PassManagerBase &,
+ formatted_raw_ostream &,
+ CodeGenFileType Filetype,
+ CodeGenOpt::Level) {
+ return CGFT_ErrorOccurred;
}
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
@@ -271,19 +265,19 @@
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
/// specified file emitted. Typically this will involve several steps of code
- /// generation. If OptLevel is None, the code generator should emit code as fast
- /// as possible, though the generated code may be less efficient. This method
- /// should return FileModel::Error if emission of this file type is not
- /// supported.
+ /// generation. If OptLevel is None, the code generator should emit code as
+ /// fast as possible, though the generated code may be less efficient. This
+ /// method should return CGFT_ErrorOccurred if emission of this file type is
+ /// not supported.
///
/// The default implementation of this method adds components from the
/// LLVM retargetable code generator, invoking the methods below to get
/// target-specific passes in standard locations.
///
- virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
- formatted_raw_ostream &Out,
- CodeGenFileType FileType,
- CodeGenOpt::Level);
+ virtual CodeGenFileType addPassesToEmitFile(PassManagerBase &PM,
+ formatted_raw_ostream &Out,
+ CodeGenFileType FileType,
+ CodeGenOpt::Level);
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
/// get machine code emitted. This uses a MachineCodeEmitter object to handle
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Tue Feb 2 15:06:45 2010
@@ -96,28 +96,25 @@
setCodeModel(CodeModel::Small);
}
-FileModel::Model
+TargetMachine::CodeGenFileType
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
// Add common CodeGen passes.
if (addCommonCodeGenPasses(PM, OptLevel))
- return FileModel::Error;
+ return CGFT_ErrorOccurred;
- FileModel::Model ResultTy;
switch (FileType) {
default:
- return FileModel::Error;
- case TargetMachine::ObjectFile:
- return FileModel::Error;
- case TargetMachine::AssemblyFile: {
+ case CGFT_ObjectFile:
+ return CGFT_ErrorOccurred;
+ case CGFT_AssemblyFile: {
FunctionPass *Printer =
getTarget().createAsmPrinter(Out, *this, getMCAsmInfo(),
getAsmVerbosityDefault());
- if (Printer == 0) return FileModel::Error;
+ if (Printer == 0) return CGFT_ErrorOccurred;
PM.add(Printer);
- ResultTy = FileModel::AsmFile;
break;
}
}
@@ -125,7 +122,7 @@
// Make sure the code model is set.
setCodeModelForStatic();
PM.add(createGCInfoDeleter());
- return ResultTy;
+ return FileType;
}
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Tue Feb 2 15:06:45 2010
@@ -3706,7 +3706,7 @@
formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
- if (FileType != TargetMachine::AssemblyFile) return true;
+ if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
PM.add(createGCLoweringPass());
PM.add(createLowerInvokePass());
Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Tue Feb 2 15:06:45 2010
@@ -2009,7 +2009,7 @@
formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel) {
- if (FileType != TargetMachine::AssemblyFile) return true;
+ if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
PM.add(new CppWriter(o));
return false;
}
Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original)
+++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Tue Feb 2 15:06:45 2010
@@ -1690,7 +1690,7 @@
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel)
{
- if (FileType != TargetMachine::AssemblyFile) return true;
+ if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
MSILWriter* Writer = new MSILWriter(o);
PM.add(createGCLoweringPass());
// FIXME: Handle switch through native IL instruction "switch"
Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Tue Feb 2 15:06:45 2010
@@ -85,14 +85,14 @@
cl::value_desc("a1,+a2,-a3,..."));
cl::opt<TargetMachine::CodeGenFileType>
-FileType("filetype", cl::init(TargetMachine::AssemblyFile),
+FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
cl::desc("Choose a file type (not all types are supported by all targets):"),
cl::values(
- clEnumValN(TargetMachine::AssemblyFile, "asm",
+ clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
"Emit an assembly ('.s') file"),
- clEnumValN(TargetMachine::ObjectFile, "obj",
+ clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
"Emit a native object ('.o') file [experimental]"),
- clEnumValN(TargetMachine::DynamicLibrary, "dynlib",
+ clEnumValN(TargetMachine::CGFT_DynamicLibrary, "dynlib",
"Emit a native dynamic library ('.so') file"
" [experimental]"),
clEnumValEnd));
@@ -162,7 +162,8 @@
bool Binary = false;
switch (FileType) {
- case TargetMachine::AssemblyFile:
+ default: assert(0 && "Unknown file type");
+ case TargetMachine::CGFT_AssemblyFile:
if (TargetName[0] == 'c') {
if (TargetName[1] == 0)
OutputFilename += ".cbe.c";
@@ -173,11 +174,11 @@
} else
OutputFilename += ".s";
break;
- case TargetMachine::ObjectFile:
+ case TargetMachine::CGFT_ObjectFile:
OutputFilename += ".o";
Binary = true;
break;
- case TargetMachine::DynamicLibrary:
+ case TargetMachine::CGFT_DynamicLibrary:
OutputFilename += LTDL_SHLIB_EXT;
Binary = true;
break;
@@ -352,14 +353,14 @@
default:
assert(0 && "Invalid file model!");
return 1;
- case FileModel::Error:
+ case TargetMachine::CGFT_ErrorOccurred:
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
- case FileModel::AsmFile:
+ case TargetMachine::CGFT_AssemblyFile:
break;
}
Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=95124&r1=95123&r2=95124&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Feb 2 15:06:45 2010
@@ -396,9 +396,9 @@
codeGenPasses->add(new TargetData(*_target->getTargetData()));
switch (_target->addPassesToEmitFile(*codeGenPasses, out,
- TargetMachine::AssemblyFile,
+ TargetMachine::CGFT_AssemblyFile,
CodeGenOpt::Aggressive)) {
- case FileModel::AsmFile:
+ case TargetMachine::CGFT_AssemblyFile:
break;
default:
errMsg = "target file type not supported";
More information about the llvm-commits
mailing list