Refactor the addPassesToEmitAssembly interface into a addPassesToEmitFile

interface.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-06-25 02:48:37 +00:00
parent 11f14c8be0
commit 0431c96cec
19 changed files with 72 additions and 41 deletions

View File

@ -54,11 +54,13 @@ AlphaTargetMachine::AlphaTargetMachine( const Module &M, IntrinsicLowering *IL)
FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these
{}
/// addPassesToEmitAssembly - Add passes to the specified pass manager
/// to implement a static compiler for this target.
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///
bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool AlphaTargetMachine::addPassesToEmitFile(PassManager &PM,
std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
if (EnableAlphaLSR) {
PM.add(createLoopStrengthReducePass());

View File

@ -37,7 +37,8 @@ public:
return &InstrInfo.getRegisterInfo();
}
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
static unsigned getModuleMatchQuality(const Module &M);
};

View File

@ -1725,7 +1725,10 @@ void CWriter::visitVAArgInst(VAArgInst &I) {
// External Interface declaration
//===----------------------------------------------------------------------===//
bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
bool CTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &o,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
PM.add(createLowerGCPass());
PM.add(createLowerAllocationsPass(true));
PM.add(createLowerInvokePass());
@ -1733,5 +1736,3 @@ bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
PM.add(new CWriter(o, getIntrinsicLowering()));
return false;
}
// vim: sw=2

View File

@ -24,7 +24,8 @@ struct CTargetMachine : public TargetMachine {
TargetMachine("CBackend", IL, M) {}
// This is the only thing that actually does anything here.
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
// This class always works, but shouldn't be the default in most cases.
static unsigned getModuleMatchQuality(const Module &M) { return 1; }

View File

@ -1725,7 +1725,10 @@ void CWriter::visitVAArgInst(VAArgInst &I) {
// External Interface declaration
//===----------------------------------------------------------------------===//
bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
bool CTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &o,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
PM.add(createLowerGCPass());
PM.add(createLowerAllocationsPass(true));
PM.add(createLowerInvokePass());
@ -1733,5 +1736,3 @@ bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
PM.add(new CWriter(o, getIntrinsicLowering()));
return false;
}
// vim: sw=2

View File

@ -77,10 +77,13 @@ IA64TargetMachine::IA64TargetMachine(const Module &M, IntrinsicLowering *IL)
FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0) { // FIXME? check this stuff
}
// addPassesToEmitAssembly - We currently use all of the same passes as the JIT
// addPassesToEmitFile - We currently use all of the same passes as the JIT
// does to emit statically compiled machine code.
bool IA64TargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool IA64TargetMachine::addPassesToEmitFile(PassManager &PM,
std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());

View File

@ -35,7 +35,8 @@ public:
return &InstrInfo.getRegisterInfo();
}
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
static unsigned getModuleMatchQuality(const Module &M);
static unsigned compileTimeMatchQuality(void);

View File

@ -73,11 +73,14 @@ unsigned PPC32TargetMachine::getJITMatchQuality() {
#endif
}
/// addPassesToEmitAssembly - Add passes to the specified pass manager
/// to implement a static compiler for this target.
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///
bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool PowerPCTargetMachine::addPassesToEmitFile(PassManager &PM,
std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
bool LP64 = (0 != dynamic_cast<PPC64TargetMachine *>(this));
if (EnablePPCLSR) {

View File

@ -32,7 +32,8 @@ protected:
public:
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
};
} // end namespace llvm

View File

@ -34,11 +34,13 @@ SkeletonTargetMachine::SkeletonTargetMachine(const Module &M,
FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4), JITInfo(*this) {
}
/// addPassesToEmitAssembly - Add passes to the specified pass manager
/// addPassesToEmitFile - Add passes to the specified pass manager
/// to implement a static compiler for this target.
///
bool SkeletonTargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool SkeletonTargetMachine::addPassesToEmitFile(PassManager &PM,
std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
// <insert instruction selector passes here>
PM.add(createRegisterAllocator());
PM.add(createPrologEpilogCodeInserter());

View File

@ -42,7 +42,8 @@ namespace llvm {
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
};
} // end namespace llvm

View File

@ -59,11 +59,14 @@ unsigned SparcV8TargetMachine::getModuleMatchQuality(const Module &M) {
return getJITMatchQuality()/2;
}
/// addPassesToEmitAssembly - Add passes to the specified pass manager
/// addPassesToEmitFile - Add passes to the specified pass manager
/// to implement a static compiler for this target.
///
bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool SparcV8TargetMachine::addPassesToEmitFile(PassManager &PM,
std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());

View File

@ -53,7 +53,8 @@ public:
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
};
} // end namespace llvm

View File

@ -59,11 +59,14 @@ unsigned SparcV8TargetMachine::getModuleMatchQuality(const Module &M) {
return getJITMatchQuality()/2;
}
/// addPassesToEmitAssembly - Add passes to the specified pass manager
/// addPassesToEmitFile - Add passes to the specified pass manager
/// to implement a static compiler for this target.
///
bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool SparcV8TargetMachine::addPassesToEmitFile(PassManager &PM,
std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());

View File

@ -53,7 +53,8 @@ public:
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
};
} // end namespace llvm

View File

@ -156,12 +156,14 @@ SparcV9TargetMachine::SparcV9TargetMachine(const Module &M,
jitInfo(*this) {
}
/// addPassesToEmitAssembly - This method controls the entire code generation
/// addPassesToEmitFile - This method controls the entire code generation
/// process for the ultra sparc.
///
bool
SparcV9TargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
{
SparcV9TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());

View File

@ -43,7 +43,8 @@ public:
return &instrInfo.getRegisterInfo();
}
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);

View File

@ -94,10 +94,12 @@ X86TargetMachine::X86TargetMachine(const Module &M, IntrinsicLowering *IL)
}
// addPassesToEmitAssembly - We currently use all of the same passes as the JIT
// addPassesToEmitFile - We currently use all of the same passes as the JIT
// does to emit statically compiled machine code.
bool X86TargetMachine::addPassesToEmitAssembly(PassManager &PM,
std::ostream &Out) {
bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType) {
if (FileType != TargetMachine::AssemblyFile) return true;
// FIXME: Implement efficient support for garbage collection intrinsics.
PM.add(createLowerGCPass());

View File

@ -46,7 +46,8 @@ public:
virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
MachineCodeEmitter &MCE);
virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType);
static unsigned getModuleMatchQuality(const Module &M);
static unsigned getJITMatchQuality();