void copy_ref_info (tree new_ref, tree old_ref) { tree new_ptr_base = NULL_TREE; gcc_assert (TREE_CODE (new_ref) == MEM_REF || TREE_CODE (new_ref) == TARGET_MEM_REF); TREE_SIDE_EFFECTS (new_ref) = TREE_SIDE_EFFECTS (old_ref); TREE_THIS_VOLATILE (new_ref) = TREE_THIS_VOLATILE (old_ref); new_ptr_base = TREE_OPERAND (new_ref, 0); /* We can transfer points-to information from an old pointer or decl base to the new one. */ if (new_ptr_base && TREE_CODE (new_ptr_base) == SSA_NAME && !SSA_NAME_PTR_INFO (new_ptr_base)) { tree base = get_base_address (old_ref); if (!base) ; else if ((TREE_CODE (base) == MEM_REF || TREE_CODE (base) == TARGET_MEM_REF) && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME && SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))) { struct ptr_info_def *new_pi; unsigned int align, misalign; duplicate_ssa_name_ptr_info (new_ptr_base, SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0))); new_pi = SSA_NAME_PTR_INFO (new_ptr_base); /* We have to be careful about transferring alignment information. */ if (get_ptr_info_alignment (new_pi, &align, &misalign) && TREE_CODE (old_ref) == MEM_REF && !(TREE_CODE (new_ref) == TARGET_MEM_REF && (TMR_INDEX2 (new_ref) || (TMR_STEP (new_ref) && (TREE_INT_CST_LOW (TMR_STEP (new_ref)) < align))))) { unsigned int inc = (mem_ref_offset (old_ref) - mem_ref_offset (new_ref)).low; adjust_ptr_info_misalignment (new_pi, inc); } else mark_ptr_info_alignment_unknown (new_pi); } else if (TREE_CODE (base) == VAR_DECL || TREE_CODE (base) == PARM_DECL || TREE_CODE (base) == RESULT_DECL) { struct ptr_info_def *pi = get_ptr_info (new_ptr_base); pt_solution_set_var (&pi->pt, base); } } }
void get_address_description (tree op, struct mem_address *addr) { addr->symbol = TMR_SYMBOL (op); addr->base = TMR_BASE (op); addr->index = TMR_INDEX (op); addr->step = TMR_STEP (op); addr->offset = TMR_OFFSET (op); }
tree tree_mem_ref_addr (tree type, tree mem_ref) { tree addr; tree act_elem; tree step = TMR_STEP (mem_ref), offset = TMR_OFFSET (mem_ref); tree sym = TMR_SYMBOL (mem_ref), base = TMR_BASE (mem_ref); tree addr_base = NULL_TREE, addr_off = NULL_TREE; if (sym) addr_base = fold_convert (type, build_addr (sym, current_function_decl)); else if (base && POINTER_TYPE_P (TREE_TYPE (base))) { addr_base = fold_convert (type, base); base = NULL_TREE; } act_elem = TMR_INDEX (mem_ref); if (act_elem) { if (step) act_elem = fold_build2 (MULT_EXPR, sizetype, act_elem, step); addr_off = act_elem; } act_elem = base; if (act_elem) { if (addr_off) addr_off = fold_build2 (PLUS_EXPR, sizetype, addr_off, act_elem); else addr_off = act_elem; } if (offset && !integer_zerop (offset)) { if (addr_off) addr_off = fold_build2 (PLUS_EXPR, sizetype, addr_off, offset); else addr_off = offset; } if (addr_off) { if (addr_base) addr = fold_build2 (POINTER_PLUS_EXPR, type, addr_base, addr_off); else addr = fold_convert (type, addr_off); } else if (addr_base) addr = addr_base; else addr = build_int_cst (type, 0); return addr; }
tree tree_mem_ref_addr (tree type, tree mem_ref) { tree addr; tree act_elem; tree step = TMR_STEP (mem_ref), offset = TMR_OFFSET (mem_ref); tree addr_base = NULL_TREE, addr_off = NULL_TREE; addr_base = fold_convert (type, TMR_BASE (mem_ref)); act_elem = TMR_INDEX (mem_ref); if (act_elem) { if (step) act_elem = fold_build2 (MULT_EXPR, TREE_TYPE (act_elem), act_elem, step); addr_off = act_elem; } act_elem = TMR_INDEX2 (mem_ref); if (act_elem) { if (addr_off) addr_off = fold_build2 (PLUS_EXPR, TREE_TYPE (addr_off), addr_off, act_elem); else addr_off = act_elem; } if (offset && !integer_zerop (offset)) { if (addr_off) addr_off = fold_build2 (PLUS_EXPR, TREE_TYPE (addr_off), addr_off, fold_convert (TREE_TYPE (addr_off), offset)); else addr_off = offset; } if (addr_off) addr = fold_build_pointer_plus (addr_base, addr_off); else addr = addr_base; return addr; }
void get_address_description (tree op, struct mem_address *addr) { if (TREE_CODE (TMR_BASE (op)) == ADDR_EXPR) { addr->symbol = TMR_BASE (op); addr->base = TMR_INDEX2 (op); } else { addr->symbol = NULL_TREE; if (TMR_INDEX2 (op)) { gcc_assert (integer_zerop (TMR_BASE (op))); addr->base = TMR_INDEX2 (op); } else addr->base = TMR_BASE (op); } addr->index = TMR_INDEX (op); addr->step = TMR_STEP (op); addr->offset = TMR_OFFSET (op); }