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

fixed debug output

parent d2f76261
......@@ -317,10 +317,20 @@ unordered_map<Value const*, int> AffineRelation::createVariableIndexMap(Function
// MARK: - debug output
unordered_map<int,Value const*> reverseMap(unordered_map<Value const*, int> map) {
unordered_map<int,Value const*> reversed;
for (auto [key, value]: map) {
reversed[value] = key;
}
return reversed;
}
void AffineRelation::printIncoming(BasicBlock const& bb, raw_ostream& out, int indentation) const {
auto reversed = reverseMap(index);
for (auto m: basis) {
out << llvm::left_justify("", 8);
for (auto [val, idx]: index) {
for (int i = 1; i <= getNumberOfVariables(); i++) {
auto val = reversed[i];
if (val->hasName()) {
out << llvm::left_justify(val->getName(), 6);
} else {
......@@ -332,9 +342,11 @@ 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);
for (auto m: basis) {
out << llvm::left_justify("", 8);
for (auto [val, idx]: index) {
for (int i = 1; i <= getNumberOfVariables(); i++) {
auto val = reversed[i];
if (val->hasName()) {
out << llvm::left_justify(val->getName(), 6);
} else {
......@@ -346,9 +358,11 @@ 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);
for (auto m: basis) {
dbgs(3) << llvm::left_justify("", 8);
for (auto [val, idx]: index) {
for (int i = 1; i <= getNumberOfVariables(); i++) {
auto val = reversed[i];
if (val->hasName()) {
dbgs(3) << llvm::left_justify(val->getName(), 6);
} else {
......
......@@ -12,7 +12,7 @@ namespace pcpo {
class AffineRelation {
private:
/// Only valid when `createVariableIndexMap` has been generated.
int getNumberOfVariables() { return index.size(); };
int getNumberOfVariables() const { return index.size(); };
std::unordered_map<llvm::Value const*, int> createVariableIndexMap(llvm::Function const& func);
public:
std::unordered_map<llvm::Value const*, int> index;
......
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