Skip to content

Commit

Permalink
Merge pull request S2E#19 from S2E/issue/144-mmx
Browse files Browse the repository at this point in the history
Issue/144 mmx
  • Loading branch information
vitalych authored May 29, 2019
2 parents ca030e1 + 31da900 commit 7e0f574
Show file tree
Hide file tree
Showing 10 changed files with 1,121 additions and 937 deletions.
35 changes: 18 additions & 17 deletions include/cpu/i386/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ typedef struct CPUX86State {
target_ulong cc_dst;
target_ulong cc_tmp; /* temporary for rcr/rcl */

/* FPU state */
unsigned int fpstt; /* top of stack index */
uint16_t fpus;
uint16_t fpuc;
uint8_t fptags[8]; /* 0 = valid, 1 = empty */
FPReg fpregs[8];

/* emulator internal variables */
float_status fp_status;
floatx80 ft0;

float_status mmx_status; /* for 3DNow! float ops */
float_status sse_status;
uint32_t mxcsr;
XMMReg xmm_regs[CPU_NB_REGS];
XMMReg xmm_t0;
MMXReg mmx_t0;

/* symbex note: the contents of the structure from this point
can never be symbolic. */
target_ulong eip;
Expand All @@ -113,28 +131,11 @@ typedef struct CPUX86State {
target_ulong cr[5]; /* NOTE: cr1 is unused */
int32_t a20_mask;

/* FPU state */
unsigned int fpstt; /* top of stack index */
uint16_t fpus;
uint16_t fpuc;
uint8_t fptags[8]; /* 0 = valid, 1 = empty */
FPReg fpregs[8];
/* KVM-only so far */
uint16_t fpop;
uint64_t fpip;
uint64_t fpdp;

/* emulator internal variables */
float_status fp_status;
floatx80 ft0;

float_status mmx_status; /* for 3DNow! float ops */
float_status sse_status;
uint32_t mxcsr;
XMMReg xmm_regs[CPU_NB_REGS];
XMMReg xmm_t0;
MMXReg mmx_t0;

/* sysenter registers */
uint32_t sysenter_cs;
target_ulong sysenter_esp;
Expand Down
1 change: 1 addition & 0 deletions include/cpu/se_libcpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct se_libcpu_interface_t {
uint64_t (*read_mem_io_vaddr)(int masked);
int (*is_port_symbolic)(uint64_t port);
int (*is_mmio_symbolic)(uint64_t phys_addr, unsigned size);
int (*is_vmem_symbolic)(uint64_t vaddr, unsigned size);

uintptr_t (*get_host_address)(uint64_t paddr);

Expand Down
2 changes: 1 addition & 1 deletion include/fpu/softfloat-specialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const float128 float128_default_nan = make_float128_init(float128_default_nan_hi
*----------------------------------------------------------------------------*/

void float_raise(uint8_t flags STATUS_PARAM) {
STATUS(float_exception_flags) |= flags;
STATUS_W(float_exception_flags, (STATUS(float_exception_flags) | flags));
}

/*----------------------------------------------------------------------------
Expand Down
20 changes: 15 additions & 5 deletions include/fpu/softfloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,19 @@ typedef int64_t int64;
#define SINLINE static inline

#define STATUS_PARAM , float_status *status
#define STATUS(field) status->field
#define STATUS_VAR , status

#if defined(CONFIG_SYMBEX) && !defined(SYMBEX_LLVM_LIB)
uint8_t RR_cpu_float_status(void *p, unsigned size);
void WR_cpu_float_status(void *p, unsigned size, int v);

#define STATUS(field) RR_cpu_float_status(&status->field, sizeof(status->field))
#define STATUS_W(field, v) WR_cpu_float_status(&status->field, sizeof(status->field), v)
#else
#define STATUS(field) status->field
#define STATUS_W(field, v) status->field = v
#endif

/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point ordering relations
*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -189,16 +199,16 @@ typedef struct float_status {
void set_float_rounding_mode(int val STATUS_PARAM);
void set_float_exception_flags(int val STATUS_PARAM);
SINLINE void set_float_detect_tininess(int val STATUS_PARAM) {
STATUS(float_detect_tininess) = val;
STATUS_W(float_detect_tininess, val);
}
SINLINE void set_flush_to_zero(flag val STATUS_PARAM) {
STATUS(flush_to_zero) = val;
STATUS_W(flush_to_zero, val);
}
SINLINE void set_flush_inputs_to_zero(flag val STATUS_PARAM) {
STATUS(flush_inputs_to_zero) = val;
STATUS_W(flush_inputs_to_zero, val);
}
SINLINE void set_default_nan_mode(flag val STATUS_PARAM) {
STATUS(default_nan_mode) = val;
STATUS_W(default_nan_mode, val);
}
SINLINE int get_float_exception_flags(float_status *status) {
return STATUS(float_exception_flags);
Expand Down
9 changes: 6 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ foreach(dir ${dirs})
endforeach()
separate_arguments(BC_INC_DIRS)

get_filename_component(LLVM_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)

add_custom_target(
op_helper_bc ALL
${CMAKE_C_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/target-i386/op_helper.c -c ${CARGS_LIST} -Wno-unused-function -O3 -DSYMBEX_LLVM_LIB -emit-llvm -o ${CMAKE_CURRENT_BINARY_DIR}/op_helper.bc
${BC_INC_DIRS}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/target-i386/op_helper.c
${CMAKE_C_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/target-i386/op_helper.c -c ${CARGS_LIST} -Wno-unused-function -O3 -DSYMBEX_LLVM_LIB -emit-llvm -o ${CMAKE_CURRENT_BINARY_DIR}/op_helper-org.bc ${BC_INC_DIRS}
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/fpu/softfloat.c -c ${CARGS_LIST} -Wno-unused-function -O3 -DSYMBEX_LLVM_LIB -emit-llvm -o ${CMAKE_CURRENT_BINARY_DIR}/softfloat.bc ${BC_INC_DIRS}
COMMAND ${LLVM_BIN_DIR}/llvm-link ${CMAKE_CURRENT_BINARY_DIR}/op_helper-org.bc ${CMAKE_CURRENT_BINARY_DIR}/softfloat.bc -o ${CMAKE_CURRENT_BINARY_DIR}/op_helper.bc
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/target-i386/op_helper.c ${CMAKE_CURRENT_SOURCE_DIR}/fpu/softfloat.c
)

endif (WITH_SYMBEX)
Expand Down
Loading

0 comments on commit 7e0f574

Please sign in to comment.