Verified Commit e4587a58 authored by Tim Gymnich's avatar Tim Gymnich
Browse files

improved debug log

parent 11e05c3e
#include "affine_relation.h"
#include "global.h"
#include "llvm/IR/CFG.h"
#include <set>
......@@ -328,7 +330,7 @@ unordered_map<int,Value const*> reverseMap(unordered_map<Value const*, int> cons
void AffineRelation::printIncoming(BasicBlock const& bb, raw_ostream& out, int indentation) const {
auto reversed = reverseMap(index);
if (basis.empty()) {
dbgs(3) << "[]";
dbgs(3) << "[]\n";
return;
}
for (auto m: basis) {
......@@ -348,7 +350,7 @@ void AffineRelation::printIncoming(BasicBlock const& bb, raw_ostream& out, int i
void AffineRelation::printOutgoing(BasicBlock const& bb, raw_ostream& out, int indentation) const {
auto reversed = reverseMap(index);
if (basis.empty()) {
dbgs(3) << "[]";
dbgs(3) << "[]\n";
return;
}
for (auto m: basis) {
......@@ -368,7 +370,7 @@ void AffineRelation::printOutgoing(BasicBlock const& bb, raw_ostream& out, int i
void AffineRelation::debug_output(Instruction const& inst, Matrix<int> operands) {
auto reversed = reverseMap(index);
if (basis.empty()) {
dbgs(3) << "[]";
dbgs(3) << "[]\n";
return;
}
for (auto m: basis) {
......@@ -385,4 +387,25 @@ void AffineRelation::debug_output(Instruction const& inst, Matrix<int> operands)
}
}
raw_ostream& operator<<(raw_ostream& os, AffineRelation const& relation) {
auto reversed = reverseMap(relation.index);
if (relation.basis.empty()) {
return os << "[]\n";
}
for (auto m: relation.basis) {
os << left_justify("", 8);
for (int i = 1; i <= int(relation.index.size()); i++) {
auto val = reversed[i];
if (val->hasName()) {
os << left_justify(val->getName(), 6);
} else {
os << left_justify("<>", 6);
}
}
os << "\n" << m << "\n";
}
return os;
}
}
......@@ -42,8 +42,6 @@ public:
bool checkOperandsForBottom(llvm::Instruction const& inst) { return false; }
// Matrix<int> AffineRelation::getAbstractValue(llvm::Value const& value) const;
void printIncoming(llvm::BasicBlock const& bb, llvm::raw_ostream& out, int indentation) const;
void printOutgoing(llvm::BasicBlock const& bb, llvm::raw_ostream& out, int indentation) const;
......@@ -64,5 +62,7 @@ protected:
Matrix<int> createTransformationMatrix(llvm::Instruction const& inst);
};
llvm::raw_ostream& operator<<(llvm::raw_ostream& os, AffineRelation const& relation);
}
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