| NN | RT | RA | RB | 1 | 11 | 1001 110 |Rc| grevlutr | X-Form |
| NN | RT | RA | RB | 0 | itype | 1101 110 |Rc| shadd | X-Form |
| NN | RT | RA | RB | 1 | itype | 1101 110 |Rc| shadduw | X-Form |
-| NN | RT | RA | RB | 0 | 00 | 0010 110 |Rc| gorc | X-Form |
-| NN | RS | RA | sh | SH | 00 | 1010 110 |Rc| gorci | XB-Form |
-| NN | RT | RA | RB | 0 | 00 | 0110 110 |Rc| gorcw | X-Form |
-| NN | RS | RA | SH | 0 | 00 | 1110 110 |Rc| gorcwi | X-Form |
+| NN | RT | RA | RB | 0 | 00 | 0010 110 |Rc| rsvd | |
+| NN | RS | RA | sh | SH | 00 | 1010 110 |Rc| rsvd | |
+| NN | RT | RA | RB | 0 | 00 | 0110 110 |Rc| rsvd | |
+| NN | RS | RA | SH | 0 | 00 | 1110 110 |Rc| rsvd | |
| NN | RT | RA | RB | 1 | 00 | 1110 110 |Rc| rsvd | |
-| NN | RT | RA | RB | 0 | 01 | 0010 110 |Rc| grev | X-Form |
+| NN | RT | RA | RB | 0 | 01 | 0010 110 |Rc| rsvd | |
| NN | RT | RA | RB | 1 | 01 | 0010 110 |Rc| clmulr | X-Form |
-| NN | RS | RA | sh | SH | 01 | 1010 110 |Rc| grevi | XB-Form |
-| NN | RT | RA | RB | 0 | 01 | 0110 110 |Rc| grevw | X-Form |
-| NN | RS | RA | SH | 0 | 01 | 1110 110 |Rc| grevwi | X-Form |
+| NN | RS | RA | sh | SH | 01 | 1010 110 |Rc| rsvd | |
+| NN | RT | RA | RB | 0 | 01 | 0110 110 |Rc| rsvd | |
+| NN | RS | RA | SH | 0 | 01 | 1110 110 |Rc| rsvd | |
| NN | RT | RA | RB | 1 | 01 | 1110 110 |Rc| rsvd | |
| NN | RS | RA | RB | 0 | 10 | 0010 110 |Rc| bmator | X-Form |
| NN | RS | RA | RB | 0 | 10 | 0110 110 |Rc| bmatand | X-Form |
| NN | RT | RA | RB | im0-7 | 01 |0 | grevlog | |
| NN | RT | RA | RB | im0-7 | 01 |1 | grevlogw | |
-# grev
-
-superceded by grevlut
-
-based on RV bitmanip, this is also known as a butterfly network. however
-where a butterfly network allows setting of every crossbar setting in
-every row and every column, generalised-reverse (grev) only allows
-a per-row decision: every entry in the same row must either switch or
-not-switch.
-
-<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Butterfly_Network.jpg/474px-Butterfly_Network.jpg" />
-
-```
-uint64_t grev64(uint64_t RA, uint64_t RB)
-{
- uint64_t x = RA;
- int shamt = RB & 63;
- if (shamt & 1) x = ((x & 0x5555555555555555LL) << 1) |
- ((x & 0xAAAAAAAAAAAAAAAALL) >> 1);
- if (shamt & 2) x = ((x & 0x3333333333333333LL) << 2) |
- ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2);
- if (shamt & 4) x = ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) |
- ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4);
- if (shamt & 8) x = ((x & 0x00FF00FF00FF00FFLL) << 8) |
- ((x & 0xFF00FF00FF00FF00LL) >> 8);
- if (shamt & 16) x = ((x & 0x0000FFFF0000FFFFLL) << 16) |
- ((x & 0xFFFF0000FFFF0000LL) >> 16);
- if (shamt & 32) x = ((x & 0x00000000FFFFFFFFLL) << 32) |
- ((x & 0xFFFFFFFF00000000LL) >> 32);
- return x;
-}
-
-```
-
-# gorc
-
-based on RV bitmanip, gorc is superceded by grevlut
-
-```
-uint32_t gorc32(uint32_t RA, uint32_t RB)
-{
- uint32_t x = RA;
- int shamt = RB & 31;
- if (shamt & 1) x |= ((x & 0x55555555) << 1) | ((x & 0xAAAAAAAA) >> 1);
- if (shamt & 2) x |= ((x & 0x33333333) << 2) | ((x & 0xCCCCCCCC) >> 2);
- if (shamt & 4) x |= ((x & 0x0F0F0F0F) << 4) | ((x & 0xF0F0F0F0) >> 4);
- if (shamt & 8) x |= ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8);
- if (shamt & 16) x |= ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16);
- return x;
-}
-uint64_t gorc64(uint64_t RA, uint64_t RB)
-{
- uint64_t x = RA;
- int shamt = RB & 63;
- if (shamt & 1) x |= ((x & 0x5555555555555555LL) << 1) |
- ((x & 0xAAAAAAAAAAAAAAAALL) >> 1);
- if (shamt & 2) x |= ((x & 0x3333333333333333LL) << 2) |
- ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2);
- if (shamt & 4) x |= ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) |
- ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4);
- if (shamt & 8) x |= ((x & 0x00FF00FF00FF00FFLL) << 8) |
- ((x & 0xFF00FF00FF00FF00LL) >> 8);
- if (shamt & 16) x |= ((x & 0x0000FFFF0000FFFFLL) << 16) |
- ((x & 0xFFFF0000FFFF0000LL) >> 16);
- if (shamt & 32) x |= ((x & 0x00000000FFFFFFFFLL) << 32) |
- ((x & 0xFFFFFFFF00000000LL) >> 32);
- return x;
-}
-
-```
-
# xperm
based on RV bitmanip.
b = VSR[VRB+32].dword[i].byte[k].bit[j]
VSR[VRT+32].dword[i].byte[j].bit[k] = b
+## grev
+
+superceded by grevlut
+
+based on RV bitmanip, this is also known as a butterfly network. however
+where a butterfly network allows setting of every crossbar setting in
+every row and every column, generalised-reverse (grev) only allows
+a per-row decision: every entry in the same row must either switch or
+not-switch.
+
+<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Butterfly_Network.jpg/474px-Butterfly_Network.jpg" />
+
+```
+uint64_t grev64(uint64_t RA, uint64_t RB)
+{
+ uint64_t x = RA;
+ int shamt = RB & 63;
+ if (shamt & 1) x = ((x & 0x5555555555555555LL) << 1) |
+ ((x & 0xAAAAAAAAAAAAAAAALL) >> 1);
+ if (shamt & 2) x = ((x & 0x3333333333333333LL) << 2) |
+ ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2);
+ if (shamt & 4) x = ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) |
+ ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4);
+ if (shamt & 8) x = ((x & 0x00FF00FF00FF00FFLL) << 8) |
+ ((x & 0xFF00FF00FF00FF00LL) >> 8);
+ if (shamt & 16) x = ((x & 0x0000FFFF0000FFFFLL) << 16) |
+ ((x & 0xFFFF0000FFFF0000LL) >> 16);
+ if (shamt & 32) x = ((x & 0x00000000FFFFFFFFLL) << 32) |
+ ((x & 0xFFFFFFFF00000000LL) >> 32);
+ return x;
+}
+
+```
+
+## gorc
+
+based on RV bitmanip, gorc is superceded by grevlut
+
+```
+uint32_t gorc32(uint32_t RA, uint32_t RB)
+{
+ uint32_t x = RA;
+ int shamt = RB & 31;
+ if (shamt & 1) x |= ((x & 0x55555555) << 1) | ((x & 0xAAAAAAAA) >> 1);
+ if (shamt & 2) x |= ((x & 0x33333333) << 2) | ((x & 0xCCCCCCCC) >> 2);
+ if (shamt & 4) x |= ((x & 0x0F0F0F0F) << 4) | ((x & 0xF0F0F0F0) >> 4);
+ if (shamt & 8) x |= ((x & 0x00FF00FF) << 8) | ((x & 0xFF00FF00) >> 8);
+ if (shamt & 16) x |= ((x & 0x0000FFFF) << 16) | ((x & 0xFFFF0000) >> 16);
+ return x;
+}
+uint64_t gorc64(uint64_t RA, uint64_t RB)
+{
+ uint64_t x = RA;
+ int shamt = RB & 63;
+ if (shamt & 1) x |= ((x & 0x5555555555555555LL) << 1) |
+ ((x & 0xAAAAAAAAAAAAAAAALL) >> 1);
+ if (shamt & 2) x |= ((x & 0x3333333333333333LL) << 2) |
+ ((x & 0xCCCCCCCCCCCCCCCCLL) >> 2);
+ if (shamt & 4) x |= ((x & 0x0F0F0F0F0F0F0F0FLL) << 4) |
+ ((x & 0xF0F0F0F0F0F0F0F0LL) >> 4);
+ if (shamt & 8) x |= ((x & 0x00FF00FF00FF00FFLL) << 8) |
+ ((x & 0xFF00FF00FF00FF00LL) >> 8);
+ if (shamt & 16) x |= ((x & 0x0000FFFF0000FFFFLL) << 16) |
+ ((x & 0xFFFF0000FFFF0000LL) >> 16);
+ if (shamt & 32) x |= ((x & 0x00000000FFFFFFFFLL) << 32) |
+ ((x & 0xFFFFFFFF00000000LL) >> 32);
+ return x;
+}
+
+```
+
+
# Appendix
see [[bitmanip/appendix]]