# HG changeset patch # User John W. Eaton # Date 1344172929 14400 # Node ID 159f800d1dff2edd7af0338d4ad4384554fc9644 # Parent 59175df7dcf64fd0cab12aef0b426ce8ced36692# Parent 03381a36f70d2a786b619460e4614d1a722e2ee3 maint: periodic merge of default to gui diff -r 59175df7dcf6 -r 159f800d1dff build-aux/common.mk --- a/build-aux/common.mk Sat Aug 04 20:22:26 2012 +0200 +++ b/build-aux/common.mk Sun Aug 05 09:22:09 2012 -0400 @@ -454,6 +454,7 @@ define do_subst_config_vals echo "making $@ from $<" $(SED) < $< \ + -e "s|%NO_EDIT_WARNING%|DO NOT EDIT! Generated automatically from $( $@-t \ + -e "s|%NO_EDIT_WARNING%|DO NOT EDIT! Generated automatically from $( image (1+i) -%!error image ([]) diff -r 59175df7dcf6 -r 159f800d1dff src/Makefile.am --- a/src/Makefile.am Sat Aug 04 20:22:26 2012 +0200 +++ b/src/Makefile.am Sun Aug 05 09:22:09 2012 -0400 @@ -172,7 +172,7 @@ endif liboctinterp_la_SOURCES = \ - $(DIST_SRC) \ + octave.cc \ $(OPERATORS_SRC) \ $(TEMPLATE_INST_SRC) @@ -192,6 +192,11 @@ include link-deps.mk liboctinterp_la_LIBADD = \ + octave-value/liboctave-value.la \ + parse-tree/libparse-tree.la \ + interp-core/libinterp-core.la \ + interpfcn/libinterpfcn.la \ + corefcn/libcorefcn.la \ ../liboctave/liboctave.la \ ../libcruft/libcruft.la \ $(LIBOCTINTERP_LINK_DEPS) @@ -264,6 +269,7 @@ version.h: version.in.h Makefile $(SED) < $< \ + -e "s|%NO_EDIT_WARNING%|DO NOT EDIT! Generated automatically from $( (aindex)), + count (convert.create (acount)) +{} + jit_magic_end::jit_magic_end (const std::vector& full_context) + : contexts (full_context) { - // for now we only support end in 1 dimensional indexing - resize_arguments (full_context.size ()); + resize_arguments (contexts.size ()); size_t i; std::vector::const_iterator iter; - for (iter = full_context.begin (), i = 0; iter != full_context.end (); ++iter, - ++i) - { - if (iter->count != 1) - throw jit_fail_exception ("end is only supported in linear contexts"); - stash_argument (i, iter->value); - } + for (iter = contexts.begin (), i = 0; iter != contexts.end (); ++iter, ++i) + stash_argument (i, iter->value); } -const jit_function& -jit_magic_end::overload () const -{ - jit_value *ctx = resolve_context (); - if (ctx) - return jit_typeinfo::end (ctx->type ()); - - static jit_function null_ret; - return null_ret; -} - -jit_value * +jit_magic_end::context jit_magic_end::resolve_context (void) const { // FIXME: We need to have a way of marking functions so we can skip them here - return argument_count () ? argument (0) : 0; + context ret = contexts[0]; + ret.value = argument (0); + return ret; } bool @@ -646,4 +638,19 @@ return false; } +std::ostream& +jit_magic_end::print (std::ostream& os, size_t indent) const +{ + context ctx = resolve_context (); + short_print (print_indent (os, indent)) << " (" << *ctx.value << ", "; + return os << *ctx.index << ", " << *ctx.count << ")"; +} + +const jit_function& +jit_magic_end::overload () const +{ + const context& ctx = resolve_context (); + return jit_typeinfo::end (ctx.value, ctx.index, ctx.count); +} + #endif diff -r 59175df7dcf6 -r 159f800d1dff src/interp-core/jit-ir.h --- a/src/interp-core/jit-ir.h Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interp-core/jit-ir.h Sun Aug 05 09:22:09 2012 -0400 @@ -1162,34 +1162,32 @@ context (void) : value (0), index (0), count (0) {} - context (jit_value *avalue, size_t aindex, size_t acount) - : value (avalue), index (aindex), count (acount) - {} + context (jit_convert& convert, jit_value *avalue, size_t aindex, + size_t acount); jit_value *value; - size_t index; - size_t count; + jit_const_index *index; + jit_const_index *count; }; jit_magic_end (const std::vector& full_context); + virtual bool infer (void); + const jit_function& overload () const; - jit_value *resolve_context (void) const; + virtual std::ostream& print (std::ostream& os, size_t indent = 0) const; - virtual bool infer (void); + context resolve_context (void) const; virtual std::ostream& short_print (std::ostream& os) const { - return os << "magic_end"; - } - - virtual std::ostream& print (std::ostream& os, size_t indent = 0) const - { - return short_print (print_indent (os, indent)); + return os << "magic_end" << "#" << id (); } JIT_VALUE_ACCEPT; +private: + std::vector contexts; }; class diff -r 59175df7dcf6 -r 159f800d1dff src/interp-core/jit-typeinfo.cc --- a/src/interp-core/jit-typeinfo.cc Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interp-core/jit-typeinfo.cc Sun Aug 05 09:22:09 2012 -0400 @@ -343,6 +343,29 @@ result->update (array); } +extern "C" double +octave_jit_end_matrix (jit_matrix *mat, octave_idx_type idx, + octave_idx_type count) +{ + octave_idx_type ndim = mat->dimensions[-1]; + if (ndim == count) + return mat->dimensions[idx]; + else if (ndim > count) + { + if (idx == count - 1) + { + double ret = mat->dimensions[idx]; + for (octave_idx_type i = idx + 1; i < ndim; ++i) + ret *= mat->dimensions[idx]; + return ret; + } + + return mat->dimensions[idx]; + } + else // ndim < count + return idx < ndim ? mat->dimensions[idx] : 1; +} + extern "C" Complex octave_jit_complex_div (Complex lhs, Complex rhs) { @@ -1626,9 +1649,9 @@ fn.mark_can_error (); paren_subsasgn_fn.add_overload (fn); - end_fn.stash_name ("end"); - fn = create_function (jit_convention::internal, "octave_jit_end_matrix", - scalar, matrix); + end1_fn.stash_name ("end1"); + fn = create_function (jit_convention::internal, "octave_jit_end1_matrix", + scalar, matrix, index, index); body = fn.new_block (); builder.SetInsertPoint (body); { @@ -1636,6 +1659,11 @@ llvm::Value *ret = builder.CreateExtractValue (mat, 2); fn.do_return (builder, builder.CreateSIToFP (ret, scalar_t)); } + end1_fn.add_overload (fn); + + end_fn.stash_name ("end"); + fn = create_function (jit_convention::external, "octave_jit_end_matrix", + scalar, matrix, index, index); end_fn.add_overload (fn); casts[any->type_id ()].stash_name ("(any)"); @@ -1760,6 +1788,25 @@ } } +const jit_function& +jit_typeinfo::do_end (jit_value *value, jit_value *idx, jit_value *count) +{ + jit_const_index *ccount = dynamic_cast (count); + if (ccount && ccount->value () == 1) + return end1_fn.overload (value->type (), idx->type (), count->type ()); + + return end_fn.overload (value->type (), idx->type (), count->type ()); +} + +jit_type* +jit_typeinfo::new_type (const std::string& name, jit_type *parent, + llvm::Type *llvm_type) +{ + jit_type *ret = new jit_type (name, parent, llvm_type, next_id++); + id_to_type.push_back (ret); + return ret; +} + void jit_typeinfo::add_print (jit_type *ty, void *fptr) { @@ -2059,13 +2106,4 @@ return get_any (); } -jit_type* -jit_typeinfo::new_type (const std::string& name, jit_type *parent, - llvm::Type *llvm_type) -{ - jit_type *ret = new jit_type (name, parent, llvm_type, next_id++); - id_to_type.push_back (ret); - return ret; -} - #endif diff -r 59175df7dcf6 -r 159f800d1dff src/interp-core/jit-typeinfo.h --- a/src/interp-core/jit-typeinfo.h Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interp-core/jit-typeinfo.h Sun Aug 05 09:22:09 2012 -0400 @@ -267,6 +267,7 @@ JIT_CALL (1); JIT_CALL (2); + JIT_CALL (3); #undef JIT_CALL #undef JIT_PARAMS @@ -549,9 +550,10 @@ return instance->end_fn; } - static const jit_function& end (jit_type *ty) + static const jit_function& end (jit_value *value, jit_value *index, + jit_value *count) { - return instance->end_fn.overload (ty); + return instance->do_end (value, index, count); } private: jit_typeinfo (llvm::Module *m, llvm::ExecutionEngine *e); @@ -619,6 +621,9 @@ return do_cast (to).overload (from); } + const jit_function& do_end (jit_value *value, jit_value *index, + jit_value *count); + jit_type *new_type (const std::string& name, jit_type *parent, llvm::Type *llvm_type); @@ -738,6 +743,7 @@ jit_operation make_range_fn; jit_paren_subsref paren_subsref_fn; jit_paren_subsasgn paren_subsasgn_fn; + jit_operation end1_fn; jit_operation end_fn; // type id -> cast function TO that type diff -r 59175df7dcf6 -r 159f800d1dff src/interp-core/module.mk --- a/src/interp-core/module.mk Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interp-core/module.mk Sun Aug 05 09:22:09 2012 -0400 @@ -23,9 +23,6 @@ interp-core/gl2ps-renderer.h \ interp-core/gl2ps.h \ interp-core/gripes.h \ - interp-core/jit-ir.h \ - interp-core/jit-typeinfo.h \ - interp-core/jit-util.h \ interp-core/ls-ascii-helper.h \ interp-core/ls-hdf5.h \ interp-core/ls-mat-ascii.h \ @@ -50,7 +47,6 @@ interp-core/oct-strstrm.h \ interp-core/oct.h \ interp-core/procstream.h \ - interp-core/pt-jit.h \ interp-core/siglist.h \ interp-core/sparse-xdiv.h \ interp-core/sparse-xpow.h \ @@ -61,7 +57,7 @@ interp-core/xnorm.h \ interp-core/xpow.h \ interp-core/zfstream.h \ - $(JIT_INCLUDES) + $(JIT_INCLUDES) JIT_SRC = \ interp-core/jit-util.cc \ @@ -84,9 +80,6 @@ interp-core/gl-render.cc \ interp-core/gl2ps-renderer.cc \ interp-core/gripes.cc \ - interp-core/jit-ir.cc \ - interp-core/jit-typeinfo.cc \ - interp-core/jit-util.cc \ interp-core/ls-ascii-helper.cc \ interp-core/ls-hdf5.cc \ interp-core/ls-mat-ascii.cc \ @@ -105,7 +98,6 @@ interp-core/oct-stream.cc \ interp-core/oct-strstrm.cc \ interp-core/procstream.cc \ - interp-core/pt-jit.cc \ interp-core/sparse-xdiv.cc \ interp-core/sparse-xpow.cc \ interp-core/txt-eng-ft.cc \ @@ -115,7 +107,7 @@ interp-core/xpow.cc \ interp-core/zfstream.cc \ $(JIT_SRC) \ - $(C_INTERP_CORE_SRC) + $(C_INTERP_CORE_SRC) ## FIXME: I don't believe this rule actually fires display.df display.lo: CPPFLAGS += $(X11_FLAGS) @@ -133,6 +125,10 @@ interp-core/mxarray.h: interp-core/mxarray.in.h Makefile $(SED) < $< \ + -e "s|%NO_EDIT_WARNING%|DO NOT EDIT! Generated automatically from $( $@-t mv $@-t $@ +noinst_LTLIBRARIES += interp-core/libinterp-core.la + +interp_core_libinterp_core_la_SOURCES = $(INTERP_CORE_SRC) diff -r 59175df7dcf6 -r 159f800d1dff src/interp-core/mxarray.in.h --- a/src/interp-core/mxarray.in.h Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interp-core/mxarray.in.h Sun Aug 05 09:22:09 2012 -0400 @@ -1,4 +1,4 @@ -// DO NOT EDIT! Generated automatically from mxarray.in.h by configure +// %NO_EDIT_WARNING% /* Copyright (C) 2001-2012 Paul Kienzle diff -r 59175df7dcf6 -r 159f800d1dff src/interp-core/pt-jit.cc --- a/src/interp-core/pt-jit.cc Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interp-core/pt-jit.cc Sun Aug 05 09:22:09 2012 -0400 @@ -842,7 +842,7 @@ unwind_protect prot; prot.add_method (&end_context, &std::vector::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); + */ diff -r 59175df7dcf6 -r 159f800d1dff src/interpfcn/defaults.in.h --- a/src/interpfcn/defaults.in.h Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interpfcn/defaults.in.h Sun Aug 05 09:22:09 2012 -0400 @@ -1,4 +1,4 @@ -// DO NOT EDIT! Generated automatically from defaults.in.h by configure +// %NO_EDIT_WARNING% /* Copyright (C) 1993-2012 John W. Eaton diff -r 59175df7dcf6 -r 159f800d1dff src/interpfcn/module.mk --- a/src/interpfcn/module.mk Sat Aug 04 20:22:26 2012 +0200 +++ b/src/interpfcn/module.mk Sun Aug 05 09:22:09 2012 -0400 @@ -71,3 +71,7 @@ __init_fltk__.lo __init_fltk__.o: \ AM_CXXFLAGS := $(filter-out $(DLL_CXXDEFS), $(AM_CXXFLAGS) $(GRAPHICS_CFLAGS)) + +noinst_LTLIBRARIES += interpfcn/libinterpfcn.la + +interpfcn_libinterpfcn_la_SOURCES = $(INTERPFCN_SRC) diff -r 59175df7dcf6 -r 159f800d1dff src/oct-conf.in.h --- a/src/oct-conf.in.h Sat Aug 04 20:22:26 2012 +0200 +++ b/src/oct-conf.in.h Sun Aug 05 09:22:09 2012 -0400 @@ -1,4 +1,4 @@ -// DO NOT EDIT! Generated automatically from oct-conf.in.h by configure +// %NO_EDIT_WARNING% /* Copyright (C) 1996-2012 John W. Eaton diff -r 59175df7dcf6 -r 159f800d1dff src/octave-value/module.mk --- a/src/octave-value/module.mk Sat Aug 04 20:22:26 2012 +0200 +++ b/src/octave-value/module.mk Sun Aug 05 09:22:09 2012 -0400 @@ -124,3 +124,6 @@ $(OV_INTTYPE_SRC) \ $(OV_SPARSE_SRC) +noinst_LTLIBRARIES += octave-value/liboctave-value.la + +octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC) diff -r 59175df7dcf6 -r 159f800d1dff src/parse-tree/module.mk --- a/src/parse-tree/module.mk Sat Aug 04 20:22:26 2012 +0200 +++ b/src/parse-tree/module.mk Sun Aug 05 09:22:09 2012 -0400 @@ -44,7 +44,7 @@ parse-tree/pt-walk.h \ parse-tree/pt.h \ parse-tree/token.h \ - $(PARSER_INCLUDES) + $(PARSER_INCLUDES) PARSE_TREE_SRC = \ parse-tree/pt-arg-list.cc \ @@ -74,7 +74,7 @@ parse-tree/pt-unop.cc \ parse-tree/pt.cc \ parse-tree/token.cc \ - $(PARSER_SRC) + $(PARSER_SRC) ## Special rules for sources which must be built before rest of compilation. @@ -88,3 +88,6 @@ mv $@-t $@ rm -f $@-t1 +noinst_LTLIBRARIES += parse-tree/libparse-tree.la + +parse_tree_libparse_tree_la_SOURCES = $(PARSE_TREE_SRC) diff -r 59175df7dcf6 -r 159f800d1dff src/version.in.h --- a/src/version.in.h Sat Aug 04 20:22:26 2012 +0200 +++ b/src/version.in.h Sun Aug 05 09:22:09 2012 -0400 @@ -1,4 +1,4 @@ -// DO NOT EDIT! Generated automatically from version.in.h by configure +// %NO_EDIT_WARNING% /* Copyright (C) 1992-2012 John W. Eaton