Permalink
Browse files

add untested implementations of the comparison ops to c-m0 and p5-m0

  • Loading branch information...
1 parent 44c0b79 commit a2cb0ea47418e74789491cc079b64792c0332f9b @cotto cotto committed May 28, 2012
@@ -17,6 +17,10 @@ enum M0_OPS {
M0_DIV_N,
M0_MOD_I,
M0_MOD_N,
+ M0_ISGT_I,
+ M0_ISGT_N,
+ M0_ISGE_I,
+ M0_ISGE_N,
M0_ITON,
M0_NTOI,
M0_ASHR,
View
@@ -104,6 +104,42 @@ m0_op_sub_n( M0_CallFrame *frame, const unsigned char *ops )
}
static void
+m0_op_isgt_i( M0_CallFrame *frame, const unsigned char *ops )
+{
+ int64_t *r2 = (int64_t*) &(frame->registers[ops[2]]);
+ int64_t *r3 = (int64_t*) &(frame->registers[ops[3]]);
+ int64_t *r1 = (int64_t*) &(frame->registers[ops[1]]);
+ *r1 = *r2 > *r3;
+}
+
+static void
+m0_op_isgt_n( M0_CallFrame *frame, const unsigned char *ops )
+{
+ double *r2 = (double*) &(frame->registers[ops[2]]);
+ double *r3 = (double*) &(frame->registers[ops[3]]);
+ double *r1 = (double*) &(frame->registers[ops[1]]);
+ *r1 = *r2 > *r3;
+}
+
+static void
+m0_op_isge_i( M0_CallFrame *frame, const unsigned char *ops )
+{
+ int64_t *r2 = (int64_t*) &(frame->registers[ops[2]]);
+ int64_t *r3 = (int64_t*) &(frame->registers[ops[3]]);
+ int64_t *r1 = (int64_t*) &(frame->registers[ops[1]]);
+ *r1 = *r2 >= *r3;
+}
+
+static void
+m0_op_isge_n( M0_CallFrame *frame, const unsigned char *ops )
+{
+ double *r2 = (double*) &(frame->registers[ops[2]]);
+ double *r3 = (double*) &(frame->registers[ops[3]]);
+ double *r1 = (double*) &(frame->registers[ops[1]]);
+ *r1 = *r2 >= *r3;
+}
+
+static void
m0_op_convert_n_i( M0_CallFrame *frame, const unsigned char *ops )
{
int64_t *r2 = (int64_t*) &(frame->registers[ops[2]]);
@@ -369,6 +405,22 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
M0_EXEC_OP(sub_n, cf, ops, pc);
break;
+ case (M0_ISGT_I):
+ M0_EXEC_OP(isgt_i, cf, ops, pc);
+ break;
+
+ case (M0_ISGT_N):
+ M0_EXEC_OP(isgt_n, cf, ops, pc);
+ break;
+
+ case (M0_ISGE_I):
+ M0_EXEC_OP(isge_i, cf, ops, pc);
+ break;
+
+ case (M0_ISGE_N):
+ M0_EXEC_OP(isge_n, cf, ops, pc);
+ break;
+
case (M0_GOTO):
M0_EXEC_OP(goto, cf, ops, pc);
break;
@@ -664,6 +664,10 @@ sub parse_chunks {
div_n
mod_i
mod_n
+isgt_i
+isgt_n
+isge_i
+isge_n
convert_i_n
convert_n_i
ashr
View
@@ -18,6 +18,7 @@ =head1 DESCRIPTION
use strict;
use warnings FATAL => qw(all);
use feature 'say';
+use IPC::System::Simple;
use autodie qw/:all/;
use File::Slurp qw/slurp/;
use Data::Dumper;
@@ -117,6 +118,10 @@ sub new_interp {
\&m0_opfunc_div_n,
\&m0_opfunc_mod_i,
\&m0_opfunc_mod_n,
+ \&m0_opfunc_isgt_i,
+ \&m0_opfunc_isgt_n,
+ \&m0_opfunc_isge_i,
+ \&m0_opfunc_isge_n,
\&m0_opfunc_convert_i_n,
\&m0_opfunc_convert_n_i,
\&m0_opfunc_ashr,
@@ -378,6 +383,34 @@ sub m0_opfunc_mod_n {
$$cf->[$a1] = n( n($$cf,$a2) % n($$cf,$a3) );
}
+sub m0_opfunc_isgt_i {
+ my ($cf, $a1, $a2, $a3) = @_;
+ m0_say "isgt_i $a1, $a2, $a3";
+
+ $$cf->[$a1] = i( i($$cf,$a2) > i($$cf,$a3) );
+}
+
+sub m0_opfunc_isgt_n {
+ my ($cf, $a1, $a2, $a3) = @_;
+ m0_say "isgt_n $a1, $a2, $a3";
+
+ $$cf->[$a1] = n( n($$cf,$a2) > n($$cf,$a3) );
+}
+
+sub m0_opfunc_isge_i {
+ my ($cf, $a1, $a2, $a3) = @_;
+ m0_say "isge_i $a1, $a2, $a3";
+
+ $$cf->[$a1] = i( i($$cf,$a2) >= i($$cf,$a3) );
+}
+
+sub m0_opfunc_isge_n {
+ my ($cf, $a1, $a2, $a3) = @_;
+ m0_say "isge_n $a1, $a2, $a3";
+
+ $$cf->[$a1] = n( n($$cf,$a2) >= n($$cf,$a3) );
+}
+
sub m0_opfunc_convert_i_n {
my ($cf, $a1, $a2, $a3) = @_;
m0_say "convert_i_n $a1, $a2, $a3";
View
Binary file not shown.
View
@@ -74,7 +74,7 @@ output_like(
output_like(
$hello_m0,
- qr/Parsed data for 42 ops/,
+ qr/Parsed data for 46 ops/,
'Parse data for the correct number of ops'
);

0 comments on commit a2cb0ea

Please sign in to comment.