core/x86/instr.c
/* Returns true if def, considered as a write, affects use.
 * Is conservative, so if both def and use are memory references,
 * will return true unless it can disambiguate them.
 */
Returns true if def, considered as a write, affects use.
Is conservative, so if both def and use are memory references,
will return true unless it can disambiguate them.
Returns true if def considered as a write affects use . Is conservative so if both def and use are memory references will return true unless it can disambiguate them .
bool opnd_defines_use(opnd_t def, opnd_t use)
{
    switch (def.kind) {
    case NULL_kind:
    case IMMED_INTEGER_kind:
    case IMMED_FLOAT_kind:
    case PC_kind:
    case FAR_PC_kind:
    case INSTR_kind:
    case FAR_INSTR_kind:
        return false;
    case REG_kind: 
        return opnd_uses_reg(use, opnd_get_reg(def));
    case BASE_DISP_kind:
        if (!opnd_is_memory_reference(use))
            return false;
#ifdef X64
        if (!opnd_is_base_disp(use))
            return true;
#endif
        if (opnd_get_base(def) != opnd_get_base(use))
            return true;
        if (opnd_get_index(def) != opnd_get_index(use))
            return true;
        if (opnd_get_scale(def) != opnd_get_scale(use))
            return true;
        if (opnd_get_segment(def) != opnd_get_segment(use))
            return true;
        return range_overlap(opnd_get_disp(def), opnd_get_disp(use),
                             opnd_size_in_bytes(opnd_get_size(def)),
                             opnd_size_in_bytes(opnd_get_size(use)));
#ifdef X64
    case REL_ADDR_kind:
    case ABS_ADDR_kind:
        if (!opnd_is_memory_reference(use))
            return false;
        if (opnd_is_base_disp(use))
            return true;
        if (opnd_get_segment(def) != opnd_get_segment(use))
            return true;
        return range_overlap((ptr_uint_t)opnd_get_addr(def),
                             (ptr_uint_t)opnd_get_addr(use),
                             opnd_size_in_bytes(opnd_get_size(def)),
                             opnd_size_in_bytes(opnd_get_size(use)));
#endif
    default: 
        CLIENT_ASSERT(false, "opnd_defines_use: invalid opnd type"); 
        return false;
    }    
}
bool opnd_defines_use ( opnd_t def , opnd_t use ) { switch ( def . kind ) { case NULL_kind : case IMMED_INTEGER_kind : case IMMED_FLOAT_kind : case PC_kind : case FAR_PC_kind : case INSTR_kind : case FAR_INSTR_kind : return false ; case REG_kind : return opnd_uses_reg ( use , opnd_get_reg ( def ) ) ; case BASE_DISP_kind : if ( ! opnd_is_memory_reference ( use ) ) return false ; #ifdef X64 if ( ! opnd_is_base_disp ( use ) ) return true ; #endif if ( opnd_get_base ( def ) != opnd_get_base ( use ) ) return true ; if ( opnd_get_index ( def ) != opnd_get_index ( use ) ) return true ; if ( opnd_get_scale ( def ) != opnd_get_scale ( use ) ) return true ; if ( opnd_get_segment ( def ) != opnd_get_segment ( use ) ) return true ; return range_overlap ( opnd_get_disp ( def ) , opnd_get_disp ( use ) , opnd_size_in_bytes ( opnd_get_size ( def ) ) , opnd_size_in_bytes ( opnd_get_size ( use ) ) ) ; #ifdef X64 case REL_ADDR_kind : case ABS_ADDR_kind : if ( ! opnd_is_memory_reference ( use ) ) return false ; if ( opnd_is_base_disp ( use ) ) return true ; if ( opnd_get_segment ( def ) != opnd_get_segment ( use ) ) return true ; return range_overlap ( ( ptr_uint_t ) opnd_get_addr ( def ) , ( ptr_uint_t ) opnd_get_addr ( use ) , opnd_size_in_bytes ( opnd_get_size ( def ) ) , opnd_size_in_bytes ( opnd_get_size ( use ) ) ) ; #endif default : CLIENT_ASSERT ( false , " " ) ; return false ; } }
Returns true if def, considered as a write, affects use.
Returns true if def considered as a write affects use .
/* try to disambiguate the two memory references 
         * for now, only consider identical regs and different disp
         */ /* everything is identical, now make sure disps don't overlap */