Introduction
Only loads and stores touch memory. The effective address is either a displacement form, d(ra), a signed 16-bit displacement added to a base register, or an
indexed form (the mnemonic ends in x), ra, rb, the sum of two registers. In both, a zero ra field means the value 0 and not the register
r0; in the table that is the operand written ra in a memory operand. The update forms (a u in the name) also write the effective address back to ra,
and need ra to be non-zero. A load that ends in z zero-extends, one that ends in a (algebraic) sign-extends.
Memory is big-endian unless the processor runs in little-endian mode (see the byte order option). The byte-reversed loads and stores
(lwbrx and the others) exchange the byte order of the access and are how a program reads data of the other byte order. The doubleword forms need a 64-bit model.
The floating-point loads and stores are on the floating point page (for example lfs and stfd), the vector loads and stores on the AltiVec page (lvx, stvx, the data stream instructions), the vector-scalar ones on its VSX section (lxvd2x and the others, and the quadword lq), and the quantized loads of the Gekko on its page.
Integer loads
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
lbz | rt, d(ra) | D 34 | all PowerPC | Load byte and zero. |
lbzu | rt, d(ra) | D 35 | all PowerPC | Load byte and zero with update (ra gets the address). |
lbzx | rt, ra, rb | X 31/87 | all PowerPC | Load byte and zero indexed. |
lbzux | rt, ra, rb | X 31/119 | all PowerPC | Load byte and zero with update indexed. |
lhz | rt, d(ra) | D 40 | all PowerPC | Load halfword and zero. |
lhzu | rt, d(ra) | D 41 | all PowerPC | Load halfword and zero with update. |
lhzx | rt, ra, rb | X 31/279 | all PowerPC | Load halfword and zero indexed. |
lhzux | rt, ra, rb | X 31/311 | all PowerPC | Load halfword and zero with update indexed. |
lha | rt, d(ra) | D 42 | all PowerPC | Load halfword algebraic (sign extended). |
lhau | rt, d(ra) | D 43 | all PowerPC | Load halfword algebraic with update. |
lhax | rt, ra, rb | X 31/343 | all PowerPC | Load halfword algebraic indexed. |
lhaux | rt, ra, rb | X 31/375 | all PowerPC | Load halfword algebraic with update indexed. |
lwz | rt, d(ra) | D 32 | all PowerPC | Load word and zero. |
lwzu | rt, d(ra) | D 33 | all PowerPC | Load word and zero with update. |
lwzx | rt, ra, rb | X 31/23 | all PowerPC | Load word and zero indexed. |
lwzux | rt, ra, rb | X 31/55 | all PowerPC | Load word and zero with update indexed. |
lwa | rt, ds(ra) | DS 58/2 | 64-bit | Load word algebraic (sign extended to 64 bits). The displacement is a multiple of four. |
lwax | rt, ra, rb | X 31/341 | 64-bit | Load word algebraic indexed. |
lwaux | rt, ra, rb | X 31/373 | 64-bit | Load word algebraic with update indexed. |
ld | rt, ds(ra) | DS 58/0 | 64-bit | Load doubleword. |
ldu | rt, ds(ra) | DS 58/1 | 64-bit | Load doubleword with update. |
ldx | rt, ra, rb | X 31/21 | 64-bit | Load doubleword indexed. |
ldux | rt, ra, rb | X 31/53 | 64-bit | Load doubleword with update indexed. |
lmw | rt, d(ra) | D 46 | all PowerPC | Load multiple words: rt to r31 from consecutive words. |
lswi | rt, ra, nb | X 31/597 | all PowerPC | Load string word immediate: NB bytes into consecutive registers. |
lswx | rt, ra, rb | X 31/533 | all PowerPC | Load string word indexed: the byte count is in XER. |
lhbrx | rt, ra, rb | X 31/790 | all PowerPC | Load halfword byte-reversed indexed. |
lwbrx | rt, ra, rb | X 31/534 | all PowerPC | Load word byte-reversed indexed. |
ldbrx | rt, ra, rb | X 31/532 | 64-bit, ISA 2.05 and later | Load doubleword byte-reversed indexed. |
Integer stores
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
stb | rs, d(ra) | D 38 | all PowerPC | Store byte. |
stbu | rs, d(ra) | D 39 | all PowerPC | Store byte with update. |
stbx | rs, ra, rb | X 31/215 | all PowerPC | Store byte indexed. |
stbux | rs, ra, rb | X 31/247 | all PowerPC | Store byte with update indexed. |
sth | rs, d(ra) | D 44 | all PowerPC | Store halfword. |
sthu | rs, d(ra) | D 45 | all PowerPC | Store halfword with update. |
sthx | rs, ra, rb | X 31/407 | all PowerPC | Store halfword indexed. |
sthux | rs, ra, rb | X 31/439 | all PowerPC | Store halfword with update indexed. |
stw | rs, d(ra) | D 36 | all PowerPC | Store word. |
stwu | rs, d(ra) | D 37 | all PowerPC | Store word with update. stwu r1, -32(r1) is the usual stack frame allocation. |
stwx | rs, ra, rb | X 31/151 | all PowerPC | Store word indexed. |
stwux | rs, ra, rb | X 31/183 | all PowerPC | Store word with update indexed. |
std | rs, ds(ra) | DS 62/0 | 64-bit | Store doubleword. |
stdu | rs, ds(ra) | DS 62/1 | 64-bit | Store doubleword with update. |
stdx | rs, ra, rb | X 31/149 | 64-bit | Store doubleword indexed. |
stdux | rs, ra, rb | X 31/181 | 64-bit | Store doubleword with update indexed. |
stmw | rs, d(ra) | D 47 | all PowerPC | Store multiple words: rs to r31. |
stswi | rs, ra, nb | X 31/725 | all PowerPC | Store string word immediate. |
stswx | rs, ra, rb | X 31/661 | all PowerPC | Store string word indexed. |
sthbrx | rs, ra, rb | X 31/918 | all PowerPC | Store halfword byte-reversed indexed. |
stwbrx | rs, ra, rb | X 31/662 | all PowerPC | Store word byte-reversed indexed. |
stdbrx | rs, ra, rb | X 31/660 | 64-bit, ISA 2.05 and later | Store doubleword byte-reversed indexed. |
Prefixed loads and stores (Power ISA 3.1)
POWER10 adds loads and stores with a 34-bit signed displacement. Each is eight bytes: a prefix word (primary opcode 1) and a suffix word that is the ordinary D-form load or store
(the same register fields, its 16-bit displacement field being the low half d1). The prefix holds the type (bits 6 to 7: 0 for the 8LS forms, 2 for the MLS forms), the bit
R (bit 11) and the upper 18 bits d0 of the displacement; the effective address is ra + (d0 || d1), and with R = 1 it is the address of the
prefix word plus the displacement, with ra = 0. Bits 8 to 10 and 12 to 13 of the prefix are reserved and must be zero. The explorer writes d(ra) and, when R is 1, d(0), 1
(llvm’s syntax); GNU omits the (0). A prefixed instruction may not cross a 64-byte boundary. The forms are the ones GNU binutils 2.47 and llvm 22.1.8 decode (checked in
parser-test/test-ppc-fixes2.mjs on about 150,000 words); the Power ISA 3.1 book was not read. Opcodes 50, 51, 54 and 55 are plxv and pstxv (the low bit of the suffix opcode is the high bit of the VSX register number); the quadword forms need an even register and, for plq, ra different from rt.
llvm has no plq and pstq; GNU accepts an odd register for them, the explorer calls that an invalid form.
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
plbz | rt, d34(ra), r | MLS:D, suffix 34 | ISA 3.1, POWER10 | Prefixed load byte and zero. |
plhz | rt, d34(ra), r | MLS:D, suffix 40 | ISA 3.1, POWER10 | Prefixed load halfword and zero. |
plha | rt, d34(ra), r | MLS:D, suffix 42 | ISA 3.1, POWER10 | Prefixed load halfword algebraic. |
plwz | rt, d34(ra), r | MLS:D, suffix 32 | ISA 3.1, POWER10 | Prefixed load word and zero. |
plwa | rt, d34(ra), r | 8LS:D, suffix 41 | ISA 3.1, POWER10 | Prefixed load word algebraic. |
pld | rt, d34(ra), r | 8LS:D, suffix 57 | ISA 3.1, POWER10 | Prefixed load doubleword. |
plq | rtp, d34(ra), r | 8LS:D, suffix 56 | ISA 3.1, POWER10 | Prefixed load quadword (an even-odd register pair). |
pstb | rs, d34(ra), r | MLS:D, suffix 38 | ISA 3.1, POWER10 | Prefixed store byte. |
psth | rs, d34(ra), r | MLS:D, suffix 44 | ISA 3.1, POWER10 | Prefixed store halfword. |
pstw | rs, d34(ra), r | MLS:D, suffix 36 | ISA 3.1, POWER10 | Prefixed store word. |
pstd | rs, d34(ra), r | 8LS:D, suffix 61 | ISA 3.1, POWER10 | Prefixed store doubleword. |
pstq | rsp, d34(ra), r | 8LS:D, suffix 60 | ISA 3.1, POWER10 | Prefixed store quadword (an even-odd register pair). |
plfs | frt, d34(ra), r | MLS:D, suffix 48 | ISA 3.1, POWER10 | Prefixed load floating-point single. |
plfd | frt, d34(ra), r | MLS:D, suffix 50 | ISA 3.1, POWER10 | Prefixed load floating-point double. |
pstfs | frs, d34(ra), r | MLS:D, suffix 52 | ISA 3.1, POWER10 | Prefixed store floating-point single. |
pstfd | frs, d34(ra), r | MLS:D, suffix 54 | ISA 3.1, POWER10 | Prefixed store floating-point double. |
plxsd | vrt, d34(ra), r | 8LS:D, suffix 42 | ISA 3.1, POWER10 | Prefixed load VSX scalar doubleword to a vector register. |
plxssp | vrt, d34(ra), r | 8LS:D, suffix 43 | ISA 3.1, POWER10 | Prefixed load VSX scalar single-precision. |
pstxsd | vrs, d34(ra), r | 8LS:D, suffix 46 | ISA 3.1, POWER10 | Prefixed store VSX scalar doubleword. |
pstxssp | vrs, d34(ra), r | 8LS:D, suffix 47 | ISA 3.1, POWER10 | Prefixed store VSX scalar single-precision. |
plxv | xt, d34(ra), r | 8LS:D, suffix 50 or 51 | ISA 3.1, POWER10 | Prefixed load VSX vector (16 bytes). |
pstxv | xs, d34(ra), r | 8LS:D, suffix 54 or 55 | ISA 3.1, POWER10 | Prefixed store VSX vector. |
plxvp | xtp, d34(ra), r | 8LS:D, suffix 58 | ISA 3.1, POWER10 | Prefixed load VSX vector pair (32 bytes). |
pstxvp | xsp, d34(ra), r | 8LS:D, suffix 62 | ISA 3.1, POWER10 | Prefixed store VSX vector pair. |
The prefixed add immediate (paddi, pli, pla) is on the integer page; pnop too.
Atomic instructions
An atomic read-modify-write is a load-and-reserve (lwarx) followed by a store-conditional (stwcx.) to the same address, with the update in between. The store succeeds, and
sets cr0[EQ], only if no other processor has written the reserved location since the load; otherwise the program branches back and tries again. The store-conditional instructions always set
cr0, so they only exist as dotted mnemonics. The optional eh operand of a load-and-reserve is a hint that the reservation will be held in a lock loop. The ISA 3.0 lwat, ldat and
their stores perform one fetch-and-operate (add, increment, swap and others, chosen by fc) in a single instruction.
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
lbarx | rt, ra, rb[, eh] | X 31/52 | ISA 2.06 and later | Load byte and reserve indexed. |
lharx | rt, ra, rb[, eh] | X 31/116 | ISA 2.06 and later | Load halfword and reserve indexed. |
lwarx | rt, ra, rb[, eh] | X 31/20 | all PowerPC | Load word and reserve indexed (the start of an atomic update). |
ldarx | rt, ra, rb[, eh] | X 31/84 | 64-bit | Load doubleword and reserve indexed. |
lqarx | rt, ra, rb[, eh] | X 31/276 | ISA 2.06 and later, 64-bit | Load quadword and reserve indexed (rt is an even register). |
lwat | rt, ra, fc | X 31/582 | ISA 3.0 and later | Load word atomic: a fetch-and-operate chosen by FC. |
ldat | rt, ra, fc | X 31/614 | ISA 3.0 and later, 64-bit | Load doubleword atomic. |
stbcx. | rs, ra, rb | X 31/694 | ISA 2.06 and later | Store byte conditional indexed. |
sthcx. | rs, ra, rb | X 31/726 | ISA 2.06 and later | Store halfword conditional indexed. |
stwcx. | rs, ra, rb | X 31/150 | all PowerPC | Store word conditional indexed (the end of an atomic update). |
stdcx. | rs, ra, rb | X 31/214 | 64-bit | Store doubleword conditional indexed. |
stqcx. | rs, ra, rb | X 31/182 | ISA 2.06 and later, 64-bit | Store quadword conditional indexed. |
stwat | rs, ra, fc | X 31/710 | ISA 3.0 and later | Store word atomic. |
stdat | rs, ra, fc | X 31/742 | ISA 3.0 and later, 64-bit | Store doubleword atomic. |
Cache control and synchronisation
The cache instructions act on the cache block that holds the effective address. The data cache block touch instructions (dcbt, dcbtst) are prefetch hints and never fault.
sync orders all earlier storage accesses before any later one; with simplified mnemonics on the explorer writes its L field as lwsync (1, a lighter barrier) and ptesync (2).
eieio orders accesses to I/O and to other storage separately. The supervisor-only dcbi is on the supervisor page, and the Gekko's dcbz_l on
its own page.
| Mnemonic | Operands | Form and opcode | Available in | What it does |
|---|---|---|---|---|
sync, lwsync, ptesync | [l] | X 31/598 | all PowerPC | Synchronise: all earlier storage accesses complete first (L selects the lwsync and ptesync forms). |
eieio | none | X 31/854 | all PowerPC | Enforce in-order execution of I/O. |
dcbf | ra, rb[, l] | X 31/86 | all PowerPC | Data cache block flush. |
dcbst | ra, rb | X 31/54 | all PowerPC | Data cache block store. |
dcbt | ra, rb[, th] | X 31/278 | all PowerPC | Data cache block touch (a prefetch hint). |
dcbtst | ra, rb[, th] | X 31/246 | all PowerPC | Data cache block touch for store. |
dcbz | ra, rb | X 31/1014 | all PowerPC | Data cache block set to zero. |
dcba | ra, rb | X 31/758 | all PowerPC | Data cache block allocate. |
icbi | ra, rb | X 31/982 | all PowerPC | Instruction cache block invalidate. |
icbt | ct, ra, rb | X 31/22 | ISA 2.03 and later | Instruction cache block touch. |
eciwx | rt, ra, rb | X 31/310 | all PowerPC | External control in word indexed. |
ecowx | rs, ra, rb | X 31/438 | all PowerPC | External control out word indexed. |
Not described
Known, not yet covered
- Reference: alignment rules and the exceptions an unaligned access raises on each model; the memory-ordering rules in detail.
- Reference: the meaning of the
thoperand ofdcbtand of thefcfunction codes of the atomic instructions beyond “chosen by FC”. - Reference and viewer: the Book E and embedded cache instructions. The ISA 3.1 text for the prefixed loads and stores was not read (GNU and llvm behaviour only).
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