mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Add option to print per module instead of per method, so that
global declarations are also printed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,31 +16,40 @@ class PrintModulePass : public Pass {
|
|||||||
string Banner; // String to print before each method
|
string Banner; // String to print before each method
|
||||||
ostream *Out; // ostream to print on
|
ostream *Out; // ostream to print on
|
||||||
bool DeleteStream; // Delete the ostream in our dtor?
|
bool DeleteStream; // Delete the ostream in our dtor?
|
||||||
|
bool PrintPerMethod; // Print one method at a time rather than the whole?
|
||||||
bool PrintAsBytecode; // Print as bytecode rather than assembly?
|
bool PrintAsBytecode; // Print as bytecode rather than assembly?
|
||||||
public:
|
public:
|
||||||
inline PrintModulePass(const string &B, ostream *o = &cout, bool DS = false,
|
inline PrintModulePass(const string &B, ostream *o = &cout,
|
||||||
|
bool DS = false,
|
||||||
|
bool printPerMethod = true,
|
||||||
bool printAsBytecode = false)
|
bool printAsBytecode = false)
|
||||||
: Banner(B), Out(o), DeleteStream(DS), PrintAsBytecode(printAsBytecode) {}
|
: Banner(B), Out(o), DeleteStream(DS),
|
||||||
|
PrintPerMethod(printPerMethod), PrintAsBytecode(printAsBytecode) {
|
||||||
|
if (PrintAsBytecode)
|
||||||
|
PrintPerMethod = false;
|
||||||
|
}
|
||||||
|
|
||||||
~PrintModulePass() {
|
~PrintModulePass() {
|
||||||
if (DeleteStream) delete Out;
|
if (DeleteStream) delete Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// doPerMethodWork - This pass just prints a banner followed by the method as
|
// doPerMethodWork - This pass just prints a banner followed by the method as
|
||||||
// it's processed.
|
// it's processed.
|
||||||
//
|
//
|
||||||
bool doPerMethodWork(Method *M) {
|
bool doPerMethodWork(Method *M) {
|
||||||
if (! PrintAsBytecode)
|
if (PrintPerMethod)
|
||||||
(*Out) << Banner << M;
|
(*Out) << Banner << M;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// doPassFinalization - Virtual method overriden by subclasses to do any post
|
// doPassFinalization - Virtual method overriden by subclasses to do any post
|
||||||
// processing needed after all passes have run.
|
// processing needed after all passes have run.
|
||||||
//
|
//
|
||||||
bool doPassFinalization(Module *M) {
|
bool doPassFinalization(Module *module) {
|
||||||
if (PrintAsBytecode)
|
if (PrintAsBytecode)
|
||||||
WriteBytecodeToFile(M, *Out);
|
WriteBytecodeToFile(module, *Out);
|
||||||
|
else if (! PrintPerMethod)
|
||||||
|
(*Out) << Banner << module;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user