diff options
Diffstat (limited to 'src/arch/sparc/isa/formats')
-rw-r--r-- | src/arch/sparc/isa/formats/basic.isa | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/arch/sparc/isa/formats/basic.isa b/src/arch/sparc/isa/formats/basic.isa index e8762a205..fac523aeb 100644 --- a/src/arch/sparc/isa/formats/basic.isa +++ b/src/arch/sparc/isa/formats/basic.isa @@ -103,3 +103,42 @@ def format BasicOperate(code, *flags) {{ decode_block = BasicDecode.subst(iop) exec_output = BasicExecute.subst(iop) }}; + +def format FpBasic(code, *flags) {{ + fp_code = """ + Fsr = insertBits(Fsr,4,0,0); +#if defined(__sun) || defined (__OpenBSD__) + fp_rnd newrnd = FP_RN; + switch (Fsr<31:30>) { + case 0: newrnd = FP_RN; break; + case 1: newrnd = FP_RZ; break; + case 2: newrnd = FP_RP; break; + case 3: newrnd = FP_RM; break; + } + fp_rnd oldrnd = fpsetround(newrnd); +#else + int newrnd = FE_TONEAREST; + switch (Fsr<31:30>) { + case 0: newrnd = FE_TONEAREST; break; + case 1: newrnd = FE_TOWARDZERO; break; + case 2: newrnd = FE_UPWARD; break; + case 3: newrnd = FE_DOWNWARD; break; + } + int oldrnd = fegetround(); + fesetround(newrnd); +#endif +""" + fp_code += code + fp_code += """ +#if defined(__sun) || defined (__OpenBSD__) + fpsetround(oldrnd); +#else + fesetround(oldrnd); +#endif +""" + iop = InstObjParams(name, Name, 'SparcStaticInst', fp_code, flags) + header_output = BasicDeclare.subst(iop) + decoder_output = BasicConstructor.subst(iop) + decode_block = BasicDecode.subst(iop) + exec_output = BasicExecute.subst(iop) +}}; |