VFP Exception Handling
ARM DDI 0301H
Copyright © 2004-2009 ARM Limited. All rights reserved.
22-5
ID012310
Non-Confidential, Unrestricted Access
22.3
Support code
The VFP11 coprocessor provides floating-point functionality through a combination of
hardware and software support.
When an instruction bounces, software installed on the ARM Undefined Instruction vector
determines why the VFP11 coprocessor rejected the instruction and takes appropriate remedial
action. This software is called the
VFP support code
. The support code has two components:
•
a library of routines that perform floating-point arithmetic functions
•
a set of exception handlers that process exceptional conditions.
See
Application Note 98, VFP Support Code
for details of support code. Support code is
provided with the RealView Compilation Tools, or for the ARM Developer Suite as an add-on
downloadable from the ARM web site.
The remedial action is performed as follows:
1.
The support code starts by reading the FPEXC register. If the EX flag, FPEXC[31], is set,
a potential exception is present. If not, an illegal instruction is detected. See
Illegal
instructions
on page 22-6.
The contents of the FPEXC register must be retained throughout exception processing.
Any VFP11 coprocessor activity might change FPEXC register bits from their state at the
time of the exception.
2.
The support code writes to the FPEXC register to clear the EX flag. Failure to do this can
result in an infinite loop of exceptions when the support code next accesses the VFP11
hardware.
3.
The support code reads the FPSCR to determine if IXE is set or not set. If IXE,
FPSCR[12], is set, an inexact exception has occurred, that takes priority over other
exceptions and is precise. Other exceptions are imprecise.
4.
The support code reads either the FPINST register, or the instruction pointed to by R14-4,
depending on whether the exception is precise or not, to determine the instruction that
caused the potential exception.
5.
The support code decodes the instruction in the FPINST register, reads its operands,
including implicit information such as the rounding mode and vector length in the FPSCR
register, executes the operation, and determines whether a floating-point exception
occurred.
6.
If no floating-point exception occurred, the support code writes the correct result of the
operation and sets the appropriate flags in the FPSCR register.
If one or more floating-point exceptions occurred, but all of them were disabled, the
support code determines the correct result of the instruction, writes it to the destination
register, and sets the corresponding flags in the FPSCR register.
If one or more floating-point exceptions occurred, and at least one of them was enabled,
the support code computes the intermediate result specified by the IEEE 754 standard, if
required, and calls the user trap handler for that exception. The user trap handler can
provide a result for the instruction and continue program execution, generate a signal or
message to the operating system or the user, or terminate the program.
7.
If the potentially exceptional instruction specified a short vector operation, the hardware
does not execute any vector iterations after the one that encountered the potentially
exceptional condition. The support code repeats steps 4 and 5 for any such iterations. See
Exception processing for CDP short vector instructions
on page 22-8 for more details.