Mercurial > hg > octave-lyh
changeset 14965:f2117a963c54
Place grab/release for assignments
* src/pt-jit.cc (jit_instruction::do_construct_ssa):
Only do replacement if variable is defined.
(jit_convert::jit_convert_llvm::visit): Place grab/release.
* src/pt-jit.h (jit_typeinfo::get_grab): New function.
(jit_assign_base::jit_assign_base): Added another argument to overload.
(jit_assign::jit_assign): Keep track of previous variable value.
author | Max Brister <max@2bass.com> |
---|---|
date | Thu, 21 Jun 2012 17:37:36 -0500 |
parents | 434ffa574c78 |
children | b7b647bc4b90 |
files | src/pt-jit.cc src/pt-jit.h |
diffstat | 2 files changed, 33 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pt-jit.cc +++ b/src/pt-jit.cc @@ -1052,7 +1052,7 @@ { jit_value *arg = argument (i); jit_variable *var = dynamic_cast<jit_variable *> (arg); - if (var) + if (var && var->has_top ()) stash_argument (i, var->top ()); } } @@ -2726,6 +2726,24 @@ jit_convert::convert_llvm::visit (jit_assign& assign) { assign.stash_llvm (assign.src ()->to_llvm ()); + + jit_value *new_value = assign.src (); + if (isa<jit_assign_base> (new_value)) // only grab non-temporaries + { + const jit_function::overload& ol + = jit_typeinfo::get_grab (new_value->type ()); + if (ol.function) + create_call (ol, new_value); + } + + jit_value *overwrite = assign.overwrite (); + if (isa<jit_assign_base> (overwrite)) + { + const jit_function::overload& ol + = jit_typeinfo::get_release (overwrite->type ()); + if (ol.function) + create_call (ol, overwrite); + } } void
--- a/src/pt-jit.h +++ b/src/pt-jit.h @@ -453,6 +453,11 @@ static const jit_function& grab (void) { return instance->grab_fn; } + static const jit_function::overload& get_grab (jit_type *type) + { + return instance->grab_fn.get_overload (type); + } + static const jit_function& release (void) { return instance->release_fn; @@ -1519,8 +1524,8 @@ jit_assign_base (jit_variable *adest, size_t npred) : jit_instruction (npred), mdest (adest) {} - jit_assign_base (jit_variable *adest, jit_value *arg0) - : jit_instruction (arg0), mdest (adest) {} + jit_assign_base (jit_variable *adest, jit_value *arg0, jit_value *arg1) + : jit_instruction (arg0, arg1), mdest (adest) {} jit_variable *dest (void) const { return mdest; } @@ -1551,11 +1556,16 @@ { public: jit_assign (jit_variable *adest, jit_value *asrc) - : jit_assign_base (adest, asrc) {} + : jit_assign_base (adest, adest, asrc) {} + + jit_value *overwrite (void) const + { + return argument (0); + } jit_value *src (void) const { - return argument (0); + return argument (1); } virtual bool infer (void)