changeset 14922:2e6f83b2f2b9

Cleanup of some type inference functions * src/pt-jit.h (jit_typeinfo::tunion): Renamed to jit_typeinfo::join. (jit_typeinfo::join): New function. (jit_typeinfo::difference): Removed. (jit_phi::infer): Rename tunoin -> join. * src/pt-jit.cc (jit_call::infer): Simplified.
author Max Brister <max@2bass.com>
date Sun, 27 May 2012 22:57:55 -0500
parents 972890bc9f38
children 168cb10bb9c5
files src/pt-jit.cc src/pt-jit.h
diffstat 2 files changed, 19 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/pt-jit.cc	Sat May 26 20:38:17 2012 -0500
+++ b/src/pt-jit.cc	Sun May 27 22:57:55 2012 -0500
@@ -714,24 +714,26 @@
 bool
 jit_call::infer (void)
 {
-  // FIXME explain algorithm
-  jit_type *current = type ();
+  // FIXME: explain algorithm
   for (size_t i = 0; i < argument_count (); ++i)
     {
-      jit_type *arg_type = argument_type (i);
-      jit_type *todo = jit_typeinfo::difference (arg_type, already_infered[i]);
-      if (todo)
-        {
-          already_infered[i] = todo;
-          jit_type *fresult = mfunction.get_result (already_infered);
-          current = jit_typeinfo::tunion (current, fresult);
-          already_infered[i] = arg_type;
-        }
+      already_infered[i] = argument_type (i);
+      if (! already_infered[i])
+        return false;
     }
 
-  if (current != type ())
+  jit_type *infered = mfunction.get_result (already_infered);
+  if (! infered && use_count ())
     {
-      stash_type (current);
+      std::stringstream ss;
+      ss << "Missing overload in type inference for ";
+      print (ss, 0);
+      fail (ss.str ());
+    }
+
+  if (infered != type ())
+    {
+      stash_type (infered);
       return true;
     }
 
--- a/src/pt-jit.h	Sat May 26 20:38:17 2012 -0500
+++ b/src/pt-jit.h	Sun May 27 22:57:55 2012 -0500
@@ -253,14 +253,9 @@
 public:
   static void initialize (llvm::Module *m, llvm::ExecutionEngine *e);
 
-  static jit_type *tunion (jit_type *lhs, jit_type *rhs)
+  static jit_type *join (jit_type *lhs, jit_type *rhs)
   {
-    return instance->do_union (lhs, rhs);
-  }
-
-  static jit_type *difference (jit_type *lhs, jit_type *rhs)
-  {
-    return instance->do_difference (lhs, rhs);
+    return instance->do_join (lhs, rhs);
   }
 
   static jit_type *get_any (void) { return instance->any; }
@@ -329,10 +324,8 @@
   jit_typeinfo (llvm::Module *m, llvm::ExecutionEngine *e);
 
   // FIXME: Do these methods really need to be in jit_typeinfo?
-  jit_type *do_union (jit_type *lhs, jit_type *rhs)
+  jit_type *do_join (jit_type *lhs, jit_type *rhs)
   {
-    // FIXME: Actually introduce a union type
-
     // empty case
     if (! lhs)
       return rhs;
@@ -967,7 +960,7 @@
   {
     jit_type *infered = 0;
     for (size_t i = 0; i < argument_count (); ++i)
-      infered = jit_typeinfo::tunion (infered, argument_type (i));
+      infered = jit_typeinfo::join (infered, argument_type (i));
 
     if (infered != type ())
       {