[svn:parrot] r47174 - in trunk: compilers/imcc runtime/parrot/library/Test/Builder t/compilers/imcc/syn t/pmc
plobsing at svn.parrot.org
plobsing at svn.parrot.org
Sun May 30 22:39:54 UTC 2010
Author: plobsing
Date: Sun May 30 22:39:53 2010
New Revision: 47174
URL: https://trac.parrot.org/parrot/changeset/47174
Log:
Eliminate <cmp_op>_(str|num) virtual ops (AKA IMCC op rewrite rules).
These don't DWIM (eg: '$I1 = cmp_str $P0, $I0' does *integer* comparison),
are generally a bad idea, and are unused.
If these ops are actually desired, they should be added as real ops that DTRT.
Modified:
trunk/compilers/imcc/parser_util.c
trunk/runtime/parrot/library/Test/Builder/Output.pir
trunk/t/compilers/imcc/syn/clash.t
trunk/t/pmc/complex.t
trunk/t/pmc/resizablepmcarray.t
Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c Sun May 30 22:24:03 2010 (r47173)
+++ trunk/compilers/imcc/parser_util.c Sun May 30 22:39:53 2010 (r47174)
@@ -47,7 +47,7 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
PARROT_WARN_UNUSED_RESULT
-static int change_op(PARROT_INTERP,
+static int change_op_arg_to_num(PARROT_INTERP,
ARGMOD(IMC_Unit *unit),
ARGMOD(SymReg **r),
int num,
@@ -94,7 +94,7 @@
FUNC_MODIFIES(*unit)
FUNC_MODIFIES(*r);
-#define ASSERT_ARGS_change_op __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+#define ASSERT_ARGS_change_op_arg_to_num __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(unit) \
, PARROT_ASSERT_ARG(r))
@@ -948,8 +948,11 @@
/*
-=item C<static int change_op(PARROT_INTERP, IMC_Unit *unit, SymReg **r, int num,
-int emit)>
+=item C<static int change_op_arg_to_num(PARROT_INTERP, IMC_Unit *unit, SymReg
+**r, int num, int emit)>
+
+Change one argument of an op to be numeric in stead of integral. Used when
+integer argument op variants don't exist.
=cut
@@ -957,9 +960,9 @@
PARROT_WARN_UNUSED_RESULT
static int
-change_op(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGMOD(SymReg **r), int num, int emit)
+change_op_arg_to_num(PARROT_INTERP, ARGMOD(IMC_Unit *unit), ARGMOD(SymReg **r), int num, int emit)
{
- ASSERT_ARGS(change_op)
+ ASSERT_ARGS(change_op_arg_to_num)
int changed = 0;
if (r[num]->type & (VTCONST|VT_CONSTP)) {
@@ -1021,44 +1024,11 @@
ASSERT_ARGS(try_find_op)
char fullname[64];
int changed = 0;
- /*
- * eq_str, eq_num => eq
- * ...
- */
- if (n == 3 && r[2]->type == VTADDRESS) {
- if (STREQ(name, "eq_str") || STREQ(name, "eq_num")) {
- name = "eq";
- changed = 1;
- }
- else if (STREQ(name, "ne_str") || STREQ(name, "ne_num")) {
- name = "ne";
- changed = 1;
- }
- else if (STREQ(name, "le_str") || STREQ(name, "le_num")) {
- name = "le";
- changed = 1;
- }
- else if (STREQ(name, "lt_str") || STREQ(name, "lt_num")) {
- name = "lt";
- changed = 1;
- }
- else if (STREQ(name, "ge_str") || STREQ(name, "ge_num")) {
- name = "ge";
- changed = 1;
- }
- else if (STREQ(name, "gt_str") || STREQ(name, "gt_num")) {
- name = "gt";
- changed = 1;
- }
- }
- else if (n == 3 && (STREQ(name, "cmp_str") || STREQ(name, "cmp_num"))) {
- name = "cmp";
- changed = 1;
- }
+
if (n == 3 && r[0]->set == 'N') {
if (r[1]->set == 'I') {
const SymReg * const r1 = r[1];
- changed |= change_op(interp, unit, r, 1, emit);
+ changed |= change_op_arg_to_num(interp, unit, r, 1, emit);
/* op Nx, Iy, Iy: reuse generated temp Nz */
if (r[2]->set == 'I' && r[2]->type != VTADDRESS && r[2] == r1)
@@ -1066,20 +1036,20 @@
}
if (r[2]->set == 'I' && r[2]->type != VTADDRESS)
- changed |= change_op(interp, unit, r, 2, emit);
+ changed |= change_op_arg_to_num(interp, unit, r, 2, emit);
}
/* handle eq_i_n_ic */
else if (n == 3 && r[1]->set == 'N' && r[0]->set == 'I' &&
r[2]->type == VTADDRESS) {
- changed |= change_op(interp, unit, r, 0, emit);
+ changed |= change_op_arg_to_num(interp, unit, r, 0, emit);
}
else if (n == 2 && r[0]->set == 'N' && r[1]->set == 'I') {
/*
* transcendentals e.g. acos N, I
*/
if (!STREQ(name, "fact"))
- changed = change_op(interp, unit, r, 1, emit);
+ changed = change_op_arg_to_num(interp, unit, r, 1, emit);
}
if (changed) {
Modified: trunk/runtime/parrot/library/Test/Builder/Output.pir
==============================================================================
--- trunk/runtime/parrot/library/Test/Builder/Output.pir Sun May 30 22:24:03 2010 (r47173)
+++ trunk/runtime/parrot/library/Test/Builder/Output.pir Sun May 30 22:39:53 2010 (r47174)
@@ -146,7 +146,7 @@
if i == 0 goto LINE_OK
line = lines[i]
first_char = substr line, 0, 1
- eq_str first_char, '#', LINE_OK
+ if first_char == '#' goto LINE_OK
.local string new_line
new_line = '# '
@@ -186,7 +186,7 @@
.local string first_char
first_char = substr message, 0, 1
- eq_str first_char, '#', WRITE_MESSAGE
+ if first_char == '#' goto WRITE_MESSAGE
first_char = '# '
concat first_char, message
Modified: trunk/t/compilers/imcc/syn/clash.t
==============================================================================
--- trunk/t/compilers/imcc/syn/clash.t Sun May 30 22:24:03 2010 (r47173)
+++ trunk/t/compilers/imcc/syn/clash.t Sun May 30 22:39:53 2010 (r47174)
@@ -8,7 +8,7 @@
use Test::More;
use Parrot::Config;
-use Parrot::Test tests => 17;
+use Parrot::Test tests => 15;
pir_output_is( <<'CODE', <<'OUT', "if/unless" );
.sub test :main
@@ -210,38 +210,6 @@
ok
OUTPUT
-pir_output_is( <<'CODE', <<'OUTPUT', "eq_num => eq" );
-.sub test :main
- .local int i
- .local int j
- i = 1
- j = 1
- eq_num i, j, ok1
- print "not "
-ok1:
- print "ok 1\n"
- end
-.end
-CODE
-ok 1
-OUTPUT
-
-pir_output_is( <<'CODE', <<'OUTPUT', "eq_num => eq mixed => eq_n_n" );
-.sub test :main
- .local int i
- .local num j
- i = 1
- j = 1.0
- eq_num j, i, ok1
- print "not "
-ok1:
- print "ok 1\n"
- end
-.end
-CODE
-ok 1
-OUTPUT
-
pir_error_output_like( <<'CODE', <<'OUT', "undefined ident" );
.sub test :main
print no_such
Modified: trunk/t/pmc/complex.t
==============================================================================
--- trunk/t/pmc/complex.t Sun May 30 22:24:03 2010 (r47173)
+++ trunk/t/pmc/complex.t Sun May 30 22:39:53 2010 (r47174)
@@ -687,9 +687,7 @@
concat $S5, $S2, " of "
concat $S5, $S5, $S4
- $I0 = cmp_str $S1, $S3
- $I0 = not $I0
-
+ $I0 = iseq $S1, $S3
todo( $I0, $S4 )
.endm
Modified: trunk/t/pmc/resizablepmcarray.t
==============================================================================
--- trunk/t/pmc/resizablepmcarray.t Sun May 30 22:24:03 2010 (r47173)
+++ trunk/t/pmc/resizablepmcarray.t Sun May 30 22:39:53 2010 (r47174)
@@ -358,7 +358,7 @@
.sub compare_reverse
.param string a
.param string b
- $I0 = cmp_str b, a
+ $I0 = cmp b, a
.return($I0)
.end
More information about the parrot-commits
mailing list