Commit 686b9ea9 authored by mei-ye's avatar mei-ye
Browse files

coloring

parent e747cf2e
...@@ -49,6 +49,7 @@ bool memory_coloring_impl::allocate(T_live_interval* interval) ...@@ -49,6 +49,7 @@ bool memory_coloring_impl::allocate(T_live_interval* interval)
conflict_queue.pop(); conflict_queue.pop();
} }
segment.offset = offset; segment.offset = offset;
DEBUG(segment.dump());
return true; return true;
} }
...@@ -158,11 +159,22 @@ void memory_coloring_impl::dump() ...@@ -158,11 +159,22 @@ void memory_coloring_impl::dump()
} }
#define GET_INS_ENUM(x) (((x) >> 1) - 1) #define GET_INS_ENUM(x) (((x) >> 1) - 1)
void live_range::dump()
{
std::cout << " segment:" << vn;
std::cout << " [" << GET_INS_ENUM(begin) << ", " << GET_INS_ENUM(end) << "]";
if (offset != -1) {
std::cout << " mem:";
std::cout << " [" << offset << "," << offset + size << "]";
}
std::cout << std::endl;
}
void live_interval::dump() void live_interval::dump()
{ {
std::cout << "id:" << id; std::cout << "id:" << id;
std::cout << " segment:" << segment.vn; segment.dump();
std::cout << " [" << GET_INS_ENUM(segment.begin) << ", " << GET_INS_ENUM(segment.end) << "]";
std::cout << " uses:"; std::cout << " uses:";
for (auto iter = use_points.begin(), end = use_points.end(); iter != end; ++iter) { for (auto iter = use_points.begin(), end = use_points.end(); iter != end; ++iter) {
int& use = *iter; int& use = *iter;
...@@ -181,6 +193,7 @@ void live_interval::dump() ...@@ -181,6 +193,7 @@ void live_interval::dump()
std::cout << " " << result; std::cout << " " << result;
std::cout << std::endl; std::cout << std::endl;
} }
#endif #endif
} // namespace migraph } // namespace migraph
...@@ -10,6 +10,9 @@ typedef struct live_range { ...@@ -10,6 +10,9 @@ typedef struct live_range {
int offset; // offset to base pointer of allocated memory trunk. int offset; // offset to base pointer of allocated memory trunk.
int vn; // value number that identifies this live_range. int vn; // value number that identifies this live_range.
int size; // size of required memory in bytes int size; // size of required memory in bytes
#ifdef DEBUG_OPT
void dump();
#endif
} T_live_range; } T_live_range;
typedef struct live_interval { typedef struct live_interval {
...@@ -77,13 +80,14 @@ struct memory_coloring_impl { ...@@ -77,13 +80,14 @@ struct memory_coloring_impl {
{ {
int len1 = I1->get_end() - I1->get_begin(); int len1 = I1->get_end() - I1->get_begin();
int len2 = I2->get_end() - I2->get_begin(); int len2 = I2->get_end() - I2->get_begin();
if (len1 < len2) if (len1 != len2) {
return true; return (len1 < len2) ? true : false;
else if (I1->result.bytes() < I2->result.bytes()) } else if (I1->result.bytes() != I2->result.bytes()) {
return true; return (I1->result.bytes() < I2->result.bytes()) ? true : false;
else } else {
return I1->id > I2->id; return I1->id > I2->id;
} }
}
bool operator() (const T_live_range* I1, const T_live_range* I2) const bool operator() (const T_live_range* I1, const T_live_range* I2) const
{ {
return (I1->offset > I2->offset); return (I1->offset > I2->offset);
......
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