changeset 15109:28ffdc42b550 classdef

maint: periodic merge of default to classdef
author John W. Eaton <jwe@octave.org>
date Sun, 05 Aug 2012 09:20:57 -0400
parents 7c7b9ea23a86 (current diff) 03381a36f70d (diff)
children 947cf10c94da
files src/Makefile.am src/octave-value/module.mk src/parse-tree/module.mk
diffstat 16 files changed, 144 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/common.mk
+++ b/build-aux/common.mk
@@ -454,6 +454,7 @@
 define do_subst_config_vals
 echo "making $@ from $<"
 $(SED) < $< \
+  -e "s|%NO_EDIT_WARNING%|DO NOT EDIT!  Generated automatically from $(<F) by Make.|" \
   -e "s|%NO_OCT_FILE_STRIP%|${NO_OCT_FILE_STRIP}|" \
   -e "s|%OCTAVE_BINDIR%|\"${bindir}\"|" \
   -e "s|%OCTAVE_CONF_ALL_CFLAGS%|\"${ALL_CFLAGS}\"|" \
@@ -606,6 +607,7 @@
 define do_subst_default_vals
 echo "making $@ from $<"
 $(SED) < $< > $@-t \
+  -e "s|%NO_EDIT_WARNING%|DO NOT EDIT!  Generated automatically from $(<F) by Make.|" \
   -e "s|%OCTAVE_ARCHLIBDIR%|\"${archlibdir}\"|" \
   -e "s|%OCTAVE_BINDIR%|\"${bindir}\"|" \
   -e "s|%OCTAVE_CANONICAL_HOST_TYPE%|\"${canonical_host_type}\"|" \
--- a/scripts/image/image.m
+++ b/scripts/image/image.m
@@ -246,6 +246,3 @@
 %! hold off;
 %! title ("line, image, line, image, line");
 
-## Test input validation
-%!error <can not be complex> image (1+i)
-%!error <matrix is empty> image ([])
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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 $(<F) by Make.|" \
 	  -e "s|%OCTAVE_API_VERSION_NUMBER%|${OCTAVE_API_VERSION_NUMBER}|" \
 	  -e "s|%OCTAVE_API_VERSION%|\"${OCTAVE_API_VERSION}\"|" \
 	  -e "s|%OCTAVE_COPYRIGHT%|\"${OCTAVE_COPYRIGHT}\"|" \
--- a/src/interp-core/jit-ir.cc
+++ b/src/interp-core/jit-ir.cc
@@ -599,38 +599,30 @@
 }
 
 // -------------------- jit_magic_end --------------------
+jit_magic_end::context::context (jit_convert& convert, jit_value *avalue,
+                                 size_t aindex, size_t acount)
+  : value (avalue), index (convert.create<jit_const_index> (aindex)),
+    count (convert.create<jit_const_index> (acount))
+{}
+
 jit_magic_end::jit_magic_end (const std::vector<context>& 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<context>::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
--- a/src/interp-core/jit-ir.h
+++ b/src/interp-core/jit-ir.h
@@ -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<context>& 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<context> contexts;
 };
 
 class
--- a/src/interp-core/jit-typeinfo.cc
+++ b/src/interp-core/jit-typeinfo.cc
@@ -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<jit_const_index *> (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
--- a/src/interp-core/jit-typeinfo.h
+++ b/src/interp-core/jit-typeinfo.h
@@ -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
--- a/src/interp-core/module.mk
+++ b/src/interp-core/module.mk
@@ -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 $(<F) by Make.|" \
 	  -e "s|%OCTAVE_IDX_TYPE%|${OCTAVE_IDX_TYPE}|" > $@-t
 	mv $@-t $@
 
+noinst_LTLIBRARIES += interp-core/libinterp-core.la
+
+interp_core_libinterp_core_la_SOURCES = $(INTERP_CORE_SRC)
--- a/src/interp-core/mxarray.in.h
+++ b/src/interp-core/mxarray.in.h
@@ -1,4 +1,4 @@
-// DO NOT EDIT!  Generated automatically from mxarray.in.h by configure
+// %NO_EDIT_WARNING%
 /*
 
 Copyright (C) 2001-2012 Paul Kienzle
--- 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);
+
 */
--- a/src/interpfcn/defaults.in.h
+++ b/src/interpfcn/defaults.in.h
@@ -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
--- a/src/interpfcn/module.mk
+++ b/src/interpfcn/module.mk
@@ -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)
--- a/src/oct-conf.in.h
+++ b/src/oct-conf.in.h
@@ -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
--- a/src/octave-value/module.mk
+++ b/src/octave-value/module.mk
@@ -126,3 +126,6 @@
   $(OV_INTTYPE_SRC) \
   $(OV_SPARSE_SRC)
 
+noinst_LTLIBRARIES += octave-value/liboctave-value.la
+
+octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC)
--- a/src/parse-tree/module.mk
+++ b/src/parse-tree/module.mk
@@ -46,7 +46,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 \
@@ -78,7 +78,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.
 
@@ -92,3 +92,6 @@
 	mv $@-t $@
 	rm -f $@-t1
 
+noinst_LTLIBRARIES += parse-tree/libparse-tree.la
+
+parse_tree_libparse_tree_la_SOURCES = $(PARSE_TREE_SRC)
--- a/src/version.in.h
+++ b/src/version.in.h
@@ -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