x86: Fix re-entrancy problems in x87 store instructions

X87 store instructions typically loads and pops the top value of the
stack and stores it in memory. The current implementation pops the
stack at the same time as the floating point value is loaded to a
temporary register. This will corrupt the state of the x87 stack if
the store fails. This changeset introduces a pop87 micro-instruction
that pops the stack and uses this instruction in the affected
macro-instructions to pop the stack after storing the value to memory.
This commit is contained in:
Andreas Sandberg
2013-09-30 11:51:25 +02:00
parent 469f2e31cf
commit c299dcedc6
2 changed files with 13 additions and 2 deletions

View File

@@ -69,13 +69,15 @@ def macroop FSTP_R {
};
def macroop FSTP_M {
movfp ufp1, st(0), spm=1
movfp ufp1, st(0)
stfp ufp1, seg, sib, disp
pop87
};
def macroop FSTP_P {
movfp ufp1, st(0), spm=1
movfp ufp1, st(0)
rdip t7
stfp ufp1, seg, riprel, disp
pop87
};
'''

View File

@@ -411,4 +411,13 @@ let {{
class chsfp(FpUnaryOp):
code = 'FpDestReg = (-1) * (FpSrcReg1);'
flag_code = 'FSW = FSW & (~CC1Bit);'
class Pop87(FpUnaryOp):
def __init__(self, spm=1, UpdateFTW=True):
super(Pop87, self).__init__( \
"InstRegIndex(FLOATREG_MICROFP0)", \
"InstRegIndex(FLOATREG_MICROFP0)", \
spm=spm, SetStatus=False, UpdateFTW=UpdateFTW)
code = ''
}};