2016-10-15 16:38:46 +00:00
|
|
|
#include "mcg.h"
|
|
|
|
|
2016-10-15 21:19:44 +00:00
|
|
|
void pass_add_prologue_epilogue(void)
|
2016-10-15 16:38:46 +00:00
|
|
|
{
|
2016-10-16 20:37:42 +00:00
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
current_proc->usedregs.count = 0;
|
|
|
|
for (i=0; i<cfg.preorder.count; i++)
|
|
|
|
{
|
|
|
|
struct basicblock* bb = cfg.preorder.item[i];
|
|
|
|
|
|
|
|
for (j=0; j<bb->hops.count; j++)
|
|
|
|
{
|
|
|
|
struct hop* hop = bb->hops.item[j];
|
|
|
|
|
|
|
|
for (k=0; k<hop->regsin.count; k++)
|
2016-10-19 21:29:05 +00:00
|
|
|
{
|
|
|
|
struct hreg* hreg = hop->regsin.item[k].left;
|
|
|
|
if (!hreg->is_stacked)
|
|
|
|
array_appendu(¤t_proc->usedregs, hreg);
|
|
|
|
}
|
2016-10-16 20:37:42 +00:00
|
|
|
|
|
|
|
for (k=0; k<hop->regsout.count; k++)
|
2016-10-19 21:29:05 +00:00
|
|
|
{
|
|
|
|
struct hreg* hreg = hop->regsout.item[k].left;
|
|
|
|
if (!hreg->is_stacked)
|
|
|
|
array_appendu(¤t_proc->usedregs, hreg);
|
|
|
|
}
|
2016-10-16 20:37:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-15 21:19:44 +00:00
|
|
|
platform_calculate_offsets();
|
2016-10-15 16:38:46 +00:00
|
|
|
|
2016-10-15 21:19:44 +00:00
|
|
|
array_insert(¤t_proc->entry->hops, platform_prologue(), 0);
|
2016-10-15 16:38:46 +00:00
|
|
|
|
2016-10-15 21:19:44 +00:00
|
|
|
if (current_proc->exit)
|
|
|
|
{
|
|
|
|
current_proc->exit->hops.count = 0;
|
|
|
|
array_append(¤t_proc->exit->hops, platform_epilogue());
|
2016-10-15 16:38:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|
|
|
|
|