Introduction
PowerPC has 32 floating-point registers, f0 to f31, each 64 bits wide and holding an IEEE 754 double-precision value, and the 32-bit
floating-point status and control register FPSCR. The single-precision instructions (those ending in s, with primary opcode 59) round their result to single
precision; the double-precision ones (primary opcode 63) do not. A single-precision load converts the value to double, and a single-precision store converts it back. There is no
separate set of single registers.
A record form (a dotted mnemonic such as fadd.) copies the four exception summary bits of the FPSCR into cr1. The multiply-add instructions are fused: the
product is not rounded before the addition. In the table, frt and frs are the same bits of the word (destination and source), and fra, frb and
frc are the source registers. Most of the entries here are available in every PowerPC model; fsqrt and fsqrts are optional in the architecture and the 750 and the
G4 lack them.
The same registers are the first halves of the vector-scalar registers (see AltiVec and VSX), and the Gekko and Broadway processors treat them as pairs of singles (see paired singles).
Floating-point loads and stores
The operand forms are as for the integer loads and stores: d(ra) is a displacement from a base register (a zero ra means the value 0, not r0),
the x forms add two registers, and the u forms write the address back to ra.
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
lfs | frt, d(ra) | D 48 | all PowerPC | Load floating-point single (converted to double). |
lfsu | frt, d(ra) | D 49 | all PowerPC | Load floating-point single with update. |
lfsx | frt, ra, rb | X 31/535 | all PowerPC | Load floating-point single indexed. |
lfsux | frt, ra, rb | X 31/567 | all PowerPC | Load floating-point single with update indexed. |
lfd | frt, d(ra) | D 50 | all PowerPC | Load floating-point double. |
lfdu | frt, d(ra) | D 51 | all PowerPC | Load floating-point double with update. |
lfdx | frt, ra, rb | X 31/599 | all PowerPC | Load floating-point double indexed. |
lfdux | frt, ra, rb | X 31/631 | all PowerPC | Load floating-point double with update indexed. |
lfiwax | frt, ra, rb | X 31/855 | ISA 2.06 and later | Load floating-point as integer word algebraic indexed. |
lfiwzx | frt, ra, rb | X 31/887 | ISA 2.06 and later | Load floating-point as integer word and zero indexed. |
lfdp | frt, ds(ra) | DS 57/0 | ISA 2.05 and later | Load floating-point double pair. |
lfdpx | frt, ra, rb | X 31/791 | ISA 2.05 and later | Load floating-point double pair indexed. |
stfs | frs, d(ra) | D 52 | all PowerPC | Store floating-point single. |
stfsu | frs, d(ra) | D 53 | all PowerPC | Store floating-point single with update. |
stfsx | frs, ra, rb | X 31/663 | all PowerPC | Store floating-point single indexed. |
stfsux | frs, ra, rb | X 31/695 | all PowerPC | Store floating-point single with update indexed. |
stfd | frs, d(ra) | D 54 | all PowerPC | Store floating-point double. |
stfdu | frs, d(ra) | D 55 | all PowerPC | Store floating-point double with update. |
stfdx | frs, ra, rb | X 31/727 | all PowerPC | Store floating-point double indexed. |
stfdux | frs, ra, rb | X 31/759 | all PowerPC | Store floating-point double with update indexed. |
stfiwx | frs, ra, rb | X 31/983 | all PowerPC | Store floating-point as integer word indexed. |
stfdp | frs, ds(ra) | DS 61/0 | ISA 2.05 and later | Store floating-point double pair. |
stfdpx | frs, ra, rb | X 31/919 | ISA 2.05 and later | Store floating-point double pair indexed. |
Single-precision arithmetic
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
fadds, fadds. | frt, fra, frb | A 59/21 | all PowerPC | Floating add single. |
fsubs, fsubs. | frt, fra, frb | A 59/20 | all PowerPC | Floating subtract single. |
fmuls, fmuls. | frt, fra, frc | A 59/25 | all PowerPC | Floating multiply single. |
fdivs, fdivs. | frt, fra, frb | A 59/18 | all PowerPC | Floating divide single. |
fsqrts, fsqrts. | frt, frb | A 59/22 | all PowerPC with the optional square root (not the 750 or G4) | Floating square root single. |
fres, fres. | frt, frb | A 59/24 | all PowerPC | Floating reciprocal estimate single. |
frsqrtes, frsqrtes. | frt, frb | A 59/26 | all PowerPC | Floating reciprocal square root estimate single. |
fmadds, fmadds. | frt, fra, frc, frb | A 59/29 | all PowerPC | Floating multiply-add single: fra x frc + frb. |
fmsubs, fmsubs. | frt, fra, frc, frb | A 59/28 | all PowerPC | Floating multiply-subtract single: fra x frc - frb. |
fnmadds, fnmadds. | frt, fra, frc, frb | A 59/31 | all PowerPC | Floating negative multiply-add single. |
fnmsubs, fnmsubs. | frt, fra, frc, frb | A 59/30 | all PowerPC | Floating negative multiply-subtract single. |
fcfids, fcfids. | frt, frb | X 59/846 | ISA 2.06 and later | Floating convert from integer doubleword single. |
fcfidus, fcfidus. | frt, frb | X 59/974 | ISA 2.06 and later | Floating convert from unsigned integer doubleword single. |
Double-precision arithmetic
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
fadd, fadd. | frt, fra, frb | A 63/21 | all PowerPC | Floating add. |
fsub, fsub. | frt, fra, frb | A 63/20 | all PowerPC | Floating subtract. |
fmul, fmul. | frt, fra, frc | A 63/25 | all PowerPC | Floating multiply. |
fdiv, fdiv. | frt, fra, frb | A 63/18 | all PowerPC | Floating divide. |
fsqrt, fsqrt. | frt, frb | A 63/22 | all PowerPC with the optional square root (not the 750 or G4) | Floating square root. |
fsel, fsel. | frt, fra, frc, frb | A 63/23 | all PowerPC | Floating select: frc if fra >= 0, else frb. |
fre, fre. | frt, frb | A 63/24 | ISA 2.05 and later | Floating reciprocal estimate. |
frsqrte, frsqrte. | frt, frb | A 63/26 | all PowerPC | Floating reciprocal square root estimate. |
fmadd, fmadd. | frt, fra, frc, frb | A 63/29 | all PowerPC | Floating multiply-add: fra x frc + frb. |
fmsub, fmsub. | frt, fra, frc, frb | A 63/28 | all PowerPC | Floating multiply-subtract: fra x frc - frb. |
fnmadd, fnmadd. | frt, fra, frc, frb | A 63/31 | all PowerPC | Floating negative multiply-add. |
fnmsub, fnmsub. | frt, fra, frc, frb | A 63/30 | all PowerPC | Floating negative multiply-subtract. |
Compare, convert, round and move
The conversions to integer leave the result in the low bits of a floating-point register (store it with stfiwx or stfd, or move it with a VSX instruction); the z forms round toward zero,
the others use the rounding mode of the FPSCR. The compare instructions write the field bf of the condition register.
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
fcmpu | bf, fra, frb | X 63/0 | all PowerPC | Floating compare unordered. |
fcmpo | bf, fra, frb | X 63/32 | all PowerPC | Floating compare ordered. |
frsp, frsp. | frt, frb | X 63/12 | all PowerPC | Floating round to single precision. |
fctiw, fctiw. | frt, frb | X 63/14 | all PowerPC | Floating convert to integer word. |
fctiwz, fctiwz. | frt, frb | X 63/15 | all PowerPC | Floating convert to integer word with round toward zero. |
fctiwu, fctiwu. | frt, frb | X 63/142 | ISA 2.06 and later | Floating convert to unsigned integer word. |
fctiwuz, fctiwuz. | frt, frb | X 63/143 | ISA 2.06 and later | Floating convert to unsigned integer word with round toward zero. |
fctid, fctid. | frt, frb | X 63/814 | 64-bit | Floating convert to integer doubleword. |
fctidz, fctidz. | frt, frb | X 63/815 | 64-bit | Floating convert to integer doubleword with round toward zero. |
fctidu, fctidu. | frt, frb | X 63/942 | ISA 2.06 and later, 64-bit | Floating convert to unsigned integer doubleword. |
fctiduz, fctiduz. | frt, frb | X 63/943 | ISA 2.06 and later, 64-bit | Floating convert to unsigned integer doubleword with round toward zero. |
fcfid, fcfid. | frt, frb | X 63/846 | 64-bit | Floating convert from integer doubleword. |
fcfidu, fcfidu. | frt, frb | X 63/974 | ISA 2.06 and later, 64-bit | Floating convert from unsigned integer doubleword. |
frin, frin. | frt, frb | X 63/392 | 64-bit | Floating round to integer nearest. |
friz, friz. | frt, frb | X 63/424 | 64-bit | Floating round to integer toward zero. |
frip, frip. | frt, frb | X 63/456 | 64-bit | Floating round to integer plus (up). |
frim, frim. | frt, frb | X 63/488 | 64-bit | Floating round to integer minus (down). |
fmr, fmr. | frt, frb | X 63/72 | all PowerPC | Floating move register. |
fneg, fneg. | frt, frb | X 63/40 | all PowerPC | Floating negate. |
fabs, fabs. | frt, frb | X 63/264 | all PowerPC | Floating absolute value. |
fnabs, fnabs. | frt, frb | X 63/136 | all PowerPC | Floating negative absolute value. |
fcpsgn, fcpsgn. | frt, fra, frb | X 63/8 | ISA 2.05 and later | Floating copy sign. |
fmrgew | frt, fra, frb | X 63/966 | ISA 2.07 and later | Floating merge even word. |
fmrgow | frt, fra, frb | X 63/838 | ISA 2.07 and later | Floating merge odd word. |
ftdiv | bf, fra, frb | X 63/128 | ISA 2.06 and later | Floating test for software divide. |
ftsqrt | bf, frb | X 63/160 | ISA 2.06 and later | Floating test for software square root. |
The FPSCR
The FPSCR holds the exception status bits, the exception enables and the rounding mode. The rounding mode is its two low bits: 0 round to nearest, 1 toward zero, 2 toward plus infinity, 3 toward minus infinity.
The instructions move it to and from floating-point and condition registers. Each has a record form that copies the exception summary into cr1. The ISA 3.0 forms of mffs
(the last six rows) also change the rounding modes or clear the enables in the same step; they are decoded here although the explorer's table keeps them with the supervisor instructions.
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
mffs, mffs. | frt | X 63/583 | all PowerPC | Move from FPSCR. |
mcrfs | bf, bfa | X 63/64 | all PowerPC | Move to condition register from FPSCR field. |
mtfsfi, mtfsfi. | bf, u[, w] | X 63/134 | all PowerPC | Move to FPSCR field immediate. |
mtfsf, mtfsf. | flm, frb[, l, w] | XFL 63/711 | all PowerPC | Move to FPSCR fields: the fields FLM selects take their bits from frb. |
mtfsb0, mtfsb0. | bt | X 63/70 | all PowerPC | Move to FPSCR bit 0: clear bit BT. |
mtfsb1, mtfsb1. | bt | X 63/38 | all PowerPC | Move to FPSCR bit 1: set bit BT. |
mffsce | frt | X 63/583 (RA field 1) | ISA 3.0 and later | Move from FPSCR and clear enables. |
mffscdrn | frt, frb | X 63/583 (RA field 20) | ISA 3.0 and later | Move from FPSCR and set the decimal rounding mode. |
mffscdrni | frt, drm | X 63/583 (RA field 21) | ISA 3.0 and later | Move from FPSCR and set the decimal rounding mode immediate. |
mffscrn | frt, frb | X 63/583 (RA field 22) | ISA 3.0 and later | Move from FPSCR and set the rounding mode. |
mffscrni | frt, rnd | X 63/583 (RA field 23) | ISA 3.0 and later | Move from FPSCR and set the rounding mode immediate. |
mffsl | frt | X 63/583 (RA field 24) | ISA 3.0 and later | Move from FPSCR lightweight. |
Not described
Known, not yet covered
- Reference and viewer: decimal floating point (
dadd,dmuland the rest, POWER6 and later), and the ISA 3.0 quad-precision instructions (xsaddqpand others). - Reference: the layout of the
FPSCRbits beyond the rounding mode, and the exact exception behaviour of each instruction. - Reference: the VMX128 floating-point extension of the Xbox 360.
Unknown
- Reference: none known.
Links
Reference
- Power ISA – the instruction set architecture, from the OpenPOWER Foundation
- The LLVM code generator – the PowerPC target used to check the decoder