Mangle label names (turns out that the ACK assembler can't really cope with
labels that are the same name as instructions...).
This commit is contained in:
parent
81525c0f2c
commit
658db4ba71
|
@ -290,5 +290,17 @@ struct hop* platform_swap(struct basicblock* bb, struct hreg* src, struct hreg*
|
||||||
return hop;
|
return hop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* platform_label(const char* label)
|
||||||
|
{
|
||||||
|
/* Labels starting with . are internal, not exported, and don't need mangling. */
|
||||||
|
|
||||||
|
if (label[0] == '.')
|
||||||
|
return label;
|
||||||
|
|
||||||
|
/* Otherwise, mangle. */
|
||||||
|
|
||||||
|
return aprintf("_%s", label);
|
||||||
|
}
|
||||||
|
|
||||||
/* vim: set sw=4 ts=4 expandtab : */
|
/* vim: set sw=4 ts=4 expandtab : */
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct basicblock* bb_get(const char* name)
|
||||||
struct idf* p;
|
struct idf* p;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
name = aprintf("___anon_bb_%d", next_id++);
|
name = aprintf(".anon_bb_%d", next_id++);
|
||||||
p = str2idf((char*) name, 0);
|
p = str2idf((char*) name, 0);
|
||||||
if (!p->block)
|
if (!p->block)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void emit_header(int desired_section)
|
||||||
fatal("label '%s' can't change sections", pending->name);
|
fatal("label '%s' can't change sections", pending->name);
|
||||||
|
|
||||||
fprintf(outputfile, "\n.sect %s\n", section_to_str(pending->section));
|
fprintf(outputfile, "\n.sect %s\n", section_to_str(pending->section));
|
||||||
fprintf(outputfile, "%s:\n", pending->name);
|
fprintf(outputfile, "%s:\n", platform_label(pending->name));
|
||||||
pending = NULL;
|
pending = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,11 +265,11 @@ char* hop_render(struct hop* hop)
|
||||||
switch (ir->opcode)
|
switch (ir->opcode)
|
||||||
{
|
{
|
||||||
case IR_BLOCK:
|
case IR_BLOCK:
|
||||||
appendf("%s", ir->u.bvalue->name);
|
appendf("%s", platform_label(ir->u.bvalue->name));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_LABEL:
|
case IR_LABEL:
|
||||||
appendf("%s", ir->u.lvalue);
|
appendf("%s", platform_label(ir->u.lvalue));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_LOCAL:
|
case IR_LOCAL:
|
||||||
|
|
|
@ -124,6 +124,7 @@ extern struct hop* platform_prologue(void);
|
||||||
extern struct hop* platform_epilogue(void);
|
extern struct hop* platform_epilogue(void);
|
||||||
extern struct hop* platform_move(struct basicblock* bb, struct hreg* src, struct hreg* dest);
|
extern struct hop* platform_move(struct basicblock* bb, struct hreg* src, struct hreg* dest);
|
||||||
extern struct hop* platform_swap(struct basicblock* bb, struct hreg* src, struct hreg* dest);
|
extern struct hop* platform_swap(struct basicblock* bb, struct hreg* src, struct hreg* dest);
|
||||||
|
extern const char* platform_label(const char* label);
|
||||||
|
|
||||||
extern FILE* outputfile;
|
extern FILE* outputfile;
|
||||||
extern FILE* dominance_dot_file;
|
extern FILE* dominance_dot_file;
|
||||||
|
|
|
@ -220,6 +220,7 @@ static struct insn* walk_instructions(struct burm_node* node, int goal)
|
||||||
{
|
{
|
||||||
case ir_to_esn(IR_REG, 0):
|
case ir_to_esn(IR_REG, 0):
|
||||||
current_hop->output = node->ir->result;
|
current_hop->output = node->ir->result;
|
||||||
|
assert(current_hop->output != NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ir_to_esn(IR_NOP, 'I'):
|
case ir_to_esn(IR_NOP, 'I'):
|
||||||
|
@ -227,6 +228,7 @@ static struct insn* walk_instructions(struct burm_node* node, int goal)
|
||||||
case ir_to_esn(IR_NOP, 'L'):
|
case ir_to_esn(IR_NOP, 'L'):
|
||||||
case ir_to_esn(IR_NOP, 'D'):
|
case ir_to_esn(IR_NOP, 'D'):
|
||||||
current_hop->output = node->left->ir->result;
|
current_hop->output = node->left->ir->result;
|
||||||
|
assert(current_hop->output != NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,9 +316,9 @@ void pass_instruction_selector(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0; i<cfg.preorder.count; i++)
|
for (i=0; i<dominance.preorder.count; i++)
|
||||||
{
|
{
|
||||||
current_bb = cfg.preorder.item[i];
|
current_bb = dominance.preorder.item[i];
|
||||||
select_instructions();
|
select_instructions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ static void emit_procedure(struct procedure* proc)
|
||||||
{
|
{
|
||||||
struct basicblock* bb = dominance.preorder.item[i];
|
struct basicblock* bb = dominance.preorder.item[i];
|
||||||
|
|
||||||
fprintf(outputfile, "%s:\n", bb->name);
|
fprintf(outputfile, "%s:\n", platform_label(bb->name));
|
||||||
for (j=0; j<bb->hops.count; j++)
|
for (j=0; j<bb->hops.count; j++)
|
||||||
{
|
{
|
||||||
struct hop* hop = bb->hops.item[j];
|
struct hop* hop = bb->hops.item[j];
|
||||||
|
@ -128,12 +128,12 @@ static void write_cfg_graph(const char* name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf(cfg_dot_file, "subgraph %s {\n", name);
|
fprintf(cfg_dot_file, "subgraph \"%s\" {\n", name);
|
||||||
fprintf(cfg_dot_file, "\t%s [color=red];\n", cfg.entry->name);
|
fprintf(cfg_dot_file, "\t\"%s\" [color=red];\n", cfg.entry->name);
|
||||||
|
|
||||||
for (i=0; i<cfg.graph.count; i++)
|
for (i=0; i<cfg.graph.count; i++)
|
||||||
{
|
{
|
||||||
fprintf(cfg_dot_file, "\t%s -> %s;\n",
|
fprintf(cfg_dot_file, "\t\"%s\" -> \"%s\";\n",
|
||||||
cfg.graph.item[i].left->name,
|
cfg.graph.item[i].left->name,
|
||||||
cfg.graph.item[i].right->name);
|
cfg.graph.item[i].right->name);
|
||||||
}
|
}
|
||||||
|
@ -145,12 +145,12 @@ static void write_dominance_graph(const char* name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf(dominance_dot_file, "subgraph %s {\n", name);
|
fprintf(dominance_dot_file, "subgraph \"%s\" {\n", name);
|
||||||
fprintf(dominance_dot_file, "\t%s [color=green];\n", cfg.entry->name);
|
fprintf(dominance_dot_file, "\t\"%s\" [color=green];\n", cfg.entry->name);
|
||||||
|
|
||||||
for (i=0; i<dominance.graph.count; i++)
|
for (i=0; i<dominance.graph.count; i++)
|
||||||
{
|
{
|
||||||
fprintf(dominance_dot_file, "\t%s -> %s;\n",
|
fprintf(dominance_dot_file, "\t\"%s\" -> \"%s\";\n",
|
||||||
dominance.graph.item[i].right->name,
|
dominance.graph.item[i].right->name,
|
||||||
dominance.graph.item[i].left->name);
|
dominance.graph.item[i].left->name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue