================ @@ -228,6 +229,42 @@ void emit(Program &P, std::vector<std::byte> &Code, const Floating &Val, Val.serialize(Code.data() + ValPos); } +template <> +void emit(Program &P, std::vector<std::byte> &Code, + const IntegralAP<false> &Val, bool &Success) { + size_t Size = Val.bytesToSerialize(); + + if (Code.size() + Size > std::numeric_limits<unsigned>::max()) { + Success = false; + return; + } + + // Access must be aligned! + size_t ValPos = align(Code.size()); + Size = align(Size); + assert(aligned(ValPos + Size)); + Code.resize(ValPos + Size); + Val.serialize(Code.data() + ValPos); +} + +template <> +void emit(Program &P, std::vector<std::byte> &Code, const IntegralAP<true> &Val, + bool &Success) { + size_t Size = Val.bytesToSerialize(); + + if (Code.size() + Size > std::numeric_limits<unsigned>::max()) { + Success = false; + return; + } + + // Access must be aligned! + size_t ValPos = align(Code.size()); + Size = align(Size); + assert(aligned(ValPos + Size)); + Code.resize(ValPos + Size); + Val.serialize(Code.data() + ValPos); +} ---------------- AaronBallman wrote:
Could we be overly clever and use an NTTP here so it's `const IntegralAP<IsUnsigned>` or is that way too awkward given this is already in a template specialization? https://github.com/llvm/llvm-project/pull/79747 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits