1 # RFC ls004 Shift-And-Add
5 * <https://libre-soc.org/openpower/sv/biginteger/analysis/>
6 * <https://libre-soc.org/openpower/sv/rfc/ls004/>
7 * <https://bugs.libre-soc.org/show_bug.cgi?id=960>
8 * <https://git.openpower.foundation/isa/PowerISA/issues/91>
9 * shift-and-add <https://bugs.libre-soc.org/show_bug.cgi?id=968>
21 **Books and Section affected**:
24 Book I Fixed-Point Shift Instructions 3.3.14.2
25 Appendix E Power ISA sorted by opcode
26 Appendix F Power ISA sorted by version
27 Appendix G Power ISA sorted by Compliancy Subset
28 Appendix H Power ISA sorted by mnemonic
36 shadduw - Shift and Add Unsigned Word
39 **Submitter**: Luke Leighton (Libre-SOC)
41 **Requester**: Libre-SOC
43 **Impact on processor**:
46 Addition of two new GPR-based instructions
49 **Impact on software**:
52 Requires support for new instructions in assembler, debuggers,
59 GPR, Big-manip, Shift, Arithmetic
64 Power ISA is missing LD/ST with shift, which is present in both ARM and x86.
65 Adding more LD/ST is too complex, a compromise is to add shift-and-add.
66 Replaces a pair of explicit instructions in hot-loops.
68 **Notes and Observations**:
70 1. `shadd` and `shadduw` operate on unsigned integers.
71 2. `shadduw` masks the upper 32-bits of the operand to-be-shifted.
72 3. These are both 2-in 1-out instructions.
76 Add the following entries to:
78 * the Appendices of Book I
79 * Instructions of Book I added to Section 3.3.14.2
89 | 0-5 | 6-10 | 11-15 | 16-20 | 21-22 | 23-30 | 31 | Form |
90 |-------|------|-------|-------|-------|-------|----|----------|
91 | PO | RT | RA | RB | sm | XO | Rc | Z23-Form |
95 shift <- sm + 1 # Shift is between 1-4
96 sum[0:63] <- ((RB) << shift) + (RA) # Shift RB, add RA
97 RT <- sum # Result stored in RT
99 `shift` is determined by the 2-bit bitfield `sm`+1.
100 The minimum shift as 1, maximum 4.
101 The result is shifted (RB) + (RA), and is stored in register RT.
103 Operands RA and RB, and the result RT are all 64-bit, unsigned integers.
105 **NEED EXAMPLES (not sure how to embedd sm)!!!**
113 # Shift-and-Add Unsigned Word
117 | 0-5 | 6-10 | 11-15 | 16-20 | 21-22 | 23-30 | 31 | Form |
118 |-------|------|-------|-------|-------|-------|----|----------|
119 | PO | RT | RA | RB | sm | XO | Rc | Z23-Form |
123 shift <- shift + 1 # Shift is between 1-4
124 n <- (RB)[XLEN/2:XLEN-1] # Limit RB to upper word (32-bits)
125 sum[0:63] <- (n << shift) + (RA) # Shift n, add RA
126 RT <- sum # Result stored in RT
128 `shift` is determined by the 2-bit bitfield `sm`+1.
129 Mask (RB) to only use the upper word (32-bits).
130 The minimum shift as 1, maximum 4.
131 The result is shifted `n` + (RA), and is stored in register RT.
133 Operands RA and RB, and the result RT are all 64-bit, unsigned integers.
147 Appendix E Power ISA sorted by opcode
148 Appendix F Power ISA sorted by version
149 Appendix G Power ISA sorted by Compliancy Subset
150 Appendix H Power ISA sorted by mnemonic
152 | Form | Book | Page | Version | mnemonic | Description |
153 |------|------|------|---------|----------|-------------|
154 | Z23 | I | # | 3.0B | shadd | Shift-and-Add |
155 | Z23 | I | # | 3.0B | shadduw | Shift-and-Add Unsigned Word |