core/x86/mangle.c
/* If stack_align16 is true, assumes the stack pointer is currently aligned
 * on a 16-byte boundary.
 */
If stack_align16 is true, assumes the stack pointer is currently aligned
on a 16-byte boundary.
If stack_align16 is true assumes the stack pointer is currently aligned on a 16 - byte boundary .
void
insert_pop_all_registers(dcontext_t *dcontext, instrlist_t *ilist, instr_t *instr,
                         bool stack_align16)
{
#ifdef X64
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RDI)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RSI)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RBP)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RBX)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RBX)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RDX)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RCX)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_RAX)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R8)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R9)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R10)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R11)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R12)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R13)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R14)));
    PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(REG_R15)));
#else
    PRE(ilist, instr, INSTR_CREATE_popa(dcontext));
#endif
    if (preserve_xmm_caller_saved()) {
        int i;
        uint opcode = (proc_has_feature(FEATURE_SSE2) ?
                       (stack_align16 ? OP_movdqa : OP_movdqu) :
                       (stack_align16 ? OP_movaps : OP_movups));
        ASSERT(proc_has_feature(FEATURE_SSE));
        for (i=0; i<NUM_XMM_SAVED; i++) {
            PRE(ilist, instr, instr_create_1dst_1src
                (dcontext, opcode, opnd_create_reg(REG_XMM0 + (reg_id_t)i),
                 opnd_create_base_disp(REG_XSP, REG_NULL, 0, i*XMM_REG_SIZE, OPSZ_16)));
        }
        ASSERT(i*XMM_REG_SIZE == XMM_SAVED_SIZE);
        ASSERT(XMM_SAVED_SIZE <= XMM_SLOTS_SIZE);
    }
    PRE(ilist, instr, INSTR_CREATE_lea
        (dcontext, opnd_create_reg(REG_XSP),
         OPND_CREATE_MEM_lea(REG_XSP, REG_NULL, 0, XMM_SLOTS_SIZE)));
}
void insert_pop_all_registers ( dcontext_t * dcontext , instrlist_t * ilist , instr_t * instr , bool stack_align16 ) { #ifdef X64 PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RDI ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RSI ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RBP ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RBX ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RBX ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RDX ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RCX ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_RAX ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R8 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R9 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R10 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R11 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R12 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R13 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R14 ) ) ) ; PRE ( ilist , instr , INSTR_CREATE_pop ( dcontext , opnd_create_reg ( REG_R15 ) ) ) ; #else PRE ( ilist , instr , INSTR_CREATE_popa ( dcontext ) ) ; #endif if ( preserve_xmm_caller_saved ( ) ) { int i ; uint opcode = ( proc_has_feature ( FEATURE_SSE2 ) ? ( stack_align16 ? OP_movdqa : OP_movdqu ) : ( stack_align16 ? OP_movaps : OP_movups ) ) ; ASSERT ( proc_has_feature ( FEATURE_SSE ) ) ; for ( i = 0 ; i < NUM_XMM_SAVED ; i ++ ) { PRE ( ilist , instr , instr_create_1dst_1src ( dcontext , opcode , opnd_create_reg ( REG_XMM0 + ( reg_id_t ) i ) , opnd_create_base_disp ( REG_XSP , REG_NULL , 0 , i * XMM_REG_SIZE , OPSZ_16 ) ) ) ; } ASSERT ( i * XMM_REG_SIZE == XMM_SAVED_SIZE ) ; ASSERT ( XMM_SAVED_SIZE <= XMM_SLOTS_SIZE ) ; } PRE ( ilist , instr , INSTR_CREATE_lea ( dcontext , opnd_create_reg ( REG_XSP ) , OPND_CREATE_MEM_lea ( REG_XSP , REG_NULL , 0 , XMM_SLOTS_SIZE ) ) ) ; }
If stack_align16 is true, assumes the stack pointer is currently aligned
 on a 16-byte boundary.
If stack_align16 is true assumes the stack pointer is currently aligned on a 16 - byte boundary .
/* in dr_mcontext_t order */ /* skip xsp by popping into dead rbx */ /* PR 264138: we must preserve xmm0-5 if on a 64-bit kernel */ /* See discussion in emit_fcache_enter_shared on which opcode
         * is better. */