# HG changeset patch # User Julien Bect # Date 1506187669 -7200 # Node ID af23baa0a9da061562af82b11f8e9c106759d1dc # Parent 4e045a47659889210900220ef89ff5a73fef193b jit: Move join() outside of class jit_typeinfo, renamed to jit_type_join() diff -r 4e045a476598 -r af23baa0a9da libinterp/parse-tree/jit-ir.cc --- 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 ()) diff -r 4e045a476598 -r af23baa0a9da libinterp/parse-tree/jit-typeinfo.cc --- 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), diff -r 4e045a476598 -r af23baa0a9da libinterp/parse-tree/jit-typeinfo.h --- 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?