From: lkcl Date: Fri, 25 Dec 2020 21:56:13 +0000 (+0000) Subject: (no commit message) X-Git-Tag: convert-csv-opcode-to-binary~882 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ef6d8da36cf24cfc4dbb422bb53ec8a9246cd82a;p=libreriscv.git --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index 54958ba43..c911d72a7 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -36,3 +36,32 @@ uint_xlen_t sbext(uint_xlen_t rs1, uint_xlen_t rs2) { int shamt = rs2 & (XLEN - } return 1 & (rs1 >> shamt); ``` + +# shuffle / unshuffle + +``` +uint64_t shuffle64_stage(uint64_t src, uint64_t maskL, uint64_t maskR, int N) { uint64_t x = src & ~(maskL | maskR); +} +x |= ((src << N) & maskL) | ((src >> N) & maskR); return x; +uint64_t shfl64(uint64_t rs1, uint64_t rs2) { uint64_t x = rs1; +} +int shamt = rs2 & 31; +if (shamt & 16) x = shuffle64_stage(x, 0x0000ffff00000000LL, +0x00000000ffff0000LL, 16); if (shamt & 8) x = shuffle64_stage(x, 0x00ff000000ff0000LL, +0x0000ff000000ff00LL, 8); if (shamt & 4) x = shuffle64_stage(x, 0x0f000f000f000f00LL, +0x00f000f000f000f0LL, 4); if (shamt & 2) x = shuffle64_stage(x, 0x3030303030303030LL, +0x0c0c0c0c0c0c0c0cLL, 2); if (shamt & 1) x = shuffle64_stage(x, 0x4444444444444444LL, +return x; +0x2222222222222222LL, 1); +uint64_t unshfl64(uint64_t rs1, uint64_t rs2) { uint64_t x = rs1; +} +int shamt = rs2 & 31; +if (shamt & 1) x = shuffle64_stage(x, 0x4444444444444444LL, +0x2222222222222222LL, 1); if (shamt & 2) x = shuffle64_stage(x, 0x3030303030303030LL, +0x0c0c0c0c0c0c0c0cLL, 2); if (shamt & 4) x = shuffle64_stage(x, 0x0f000f000f000f00LL, +0x00f000f000f000f0LL, 4); if (shamt & 8) x = shuffle64_stage(x, 0x00ff000000ff0000LL, +0x0000ff000000ff00LL, 8); if (shamt & 16) x = shuffle64_stage(x, 0x0000ffff00000000LL, +return x; +0x00000000ffff0000LL, 16); +``` +