cvsuser 03/06/21 04:33:37
Modified: . core.ops
languages/imcc imcc.y instructions.c instructions.h pbc.c
Log:
22749 - finally + imcc fixes for local newsub branches
Revision Changes Path
1.289 +3 -3 parrot/core.ops
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -w -r1.288 -r1.289
--- core.ops 21 Jun 2003 09:22:39 -0000 1.288
+++ core.ops 21 Jun 2003 11:33:34 -0000 1.289
@@ -1195,7 +1195,7 @@
$1 = pmc_new_noinit(interpreter, $2);
$1->vtable->init(interpreter, $1);
VTABLE_set_integer_native(interpreter, $1,
- PTR2OPCODE_T(CUR_OPCODE + $3 - REL_PC));
+ PTR2OPCODE_T(CUR_OPCODE + $3));
goto NEXT();
}
@@ -1211,11 +1211,11 @@
interpreter->pmc_reg.registers[0] = pmc_new_noinit(interpreter, $1);
VTABLE_init(interpreter, interpreter->pmc_reg.registers[0]);
VTABLE_set_integer_native(interpreter, interpreter->pmc_reg.registers[0],
- PTR2OPCODE_T(CUR_OPCODE + $3 - REL_PC));
+ PTR2OPCODE_T(CUR_OPCODE + $3));
interpreter->pmc_reg.registers[1] = pmc_new_noinit(interpreter, $2);
VTABLE_init(interpreter, interpreter->pmc_reg.registers[1]);
VTABLE_set_integer_native(interpreter, interpreter->pmc_reg.registers[1],
- PTR2OPCODE_T(CUR_OPCODE + $4 - REL_PC));
+ PTR2OPCODE_T(CUR_OPCODE + $4));
goto NEXT();
}
1.62 +6 -0 parrot/languages/imcc/imcc.y
Index: imcc.y
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imcc.y,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -w -r1.61 -r1.62
--- imcc.y 16 Jun 2003 10:43:58 -0000 1.61
+++ imcc.y 21 Jun 2003 11:33:37 -0000 1.62
@@ -373,6 +373,12 @@
/* mark this as branch, because it needs fixup */
ins->type = ITADDR | IF_r1_branch | ITBRANCH;
}
+ else if (!strcmp(name, "newsub")) {
+ if (ins->opsize == 4)
+ ins->type = ITADDR | IF_r2_branch | ITBRANCH;
+ else
+ ins->type = ITADDR | IF_r2_branch | IF_r3_branch | ITBRANCH;
+ }
else if (!strcmp(name, "compile"))
++has_compile;
1.32 +1 -1 parrot/languages/imcc/instructions.c
Index: instructions.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/instructions.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -w -r1.31 -r1.32
--- instructions.c 31 May 2003 23:37:42 -0000 1.31
+++ instructions.c 21 Jun 2003 11:33:37 -0000 1.32
@@ -264,7 +264,7 @@
int get_branch_regno(Instruction * ins)
{
int j;
- for (j = 0; ins->r[j] && j < IMCC_MAX_REGS-1; j++)
+ for (j = ins->opsize - 2; j >= 0 && ins->r[j] ; --j)
if (ins->type & (1<<j))
return j;
return -1;
1.22 +1 -0 parrot/languages/imcc/instructions.h
Index: instructions.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/instructions.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -r1.21 -r1.22
--- instructions.h 31 May 2003 23:37:42 -0000 1.21
+++ instructions.h 21 Jun 2003 11:33:37 -0000 1.22
@@ -56,6 +56,7 @@
IF_r0_branch = (1 << 0),
IF_r1_branch = (1 << 1),
IF_r2_branch = (1 << 2),
+ IF_r3_branch = (1 << 3),
IF_goto = (1 << 15)
} Instruction_Flags;
1.35 +15 -2 parrot/languages/imcc/pbc.c
Index: pbc.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/pbc.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -w -r1.34 -r1.35
--- pbc.c 8 Jun 2003 10:09:53 -0000 1.34
+++ pbc.c 21 Jun 2003 11:33:37 -0000 1.35
@@ -794,6 +794,19 @@
/* TODO make intersegment branch */
fatal(1, "e_pbc_emit", "label not found for '%s'\n",
addr->name);
+ }
+ if (ins->opsize == 5 && !strcmp(ins->op, "newsub")) {
+ /* this only fixes local branches,
+ * TOTO globals
+ */
+ addr = ins->r[2];
+ label = _get_sym(globals.cs->subs->labels, addr->name);
+ /* maybe global */
+ if (label) {
+ addr->color = label->color - npc;
+ debug(DEBUG_PBC_FIXUP, "branch label %d jump %d %s %d\n",
+ npc, label->color, addr->name,addr->color);
+ }
}
}
/* add debug line info */