F-5
GUIDELINES FOR WRITING SIMD FLOATING-POINT EXCEPTION
Two cases are possible:
If an unmasked (enabled) exception occurs in this process, the emulation function will
return to its caller (the filter function) with the appropriate information. The filter will
invoke a (previously registered) user floating-point exception handler for this set of sub-
operands, and will record the result upon return from the user handler (provided the user
handler allows continuation of the execution).
If no unmasked (enabled) exception occurs, the emulation function will determine and will
return to its caller the result of the operation for the current set of sub-operands (it has to
be IEEE compliant). The filter function will record the result (plus any new flag settings).
The user level filter function will then call the emulation function for the next set of sub-oper-
ands (if any). When done, the partial results will be packed (if the excepting instruction has a
packed floating-point result, which is true for most Streaming SIMD Extensions numeric in-
structions) and the filter will return to the low-level exception handler, which in turn will return
from the interruption, allowing execution to continue. Note that the instruction pointer (EIP) has
to be altered to point to the instruction following the excepting instruction, in order to continue
execution correctly.
If a user mode floating-point exception filter is not provided, then all the work for decoding the
excepting instruction, reading its operands, emulating the instruction for the components of the
result that do not correspond to unmasked floating-point exceptions, and providing the com-
pounded result will have to be performed by the user provided floating-point exception handler.
Actual emulation will have to take place for one operand or pair of operands for scalar opera-
tions, and for all four operands or pairs of operands for packed operations. The steps to perform
are the following:
the excepting instruction has to be decoded and the operands have to be read from the
saved context
the instruction has to be emulated for each (pair of) sub-operand(s); if no floating-point
exception occurs, the partial result has to be saved; if a masked floating-point exception
occurs, the masked result has to be produced through emulation and saved, and the
appropriate status flags have to be set; if an unmasked floating-point exception occurs, the
result has to be generated by the user provided floating-point exception handler, and the
appropriate status flags have to be set
the four partial results have to be combined and written to the context that will be restored
upon application program resumption