mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
eliminate FileModel::Model, just use CodeGenFileType. The client
of the code generator shouldn't care what object format a target uses. llvm-svn: 95124
This commit is contained in:
parent
7c37b4942d
commit
7d162688a9
@ -60,16 +60,6 @@ namespace CodeModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace FileModel {
|
|
||||||
enum Model {
|
|
||||||
Error,
|
|
||||||
None,
|
|
||||||
AsmFile,
|
|
||||||
MachOFile,
|
|
||||||
ElfFile
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Code generation optimization level.
|
// Code generation optimization level.
|
||||||
namespace CodeGenOpt {
|
namespace CodeGenOpt {
|
||||||
enum Level {
|
enum Level {
|
||||||
@ -206,9 +196,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// CodeGenFileType - These enums are meant to be passed into
|
/// 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 {
|
enum CodeGenFileType {
|
||||||
AssemblyFile, ObjectFile, DynamicLibrary
|
CGFT_AssemblyFile,
|
||||||
|
CGFT_ObjectFile,
|
||||||
|
CGFT_DynamicLibrary,
|
||||||
|
CGFT_ErrorOccurred
|
||||||
};
|
};
|
||||||
|
|
||||||
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
||||||
@ -218,14 +212,14 @@ public:
|
|||||||
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
||||||
/// specified file emitted. Typically this will involve several steps of code
|
/// specified file emitted. Typically this will involve several steps of code
|
||||||
/// generation.
|
/// 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.
|
/// is not supported.
|
||||||
///
|
///
|
||||||
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &,
|
virtual CodeGenFileType addPassesToEmitFile(PassManagerBase &,
|
||||||
formatted_raw_ostream &,
|
formatted_raw_ostream &,
|
||||||
CodeGenFileType,
|
CodeGenFileType Filetype,
|
||||||
CodeGenOpt::Level) {
|
CodeGenOpt::Level) {
|
||||||
return FileModel::None;
|
return CGFT_ErrorOccurred;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||||
@ -271,19 +265,19 @@ public:
|
|||||||
|
|
||||||
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
||||||
/// specified file emitted. Typically this will involve several steps of code
|
/// specified file emitted. Typically this will involve several steps of code
|
||||||
/// generation. If OptLevel is None, the code generator should emit code as fast
|
/// generation. If OptLevel is None, the code generator should emit code as
|
||||||
/// as possible, though the generated code may be less efficient. This method
|
/// fast as possible, though the generated code may be less efficient. This
|
||||||
/// should return FileModel::Error if emission of this file type is not
|
/// method should return CGFT_ErrorOccurred if emission of this file type is
|
||||||
/// supported.
|
/// not supported.
|
||||||
///
|
///
|
||||||
/// The default implementation of this method adds components from the
|
/// The default implementation of this method adds components from the
|
||||||
/// LLVM retargetable code generator, invoking the methods below to get
|
/// LLVM retargetable code generator, invoking the methods below to get
|
||||||
/// target-specific passes in standard locations.
|
/// target-specific passes in standard locations.
|
||||||
///
|
///
|
||||||
virtual FileModel::Model addPassesToEmitFile(PassManagerBase &PM,
|
virtual CodeGenFileType addPassesToEmitFile(PassManagerBase &PM,
|
||||||
formatted_raw_ostream &Out,
|
formatted_raw_ostream &Out,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
CodeGenOpt::Level);
|
CodeGenOpt::Level);
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||||
/// get machine code emitted. This uses a MachineCodeEmitter object to handle
|
/// get machine code emitted. This uses a MachineCodeEmitter object to handle
|
||||||
|
@ -96,28 +96,25 @@ LLVMTargetMachine::setCodeModelForStatic() {
|
|||||||
setCodeModel(CodeModel::Small);
|
setCodeModel(CodeModel::Small);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileModel::Model
|
TargetMachine::CodeGenFileType
|
||||||
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||||
formatted_raw_ostream &Out,
|
formatted_raw_ostream &Out,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
CodeGenOpt::Level OptLevel) {
|
CodeGenOpt::Level OptLevel) {
|
||||||
// Add common CodeGen passes.
|
// Add common CodeGen passes.
|
||||||
if (addCommonCodeGenPasses(PM, OptLevel))
|
if (addCommonCodeGenPasses(PM, OptLevel))
|
||||||
return FileModel::Error;
|
return CGFT_ErrorOccurred;
|
||||||
|
|
||||||
FileModel::Model ResultTy;
|
|
||||||
switch (FileType) {
|
switch (FileType) {
|
||||||
default:
|
default:
|
||||||
return FileModel::Error;
|
case CGFT_ObjectFile:
|
||||||
case TargetMachine::ObjectFile:
|
return CGFT_ErrorOccurred;
|
||||||
return FileModel::Error;
|
case CGFT_AssemblyFile: {
|
||||||
case TargetMachine::AssemblyFile: {
|
|
||||||
FunctionPass *Printer =
|
FunctionPass *Printer =
|
||||||
getTarget().createAsmPrinter(Out, *this, getMCAsmInfo(),
|
getTarget().createAsmPrinter(Out, *this, getMCAsmInfo(),
|
||||||
getAsmVerbosityDefault());
|
getAsmVerbosityDefault());
|
||||||
if (Printer == 0) return FileModel::Error;
|
if (Printer == 0) return CGFT_ErrorOccurred;
|
||||||
PM.add(Printer);
|
PM.add(Printer);
|
||||||
ResultTy = FileModel::AsmFile;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +122,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
// Make sure the code model is set.
|
// Make sure the code model is set.
|
||||||
setCodeModelForStatic();
|
setCodeModelForStatic();
|
||||||
PM.add(createGCInfoDeleter());
|
PM.add(createGCInfoDeleter());
|
||||||
return ResultTy;
|
return FileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||||
|
@ -3706,7 +3706,7 @@ bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
|
|||||||
formatted_raw_ostream &o,
|
formatted_raw_ostream &o,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
CodeGenOpt::Level OptLevel) {
|
CodeGenOpt::Level OptLevel) {
|
||||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
|
||||||
|
|
||||||
PM.add(createGCLoweringPass());
|
PM.add(createGCLoweringPass());
|
||||||
PM.add(createLowerInvokePass());
|
PM.add(createLowerInvokePass());
|
||||||
|
@ -2009,7 +2009,7 @@ bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
|
|||||||
formatted_raw_ostream &o,
|
formatted_raw_ostream &o,
|
||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
CodeGenOpt::Level OptLevel) {
|
CodeGenOpt::Level OptLevel) {
|
||||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
|
||||||
PM.add(new CppWriter(o));
|
PM.add(new CppWriter(o));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1690,7 +1690,7 @@ bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM,
|
|||||||
CodeGenFileType FileType,
|
CodeGenFileType FileType,
|
||||||
CodeGenOpt::Level OptLevel)
|
CodeGenOpt::Level OptLevel)
|
||||||
{
|
{
|
||||||
if (FileType != TargetMachine::AssemblyFile) return true;
|
if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
|
||||||
MSILWriter* Writer = new MSILWriter(o);
|
MSILWriter* Writer = new MSILWriter(o);
|
||||||
PM.add(createGCLoweringPass());
|
PM.add(createGCLoweringPass());
|
||||||
// FIXME: Handle switch through native IL instruction "switch"
|
// FIXME: Handle switch through native IL instruction "switch"
|
||||||
|
@ -85,14 +85,14 @@ MAttrs("mattr",
|
|||||||
cl::value_desc("a1,+a2,-a3,..."));
|
cl::value_desc("a1,+a2,-a3,..."));
|
||||||
|
|
||||||
cl::opt<TargetMachine::CodeGenFileType>
|
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::desc("Choose a file type (not all types are supported by all targets):"),
|
||||||
cl::values(
|
cl::values(
|
||||||
clEnumValN(TargetMachine::AssemblyFile, "asm",
|
clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
|
||||||
"Emit an assembly ('.s') file"),
|
"Emit an assembly ('.s') file"),
|
||||||
clEnumValN(TargetMachine::ObjectFile, "obj",
|
clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
|
||||||
"Emit a native object ('.o') file [experimental]"),
|
"Emit a native object ('.o') file [experimental]"),
|
||||||
clEnumValN(TargetMachine::DynamicLibrary, "dynlib",
|
clEnumValN(TargetMachine::CGFT_DynamicLibrary, "dynlib",
|
||||||
"Emit a native dynamic library ('.so') file"
|
"Emit a native dynamic library ('.so') file"
|
||||||
" [experimental]"),
|
" [experimental]"),
|
||||||
clEnumValEnd));
|
clEnumValEnd));
|
||||||
@ -162,7 +162,8 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
|
|||||||
|
|
||||||
bool Binary = false;
|
bool Binary = false;
|
||||||
switch (FileType) {
|
switch (FileType) {
|
||||||
case TargetMachine::AssemblyFile:
|
default: assert(0 && "Unknown file type");
|
||||||
|
case TargetMachine::CGFT_AssemblyFile:
|
||||||
if (TargetName[0] == 'c') {
|
if (TargetName[0] == 'c') {
|
||||||
if (TargetName[1] == 0)
|
if (TargetName[1] == 0)
|
||||||
OutputFilename += ".cbe.c";
|
OutputFilename += ".cbe.c";
|
||||||
@ -173,11 +174,11 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
|
|||||||
} else
|
} else
|
||||||
OutputFilename += ".s";
|
OutputFilename += ".s";
|
||||||
break;
|
break;
|
||||||
case TargetMachine::ObjectFile:
|
case TargetMachine::CGFT_ObjectFile:
|
||||||
OutputFilename += ".o";
|
OutputFilename += ".o";
|
||||||
Binary = true;
|
Binary = true;
|
||||||
break;
|
break;
|
||||||
case TargetMachine::DynamicLibrary:
|
case TargetMachine::CGFT_DynamicLibrary:
|
||||||
OutputFilename += LTDL_SHLIB_EXT;
|
OutputFilename += LTDL_SHLIB_EXT;
|
||||||
Binary = true;
|
Binary = true;
|
||||||
break;
|
break;
|
||||||
@ -352,14 +353,14 @@ int main(int argc, char **argv) {
|
|||||||
default:
|
default:
|
||||||
assert(0 && "Invalid file model!");
|
assert(0 && "Invalid file model!");
|
||||||
return 1;
|
return 1;
|
||||||
case FileModel::Error:
|
case TargetMachine::CGFT_ErrorOccurred:
|
||||||
errs() << argv[0] << ": target does not support generation of this"
|
errs() << argv[0] << ": target does not support generation of this"
|
||||||
<< " file type!\n";
|
<< " file type!\n";
|
||||||
if (Out != &fouts()) delete Out;
|
if (Out != &fouts()) delete Out;
|
||||||
// And the Out file is empty and useless, so remove it now.
|
// And the Out file is empty and useless, so remove it now.
|
||||||
sys::Path(OutputFilename).eraseFromDisk();
|
sys::Path(OutputFilename).eraseFromDisk();
|
||||||
return 1;
|
return 1;
|
||||||
case FileModel::AsmFile:
|
case TargetMachine::CGFT_AssemblyFile:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,9 +396,9 @@ bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
|
|||||||
codeGenPasses->add(new TargetData(*_target->getTargetData()));
|
codeGenPasses->add(new TargetData(*_target->getTargetData()));
|
||||||
|
|
||||||
switch (_target->addPassesToEmitFile(*codeGenPasses, out,
|
switch (_target->addPassesToEmitFile(*codeGenPasses, out,
|
||||||
TargetMachine::AssemblyFile,
|
TargetMachine::CGFT_AssemblyFile,
|
||||||
CodeGenOpt::Aggressive)) {
|
CodeGenOpt::Aggressive)) {
|
||||||
case FileModel::AsmFile:
|
case TargetMachine::CGFT_AssemblyFile:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errMsg = "target file type not supported";
|
errMsg = "target file type not supported";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user