3 See <https://bugs.libre-soc.org/show_bug.cgi?id=238>
5 This one is a conundrum. OpenPOWER ISA was never designed with 16
6 bit in mind. VLE was added 10 years ago but only by way of marking
7 an entire 64k page as "VLE". With no means to mix 32 bit and 16 bit,
8 jumping between the two would have been painful and taken up space.
10 Here, in order to embed 16 bit into a predominantly 32 bit stream the
11 overhead of using an entire 16 bits just to switch into Compressed mode
12 is itself a significant overhead. The situation is made worse by 5 bits
13 being taken up by Major Opcode space, leaving only 11 bits to allocate
14 to actual instructions.
16 In addition we would like to add SV-C32 which is a Vectorised version
17 of 16 bit Compressed, and ideally have a variant that adds the 27-bit
18 prefix format from SV-P64, as well.
20 Potential ways to reduce pressure on the 16 bit space are:
22 * To provide "paging". This involves bank-switching to alternative optimised encodings for specific workloads
23 * To enter "16 bit mode" for durations specified at the start
24 * To reserve one bit of every 16 bit instruction to indicate that the 16 bit mode is to continue to be sustained
26 This latter would be useful in the Vector context to have an alternative
27 meaning: as the bit which determines whether the instruction is 11-bit
28 prefixed or 27-bit prefixed:
30 0 1 2 3 4 5 6 7 8 9 a b c d e f |
31 |major op | 11 bit vector prefix|
32 |16 bit opcode alt vec. mode ^ |
33 | extra vector prefix if alt set|
35 Using a major opcode to enter 16 bit mode, leaves 11 bits to find
36 something to use them for:
38 0 1 2 3 4 5 6 7 8 9 a b c d e f |
39 |major op | what to do here 1 |
40 |16 bit stay in 16bit mode 1 |
41 |16 bit stay in 16bit mode 1 |
42 |16 bit exit 16bit mode 0 |
44 One possibility is that the 11 bits are used for bank selection, with
45 some room for additional context such as altering the registers used
46 for the 16 bit operations (bank selection of which scalar regs)
48 Another is to use the 11 bits for only the utmost commonly used
49 instructions. That being the case then even one of those 11 bits would
50 also need to be dedicated to saying if 16 bit mode is to be continued.
51 10 bits remain for actual opcodes!
53 # Opcode Allocation Ideas
55 ## Opcodes exploration (Attempt 1)
59 10 bit mode may be expanded by 16 bit mode later, adding capabilities
60 that do not fit in the extreme limited space.
62 | 0 1 | 2 3 4 | | 5 6 7 | 8 9 | a b | c d | e | f |
63 | offs2 | | 0 0 0 | offs | LK | 1 | b
64 | BO2 | BI3 | | 0 0 1 | 00 | BI | BO | LK | 1 | bclr
65 | BO2 | BI3 | | 0 0 1 | 01 | BI | BO | LK | 1 | bctar
69 * offs2 extends offset in MSBs
70 * BI3 extends BI in MSBs to allow selection of full CR
75 * BO[0] enables CR check, BO[1] inverts check
76 * BI refers to CR0 only (4 bits of)
77 * no Branch Conditional with immediate
79 * no CTR mode (and no bctr)
80 * offs is to 2 byte (signed) aligned
81 * all branches to 2 byte aligned
85 | 0 | 1 | 2 3 4 | | 5 6 7 | 8 9 | a b | c d | e | f |
86 | F | RA2 | RT | | 0 0 1 | 11 | RA | RB | 0 | 1 | ld
87 | F | RT2 | RB | | 0 0 1 | 11 | RA | RT | 1 | 1 | st
89 * elwidth overrides can set different widths
94 * RA2 extends RA to 3 bits (MSB)
95 * RT2 extends RT to 3 bits (MSB)
99 * RA and RB are only 2 bit (0-3)
100 * for LD, RT is implicitly RB: ld RT=RB, RA(RB)
101 * for ST, there is no offset: st RT, RA(0)
105 | 0 1 | 2 3 4 | | 5 6 7 | 8 9 a | b c d | e | f |
106 | | | | 0 1 0 | RB | RA | 0 | 1 | add
107 | | | | 0 1 0 | RB | RA | 1 | 1 | mul
108 | | | | 0 1 1 | RB | (RA|0)| 0 | 1 | sub
109 | | | | 0 1 1 | RB | (RA|0)| 1 | 1 | cmp
113 * cmp default target is CR0
114 * for (RA|0) when RA=0 the input is a zero immediate,
115 meaning that sub becomes neg, and cmp becomes cmp-against-zero
119 | 0 1 | 2 3 4 | | 5 6 7 | 8 9 a | b c d | e | f |
120 | | | | 1 0 0 | RB | RA | 0 | 1 | and
121 | | | | 1 0 0 | RB | RA | 1 | 1 | nand
122 | | | | 1 0 1 | RB | RA | 0 | 1 | or
123 | | | | 1 0 1 | RB | (RA|0)| 1 | 1 | nor
127 * for (RA|0) when RA=0 the input is a zero immediate,
128 meaning that nor becomes not
132 | 0 1 | 2 3 4 | | 5 6 7 | 8 9 a | b c d | e | f |
133 | | RT | | 1 1 0 | RB | RA!=0 | 0 | 1 | fadd
134 | | RT | | 1 1 0 | RB | 0 0 0 | 0 | 1 | fabs
135 | | RT | | 1 1 0 | RB | RA | 1 | 1 | fmul
136 | | RT | | 1 1 1 | RB | (RA|0)| 0 | 1 | fsub
137 | | RT | | 1 1 1 | RB | (RA|0)| 1 | 1 | fcmp
141 * fcmp default target is CR1
142 * for (RA|0) when RA=0 the input is a zero immediate,
143 meaning that fsub becomes fneg, and fcmp becomes fcmp-against-zero
145 ### Condition Register
147 | 0 1 2 3 | 4 | | 5 6 7 | 8 9 | a b | c d e | f |
148 | 0 0 0 0 | BF2 | | 0 0 1 | 10 | BF | BFA | 1 | mcrf
149 | 0 0 0 1 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | crnor
150 | 0 1 0 0 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | crandc
151 | 0 1 1 0 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | crxor
152 | 0 1 1 1 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | crnand
153 | 1 0 0 0 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | crand
154 | 1 0 0 1 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | creqv
155 | 1 1 0 1 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | crorc
156 | 1 1 1 0 | BA2 | | 0 0 1 | 10 | BA | BB | 1 | cror
160 * mcrf BF is only 2 bits which means the destination is only CR0-CR3
164 * mcrf BF2 extends BF (in MSB) to 3 bits
165 * CR operations: destination register is same as BA.
166 * CR operations: only possible on CR0 and CR1
170 * CR operations: greatly extended reach/range (useful for predicates)