mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Region: Allow user control the printing style of the print function.
Contributed by: etherzhhb@gmail.com git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128808 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
10fdd5a0f6
commit
cc5d992bc1
@ -335,12 +335,16 @@ public:
|
||||
return RI;
|
||||
}
|
||||
|
||||
/// PrintStyle - Print region in difference ways.
|
||||
enum PrintStyle { PrintNone, PrintBB, PrintRN };
|
||||
|
||||
/// @brief Print the region.
|
||||
///
|
||||
/// @param OS The output stream the Region is printed to.
|
||||
/// @param printTree Print also the tree of subregions.
|
||||
/// @param level The indentation level used for printing.
|
||||
void print(raw_ostream& OS, bool printTree = true, unsigned level = 0) const;
|
||||
void print(raw_ostream& OS, bool printTree = true, unsigned level = 0,
|
||||
enum PrintStyle Style = PrintNone) const;
|
||||
|
||||
/// @brief Print the region to stderr.
|
||||
void dump() const;
|
||||
|
@ -41,16 +41,15 @@ VerifyRegionInfoX("verify-region-info", cl::location(VerifyRegionInfo),
|
||||
STATISTIC(numRegions, "The # of regions");
|
||||
STATISTIC(numSimpleRegions, "The # of simple regions");
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// PrintStyle - Print region in difference ways.
|
||||
enum PrintStyle { PrintNone, PrintBB, PrintRN };
|
||||
|
||||
static cl::opt<enum PrintStyle> printStyle("print-region-style", cl::Hidden,
|
||||
static cl::opt<enum Region::PrintStyle> printStyle("print-region-style",
|
||||
cl::Hidden,
|
||||
cl::desc("style of printing regions"),
|
||||
cl::values(
|
||||
clEnumValN(PrintNone, "none", "print no details"),
|
||||
clEnumValN(PrintBB, "bb", "print regions in detail with block_iterator"),
|
||||
clEnumValN(PrintRN, "rn", "print regions in detail with element_iterator"),
|
||||
clEnumValN(Region::PrintNone, "none", "print no details"),
|
||||
clEnumValN(Region::PrintBB, "bb",
|
||||
"print regions in detail with block_iterator"),
|
||||
clEnumValN(Region::PrintRN, "rn",
|
||||
"print regions in detail with element_iterator"),
|
||||
clEnumValEnd));
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// Region Implementation
|
||||
@ -413,7 +412,8 @@ Region *Region::getExpandedRegion() const {
|
||||
return new Region(getEntry(), R->getExit(), RI, DT);
|
||||
}
|
||||
|
||||
void Region::print(raw_ostream &OS, bool print_tree, unsigned level) const {
|
||||
void Region::print(raw_ostream &OS, bool print_tree, unsigned level,
|
||||
enum PrintStyle Style) const {
|
||||
if (print_tree)
|
||||
OS.indent(level*2) << "[" << level << "] " << getNameStr();
|
||||
else
|
||||
@ -422,14 +422,14 @@ void Region::print(raw_ostream &OS, bool print_tree, unsigned level) const {
|
||||
OS << "\n";
|
||||
|
||||
|
||||
if (printStyle != PrintNone) {
|
||||
if (Style != PrintNone) {
|
||||
OS.indent(level*2) << "{\n";
|
||||
OS.indent(level*2 + 2);
|
||||
|
||||
if (printStyle == PrintBB) {
|
||||
if (Style == PrintBB) {
|
||||
for (const_block_iterator I = block_begin(), E = block_end(); I!=E; ++I)
|
||||
OS << **I << ", "; // TODO: remove the last ","
|
||||
} else if (printStyle == PrintRN) {
|
||||
} else if (Style == PrintRN) {
|
||||
for (const_element_iterator I = element_begin(), E = element_end(); I!=E; ++I)
|
||||
OS << **I << ", "; // TODO: remove the last ",
|
||||
}
|
||||
@ -439,14 +439,14 @@ void Region::print(raw_ostream &OS, bool print_tree, unsigned level) const {
|
||||
|
||||
if (print_tree)
|
||||
for (const_iterator RI = begin(), RE = end(); RI != RE; ++RI)
|
||||
(*RI)->print(OS, print_tree, level+1);
|
||||
(*RI)->print(OS, print_tree, level+1, Style);
|
||||
|
||||
if (printStyle != PrintNone)
|
||||
if (Style != PrintNone)
|
||||
OS.indent(level*2) << "} \n";
|
||||
}
|
||||
|
||||
void Region::dump() const {
|
||||
print(dbgs(), true, getDepth());
|
||||
print(dbgs(), true, getDepth(), printStyle.getValue());
|
||||
}
|
||||
|
||||
void Region::clearNodeCache() {
|
||||
@ -714,7 +714,7 @@ void RegionInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
|
||||
void RegionInfo::print(raw_ostream &OS, const Module *) const {
|
||||
OS << "Region tree:\n";
|
||||
TopLevelRegion->print(OS, true, 0);
|
||||
TopLevelRegion->print(OS, true, 0, printStyle.getValue());
|
||||
OS << "End region tree\n";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user