--- /dev/null
+#include "mcg.h"
+
+struct hop* new_hop(int insn_no, struct ir* ir)
+{
+ struct hop* hop = calloc(1, sizeof *hop);
+ hop->insn_no = insn_no;
+ hop->ir = ir;
+}
+
+static void add_reg(struct vreg* vregs[], struct vreg* vreg)
+{
+ int i;
+
+ for (i=0; i<HOP_INOUT_REGS; i++)
+ if (!vregs[i])
+ {
+ vregs[i] = vreg;
+ return;
+ }
+
+ fatal("too many input registers for instruction");
+}
+
+void hop_add_in_reg(struct hop* hop, struct vreg* vreg)
+{
+ add_reg(hop->invregs, vreg);
+}
+
+void hop_add_out_reg(struct hop* hop, struct vreg* vreg)
+{
+ add_reg(hop->outvregs, vreg);
+}
+
+void hop_emit(struct hop* hop, const struct burm_emitter_data* ed)
+{
+ const struct burm_instruction_data* insndata = &burm_instruction_data[hop->insn_no];
+ insndata->emitter(hop->ir, ed);
+}
+
--- /dev/null
+#ifndef HOP_H
+#define HOP_H
+
+struct vreg
+{
+ int id;
+ int regclass;
+};
+
+#define HOP_INOUT_REGS 4
+
+struct hop
+{
+ int insn_no;
+ struct ir* ir;
+ struct vreg* invregs[HOP_INOUT_REGS];
+ struct vreg* outvregs[HOP_INOUT_REGS];
+};
+
+extern struct hop* new_hop(int insn_no, struct ir* ir);
+
+extern void hop_add_in_reg(struct hop* hop, struct vreg* reg);
+extern void hop_add_out_reg(struct hop* hop, struct vreg* reg);
+
+#endif
+
+
#include "mcg.h"
-#include "mcgg.h"
+
+static int vregcount;
#if 0
static void dumpCover(NODEPTR_TYPE p, int goalnt, int indent) {
void burm_trace(struct ir* p, int ruleno, int cost, int bestcost) {
const struct burm_instruction_data* insndata = &burm_instruction_data[ruleno];
- tracef('I', "I: 0x%p matched %s with cost %d vs. %d\n", p,
- insndata->name, cost, bestcost);
+ //tracef('I', "I: 0x%p matched %s with cost %d vs. %d\n", p,
+ // insndata->name, cost, bestcost);
}
void burm_panic_cannot_match(struct ir* ir)
if (insndata->is_fragment)
insndata->emitter(ir, &emitter_data);
else
- tracef('I', "I: emit reg $%d\n", ir->id);
+ tracef('I', "I: emit reg %d\n", ir->vreg);
}
static void emit_value(struct ir* ir)
const struct burm_instruction_data* insndata = &burm_instruction_data[insn_no];
const short* nts = burm_nts[insn_no];
int i;
+ int resultreg = 0;
ir->insn_no = insn_no;
+ if (insndata->allocate)
+ {
+ resultreg = vregcount++;
+ tracef('I', "I: new %s %d\n",
+ burm_register_class_names[insndata->allocate], resultreg);
+ }
+
burm_kids(ir, insn_no, children);
for (i=0; nts[i]; i++)
walk_instructions(children[i], nts[i]);
+ if (ir->vreg)
+ tracef('I', "I: use %d\n", ir->vreg);
+ if (resultreg)
+ ir->vreg = resultreg;
+
tracef('I', "I: $%d %s selected %s %d: %s\n",
ir->id,
ir->is_sequence ? "S" : " ",
insndata->name);
ir->is_generated = true;
- if (insndata->allocate)
- tracef('I', "I: allocate reg of class %d\n", insndata->allocate);
if (!insndata->is_fragment && insndata->emitter)
insndata->emitter(ir, &emitter_data);
}
{
int i;
+ vregcount = 1;
+
for (i=0; i<proc->blocks_count; i++)
{
struct basicblock* bb = proc->blocks[i];