| ... | ... | @@ -23,6 +23,11 @@ const RegisterManager = @import("register_manager.zig").RegisterManager; |
| 23 | 23 | |
| 24 | 24 | const X8664Encoder = @import("codegen/x86_64.zig").Encoder; |
| 25 | 25 | |
| 26 | pub const FnResult = union(enum) { |
| 27 | /// The `code` parameter passed to `generateSymbol` has the value appended. |
| 28 | appended: void, |
| 29 | fail: *ErrorMsg, |
| 30 | }; |
| 26 | 31 | pub const Result = union(enum) { |
| 27 | 32 | /// The `code` parameter passed to `generateSymbol` has the value appended. |
| 28 | 33 | appended: void, |
| ... | ... | @@ -54,7 +59,7 @@ pub fn generateFunction( |
| 54 | 59 | liveness: Liveness, |
| 55 | 60 | code: *std.ArrayList(u8), |
| 56 | 61 | debug_output: DebugInfoOutput, |
| 57 | | ) GenerateSymbolError!Result { |
| 62 | ) GenerateSymbolError!FnResult { |
| 58 | 63 | switch (bin_file.options.target.cpu.arch) { |
| 59 | 64 | .wasm32 => unreachable, // has its own code path |
| 60 | 65 | .wasm64 => unreachable, // has its own code path |
| ... | ... | @@ -451,7 +456,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 451 | 456 | liveness: Liveness, |
| 452 | 457 | code: *std.ArrayList(u8), |
| 453 | 458 | debug_output: DebugInfoOutput, |
| 454 | | ) GenerateSymbolError!Result { |
| 459 | ) GenerateSymbolError!FnResult { |
| 455 | 460 | if (build_options.skip_non_native and std.Target.current.cpu.arch != arch) { |
| 456 | 461 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 457 | 462 | } |
| ... | ... | @@ -495,7 +500,7 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 495 | 500 | defer function.exitlude_jump_relocs.deinit(bin_file.allocator); |
| 496 | 501 | |
| 497 | 502 | var call_info = function.resolveCallingConventionValues(fn_type) catch |err| switch (err) { |
| 498 | | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 503 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, |
| 499 | 504 | else => |e| return e, |
| 500 | 505 | }; |
| 501 | 506 | defer call_info.deinit(&function); |
| ... | ... | @@ -506,14 +511,14 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type { |
| 506 | 511 | function.max_end_stack = call_info.stack_byte_count; |
| 507 | 512 | |
| 508 | 513 | function.gen() catch |err| switch (err) { |
| 509 | | error.CodegenFail => return Result{ .fail = function.err_msg.? }, |
| 514 | error.CodegenFail => return FnResult{ .fail = function.err_msg.? }, |
| 510 | 515 | else => |e| return e, |
| 511 | 516 | }; |
| 512 | 517 | |
| 513 | 518 | if (function.err_msg) |em| { |
| 514 | | return Result{ .fail = em }; |
| 519 | return FnResult{ .fail = em }; |
| 515 | 520 | } else { |
| 516 | | return Result{ .appended = {} }; |
| 521 | return FnResult{ .appended = {} }; |
| 517 | 522 | } |
| 518 | 523 | } |
| 519 | 524 | |