diff libinterp/interp-core/jit-typeinfo.h @ 15893:1f076c40c133

Do not use vectorized llvm commands for complex numbers * jit-typeinfo.cc (octave_jit_complex_mul): New function. (jit_typeinfo::jit_typeinfo): Implement complex numbers using an llvm array and use create_internal/create_external. (jit_typeinfo::complex_real, jit_typeinfo::complex_imag, jit_typeinfo::pack_complex, jit_typeinfo::unpack_complex): Implement complex numbers using an llvm array. (jit_typeinfo::add_binary_op, jit_typeinfo::add_binary_icmp, jit_typeinfo::add_binary_fcmp, jit_typeinfo::create_identity, jit_typeinfo::register_intrinsic, jit_typeinfo::register_generic, jit_typeinfo::mirror_binary): Use create_internal/create_external. (jit_typeinfo::type_of): Correctly determine complex type. * jit-typeinfo.h (jit_typeinfo::create_complex, jit_typeinfo::create_internal, jit_typeinfo::create_external): New function. * pt-jit.cc (jit_convert_llvm::visit): Create an array for complex constants.
author Max Brister <max@2bass.com>
date Thu, 03 Jan 2013 12:35:10 -0700
parents 44272909d926
children e2de3c8882be
line wrap: on
line diff
--- a/libinterp/interp-core/jit-typeinfo.h	Thu Jan 03 13:24:14 2013 -0500
+++ b/libinterp/interp-core/jit-typeinfo.h	Thu Jan 03 12:35:10 2013 -0700
@@ -586,6 +586,11 @@
   {
     return instance->create_undef_fn;
   }
+
+  static llvm::Value *create_complex (llvm::Value *real, llvm::Value *imag)
+  {
+    return instance->complex_new (real, imag);
+  }
 private:
   jit_typeinfo (llvm::Module *m, llvm::ExecutionEngine *e);
 
@@ -673,15 +678,53 @@
 
   void add_binary_fcmp (jit_type *ty, int op, int llvm_op);
 
+  // create a function with an external calling convention
+  // forces the function pointer to be specified
+  template <typename T>
+  jit_function create_external (llvm::ExecutionEngine *ee, T fn,
+                                const llvm::Twine& name, jit_type *ret,
+                                const std::vector<jit_type *>& args
+                                = std::vector<jit_type *> ())
+  {
+    jit_function retval = create_function (jit_convention::external, name, ret,
+                                           args);
+    retval.add_mapping (ee, fn);
+    return retval;
+  }
+
+#define JIT_PARAM_ARGS llvm::ExecutionEngine *ee, T fn,     \
+    const llvm::Twine& name, jit_type *ret,
+#define JIT_PARAMS ee, fn, name, ret,
+#define CREATE_FUNCTION(N) JIT_EXPAND(template <typename T> jit_function, \
+                                      create_external,                  \
+                                      jit_type *, /* empty */, N)
+
+  CREATE_FUNCTION(1);
+  CREATE_FUNCTION(2);
+  CREATE_FUNCTION(3);
+  CREATE_FUNCTION(4);
+
+#undef JIT_PARAM_ARGS
+#undef JIT_PARAMS
+#undef CREATE_FUNCTION
+
+  // use create_external or create_internal directly
   jit_function create_function (jit_convention::type cc,
                                 const llvm::Twine& name, jit_type *ret,
                                 const std::vector<jit_type *>& args
                                 = std::vector<jit_type *> ());
 
-#define JIT_PARAM_ARGS jit_convention::type cc, const llvm::Twine& name, \
-    jit_type *ret,
-#define JIT_PARAMS cc, name, ret,
-#define CREATE_FUNCTION(N) JIT_EXPAND(jit_function, create_function,    \
+  // create an internal calling convention (a function defined in llvm)
+  jit_function create_internal (const llvm::Twine& name, jit_type *ret,
+                                const std::vector<jit_type *>& args
+                                = std::vector<jit_type *> ())
+  {
+    return create_function (jit_convention::internal, name, ret, args);
+  }
+
+#define JIT_PARAM_ARGS const llvm::Twine& name, jit_type *ret,
+#define JIT_PARAMS name, ret,
+#define CREATE_FUNCTION(N) JIT_EXPAND(jit_function, create_internal,    \
                                       jit_type *, /* empty */, N)
 
   CREATE_FUNCTION(1);