[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [RFC 00/12] target-ppc: Decimal Floating Point
From: |
Tom Musta |
Subject: |
[Qemu-ppc] [RFC 00/12] target-ppc: Decimal Floating Point |
Date: |
Thu, 13 Mar 2014 10:12:56 -0500 |
This patch series provides a prototype of Decimal Floating Point (DFP)
instruction
support in QEMU. The topic was briefly discussed here:
http://lists.nongnu.org/archive/html/qemu-ppc/2014-02/msg00129.html
I. Overview
The core of the DFP model is a library named libdecnumber, which is a
sub-library
of GCC's libdfp. Libdecnumber's model uses an expanded internal representation
of a decimal floating point number as:
- exponent (base 10)
- the number of digits (aka declets)
- flags (sign bit and "special" bits for NaNs and infinities)
- an array of units. Each unit contains DECPUN declets.
Libdecnumber provides routines for various arithmetic operations (e.g.
decNumberAdd for
addition) as well as converters for going to/from binary form.
PowerPC's support of DFP uses Densely Packed Decimal (DPD) format. The
standard floating
point registers are re-used to hold DFP operands. There are typically PowerPC
instructions
for both the long (64 bit) and extended (128 bit, aka quad) formats. The
extended format
instructions use adjacent pairs of FPRs to hold the 128 bit operands.
II. A Simple Example
PowerPC DFP instructions are implemented using helpers, which in turn use
libdecnumber
routines to perform the detailed computations. This is similar to how
softfloat is used
to model binary floating point instructions.
For example, the implementation of the helper for DFP Add Long (dadd) looks
like this:
1) Establish a libdecnumber context for 64-bit computation (decContext)
2) Convert the two source FPRs from DPD to decNumbers (the expanded
internal representation)
3) Invoke the add operation (decNumberAdd)
4) Inspect the context's flags for various exception situations (e.g.
overflow), mapping
them to the corresponding FPSCR status flags.
5) Convert the summand to DPD form and store into the target FPR.
The helper for the DPD Add Extended (daddq) is nearly identical. It differs
only in that
it establishes a 128 bit context and the conversions are from and to 128 bit
DPD format.
III. Integration of libdecnumber in QEMU
The appoach taken here is direct and simple:
1) A copy of libdecnumber code is imported into QEMU. The header files are
placed under
include/libdecnumber and the code is placed under libdecnumber. A
minimalist approach
is taken -- only the source required to support PPC DFP instruction
models is imported.
2) The code is modified to account for this structure (see patch 02/12)
3) The libdecnumber configuration script is jettisoned. Instead, the
configuration header
that is normally generated is modified to integrate properly with QEMU's
configuration.
See patch 03/12.
4) Some trivial modifications to source are made to address compiler
warnings. See
patches 04/12 - 06/12
5) Compilation is enabled for PowerPC emulation models (see patch 07/12).
Tom Musta (12):
target-ppc: Introduce libdecnumber Code
target-ppc: Prepare libdecnumber for QEMU include structure
target-ppc: Modify dconfig.h to Integrate with QEMU
target-ppc: Change gstdint.h to stdint.h
target-ppc: Eliminate redundant declarations
target-ppc: Eliminate Unused Variable in decSetSubnormal
target-ppc: Enable Building of libdecnumber
target-ppc: Define FPR Pointer Type for Helpers
target-ppc: Introduce Translation Macros for DFP Arithmetic Forms
target-ppc: Introduce DFP Helper Utilities
target-ppc: Introduce DFP Post Processor Utilities
target-ppc: Introduce DFP Add
Makefile.target | 5 +
default-configs/ppc-linux-user.mak | 1 +
default-configs/ppc-softmmu.mak | 1 +
default-configs/ppc64-linux-user.mak | 1 +
default-configs/ppc64-softmmu.mak | 1 +
include/libdecnumber/dconfig.h | 35 +
include/libdecnumber/decCommonSymbols.h | 14 +
include/libdecnumber/decContext.h | 253 +
include/libdecnumber/decContextSymbols.h | 44 +
include/libdecnumber/decDPD.h | 1211 ++++
include/libdecnumber/decDPDSymbols.h | 26 +
include/libdecnumber/decDouble.h | 161 +
include/libdecnumber/decDoubleSymbols.h | 165 +
include/libdecnumber/decNumber.h | 195 +
include/libdecnumber/decNumberLocal.h | 662 +++
include/libdecnumber/decNumberSymbols.h | 143 +
include/libdecnumber/decQuad.h | 183 +
include/libdecnumber/decQuadSymbols.h | 160 +
include/libdecnumber/dpd/decimal128.h | 96 +
include/libdecnumber/dpd/decimal128Local.h | 42 +
include/libdecnumber/dpd/decimal128Symbols.h | 48 +
include/libdecnumber/dpd/decimal64.h | 96 +
include/libdecnumber/dpd/decimal64Symbols.h | 48 +
libdecnumber/decContext.c | 427 ++
libdecnumber/decNumber.c | 8115 ++++++++++++++++++++++++++
libdecnumber/dpd/decimal128.c | 559 ++
libdecnumber/dpd/decimal128Local.h | 42 +
libdecnumber/dpd/decimal64.c | 845 +++
target-ppc/Makefile.objs | 1 +
target-ppc/dfp_helper.c | 264 +
target-ppc/helper.h | 7 +
target-ppc/translate.c | 65 +
32 files changed, 13916 insertions(+), 0 deletions(-)
create mode 100644 include/libdecnumber/dconfig.h
create mode 100644 include/libdecnumber/decCommonSymbols.h
create mode 100644 include/libdecnumber/decContext.h
create mode 100644 include/libdecnumber/decContextSymbols.h
create mode 100644 include/libdecnumber/decDPD.h
create mode 100644 include/libdecnumber/decDPDSymbols.h
create mode 100644 include/libdecnumber/decDouble.h
create mode 100644 include/libdecnumber/decDoubleSymbols.h
create mode 100644 include/libdecnumber/decNumber.h
create mode 100644 include/libdecnumber/decNumberLocal.h
create mode 100644 include/libdecnumber/decNumberSymbols.h
create mode 100644 include/libdecnumber/decQuad.h
create mode 100644 include/libdecnumber/decQuadSymbols.h
create mode 100644 include/libdecnumber/dpd/decimal128.h
create mode 100644 include/libdecnumber/dpd/decimal128Local.h
create mode 100644 include/libdecnumber/dpd/decimal128Symbols.h
create mode 100644 include/libdecnumber/dpd/decimal64.h
create mode 100644 include/libdecnumber/dpd/decimal64Symbols.h
create mode 100644 libdecnumber/decContext.c
create mode 100644 libdecnumber/decNumber.c
create mode 100644 libdecnumber/dpd/decimal128.c
create mode 100644 libdecnumber/dpd/decimal128Local.h
create mode 100644 libdecnumber/dpd/decimal64.c
create mode 100644 target-ppc/dfp_helper.c
- [Qemu-ppc] [RFC 00/12] target-ppc: Decimal Floating Point,
Tom Musta <=
- [Qemu-ppc] [RFC 03/12] target-ppc: Modify dconfig.h to Integrate with QEMU, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 02/12] target-ppc: Prepare libdecnumber for QEMU include structure, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 11/12] target-ppc: Introduce DFP Post Processor Utilities, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 12/12] target-ppc: Introduce DFP Add, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 07/12] target-ppc: Enable Building of libdecnumber, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 06/12] target-ppc: Eliminate Unused Variable in decSetSubnormal, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 05/12] target-ppc: Eliminate redundant declarations, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 10/12] target-ppc: Introduce DFP Helper Utilities, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 04/12] target-ppc: Change gstdint.h to stdint.h, Tom Musta, 2014/03/13
- [Qemu-ppc] [RFC 08/12] target-ppc: Define FPR Pointer Type for Helpers, Tom Musta, 2014/03/13