Convert to new simpler, more powerful pass structure

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@882 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-10-18 05:28:44 +00:00
parent 8d9e3776d8
commit 685639df42

View File

@ -52,7 +52,7 @@ static inline string GetFileNameRoot(const string &InputFilename) {
// Native code generation for a specified target. // Native code generation for a specified target.
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
class GenerateCodeForTarget : public ConcretePass { class GenerateCodeForTarget : public Pass {
TargetMachine &Target; TargetMachine &Target;
public: public:
inline GenerateCodeForTarget(TargetMachine &T) : Target(T) {} inline GenerateCodeForTarget(TargetMachine &T) : Target(T) {}
@ -60,7 +60,7 @@ public:
// doPerMethodWork - This method does the actual work of generating code for // doPerMethodWork - This method does the actual work of generating code for
// the specified method. // the specified method.
// //
bool doPerMethodWorkVirt(Method *M) { bool doPerMethodWork(Method *M) {
if (!M->isExternal() && Target.compileMethod(M)) { if (!M->isExternal() && Target.compileMethod(M)) {
cerr << "Error compiling " << InputFilename << "!\n"; cerr << "Error compiling " << InputFilename << "!\n";
return true; return true;
@ -77,27 +77,22 @@ public:
// Write assembly code to specified output stream // Write assembly code to specified output stream
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
class EmitAssembly : public ConcretePass { class EmitAssembly : public Pass {
const TargetMachine &Target; // Target to compile for const TargetMachine &Target; // Target to compile for
ostream *Out; // Stream to print on ostream *Out; // Stream to print on
bool DeleteStream; // Delete stream in dtor? bool DeleteStream; // Delete stream in dtor?
Module *TheMod;
public: public:
inline EmitAssembly(const TargetMachine &T, ostream *O, bool D) inline EmitAssembly(const TargetMachine &T, ostream *O, bool D)
: Target(T), Out(O), DeleteStream(D) {} : Target(T), Out(O), DeleteStream(D) {}
virtual bool doPassInitializationVirt(Module *M) {
TheMod = M;
return false;
}
~EmitAssembly() { virtual bool doPassFinalization(Module *M) {
// TODO: This should be performed as a moduleCleanup function, but we don't // TODO: This should be performed as a moduleCleanup function, but we don't
// have one yet! // have one yet!
Target.emitAssembly(TheMod, *Out); Target.emitAssembly(M, *Out);
if (DeleteStream) delete Out; if (DeleteStream) delete Out;
return false;
} }
}; };