labels that are the same name as instructions...).
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 : */
struct idf* p;
if (!name)
- name = aprintf("___anon_bb_%d", next_id++);
+ name = aprintf(".anon_bb_%d", next_id++);
p = str2idf((char*) name, 0);
if (!p->block)
{
fatal("label '%s' can't change sections", pending->name);
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;
}
}
switch (ir->opcode)
{
case IR_BLOCK:
- appendf("%s", ir->u.bvalue->name);
+ appendf("%s", platform_label(ir->u.bvalue->name));
break;
case IR_LABEL:
- appendf("%s", ir->u.lvalue);
+ appendf("%s", platform_label(ir->u.lvalue));
break;
case IR_LOCAL:
extern struct hop* platform_epilogue(void);
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 const char* platform_label(const char* label);
extern FILE* outputfile;
extern FILE* dominance_dot_file;
{
case ir_to_esn(IR_REG, 0):
current_hop->output = node->ir->result;
+ assert(current_hop->output != NULL);
break;
case ir_to_esn(IR_NOP, 'I'):
case ir_to_esn(IR_NOP, 'L'):
case ir_to_esn(IR_NOP, 'D'):
current_hop->output = node->left->ir->result;
+ assert(current_hop->output != NULL);
break;
}
}
{
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();
}
}
{
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++)
{
struct hop* hop = bb->hops.item[j];
{
int i;
- fprintf(cfg_dot_file, "subgraph %s {\n", name);
- fprintf(cfg_dot_file, "\t%s [color=red];\n", cfg.entry->name);
+ fprintf(cfg_dot_file, "subgraph \"%s\" {\n", name);
+ fprintf(cfg_dot_file, "\t\"%s\" [color=red];\n", cfg.entry->name);
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].right->name);
}
{
int i;
- fprintf(dominance_dot_file, "subgraph %s {\n", name);
- fprintf(dominance_dot_file, "\t%s [color=green];\n", cfg.entry->name);
+ fprintf(dominance_dot_file, "subgraph \"%s\" {\n", name);
+ fprintf(dominance_dot_file, "\t\"%s\" [color=green];\n", cfg.entry->name);
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].left->name);
}