| ... | @@ -8,7 +8,7 @@ const Type = @import("../Type.zig"); | ... | @@ -8,7 +8,7 @@ const Type = @import("../Type.zig"); |
| 8 | const Air = @import("../Air.zig"); | 8 | const Air = @import("../Air.zig"); |
| 9 | const InternPool = @import("../InternPool.zig"); | 9 | const InternPool = @import("../InternPool.zig"); |
| 10 | | 10 | |
| 11 | pub fn write(air: Air, stream: anytype, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { | 11 | pub fn write(air: Air, stream: *std.io.BufferedWriter, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { |
| 12 | comptime std.debug.assert(build_options.enable_debug_extensions); | 12 | comptime std.debug.assert(build_options.enable_debug_extensions); |
| 13 | const instruction_bytes = air.instructions.len * | 13 | const instruction_bytes = air.instructions.len * |
| 14 | // Here we don't use @sizeOf(Air.Inst.Data) because it would include | 14 | // Here we don't use @sizeOf(Air.Inst.Data) because it would include |
| ... | @@ -54,7 +54,7 @@ pub fn write(air: Air, stream: anytype, pt: Zcu.PerThread, liveness: ?Air.Livene | ... | @@ -54,7 +54,7 @@ pub fn write(air: Air, stream: anytype, pt: Zcu.PerThread, liveness: ?Air.Livene |
| 54 | | 54 | |
| 55 | pub fn writeInst( | 55 | pub fn writeInst( |
| 56 | air: Air, | 56 | air: Air, |
| 57 | stream: anytype, | 57 | stream: *std.io.BufferedWriter, |
| 58 | inst: Air.Inst.Index, | 58 | inst: Air.Inst.Index, |
| 59 | pt: Zcu.PerThread, | 59 | pt: Zcu.PerThread, |
| 60 | liveness: ?Air.Liveness, | 60 | liveness: ?Air.Liveness, |
| ... | @@ -72,11 +72,15 @@ pub fn writeInst( | ... | @@ -72,11 +72,15 @@ pub fn writeInst( |
| 72 | } | 72 | } |
| 73 | | 73 | |
| 74 | pub fn dump(air: Air, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { | 74 | pub fn dump(air: Air, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { |
| 75 | air.write(std.io.getStdErr().writer(), pt, liveness); | 75 | var bw = std.debug.lockStdErr2(); |
| | 76 | defer std.debug.unlockStdErr(); |
| | 77 | air.write(&bw, pt, liveness); |
| 76 | } | 78 | } |
| 77 | | 79 | |
| 78 | pub fn dumpInst(air: Air, inst: Air.Inst.Index, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { | 80 | pub fn dumpInst(air: Air, inst: Air.Inst.Index, pt: Zcu.PerThread, liveness: ?Air.Liveness) void { |
| 79 | air.writeInst(std.io.getStdErr().writer(), inst, pt, liveness); | 81 | var bw = std.debug.lockStdErr2(); |
| | 82 | defer std.debug.unlockStdErr(); |
| | 83 | air.writeInst(&bw, inst, pt, liveness); |
| 80 | } | 84 | } |
| 81 | | 85 | |
| 82 | const Writer = struct { | 86 | const Writer = struct { |
| ... | @@ -87,16 +91,16 @@ const Writer = struct { | ... | @@ -87,16 +91,16 @@ const Writer = struct { |
| 87 | indent: usize, | 91 | indent: usize, |
| 88 | skip_body: bool, | 92 | skip_body: bool, |
| 89 | | 93 | |
| 90 | fn writeBody(w: *Writer, s: anytype, body: []const Air.Inst.Index) @TypeOf(s).Error!void { | 94 | fn writeBody(w: *Writer, s: *std.io.BufferedWriter, body: []const Air.Inst.Index) anyerror!void { |
| 91 | for (body) |inst| { | 95 | for (body) |inst| { |
| 92 | try w.writeInst(s, inst); | 96 | try w.writeInst(s, inst); |
| 93 | try s.writeByte('\n'); | 97 | try s.writeByte('\n'); |
| 94 | } | 98 | } |
| 95 | } | 99 | } |
| 96 | | 100 | |
| 97 | fn writeInst(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 101 | fn writeInst(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 98 | const tag = w.air.instructions.items(.tag)[@intFromEnum(inst)]; | 102 | const tag = w.air.instructions.items(.tag)[@intFromEnum(inst)]; |
| 99 | try s.writeByteNTimes(' ', w.indent); | 103 | try s.splatByteAll(' ', w.indent); |
| 100 | try s.print("{}{c}= {s}(", .{ | 104 | try s.print("{}{c}= {s}(", .{ |
| 101 | inst, | 105 | inst, |
| 102 | @as(u8, if (if (w.liveness) |liveness| liveness.isUnused(inst) else false) '!' else ' '), | 106 | @as(u8, if (if (w.liveness) |liveness| liveness.isUnused(inst) else false) '!' else ' '), |
| ... | @@ -334,47 +338,48 @@ const Writer = struct { | ... | @@ -334,47 +338,48 @@ const Writer = struct { |
| 334 | try s.writeByte(')'); | 338 | try s.writeByte(')'); |
| 335 | } | 339 | } |
| 336 | | 340 | |
| 337 | fn writeBinOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 341 | fn writeBinOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 338 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; | 342 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 339 | try w.writeOperand(s, inst, 0, bin_op.lhs); | 343 | try w.writeOperand(s, inst, 0, bin_op.lhs); |
| 340 | try s.writeAll(", "); | 344 | try s.writeAll(", "); |
| 341 | try w.writeOperand(s, inst, 1, bin_op.rhs); | 345 | try w.writeOperand(s, inst, 1, bin_op.rhs); |
| 342 | } | 346 | } |
| 343 | | 347 | |
| 344 | fn writeUnOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 348 | fn writeUnOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 345 | const un_op = w.air.instructions.items(.data)[@intFromEnum(inst)].un_op; | 349 | const un_op = w.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 346 | try w.writeOperand(s, inst, 0, un_op); | 350 | try w.writeOperand(s, inst, 0, un_op); |
| 347 | } | 351 | } |
| 348 | | 352 | |
| 349 | fn writeNoOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 353 | fn writeNoOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 350 | _ = w; | 354 | _ = w; |
| | 355 | _ = s; |
| 351 | _ = inst; | 356 | _ = inst; |
| 352 | // no-op, no argument to write | 357 | // no-op, no argument to write |
| 353 | } | 358 | } |
| 354 | | 359 | |
| 355 | fn writeType(w: *Writer, s: anytype, ty: Type) !void { | 360 | fn writeType(w: *Writer, s: *std.io.BufferedWriter, ty: Type) !void { |
| 356 | return ty.print(s, w.pt); | 361 | return ty.print(s, w.pt); |
| 357 | } | 362 | } |
| 358 | | 363 | |
| 359 | fn writeTy(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 364 | fn writeTy(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 360 | const ty = w.air.instructions.items(.data)[@intFromEnum(inst)].ty; | 365 | const ty = w.air.instructions.items(.data)[@intFromEnum(inst)].ty; |
| 361 | try w.writeType(s, ty); | 366 | try w.writeType(s, ty); |
| 362 | } | 367 | } |
| 363 | | 368 | |
| 364 | fn writeArg(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 369 | fn writeArg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 365 | const arg = w.air.instructions.items(.data)[@intFromEnum(inst)].arg; | 370 | const arg = w.air.instructions.items(.data)[@intFromEnum(inst)].arg; |
| 366 | try w.writeType(s, arg.ty.toType()); | 371 | try w.writeType(s, arg.ty.toType()); |
| 367 | try s.print(", {d}", .{arg.zir_param_index}); | 372 | try s.print(", {d}", .{arg.zir_param_index}); |
| 368 | } | 373 | } |
| 369 | | 374 | |
| 370 | fn writeTyOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 375 | fn writeTyOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 371 | const ty_op = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; | 376 | const ty_op = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 372 | try w.writeType(s, ty_op.ty.toType()); | 377 | try w.writeType(s, ty_op.ty.toType()); |
| 373 | try s.writeAll(", "); | 378 | try s.writeAll(", "); |
| 374 | try w.writeOperand(s, inst, 0, ty_op.operand); | 379 | try w.writeOperand(s, inst, 0, ty_op.operand); |
| 375 | } | 380 | } |
| 376 | | 381 | |
| 377 | fn writeBlock(w: *Writer, s: anytype, tag: Air.Inst.Tag, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 382 | fn writeBlock(w: *Writer, s: *std.io.BufferedWriter, tag: Air.Inst.Tag, inst: Air.Inst.Index) anyerror!void { |
| 378 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 383 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 379 | try w.writeType(s, ty_pl.ty.toType()); | 384 | try w.writeType(s, ty_pl.ty.toType()); |
| 380 | const body: []const Air.Inst.Index = @ptrCast(switch (tag) { | 385 | const body: []const Air.Inst.Index = @ptrCast(switch (tag) { |
| ... | @@ -407,7 +412,7 @@ const Writer = struct { | ... | @@ -407,7 +412,7 @@ const Writer = struct { |
| 407 | w.indent += 2; | 412 | w.indent += 2; |
| 408 | try w.writeBody(s, body); | 413 | try w.writeBody(s, body); |
| 409 | w.indent = old_indent; | 414 | w.indent = old_indent; |
| 410 | try s.writeByteNTimes(' ', w.indent); | 415 | try s.splatByteAll(' ', w.indent); |
| 411 | try s.writeAll("}"); | 416 | try s.writeAll("}"); |
| 412 | | 417 | |
| 413 | for (liveness_block.deaths) |operand| { | 418 | for (liveness_block.deaths) |operand| { |
| ... | @@ -415,7 +420,7 @@ const Writer = struct { | ... | @@ -415,7 +420,7 @@ const Writer = struct { |
| 415 | } | 420 | } |
| 416 | } | 421 | } |
| 417 | | 422 | |
| 418 | fn writeLoop(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 423 | fn writeLoop(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 419 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 424 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 420 | const extra = w.air.extraData(Air.Block, ty_pl.payload); | 425 | const extra = w.air.extraData(Air.Block, ty_pl.payload); |
| 421 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); | 426 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); |
| ... | @@ -427,11 +432,11 @@ const Writer = struct { | ... | @@ -427,11 +432,11 @@ const Writer = struct { |
| 427 | w.indent += 2; | 432 | w.indent += 2; |
| 428 | try w.writeBody(s, body); | 433 | try w.writeBody(s, body); |
| 429 | w.indent = old_indent; | 434 | w.indent = old_indent; |
| 430 | try s.writeByteNTimes(' ', w.indent); | 435 | try s.splatByteAll(' ', w.indent); |
| 431 | try s.writeAll("}"); | 436 | try s.writeAll("}"); |
| 432 | } | 437 | } |
| 433 | | 438 | |
| 434 | fn writeAggregateInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 439 | fn writeAggregateInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 435 | const zcu = w.pt.zcu; | 440 | const zcu = w.pt.zcu; |
| 436 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 441 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 437 | const vector_ty = ty_pl.ty.toType(); | 442 | const vector_ty = ty_pl.ty.toType(); |
| ... | @@ -447,7 +452,7 @@ const Writer = struct { | ... | @@ -447,7 +452,7 @@ const Writer = struct { |
| 447 | try s.writeAll("]"); | 452 | try s.writeAll("]"); |
| 448 | } | 453 | } |
| 449 | | 454 | |
| 450 | fn writeUnionInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 455 | fn writeUnionInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 451 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 456 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 452 | const extra = w.air.extraData(Air.UnionInit, ty_pl.payload).data; | 457 | const extra = w.air.extraData(Air.UnionInit, ty_pl.payload).data; |
| 453 | | 458 | |
| ... | @@ -455,7 +460,7 @@ const Writer = struct { | ... | @@ -455,7 +460,7 @@ const Writer = struct { |
| 455 | try w.writeOperand(s, inst, 0, extra.init); | 460 | try w.writeOperand(s, inst, 0, extra.init); |
| 456 | } | 461 | } |
| 457 | | 462 | |
| 458 | fn writeStructField(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 463 | fn writeStructField(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 459 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 464 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 460 | const extra = w.air.extraData(Air.StructField, ty_pl.payload).data; | 465 | const extra = w.air.extraData(Air.StructField, ty_pl.payload).data; |
| 461 | | 466 | |
| ... | @@ -463,7 +468,7 @@ const Writer = struct { | ... | @@ -463,7 +468,7 @@ const Writer = struct { |
| 463 | try s.print(", {d}", .{extra.field_index}); | 468 | try s.print(", {d}", .{extra.field_index}); |
| 464 | } | 469 | } |
| 465 | | 470 | |
| 466 | fn writeTyPlBin(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 471 | fn writeTyPlBin(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 467 | const data = w.air.instructions.items(.data); | 472 | const data = w.air.instructions.items(.data); |
| 468 | const ty_pl = data[@intFromEnum(inst)].ty_pl; | 473 | const ty_pl = data[@intFromEnum(inst)].ty_pl; |
| 469 | const extra = w.air.extraData(Air.Bin, ty_pl.payload).data; | 474 | const extra = w.air.extraData(Air.Bin, ty_pl.payload).data; |
| ... | @@ -476,7 +481,7 @@ const Writer = struct { | ... | @@ -476,7 +481,7 @@ const Writer = struct { |
| 476 | try w.writeOperand(s, inst, 1, extra.rhs); | 481 | try w.writeOperand(s, inst, 1, extra.rhs); |
| 477 | } | 482 | } |
| 478 | | 483 | |
| 479 | fn writeCmpxchg(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 484 | fn writeCmpxchg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 480 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 485 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 481 | const extra = w.air.extraData(Air.Cmpxchg, ty_pl.payload).data; | 486 | const extra = w.air.extraData(Air.Cmpxchg, ty_pl.payload).data; |
| 482 | | 487 | |
| ... | @@ -490,7 +495,7 @@ const Writer = struct { | ... | @@ -490,7 +495,7 @@ const Writer = struct { |
| 490 | }); | 495 | }); |
| 491 | } | 496 | } |
| 492 | | 497 | |
| 493 | fn writeMulAdd(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 498 | fn writeMulAdd(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 494 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 499 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 495 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; | 500 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| 496 | | 501 | |
| ... | @@ -501,7 +506,7 @@ const Writer = struct { | ... | @@ -501,7 +506,7 @@ const Writer = struct { |
| 501 | try w.writeOperand(s, inst, 2, pl_op.operand); | 506 | try w.writeOperand(s, inst, 2, pl_op.operand); |
| 502 | } | 507 | } |
| 503 | | 508 | |
| 504 | fn writeShuffleOne(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 509 | fn writeShuffleOne(w: *Writer, s: anytype, inst: Air.Inst.Index) anyerror!void { |
| 505 | const unwrapped = w.air.unwrapShuffleOne(w.pt.zcu, inst); | 510 | const unwrapped = w.air.unwrapShuffleOne(w.pt.zcu, inst); |
| 506 | try w.writeType(s, unwrapped.result_ty); | 511 | try w.writeType(s, unwrapped.result_ty); |
| 507 | try s.writeAll(", "); | 512 | try s.writeAll(", "); |
| ... | @@ -536,7 +541,7 @@ const Writer = struct { | ... | @@ -536,7 +541,7 @@ const Writer = struct { |
| 536 | try s.writeByte(']'); | 541 | try s.writeByte(']'); |
| 537 | } | 542 | } |
| 538 | | 543 | |
| 539 | fn writeSelect(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 544 | fn writeSelect(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 540 | const zcu = w.pt.zcu; | 545 | const zcu = w.pt.zcu; |
| 541 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 546 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 542 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; | 547 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| ... | @@ -551,14 +556,14 @@ const Writer = struct { | ... | @@ -551,14 +556,14 @@ const Writer = struct { |
| 551 | try w.writeOperand(s, inst, 2, extra.rhs); | 556 | try w.writeOperand(s, inst, 2, extra.rhs); |
| 552 | } | 557 | } |
| 553 | | 558 | |
| 554 | fn writeReduce(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 559 | fn writeReduce(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 555 | const reduce = w.air.instructions.items(.data)[@intFromEnum(inst)].reduce; | 560 | const reduce = w.air.instructions.items(.data)[@intFromEnum(inst)].reduce; |
| 556 | | 561 | |
| 557 | try w.writeOperand(s, inst, 0, reduce.operand); | 562 | try w.writeOperand(s, inst, 0, reduce.operand); |
| 558 | try s.print(", {s}", .{@tagName(reduce.operation)}); | 563 | try s.print(", {s}", .{@tagName(reduce.operation)}); |
| 559 | } | 564 | } |
| 560 | | 565 | |
| 561 | fn writeCmpVector(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 566 | fn writeCmpVector(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 562 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 567 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 563 | const extra = w.air.extraData(Air.VectorCmp, ty_pl.payload).data; | 568 | const extra = w.air.extraData(Air.VectorCmp, ty_pl.payload).data; |
| 564 | | 569 | |
| ... | @@ -568,7 +573,7 @@ const Writer = struct { | ... | @@ -568,7 +573,7 @@ const Writer = struct { |
| 568 | try w.writeOperand(s, inst, 1, extra.rhs); | 573 | try w.writeOperand(s, inst, 1, extra.rhs); |
| 569 | } | 574 | } |
| 570 | | 575 | |
| 571 | fn writeVectorStoreElem(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 576 | fn writeVectorStoreElem(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 572 | const data = w.air.instructions.items(.data)[@intFromEnum(inst)].vector_store_elem; | 577 | const data = w.air.instructions.items(.data)[@intFromEnum(inst)].vector_store_elem; |
| 573 | const extra = w.air.extraData(Air.VectorCmp, data.payload).data; | 578 | const extra = w.air.extraData(Air.VectorCmp, data.payload).data; |
| 574 | | 579 | |
| ... | @@ -579,21 +584,21 @@ const Writer = struct { | ... | @@ -579,21 +584,21 @@ const Writer = struct { |
| 579 | try w.writeOperand(s, inst, 2, extra.rhs); | 584 | try w.writeOperand(s, inst, 2, extra.rhs); |
| 580 | } | 585 | } |
| 581 | | 586 | |
| 582 | fn writeRuntimeNavPtr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 587 | fn writeRuntimeNavPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) std.io.Writer.Error!void { |
| 583 | const ip = &w.pt.zcu.intern_pool; | 588 | const ip = &w.pt.zcu.intern_pool; |
| 584 | const ty_nav = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_nav; | 589 | const ty_nav = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_nav; |
| 585 | try w.writeType(s, .fromInterned(ty_nav.ty)); | 590 | try w.writeType(s, .fromInterned(ty_nav.ty)); |
| 586 | try s.print(", '{}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); | 591 | try s.print(", '{}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); |
| 587 | } | 592 | } |
| 588 | | 593 | |
| 589 | fn writeAtomicLoad(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 594 | fn writeAtomicLoad(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) std.io.Writer.Error!void { |
| 590 | const atomic_load = w.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load; | 595 | const atomic_load = w.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load; |
| 591 | | 596 | |
| 592 | try w.writeOperand(s, inst, 0, atomic_load.ptr); | 597 | try w.writeOperand(s, inst, 0, atomic_load.ptr); |
| 593 | try s.print(", {s}", .{@tagName(atomic_load.order)}); | 598 | try s.print(", {s}", .{@tagName(atomic_load.order)}); |
| 594 | } | 599 | } |
| 595 | | 600 | |
| 596 | fn writePrefetch(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 601 | fn writePrefetch(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 597 | const prefetch = w.air.instructions.items(.data)[@intFromEnum(inst)].prefetch; | 602 | const prefetch = w.air.instructions.items(.data)[@intFromEnum(inst)].prefetch; |
| 598 | | 603 | |
| 599 | try w.writeOperand(s, inst, 0, prefetch.ptr); | 604 | try w.writeOperand(s, inst, 0, prefetch.ptr); |
| ... | @@ -604,10 +609,10 @@ const Writer = struct { | ... | @@ -604,10 +609,10 @@ const Writer = struct { |
| 604 | | 609 | |
| 605 | fn writeAtomicStore( | 610 | fn writeAtomicStore( |
| 606 | w: *Writer, | 611 | w: *Writer, |
| 607 | s: anytype, | 612 | s: *std.io.BufferedWriter, |
| 608 | inst: Air.Inst.Index, | 613 | inst: Air.Inst.Index, |
| 609 | order: std.builtin.AtomicOrder, | 614 | order: std.builtin.AtomicOrder, |
| 610 | ) @TypeOf(s).Error!void { | 615 | ) anyerror!void { |
| 611 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; | 616 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 612 | try w.writeOperand(s, inst, 0, bin_op.lhs); | 617 | try w.writeOperand(s, inst, 0, bin_op.lhs); |
| 613 | try s.writeAll(", "); | 618 | try s.writeAll(", "); |
| ... | @@ -615,7 +620,7 @@ const Writer = struct { | ... | @@ -615,7 +620,7 @@ const Writer = struct { |
| 615 | try s.print(", {s}", .{@tagName(order)}); | 620 | try s.print(", {s}", .{@tagName(order)}); |
| 616 | } | 621 | } |
| 617 | | 622 | |
| 618 | fn writeAtomicRmw(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 623 | fn writeAtomicRmw(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 619 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 624 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 620 | const extra = w.air.extraData(Air.AtomicRmw, pl_op.payload).data; | 625 | const extra = w.air.extraData(Air.AtomicRmw, pl_op.payload).data; |
| 621 | | 626 | |
| ... | @@ -625,7 +630,7 @@ const Writer = struct { | ... | @@ -625,7 +630,7 @@ const Writer = struct { |
| 625 | try s.print(", {s}, {s}", .{ @tagName(extra.op()), @tagName(extra.ordering()) }); | 630 | try s.print(", {s}, {s}", .{ @tagName(extra.op()), @tagName(extra.ordering()) }); |
| 626 | } | 631 | } |
| 627 | | 632 | |
| 628 | fn writeFieldParentPtr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 633 | fn writeFieldParentPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 629 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 634 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 630 | const extra = w.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; | 635 | const extra = w.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; |
| 631 | | 636 | |
| ... | @@ -633,7 +638,7 @@ const Writer = struct { | ... | @@ -633,7 +638,7 @@ const Writer = struct { |
| 633 | try s.print(", {d}", .{extra.field_index}); | 638 | try s.print(", {d}", .{extra.field_index}); |
| 634 | } | 639 | } |
| 635 | | 640 | |
| 636 | fn writeAssembly(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 641 | fn writeAssembly(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 637 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 642 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 638 | const extra = w.air.extraData(Air.Asm, ty_pl.payload); | 643 | const extra = w.air.extraData(Air.Asm, ty_pl.payload); |
| 639 | const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; | 644 | const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; |
| ... | @@ -706,19 +711,19 @@ const Writer = struct { | ... | @@ -706,19 +711,19 @@ const Writer = struct { |
| 706 | try s.print(", \"{}\"", .{std.zig.fmtEscapes(asm_source)}); | 711 | try s.print(", \"{}\"", .{std.zig.fmtEscapes(asm_source)}); |
| 707 | } | 712 | } |
| 708 | | 713 | |
| 709 | fn writeDbgStmt(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 714 | fn writeDbgStmt(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 710 | const dbg_stmt = w.air.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; | 715 | const dbg_stmt = w.air.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; |
| 711 | try s.print("{d}:{d}", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 }); | 716 | try s.print("{d}:{d}", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 }); |
| 712 | } | 717 | } |
| 713 | | 718 | |
| 714 | fn writeDbgVar(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 719 | fn writeDbgVar(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 715 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 720 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 716 | try w.writeOperand(s, inst, 0, pl_op.operand); | 721 | try w.writeOperand(s, inst, 0, pl_op.operand); |
| 717 | const name: Air.NullTerminatedString = @enumFromInt(pl_op.payload); | 722 | const name: Air.NullTerminatedString = @enumFromInt(pl_op.payload); |
| 718 | try s.print(", \"{}\"", .{std.zig.fmtEscapes(name.toSlice(w.air))}); | 723 | try s.print(", \"{}\"", .{std.zig.fmtEscapes(name.toSlice(w.air))}); |
| 719 | } | 724 | } |
| 720 | | 725 | |
| 721 | fn writeCall(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 726 | fn writeCall(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 722 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 727 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 723 | const extra = w.air.extraData(Air.Call, pl_op.payload); | 728 | const extra = w.air.extraData(Air.Call, pl_op.payload); |
| 724 | const args = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra.end..][0..extra.data.args_len])); | 729 | const args = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra.end..][0..extra.data.args_len])); |
| ... | @@ -731,19 +736,19 @@ const Writer = struct { | ... | @@ -731,19 +736,19 @@ const Writer = struct { |
| 731 | try s.writeAll("]"); | 736 | try s.writeAll("]"); |
| 732 | } | 737 | } |
| 733 | | 738 | |
| 734 | fn writeBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 739 | fn writeBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 735 | const br = w.air.instructions.items(.data)[@intFromEnum(inst)].br; | 740 | const br = w.air.instructions.items(.data)[@intFromEnum(inst)].br; |
| 736 | try w.writeInstIndex(s, br.block_inst, false); | 741 | try w.writeInstIndex(s, br.block_inst, false); |
| 737 | try s.writeAll(", "); | 742 | try s.writeAll(", "); |
| 738 | try w.writeOperand(s, inst, 0, br.operand); | 743 | try w.writeOperand(s, inst, 0, br.operand); |
| 739 | } | 744 | } |
| 740 | | 745 | |
| 741 | fn writeRepeat(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 746 | fn writeRepeat(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 742 | const repeat = w.air.instructions.items(.data)[@intFromEnum(inst)].repeat; | 747 | const repeat = w.air.instructions.items(.data)[@intFromEnum(inst)].repeat; |
| 743 | try w.writeInstIndex(s, repeat.loop_inst, false); | 748 | try w.writeInstIndex(s, repeat.loop_inst, false); |
| 744 | } | 749 | } |
| 745 | | 750 | |
| 746 | fn writeTry(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 751 | fn writeTry(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 747 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 752 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 748 | const extra = w.air.extraData(Air.Try, pl_op.payload); | 753 | const extra = w.air.extraData(Air.Try, pl_op.payload); |
| 749 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); | 754 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); |
| ... | @@ -759,7 +764,7 @@ const Writer = struct { | ... | @@ -759,7 +764,7 @@ const Writer = struct { |
| 759 | w.indent += 2; | 764 | w.indent += 2; |
| 760 | | 765 | |
| 761 | if (liveness_condbr.else_deaths.len != 0) { | 766 | if (liveness_condbr.else_deaths.len != 0) { |
| 762 | try s.writeByteNTimes(' ', w.indent); | 767 | try s.splatByteAll(' ', w.indent); |
| 763 | for (liveness_condbr.else_deaths, 0..) |operand, i| { | 768 | for (liveness_condbr.else_deaths, 0..) |operand, i| { |
| 764 | if (i != 0) try s.writeAll(" "); | 769 | if (i != 0) try s.writeAll(" "); |
| 765 | try s.print("{}!", .{operand}); | 770 | try s.print("{}!", .{operand}); |
| ... | @@ -769,7 +774,7 @@ const Writer = struct { | ... | @@ -769,7 +774,7 @@ const Writer = struct { |
| 769 | try w.writeBody(s, body); | 774 | try w.writeBody(s, body); |
| 770 | | 775 | |
| 771 | w.indent = old_indent; | 776 | w.indent = old_indent; |
| 772 | try s.writeByteNTimes(' ', w.indent); | 777 | try s.splatByteAll(' ', w.indent); |
| 773 | try s.writeAll("}"); | 778 | try s.writeAll("}"); |
| 774 | | 779 | |
| 775 | for (liveness_condbr.then_deaths) |operand| { | 780 | for (liveness_condbr.then_deaths) |operand| { |
| ... | @@ -777,7 +782,7 @@ const Writer = struct { | ... | @@ -777,7 +782,7 @@ const Writer = struct { |
| 777 | } | 782 | } |
| 778 | } | 783 | } |
| 779 | | 784 | |
| 780 | fn writeTryPtr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 785 | fn writeTryPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 781 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 786 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 782 | const extra = w.air.extraData(Air.TryPtr, ty_pl.payload); | 787 | const extra = w.air.extraData(Air.TryPtr, ty_pl.payload); |
| 783 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); | 788 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); |
| ... | @@ -796,7 +801,7 @@ const Writer = struct { | ... | @@ -796,7 +801,7 @@ const Writer = struct { |
| 796 | w.indent += 2; | 801 | w.indent += 2; |
| 797 | | 802 | |
| 798 | if (liveness_condbr.else_deaths.len != 0) { | 803 | if (liveness_condbr.else_deaths.len != 0) { |
| 799 | try s.writeByteNTimes(' ', w.indent); | 804 | try s.splatByteAll(' ', w.indent); |
| 800 | for (liveness_condbr.else_deaths, 0..) |operand, i| { | 805 | for (liveness_condbr.else_deaths, 0..) |operand, i| { |
| 801 | if (i != 0) try s.writeAll(" "); | 806 | if (i != 0) try s.writeAll(" "); |
| 802 | try s.print("{}!", .{operand}); | 807 | try s.print("{}!", .{operand}); |
| ... | @@ -806,7 +811,7 @@ const Writer = struct { | ... | @@ -806,7 +811,7 @@ const Writer = struct { |
| 806 | try w.writeBody(s, body); | 811 | try w.writeBody(s, body); |
| 807 | | 812 | |
| 808 | w.indent = old_indent; | 813 | w.indent = old_indent; |
| 809 | try s.writeByteNTimes(' ', w.indent); | 814 | try s.splatByteAll(' ', w.indent); |
| 810 | try s.writeAll("}"); | 815 | try s.writeAll("}"); |
| 811 | | 816 | |
| 812 | for (liveness_condbr.then_deaths) |operand| { | 817 | for (liveness_condbr.then_deaths) |operand| { |
| ... | @@ -814,7 +819,7 @@ const Writer = struct { | ... | @@ -814,7 +819,7 @@ const Writer = struct { |
| 814 | } | 819 | } |
| 815 | } | 820 | } |
| 816 | | 821 | |
| 817 | fn writeCondBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 822 | fn writeCondBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 818 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 823 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 819 | const extra = w.air.extraData(Air.CondBr, pl_op.payload); | 824 | const extra = w.air.extraData(Air.CondBr, pl_op.payload); |
| 820 | const then_body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.then_body_len]); | 825 | const then_body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.then_body_len]); |
| ... | @@ -838,7 +843,7 @@ const Writer = struct { | ... | @@ -838,7 +843,7 @@ const Writer = struct { |
| 838 | w.indent += 2; | 843 | w.indent += 2; |
| 839 | | 844 | |
| 840 | if (liveness_condbr.then_deaths.len != 0) { | 845 | if (liveness_condbr.then_deaths.len != 0) { |
| 841 | try s.writeByteNTimes(' ', w.indent); | 846 | try s.splatByteAll(' ', w.indent); |
| 842 | for (liveness_condbr.then_deaths, 0..) |operand, i| { | 847 | for (liveness_condbr.then_deaths, 0..) |operand, i| { |
| 843 | if (i != 0) try s.writeAll(" "); | 848 | if (i != 0) try s.writeAll(" "); |
| 844 | try s.print("{}!", .{operand}); | 849 | try s.print("{}!", .{operand}); |
| ... | @@ -847,7 +852,7 @@ const Writer = struct { | ... | @@ -847,7 +852,7 @@ const Writer = struct { |
| 847 | } | 852 | } |
| 848 | | 853 | |
| 849 | try w.writeBody(s, then_body); | 854 | try w.writeBody(s, then_body); |
| 850 | try s.writeByteNTimes(' ', old_indent); | 855 | try s.splatByteAll(' ', old_indent); |
| 851 | try s.writeAll("},"); | 856 | try s.writeAll("},"); |
| 852 | if (extra.data.branch_hints.false != .none) { | 857 | if (extra.data.branch_hints.false != .none) { |
| 853 | try s.print(" {s}", .{@tagName(extra.data.branch_hints.false)}); | 858 | try s.print(" {s}", .{@tagName(extra.data.branch_hints.false)}); |
| ... | @@ -858,7 +863,7 @@ const Writer = struct { | ... | @@ -858,7 +863,7 @@ const Writer = struct { |
| 858 | try s.writeAll(" {\n"); | 863 | try s.writeAll(" {\n"); |
| 859 | | 864 | |
| 860 | if (liveness_condbr.else_deaths.len != 0) { | 865 | if (liveness_condbr.else_deaths.len != 0) { |
| 861 | try s.writeByteNTimes(' ', w.indent); | 866 | try s.splatByteAll(' ', w.indent); |
| 862 | for (liveness_condbr.else_deaths, 0..) |operand, i| { | 867 | for (liveness_condbr.else_deaths, 0..) |operand, i| { |
| 863 | if (i != 0) try s.writeAll(" "); | 868 | if (i != 0) try s.writeAll(" "); |
| 864 | try s.print("{}!", .{operand}); | 869 | try s.print("{}!", .{operand}); |
| ... | @@ -869,11 +874,11 @@ const Writer = struct { | ... | @@ -869,11 +874,11 @@ const Writer = struct { |
| 869 | try w.writeBody(s, else_body); | 874 | try w.writeBody(s, else_body); |
| 870 | w.indent = old_indent; | 875 | w.indent = old_indent; |
| 871 | | 876 | |
| 872 | try s.writeByteNTimes(' ', old_indent); | 877 | try s.splatByteAll(' ', old_indent); |
| 873 | try s.writeAll("}"); | 878 | try s.writeAll("}"); |
| 874 | } | 879 | } |
| 875 | | 880 | |
| 876 | fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 881 | fn writeSwitchBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 877 | const switch_br = w.air.unwrapSwitch(inst); | 882 | const switch_br = w.air.unwrapSwitch(inst); |
| 878 | | 883 | |
| 879 | const liveness: Air.Liveness.SwitchBrTable = if (w.liveness) |liveness| | 884 | const liveness: Air.Liveness.SwitchBrTable = if (w.liveness) |liveness| |
| ... | @@ -915,7 +920,7 @@ const Writer = struct { | ... | @@ -915,7 +920,7 @@ const Writer = struct { |
| 915 | | 920 | |
| 916 | const deaths = liveness.deaths[case.idx]; | 921 | const deaths = liveness.deaths[case.idx]; |
| 917 | if (deaths.len != 0) { | 922 | if (deaths.len != 0) { |
| 918 | try s.writeByteNTimes(' ', w.indent); | 923 | try s.splatByteAll(' ', w.indent); |
| 919 | for (deaths, 0..) |operand, i| { | 924 | for (deaths, 0..) |operand, i| { |
| 920 | if (i != 0) try s.writeAll(" "); | 925 | if (i != 0) try s.writeAll(" "); |
| 921 | try s.print("{}!", .{operand}); | 926 | try s.print("{}!", .{operand}); |
| ... | @@ -925,7 +930,7 @@ const Writer = struct { | ... | @@ -925,7 +930,7 @@ const Writer = struct { |
| 925 | | 930 | |
| 926 | try w.writeBody(s, case.body); | 931 | try w.writeBody(s, case.body); |
| 927 | w.indent -= 2; | 932 | w.indent -= 2; |
| 928 | try s.writeByteNTimes(' ', w.indent); | 933 | try s.splatByteAll(' ', w.indent); |
| 929 | try s.writeAll("}"); | 934 | try s.writeAll("}"); |
| 930 | } | 935 | } |
| 931 | | 936 | |
| ... | @@ -941,7 +946,7 @@ const Writer = struct { | ... | @@ -941,7 +946,7 @@ const Writer = struct { |
| 941 | | 946 | |
| 942 | const deaths = liveness.deaths[liveness.deaths.len - 1]; | 947 | const deaths = liveness.deaths[liveness.deaths.len - 1]; |
| 943 | if (deaths.len != 0) { | 948 | if (deaths.len != 0) { |
| 944 | try s.writeByteNTimes(' ', w.indent); | 949 | try s.splatByteAll(' ', w.indent); |
| 945 | for (deaths, 0..) |operand, i| { | 950 | for (deaths, 0..) |operand, i| { |
| 946 | if (i != 0) try s.writeAll(" "); | 951 | if (i != 0) try s.writeAll(" "); |
| 947 | try s.print("{}!", .{operand}); | 952 | try s.print("{}!", .{operand}); |
| ... | @@ -951,37 +956,37 @@ const Writer = struct { | ... | @@ -951,37 +956,37 @@ const Writer = struct { |
| 951 | | 956 | |
| 952 | try w.writeBody(s, else_body); | 957 | try w.writeBody(s, else_body); |
| 953 | w.indent -= 2; | 958 | w.indent -= 2; |
| 954 | try s.writeByteNTimes(' ', w.indent); | 959 | try s.splatByteAll(' ', w.indent); |
| 955 | try s.writeAll("}"); | 960 | try s.writeAll("}"); |
| 956 | } | 961 | } |
| 957 | | 962 | |
| 958 | try s.writeAll("\n"); | 963 | try s.writeAll("\n"); |
| 959 | try s.writeByteNTimes(' ', old_indent); | 964 | try s.splatByteAll(' ', old_indent); |
| 960 | } | 965 | } |
| 961 | | 966 | |
| 962 | fn writeWasmMemorySize(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 967 | fn writeWasmMemorySize(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 963 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 968 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 964 | try s.print("{d}", .{pl_op.payload}); | 969 | try s.print("{d}", .{pl_op.payload}); |
| 965 | } | 970 | } |
| 966 | | 971 | |
| 967 | fn writeWasmMemoryGrow(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 972 | fn writeWasmMemoryGrow(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 968 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 973 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 969 | try s.print("{d}, ", .{pl_op.payload}); | 974 | try s.print("{d}, ", .{pl_op.payload}); |
| 970 | try w.writeOperand(s, inst, 0, pl_op.operand); | 975 | try w.writeOperand(s, inst, 0, pl_op.operand); |
| 971 | } | 976 | } |
| 972 | | 977 | |
| 973 | fn writeWorkDimension(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 978 | fn writeWorkDimension(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { |
| 974 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 979 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 975 | try s.print("{d}", .{pl_op.payload}); | 980 | try s.print("{d}", .{pl_op.payload}); |
| 976 | } | 981 | } |
| 977 | | 982 | |
| 978 | fn writeOperand( | 983 | fn writeOperand( |
| 979 | w: *Writer, | 984 | w: *Writer, |
| 980 | s: anytype, | 985 | s: *std.io.BufferedWriter, |
| 981 | inst: Air.Inst.Index, | 986 | inst: Air.Inst.Index, |
| 982 | op_index: usize, | 987 | op_index: usize, |
| 983 | operand: Air.Inst.Ref, | 988 | operand: Air.Inst.Ref, |
| 984 | ) @TypeOf(s).Error!void { | 989 | ) anyerror!void { |
| 985 | const small_tomb_bits = Air.Liveness.bpi - 1; | 990 | const small_tomb_bits = Air.Liveness.bpi - 1; |
| 986 | const dies = if (w.liveness) |liveness| blk: { | 991 | const dies = if (w.liveness) |liveness| blk: { |
| 987 | if (op_index < small_tomb_bits) | 992 | if (op_index < small_tomb_bits) |
| ... | @@ -1006,7 +1011,7 @@ const Writer = struct { | ... | @@ -1006,7 +1011,7 @@ const Writer = struct { |
| 1006 | s: anytype, | 1011 | s: anytype, |
| 1007 | operand: Air.Inst.Ref, | 1012 | operand: Air.Inst.Ref, |
| 1008 | dies: bool, | 1013 | dies: bool, |
| 1009 | ) @TypeOf(s).Error!void { | 1014 | ) anyerror!void { |
| 1010 | if (@intFromEnum(operand) < InternPool.static_len) { | 1015 | if (@intFromEnum(operand) < InternPool.static_len) { |
| 1011 | return s.print("@{}", .{operand}); | 1016 | return s.print("@{}", .{operand}); |
| 1012 | } else if (operand.toInterned()) |ip_index| { | 1017 | } else if (operand.toInterned()) |ip_index| { |
| ... | @@ -1023,10 +1028,10 @@ const Writer = struct { | ... | @@ -1023,10 +1028,10 @@ const Writer = struct { |
| 1023 | | 1028 | |
| 1024 | fn writeInstIndex( | 1029 | fn writeInstIndex( |
| 1025 | w: *Writer, | 1030 | w: *Writer, |
| 1026 | s: anytype, | 1031 | s: *std.io.BufferedWriter, |
| 1027 | inst: Air.Inst.Index, | 1032 | inst: Air.Inst.Index, |
| 1028 | dies: bool, | 1033 | dies: bool, |
| 1029 | ) @TypeOf(s).Error!void { | 1034 | ) anyerror!void { |
| 1030 | _ = w; | 1035 | _ = w; |
| 1031 | try s.print("{}", .{inst}); | 1036 | try s.print("{}", .{inst}); |
| 1032 | if (dies) try s.writeByte('!'); | 1037 | if (dies) try s.writeByte('!'); |