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