cvsuser 03/07/15 03:19:05
Modified: languages/imcc pbc.c
languages/imcc/t/syn bsr.t
Log:
global fixup for newsub opcode
Revision Changes Path
1.37 +6 -4 parrot/languages/imcc/pbc.c
Index: pbc.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/pbc.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -w -r1.36 -r1.37
--- pbc.c 3 Jul 2003 11:52:56 -0000 1.36
+++ pbc.c 15 Jul 2003 10:19:03 -0000 1.37
@@ -227,7 +227,7 @@
SymReg * bsr;
bsr = _mk_address(globals.cs->subs->bsrs, str_dup(r->name), U_add_all);
bsr->color = pc;
- bsr->score = offset; /* bsr = 1, addr I,x = 2 */
+ bsr->score = offset; /* bsr = 1, set_addr I,x = 2, newsub = 3 */
}
static void store_str_const(char * str, int idx)
@@ -316,6 +316,8 @@
}
else if (!strcmp(ins->op, "set_addr"))
store_bsr(ins->r[1], pc, 2);
+ else if (!strcmp(ins->op, "newsub"))
+ store_bsr(ins->r[2], pc, 3);
}
pc += ins->opsize;
}
@@ -361,7 +363,7 @@
if (label)
continue;
if (strcmp(ins->op, "bsr") && strcmp(ins->op, "set_addr") &&
- strcmp(ins->op, "branch_cs")) {
+ strcmp(ins->op, "branch_cs") && strcmp(ins->op, "newsub")) {
char buf[64];
Instruction *il;
SymReg *r[IMCC_MAX_REGS];
@@ -791,14 +793,14 @@
npc, label->color, addr->name,addr->color);
}
else if (strcmp(ins->op, "bsr") && strcmp(ins->op, "set_addr") &&
- strcmp(ins->op, "branch_cs")) {
+ strcmp(ins->op, "branch_cs") && strcmp(ins->op, "newsub")) {
/* 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
+ * TODO globals
*/
addr = ins->r[2];
label = _get_sym(globals.cs->subs->labels, addr->name);
1.11 +15 -1 parrot/languages/imcc/t/syn/bsr.t
Index: bsr.t
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/t/syn/bsr.t,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- bsr.t 2 Jul 2003 13:37:22 -0000 1.10
+++ bsr.t 15 Jul 2003 10:19:05 -0000 1.11
@@ -1,6 +1,6 @@
#!perl
use strict;
-use TestCompiler tests => 11;
+use TestCompiler tests => 12;
##############################
# this tests register allocation/preserving of local bsr calls
@@ -338,3 +338,17 @@
back
OUT
+output_is(<<'CODE', <<'OUT', "newsub");
+ .sub _main
+ newsub P0, .Sub, _foo # PASM syntax only for now
+ invokecc P0
+ end
+ .end
+
+ .sub _foo
+ print "foo\n"
+ invoke P1
+ .end
+CODE
+foo
+OUT