| ... | ... | @@ -1,566 +0,0 @@ |
| 1 | | * be sure to test debug info of parameters |
| 2 | | |
| 3 | | |
| 4 | | pub fn specialOperandDeaths(self: Inst) bool { |
| 5 | | return (self.deaths & (1 << deaths_bits)) != 0; |
| 6 | | } |
| 7 | | |
| 8 | | /// Returns `null` if runtime-known. |
| 9 | | /// Should be called by codegen, not by Sema. Sema functions should call |
| 10 | | /// `resolvePossiblyUndefinedValue` or `resolveDefinedValue` instead. |
| 11 | | /// TODO audit Sema code for violations to the above guidance. |
| 12 | | pub fn value(base: *Inst) ?Value { |
| 13 | | if (base.ty.onePossibleValue()) |opv| return opv; |
| 14 | | |
| 15 | | const inst = base.castTag(.constant) orelse return null; |
| 16 | | return inst.val; |
| 17 | | } |
| 18 | | |
| 19 | | |
| 20 | | |
| 21 | | /// For debugging purposes, prints a function representation to stderr. |
| 22 | | pub fn dumpFn(old_module: Module, module_fn: *Module.Fn) void { |
| 23 | | const allocator = old_module.gpa; |
| 24 | | var ctx: DumpAir = .{ |
| 25 | | .allocator = allocator, |
| 26 | | .arena = std.heap.ArenaAllocator.init(allocator), |
| 27 | | .old_module = &old_module, |
| 28 | | .module_fn = module_fn, |
| 29 | | .indent = 2, |
| 30 | | .inst_table = DumpAir.InstTable.init(allocator), |
| 31 | | .partial_inst_table = DumpAir.InstTable.init(allocator), |
| 32 | | .const_table = DumpAir.InstTable.init(allocator), |
| 33 | | }; |
| 34 | | defer ctx.inst_table.deinit(); |
| 35 | | defer ctx.partial_inst_table.deinit(); |
| 36 | | defer ctx.const_table.deinit(); |
| 37 | | defer ctx.arena.deinit(); |
| 38 | | |
| 39 | | switch (module_fn.state) { |
| 40 | | .queued => std.debug.print("(queued)", .{}), |
| 41 | | .inline_only => std.debug.print("(inline_only)", .{}), |
| 42 | | .in_progress => std.debug.print("(in_progress)", .{}), |
| 43 | | .sema_failure => std.debug.print("(sema_failure)", .{}), |
| 44 | | .dependency_failure => std.debug.print("(dependency_failure)", .{}), |
| 45 | | .success => { |
| 46 | | const writer = std.io.getStdErr().writer(); |
| 47 | | ctx.dump(module_fn.body, writer) catch @panic("failed to dump AIR"); |
| 48 | | }, |
| 49 | | } |
| 50 | | } |
| 51 | | |
| 52 | | const DumpAir = struct { |
| 53 | | allocator: *std.mem.Allocator, |
| 54 | | arena: std.heap.ArenaAllocator, |
| 55 | | old_module: *const Module, |
| 56 | | module_fn: *Module.Fn, |
| 57 | | indent: usize, |
| 58 | | inst_table: InstTable, |
| 59 | | partial_inst_table: InstTable, |
| 60 | | const_table: InstTable, |
| 61 | | next_index: usize = 0, |
| 62 | | next_partial_index: usize = 0, |
| 63 | | next_const_index: usize = 0, |
| 64 | | |
| 65 | | const InstTable = std.AutoArrayHashMap(*Inst, usize); |
| 66 | | |
| 67 | | /// TODO: Improve this code to include a stack of Body and store the instructions |
| 68 | | /// in there. Now we are putting all the instructions in a function local table, |
| 69 | | /// however instructions that are in a Body can be thown away when the Body ends. |
| 70 | | fn dump(dtz: *DumpAir, body: Body, writer: std.fs.File.Writer) !void { |
| 71 | | // First pass to pre-populate the table so that we can show even invalid references. |
| 72 | | // Must iterate the same order we iterate the second time. |
| 73 | | // We also look for constants and put them in the const_table. |
| 74 | | try dtz.fetchInstsAndResolveConsts(body); |
| 75 | | |
| 76 | | std.debug.print("Module.Function(name={s}):\n", .{dtz.module_fn.owner_decl.name}); |
| 77 | | |
| 78 | | var it = dtz.const_table.iterator(); |
| 79 | | while (it.next()) |entry| { |
| 80 | | const constant = entry.key_ptr.*.castTag(.constant).?; |
| 81 | | try writer.print(" @{d}: {} = {};\n", .{ |
| 82 | | entry.value_ptr.*, constant.base.ty, constant.val, |
| 83 | | }); |
| 84 | | } |
| 85 | | |
| 86 | | return dtz.dumpBody(body, writer); |
| 87 | | } |
| 88 | | |
| 89 | | fn fetchInstsAndResolveConsts(dtz: *DumpAir, body: Body) error{OutOfMemory}!void { |
| 90 | | for (body.instructions) |inst| { |
| 91 | | try dtz.inst_table.put(inst, dtz.next_index); |
| 92 | | dtz.next_index += 1; |
| 93 | | switch (inst.tag) { |
| 94 | | .alloc, |
| 95 | | .retvoid, |
| 96 | | .unreach, |
| 97 | | .breakpoint, |
| 98 | | .dbg_stmt, |
| 99 | | .arg, |
| 100 | | => {}, |
| 101 | | |
| 102 | | .ref, |
| 103 | | .ret, |
| 104 | | .bitcast, |
| 105 | | .not, |
| 106 | | .is_non_null, |
| 107 | | .is_non_null_ptr, |
| 108 | | .is_null, |
| 109 | | .is_null_ptr, |
| 110 | | .is_err, |
| 111 | | .is_non_err, |
| 112 | | .is_err_ptr, |
| 113 | | .is_non_err_ptr, |
| 114 | | .ptrtoint, |
| 115 | | .floatcast, |
| 116 | | .intcast, |
| 117 | | .load, |
| 118 | | .optional_payload, |
| 119 | | .optional_payload_ptr, |
| 120 | | .wrap_optional, |
| 121 | | .wrap_errunion_payload, |
| 122 | | .wrap_errunion_err, |
| 123 | | .unwrap_errunion_payload, |
| 124 | | .unwrap_errunion_err, |
| 125 | | .unwrap_errunion_payload_ptr, |
| 126 | | .unwrap_errunion_err_ptr, |
| 127 | | => { |
| 128 | | const un_op = inst.cast(Inst.UnOp).?; |
| 129 | | try dtz.findConst(un_op.operand); |
| 130 | | }, |
| 131 | | |
| 132 | | .add, |
| 133 | | .addwrap, |
| 134 | | .sub, |
| 135 | | .subwrap, |
| 136 | | .mul, |
| 137 | | .mulwrap, |
| 138 | | .div, |
| 139 | | .cmp_lt, |
| 140 | | .cmp_lte, |
| 141 | | .cmp_eq, |
| 142 | | .cmp_gte, |
| 143 | | .cmp_gt, |
| 144 | | .cmp_neq, |
| 145 | | .store, |
| 146 | | .bool_and, |
| 147 | | .bool_or, |
| 148 | | .bit_and, |
| 149 | | .bit_or, |
| 150 | | .xor, |
| 151 | | => { |
| 152 | | const bin_op = inst.cast(Inst.BinOp).?; |
| 153 | | try dtz.findConst(bin_op.lhs); |
| 154 | | try dtz.findConst(bin_op.rhs); |
| 155 | | }, |
| 156 | | |
| 157 | | .br => { |
| 158 | | const br = inst.castTag(.br).?; |
| 159 | | try dtz.findConst(&br.block.base); |
| 160 | | try dtz.findConst(br.operand); |
| 161 | | }, |
| 162 | | |
| 163 | | .br_block_flat => { |
| 164 | | const br_block_flat = inst.castTag(.br_block_flat).?; |
| 165 | | try dtz.findConst(&br_block_flat.block.base); |
| 166 | | try dtz.fetchInstsAndResolveConsts(br_block_flat.body); |
| 167 | | }, |
| 168 | | |
| 169 | | .br_void => { |
| 170 | | const br_void = inst.castTag(.br_void).?; |
| 171 | | try dtz.findConst(&br_void.block.base); |
| 172 | | }, |
| 173 | | |
| 174 | | .block => { |
| 175 | | const block = inst.castTag(.block).?; |
| 176 | | try dtz.fetchInstsAndResolveConsts(block.body); |
| 177 | | }, |
| 178 | | |
| 179 | | .condbr => { |
| 180 | | const condbr = inst.castTag(.condbr).?; |
| 181 | | try dtz.findConst(condbr.condition); |
| 182 | | try dtz.fetchInstsAndResolveConsts(condbr.then_body); |
| 183 | | try dtz.fetchInstsAndResolveConsts(condbr.else_body); |
| 184 | | }, |
| 185 | | .switchbr => { |
| 186 | | const switchbr = inst.castTag(.switchbr).?; |
| 187 | | try dtz.findConst(switchbr.target); |
| 188 | | try dtz.fetchInstsAndResolveConsts(switchbr.else_body); |
| 189 | | for (switchbr.cases) |case| { |
| 190 | | try dtz.fetchInstsAndResolveConsts(case.body); |
| 191 | | } |
| 192 | | }, |
| 193 | | |
| 194 | | .loop => { |
| 195 | | const loop = inst.castTag(.loop).?; |
| 196 | | try dtz.fetchInstsAndResolveConsts(loop.body); |
| 197 | | }, |
| 198 | | .call => { |
| 199 | | const call = inst.castTag(.call).?; |
| 200 | | try dtz.findConst(call.func); |
| 201 | | for (call.args) |arg| { |
| 202 | | try dtz.findConst(arg); |
| 203 | | } |
| 204 | | }, |
| 205 | | .struct_field_ptr => { |
| 206 | | const struct_field_ptr = inst.castTag(.struct_field_ptr).?; |
| 207 | | try dtz.findConst(struct_field_ptr.struct_ptr); |
| 208 | | }, |
| 209 | | |
| 210 | | // TODO fill out this debug printing |
| 211 | | .assembly, |
| 212 | | .constant, |
| 213 | | .varptr, |
| 214 | | => {}, |
| 215 | | } |
| 216 | | } |
| 217 | | } |
| 218 | | |
| 219 | | fn dumpBody(dtz: *DumpAir, body: Body, writer: std.fs.File.Writer) (std.fs.File.WriteError || error{OutOfMemory})!void { |
| 220 | | for (body.instructions) |inst| { |
| 221 | | const my_index = dtz.next_partial_index; |
| 222 | | try dtz.partial_inst_table.put(inst, my_index); |
| 223 | | dtz.next_partial_index += 1; |
| 224 | | |
| 225 | | try writer.writeByteNTimes(' ', dtz.indent); |
| 226 | | try writer.print("%{d}: {} = {s}(", .{ |
| 227 | | my_index, inst.ty, @tagName(inst.tag), |
| 228 | | }); |
| 229 | | switch (inst.tag) { |
| 230 | | .alloc, |
| 231 | | .retvoid, |
| 232 | | .unreach, |
| 233 | | .breakpoint, |
| 234 | | .dbg_stmt, |
| 235 | | => try writer.writeAll(")\n"), |
| 236 | | |
| 237 | | .ref, |
| 238 | | .ret, |
| 239 | | .bitcast, |
| 240 | | .not, |
| 241 | | .is_non_null, |
| 242 | | .is_non_null_ptr, |
| 243 | | .is_null, |
| 244 | | .is_null_ptr, |
| 245 | | .is_err, |
| 246 | | .is_err_ptr, |
| 247 | | .is_non_err, |
| 248 | | .is_non_err_ptr, |
| 249 | | .ptrtoint, |
| 250 | | .floatcast, |
| 251 | | .intcast, |
| 252 | | .load, |
| 253 | | .optional_payload, |
| 254 | | .optional_payload_ptr, |
| 255 | | .wrap_optional, |
| 256 | | .wrap_errunion_err, |
| 257 | | .wrap_errunion_payload, |
| 258 | | .unwrap_errunion_err, |
| 259 | | .unwrap_errunion_payload, |
| 260 | | .unwrap_errunion_payload_ptr, |
| 261 | | .unwrap_errunion_err_ptr, |
| 262 | | => { |
| 263 | | const un_op = inst.cast(Inst.UnOp).?; |
| 264 | | const kinky = try dtz.writeInst(writer, un_op.operand); |
| 265 | | if (kinky != null) { |
| 266 | | try writer.writeAll(") // Instruction does not dominate all uses!\n"); |
| 267 | | } else { |
| 268 | | try writer.writeAll(")\n"); |
| 269 | | } |
| 270 | | }, |
| 271 | | |
| 272 | | .add, |
| 273 | | .addwrap, |
| 274 | | .sub, |
| 275 | | .subwrap, |
| 276 | | .mul, |
| 277 | | .mulwrap, |
| 278 | | .div, |
| 279 | | .cmp_lt, |
| 280 | | .cmp_lte, |
| 281 | | .cmp_eq, |
| 282 | | .cmp_gte, |
| 283 | | .cmp_gt, |
| 284 | | .cmp_neq, |
| 285 | | .store, |
| 286 | | .bool_and, |
| 287 | | .bool_or, |
| 288 | | .bit_and, |
| 289 | | .bit_or, |
| 290 | | .xor, |
| 291 | | => { |
| 292 | | const bin_op = inst.cast(Inst.BinOp).?; |
| 293 | | |
| 294 | | const lhs_kinky = try dtz.writeInst(writer, bin_op.lhs); |
| 295 | | try writer.writeAll(", "); |
| 296 | | const rhs_kinky = try dtz.writeInst(writer, bin_op.rhs); |
| 297 | | |
| 298 | | if (lhs_kinky != null or rhs_kinky != null) { |
| 299 | | try writer.writeAll(") // Instruction does not dominate all uses!"); |
| 300 | | if (lhs_kinky) |lhs| { |
| 301 | | try writer.print(" %{d}", .{lhs}); |
| 302 | | } |
| 303 | | if (rhs_kinky) |rhs| { |
| 304 | | try writer.print(" %{d}", .{rhs}); |
| 305 | | } |
| 306 | | try writer.writeAll("\n"); |
| 307 | | } else { |
| 308 | | try writer.writeAll(")\n"); |
| 309 | | } |
| 310 | | }, |
| 311 | | |
| 312 | | .arg => { |
| 313 | | const arg = inst.castTag(.arg).?; |
| 314 | | try writer.print("{s})\n", .{arg.name}); |
| 315 | | }, |
| 316 | | |
| 317 | | .br => { |
| 318 | | const br = inst.castTag(.br).?; |
| 319 | | |
| 320 | | const lhs_kinky = try dtz.writeInst(writer, &br.block.base); |
| 321 | | try writer.writeAll(", "); |
| 322 | | const rhs_kinky = try dtz.writeInst(writer, br.operand); |
| 323 | | |
| 324 | | if (lhs_kinky != null or rhs_kinky != null) { |
| 325 | | try writer.writeAll(") // Instruction does not dominate all uses!"); |
| 326 | | if (lhs_kinky) |lhs| { |
| 327 | | try writer.print(" %{d}", .{lhs}); |
| 328 | | } |
| 329 | | if (rhs_kinky) |rhs| { |
| 330 | | try writer.print(" %{d}", .{rhs}); |
| 331 | | } |
| 332 | | try writer.writeAll("\n"); |
| 333 | | } else { |
| 334 | | try writer.writeAll(")\n"); |
| 335 | | } |
| 336 | | }, |
| 337 | | |
| 338 | | .br_block_flat => { |
| 339 | | const br_block_flat = inst.castTag(.br_block_flat).?; |
| 340 | | const block_kinky = try dtz.writeInst(writer, &br_block_flat.block.base); |
| 341 | | if (block_kinky != null) { |
| 342 | | try writer.writeAll(", { // Instruction does not dominate all uses!\n"); |
| 343 | | } else { |
| 344 | | try writer.writeAll(", {\n"); |
| 345 | | } |
| 346 | | |
| 347 | | const old_indent = dtz.indent; |
| 348 | | dtz.indent += 2; |
| 349 | | try dtz.dumpBody(br_block_flat.body, writer); |
| 350 | | dtz.indent = old_indent; |
| 351 | | |
| 352 | | try writer.writeByteNTimes(' ', dtz.indent); |
| 353 | | try writer.writeAll("})\n"); |
| 354 | | }, |
| 355 | | |
| 356 | | .br_void => { |
| 357 | | const br_void = inst.castTag(.br_void).?; |
| 358 | | const kinky = try dtz.writeInst(writer, &br_void.block.base); |
| 359 | | if (kinky) |_| { |
| 360 | | try writer.writeAll(") // Instruction does not dominate all uses!\n"); |
| 361 | | } else { |
| 362 | | try writer.writeAll(")\n"); |
| 363 | | } |
| 364 | | }, |
| 365 | | |
| 366 | | .block => { |
| 367 | | const block = inst.castTag(.block).?; |
| 368 | | |
| 369 | | try writer.writeAll("{\n"); |
| 370 | | |
| 371 | | const old_indent = dtz.indent; |
| 372 | | dtz.indent += 2; |
| 373 | | try dtz.dumpBody(block.body, writer); |
| 374 | | dtz.indent = old_indent; |
| 375 | | |
| 376 | | try writer.writeByteNTimes(' ', dtz.indent); |
| 377 | | try writer.writeAll("})\n"); |
| 378 | | }, |
| 379 | | |
| 380 | | .condbr => { |
| 381 | | const condbr = inst.castTag(.condbr).?; |
| 382 | | |
| 383 | | const condition_kinky = try dtz.writeInst(writer, condbr.condition); |
| 384 | | if (condition_kinky != null) { |
| 385 | | try writer.writeAll(", { // Instruction does not dominate all uses!\n"); |
| 386 | | } else { |
| 387 | | try writer.writeAll(", {\n"); |
| 388 | | } |
| 389 | | |
| 390 | | const old_indent = dtz.indent; |
| 391 | | dtz.indent += 2; |
| 392 | | try dtz.dumpBody(condbr.then_body, writer); |
| 393 | | |
| 394 | | try writer.writeByteNTimes(' ', old_indent); |
| 395 | | try writer.writeAll("}, {\n"); |
| 396 | | |
| 397 | | try dtz.dumpBody(condbr.else_body, writer); |
| 398 | | dtz.indent = old_indent; |
| 399 | | |
| 400 | | try writer.writeByteNTimes(' ', old_indent); |
| 401 | | try writer.writeAll("})\n"); |
| 402 | | }, |
| 403 | | |
| 404 | | .switchbr => { |
| 405 | | const switchbr = inst.castTag(.switchbr).?; |
| 406 | | |
| 407 | | const condition_kinky = try dtz.writeInst(writer, switchbr.target); |
| 408 | | if (condition_kinky != null) { |
| 409 | | try writer.writeAll(", { // Instruction does not dominate all uses!\n"); |
| 410 | | } else { |
| 411 | | try writer.writeAll(", {\n"); |
| 412 | | } |
| 413 | | const old_indent = dtz.indent; |
| 414 | | |
| 415 | | if (switchbr.else_body.instructions.len != 0) { |
| 416 | | dtz.indent += 2; |
| 417 | | try dtz.dumpBody(switchbr.else_body, writer); |
| 418 | | |
| 419 | | try writer.writeByteNTimes(' ', old_indent); |
| 420 | | try writer.writeAll("}, {\n"); |
| 421 | | dtz.indent = old_indent; |
| 422 | | } |
| 423 | | for (switchbr.cases) |case| { |
| 424 | | dtz.indent += 2; |
| 425 | | try dtz.dumpBody(case.body, writer); |
| 426 | | |
| 427 | | try writer.writeByteNTimes(' ', old_indent); |
| 428 | | try writer.writeAll("}, {\n"); |
| 429 | | dtz.indent = old_indent; |
| 430 | | } |
| 431 | | |
| 432 | | try writer.writeByteNTimes(' ', old_indent); |
| 433 | | try writer.writeAll("})\n"); |
| 434 | | }, |
| 435 | | |
| 436 | | .loop => { |
| 437 | | const loop = inst.castTag(.loop).?; |
| 438 | | |
| 439 | | try writer.writeAll("{\n"); |
| 440 | | |
| 441 | | const old_indent = dtz.indent; |
| 442 | | dtz.indent += 2; |
| 443 | | try dtz.dumpBody(loop.body, writer); |
| 444 | | dtz.indent = old_indent; |
| 445 | | |
| 446 | | try writer.writeByteNTimes(' ', dtz.indent); |
| 447 | | try writer.writeAll("})\n"); |
| 448 | | }, |
| 449 | | |
| 450 | | .call => { |
| 451 | | const call = inst.castTag(.call).?; |
| 452 | | |
| 453 | | const args_kinky = try dtz.allocator.alloc(?usize, call.args.len); |
| 454 | | defer dtz.allocator.free(args_kinky); |
| 455 | | std.mem.set(?usize, args_kinky, null); |
| 456 | | var any_kinky_args = false; |
| 457 | | |
| 458 | | const func_kinky = try dtz.writeInst(writer, call.func); |
| 459 | | |
| 460 | | for (call.args) |arg, i| { |
| 461 | | try writer.writeAll(", "); |
| 462 | | |
| 463 | | args_kinky[i] = try dtz.writeInst(writer, arg); |
| 464 | | any_kinky_args = any_kinky_args or args_kinky[i] != null; |
| 465 | | } |
| 466 | | |
| 467 | | if (func_kinky != null or any_kinky_args) { |
| 468 | | try writer.writeAll(") // Instruction does not dominate all uses!"); |
| 469 | | if (func_kinky) |func_index| { |
| 470 | | try writer.print(" %{d}", .{func_index}); |
| 471 | | } |
| 472 | | for (args_kinky) |arg_kinky| { |
| 473 | | if (arg_kinky) |arg_index| { |
| 474 | | try writer.print(" %{d}", .{arg_index}); |
| 475 | | } |
| 476 | | } |
| 477 | | try writer.writeAll("\n"); |
| 478 | | } else { |
| 479 | | try writer.writeAll(")\n"); |
| 480 | | } |
| 481 | | }, |
| 482 | | |
| 483 | | .struct_field_ptr => { |
| 484 | | const struct_field_ptr = inst.castTag(.struct_field_ptr).?; |
| 485 | | const kinky = try dtz.writeInst(writer, struct_field_ptr.struct_ptr); |
| 486 | | if (kinky != null) { |
| 487 | | try writer.print("{d}) // Instruction does not dominate all uses!\n", .{ |
| 488 | | struct_field_ptr.field_index, |
| 489 | | }); |
| 490 | | } else { |
| 491 | | try writer.print("{d})\n", .{struct_field_ptr.field_index}); |
| 492 | | } |
| 493 | | }, |
| 494 | | |
| 495 | | // TODO fill out this debug printing |
| 496 | | .assembly, |
| 497 | | .constant, |
| 498 | | .varptr, |
| 499 | | => { |
| 500 | | try writer.writeAll("!TODO!)\n"); |
| 501 | | }, |
| 502 | | } |
| 503 | | } |
| 504 | | } |
| 505 | | |
| 506 | | fn writeInst(dtz: *DumpAir, writer: std.fs.File.Writer, inst: *Inst) !?usize { |
| 507 | | if (dtz.partial_inst_table.get(inst)) |operand_index| { |
| 508 | | try writer.print("%{d}", .{operand_index}); |
| 509 | | return null; |
| 510 | | } else if (dtz.const_table.get(inst)) |operand_index| { |
| 511 | | try writer.print("@{d}", .{operand_index}); |
| 512 | | return null; |
| 513 | | } else if (dtz.inst_table.get(inst)) |operand_index| { |
| 514 | | try writer.print("%{d}", .{operand_index}); |
| 515 | | return operand_index; |
| 516 | | } else { |
| 517 | | try writer.writeAll("!BADREF!"); |
| 518 | | return null; |
| 519 | | } |
| 520 | | } |
| 521 | | |
| 522 | | fn findConst(dtz: *DumpAir, operand: *Inst) !void { |
| 523 | | if (operand.tag == .constant) { |
| 524 | | try dtz.const_table.put(operand, dtz.next_const_index); |
| 525 | | dtz.next_const_index += 1; |
| 526 | | } |
| 527 | | } |
| 528 | | }; |
| 529 | | |
| 530 | | pub fn dumpInst(mod: *Module, scope: *Scope, inst: *ir.Inst) void { |
| 531 | | const zir_module = scope.namespace(); |
| 532 | | const source = zir_module.getSource(mod) catch @panic("dumpInst failed to get source"); |
| 533 | | const loc = std.zig.findLineColumn(source, inst.src); |
| 534 | | if (inst.tag == .constant) { |
| 535 | | std.debug.print("constant ty={} val={} src={s}:{d}:{d}\n", .{ |
| 536 | | inst.ty, |
| 537 | | inst.castTag(.constant).?.val, |
| 538 | | zir_module.subFilePath(), |
| 539 | | loc.line + 1, |
| 540 | | loc.column + 1, |
| 541 | | }); |
| 542 | | } else if (inst.deaths == 0) { |
| 543 | | std.debug.print("{s} ty={} src={s}:{d}:{d}\n", .{ |
| 544 | | @tagName(inst.tag), |
| 545 | | inst.ty, |
| 546 | | zir_module.subFilePath(), |
| 547 | | loc.line + 1, |
| 548 | | loc.column + 1, |
| 549 | | }); |
| 550 | | } else { |
| 551 | | std.debug.print("{s} ty={} deaths={b} src={s}:{d}:{d}\n", .{ |
| 552 | | @tagName(inst.tag), |
| 553 | | inst.ty, |
| 554 | | inst.deaths, |
| 555 | | zir_module.subFilePath(), |
| 556 | | loc.line + 1, |
| 557 | | loc.column + 1, |
| 558 | | }); |
| 559 | | } |
| 560 | | } |
| 561 | | |
| 562 | | /// For debugging purposes. |
| 563 | | pub fn dump(func: *Fn, mod: Module) void { |
| 564 | | ir.dumpFn(mod, func); |
| 565 | | } |
| 566 | | |