comparison src/interp-core/jit-ir.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 0464e3ceb85b
comparison
equal deleted inserted replaced
15101:2512448babac 15102:d29f2583cf7b
597 597
598 return false; 598 return false;
599 } 599 }
600 600
601 // -------------------- jit_magic_end -------------------- 601 // -------------------- jit_magic_end --------------------
602 jit_magic_end::context::context (jit_convert& convert, jit_value *avalue,
603 size_t aindex, size_t acount)
604 : value (avalue), index (convert.create<jit_const_index> (aindex)),
605 count (convert.create<jit_const_index> (acount))
606 {}
607
602 jit_magic_end::jit_magic_end (const std::vector<context>& full_context) 608 jit_magic_end::jit_magic_end (const std::vector<context>& full_context)
603 { 609 : contexts (full_context)
604 // for now we only support end in 1 dimensional indexing 610 {
605 resize_arguments (full_context.size ()); 611 resize_arguments (contexts.size ());
606 612
607 size_t i; 613 size_t i;
608 std::vector<context>::const_iterator iter; 614 std::vector<context>::const_iterator iter;
609 for (iter = full_context.begin (), i = 0; iter != full_context.end (); ++iter, 615 for (iter = contexts.begin (), i = 0; iter != contexts.end (); ++iter, ++i)
610 ++i) 616 stash_argument (i, iter->value);
611 { 617 }
612 if (iter->count != 1) 618
613 throw jit_fail_exception ("end is only supported in linear contexts"); 619 jit_magic_end::context
614 stash_argument (i, iter->value); 620 jit_magic_end::resolve_context (void) const
615 } 621 {
622 // FIXME: We need to have a way of marking functions so we can skip them here
623 context ret = contexts[0];
624 ret.value = argument (0);
625 return ret;
626 }
627
628 bool
629 jit_magic_end::infer (void)
630 {
631 jit_type *new_type = overload ().result ();
632 if (new_type != type ())
633 {
634 stash_type (new_type);
635 return true;
636 }
637
638 return false;
639 }
640
641 std::ostream&
642 jit_magic_end::print (std::ostream& os, size_t indent) const
643 {
644 context ctx = resolve_context ();
645 short_print (print_indent (os, indent)) << " (" << *ctx.value << ", ";
646 return os << *ctx.index << ", " << *ctx.count << ")";
616 } 647 }
617 648
618 const jit_function& 649 const jit_function&
619 jit_magic_end::overload () const 650 jit_magic_end::overload () const
620 { 651 {
621 jit_value *ctx = resolve_context (); 652 const context& ctx = resolve_context ();
622 if (ctx) 653 return jit_typeinfo::end (ctx.value, ctx.index, ctx.count);
623 return jit_typeinfo::end (ctx->type ());
624
625 static jit_function null_ret;
626 return null_ret;
627 }
628
629 jit_value *
630 jit_magic_end::resolve_context (void) const
631 {
632 // FIXME: We need to have a way of marking functions so we can skip them here
633 return argument_count () ? argument (0) : 0;
634 }
635
636 bool
637 jit_magic_end::infer (void)
638 {
639 jit_type *new_type = overload ().result ();
640 if (new_type != type ())
641 {
642 stash_type (new_type);
643 return true;
644 }
645
646 return false;
647 } 654 }
648 655
649 #endif 656 #endif