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