eliminate all uses of std.io.Writer.count except for CBE

This commit is contained in:
Andrew Kelley
2025-07-08 17:33:02 -07:00
parent d345a10054
commit bc2cf0c173
8 changed files with 81 additions and 94 deletions

View File

@@ -1016,8 +1016,8 @@ fn estimateInstructionLength(prefix: Prefix, encoding: Encoding, ops: []const Op
// By using a buffer with maximum length of encoded instruction, we can use
// the `end` field of the Writer for the count.
var buf: [16]u8 = undefined;
var trash = std.io.Writer.discarding(&buf);
inst.encode(&trash, .{
var trash: std.io.Writer.Discarding = .init(&buf);
inst.encode(&trash.writer, .{
.allow_frame_locs = true,
.allow_symbols = true,
}) catch {
@@ -1027,7 +1027,7 @@ fn estimateInstructionLength(prefix: Prefix, encoding: Encoding, ops: []const Op
// (`estimateInstructionLength`) has the wrong function signature.
@panic("unexpected failure to encode");
};
return @intCast(trash.end);
return trash.writer.end;
}
const mnemonic_to_encodings_map = init: {

View File

@@ -1390,8 +1390,8 @@ const x86_64 = struct {
// TODO: hack to force imm32s in the assembler
.{ .imm = .s(-129) },
}, t) catch return false;
var trash = std.io.Writer.discarding(&.{});
inst.encode(&trash, .{}) catch return false;
var trash: std.io.Writer.Discarding = .init(&.{});
inst.encode(&trash.writer, .{}) catch return false;
return true;
},
else => return false,