diff src/interp-core/pt-jit.cc @ 15102:d29f2583cf7b

Support end in multi indexing in JIT * src/interp-core/jit-ir.cc (jit_magic_end::context::context): New function. (jit_magic_end::jit_magic_end): Take context vector as argument. (jit_magic_end::resolve_context): Return a context. (jit_magic_end::print): Prettify output. (jit_magic_end::overload): Use context. * src/interp-core/jit-ir.h (jit_magic_end::context::context, jit_magic_end::print): Move implementation to src/jit-ir.cc. (jit_magic_end::short_print): Prettify output. (jit_magic_end::resolve_context): Return a context. * src/interp-core/jit-typeinfo.cc (octave_jit_end_matrix): New function. (jit_typeinfo::jit_typeinfo): Initilaize end_fn and end1_fn. (jit_typeinfo::do_end): New function. (jit_typeinfo::new_type): Moved location in file. * src/interp-core/jit-typeinfo.h (jit_typeinfo::end): Take index and count arguments. (jit_typeinfo::do_end): New declaration. * src/interp-core/pt-jit.cc (jit_convert::resolve): Pass extra argument to context constructor. (jit_convert::convert_llvm::visit): New arguments to jit_magic_end overload.
author Max Brister <max@2bass.com>
date Sat, 04 Aug 2012 00:19:07 -0500
parents 909a2797935b
children bd6bb87e2bea
line wrap: on
line diff
--- a/src/interp-core/pt-jit.cc
+++ b/src/interp-core/pt-jit.cc
@@ -842,7 +842,7 @@
       unwind_protect prot;
       prot.add_method (&end_context,
                        &std::vector<jit_magic_end::context>::pop_back);
-      end_context.push_back (jit_magic_end::context (object, idx, narg));
+      end_context.push_back (jit_magic_end::context (*this, object, idx, narg));
       call_args[idx + 1] = visit (*iter);
     }
 
@@ -1498,7 +1498,9 @@
 jit_convert::convert_llvm::visit (jit_magic_end& me)
 {
   const jit_function& ol = me.overload ();
-  llvm::Value *ret = ol.call (builder, me.resolve_context ());
+
+  jit_magic_end::context ctx = me.resolve_context ();
+  llvm::Value *ret = ol.call (builder, ctx.value, ctx.index, ctx.count);
   me.stash_llvm (ret);
 }
 
@@ -1927,4 +1929,15 @@
 %! endwhile
 %! assert (result, 0);
 
+%!test
+%! m = zeros (2, 1001);
+%! for i=1:1001
+%!   m(end, i) = i;
+%!   m(end - 1, end - i + 1) = i;
+%! endfor
+%! m2 = zeros (2, 1001);
+%! m2(1, :) = fliplr (1:1001);
+%! m2(2, :) = 1:1001;
+%! assert (m, m2);
+
 */