diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2013-01-15 07:43:19 -0600 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2013-01-15 07:43:19 -0600 |
commit | 91b00d98a5973d47b831495f5c668bbb185c7a15 (patch) | |
tree | d2108f83a8be89fdaeec5120c5f5ccb6744cdba1 /src/arch/x86 | |
parent | 7fdcfdf08b9d654fcf311b213bd729cb957f822c (diff) | |
download | gem5-91b00d98a5973d47b831495f5c668bbb185c7a15.tar.xz |
x86: implement fabs, fchs instructions
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/isa/decoder/x87.isa | 4 | ||||
-rw-r--r-- | src/arch/x86/isa/insts/x87/arithmetic/change_sign.py | 10 | ||||
-rw-r--r-- | src/arch/x86/isa/microops/fpop.isa | 8 | ||||
-rw-r--r-- | src/arch/x86/isa/operands.isa | 4 | ||||
-rw-r--r-- | src/arch/x86/regs/misc.hh | 19 |
5 files changed, 41 insertions, 4 deletions
diff --git a/src/arch/x86/isa/decoder/x87.isa b/src/arch/x86/isa/decoder/x87.isa index 3af68cd54..f278dc2f8 100644 --- a/src/arch/x86/isa/decoder/x87.isa +++ b/src/arch/x86/isa/decoder/x87.isa @@ -68,8 +68,8 @@ format WarnUnimpl { } 0x4: decode MODRM_MOD { 0x3: decode MODRM_RM { - 0x0: fchs(); - 0x1: fabs(); + 0x0: Inst::FCHS(); + 0x1: Inst::FABS(); 0x4: ftst(); 0x5: fxam(); default: Inst::UD2(); diff --git a/src/arch/x86/isa/insts/x87/arithmetic/change_sign.py b/src/arch/x86/isa/insts/x87/arithmetic/change_sign.py index 059fb1ef1..779f1b5b2 100644 --- a/src/arch/x86/isa/insts/x87/arithmetic/change_sign.py +++ b/src/arch/x86/isa/insts/x87/arithmetic/change_sign.py @@ -36,6 +36,12 @@ # Authors: Gabe Black microcode = ''' -# FABS -# FCHS + +def macroop FABS { + absfp st(0), st(0) +}; + +def macroop FCHS { + chsfp st(0), st(0) +}; ''' diff --git a/src/arch/x86/isa/microops/fpop.isa b/src/arch/x86/isa/microops/fpop.isa index f6cbd2036..b9aceea09 100644 --- a/src/arch/x86/isa/microops/fpop.isa +++ b/src/arch/x86/isa/microops/fpop.isa @@ -331,4 +331,12 @@ let {{ else if(FpSrcReg1 == FpSrcReg2) ccFlagBits = ccFlagBits | ZFBit; ''' + + class absfp(FpUnaryOp): + code = 'FpDestReg = fabs(FpSrcReg1);' + flag_code = 'FSW &= (~CC1Bit);' + + class chsfp(FpUnaryOp): + code = 'FpDestReg = (-1) * (FpSrcReg1);' + flag_code = 'FSW &= (~CC1Bit);' }}; diff --git a/src/arch/x86/isa/operands.isa b/src/arch/x86/isa/operands.isa index 05b127e37..bc6d1886c 100644 --- a/src/arch/x86/isa/operands.isa +++ b/src/arch/x86/isa/operands.isa @@ -158,7 +158,11 @@ def operands {{ # These register should needs to be more protected so that later # instructions don't map their indexes with an old value. 'nccFlagBits': controlReg('MISCREG_RFLAGS', 65), + + # Registers related to the state of x87 floating point unit. 'TOP': controlReg('MISCREG_X87_TOP', 66, ctype='ub'), + 'FSW': controlReg('MISCREG_FSW', 67, ctype='uw'), + # The segment base as used by memory instructions. 'SegBase': controlReg('MISCREG_SEG_EFF_BASE(segment)', 70), diff --git a/src/arch/x86/regs/misc.hh b/src/arch/x86/regs/misc.hh index 697c81fc9..5887e7486 100644 --- a/src/arch/x86/regs/misc.hh +++ b/src/arch/x86/regs/misc.hh @@ -79,6 +79,25 @@ namespace X86ISA IDBit = 1 << 21 }; + enum X87StatusBit { + // Exception Flags + IEBit = 1 << 0, + DEBit = 1 << 1, + ZEBit = 1 << 2, + OEBit = 1 << 3, + UEBit = 1 << 4, + PEBit = 1 << 5, + + // !Exception Flags + StackFaultBit = 1 << 6, + ErrSummaryBit = 1 << 7, + CC0Bit = 1 << 8, + CC1Bit = 1 << 9, + CC2Bit = 1 << 10, + CC3Bit = 1 << 14, + BusyBit = 1 << 15, + }; + enum MiscRegIndex { // Control registers |