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. |
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, and the ISA 3.1 prefixed (8-byte) loads and stores.
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