Skip to content

Commit

Permalink
Merge pull request #788 from nbrown/m0-c-use-ops-list
Browse files Browse the repository at this point in the history
Make it easier to modify M0 ops
  • Loading branch information
leto committed Jun 9, 2012
2 parents 655c43d + 557ee07 commit 06d08af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/m0/c/m0.h
Expand Up @@ -17,6 +17,7 @@ enum {
};

enum M0_OPS {
/* gen_c_opnames_from(m0.ops) template(' M0_UC_OP,') */
M0_NOOP,
M0_GOTO,
M0_GOTO_IF,
Expand All @@ -35,8 +36,8 @@ enum M0_OPS {
M0_ISGT_N,
M0_ISGE_I,
M0_ISGE_N,
M0_ITON,
M0_NTOI,
M0_CONVERT_I_N,
M0_CONVERT_N_I,
M0_ASHR,
M0_LSHR,
M0_SHL,
Expand All @@ -63,6 +64,7 @@ enum M0_OPS {
M0_PRINT_I,
M0_PRINT_N,
M0_EXIT
/* end_gen */
};

typedef uint64_t M0_Config[8];
Expand Down
4 changes: 2 additions & 2 deletions src/m0/c/ops.c
Expand Up @@ -518,11 +518,11 @@ run_ops( M0_Interp *interp, M0_CallFrame *cf ) {
M0_EXEC_OP(get_word, cf, ops, pc);
break;

case (M0_ITON):
case (M0_CONVERT_I_N):
M0_EXEC_OP(convert_i_n, cf, ops, pc);
break;

case (M0_NTOI):
case (M0_CONVERT_N_I):
M0_EXEC_OP(convert_n_i, cf, ops, pc);
break;

Expand Down
16 changes: 16 additions & 0 deletions tools/dev/m0_opcheck.pl
Expand Up @@ -16,6 +16,7 @@
my @m0_files = qw<
src/m0/perl5/m0_assembler.pl
src/m0/perl5/m0_interp.pl
src/m0/c/m0.h
>;


Expand All @@ -37,6 +38,21 @@
push @fixed_lines, "$op_name\n";
}
}
elsif ($line =~ /gen_c_opnames_from\(m0\.ops\)/) {
push @fixed_lines, $line;
my $template = $line;
$template =~ s/.*template\('([^']*)'\).*\*\/.*\n/$1/;
$op_gen = 'names';
foreach my $op (m0_ops()) {
my $op_name = $template;
my $uc_op = uc($op);
$op_name =~ s/UC_OP/$uc_op/;
push @fixed_lines, "$op_name\n";
}
my $last_line = pop @fixed_lines;
$last_line =~ s/,\s*$/\n/;
push @fixed_lines, $last_line
}
elsif ($op_gen) {
if ($line =~ /end_gen/) {
$op_gen = '';
Expand Down

0 comments on commit 06d08af

Please sign in to comment.