Mercurial > hg > octave-terminal
changeset 15148:1b2fbc30e4e7
Postfix increment and decrement operations in JIT
* jit-typeinfo.cc (jit_typeinfo::jit_typeinfo): Initialize copy operation.
* jit-typeinfo.h (jit_typeinfo::copy): New function.
* pt-jit.cc (jit_convert::visit_postfix_expression): Implement for ++ and --.
author | Max Brister <max@2bass.com> |
---|---|
date | Fri, 10 Aug 2012 16:41:07 -0500 |
parents | 98a65d9e426f |
children | 62a35ae7d6a2 |
files | src/interp-core/jit-typeinfo.cc src/interp-core/jit-typeinfo.h src/interp-core/pt-jit.cc |
diffstat | 3 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/interp-core/jit-typeinfo.cc +++ b/src/interp-core/jit-typeinfo.cc @@ -1159,6 +1159,10 @@ fn.add_mapping (engine, &octave_jit_release_matrix); release_fn.add_overload (fn); + // copy + copy_fn.stash_name ("copy"); + copy_fn.add_overload (create_identity (scalar)); + // now for binary scalar operations add_binary_op (scalar, octave_value::op_add, llvm::Instruction::FAdd); add_binary_op (scalar, octave_value::op_sub, llvm::Instruction::FSub);
--- a/src/interp-core/jit-typeinfo.h +++ b/src/interp-core/jit-typeinfo.h @@ -498,6 +498,11 @@ return instance->release_fn.overload (type); } + static const jit_operation& copy (void) + { + return instance->copy_fn; + } + static const jit_operation& print_value (void) { return instance->print_fn; @@ -751,6 +756,7 @@ std::vector<jit_operation> unary_ops; jit_operation grab_fn; jit_operation release_fn; + jit_operation copy_fn; jit_operation print_fn; jit_operation for_init_fn; jit_operation for_check_fn;
--- a/src/interp-core/pt-jit.cc +++ b/src/interp-core/pt-jit.cc @@ -592,9 +592,9 @@ if (etype == octave_value::op_incr || etype == octave_value::op_decr) { - // FIXME: Somehow copy operandv - // do_assign (operand, operandv); - throw jit_fail_exception ("Postfix ++ and -- not yet supported"); + jit_value *ret = create_checked (&jit_typeinfo::copy, operandv); + do_assign (operand, result); + result = ret; } } @@ -1991,5 +1991,12 @@ %! endwhile %! assert (i == 10); %! assert (a == 10); +%!test +%! i = 0; +%! while i < 10 +%! a = i++; +%! endwhile +%! assert (i == 10); +%! assert (a == 9); */