| 227 | } |
| 228 | |
| 229 | static size_t Encode(uint8_t* dst, uint64_t data_arm, uint64_t data_rip) { |
| 230 | auto vl8_type = reinterpret_cast<vl8_enc*>(dst); |
| 231 | auto vl16_type = reinterpret_cast<vl16_enc*>(dst); |
| 232 | auto vl32_type = reinterpret_cast<vl32_enc*>(dst); |
| 233 | auto vl64_type = reinterpret_cast<vl64_enc*>(dst); |
| 234 | |
| 235 | if (can_encode_vl8(data_arm, data_rip)) { |
| 236 | *vl8_type = { |
| 237 | .IntegerARMPC = static_cast<uint8_t>((data_arm - 1) >> vl8_arm_align_bits), |
| 238 | .IntegerX86RIP = static_cast<uint8_t>(data_rip - 1), |
| 239 | .Type = vl8_type_header, |
| 240 | }; |
| 241 | return sizeof(vl8_enc); |
| 242 | } else if (can_encode_vl16(data_arm, data_rip)) { |
| 243 | *vl16_type = { |
| 244 | .HighBits { |
| 245 | .IntegerX86RIP = static_cast<int8_t>(static_cast<int64_t>(data_rip)), |
| 246 | .Type = vl16_type_header, |
| 247 | }, |
| 248 | .IntegerARMPC = static_cast<int8_t>(static_cast<int64_t>(data_arm) >> vl8_arm_align_bits), |
| 249 | }; |
| 250 | return sizeof(vl16_enc); |
| 251 | } else if (can_encode_vl32(data_arm, data_rip)) { |
| 252 | *vl32_type = { |
| 253 | .Type = vl32_type_header, |
| 254 | .IntegerARMPC = static_cast<int32_t>(data_arm), |
| 255 | .IntegerX86RIP = static_cast<int32_t>(data_rip), |
| 256 | }; |
| 257 | return sizeof(vl32_enc); |
| 258 | } |
| 259 | |
| 260 | *vl64_type = { |
| 261 | .Type = vl64_type_header, |
| 262 | .IntegerARMPC = data_arm, |
| 263 | .IntegerX86RIP = data_rip, |
| 264 | }; |
| 265 | return sizeof(vl64_enc); |
| 266 | } |
| 267 | |
| 268 | private: |
| 269 | struct vl8_enc { |
nothing calls this directly
no outgoing calls
no test coverage detected