| author | |
| committer | |
| log | 48f9e491cb97de54c7e8d395170d8b4c8ea9a62b |
| tree | 1814df5a930afc03f1cadd114ccee2b2204107f1 |
| parent | 96a55f6ce86dc2e25c275ee3211b2cde0e3d92ab |
| parent | a95d58caf289ecc2ab36cdb30437f634c07b64e4 |
| signature |
self-hosted: cleanup codegen.Result12 files changed, 121 insertions(+), 211 deletions(-)
src/arch/aarch64/CodeGen.zig+9-9| ... | @@ -24,7 +24,7 @@ const log = std.log.scoped(.codegen); | ... | @@ -24,7 +24,7 @@ const log = std.log.scoped(.codegen); |
| 24 | const build_options = @import("build_options"); | 24 | const build_options = @import("build_options"); |
| 25 | 25 | ||
| 26 | const GenerateSymbolError = codegen.GenerateSymbolError; | 26 | const GenerateSymbolError = codegen.GenerateSymbolError; |
| 27 | const FnResult = codegen.FnResult; | 27 | const Result = codegen.Result; |
| 28 | const DebugInfoOutput = codegen.DebugInfoOutput; | 28 | const DebugInfoOutput = codegen.DebugInfoOutput; |
| 29 | 29 | ||
| 30 | const bits = @import("bits.zig"); | 30 | const bits = @import("bits.zig"); |
| ... | @@ -349,7 +349,7 @@ pub fn generate( | ... | @@ -349,7 +349,7 @@ pub fn generate( |
| 349 | liveness: Liveness, | 349 | liveness: Liveness, |
| 350 | code: *std.ArrayList(u8), | 350 | code: *std.ArrayList(u8), |
| 351 | debug_output: DebugInfoOutput, | 351 | debug_output: DebugInfoOutput, |
| 352 | ) GenerateSymbolError!FnResult { | 352 | ) GenerateSymbolError!Result { |
| 353 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { | 353 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { |
| 354 | @panic("Attempted to compile for architecture that was disabled by build configuration"); | 354 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 355 | } | 355 | } |
| ... | @@ -392,8 +392,8 @@ pub fn generate( | ... | @@ -392,8 +392,8 @@ pub fn generate( |
| 392 | defer function.dbg_info_relocs.deinit(bin_file.allocator); | 392 | defer function.dbg_info_relocs.deinit(bin_file.allocator); |
| 393 | 393 | ||
| 394 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { | 394 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { |
| 395 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 395 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 396 | error.OutOfRegisters => return FnResult{ | 396 | error.OutOfRegisters => return Result{ |
| 397 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 397 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 398 | }, | 398 | }, |
| 399 | else => |e| return e, | 399 | else => |e| return e, |
| ... | @@ -406,8 +406,8 @@ pub fn generate( | ... | @@ -406,8 +406,8 @@ pub fn generate( |
| 406 | function.max_end_stack = call_info.stack_byte_count; | 406 | function.max_end_stack = call_info.stack_byte_count; |
| 407 | 407 | ||
| 408 | function.gen() catch |err| switch (err) { | 408 | function.gen() catch |err| switch (err) { |
| 409 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 409 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 410 | error.OutOfRegisters => return FnResult{ | 410 | error.OutOfRegisters => return Result{ |
| 411 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 411 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 412 | }, | 412 | }, |
| 413 | else => |e| return e, | 413 | else => |e| return e, |
| ... | @@ -439,14 +439,14 @@ pub fn generate( | ... | @@ -439,14 +439,14 @@ pub fn generate( |
| 439 | defer emit.deinit(); | 439 | defer emit.deinit(); |
| 440 | 440 | ||
| 441 | emit.emitMir() catch |err| switch (err) { | 441 | emit.emitMir() catch |err| switch (err) { |
| 442 | error.EmitFail => return FnResult{ .fail = emit.err_msg.? }, | 442 | error.EmitFail => return Result{ .fail = emit.err_msg.? }, |
| 443 | else => |e| return e, | 443 | else => |e| return e, |
| 444 | }; | 444 | }; |
| 445 | 445 | ||
| 446 | if (function.err_msg) |em| { | 446 | if (function.err_msg) |em| { |
| 447 | return FnResult{ .fail = em }; | 447 | return Result{ .fail = em }; |
| 448 | } else { | 448 | } else { |
| 449 | return FnResult{ .appended = {} }; | 449 | return Result.ok; |
| 450 | } | 450 | } |
| 451 | } | 451 | } |
| 452 | 452 |
src/arch/arm/CodeGen.zig+9-9| ... | @@ -23,7 +23,7 @@ const leb128 = std.leb; | ... | @@ -23,7 +23,7 @@ const leb128 = std.leb; |
| 23 | const log = std.log.scoped(.codegen); | 23 | const log = std.log.scoped(.codegen); |
| 24 | const build_options = @import("build_options"); | 24 | const build_options = @import("build_options"); |
| 25 | 25 | ||
| 26 | const FnResult = codegen.FnResult; | 26 | const Result = codegen.Result; |
| 27 | const GenerateSymbolError = codegen.GenerateSymbolError; | 27 | const GenerateSymbolError = codegen.GenerateSymbolError; |
| 28 | const DebugInfoOutput = codegen.DebugInfoOutput; | 28 | const DebugInfoOutput = codegen.DebugInfoOutput; |
| 29 | 29 | ||
| ... | @@ -356,7 +356,7 @@ pub fn generate( | ... | @@ -356,7 +356,7 @@ pub fn generate( |
| 356 | liveness: Liveness, | 356 | liveness: Liveness, |
| 357 | code: *std.ArrayList(u8), | 357 | code: *std.ArrayList(u8), |
| 358 | debug_output: DebugInfoOutput, | 358 | debug_output: DebugInfoOutput, |
| 359 | ) GenerateSymbolError!FnResult { | 359 | ) GenerateSymbolError!Result { |
| 360 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { | 360 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { |
| 361 | @panic("Attempted to compile for architecture that was disabled by build configuration"); | 361 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 362 | } | 362 | } |
| ... | @@ -399,8 +399,8 @@ pub fn generate( | ... | @@ -399,8 +399,8 @@ pub fn generate( |
| 399 | defer function.dbg_info_relocs.deinit(bin_file.allocator); | 399 | defer function.dbg_info_relocs.deinit(bin_file.allocator); |
| 400 | 400 | ||
| 401 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { | 401 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { |
| 402 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 402 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 403 | error.OutOfRegisters => return FnResult{ | 403 | error.OutOfRegisters => return Result{ |
| 404 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 404 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 405 | }, | 405 | }, |
| 406 | else => |e| return e, | 406 | else => |e| return e, |
| ... | @@ -413,8 +413,8 @@ pub fn generate( | ... | @@ -413,8 +413,8 @@ pub fn generate( |
| 413 | function.max_end_stack = call_info.stack_byte_count; | 413 | function.max_end_stack = call_info.stack_byte_count; |
| 414 | 414 | ||
| 415 | function.gen() catch |err| switch (err) { | 415 | function.gen() catch |err| switch (err) { |
| 416 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 416 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 417 | error.OutOfRegisters => return FnResult{ | 417 | error.OutOfRegisters => return Result{ |
| 418 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 418 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 419 | }, | 419 | }, |
| 420 | else => |e| return e, | 420 | else => |e| return e, |
| ... | @@ -446,14 +446,14 @@ pub fn generate( | ... | @@ -446,14 +446,14 @@ pub fn generate( |
| 446 | defer emit.deinit(); | 446 | defer emit.deinit(); |
| 447 | 447 | ||
| 448 | emit.emitMir() catch |err| switch (err) { | 448 | emit.emitMir() catch |err| switch (err) { |
| 449 | error.EmitFail => return FnResult{ .fail = emit.err_msg.? }, | 449 | error.EmitFail => return Result{ .fail = emit.err_msg.? }, |
| 450 | else => |e| return e, | 450 | else => |e| return e, |
| 451 | }; | 451 | }; |
| 452 | 452 | ||
| 453 | if (function.err_msg) |em| { | 453 | if (function.err_msg) |em| { |
| 454 | return FnResult{ .fail = em }; | 454 | return Result{ .fail = em }; |
| 455 | } else { | 455 | } else { |
| 456 | return FnResult{ .appended = {} }; | 456 | return Result.ok; |
| 457 | } | 457 | } |
| 458 | } | 458 | } |
| 459 | 459 |
src/arch/riscv64/CodeGen.zig+9-9| ... | @@ -22,7 +22,7 @@ const leb128 = std.leb; | ... | @@ -22,7 +22,7 @@ const leb128 = std.leb; |
| 22 | const log = std.log.scoped(.codegen); | 22 | const log = std.log.scoped(.codegen); |
| 23 | const build_options = @import("build_options"); | 23 | const build_options = @import("build_options"); |
| 24 | 24 | ||
| 25 | const FnResult = @import("../../codegen.zig").FnResult; | 25 | const Result = @import("../../codegen.zig").Result; |
| 26 | const GenerateSymbolError = @import("../../codegen.zig").GenerateSymbolError; | 26 | const GenerateSymbolError = @import("../../codegen.zig").GenerateSymbolError; |
| 27 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | 27 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; |
| 28 | 28 | ||
| ... | @@ -225,7 +225,7 @@ pub fn generate( | ... | @@ -225,7 +225,7 @@ pub fn generate( |
| 225 | liveness: Liveness, | 225 | liveness: Liveness, |
| 226 | code: *std.ArrayList(u8), | 226 | code: *std.ArrayList(u8), |
| 227 | debug_output: DebugInfoOutput, | 227 | debug_output: DebugInfoOutput, |
| 228 | ) GenerateSymbolError!FnResult { | 228 | ) GenerateSymbolError!Result { |
| 229 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { | 229 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { |
| 230 | @panic("Attempted to compile for architecture that was disabled by build configuration"); | 230 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 231 | } | 231 | } |
| ... | @@ -268,8 +268,8 @@ pub fn generate( | ... | @@ -268,8 +268,8 @@ pub fn generate( |
| 268 | defer function.exitlude_jump_relocs.deinit(bin_file.allocator); | 268 | defer function.exitlude_jump_relocs.deinit(bin_file.allocator); |
| 269 | 269 | ||
| 270 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { | 270 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { |
| 271 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 271 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 272 | error.OutOfRegisters => return FnResult{ | 272 | error.OutOfRegisters => return Result{ |
| 273 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 273 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 274 | }, | 274 | }, |
| 275 | else => |e| return e, | 275 | else => |e| return e, |
| ... | @@ -282,8 +282,8 @@ pub fn generate( | ... | @@ -282,8 +282,8 @@ pub fn generate( |
| 282 | function.max_end_stack = call_info.stack_byte_count; | 282 | function.max_end_stack = call_info.stack_byte_count; |
| 283 | 283 | ||
| 284 | function.gen() catch |err| switch (err) { | 284 | function.gen() catch |err| switch (err) { |
| 285 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 285 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 286 | error.OutOfRegisters => return FnResult{ | 286 | error.OutOfRegisters => return Result{ |
| 287 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 287 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 288 | }, | 288 | }, |
| 289 | else => |e| return e, | 289 | else => |e| return e, |
| ... | @@ -309,14 +309,14 @@ pub fn generate( | ... | @@ -309,14 +309,14 @@ pub fn generate( |
| 309 | defer emit.deinit(); | 309 | defer emit.deinit(); |
| 310 | 310 | ||
| 311 | emit.emitMir() catch |err| switch (err) { | 311 | emit.emitMir() catch |err| switch (err) { |
| 312 | error.EmitFail => return FnResult{ .fail = emit.err_msg.? }, | 312 | error.EmitFail => return Result{ .fail = emit.err_msg.? }, |
| 313 | else => |e| return e, | 313 | else => |e| return e, |
| 314 | }; | 314 | }; |
| 315 | 315 | ||
| 316 | if (function.err_msg) |em| { | 316 | if (function.err_msg) |em| { |
| 317 | return FnResult{ .fail = em }; | 317 | return Result{ .fail = em }; |
| 318 | } else { | 318 | } else { |
| 319 | return FnResult{ .appended = {} }; | 319 | return Result.ok; |
| 320 | } | 320 | } |
| 321 | } | 321 | } |
| 322 | 322 |
src/arch/sparc64/CodeGen.zig+9-9| ... | @@ -20,7 +20,7 @@ const Emit = @import("Emit.zig"); | ... | @@ -20,7 +20,7 @@ const Emit = @import("Emit.zig"); |
| 20 | const Liveness = @import("../../Liveness.zig"); | 20 | const Liveness = @import("../../Liveness.zig"); |
| 21 | const Type = @import("../../type.zig").Type; | 21 | const Type = @import("../../type.zig").Type; |
| 22 | const GenerateSymbolError = @import("../../codegen.zig").GenerateSymbolError; | 22 | const GenerateSymbolError = @import("../../codegen.zig").GenerateSymbolError; |
| 23 | const FnResult = @import("../../codegen.zig").FnResult; | 23 | const Result = @import("../../codegen.zig").Result; |
| 24 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | 24 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; |
| 25 | 25 | ||
| 26 | const build_options = @import("build_options"); | 26 | const build_options = @import("build_options"); |
| ... | @@ -265,7 +265,7 @@ pub fn generate( | ... | @@ -265,7 +265,7 @@ pub fn generate( |
| 265 | liveness: Liveness, | 265 | liveness: Liveness, |
| 266 | code: *std.ArrayList(u8), | 266 | code: *std.ArrayList(u8), |
| 267 | debug_output: DebugInfoOutput, | 267 | debug_output: DebugInfoOutput, |
| 268 | ) GenerateSymbolError!FnResult { | 268 | ) GenerateSymbolError!Result { |
| 269 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { | 269 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { |
| 270 | @panic("Attempted to compile for architecture that was disabled by build configuration"); | 270 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 271 | } | 271 | } |
| ... | @@ -310,8 +310,8 @@ pub fn generate( | ... | @@ -310,8 +310,8 @@ pub fn generate( |
| 310 | defer function.exitlude_jump_relocs.deinit(bin_file.allocator); | 310 | defer function.exitlude_jump_relocs.deinit(bin_file.allocator); |
| 311 | 311 | ||
| 312 | var call_info = function.resolveCallingConventionValues(fn_type, .callee) catch |err| switch (err) { | 312 | var call_info = function.resolveCallingConventionValues(fn_type, .callee) catch |err| switch (err) { |
| 313 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 313 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 314 | error.OutOfRegisters => return FnResult{ | 314 | error.OutOfRegisters => return Result{ |
| 315 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 315 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 316 | }, | 316 | }, |
| 317 | else => |e| return e, | 317 | else => |e| return e, |
| ... | @@ -324,8 +324,8 @@ pub fn generate( | ... | @@ -324,8 +324,8 @@ pub fn generate( |
| 324 | function.max_end_stack = call_info.stack_byte_count; | 324 | function.max_end_stack = call_info.stack_byte_count; |
| 325 | 325 | ||
| 326 | function.gen() catch |err| switch (err) { | 326 | function.gen() catch |err| switch (err) { |
| 327 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 327 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 328 | error.OutOfRegisters => return FnResult{ | 328 | error.OutOfRegisters => return Result{ |
| 329 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 329 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 330 | }, | 330 | }, |
| 331 | else => |e| return e, | 331 | else => |e| return e, |
| ... | @@ -351,14 +351,14 @@ pub fn generate( | ... | @@ -351,14 +351,14 @@ pub fn generate( |
| 351 | defer emit.deinit(); | 351 | defer emit.deinit(); |
| 352 | 352 | ||
| 353 | emit.emitMir() catch |err| switch (err) { | 353 | emit.emitMir() catch |err| switch (err) { |
| 354 | error.EmitFail => return FnResult{ .fail = emit.err_msg.? }, | 354 | error.EmitFail => return Result{ .fail = emit.err_msg.? }, |
| 355 | else => |e| return e, | 355 | else => |e| return e, |
| 356 | }; | 356 | }; |
| 357 | 357 | ||
| 358 | if (function.err_msg) |em| { | 358 | if (function.err_msg) |em| { |
| 359 | return FnResult{ .fail = em }; | 359 | return Result{ .fail = em }; |
| 360 | } else { | 360 | } else { |
| 361 | return FnResult{ .appended = {} }; | 361 | return Result.ok; |
| 362 | } | 362 | } |
| 363 | } | 363 | } |
| 364 | 364 |
src/arch/wasm/CodeGen.zig+3-10| ... | @@ -627,13 +627,6 @@ test "Wasm - buildOpcode" { | ... | @@ -627,13 +627,6 @@ test "Wasm - buildOpcode" { |
| 627 | try testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64); | 627 | try testing.expectEqual(@as(wasm.Opcode, .f64_reinterpret_i64), f64_reinterpret_i64); |
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | pub const Result = union(enum) { | ||
| 631 | /// The codegen bytes have been appended to `Context.code` | ||
| 632 | appended: void, | ||
| 633 | /// The data is managed externally and are part of the `Result` | ||
| 634 | externally_managed: []const u8, | ||
| 635 | }; | ||
| 636 | |||
| 637 | /// Hashmap to store generated `WValue` for each `Air.Inst.Ref` | 630 | /// Hashmap to store generated `WValue` for each `Air.Inst.Ref` |
| 638 | pub const ValueTable = std.AutoArrayHashMapUnmanaged(Air.Inst.Ref, WValue); | 631 | pub const ValueTable = std.AutoArrayHashMapUnmanaged(Air.Inst.Ref, WValue); |
| 639 | 632 | ||
| ... | @@ -1171,7 +1164,7 @@ pub fn generate( | ... | @@ -1171,7 +1164,7 @@ pub fn generate( |
| 1171 | liveness: Liveness, | 1164 | liveness: Liveness, |
| 1172 | code: *std.ArrayList(u8), | 1165 | code: *std.ArrayList(u8), |
| 1173 | debug_output: codegen.DebugInfoOutput, | 1166 | debug_output: codegen.DebugInfoOutput, |
| 1174 | ) codegen.GenerateSymbolError!codegen.FnResult { | 1167 | ) codegen.GenerateSymbolError!codegen.Result { |
| 1175 | _ = src_loc; | 1168 | _ = src_loc; |
| 1176 | var code_gen: CodeGen = .{ | 1169 | var code_gen: CodeGen = .{ |
| 1177 | .gpa = bin_file.allocator, | 1170 | .gpa = bin_file.allocator, |
| ... | @@ -1190,11 +1183,11 @@ pub fn generate( | ... | @@ -1190,11 +1183,11 @@ pub fn generate( |
| 1190 | defer code_gen.deinit(); | 1183 | defer code_gen.deinit(); |
| 1191 | 1184 | ||
| 1192 | genFunc(&code_gen) catch |err| switch (err) { | 1185 | genFunc(&code_gen) catch |err| switch (err) { |
| 1193 | error.CodegenFail => return codegen.FnResult{ .fail = code_gen.err_msg }, | 1186 | error.CodegenFail => return codegen.Result{ .fail = code_gen.err_msg }, |
| 1194 | else => |e| return e, | 1187 | else => |e| return e, |
| 1195 | }; | 1188 | }; |
| 1196 | 1189 | ||
| 1197 | return codegen.FnResult{ .appended = {} }; | 1190 | return codegen.Result.ok; |
| 1198 | } | 1191 | } |
| 1199 | 1192 | ||
| 1200 | fn genFunc(func: *CodeGen) InnerError!void { | 1193 | fn genFunc(func: *CodeGen) InnerError!void { |
src/arch/x86_64/CodeGen.zig+9-9| ... | @@ -16,7 +16,7 @@ const Compilation = @import("../../Compilation.zig"); | ... | @@ -16,7 +16,7 @@ const Compilation = @import("../../Compilation.zig"); |
| 16 | const DebugInfoOutput = codegen.DebugInfoOutput; | 16 | const DebugInfoOutput = codegen.DebugInfoOutput; |
| 17 | const DW = std.dwarf; | 17 | const DW = std.dwarf; |
| 18 | const ErrorMsg = Module.ErrorMsg; | 18 | const ErrorMsg = Module.ErrorMsg; |
| 19 | const FnResult = codegen.FnResult; | 19 | const Result = codegen.Result; |
| 20 | const GenerateSymbolError = codegen.GenerateSymbolError; | 20 | const GenerateSymbolError = codegen.GenerateSymbolError; |
| 21 | const Emit = @import("Emit.zig"); | 21 | const Emit = @import("Emit.zig"); |
| 22 | const Liveness = @import("../../Liveness.zig"); | 22 | const Liveness = @import("../../Liveness.zig"); |
| ... | @@ -257,7 +257,7 @@ pub fn generate( | ... | @@ -257,7 +257,7 @@ pub fn generate( |
| 257 | liveness: Liveness, | 257 | liveness: Liveness, |
| 258 | code: *std.ArrayList(u8), | 258 | code: *std.ArrayList(u8), |
| 259 | debug_output: DebugInfoOutput, | 259 | debug_output: DebugInfoOutput, |
| 260 | ) GenerateSymbolError!FnResult { | 260 | ) GenerateSymbolError!Result { |
| 261 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { | 261 | if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { |
| 262 | @panic("Attempted to compile for architecture that was disabled by build configuration"); | 262 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 263 | } | 263 | } |
| ... | @@ -305,8 +305,8 @@ pub fn generate( | ... | @@ -305,8 +305,8 @@ pub fn generate( |
| 305 | defer if (builtin.mode == .Debug) function.mir_to_air_map.deinit(); | 305 | defer if (builtin.mode == .Debug) function.mir_to_air_map.deinit(); |
| 306 | 306 | ||
| 307 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { | 307 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { |
| 308 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 308 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 309 | error.OutOfRegisters => return FnResult{ | 309 | error.OutOfRegisters => return Result{ |
| 310 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 310 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 311 | }, | 311 | }, |
| 312 | else => |e| return e, | 312 | else => |e| return e, |
| ... | @@ -319,8 +319,8 @@ pub fn generate( | ... | @@ -319,8 +319,8 @@ pub fn generate( |
| 319 | function.max_end_stack = call_info.stack_byte_count; | 319 | function.max_end_stack = call_info.stack_byte_count; |
| 320 | 320 | ||
| 321 | function.gen() catch |err| switch (err) { | 321 | function.gen() catch |err| switch (err) { |
| 322 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, | 322 | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 323 | error.OutOfRegisters => return FnResult{ | 323 | error.OutOfRegisters => return Result{ |
| 324 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), | 324 | .fail = try ErrorMsg.create(bin_file.allocator, src_loc, "CodeGen ran out of registers. This is a bug in the Zig compiler.", .{}), |
| 325 | }, | 325 | }, |
| 326 | else => |e| return e, | 326 | else => |e| return e, |
| ... | @@ -345,14 +345,14 @@ pub fn generate( | ... | @@ -345,14 +345,14 @@ pub fn generate( |
| 345 | }; | 345 | }; |
| 346 | defer emit.deinit(); | 346 | defer emit.deinit(); |
| 347 | emit.lowerMir() catch |err| switch (err) { | 347 | emit.lowerMir() catch |err| switch (err) { |
| 348 | error.EmitFail => return FnResult{ .fail = emit.err_msg.? }, | 348 | error.EmitFail => return Result{ .fail = emit.err_msg.? }, |
| 349 | else => |e| return e, | 349 | else => |e| return e, |
| 350 | }; | 350 | }; |
| 351 | 351 | ||
| 352 | if (function.err_msg) |em| { | 352 | if (function.err_msg) |em| { |
| 353 | return FnResult{ .fail = em }; | 353 | return Result{ .fail = em }; |
| 354 | } else { | 354 | } else { |
| 355 | return FnResult{ .appended = {} }; | 355 | return Result.ok; |
| 356 | } | 356 | } |
| 357 | } | 357 | } |
| 358 | 358 |
src/codegen.zig+58-131| ... | @@ -21,16 +21,11 @@ const TypedValue = @import("TypedValue.zig"); | ... | @@ -21,16 +21,11 @@ const TypedValue = @import("TypedValue.zig"); |
| 21 | const Value = @import("value.zig").Value; | 21 | const Value = @import("value.zig").Value; |
| 22 | const Zir = @import("Zir.zig"); | 22 | const Zir = @import("Zir.zig"); |
| 23 | 23 | ||
| 24 | pub const FnResult = union(enum) { | ||
| 25 | /// The `code` parameter passed to `generateSymbol` has the value appended. | ||
| 26 | appended: void, | ||
| 27 | fail: *ErrorMsg, | ||
| 28 | }; | ||
| 29 | pub const Result = union(enum) { | 24 | pub const Result = union(enum) { |
| 30 | /// The `code` parameter passed to `generateSymbol` has the value appended. | 25 | /// The `code` parameter passed to `generateSymbol` has the value ok. |
| 31 | appended: void, | 26 | ok: void, |
| 32 | /// The value is available externally, `code` is unused. | 27 | |
| 33 | externally_managed: []const u8, | 28 | /// There was a codegen error. |
| 34 | fail: *ErrorMsg, | 29 | fail: *ErrorMsg, |
| 35 | }; | 30 | }; |
| 36 | 31 | ||
| ... | @@ -89,7 +84,7 @@ pub fn generateFunction( | ... | @@ -89,7 +84,7 @@ pub fn generateFunction( |
| 89 | liveness: Liveness, | 84 | liveness: Liveness, |
| 90 | code: *std.ArrayList(u8), | 85 | code: *std.ArrayList(u8), |
| 91 | debug_output: DebugInfoOutput, | 86 | debug_output: DebugInfoOutput, |
| 92 | ) GenerateSymbolError!FnResult { | 87 | ) GenerateSymbolError!Result { |
| 93 | switch (bin_file.options.target.cpu.arch) { | 88 | switch (bin_file.options.target.cpu.arch) { |
| 94 | .arm, | 89 | .arm, |
| 95 | .armeb, | 90 | .armeb, |
| ... | @@ -145,7 +140,7 @@ pub fn generateSymbol( | ... | @@ -145,7 +140,7 @@ pub fn generateSymbol( |
| 145 | if (typed_value.val.isUndefDeep()) { | 140 | if (typed_value.val.isUndefDeep()) { |
| 146 | const abi_size = math.cast(usize, typed_value.ty.abiSize(target)) orelse return error.Overflow; | 141 | const abi_size = math.cast(usize, typed_value.ty.abiSize(target)) orelse return error.Overflow; |
| 147 | try code.appendNTimes(0xaa, abi_size); | 142 | try code.appendNTimes(0xaa, abi_size); |
| 148 | return Result{ .appended = {} }; | 143 | return Result.ok; |
| 149 | } | 144 | } |
| 150 | 145 | ||
| 151 | switch (typed_value.ty.zigTypeTag()) { | 146 | switch (typed_value.ty.zigTypeTag()) { |
| ... | @@ -176,7 +171,7 @@ pub fn generateSymbol( | ... | @@ -176,7 +171,7 @@ pub fn generateSymbol( |
| 176 | 128 => writeFloat(f128, typed_value.val.toFloat(f128), target, endian, try code.addManyAsArray(16)), | 171 | 128 => writeFloat(f128, typed_value.val.toFloat(f128), target, endian, try code.addManyAsArray(16)), |
| 177 | else => unreachable, | 172 | else => unreachable, |
| 178 | } | 173 | } |
| 179 | return Result{ .appended = {} }; | 174 | return Result.ok; |
| 180 | }, | 175 | }, |
| 181 | .Array => switch (typed_value.val.tag()) { | 176 | .Array => switch (typed_value.val.tag()) { |
| 182 | .bytes => { | 177 | .bytes => { |
| ... | @@ -185,7 +180,7 @@ pub fn generateSymbol( | ... | @@ -185,7 +180,7 @@ pub fn generateSymbol( |
| 185 | // The bytes payload already includes the sentinel, if any | 180 | // The bytes payload already includes the sentinel, if any |
| 186 | try code.ensureUnusedCapacity(len); | 181 | try code.ensureUnusedCapacity(len); |
| 187 | code.appendSliceAssumeCapacity(bytes[0..len]); | 182 | code.appendSliceAssumeCapacity(bytes[0..len]); |
| 188 | return Result{ .appended = {} }; | 183 | return Result.ok; |
| 189 | }, | 184 | }, |
| 190 | .str_lit => { | 185 | .str_lit => { |
| 191 | const str_lit = typed_value.val.castTag(.str_lit).?.data; | 186 | const str_lit = typed_value.val.castTag(.str_lit).?.data; |
| ... | @@ -197,7 +192,7 @@ pub fn generateSymbol( | ... | @@ -197,7 +192,7 @@ pub fn generateSymbol( |
| 197 | const byte = @intCast(u8, sent_val.toUnsignedInt(target)); | 192 | const byte = @intCast(u8, sent_val.toUnsignedInt(target)); |
| 198 | code.appendAssumeCapacity(byte); | 193 | code.appendAssumeCapacity(byte); |
| 199 | } | 194 | } |
| 200 | return Result{ .appended = {} }; | 195 | return Result.ok; |
| 201 | }, | 196 | }, |
| 202 | .aggregate => { | 197 | .aggregate => { |
| 203 | const elem_vals = typed_value.val.castTag(.aggregate).?.data; | 198 | const elem_vals = typed_value.val.castTag(.aggregate).?.data; |
| ... | @@ -208,14 +203,11 @@ pub fn generateSymbol( | ... | @@ -208,14 +203,11 @@ pub fn generateSymbol( |
| 208 | .ty = elem_ty, | 203 | .ty = elem_ty, |
| 209 | .val = elem_val, | 204 | .val = elem_val, |
| 210 | }, code, debug_output, reloc_info)) { | 205 | }, code, debug_output, reloc_info)) { |
| 211 | .appended => {}, | 206 | .ok => {}, |
| 212 | .externally_managed => |slice| { | ||
| 213 | code.appendSliceAssumeCapacity(slice); | ||
| 214 | }, | ||
| 215 | .fail => |em| return Result{ .fail = em }, | 207 | .fail => |em| return Result{ .fail = em }, |
| 216 | } | 208 | } |
| 217 | } | 209 | } |
| 218 | return Result{ .appended = {} }; | 210 | return Result.ok; |
| 219 | }, | 211 | }, |
| 220 | .repeated => { | 212 | .repeated => { |
| 221 | const array = typed_value.val.castTag(.repeated).?.data; | 213 | const array = typed_value.val.castTag(.repeated).?.data; |
| ... | @@ -229,10 +221,7 @@ pub fn generateSymbol( | ... | @@ -229,10 +221,7 @@ pub fn generateSymbol( |
| 229 | .ty = elem_ty, | 221 | .ty = elem_ty, |
| 230 | .val = array, | 222 | .val = array, |
| 231 | }, code, debug_output, reloc_info)) { | 223 | }, code, debug_output, reloc_info)) { |
| 232 | .appended => {}, | 224 | .ok => {}, |
| 233 | .externally_managed => |slice| { | ||
| 234 | code.appendSliceAssumeCapacity(slice); | ||
| 235 | }, | ||
| 236 | .fail => |em| return Result{ .fail = em }, | 225 | .fail => |em| return Result{ .fail = em }, |
| 237 | } | 226 | } |
| 238 | } | 227 | } |
| ... | @@ -242,15 +231,12 @@ pub fn generateSymbol( | ... | @@ -242,15 +231,12 @@ pub fn generateSymbol( |
| 242 | .ty = elem_ty, | 231 | .ty = elem_ty, |
| 243 | .val = sentinel_val, | 232 | .val = sentinel_val, |
| 244 | }, code, debug_output, reloc_info)) { | 233 | }, code, debug_output, reloc_info)) { |
| 245 | .appended => {}, | 234 | .ok => {}, |
| 246 | .externally_managed => |slice| { | ||
| 247 | code.appendSliceAssumeCapacity(slice); | ||
| 248 | }, | ||
| 249 | .fail => |em| return Result{ .fail = em }, | 235 | .fail => |em| return Result{ .fail = em }, |
| 250 | } | 236 | } |
| 251 | } | 237 | } |
| 252 | 238 | ||
| 253 | return Result{ .appended = {} }; | 239 | return Result.ok; |
| 254 | }, | 240 | }, |
| 255 | .empty_array_sentinel => { | 241 | .empty_array_sentinel => { |
| 256 | const elem_ty = typed_value.ty.childType(); | 242 | const elem_ty = typed_value.ty.childType(); |
| ... | @@ -259,13 +245,10 @@ pub fn generateSymbol( | ... | @@ -259,13 +245,10 @@ pub fn generateSymbol( |
| 259 | .ty = elem_ty, | 245 | .ty = elem_ty, |
| 260 | .val = sentinel_val, | 246 | .val = sentinel_val, |
| 261 | }, code, debug_output, reloc_info)) { | 247 | }, code, debug_output, reloc_info)) { |
| 262 | .appended => {}, | 248 | .ok => {}, |
| 263 | .externally_managed => |slice| { | ||
| 264 | code.appendSliceAssumeCapacity(slice); | ||
| 265 | }, | ||
| 266 | .fail => |em| return Result{ .fail = em }, | 249 | .fail => |em| return Result{ .fail = em }, |
| 267 | } | 250 | } |
| 268 | return Result{ .appended = {} }; | 251 | return Result.ok; |
| 269 | }, | 252 | }, |
| 270 | else => return Result{ | 253 | else => return Result{ |
| 271 | .fail = try ErrorMsg.create( | 254 | .fail = try ErrorMsg.create( |
| ... | @@ -289,7 +272,7 @@ pub fn generateSymbol( | ... | @@ -289,7 +272,7 @@ pub fn generateSymbol( |
| 289 | }, | 272 | }, |
| 290 | else => unreachable, | 273 | else => unreachable, |
| 291 | } | 274 | } |
| 292 | return Result{ .appended = {} }; | 275 | return Result.ok; |
| 293 | }, | 276 | }, |
| 294 | .variable => { | 277 | .variable => { |
| 295 | const decl = typed_value.val.castTag(.variable).?.data.owner_decl; | 278 | const decl = typed_value.val.castTag(.variable).?.data.owner_decl; |
| ... | @@ -309,10 +292,7 @@ pub fn generateSymbol( | ... | @@ -309,10 +292,7 @@ pub fn generateSymbol( |
| 309 | .ty = slice_ptr_field_type, | 292 | .ty = slice_ptr_field_type, |
| 310 | .val = slice.ptr, | 293 | .val = slice.ptr, |
| 311 | }, code, debug_output, reloc_info)) { | 294 | }, code, debug_output, reloc_info)) { |
| 312 | .appended => {}, | 295 | .ok => {}, |
| 313 | .externally_managed => |external_slice| { | ||
| 314 | code.appendSliceAssumeCapacity(external_slice); | ||
| 315 | }, | ||
| 316 | .fail => |em| return Result{ .fail = em }, | 296 | .fail => |em| return Result{ .fail = em }, |
| 317 | } | 297 | } |
| 318 | 298 | ||
| ... | @@ -321,14 +301,11 @@ pub fn generateSymbol( | ... | @@ -321,14 +301,11 @@ pub fn generateSymbol( |
| 321 | .ty = Type.initTag(.usize), | 301 | .ty = Type.initTag(.usize), |
| 322 | .val = slice.len, | 302 | .val = slice.len, |
| 323 | }, code, debug_output, reloc_info)) { | 303 | }, code, debug_output, reloc_info)) { |
| 324 | .appended => {}, | 304 | .ok => {}, |
| 325 | .externally_managed => |external_slice| { | ||
| 326 | code.appendSliceAssumeCapacity(external_slice); | ||
| 327 | }, | ||
| 328 | .fail => |em| return Result{ .fail = em }, | 305 | .fail => |em| return Result{ .fail = em }, |
| 329 | } | 306 | } |
| 330 | 307 | ||
| 331 | return Result{ .appended = {} }; | 308 | return Result.ok; |
| 332 | }, | 309 | }, |
| 333 | .field_ptr => { | 310 | .field_ptr => { |
| 334 | const field_ptr = typed_value.val.castTag(.field_ptr).?.data; | 311 | const field_ptr = typed_value.val.castTag(.field_ptr).?.data; |
| ... | @@ -375,13 +352,10 @@ pub fn generateSymbol( | ... | @@ -375,13 +352,10 @@ pub fn generateSymbol( |
| 375 | .ty = typed_value.ty, | 352 | .ty = typed_value.ty, |
| 376 | .val = container_ptr, | 353 | .val = container_ptr, |
| 377 | }, code, debug_output, reloc_info)) { | 354 | }, code, debug_output, reloc_info)) { |
| 378 | .appended => {}, | 355 | .ok => {}, |
| 379 | .externally_managed => |external_slice| { | ||
| 380 | code.appendSliceAssumeCapacity(external_slice); | ||
| 381 | }, | ||
| 382 | .fail => |em| return Result{ .fail = em }, | 356 | .fail => |em| return Result{ .fail = em }, |
| 383 | } | 357 | } |
| 384 | return Result{ .appended = {} }; | 358 | return Result.ok; |
| 385 | }, | 359 | }, |
| 386 | else => return Result{ | 360 | else => return Result{ |
| 387 | .fail = try ErrorMsg.create( | 361 | .fail = try ErrorMsg.create( |
| ... | @@ -434,7 +408,7 @@ pub fn generateSymbol( | ... | @@ -434,7 +408,7 @@ pub fn generateSymbol( |
| 434 | .signed => @bitCast(u8, @intCast(i8, typed_value.val.toSignedInt(target))), | 408 | .signed => @bitCast(u8, @intCast(i8, typed_value.val.toSignedInt(target))), |
| 435 | }; | 409 | }; |
| 436 | try code.append(x); | 410 | try code.append(x); |
| 437 | return Result{ .appended = {} }; | 411 | return Result.ok; |
| 438 | } | 412 | } |
| 439 | if (info.bits > 64) { | 413 | if (info.bits > 64) { |
| 440 | var bigint_buffer: Value.BigIntSpace = undefined; | 414 | var bigint_buffer: Value.BigIntSpace = undefined; |
| ... | @@ -443,7 +417,7 @@ pub fn generateSymbol( | ... | @@ -443,7 +417,7 @@ pub fn generateSymbol( |
| 443 | const start = code.items.len; | 417 | const start = code.items.len; |
| 444 | try code.resize(start + abi_size); | 418 | try code.resize(start + abi_size); |
| 445 | bigint.writeTwosComplement(code.items[start..][0..abi_size], endian); | 419 | bigint.writeTwosComplement(code.items[start..][0..abi_size], endian); |
| 446 | return Result{ .appended = {} }; | 420 | return Result.ok; |
| 447 | } | 421 | } |
| 448 | switch (info.signedness) { | 422 | switch (info.signedness) { |
| 449 | .unsigned => { | 423 | .unsigned => { |
| ... | @@ -471,7 +445,7 @@ pub fn generateSymbol( | ... | @@ -471,7 +445,7 @@ pub fn generateSymbol( |
| 471 | } | 445 | } |
| 472 | }, | 446 | }, |
| 473 | } | 447 | } |
| 474 | return Result{ .appended = {} }; | 448 | return Result.ok; |
| 475 | }, | 449 | }, |
| 476 | .Enum => { | 450 | .Enum => { |
| 477 | var int_buffer: Value.Payload.U64 = undefined; | 451 | var int_buffer: Value.Payload.U64 = undefined; |
| ... | @@ -481,7 +455,7 @@ pub fn generateSymbol( | ... | @@ -481,7 +455,7 @@ pub fn generateSymbol( |
| 481 | if (info.bits <= 8) { | 455 | if (info.bits <= 8) { |
| 482 | const x = @intCast(u8, int_val.toUnsignedInt(target)); | 456 | const x = @intCast(u8, int_val.toUnsignedInt(target)); |
| 483 | try code.append(x); | 457 | try code.append(x); |
| 484 | return Result{ .appended = {} }; | 458 | return Result.ok; |
| 485 | } | 459 | } |
| 486 | if (info.bits > 64) { | 460 | if (info.bits > 64) { |
| 487 | return Result{ | 461 | return Result{ |
| ... | @@ -519,12 +493,12 @@ pub fn generateSymbol( | ... | @@ -519,12 +493,12 @@ pub fn generateSymbol( |
| 519 | } | 493 | } |
| 520 | }, | 494 | }, |
| 521 | } | 495 | } |
| 522 | return Result{ .appended = {} }; | 496 | return Result.ok; |
| 523 | }, | 497 | }, |
| 524 | .Bool => { | 498 | .Bool => { |
| 525 | const x: u8 = @boolToInt(typed_value.val.toBool()); | 499 | const x: u8 = @boolToInt(typed_value.val.toBool()); |
| 526 | try code.append(x); | 500 | try code.append(x); |
| 527 | return Result{ .appended = {} }; | 501 | return Result.ok; |
| 528 | }, | 502 | }, |
| 529 | .Struct => { | 503 | .Struct => { |
| 530 | if (typed_value.ty.containerLayout() == .Packed) { | 504 | if (typed_value.ty.containerLayout() == .Packed) { |
| ... | @@ -549,12 +523,7 @@ pub fn generateSymbol( | ... | @@ -549,12 +523,7 @@ pub fn generateSymbol( |
| 549 | .ty = field_ty, | 523 | .ty = field_ty, |
| 550 | .val = field_val, | 524 | .val = field_val, |
| 551 | }, &tmp_list, debug_output, reloc_info)) { | 525 | }, &tmp_list, debug_output, reloc_info)) { |
| 552 | .appended => { | 526 | .ok => mem.copy(u8, code.items[current_pos..], tmp_list.items), |
| 553 | mem.copy(u8, code.items[current_pos..], tmp_list.items); | ||
| 554 | }, | ||
| 555 | .externally_managed => |external_slice| { | ||
| 556 | mem.copy(u8, code.items[current_pos..], external_slice); | ||
| 557 | }, | ||
| 558 | .fail => |em| return Result{ .fail = em }, | 527 | .fail => |em| return Result{ .fail = em }, |
| 559 | } | 528 | } |
| 560 | } else { | 529 | } else { |
| ... | @@ -563,7 +532,7 @@ pub fn generateSymbol( | ... | @@ -563,7 +532,7 @@ pub fn generateSymbol( |
| 563 | bits += @intCast(u16, field_ty.bitSize(target)); | 532 | bits += @intCast(u16, field_ty.bitSize(target)); |
| 564 | } | 533 | } |
| 565 | 534 | ||
| 566 | return Result{ .appended = {} }; | 535 | return Result.ok; |
| 567 | } | 536 | } |
| 568 | 537 | ||
| 569 | const struct_begin = code.items.len; | 538 | const struct_begin = code.items.len; |
| ... | @@ -576,10 +545,7 @@ pub fn generateSymbol( | ... | @@ -576,10 +545,7 @@ pub fn generateSymbol( |
| 576 | .ty = field_ty, | 545 | .ty = field_ty, |
| 577 | .val = field_val, | 546 | .val = field_val, |
| 578 | }, code, debug_output, reloc_info)) { | 547 | }, code, debug_output, reloc_info)) { |
| 579 | .appended => {}, | 548 | .ok => {}, |
| 580 | .externally_managed => |external_slice| { | ||
| 581 | code.appendSliceAssumeCapacity(external_slice); | ||
| 582 | }, | ||
| 583 | .fail => |em| return Result{ .fail = em }, | 549 | .fail => |em| return Result{ .fail = em }, |
| 584 | } | 550 | } |
| 585 | const unpadded_field_end = code.items.len - struct_begin; | 551 | const unpadded_field_end = code.items.len - struct_begin; |
| ... | @@ -593,7 +559,7 @@ pub fn generateSymbol( | ... | @@ -593,7 +559,7 @@ pub fn generateSymbol( |
| 593 | } | 559 | } |
| 594 | } | 560 | } |
| 595 | 561 | ||
| 596 | return Result{ .appended = {} }; | 562 | return Result.ok; |
| 597 | }, | 563 | }, |
| 598 | .Union => { | 564 | .Union => { |
| 599 | const union_obj = typed_value.val.castTag(.@"union").?.data; | 565 | const union_obj = typed_value.val.castTag(.@"union").?.data; |
| ... | @@ -612,10 +578,7 @@ pub fn generateSymbol( | ... | @@ -612,10 +578,7 @@ pub fn generateSymbol( |
| 612 | .ty = typed_value.ty.unionTagType().?, | 578 | .ty = typed_value.ty.unionTagType().?, |
| 613 | .val = union_obj.tag, | 579 | .val = union_obj.tag, |
| 614 | }, code, debug_output, reloc_info)) { | 580 | }, code, debug_output, reloc_info)) { |
| 615 | .appended => {}, | 581 | .ok => {}, |
| 616 | .externally_managed => |external_slice| { | ||
| 617 | code.appendSliceAssumeCapacity(external_slice); | ||
| 618 | }, | ||
| 619 | .fail => |em| return Result{ .fail = em }, | 582 | .fail => |em| return Result{ .fail = em }, |
| 620 | } | 583 | } |
| 621 | } | 584 | } |
| ... | @@ -632,10 +595,7 @@ pub fn generateSymbol( | ... | @@ -632,10 +595,7 @@ pub fn generateSymbol( |
| 632 | .ty = field_ty, | 595 | .ty = field_ty, |
| 633 | .val = union_obj.val, | 596 | .val = union_obj.val, |
| 634 | }, code, debug_output, reloc_info)) { | 597 | }, code, debug_output, reloc_info)) { |
| 635 | .appended => {}, | 598 | .ok => {}, |
| 636 | .externally_managed => |external_slice| { | ||
| 637 | code.appendSliceAssumeCapacity(external_slice); | ||
| 638 | }, | ||
| 639 | .fail => |em| return Result{ .fail = em }, | 599 | .fail => |em| return Result{ .fail = em }, |
| 640 | } | 600 | } |
| 641 | 601 | ||
| ... | @@ -650,15 +610,12 @@ pub fn generateSymbol( | ... | @@ -650,15 +610,12 @@ pub fn generateSymbol( |
| 650 | .ty = union_ty.tag_ty, | 610 | .ty = union_ty.tag_ty, |
| 651 | .val = union_obj.tag, | 611 | .val = union_obj.tag, |
| 652 | }, code, debug_output, reloc_info)) { | 612 | }, code, debug_output, reloc_info)) { |
| 653 | .appended => {}, | 613 | .ok => {}, |
| 654 | .externally_managed => |external_slice| { | ||
| 655 | code.appendSliceAssumeCapacity(external_slice); | ||
| 656 | }, | ||
| 657 | .fail => |em| return Result{ .fail = em }, | 614 | .fail => |em| return Result{ .fail = em }, |
| 658 | } | 615 | } |
| 659 | } | 616 | } |
| 660 | 617 | ||
| 661 | return Result{ .appended = {} }; | 618 | return Result.ok; |
| 662 | }, | 619 | }, |
| 663 | .Optional => { | 620 | .Optional => { |
| 664 | var opt_buf: Type.Payload.ElemType = undefined; | 621 | var opt_buf: Type.Payload.ElemType = undefined; |
| ... | @@ -669,7 +626,7 @@ pub fn generateSymbol( | ... | @@ -669,7 +626,7 @@ pub fn generateSymbol( |
| 669 | 626 | ||
| 670 | if (!payload_type.hasRuntimeBits()) { | 627 | if (!payload_type.hasRuntimeBits()) { |
| 671 | try code.writer().writeByteNTimes(@boolToInt(is_pl), abi_size); | 628 | try code.writer().writeByteNTimes(@boolToInt(is_pl), abi_size); |
| 672 | return Result{ .appended = {} }; | 629 | return Result.ok; |
| 673 | } | 630 | } |
| 674 | 631 | ||
| 675 | if (typed_value.ty.optionalReprIsPayload()) { | 632 | if (typed_value.ty.optionalReprIsPayload()) { |
| ... | @@ -678,10 +635,7 @@ pub fn generateSymbol( | ... | @@ -678,10 +635,7 @@ pub fn generateSymbol( |
| 678 | .ty = payload_type, | 635 | .ty = payload_type, |
| 679 | .val = payload.data, | 636 | .val = payload.data, |
| 680 | }, code, debug_output, reloc_info)) { | 637 | }, code, debug_output, reloc_info)) { |
| 681 | .appended => {}, | 638 | .ok => {}, |
| 682 | .externally_managed => |external_slice| { | ||
| 683 | code.appendSliceAssumeCapacity(external_slice); | ||
| 684 | }, | ||
| 685 | .fail => |em| return Result{ .fail = em }, | 639 | .fail => |em| return Result{ .fail = em }, |
| 686 | } | 640 | } |
| 687 | } else if (!typed_value.val.isNull()) { | 641 | } else if (!typed_value.val.isNull()) { |
| ... | @@ -689,17 +643,14 @@ pub fn generateSymbol( | ... | @@ -689,17 +643,14 @@ pub fn generateSymbol( |
| 689 | .ty = payload_type, | 643 | .ty = payload_type, |
| 690 | .val = typed_value.val, | 644 | .val = typed_value.val, |
| 691 | }, code, debug_output, reloc_info)) { | 645 | }, code, debug_output, reloc_info)) { |
| 692 | .appended => {}, | 646 | .ok => {}, |
| 693 | .externally_managed => |external_slice| { | ||
| 694 | code.appendSliceAssumeCapacity(external_slice); | ||
| 695 | }, | ||
| 696 | .fail => |em| return Result{ .fail = em }, | 647 | .fail => |em| return Result{ .fail = em }, |
| 697 | } | 648 | } |
| 698 | } else { | 649 | } else { |
| 699 | try code.writer().writeByteNTimes(0, abi_size); | 650 | try code.writer().writeByteNTimes(0, abi_size); |
| 700 | } | 651 | } |
| 701 | 652 | ||
| 702 | return Result{ .appended = {} }; | 653 | return Result.ok; |
| 703 | } | 654 | } |
| 704 | 655 | ||
| 705 | const value = if (typed_value.val.castTag(.opt_payload)) |payload| payload.data else Value.initTag(.undef); | 656 | const value = if (typed_value.val.castTag(.opt_payload)) |payload| payload.data else Value.initTag(.undef); |
| ... | @@ -708,14 +659,11 @@ pub fn generateSymbol( | ... | @@ -708,14 +659,11 @@ pub fn generateSymbol( |
| 708 | .ty = payload_type, | 659 | .ty = payload_type, |
| 709 | .val = value, | 660 | .val = value, |
| 710 | }, code, debug_output, reloc_info)) { | 661 | }, code, debug_output, reloc_info)) { |
| 711 | .appended => {}, | 662 | .ok => {}, |
| 712 | .externally_managed => |external_slice| { | ||
| 713 | code.appendSliceAssumeCapacity(external_slice); | ||
| 714 | }, | ||
| 715 | .fail => |em| return Result{ .fail = em }, | 663 | .fail => |em| return Result{ .fail = em }, |
| 716 | } | 664 | } |
| 717 | 665 | ||
| 718 | return Result{ .appended = {} }; | 666 | return Result.ok; |
| 719 | }, | 667 | }, |
| 720 | .ErrorUnion => { | 668 | .ErrorUnion => { |
| 721 | const error_ty = typed_value.ty.errorUnionSet(); | 669 | const error_ty = typed_value.ty.errorUnionSet(); |
| ... | @@ -740,10 +688,7 @@ pub fn generateSymbol( | ... | @@ -740,10 +688,7 @@ pub fn generateSymbol( |
| 740 | .ty = error_ty, | 688 | .ty = error_ty, |
| 741 | .val = if (is_payload) Value.initTag(.zero) else typed_value.val, | 689 | .val = if (is_payload) Value.initTag(.zero) else typed_value.val, |
| 742 | }, code, debug_output, reloc_info)) { | 690 | }, code, debug_output, reloc_info)) { |
| 743 | .appended => {}, | 691 | .ok => {}, |
| 744 | .externally_managed => |external_slice| { | ||
| 745 | code.appendSliceAssumeCapacity(external_slice); | ||
| 746 | }, | ||
| 747 | .fail => |em| return Result{ .fail = em }, | 692 | .fail => |em| return Result{ .fail = em }, |
| 748 | } | 693 | } |
| 749 | } | 694 | } |
| ... | @@ -756,10 +701,7 @@ pub fn generateSymbol( | ... | @@ -756,10 +701,7 @@ pub fn generateSymbol( |
| 756 | .ty = payload_ty, | 701 | .ty = payload_ty, |
| 757 | .val = payload_val, | 702 | .val = payload_val, |
| 758 | }, code, debug_output, reloc_info)) { | 703 | }, code, debug_output, reloc_info)) { |
| 759 | .appended => {}, | 704 | .ok => {}, |
| 760 | .externally_managed => |external_slice| { | ||
| 761 | code.appendSliceAssumeCapacity(external_slice); | ||
| 762 | }, | ||
| 763 | .fail => |em| return Result{ .fail = em }, | 705 | .fail => |em| return Result{ .fail = em }, |
| 764 | } | 706 | } |
| 765 | const unpadded_end = code.items.len - begin; | 707 | const unpadded_end = code.items.len - begin; |
| ... | @@ -778,10 +720,7 @@ pub fn generateSymbol( | ... | @@ -778,10 +720,7 @@ pub fn generateSymbol( |
| 778 | .ty = error_ty, | 720 | .ty = error_ty, |
| 779 | .val = if (is_payload) Value.initTag(.zero) else typed_value.val, | 721 | .val = if (is_payload) Value.initTag(.zero) else typed_value.val, |
| 780 | }, code, debug_output, reloc_info)) { | 722 | }, code, debug_output, reloc_info)) { |
| 781 | .appended => {}, | 723 | .ok => {}, |
| 782 | .externally_managed => |external_slice| { | ||
| 783 | code.appendSliceAssumeCapacity(external_slice); | ||
| 784 | }, | ||
| 785 | .fail => |em| return Result{ .fail = em }, | 724 | .fail => |em| return Result{ .fail = em }, |
| 786 | } | 725 | } |
| 787 | const unpadded_end = code.items.len - begin; | 726 | const unpadded_end = code.items.len - begin; |
| ... | @@ -793,7 +732,7 @@ pub fn generateSymbol( | ... | @@ -793,7 +732,7 @@ pub fn generateSymbol( |
| 793 | } | 732 | } |
| 794 | } | 733 | } |
| 795 | 734 | ||
| 796 | return Result{ .appended = {} }; | 735 | return Result.ok; |
| 797 | }, | 736 | }, |
| 798 | .ErrorSet => { | 737 | .ErrorSet => { |
| 799 | switch (typed_value.val.tag()) { | 738 | switch (typed_value.val.tag()) { |
| ... | @@ -806,7 +745,7 @@ pub fn generateSymbol( | ... | @@ -806,7 +745,7 @@ pub fn generateSymbol( |
| 806 | try code.writer().writeByteNTimes(0, @intCast(usize, Type.anyerror.abiSize(target))); | 745 | try code.writer().writeByteNTimes(0, @intCast(usize, Type.anyerror.abiSize(target))); |
| 807 | }, | 746 | }, |
| 808 | } | 747 | } |
| 809 | return Result{ .appended = {} }; | 748 | return Result.ok; |
| 810 | }, | 749 | }, |
| 811 | .Vector => switch (typed_value.val.tag()) { | 750 | .Vector => switch (typed_value.val.tag()) { |
| 812 | .bytes => { | 751 | .bytes => { |
| ... | @@ -814,7 +753,7 @@ pub fn generateSymbol( | ... | @@ -814,7 +753,7 @@ pub fn generateSymbol( |
| 814 | const len = @intCast(usize, typed_value.ty.arrayLen()); | 753 | const len = @intCast(usize, typed_value.ty.arrayLen()); |
| 815 | try code.ensureUnusedCapacity(len); | 754 | try code.ensureUnusedCapacity(len); |
| 816 | code.appendSliceAssumeCapacity(bytes[0..len]); | 755 | code.appendSliceAssumeCapacity(bytes[0..len]); |
| 817 | return Result{ .appended = {} }; | 756 | return Result.ok; |
| 818 | }, | 757 | }, |
| 819 | .aggregate => { | 758 | .aggregate => { |
| 820 | const elem_vals = typed_value.val.castTag(.aggregate).?.data; | 759 | const elem_vals = typed_value.val.castTag(.aggregate).?.data; |
| ... | @@ -825,14 +764,11 @@ pub fn generateSymbol( | ... | @@ -825,14 +764,11 @@ pub fn generateSymbol( |
| 825 | .ty = elem_ty, | 764 | .ty = elem_ty, |
| 826 | .val = elem_val, | 765 | .val = elem_val, |
| 827 | }, code, debug_output, reloc_info)) { | 766 | }, code, debug_output, reloc_info)) { |
| 828 | .appended => {}, | 767 | .ok => {}, |
| 829 | .externally_managed => |slice| { | ||
| 830 | code.appendSliceAssumeCapacity(slice); | ||
| 831 | }, | ||
| 832 | .fail => |em| return Result{ .fail = em }, | 768 | .fail => |em| return Result{ .fail = em }, |
| 833 | } | 769 | } |
| 834 | } | 770 | } |
| 835 | return Result{ .appended = {} }; | 771 | return Result.ok; |
| 836 | }, | 772 | }, |
| 837 | .repeated => { | 773 | .repeated => { |
| 838 | const array = typed_value.val.castTag(.repeated).?.data; | 774 | const array = typed_value.val.castTag(.repeated).?.data; |
| ... | @@ -845,14 +781,11 @@ pub fn generateSymbol( | ... | @@ -845,14 +781,11 @@ pub fn generateSymbol( |
| 845 | .ty = elem_ty, | 781 | .ty = elem_ty, |
| 846 | .val = array, | 782 | .val = array, |
| 847 | }, code, debug_output, reloc_info)) { | 783 | }, code, debug_output, reloc_info)) { |
| 848 | .appended => {}, | 784 | .ok => {}, |
| 849 | .externally_managed => |slice| { | ||
| 850 | code.appendSliceAssumeCapacity(slice); | ||
| 851 | }, | ||
| 852 | .fail => |em| return Result{ .fail = em }, | 785 | .fail => |em| return Result{ .fail = em }, |
| 853 | } | 786 | } |
| 854 | } | 787 | } |
| 855 | return Result{ .appended = {} }; | 788 | return Result.ok; |
| 856 | }, | 789 | }, |
| 857 | .str_lit => { | 790 | .str_lit => { |
| 858 | const str_lit = typed_value.val.castTag(.str_lit).?.data; | 791 | const str_lit = typed_value.val.castTag(.str_lit).?.data; |
| ... | @@ -860,7 +793,7 @@ pub fn generateSymbol( | ... | @@ -860,7 +793,7 @@ pub fn generateSymbol( |
| 860 | const bytes = mod.string_literal_bytes.items[str_lit.index..][0..str_lit.len]; | 793 | const bytes = mod.string_literal_bytes.items[str_lit.index..][0..str_lit.len]; |
| 861 | try code.ensureUnusedCapacity(str_lit.len); | 794 | try code.ensureUnusedCapacity(str_lit.len); |
| 862 | code.appendSliceAssumeCapacity(bytes); | 795 | code.appendSliceAssumeCapacity(bytes); |
| 863 | return Result{ .appended = {} }; | 796 | return Result.ok; |
| 864 | }, | 797 | }, |
| 865 | else => unreachable, | 798 | else => unreachable, |
| 866 | }, | 799 | }, |
| ... | @@ -901,10 +834,7 @@ fn lowerDeclRef( | ... | @@ -901,10 +834,7 @@ fn lowerDeclRef( |
| 901 | .ty = slice_ptr_field_type, | 834 | .ty = slice_ptr_field_type, |
| 902 | .val = typed_value.val, | 835 | .val = typed_value.val, |
| 903 | }, code, debug_output, reloc_info)) { | 836 | }, code, debug_output, reloc_info)) { |
| 904 | .appended => {}, | 837 | .ok => {}, |
| 905 | .externally_managed => |external_slice| { | ||
| 906 | code.appendSliceAssumeCapacity(external_slice); | ||
| 907 | }, | ||
| 908 | .fail => |em| return Result{ .fail = em }, | 838 | .fail => |em| return Result{ .fail = em }, |
| 909 | } | 839 | } |
| 910 | 840 | ||
| ... | @@ -917,14 +847,11 @@ fn lowerDeclRef( | ... | @@ -917,14 +847,11 @@ fn lowerDeclRef( |
| 917 | .ty = Type.usize, | 847 | .ty = Type.usize, |
| 918 | .val = Value.initPayload(&slice_len.base), | 848 | .val = Value.initPayload(&slice_len.base), |
| 919 | }, code, debug_output, reloc_info)) { | 849 | }, code, debug_output, reloc_info)) { |
| 920 | .appended => {}, | 850 | .ok => {}, |
| 921 | .externally_managed => |external_slice| { | ||
| 922 | code.appendSliceAssumeCapacity(external_slice); | ||
| 923 | }, | ||
| 924 | .fail => |em| return Result{ .fail = em }, | 851 | .fail => |em| return Result{ .fail = em }, |
| 925 | } | 852 | } |
| 926 | 853 | ||
| 927 | return Result{ .appended = {} }; | 854 | return Result.ok; |
| 928 | } | 855 | } |
| 929 | 856 | ||
| 930 | const ptr_width = target.cpu.arch.ptrBitWidth(); | 857 | const ptr_width = target.cpu.arch.ptrBitWidth(); |
| ... | @@ -932,7 +859,7 @@ fn lowerDeclRef( | ... | @@ -932,7 +859,7 @@ fn lowerDeclRef( |
| 932 | const is_fn_body = decl.ty.zigTypeTag() == .Fn; | 859 | const is_fn_body = decl.ty.zigTypeTag() == .Fn; |
| 933 | if (!is_fn_body and !decl.ty.hasRuntimeBits()) { | 860 | if (!is_fn_body and !decl.ty.hasRuntimeBits()) { |
| 934 | try code.writer().writeByteNTimes(0xaa, @divExact(ptr_width, 8)); | 861 | try code.writer().writeByteNTimes(0xaa, @divExact(ptr_width, 8)); |
| 935 | return Result{ .appended = {} }; | 862 | return Result.ok; |
| 936 | } | 863 | } |
| 937 | 864 | ||
| 938 | module.markDeclAlive(decl); | 865 | module.markDeclAlive(decl); |
| ... | @@ -950,7 +877,7 @@ fn lowerDeclRef( | ... | @@ -950,7 +877,7 @@ fn lowerDeclRef( |
| 950 | else => unreachable, | 877 | else => unreachable, |
| 951 | } | 878 | } |
| 952 | 879 | ||
| 953 | return Result{ .appended = {} }; | 880 | return Result.ok; |
| 954 | } | 881 | } |
| 955 | 882 | ||
| 956 | pub fn errUnionPayloadOffset(payload_ty: Type, target: std.Target) u64 { | 883 | pub fn errUnionPayloadOffset(payload_ty: Type, target: std.Target) u64 { |
src/link/Coff.zig+3-5| ... | @@ -928,7 +928,7 @@ pub fn updateFunc(self: *Coff, module: *Module, func: *Module.Fn, air: Air, live | ... | @@ -928,7 +928,7 @@ pub fn updateFunc(self: *Coff, module: *Module, func: *Module.Fn, air: Air, live |
| 928 | .none, | 928 | .none, |
| 929 | ); | 929 | ); |
| 930 | const code = switch (res) { | 930 | const code = switch (res) { |
| 931 | .appended => code_buffer.items, | 931 | .ok => code_buffer.items, |
| 932 | .fail => |em| { | 932 | .fail => |em| { |
| 933 | decl.analysis = .codegen_failure; | 933 | decl.analysis = .codegen_failure; |
| 934 | try module.failed_decls.put(module.gpa, decl_index, em); | 934 | try module.failed_decls.put(module.gpa, decl_index, em); |
| ... | @@ -981,8 +981,7 @@ pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.In | ... | @@ -981,8 +981,7 @@ pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.In |
| 981 | .parent_atom_index = atom.sym_index, | 981 | .parent_atom_index = atom.sym_index, |
| 982 | }); | 982 | }); |
| 983 | const code = switch (res) { | 983 | const code = switch (res) { |
| 984 | .externally_managed => |x| x, | 984 | .ok => code_buffer.items, |
| 985 | .appended => code_buffer.items, | ||
| 986 | .fail => |em| { | 985 | .fail => |em| { |
| 987 | decl.analysis = .codegen_failure; | 986 | decl.analysis = .codegen_failure; |
| 988 | try mod.failed_decls.put(mod.gpa, decl_index, em); | 987 | try mod.failed_decls.put(mod.gpa, decl_index, em); |
| ... | @@ -1042,8 +1041,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl_index: Module.Decl.Index) ! | ... | @@ -1042,8 +1041,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl_index: Module.Decl.Index) ! |
| 1042 | .parent_atom_index = decl.link.coff.sym_index, | 1041 | .parent_atom_index = decl.link.coff.sym_index, |
| 1043 | }); | 1042 | }); |
| 1044 | const code = switch (res) { | 1043 | const code = switch (res) { |
| 1045 | .externally_managed => |x| x, | 1044 | .ok => code_buffer.items, |
| 1046 | .appended => code_buffer.items, | ||
| 1047 | .fail => |em| { | 1045 | .fail => |em| { |
| 1048 | decl.analysis = .codegen_failure; | 1046 | decl.analysis = .codegen_failure; |
| 1049 | try module.failed_decls.put(module.gpa, decl_index, em); | 1047 | try module.failed_decls.put(module.gpa, decl_index, em); |
src/link/Elf.zig+3-5| ... | @@ -2479,7 +2479,7 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven | ... | @@ -2479,7 +2479,7 @@ pub fn updateFunc(self: *Elf, module: *Module, func: *Module.Fn, air: Air, liven |
| 2479 | try codegen.generateFunction(&self.base, decl.srcLoc(), func, air, liveness, &code_buffer, .none); | 2479 | try codegen.generateFunction(&self.base, decl.srcLoc(), func, air, liveness, &code_buffer, .none); |
| 2480 | 2480 | ||
| 2481 | const code = switch (res) { | 2481 | const code = switch (res) { |
| 2482 | .appended => code_buffer.items, | 2482 | .ok => code_buffer.items, |
| 2483 | .fail => |em| { | 2483 | .fail => |em| { |
| 2484 | decl.analysis = .codegen_failure; | 2484 | decl.analysis = .codegen_failure; |
| 2485 | try module.failed_decls.put(module.gpa, decl_index, em); | 2485 | try module.failed_decls.put(module.gpa, decl_index, em); |
| ... | @@ -2553,8 +2553,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl_index: Module.Decl.Index) !v | ... | @@ -2553,8 +2553,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl_index: Module.Decl.Index) !v |
| 2553 | }); | 2553 | }); |
| 2554 | 2554 | ||
| 2555 | const code = switch (res) { | 2555 | const code = switch (res) { |
| 2556 | .externally_managed => |x| x, | 2556 | .ok => code_buffer.items, |
| 2557 | .appended => code_buffer.items, | ||
| 2558 | .fail => |em| { | 2557 | .fail => |em| { |
| 2559 | decl.analysis = .codegen_failure; | 2558 | decl.analysis = .codegen_failure; |
| 2560 | try module.failed_decls.put(module.gpa, decl_index, em); | 2559 | try module.failed_decls.put(module.gpa, decl_index, em); |
| ... | @@ -2618,8 +2617,7 @@ pub fn lowerUnnamedConst(self: *Elf, typed_value: TypedValue, decl_index: Module | ... | @@ -2618,8 +2617,7 @@ pub fn lowerUnnamedConst(self: *Elf, typed_value: TypedValue, decl_index: Module |
| 2618 | .parent_atom_index = atom.local_sym_index, | 2617 | .parent_atom_index = atom.local_sym_index, |
| 2619 | }); | 2618 | }); |
| 2620 | const code = switch (res) { | 2619 | const code = switch (res) { |
| 2621 | .externally_managed => |x| x, | 2620 | .ok => code_buffer.items, |
| 2622 | .appended => code_buffer.items, | ||
| 2623 | .fail => |em| { | 2621 | .fail => |em| { |
| 2624 | decl.analysis = .codegen_failure; | 2622 | decl.analysis = .codegen_failure; |
| 2625 | try mod.failed_decls.put(mod.gpa, decl_index, em); | 2623 | try mod.failed_decls.put(mod.gpa, decl_index, em); |
src/link/MachO.zig+3-5| ... | @@ -2017,7 +2017,7 @@ pub fn updateFunc(self: *MachO, module: *Module, func: *Module.Fn, air: Air, liv | ... | @@ -2017,7 +2017,7 @@ pub fn updateFunc(self: *MachO, module: *Module, func: *Module.Fn, air: Air, liv |
| 2017 | try codegen.generateFunction(&self.base, decl.srcLoc(), func, air, liveness, &code_buffer, .none); | 2017 | try codegen.generateFunction(&self.base, decl.srcLoc(), func, air, liveness, &code_buffer, .none); |
| 2018 | 2018 | ||
| 2019 | const code = switch (res) { | 2019 | const code = switch (res) { |
| 2020 | .appended => code_buffer.items, | 2020 | .ok => code_buffer.items, |
| 2021 | .fail => |em| { | 2021 | .fail => |em| { |
| 2022 | decl.analysis = .codegen_failure; | 2022 | decl.analysis = .codegen_failure; |
| 2023 | try module.failed_decls.put(module.gpa, decl_index, em); | 2023 | try module.failed_decls.put(module.gpa, decl_index, em); |
| ... | @@ -2082,8 +2082,7 @@ pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Modu | ... | @@ -2082,8 +2082,7 @@ pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Modu |
| 2082 | .parent_atom_index = atom.sym_index, | 2082 | .parent_atom_index = atom.sym_index, |
| 2083 | }); | 2083 | }); |
| 2084 | const code = switch (res) { | 2084 | const code = switch (res) { |
| 2085 | .externally_managed => |x| x, | 2085 | .ok => code_buffer.items, |
| 2086 | .appended => code_buffer.items, | ||
| 2087 | .fail => |em| { | 2086 | .fail => |em| { |
| 2088 | decl.analysis = .codegen_failure; | 2087 | decl.analysis = .codegen_failure; |
| 2089 | try module.failed_decls.put(module.gpa, decl_index, em); | 2088 | try module.failed_decls.put(module.gpa, decl_index, em); |
| ... | @@ -2167,8 +2166,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl_index: Module.Decl.Index) | ... | @@ -2167,8 +2166,7 @@ pub fn updateDecl(self: *MachO, module: *Module, decl_index: Module.Decl.Index) |
| 2167 | }); | 2166 | }); |
| 2168 | 2167 | ||
| 2169 | const code = switch (res) { | 2168 | const code = switch (res) { |
| 2170 | .externally_managed => |x| x, | 2169 | .ok => code_buffer.items, |
| 2171 | .appended => code_buffer.items, | ||
| 2172 | .fail => |em| { | 2170 | .fail => |em| { |
| 2173 | decl.analysis = .codegen_failure; | 2171 | decl.analysis = .codegen_failure; |
| 2174 | try module.failed_decls.put(module.gpa, decl_index, em); | 2172 | try module.failed_decls.put(module.gpa, decl_index, em); |
src/link/Plan9.zig+3-5| ... | @@ -299,7 +299,7 @@ pub fn updateFunc(self: *Plan9, module: *Module, func: *Module.Fn, air: Air, liv | ... | @@ -299,7 +299,7 @@ pub fn updateFunc(self: *Plan9, module: *Module, func: *Module.Fn, air: Air, liv |
| 299 | }, | 299 | }, |
| 300 | ); | 300 | ); |
| 301 | const code = switch (res) { | 301 | const code = switch (res) { |
| 302 | .appended => try code_buffer.toOwnedSlice(), | 302 | .ok => try code_buffer.toOwnedSlice(), |
| 303 | .fail => |em| { | 303 | .fail => |em| { |
| 304 | decl.analysis = .codegen_failure; | 304 | decl.analysis = .codegen_failure; |
| 305 | try module.failed_decls.put(module.gpa, decl_index, em); | 305 | try module.failed_decls.put(module.gpa, decl_index, em); |
| ... | @@ -358,8 +358,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I | ... | @@ -358,8 +358,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I |
| 358 | .parent_atom_index = @enumToInt(decl_index), | 358 | .parent_atom_index = @enumToInt(decl_index), |
| 359 | }); | 359 | }); |
| 360 | const code = switch (res) { | 360 | const code = switch (res) { |
| 361 | .externally_managed => |x| x, | 361 | .ok => code_buffer.items, |
| 362 | .appended => code_buffer.items, | ||
| 363 | .fail => |em| { | 362 | .fail => |em| { |
| 364 | decl.analysis = .codegen_failure; | 363 | decl.analysis = .codegen_failure; |
| 365 | try mod.failed_decls.put(mod.gpa, decl_index, em); | 364 | try mod.failed_decls.put(mod.gpa, decl_index, em); |
| ... | @@ -403,8 +402,7 @@ pub fn updateDecl(self: *Plan9, module: *Module, decl_index: Module.Decl.Index) | ... | @@ -403,8 +402,7 @@ pub fn updateDecl(self: *Plan9, module: *Module, decl_index: Module.Decl.Index) |
| 403 | .parent_atom_index = @enumToInt(decl_index), | 402 | .parent_atom_index = @enumToInt(decl_index), |
| 404 | }); | 403 | }); |
| 405 | const code = switch (res) { | 404 | const code = switch (res) { |
| 406 | .externally_managed => |x| x, | 405 | .ok => code_buffer.items, |
| 407 | .appended => code_buffer.items, | ||
| 408 | .fail => |em| { | 406 | .fail => |em| { |
| 409 | decl.analysis = .codegen_failure; | 407 | decl.analysis = .codegen_failure; |
| 410 | try module.failed_decls.put(module.gpa, decl_index, em); | 408 | try module.failed_decls.put(module.gpa, decl_index, em); |
src/link/Wasm.zig+3-5| ... | @@ -1046,7 +1046,7 @@ pub fn updateFunc(wasm: *Wasm, mod: *Module, func: *Module.Fn, air: Air, livenes | ... | @@ -1046,7 +1046,7 @@ pub fn updateFunc(wasm: *Wasm, mod: *Module, func: *Module.Fn, air: Air, livenes |
| 1046 | ); | 1046 | ); |
| 1047 | 1047 | ||
| 1048 | const code = switch (result) { | 1048 | const code = switch (result) { |
| 1049 | .appended => code_writer.items, | 1049 | .ok => code_writer.items, |
| 1050 | .fail => |em| { | 1050 | .fail => |em| { |
| 1051 | decl.analysis = .codegen_failure; | 1051 | decl.analysis = .codegen_failure; |
| 1052 | try mod.failed_decls.put(mod.gpa, decl_index, em); | 1052 | try mod.failed_decls.put(mod.gpa, decl_index, em); |
| ... | @@ -1113,8 +1113,7 @@ pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !voi | ... | @@ -1113,8 +1113,7 @@ pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !voi |
| 1113 | ); | 1113 | ); |
| 1114 | 1114 | ||
| 1115 | const code = switch (res) { | 1115 | const code = switch (res) { |
| 1116 | .externally_managed => |x| x, | 1116 | .ok => code_writer.items, |
| 1117 | .appended => code_writer.items, | ||
| 1118 | .fail => |em| { | 1117 | .fail => |em| { |
| 1119 | decl.analysis = .codegen_failure; | 1118 | decl.analysis = .codegen_failure; |
| 1120 | try mod.failed_decls.put(mod.gpa, decl_index, em); | 1119 | try mod.failed_decls.put(mod.gpa, decl_index, em); |
| ... | @@ -1250,8 +1249,7 @@ pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.In | ... | @@ -1250,8 +1249,7 @@ pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.In |
| 1250 | }, | 1249 | }, |
| 1251 | ); | 1250 | ); |
| 1252 | const code = switch (result) { | 1251 | const code = switch (result) { |
| 1253 | .externally_managed => |x| x, | 1252 | .ok => value_bytes.items, |
| 1254 | .appended => value_bytes.items, | ||
| 1255 | .fail => |em| { | 1253 | .fail => |em| { |
| 1256 | decl.analysis = .codegen_failure; | 1254 | decl.analysis = .codegen_failure; |
| 1257 | try mod.failed_decls.put(mod.gpa, decl_index, em); | 1255 | try mod.failed_decls.put(mod.gpa, decl_index, em); |