Commit f96c49ab authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #904 from undingen/printvisitor

PrintVisitor: use raw_ostream
parents 1782dd56 fe6885a6
This diff is collapsed.
......@@ -22,6 +22,7 @@
#include <vector>
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"
#include "analysis/scoping_analysis.h"
#include "core/common.h"
......@@ -1329,11 +1330,13 @@ public:
void print_ast(AST* ast);
class PrintVisitor : public ASTVisitor {
private:
llvm::raw_ostream& stream;
int indent;
void printIndent();
void printOp(AST_TYPE::AST_TYPE op_type);
public:
PrintVisitor(int indent = 0) : indent(indent) {}
PrintVisitor(int indent = 0, llvm::raw_ostream& stream = llvm::outs()) : stream(stream), indent(indent) {}
virtual ~PrintVisitor() {}
virtual bool visit_alias(AST_alias* node);
......
......@@ -56,26 +56,26 @@ void CFGBlock::unconnectFrom(CFGBlock* successor) {
successor->predecessors.end());
}
void CFGBlock::print() {
printf("Block %d", idx);
void CFGBlock::print(llvm::raw_ostream& stream) {
stream << "Block " << idx;
if (info)
printf(" '%s'", info);
stream << " '" << info << "'";
printf("; Predecessors:");
stream << "; Predecessors:";
for (int j = 0; j < predecessors.size(); j++) {
printf(" %d", predecessors[j]->idx);
stream << " " << predecessors[j]->idx;
}
printf(" Successors:");
stream << " Successors:";
for (int j = 0; j < successors.size(); j++) {
printf(" %d", successors[j]->idx);
stream << " " << successors[j]->idx;
}
printf("\n");
stream << "\n";
PrintVisitor pv(4);
for (int j = 0; j < body.size(); j++) {
printf(" ");
stream << " ";
body[j]->accept(&pv);
printf("\n");
stream << "\n";
}
}
......@@ -2518,11 +2518,11 @@ public:
}
};
void CFG::print() {
printf("CFG:\n");
printf("%ld blocks\n", blocks.size());
void CFG::print(llvm::raw_ostream& stream) {
stream << "CFG:\n";
stream << blocks.size() << " blocks\n";
for (int i = 0; i < blocks.size(); i++)
blocks[i]->print();
blocks[i]->print(stream);
}
class AssignVRegsVisitor : public NoopASTVisitor {
......
......@@ -66,7 +66,7 @@ public:
void unconnectFrom(CFGBlock* successor);
void push_back(AST_stmt* node) { body.push_back(node); }
void print();
void print(llvm::raw_ostream& stream = llvm::outs());
};
// Control Flow Graph
......@@ -108,7 +108,7 @@ public:
blocks.push_back(block);
}
void print();
void print(llvm::raw_ostream& stream = llvm::outs());
bool hasVregsAssigned() { return has_vregs_assigned; }
void assignVRegs(const ParamNames& param_names, ScopeInfo* scope_info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment