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