mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Add RegionPass support.
A RegionPass is executed like a LoopPass but on the regions detected by the RegionInfo pass instead of the loops detected by the LoopInfo pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116905 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include "llvm/Assembly/PrintModulePass.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Analysis/LoopPass.h"
|
||||
#include "llvm/Analysis/RegionPass.h"
|
||||
#include "llvm/Analysis/CallGraph.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
@ -267,6 +268,40 @@ struct LoopPassPrinter : public LoopPass {
|
||||
|
||||
char LoopPassPrinter::ID = 0;
|
||||
|
||||
struct RegionPassPrinter : public RegionPass {
|
||||
static char ID;
|
||||
const PassInfo *PassToPrint;
|
||||
raw_ostream &Out;
|
||||
std::string PassName;
|
||||
|
||||
RegionPassPrinter(const PassInfo *PI, raw_ostream &out) : RegionPass(ID),
|
||||
PassToPrint(PI), Out(out) {
|
||||
std::string PassToPrintName = PassToPrint->getPassName();
|
||||
PassName = "LoopPass Printer: " + PassToPrintName;
|
||||
}
|
||||
|
||||
virtual bool runOnRegion(Region *R, RGPassManager &RGM) {
|
||||
if (!Quiet) {
|
||||
Out << "Printing analysis '" << PassToPrint->getPassName() << "' for "
|
||||
<< "region: '" << R->getNameStr() << "' in function '"
|
||||
<< R->getEntry()->getParent()->getNameStr() << "':\n";
|
||||
}
|
||||
// Get and print pass...
|
||||
getAnalysisID<Pass>(PassToPrint->getTypeInfo()).print(Out,
|
||||
R->getEntry()->getParent()->getParent());
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual const char *getPassName() const { return "'Pass' Printer"; }
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequiredID(PassToPrint->getTypeInfo());
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
};
|
||||
|
||||
char RegionPassPrinter::ID = 0;
|
||||
|
||||
struct BasicBlockPassPrinter : public BasicBlockPass {
|
||||
const PassInfo *PassToPrint;
|
||||
raw_ostream &Out;
|
||||
@ -526,6 +561,9 @@ int main(int argc, char **argv) {
|
||||
case PT_BasicBlock:
|
||||
Passes.add(new BasicBlockPassPrinter(PassInf, Out->os()));
|
||||
break;
|
||||
case PT_Region:
|
||||
Passes.add(new RegionPassPrinter(PassInf, Out->os()));
|
||||
break;
|
||||
case PT_Loop:
|
||||
Passes.add(new LoopPassPrinter(PassInf, Out->os()));
|
||||
break;
|
||||
|
Reference in New Issue
Block a user