changeset 24248:af23baa0a9da

jit: Move join() outside of class jit_typeinfo, renamed to jit_type_join()
author Julien Bect <jbect@users.sourceforge.net>
date Sat, 23 Sep 2017 19:27:49 +0200
parents 4e045a476598
children 790b4389cfb4
files libinterp/parse-tree/jit-ir.cc libinterp/parse-tree/jit-typeinfo.cc libinterp/parse-tree/jit-typeinfo.h
diffstat 3 files changed, 36 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/jit-ir.cc	Wed Aug 09 08:32:06 2017 +0200
+++ b/libinterp/parse-tree/jit-ir.cc	Sat Sep 23 19:27:49 2017 +0200
@@ -651,7 +651,7 @@
       {
         jit_block *inc = incomming (i);
         if (inc->branch_alive (p))
-          infered = jit_typeinfo::join (infered, argument_type (i));
+          infered = jit_type_join (infered, argument_type (i));
       }
 
     if (infered != type ())
--- a/libinterp/parse-tree/jit-typeinfo.cc	Wed Aug 09 08:32:06 2017 +0200
+++ b/libinterp/parse-tree/jit-typeinfo.cc	Sat Sep 23 19:27:49 2017 +0200
@@ -526,6 +526,37 @@
     return llvm_type ? llvm_type->getPointerTo () : nullptr;
   }
 
+jit_type*
+jit_type_join (jit_type *lhs, jit_type *rhs)
+{
+  // empty case
+  if (! lhs)
+    return rhs;
+
+  if (! rhs)
+    return lhs;
+
+  // check for a shared parent
+  while (lhs != rhs)
+    {
+      if (lhs->depth () > rhs->depth ())
+        lhs = lhs->parent ();
+      else if (lhs->depth () < rhs->depth ())
+        rhs = rhs->parent ();
+      else
+        {
+          // we MUST have depth > 0 as any is the base type of everything
+          do
+            {
+              lhs = lhs->parent ();
+              rhs = rhs->parent ();
+            }
+          while (lhs != rhs);
+        }
+    }
+  return lhs;
+}
+
   // -------------------- jit_function --------------------
   jit_function::jit_function () : module (0), llvm_function (0), mresult (0),
                                   call_conv (jit_convention::length),
--- a/libinterp/parse-tree/jit-typeinfo.h	Wed Aug 09 08:32:06 2017 +0200
+++ b/libinterp/parse-tree/jit-typeinfo.h	Sat Sep 23 19:27:49 2017 +0200
@@ -219,6 +219,10 @@
   // seperate print function to allow easy printing if type is null
   std::ostream& jit_print (std::ostream& os, jit_type *atype);
 
+// Find common type
+jit_type* jit_type_join (jit_type *lhs, jit_type *rhs);
+
+
   class jit_value;
 
   // An abstraction for calling llvm functions with jit_values.  Deals with
@@ -483,10 +487,6 @@
   public:
     static void initialize (llvm::Module *m, llvm::ExecutionEngine *e);
 
-    static jit_type * join (jit_type *lhs, jit_type *rhs)
-    {
-      return instance->do_join (lhs, rhs);
-    }
 
     static jit_type * get_any (void) { return instance->any; }
 
@@ -635,38 +635,6 @@
   private:
     jit_typeinfo (llvm::Module *m, llvm::ExecutionEngine *e);
 
-    // FIXME: Do these methods really need to be in jit_typeinfo?
-    jit_type * do_join (jit_type *lhs, jit_type *rhs)
-    {
-      // empty case
-      if (! lhs)
-        return rhs;
-
-      if (! rhs)
-        return lhs;
-
-      // check for a shared parent
-      while (lhs != rhs)
-        {
-          if (lhs->depth () > rhs->depth ())
-            lhs = lhs->parent ();
-          else if (lhs->depth () < rhs->depth ())
-            rhs = rhs->parent ();
-          else
-            {
-              // we MUST have depth > 0 as any is the base type of everything
-              do
-                {
-                  lhs = lhs->parent ();
-                  rhs = rhs->parent ();
-                }
-              while (lhs != rhs);
-            }
-        }
-
-      return lhs;
-    }
-
     jit_type * do_difference (jit_type *lhs, jit_type *)
     {
       // FIXME: Maybe we can do something smarter?