Helper function to serialize an APInt.
| 212 | |
| 213 | /// Helper function to serialize an APInt. |
| 214 | static void writeAPInt(const APInt &apInt, EncodingWriter &writer) { |
| 215 | unsigned bitWidth = apInt.getBitWidth(); |
| 216 | if (bitWidth <= 8) { |
| 217 | writer.writeByte(static_cast<uint8_t>(apInt.getLimitedValue())); |
| 218 | } else if (bitWidth <= 64) { |
| 219 | writer.writeSignedVarInt(apInt.getLimitedValue()); |
| 220 | } else { |
| 221 | unsigned numActiveWords = apInt.getActiveWords(); |
| 222 | writer.writeVarInt(numActiveWords); |
| 223 | const uint64_t *rawValueData = apInt.getRawData(); |
| 224 | for (unsigned i = 0; i < numActiveWords; ++i) |
| 225 | writer.writeSignedVarInt(rawValueData[i]); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /// Helper function to serialize the APFloat representation of a FloatAttr. |
| 230 | static void writeAPFloatRepresentation(const APFloat &apFloat, |
no test coverage detected