Term* migrate_term_pointer(Term* term, Migration* migration) { if (!term_is_child_of_block(term, migration->oldBlock)) return term; Value relativeName; get_relative_name_as_list(term, migration->oldBlock, &relativeName); return find_from_relative_name_list(&relativeName, migration->newBlock); }
bool term_accesses_input_from_inside_loop(Term* term, Term* input) { // Returns true if 1) "term" is inside a loop and 2) "input" is not inside that loop. // In other words, "term" will access "input"'s value multiple times. // (once per iteration) Block* enclosingLoop = find_enclosing_loop(term->owningBlock); if (enclosingLoop == NULL) return false; return !term_is_child_of_block(input, enclosingLoop); }