| 2 | #include <iomanip> |
| 3 | |
| 4 | void generateSelectVectorTable() { |
| 5 | std::cout << "const uint128_t select_vector_table[128] = {\n"; |
| 6 | |
| 7 | // 生成高64位部分 (索引 0-63) |
| 8 | for(int i = 0; i < 64; i++) { |
| 9 | uint64_t high = 1ULL << (63 - i); |
| 10 | uint64_t low = 0ULL; |
| 11 | |
| 12 | std::cout << " uint128_t(0x" |
| 13 | << std::hex << std::setfill('0') << std::setw(16) << high |
| 14 | << "ULL, 0x" |
| 15 | << std::hex << std::setfill('0') << std::setw(16) << low |
| 16 | << "ULL),"; |
| 17 | |
| 18 | std::cout << " // " << std::dec << i << "\n"; |
| 19 | } |
| 20 | |
| 21 | // 生成低64位部分 (索引 64-127) |
| 22 | for(int i = 64; i < 128; i++) { |
| 23 | uint64_t high = 0ULL; |
| 24 | uint64_t low = 1ULL << (127 - i); |
| 25 | |
| 26 | std::cout << " uint128_t(0x" |
| 27 | << std::hex << std::setfill('0') << std::setw(16) << high |
| 28 | << "ULL, 0x" |
| 29 | << std::hex << std::setfill('0') << std::setw(16) << low |
| 30 | << "ULL)"; |
| 31 | |
| 32 | // 最后一个元素不需要逗号 |
| 33 | if (i < 127) std::cout << ","; |
| 34 | std::cout << " // " << std::dec << i << "\n"; |
| 35 | } |
| 36 | |
| 37 | std::cout << "};\n"; |
| 38 | } |
| 39 | |
| 40 | int main() { |
| 41 | generateSelectVectorTable(); |