}
}
+
+// Helpers:
+//
+// Check that the given FPU format is usable, and signal a
+// ReservedInstruction exception if not.
+//
+
+// check_fmt checks that the format is single or double.
+:function:::void:check_fmt:int fmt, instruction_word insn
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mipsV:
+*vr4100:
+*vr5000:
+*r3900:
+{
+ if ((fmt != fmt_single) && (fmt != fmt_double))
+ SignalException (ReservedInstruction, insn);
+}
+
+// check_fmt_p checks that the format is single, double, or paired single.
+:function:::void:check_fmt_p:int fmt, instruction_word insn
+*mipsI:
+*mipsII:
+*mipsIII:
+*mipsIV:
+*mipsV:
+*vr4100:
+*vr5000:
+*r3900:
+{
+ /* None of these ISAs support Paired Single, so just fall back to
+ the single/double check. */
+ /* XXX FIXME: not true for mipsV, but we don't support .ps insns yet. */
+ check_fmt (SD_, fmt, insn);
+}
+
+
// Helper:
//
// Check that the FPU is currently usable, and signal a CoProcessorUnusable
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,AbsoluteValue(ValueFPR(FS,fmt),fmt));
- }
+ check_fmt_p (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,AbsoluteValue(ValueFPR(FS,fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction, instruction_0);
- else
- StoreFPR(FD,fmt,Add(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
- }
+ check_fmt_p (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Add(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
}
:function:::void:do_c_cond_fmt:int fmt, int ft, int fs, int cc, int cond, instruction_word insn
{
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException (ReservedInstruction, insn);
- else
+ int less;
+ int equal;
+ int unordered;
+ int condition;
+ unsigned64 ofs = ValueFPR (fs, fmt);
+ unsigned64 oft = ValueFPR (ft, fmt);
+ if (NaN (ofs, fmt) || NaN (oft, fmt))
{
- int less;
- int equal;
- int unordered;
- int condition;
- unsigned64 ofs = ValueFPR (fs, fmt);
- unsigned64 oft = ValueFPR (ft, fmt);
- if (NaN (ofs, fmt) || NaN (oft, fmt))
+ if (FCSR & FP_ENABLE (IO))
{
- if (FCSR & FP_ENABLE (IO))
- {
- FCSR |= FP_CAUSE (IO);
- SignalExceptionFPE ();
- }
- less = 0;
- equal = 0;
- unordered = 1;
+ FCSR |= FP_CAUSE (IO);
+ SignalExceptionFPE ();
}
- else
- {
- less = Less (ofs, oft, fmt);
- equal = Equal (ofs, oft, fmt);
- unordered = 0;
- }
- condition = (((cond & (1 << 2)) && less)
- || ((cond & (1 << 1)) && equal)
- || ((cond & (1 << 0)) && unordered));
- SETFCC (cc, condition);
+ less = 0;
+ equal = 0;
+ unordered = 1;
+ }
+ else
+ {
+ less = Less (ofs, oft, fmt);
+ equal = Equal (ofs, oft, fmt);
+ unordered = 0;
}
+ condition = (((cond & (1 << 2)) && less)
+ || ((cond & (1 << 1)) && equal)
+ || ((cond & (1 << 0)) && unordered));
+ SETFCC (cc, condition);
}
010001,10,3.FMT,5.FT,5.FS,3.0,00,11,4.COND:COP1:32,f::C.cond.fmta
*mipsII:
*mipsIII:
{
+ int fmt = FMT;
check_fpu (SD_);
- do_c_cond_fmt (SD_, FMT, FT, FS, 0, COND, instruction_0);
+ check_fmt_p (SD_, fmt, instruction_0);
+ do_c_cond_fmt (SD_, fmt, FT, FS, 0, COND, instruction_0);
}
010001,10,3.FMT,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32,f::C.cond.fmtb
*vr5000:
*r3900:
{
+ int fmt = FMT;
check_fpu (SD_);
- do_c_cond_fmt (SD_, FMT, FT, FS, CC, COND, instruction_0);
+ check_fmt_p (SD_, fmt, instruction_0);
+ do_c_cond_fmt (SD_, fmt, FT, FS, CC, COND, instruction_0);
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(FS,fmt),fmt,fmt_long));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(FS,fmt),fmt,fmt_long));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(FS,fmt),fmt,fmt_word));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(FS,fmt),fmt,fmt_word));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,Divide(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Divide(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(FS,fmt),fmt,fmt_long));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(FS,fmt),fmt,fmt_long));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(FS,fmt),fmt,fmt_word));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(FS,fmt),fmt,fmt_word));
}
{
int fmt = FMT;
check_fpu (SD_);
+ check_fmt_p (SD_, fmt, instruction_0);
StoreFPR(FD,fmt,ValueFPR(FS,fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,Multiply(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
- }
+ check_fmt_p (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Multiply(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,Negate(ValueFPR(FS,fmt),fmt));
- }
+ check_fmt_p (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Negate(ValueFPR(FS,fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,Recip(ValueFPR(FS,fmt),fmt));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Recip(ValueFPR(FS,fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(FS,fmt),fmt,fmt_long));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(FS,fmt),fmt,fmt_long));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(FS,fmt),fmt,fmt_word));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(FS,fmt),fmt,fmt_word));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,Recip(SquareRoot(ValueFPR(FS,fmt),fmt),fmt));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Recip(SquareRoot(ValueFPR(FS,fmt),fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,(SquareRoot(ValueFPR(FS,fmt),fmt)));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,(SquareRoot(ValueFPR(FS,fmt),fmt)));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt,Sub(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
- }
+ check_fmt_p (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt,Sub(ValueFPR(FS,fmt),ValueFPR(FT,fmt),fmt));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(FS,fmt),fmt,fmt_long));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(FS,fmt),fmt,fmt_long));
}
{
int fmt = FMT;
check_fpu (SD_);
- {
- if ((fmt != fmt_single) && (fmt != fmt_double))
- SignalException(ReservedInstruction,instruction_0);
- else
- StoreFPR(FD,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(FS,fmt),fmt,fmt_word));
- }
+ check_fmt (SD_, fmt, instruction_0);
+ StoreFPR(FD,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(FS,fmt),fmt,fmt_word));
}
\f