# HG changeset patch # User Max Brister # Date 1338177475 18000 # Node ID 2e6f83b2f2b930e1b2bcefe723171be63a61af07 # Parent 972890bc9f3813a6e4127c23383f6fc08c39d43f 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. diff --git a/src/pt-jit.cc b/src/pt-jit.cc --- a/src/pt-jit.cc +++ b/src/pt-jit.cc @@ -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; } diff --git a/src/pt-jit.h b/src/pt-jit.h --- a/src/pt-jit.h +++ b/src/pt-jit.h @@ -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 ()) {