| author | |
| committer | |
| log | e0469773542e49c9a76df6746afa10f22d44dae4 |
| tree | 439c5f47cef779ece68ab57c812975241715620a |
| parent | 6459212ebe20da1607ea3b56bff37b7ace019343 |
20 files changed, 339 insertions(+), 248 deletions(-)
src/arch/aarch64/CodeGen.zig+2-3| ... | @@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment; | ... | @@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment; |
| 25 | 25 | ||
| 26 | const CodeGenError = codegen.CodeGenError; | 26 | const CodeGenError = codegen.CodeGenError; |
| 27 | const Result = codegen.Result; | 27 | const Result = codegen.Result; |
| 28 | const DebugInfoOutput = codegen.DebugInfoOutput; | ||
| 29 | 28 | ||
| 30 | const bits = @import("bits.zig"); | 29 | const bits = @import("bits.zig"); |
| 31 | const abi = @import("abi.zig"); | 30 | const abi = @import("abi.zig"); |
| ... | @@ -48,7 +47,7 @@ pt: Zcu.PerThread, | ... | @@ -48,7 +47,7 @@ pt: Zcu.PerThread, |
| 48 | air: Air, | 47 | air: Air, |
| 49 | liveness: Liveness, | 48 | liveness: Liveness, |
| 50 | bin_file: *link.File, | 49 | bin_file: *link.File, |
| 51 | debug_output: DebugInfoOutput, | 50 | debug_output: link.File.DebugInfoOutput, |
| 52 | target: *const std.Target, | 51 | target: *const std.Target, |
| 53 | func_index: InternPool.Index, | 52 | func_index: InternPool.Index, |
| 54 | owner_nav: InternPool.Nav.Index, | 53 | owner_nav: InternPool.Nav.Index, |
| ... | @@ -327,7 +326,7 @@ pub fn generate( | ... | @@ -327,7 +326,7 @@ pub fn generate( |
| 327 | air: Air, | 326 | air: Air, |
| 328 | liveness: Liveness, | 327 | liveness: Liveness, |
| 329 | code: *std.ArrayList(u8), | 328 | code: *std.ArrayList(u8), |
| 330 | debug_output: DebugInfoOutput, | 329 | debug_output: link.File.DebugInfoOutput, |
| 331 | ) CodeGenError!Result { | 330 | ) CodeGenError!Result { |
| 332 | const zcu = pt.zcu; | 331 | const zcu = pt.zcu; |
| 333 | const gpa = zcu.gpa; | 332 | const gpa = zcu.gpa; |
src/arch/aarch64/Emit.zig+1-2| ... | @@ -13,11 +13,10 @@ const assert = std.debug.assert; | ... | @@ -13,11 +13,10 @@ const assert = std.debug.assert; |
| 13 | const Instruction = bits.Instruction; | 13 | const Instruction = bits.Instruction; |
| 14 | const Register = bits.Register; | 14 | const Register = bits.Register; |
| 15 | const log = std.log.scoped(.aarch64_emit); | 15 | const log = std.log.scoped(.aarch64_emit); |
| 16 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | ||
| 17 | 16 | ||
| 18 | mir: Mir, | 17 | mir: Mir, |
| 19 | bin_file: *link.File, | 18 | bin_file: *link.File, |
| 20 | debug_output: DebugInfoOutput, | 19 | debug_output: link.File.DebugInfoOutput, |
| 21 | target: *const std.Target, | 20 | target: *const std.Target, |
| 22 | err_msg: ?*ErrorMsg = null, | 21 | err_msg: ?*ErrorMsg = null, |
| 23 | src_loc: Zcu.LazySrcLoc, | 22 | src_loc: Zcu.LazySrcLoc, |
src/arch/arm/CodeGen.zig+2-3| ... | @@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment; | ... | @@ -25,7 +25,6 @@ const Alignment = InternPool.Alignment; |
| 25 | 25 | ||
| 26 | const Result = codegen.Result; | 26 | const Result = codegen.Result; |
| 27 | const CodeGenError = codegen.CodeGenError; | 27 | const CodeGenError = codegen.CodeGenError; |
| 28 | const DebugInfoOutput = codegen.DebugInfoOutput; | ||
| 29 | 28 | ||
| 30 | const bits = @import("bits.zig"); | 29 | const bits = @import("bits.zig"); |
| 31 | const abi = @import("abi.zig"); | 30 | const abi = @import("abi.zig"); |
| ... | @@ -49,7 +48,7 @@ pt: Zcu.PerThread, | ... | @@ -49,7 +48,7 @@ pt: Zcu.PerThread, |
| 49 | air: Air, | 48 | air: Air, |
| 50 | liveness: Liveness, | 49 | liveness: Liveness, |
| 51 | bin_file: *link.File, | 50 | bin_file: *link.File, |
| 52 | debug_output: DebugInfoOutput, | 51 | debug_output: link.File.DebugInfoOutput, |
| 53 | target: *const std.Target, | 52 | target: *const std.Target, |
| 54 | func_index: InternPool.Index, | 53 | func_index: InternPool.Index, |
| 55 | err_msg: ?*ErrorMsg, | 54 | err_msg: ?*ErrorMsg, |
| ... | @@ -335,7 +334,7 @@ pub fn generate( | ... | @@ -335,7 +334,7 @@ pub fn generate( |
| 335 | air: Air, | 334 | air: Air, |
| 336 | liveness: Liveness, | 335 | liveness: Liveness, |
| 337 | code: *std.ArrayList(u8), | 336 | code: *std.ArrayList(u8), |
| 338 | debug_output: DebugInfoOutput, | 337 | debug_output: link.File.DebugInfoOutput, |
| 339 | ) CodeGenError!Result { | 338 | ) CodeGenError!Result { |
| 340 | const zcu = pt.zcu; | 339 | const zcu = pt.zcu; |
| 341 | const gpa = zcu.gpa; | 340 | const gpa = zcu.gpa; |
src/arch/arm/Emit.zig+1-2| ... | @@ -16,12 +16,11 @@ const assert = std.debug.assert; | ... | @@ -16,12 +16,11 @@ const assert = std.debug.assert; |
| 16 | const Instruction = bits.Instruction; | 16 | const Instruction = bits.Instruction; |
| 17 | const Register = bits.Register; | 17 | const Register = bits.Register; |
| 18 | const log = std.log.scoped(.aarch32_emit); | 18 | const log = std.log.scoped(.aarch32_emit); |
| 19 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | ||
| 20 | const CodeGen = @import("CodeGen.zig"); | 19 | const CodeGen = @import("CodeGen.zig"); |
| 21 | 20 | ||
| 22 | mir: Mir, | 21 | mir: Mir, |
| 23 | bin_file: *link.File, | 22 | bin_file: *link.File, |
| 24 | debug_output: DebugInfoOutput, | 23 | debug_output: link.File.DebugInfoOutput, |
| 25 | target: *const std.Target, | 24 | target: *const std.Target, |
| 26 | err_msg: ?*ErrorMsg = null, | 25 | err_msg: ?*ErrorMsg = null, |
| 27 | src_loc: Zcu.LazySrcLoc, | 26 | src_loc: Zcu.LazySrcLoc, |
src/arch/riscv64/CodeGen.zig+3-4| ... | @@ -32,7 +32,6 @@ const Alignment = InternPool.Alignment; | ... | @@ -32,7 +32,6 @@ const Alignment = InternPool.Alignment; |
| 32 | 32 | ||
| 33 | const CodeGenError = codegen.CodeGenError; | 33 | const CodeGenError = codegen.CodeGenError; |
| 34 | const Result = codegen.Result; | 34 | const Result = codegen.Result; |
| 35 | const DebugInfoOutput = codegen.DebugInfoOutput; | ||
| 36 | 35 | ||
| 37 | const bits = @import("bits.zig"); | 36 | const bits = @import("bits.zig"); |
| 38 | const abi = @import("abi.zig"); | 37 | const abi = @import("abi.zig"); |
| ... | @@ -61,7 +60,7 @@ gpa: Allocator, | ... | @@ -61,7 +60,7 @@ gpa: Allocator, |
| 61 | 60 | ||
| 62 | mod: *Package.Module, | 61 | mod: *Package.Module, |
| 63 | target: *const std.Target, | 62 | target: *const std.Target, |
| 64 | debug_output: DebugInfoOutput, | 63 | debug_output: link.File.DebugInfoOutput, |
| 65 | err_msg: ?*ErrorMsg, | 64 | err_msg: ?*ErrorMsg, |
| 66 | args: []MCValue, | 65 | args: []MCValue, |
| 67 | ret_mcv: InstTracking, | 66 | ret_mcv: InstTracking, |
| ... | @@ -760,7 +759,7 @@ pub fn generate( | ... | @@ -760,7 +759,7 @@ pub fn generate( |
| 760 | air: Air, | 759 | air: Air, |
| 761 | liveness: Liveness, | 760 | liveness: Liveness, |
| 762 | code: *std.ArrayList(u8), | 761 | code: *std.ArrayList(u8), |
| 763 | debug_output: DebugInfoOutput, | 762 | debug_output: link.File.DebugInfoOutput, |
| 764 | ) CodeGenError!Result { | 763 | ) CodeGenError!Result { |
| 765 | const zcu = pt.zcu; | 764 | const zcu = pt.zcu; |
| 766 | const comp = zcu.comp; | 765 | const comp = zcu.comp; |
| ... | @@ -928,7 +927,7 @@ pub fn generateLazy( | ... | @@ -928,7 +927,7 @@ pub fn generateLazy( |
| 928 | src_loc: Zcu.LazySrcLoc, | 927 | src_loc: Zcu.LazySrcLoc, |
| 929 | lazy_sym: link.File.LazySymbol, | 928 | lazy_sym: link.File.LazySymbol, |
| 930 | code: *std.ArrayList(u8), | 929 | code: *std.ArrayList(u8), |
| 931 | debug_output: DebugInfoOutput, | 930 | debug_output: link.File.DebugInfoOutput, |
| 932 | ) CodeGenError!Result { | 931 | ) CodeGenError!Result { |
| 933 | const comp = bin_file.comp; | 932 | const comp = bin_file.comp; |
| 934 | const gpa = comp.gpa; | 933 | const gpa = comp.gpa; |
src/arch/riscv64/Emit.zig+1-2| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | ||
| 3 | bin_file: *link.File, | 3 | bin_file: *link.File, |
| 4 | lower: Lower, | 4 | lower: Lower, |
| 5 | debug_output: DebugInfoOutput, | 5 | debug_output: link.File.DebugInfoOutput, |
| 6 | code: *std.ArrayList(u8), | 6 | code: *std.ArrayList(u8), |
| 7 | 7 | ||
| 8 | prev_di_line: u32, | 8 | prev_di_line: u32, |
| ... | @@ -216,7 +216,6 @@ const log = std.log.scoped(.emit); | ... | @@ -216,7 +216,6 @@ const log = std.log.scoped(.emit); |
| 216 | const mem = std.mem; | 216 | const mem = std.mem; |
| 217 | const std = @import("std"); | 217 | const std = @import("std"); |
| 218 | 218 | ||
| 219 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | ||
| 220 | const Emit = @This(); | 219 | const Emit = @This(); |
| 221 | const Lower = @import("Lower.zig"); | 220 | const Lower = @import("Lower.zig"); |
| 222 | const Mir = @import("Mir.zig"); | 221 | const Mir = @import("Mir.zig"); |
src/arch/sparc64/CodeGen.zig+2-3| ... | @@ -22,7 +22,6 @@ const Liveness = @import("../../Liveness.zig"); | ... | @@ -22,7 +22,6 @@ const Liveness = @import("../../Liveness.zig"); |
| 22 | const Type = @import("../../Type.zig"); | 22 | const Type = @import("../../Type.zig"); |
| 23 | const CodeGenError = codegen.CodeGenError; | 23 | const CodeGenError = codegen.CodeGenError; |
| 24 | const Result = @import("../../codegen.zig").Result; | 24 | const Result = @import("../../codegen.zig").Result; |
| 25 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | ||
| 26 | const Endian = std.builtin.Endian; | 25 | const Endian = std.builtin.Endian; |
| 27 | const Alignment = InternPool.Alignment; | 26 | const Alignment = InternPool.Alignment; |
| 28 | 27 | ||
| ... | @@ -57,7 +56,7 @@ bin_file: *link.File, | ... | @@ -57,7 +56,7 @@ bin_file: *link.File, |
| 57 | target: *const std.Target, | 56 | target: *const std.Target, |
| 58 | func_index: InternPool.Index, | 57 | func_index: InternPool.Index, |
| 59 | code: *std.ArrayList(u8), | 58 | code: *std.ArrayList(u8), |
| 60 | debug_output: DebugInfoOutput, | 59 | debug_output: link.File.DebugInfoOutput, |
| 61 | err_msg: ?*ErrorMsg, | 60 | err_msg: ?*ErrorMsg, |
| 62 | args: []MCValue, | 61 | args: []MCValue, |
| 63 | ret_mcv: MCValue, | 62 | ret_mcv: MCValue, |
| ... | @@ -268,7 +267,7 @@ pub fn generate( | ... | @@ -268,7 +267,7 @@ pub fn generate( |
| 268 | air: Air, | 267 | air: Air, |
| 269 | liveness: Liveness, | 268 | liveness: Liveness, |
| 270 | code: *std.ArrayList(u8), | 269 | code: *std.ArrayList(u8), |
| 271 | debug_output: DebugInfoOutput, | 270 | debug_output: link.File.DebugInfoOutput, |
| 272 | ) CodeGenError!Result { | 271 | ) CodeGenError!Result { |
| 273 | const zcu = pt.zcu; | 272 | const zcu = pt.zcu; |
| 274 | const gpa = zcu.gpa; | 273 | const gpa = zcu.gpa; |
src/arch/sparc64/Emit.zig+1-2| ... | @@ -9,7 +9,6 @@ const Zcu = @import("../../Zcu.zig"); | ... | @@ -9,7 +9,6 @@ const Zcu = @import("../../Zcu.zig"); |
| 9 | const ErrorMsg = Zcu.ErrorMsg; | 9 | const ErrorMsg = Zcu.ErrorMsg; |
| 10 | const Liveness = @import("../../Liveness.zig"); | 10 | const Liveness = @import("../../Liveness.zig"); |
| 11 | const log = std.log.scoped(.sparcv9_emit); | 11 | const log = std.log.scoped(.sparcv9_emit); |
| 12 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | ||
| 13 | 12 | ||
| 14 | const Emit = @This(); | 13 | const Emit = @This(); |
| 15 | const Mir = @import("Mir.zig"); | 14 | const Mir = @import("Mir.zig"); |
| ... | @@ -19,7 +18,7 @@ const Register = bits.Register; | ... | @@ -19,7 +18,7 @@ const Register = bits.Register; |
| 19 | 18 | ||
| 20 | mir: Mir, | 19 | mir: Mir, |
| 21 | bin_file: *link.File, | 20 | bin_file: *link.File, |
| 22 | debug_output: DebugInfoOutput, | 21 | debug_output: link.File.DebugInfoOutput, |
| 23 | target: *const std.Target, | 22 | target: *const std.Target, |
| 24 | err_msg: ?*ErrorMsg = null, | 23 | err_msg: ?*ErrorMsg = null, |
| 25 | src_loc: Zcu.LazySrcLoc, | 24 | src_loc: Zcu.LazySrcLoc, |
src/arch/wasm/CodeGen.zig+2-2| ... | @@ -648,7 +648,7 @@ block_depth: u32 = 0, | ... | @@ -648,7 +648,7 @@ block_depth: u32 = 0, |
| 648 | air: Air, | 648 | air: Air, |
| 649 | liveness: Liveness, | 649 | liveness: Liveness, |
| 650 | gpa: mem.Allocator, | 650 | gpa: mem.Allocator, |
| 651 | debug_output: codegen.DebugInfoOutput, | 651 | debug_output: link.File.DebugInfoOutput, |
| 652 | func_index: InternPool.Index, | 652 | func_index: InternPool.Index, |
| 653 | /// Contains a list of current branches. | 653 | /// Contains a list of current branches. |
| 654 | /// When we return from a branch, the branch will be popped from this list, | 654 | /// When we return from a branch, the branch will be popped from this list, |
| ... | @@ -1211,7 +1211,7 @@ pub fn generate( | ... | @@ -1211,7 +1211,7 @@ pub fn generate( |
| 1211 | air: Air, | 1211 | air: Air, |
| 1212 | liveness: Liveness, | 1212 | liveness: Liveness, |
| 1213 | code: *std.ArrayList(u8), | 1213 | code: *std.ArrayList(u8), |
| 1214 | debug_output: codegen.DebugInfoOutput, | 1214 | debug_output: link.File.DebugInfoOutput, |
| 1215 | ) codegen.CodeGenError!codegen.Result { | 1215 | ) codegen.CodeGenError!codegen.Result { |
| 1216 | const zcu = pt.zcu; | 1216 | const zcu = pt.zcu; |
| 1217 | const gpa = zcu.gpa; | 1217 | const gpa = zcu.gpa; |
src/arch/wasm/Emit.zig+1-1| ... | @@ -26,7 +26,7 @@ owner_nav: InternPool.Nav.Index, | ... | @@ -26,7 +26,7 @@ owner_nav: InternPool.Nav.Index, |
| 26 | 26 | ||
| 27 | // Debug information | 27 | // Debug information |
| 28 | /// Holds the debug information for this emission | 28 | /// Holds the debug information for this emission |
| 29 | dbg_output: codegen.DebugInfoOutput, | 29 | dbg_output: link.File.DebugInfoOutput, |
| 30 | /// Previous debug info line | 30 | /// Previous debug info line |
| 31 | prev_di_line: u32, | 31 | prev_di_line: u32, |
| 32 | /// Previous debug info column | 32 | /// Previous debug info column |
src/arch/x86_64/CodeGen.zig+3-4| ... | @@ -17,7 +17,6 @@ const Air = @import("../../Air.zig"); | ... | @@ -17,7 +17,6 @@ const Air = @import("../../Air.zig"); |
| 17 | const Allocator = mem.Allocator; | 17 | const Allocator = mem.Allocator; |
| 18 | const CodeGenError = codegen.CodeGenError; | 18 | const CodeGenError = codegen.CodeGenError; |
| 19 | const Compilation = @import("../../Compilation.zig"); | 19 | const Compilation = @import("../../Compilation.zig"); |
| 20 | const DebugInfoOutput = codegen.DebugInfoOutput; | ||
| 21 | const ErrorMsg = Zcu.ErrorMsg; | 20 | const ErrorMsg = Zcu.ErrorMsg; |
| 22 | const Result = codegen.Result; | 21 | const Result = codegen.Result; |
| 23 | const Emit = @import("Emit.zig"); | 22 | const Emit = @import("Emit.zig"); |
| ... | @@ -53,7 +52,7 @@ pt: Zcu.PerThread, | ... | @@ -53,7 +52,7 @@ pt: Zcu.PerThread, |
| 53 | air: Air, | 52 | air: Air, |
| 54 | liveness: Liveness, | 53 | liveness: Liveness, |
| 55 | bin_file: *link.File, | 54 | bin_file: *link.File, |
| 56 | debug_output: DebugInfoOutput, | 55 | debug_output: link.File.DebugInfoOutput, |
| 57 | target: *const std.Target, | 56 | target: *const std.Target, |
| 58 | owner: Owner, | 57 | owner: Owner, |
| 59 | inline_func: InternPool.Index, | 58 | inline_func: InternPool.Index, |
| ... | @@ -819,7 +818,7 @@ pub fn generate( | ... | @@ -819,7 +818,7 @@ pub fn generate( |
| 819 | air: Air, | 818 | air: Air, |
| 820 | liveness: Liveness, | 819 | liveness: Liveness, |
| 821 | code: *std.ArrayList(u8), | 820 | code: *std.ArrayList(u8), |
| 822 | debug_output: DebugInfoOutput, | 821 | debug_output: link.File.DebugInfoOutput, |
| 823 | ) CodeGenError!Result { | 822 | ) CodeGenError!Result { |
| 824 | const zcu = pt.zcu; | 823 | const zcu = pt.zcu; |
| 825 | const comp = zcu.comp; | 824 | const comp = zcu.comp; |
| ... | @@ -1000,7 +999,7 @@ pub fn generateLazy( | ... | @@ -1000,7 +999,7 @@ pub fn generateLazy( |
| 1000 | src_loc: Zcu.LazySrcLoc, | 999 | src_loc: Zcu.LazySrcLoc, |
| 1001 | lazy_sym: link.File.LazySymbol, | 1000 | lazy_sym: link.File.LazySymbol, |
| 1002 | code: *std.ArrayList(u8), | 1001 | code: *std.ArrayList(u8), |
| 1003 | debug_output: DebugInfoOutput, | 1002 | debug_output: link.File.DebugInfoOutput, |
| 1004 | ) CodeGenError!Result { | 1003 | ) CodeGenError!Result { |
| 1005 | const comp = bin_file.comp; | 1004 | const comp = bin_file.comp; |
| 1006 | const gpa = comp.gpa; | 1005 | const gpa = comp.gpa; |
src/arch/x86_64/Emit.zig+1-2| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | air: Air, | 3 | air: Air, |
| 4 | lower: Lower, | 4 | lower: Lower, |
| 5 | atom_index: u32, | 5 | atom_index: u32, |
| 6 | debug_output: DebugInfoOutput, | 6 | debug_output: link.File.DebugInfoOutput, |
| 7 | code: *std.ArrayList(u8), | 7 | code: *std.ArrayList(u8), |
| 8 | 8 | ||
| 9 | prev_di_line: u32, | 9 | prev_di_line: u32, |
| ... | @@ -546,7 +546,6 @@ const log = std.log.scoped(.emit); | ... | @@ -546,7 +546,6 @@ const log = std.log.scoped(.emit); |
| 546 | const std = @import("std"); | 546 | const std = @import("std"); |
| 547 | 547 | ||
| 548 | const Air = @import("../../Air.zig"); | 548 | const Air = @import("../../Air.zig"); |
| 549 | const DebugInfoOutput = @import("../../codegen.zig").DebugInfoOutput; | ||
| 550 | const Emit = @This(); | 549 | const Emit = @This(); |
| 551 | const Lower = @import("Lower.zig"); | 550 | const Lower = @import("Lower.zig"); |
| 552 | const Mir = @import("Mir.zig"); | 551 | const Mir = @import("Mir.zig"); |
src/codegen.zig+34-60| ... | @@ -38,12 +38,6 @@ pub const CodeGenError = error{ | ... | @@ -38,12 +38,6 @@ pub const CodeGenError = error{ |
| 38 | CodegenFail, | 38 | CodegenFail, |
| 39 | } || link.File.UpdateDebugInfoError; | 39 | } || link.File.UpdateDebugInfoError; |
| 40 | 40 | ||
| 41 | pub const DebugInfoOutput = union(enum) { | ||
| 42 | dwarf: *link.File.Dwarf.WipNav, | ||
| 43 | plan9: *link.File.Plan9.DebugInfoOutput, | ||
| 44 | none, | ||
| 45 | }; | ||
| 46 | |||
| 47 | fn devFeatureForBackend(comptime backend: std.builtin.CompilerBackend) dev.Feature { | 41 | fn devFeatureForBackend(comptime backend: std.builtin.CompilerBackend) dev.Feature { |
| 48 | comptime assert(mem.startsWith(u8, @tagName(backend), "stage2_")); | 42 | comptime assert(mem.startsWith(u8, @tagName(backend), "stage2_")); |
| 49 | return @field(dev.Feature, @tagName(backend)["stage2_".len..] ++ "_backend"); | 43 | return @field(dev.Feature, @tagName(backend)["stage2_".len..] ++ "_backend"); |
| ... | @@ -69,7 +63,7 @@ pub fn generateFunction( | ... | @@ -69,7 +63,7 @@ pub fn generateFunction( |
| 69 | air: Air, | 63 | air: Air, |
| 70 | liveness: Liveness, | 64 | liveness: Liveness, |
| 71 | code: *std.ArrayList(u8), | 65 | code: *std.ArrayList(u8), |
| 72 | debug_output: DebugInfoOutput, | 66 | debug_output: link.File.DebugInfoOutput, |
| 73 | ) CodeGenError!Result { | 67 | ) CodeGenError!Result { |
| 74 | const zcu = pt.zcu; | 68 | const zcu = pt.zcu; |
| 75 | const func = zcu.funcInfo(func_index); | 69 | const func = zcu.funcInfo(func_index); |
| ... | @@ -95,7 +89,7 @@ pub fn generateLazyFunction( | ... | @@ -95,7 +89,7 @@ pub fn generateLazyFunction( |
| 95 | src_loc: Zcu.LazySrcLoc, | 89 | src_loc: Zcu.LazySrcLoc, |
| 96 | lazy_sym: link.File.LazySymbol, | 90 | lazy_sym: link.File.LazySymbol, |
| 97 | code: *std.ArrayList(u8), | 91 | code: *std.ArrayList(u8), |
| 98 | debug_output: DebugInfoOutput, | 92 | debug_output: link.File.DebugInfoOutput, |
| 99 | ) CodeGenError!Result { | 93 | ) CodeGenError!Result { |
| 100 | const zcu = pt.zcu; | 94 | const zcu = pt.zcu; |
| 101 | const file = Type.fromInterned(lazy_sym.ty).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(&zcu.intern_pool); | 95 | const file = Type.fromInterned(lazy_sym.ty).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(&zcu.intern_pool); |
| ... | @@ -127,10 +121,10 @@ pub fn generateLazySymbol( | ... | @@ -127,10 +121,10 @@ pub fn generateLazySymbol( |
| 127 | // TODO don't use an "out" parameter like this; put it in the result instead | 121 | // TODO don't use an "out" parameter like this; put it in the result instead |
| 128 | alignment: *Alignment, | 122 | alignment: *Alignment, |
| 129 | code: *std.ArrayList(u8), | 123 | code: *std.ArrayList(u8), |
| 130 | debug_output: DebugInfoOutput, | 124 | debug_output: link.File.DebugInfoOutput, |
| 131 | reloc_info: RelocInfo, | 125 | reloc_parent: link.File.RelocInfo.Parent, |
| 132 | ) CodeGenError!Result { | 126 | ) CodeGenError!Result { |
| 133 | _ = reloc_info; | 127 | _ = reloc_parent; |
| 134 | 128 | ||
| 135 | const tracy = trace(@src()); | 129 | const tracy = trace(@src()); |
| 136 | defer tracy.end(); | 130 | defer tracy.end(); |
| ... | @@ -192,8 +186,7 @@ pub fn generateSymbol( | ... | @@ -192,8 +186,7 @@ pub fn generateSymbol( |
| 192 | src_loc: Zcu.LazySrcLoc, | 186 | src_loc: Zcu.LazySrcLoc, |
| 193 | val: Value, | 187 | val: Value, |
| 194 | code: *std.ArrayList(u8), | 188 | code: *std.ArrayList(u8), |
| 195 | debug_output: DebugInfoOutput, | 189 | reloc_parent: link.File.RelocInfo.Parent, |
| 196 | reloc_info: RelocInfo, | ||
| 197 | ) CodeGenError!Result { | 190 | ) CodeGenError!Result { |
| 198 | const tracy = trace(@src()); | 191 | const tracy = trace(@src()); |
| 199 | defer tracy.end(); | 192 | defer tracy.end(); |
| ... | @@ -290,7 +283,7 @@ pub fn generateSymbol( | ... | @@ -290,7 +283,7 @@ pub fn generateSymbol( |
| 290 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(switch (error_union.val) { | 283 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(switch (error_union.val) { |
| 291 | .err_name => try pt.intern(.{ .undef = payload_ty.toIntern() }), | 284 | .err_name => try pt.intern(.{ .undef = payload_ty.toIntern() }), |
| 292 | .payload => |payload| payload, | 285 | .payload => |payload| payload, |
| 293 | }), code, debug_output, reloc_info)) { | 286 | }), code, reloc_parent)) { |
| 294 | .ok => {}, | 287 | .ok => {}, |
| 295 | .fail => |em| return .{ .fail = em }, | 288 | .fail => |em| return .{ .fail = em }, |
| 296 | } | 289 | } |
| ... | @@ -318,7 +311,7 @@ pub fn generateSymbol( | ... | @@ -318,7 +311,7 @@ pub fn generateSymbol( |
| 318 | }, | 311 | }, |
| 319 | .enum_tag => |enum_tag| { | 312 | .enum_tag => |enum_tag| { |
| 320 | const int_tag_ty = ty.intTagType(zcu); | 313 | const int_tag_ty = ty.intTagType(zcu); |
| 321 | switch (try generateSymbol(bin_file, pt, src_loc, try pt.getCoerced(Value.fromInterned(enum_tag.int), int_tag_ty), code, debug_output, reloc_info)) { | 314 | switch (try generateSymbol(bin_file, pt, src_loc, try pt.getCoerced(Value.fromInterned(enum_tag.int), int_tag_ty), code, reloc_parent)) { |
| 322 | .ok => {}, | 315 | .ok => {}, |
| 323 | .fail => |em| return .{ .fail = em }, | 316 | .fail => |em| return .{ .fail = em }, |
| 324 | } | 317 | } |
| ... | @@ -334,16 +327,16 @@ pub fn generateSymbol( | ... | @@ -334,16 +327,16 @@ pub fn generateSymbol( |
| 334 | }, | 327 | }, |
| 335 | .f128 => |f128_val| writeFloat(f128, f128_val, target, endian, try code.addManyAsArray(16)), | 328 | .f128 => |f128_val| writeFloat(f128, f128_val, target, endian, try code.addManyAsArray(16)), |
| 336 | }, | 329 | }, |
| 337 | .ptr => switch (try lowerPtr(bin_file, pt, src_loc, val.toIntern(), code, debug_output, reloc_info, 0)) { | 330 | .ptr => switch (try lowerPtr(bin_file, pt, src_loc, val.toIntern(), code, reloc_parent, 0)) { |
| 338 | .ok => {}, | 331 | .ok => {}, |
| 339 | .fail => |em| return .{ .fail = em }, | 332 | .fail => |em| return .{ .fail = em }, |
| 340 | }, | 333 | }, |
| 341 | .slice => |slice| { | 334 | .slice => |slice| { |
| 342 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.ptr), code, debug_output, reloc_info)) { | 335 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.ptr), code, reloc_parent)) { |
| 343 | .ok => {}, | 336 | .ok => {}, |
| 344 | .fail => |em| return .{ .fail = em }, | 337 | .fail => |em| return .{ .fail = em }, |
| 345 | } | 338 | } |
| 346 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.len), code, debug_output, reloc_info)) { | 339 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(slice.len), code, reloc_parent)) { |
| 347 | .ok => {}, | 340 | .ok => {}, |
| 348 | .fail => |em| return .{ .fail = em }, | 341 | .fail => |em| return .{ .fail = em }, |
| 349 | } | 342 | } |
| ... | @@ -355,7 +348,7 @@ pub fn generateSymbol( | ... | @@ -355,7 +348,7 @@ pub fn generateSymbol( |
| 355 | 348 | ||
| 356 | if (ty.optionalReprIsPayload(zcu)) { | 349 | if (ty.optionalReprIsPayload(zcu)) { |
| 357 | if (payload_val) |value| { | 350 | if (payload_val) |value| { |
| 358 | switch (try generateSymbol(bin_file, pt, src_loc, value, code, debug_output, reloc_info)) { | 351 | switch (try generateSymbol(bin_file, pt, src_loc, value, code, reloc_parent)) { |
| 359 | .ok => {}, | 352 | .ok => {}, |
| 360 | .fail => |em| return Result{ .fail = em }, | 353 | .fail => |em| return Result{ .fail = em }, |
| 361 | } | 354 | } |
| ... | @@ -368,7 +361,7 @@ pub fn generateSymbol( | ... | @@ -368,7 +361,7 @@ pub fn generateSymbol( |
| 368 | const value = payload_val orelse Value.fromInterned(try pt.intern(.{ | 361 | const value = payload_val orelse Value.fromInterned(try pt.intern(.{ |
| 369 | .undef = payload_type.toIntern(), | 362 | .undef = payload_type.toIntern(), |
| 370 | })); | 363 | })); |
| 371 | switch (try generateSymbol(bin_file, pt, src_loc, value, code, debug_output, reloc_info)) { | 364 | switch (try generateSymbol(bin_file, pt, src_loc, value, code, reloc_parent)) { |
| 372 | .ok => {}, | 365 | .ok => {}, |
| 373 | .fail => |em| return Result{ .fail = em }, | 366 | .fail => |em| return Result{ .fail = em }, |
| 374 | } | 367 | } |
| ... | @@ -390,7 +383,7 @@ pub fn generateSymbol( | ... | @@ -390,7 +383,7 @@ pub fn generateSymbol( |
| 390 | elem | 383 | elem |
| 391 | else | 384 | else |
| 392 | array_type.sentinel, | 385 | array_type.sentinel, |
| 393 | }), code, debug_output, reloc_info)) { | 386 | }), code, reloc_parent)) { |
| 394 | .ok => {}, | 387 | .ok => {}, |
| 395 | .fail => |em| return .{ .fail = em }, | 388 | .fail => |em| return .{ .fail = em }, |
| 396 | } | 389 | } |
| ... | @@ -449,7 +442,7 @@ pub fn generateSymbol( | ... | @@ -449,7 +442,7 @@ pub fn generateSymbol( |
| 449 | math.cast(usize, index) orelse return error.Overflow | 442 | math.cast(usize, index) orelse return error.Overflow |
| 450 | ], | 443 | ], |
| 451 | .repeated_elem => |elem| elem, | 444 | .repeated_elem => |elem| elem, |
| 452 | }), code, debug_output, reloc_info)) { | 445 | }), code, reloc_parent)) { |
| 453 | .ok => {}, | 446 | .ok => {}, |
| 454 | .fail => |em| return .{ .fail = em }, | 447 | .fail => |em| return .{ .fail = em }, |
| 455 | } | 448 | } |
| ... | @@ -482,7 +475,7 @@ pub fn generateSymbol( | ... | @@ -482,7 +475,7 @@ pub fn generateSymbol( |
| 482 | .repeated_elem => |elem| elem, | 475 | .repeated_elem => |elem| elem, |
| 483 | }; | 476 | }; |
| 484 | 477 | ||
| 485 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, debug_output, reloc_info)) { | 478 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, reloc_parent)) { |
| 486 | .ok => {}, | 479 | .ok => {}, |
| 487 | .fail => |em| return Result{ .fail = em }, | 480 | .fail => |em| return Result{ .fail = em }, |
| 488 | } | 481 | } |
| ... | @@ -524,7 +517,7 @@ pub fn generateSymbol( | ... | @@ -524,7 +517,7 @@ pub fn generateSymbol( |
| 524 | return error.Overflow; | 517 | return error.Overflow; |
| 525 | var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size); | 518 | var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size); |
| 526 | defer tmp_list.deinit(); | 519 | defer tmp_list.deinit(); |
| 527 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), &tmp_list, debug_output, reloc_info)) { | 520 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), &tmp_list, reloc_parent)) { |
| 528 | .ok => @memcpy(code.items[current_pos..][0..tmp_list.items.len], tmp_list.items), | 521 | .ok => @memcpy(code.items[current_pos..][0..tmp_list.items.len], tmp_list.items), |
| 529 | .fail => |em| return Result{ .fail = em }, | 522 | .fail => |em| return Result{ .fail = em }, |
| 530 | } | 523 | } |
| ... | @@ -559,7 +552,7 @@ pub fn generateSymbol( | ... | @@ -559,7 +552,7 @@ pub fn generateSymbol( |
| 559 | ) orelse return error.Overflow; | 552 | ) orelse return error.Overflow; |
| 560 | if (padding > 0) try code.appendNTimes(0, padding); | 553 | if (padding > 0) try code.appendNTimes(0, padding); |
| 561 | 554 | ||
| 562 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, debug_output, reloc_info)) { | 555 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(field_val), code, reloc_parent)) { |
| 563 | .ok => {}, | 556 | .ok => {}, |
| 564 | .fail => |em| return Result{ .fail = em }, | 557 | .fail => |em| return Result{ .fail = em }, |
| 565 | } | 558 | } |
| ... | @@ -583,12 +576,12 @@ pub fn generateSymbol( | ... | @@ -583,12 +576,12 @@ pub fn generateSymbol( |
| 583 | const layout = ty.unionGetLayout(zcu); | 576 | const layout = ty.unionGetLayout(zcu); |
| 584 | 577 | ||
| 585 | if (layout.payload_size == 0) { | 578 | if (layout.payload_size == 0) { |
| 586 | return generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, debug_output, reloc_info); | 579 | return generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, reloc_parent); |
| 587 | } | 580 | } |
| 588 | 581 | ||
| 589 | // Check if we should store the tag first. | 582 | // Check if we should store the tag first. |
| 590 | if (layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align)) { | 583 | if (layout.tag_size > 0 and layout.tag_align.compare(.gte, layout.payload_align)) { |
| 591 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, debug_output, reloc_info)) { | 584 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, reloc_parent)) { |
| 592 | .ok => {}, | 585 | .ok => {}, |
| 593 | .fail => |em| return Result{ .fail = em }, | 586 | .fail => |em| return Result{ .fail = em }, |
| 594 | } | 587 | } |
| ... | @@ -601,7 +594,7 @@ pub fn generateSymbol( | ... | @@ -601,7 +594,7 @@ pub fn generateSymbol( |
| 601 | if (!field_ty.hasRuntimeBits(zcu)) { | 594 | if (!field_ty.hasRuntimeBits(zcu)) { |
| 602 | try code.appendNTimes(0xaa, math.cast(usize, layout.payload_size) orelse return error.Overflow); | 595 | try code.appendNTimes(0xaa, math.cast(usize, layout.payload_size) orelse return error.Overflow); |
| 603 | } else { | 596 | } else { |
| 604 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, debug_output, reloc_info)) { | 597 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, reloc_parent)) { |
| 605 | .ok => {}, | 598 | .ok => {}, |
| 606 | .fail => |em| return Result{ .fail = em }, | 599 | .fail => |em| return Result{ .fail = em }, |
| 607 | } | 600 | } |
| ... | @@ -612,14 +605,14 @@ pub fn generateSymbol( | ... | @@ -612,14 +605,14 @@ pub fn generateSymbol( |
| 612 | } | 605 | } |
| 613 | } | 606 | } |
| 614 | } else { | 607 | } else { |
| 615 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, debug_output, reloc_info)) { | 608 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.val), code, reloc_parent)) { |
| 616 | .ok => {}, | 609 | .ok => {}, |
| 617 | .fail => |em| return Result{ .fail = em }, | 610 | .fail => |em| return Result{ .fail = em }, |
| 618 | } | 611 | } |
| 619 | } | 612 | } |
| 620 | 613 | ||
| 621 | if (layout.tag_size > 0 and layout.tag_align.compare(.lt, layout.payload_align)) { | 614 | if (layout.tag_size > 0 and layout.tag_align.compare(.lt, layout.payload_align)) { |
| 622 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, debug_output, reloc_info)) { | 615 | switch (try generateSymbol(bin_file, pt, src_loc, Value.fromInterned(un.tag), code, reloc_parent)) { |
| 623 | .ok => {}, | 616 | .ok => {}, |
| 624 | .fail => |em| return Result{ .fail = em }, | 617 | .fail => |em| return Result{ .fail = em }, |
| 625 | } | 618 | } |
| ... | @@ -640,40 +633,29 @@ fn lowerPtr( | ... | @@ -640,40 +633,29 @@ fn lowerPtr( |
| 640 | src_loc: Zcu.LazySrcLoc, | 633 | src_loc: Zcu.LazySrcLoc, |
| 641 | ptr_val: InternPool.Index, | 634 | ptr_val: InternPool.Index, |
| 642 | code: *std.ArrayList(u8), | 635 | code: *std.ArrayList(u8), |
| 643 | debug_output: DebugInfoOutput, | 636 | reloc_parent: link.File.RelocInfo.Parent, |
| 644 | reloc_info: RelocInfo, | ||
| 645 | prev_offset: u64, | 637 | prev_offset: u64, |
| 646 | ) CodeGenError!Result { | 638 | ) CodeGenError!Result { |
| 647 | const zcu = pt.zcu; | 639 | const zcu = pt.zcu; |
| 648 | const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr; | 640 | const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr; |
| 649 | const offset: u64 = prev_offset + ptr.byte_offset; | 641 | const offset: u64 = prev_offset + ptr.byte_offset; |
| 650 | return switch (ptr.base_addr) { | 642 | return switch (ptr.base_addr) { |
| 651 | .nav => |nav| try lowerNavRef(bin_file, pt, src_loc, nav, code, debug_output, reloc_info, offset), | 643 | .nav => |nav| try lowerNavRef(bin_file, pt, src_loc, nav, code, reloc_parent, offset), |
| 652 | .uav => |uav| try lowerUavRef(bin_file, pt, src_loc, uav, code, debug_output, reloc_info, offset), | 644 | .uav => |uav| try lowerUavRef(bin_file, pt, src_loc, uav, code, reloc_parent, offset), |
| 653 | .int => try generateSymbol(bin_file, pt, src_loc, try pt.intValue(Type.usize, offset), code, debug_output, reloc_info), | 645 | .int => try generateSymbol(bin_file, pt, src_loc, try pt.intValue(Type.usize, offset), code, reloc_parent), |
| 654 | .eu_payload => |eu_ptr| try lowerPtr( | 646 | .eu_payload => |eu_ptr| try lowerPtr( |
| 655 | bin_file, | 647 | bin_file, |
| 656 | pt, | 648 | pt, |
| 657 | src_loc, | 649 | src_loc, |
| 658 | eu_ptr, | 650 | eu_ptr, |
| 659 | code, | 651 | code, |
| 660 | debug_output, | 652 | reloc_parent, |
| 661 | reloc_info, | ||
| 662 | offset + errUnionPayloadOffset( | 653 | offset + errUnionPayloadOffset( |
| 663 | Value.fromInterned(eu_ptr).typeOf(zcu).childType(zcu).errorUnionPayload(zcu), | 654 | Value.fromInterned(eu_ptr).typeOf(zcu).childType(zcu).errorUnionPayload(zcu), |
| 664 | zcu, | 655 | zcu, |
| 665 | ), | 656 | ), |
| 666 | ), | 657 | ), |
| 667 | .opt_payload => |opt_ptr| try lowerPtr( | 658 | .opt_payload => |opt_ptr| try lowerPtr(bin_file, pt, src_loc, opt_ptr, code, reloc_parent, offset), |
| 668 | bin_file, | ||
| 669 | pt, | ||
| 670 | src_loc, | ||
| 671 | opt_ptr, | ||
| 672 | code, | ||
| 673 | debug_output, | ||
| 674 | reloc_info, | ||
| 675 | offset, | ||
| 676 | ), | ||
| 677 | .field => |field| { | 659 | .field => |field| { |
| 678 | const base_ptr = Value.fromInterned(field.base); | 660 | const base_ptr = Value.fromInterned(field.base); |
| 679 | const base_ty = base_ptr.typeOf(zcu).childType(zcu); | 661 | const base_ty = base_ptr.typeOf(zcu).childType(zcu); |
| ... | @@ -692,27 +674,21 @@ fn lowerPtr( | ... | @@ -692,27 +674,21 @@ fn lowerPtr( |
| 692 | }, | 674 | }, |
| 693 | else => unreachable, | 675 | else => unreachable, |
| 694 | }; | 676 | }; |
| 695 | return lowerPtr(bin_file, pt, src_loc, field.base, code, debug_output, reloc_info, offset + field_off); | 677 | return lowerPtr(bin_file, pt, src_loc, field.base, code, reloc_parent, offset + field_off); |
| 696 | }, | 678 | }, |
| 697 | .arr_elem, .comptime_field, .comptime_alloc => unreachable, | 679 | .arr_elem, .comptime_field, .comptime_alloc => unreachable, |
| 698 | }; | 680 | }; |
| 699 | } | 681 | } |
| 700 | 682 | ||
| 701 | const RelocInfo = struct { | ||
| 702 | parent_atom_index: u32, | ||
| 703 | }; | ||
| 704 | |||
| 705 | fn lowerUavRef( | 683 | fn lowerUavRef( |
| 706 | lf: *link.File, | 684 | lf: *link.File, |
| 707 | pt: Zcu.PerThread, | 685 | pt: Zcu.PerThread, |
| 708 | src_loc: Zcu.LazySrcLoc, | 686 | src_loc: Zcu.LazySrcLoc, |
| 709 | uav: InternPool.Key.Ptr.BaseAddr.Uav, | 687 | uav: InternPool.Key.Ptr.BaseAddr.Uav, |
| 710 | code: *std.ArrayList(u8), | 688 | code: *std.ArrayList(u8), |
| 711 | debug_output: DebugInfoOutput, | 689 | reloc_parent: link.File.RelocInfo.Parent, |
| 712 | reloc_info: RelocInfo, | ||
| 713 | offset: u64, | 690 | offset: u64, |
| 714 | ) CodeGenError!Result { | 691 | ) CodeGenError!Result { |
| 715 | _ = debug_output; | ||
| 716 | const zcu = pt.zcu; | 692 | const zcu = pt.zcu; |
| 717 | const ip = &zcu.intern_pool; | 693 | const ip = &zcu.intern_pool; |
| 718 | const target = lf.comp.root_mod.resolved_target.result; | 694 | const target = lf.comp.root_mod.resolved_target.result; |
| ... | @@ -735,7 +711,7 @@ fn lowerUavRef( | ... | @@ -735,7 +711,7 @@ fn lowerUavRef( |
| 735 | } | 711 | } |
| 736 | 712 | ||
| 737 | const vaddr = try lf.getUavVAddr(uav_val, .{ | 713 | const vaddr = try lf.getUavVAddr(uav_val, .{ |
| 738 | .parent_atom_index = reloc_info.parent_atom_index, | 714 | .parent = reloc_parent, |
| 739 | .offset = code.items.len, | 715 | .offset = code.items.len, |
| 740 | .addend = @intCast(offset), | 716 | .addend = @intCast(offset), |
| 741 | }); | 717 | }); |
| ... | @@ -756,12 +732,10 @@ fn lowerNavRef( | ... | @@ -756,12 +732,10 @@ fn lowerNavRef( |
| 756 | src_loc: Zcu.LazySrcLoc, | 732 | src_loc: Zcu.LazySrcLoc, |
| 757 | nav_index: InternPool.Nav.Index, | 733 | nav_index: InternPool.Nav.Index, |
| 758 | code: *std.ArrayList(u8), | 734 | code: *std.ArrayList(u8), |
| 759 | debug_output: DebugInfoOutput, | 735 | reloc_parent: link.File.RelocInfo.Parent, |
| 760 | reloc_info: RelocInfo, | ||
| 761 | offset: u64, | 736 | offset: u64, |
| 762 | ) CodeGenError!Result { | 737 | ) CodeGenError!Result { |
| 763 | _ = src_loc; | 738 | _ = src_loc; |
| 764 | _ = debug_output; | ||
| 765 | const zcu = pt.zcu; | 739 | const zcu = pt.zcu; |
| 766 | const ip = &zcu.intern_pool; | 740 | const ip = &zcu.intern_pool; |
| 767 | const target = zcu.navFileScope(nav_index).mod.resolved_target.result; | 741 | const target = zcu.navFileScope(nav_index).mod.resolved_target.result; |
| ... | @@ -775,7 +749,7 @@ fn lowerNavRef( | ... | @@ -775,7 +749,7 @@ fn lowerNavRef( |
| 775 | } | 749 | } |
| 776 | 750 | ||
| 777 | const vaddr = try lf.getNavVAddr(pt, nav_index, .{ | 751 | const vaddr = try lf.getNavVAddr(pt, nav_index, .{ |
| 778 | .parent_atom_index = reloc_info.parent_atom_index, | 752 | .parent = reloc_parent, |
| 779 | .offset = code.items.len, | 753 | .offset = code.items.len, |
| 780 | .addend = @intCast(offset), | 754 | .addend = @intCast(offset), |
| 781 | }); | 755 | }); |
src/link.zig+11-1| ... | @@ -330,6 +330,11 @@ pub const File = struct { | ... | @@ -330,6 +330,11 @@ pub const File = struct { |
| 330 | } | 330 | } |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | pub const DebugInfoOutput = union(enum) { | ||
| 334 | dwarf: *Dwarf.WipNav, | ||
| 335 | plan9: *Plan9.DebugInfoOutput, | ||
| 336 | none, | ||
| 337 | }; | ||
| 333 | pub const UpdateDebugInfoError = Dwarf.UpdateError; | 338 | pub const UpdateDebugInfoError = Dwarf.UpdateError; |
| 334 | pub const FlushDebugInfoError = Dwarf.FlushError; | 339 | pub const FlushDebugInfoError = Dwarf.FlushError; |
| 335 | 340 | ||
| ... | @@ -673,9 +678,14 @@ pub const File = struct { | ... | @@ -673,9 +678,14 @@ pub const File = struct { |
| 673 | } | 678 | } |
| 674 | 679 | ||
| 675 | pub const RelocInfo = struct { | 680 | pub const RelocInfo = struct { |
| 676 | parent_atom_index: u32, | 681 | parent: Parent, |
| 677 | offset: u64, | 682 | offset: u64, |
| 678 | addend: u32, | 683 | addend: u32, |
| 684 | |||
| 685 | pub const Parent = union(enum) { | ||
| 686 | atom_index: u32, | ||
| 687 | debug_output: DebugInfoOutput, | ||
| 688 | }; | ||
| 679 | }; | 689 | }; |
| 680 | 690 | ||
| 681 | /// Get allocated `Nav`'s address in virtual memory. | 691 | /// Get allocated `Nav`'s address in virtual memory. |
src/link/Coff.zig+12-7| ... | @@ -1163,8 +1163,8 @@ fn lowerConst( | ... | @@ -1163,8 +1163,8 @@ fn lowerConst( |
| 1163 | try self.setSymbolName(sym, name); | 1163 | try self.setSymbolName(sym, name); |
| 1164 | sym.section_number = @as(coff.SectionNumber, @enumFromInt(sect_id + 1)); | 1164 | sym.section_number = @as(coff.SectionNumber, @enumFromInt(sect_id + 1)); |
| 1165 | 1165 | ||
| 1166 | const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .none, .{ | 1166 | const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{ |
| 1167 | .parent_atom_index = self.getAtom(atom_index).getSymbolIndex().?, | 1167 | .atom_index = self.getAtom(atom_index).getSymbolIndex().?, |
| 1168 | }); | 1168 | }); |
| 1169 | const code = switch (res) { | 1169 | const code = switch (res) { |
| 1170 | .ok => code_buffer.items, | 1170 | .ok => code_buffer.items, |
| ... | @@ -1235,8 +1235,7 @@ pub fn updateNav( | ... | @@ -1235,8 +1235,7 @@ pub fn updateNav( |
| 1235 | zcu.navSrcLoc(nav_index), | 1235 | zcu.navSrcLoc(nav_index), |
| 1236 | nav_init, | 1236 | nav_init, |
| 1237 | &code_buffer, | 1237 | &code_buffer, |
| 1238 | .none, | 1238 | .{ .atom_index = atom.getSymbolIndex().? }, |
| 1239 | .{ .parent_atom_index = atom.getSymbolIndex().? }, | ||
| 1240 | ); | 1239 | ); |
| 1241 | const code = switch (res) { | 1240 | const code = switch (res) { |
| 1242 | .ok => code_buffer.items, | 1241 | .ok => code_buffer.items, |
| ... | @@ -1284,7 +1283,7 @@ fn updateLazySymbolAtom( | ... | @@ -1284,7 +1283,7 @@ fn updateLazySymbolAtom( |
| 1284 | &required_alignment, | 1283 | &required_alignment, |
| 1285 | &code_buffer, | 1284 | &code_buffer, |
| 1286 | .none, | 1285 | .none, |
| 1287 | .{ .parent_atom_index = local_sym_index }, | 1286 | .{ .atom_index = local_sym_index }, |
| 1288 | ); | 1287 | ); |
| 1289 | const code = switch (res) { | 1288 | const code = switch (res) { |
| 1290 | .ok => code_buffer.items, | 1289 | .ok => code_buffer.items, |
| ... | @@ -1823,7 +1822,10 @@ pub fn getNavVAddr( | ... | @@ -1823,7 +1822,10 @@ pub fn getNavVAddr( |
| 1823 | .@"extern" => |@"extern"| try self.getGlobalSymbol(nav.name.toSlice(ip), @"extern".lib_name.toSlice(ip)), | 1822 | .@"extern" => |@"extern"| try self.getGlobalSymbol(nav.name.toSlice(ip), @"extern".lib_name.toSlice(ip)), |
| 1824 | else => self.getAtom(try self.getOrCreateAtomForNav(nav_index)).getSymbolIndex().?, | 1823 | else => self.getAtom(try self.getOrCreateAtomForNav(nav_index)).getSymbolIndex().?, |
| 1825 | }; | 1824 | }; |
| 1826 | const atom_index = self.getAtomIndexForSymbol(.{ .sym_index = reloc_info.parent_atom_index, .file = null }).?; | 1825 | const atom_index = self.getAtomIndexForSymbol(.{ |
| 1826 | .sym_index = reloc_info.parent.atom_index, | ||
| 1827 | .file = null, | ||
| 1828 | }).?; | ||
| 1827 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; | 1829 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; |
| 1828 | try Atom.addRelocation(self, atom_index, .{ | 1830 | try Atom.addRelocation(self, atom_index, .{ |
| 1829 | .type = .direct, | 1831 | .type = .direct, |
| ... | @@ -1901,7 +1903,10 @@ pub fn getUavVAddr( | ... | @@ -1901,7 +1903,10 @@ pub fn getUavVAddr( |
| 1901 | 1903 | ||
| 1902 | const this_atom_index = self.uavs.get(uav).?.atom; | 1904 | const this_atom_index = self.uavs.get(uav).?.atom; |
| 1903 | const sym_index = self.getAtom(this_atom_index).getSymbolIndex().?; | 1905 | const sym_index = self.getAtom(this_atom_index).getSymbolIndex().?; |
| 1904 | const atom_index = self.getAtomIndexForSymbol(.{ .sym_index = reloc_info.parent_atom_index, .file = null }).?; | 1906 | const atom_index = self.getAtomIndexForSymbol(.{ |
| 1907 | .sym_index = reloc_info.parent.atom_index, | ||
| 1908 | .file = null, | ||
| 1909 | }).?; | ||
| 1905 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; | 1910 | const target = SymbolWithLoc{ .sym_index = sym_index, .file = null }; |
| 1906 | try Atom.addRelocation(self, atom_index, .{ | 1911 | try Atom.addRelocation(self, atom_index, .{ |
| 1907 | .type = .direct, | 1912 | .type = .direct, |
src/link/Dwarf.zig+129-69| ... | @@ -19,8 +19,8 @@ debug_rnglists: DebugRngLists, | ... | @@ -19,8 +19,8 @@ debug_rnglists: DebugRngLists, |
| 19 | debug_str: StringSection, | 19 | debug_str: StringSection, |
| 20 | 20 | ||
| 21 | pub const UpdateError = error{ | 21 | pub const UpdateError = error{ |
| 22 | CodegenFail, | ||
| 22 | ReinterpretDeclRef, | 23 | ReinterpretDeclRef, |
| 23 | IllDefinedMemoryLayout, | ||
| 24 | Unimplemented, | 24 | Unimplemented, |
| 25 | OutOfMemory, | 25 | OutOfMemory, |
| 26 | EndOfStream, | 26 | EndOfStream, |
| ... | @@ -1584,6 +1584,18 @@ pub const WipNav = struct { | ... | @@ -1584,6 +1584,18 @@ pub const WipNav = struct { |
| 1584 | wip_nav.func = func; | 1584 | wip_nav.func = func; |
| 1585 | } | 1585 | } |
| 1586 | 1586 | ||
| 1587 | fn externalReloc(wip_nav: *WipNav, sec: *Section, reloc: ExternalReloc) std.mem.Allocator.Error!void { | ||
| 1588 | try sec.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(wip_nav.dwarf.gpa, reloc); | ||
| 1589 | } | ||
| 1590 | |||
| 1591 | pub fn infoExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void { | ||
| 1592 | try wip_nav.externalReloc(&wip_nav.dwarf.debug_info.section, reloc); | ||
| 1593 | } | ||
| 1594 | |||
| 1595 | fn frameExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void { | ||
| 1596 | try wip_nav.externalReloc(&wip_nav.dwarf.debug_frame.section, reloc); | ||
| 1597 | } | ||
| 1598 | |||
| 1587 | fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void { | 1599 | fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void { |
| 1588 | try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), try wip_nav.dwarf.refAbbrevCode(abbrev_code)); | 1600 | try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), try wip_nav.dwarf.refAbbrevCode(abbrev_code)); |
| 1589 | } | 1601 | } |
| ... | @@ -1660,12 +1672,11 @@ pub const WipNav = struct { | ... | @@ -1660,12 +1672,11 @@ pub const WipNav = struct { |
| 1660 | } | 1672 | } |
| 1661 | 1673 | ||
| 1662 | fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void { | 1674 | fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void { |
| 1663 | const dwarf = wip_nav.dwarf; | 1675 | try wip_nav.infoExternalReloc(.{ |
| 1664 | try dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(dwarf.gpa, .{ | ||
| 1665 | .source_off = @intCast(wip_nav.debug_info.items.len), | 1676 | .source_off = @intCast(wip_nav.debug_info.items.len), |
| 1666 | .target_sym = sym_index, | 1677 | .target_sym = sym_index, |
| 1667 | }); | 1678 | }); |
| 1668 | try wip_nav.debug_info.appendNTimes(dwarf.gpa, 0, @intFromEnum(dwarf.address_size)); | 1679 | try wip_nav.debug_info.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size)); |
| 1669 | } | 1680 | } |
| 1670 | 1681 | ||
| 1671 | fn frameExprloc(wip_nav: *WipNav, loc: Loc) UpdateError!void { | 1682 | fn frameExprloc(wip_nav: *WipNav, loc: Loc) UpdateError!void { |
| ... | @@ -1692,12 +1703,11 @@ pub const WipNav = struct { | ... | @@ -1692,12 +1703,11 @@ pub const WipNav = struct { |
| 1692 | } | 1703 | } |
| 1693 | 1704 | ||
| 1694 | fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void { | 1705 | fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void { |
| 1695 | const dwarf = wip_nav.dwarf; | 1706 | try wip_nav.frameExternalReloc(.{ |
| 1696 | try dwarf.debug_frame.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(dwarf.gpa, .{ | ||
| 1697 | .source_off = @intCast(wip_nav.debug_frame.items.len), | 1707 | .source_off = @intCast(wip_nav.debug_frame.items.len), |
| 1698 | .target_sym = sym_index, | 1708 | .target_sym = sym_index, |
| 1699 | }); | 1709 | }); |
| 1700 | try wip_nav.debug_frame.appendNTimes(dwarf.gpa, 0, @intFromEnum(dwarf.address_size)); | 1710 | try wip_nav.debug_frame.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size)); |
| 1701 | } | 1711 | } |
| 1702 | 1712 | ||
| 1703 | fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } { | 1713 | fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } { |
| ... | @@ -1749,6 +1759,27 @@ pub const WipNav = struct { | ... | @@ -1749,6 +1759,27 @@ pub const WipNav = struct { |
| 1749 | reloc.target_off = @intCast(wip_nav.debug_info.items.len); | 1759 | reloc.target_off = @intCast(wip_nav.debug_info.items.len); |
| 1750 | } | 1760 | } |
| 1751 | 1761 | ||
| 1762 | fn blockValue(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc, val: Value) UpdateError!void { | ||
| 1763 | const ty = val.typeOf(wip_nav.pt.zcu); | ||
| 1764 | const diw = wip_nav.debug_info.writer(wip_nav.dwarf.gpa); | ||
| 1765 | const bytes = ty.abiSize(wip_nav.pt.zcu); | ||
| 1766 | try uleb128(diw, bytes); | ||
| 1767 | if (bytes == 0) return; | ||
| 1768 | var dim = wip_nav.debug_info.toManaged(wip_nav.dwarf.gpa); | ||
| 1769 | defer wip_nav.debug_info = dim.moveToUnmanaged(); | ||
| 1770 | switch (try codegen.generateSymbol( | ||
| 1771 | wip_nav.dwarf.bin_file, | ||
| 1772 | wip_nav.pt, | ||
| 1773 | src_loc, | ||
| 1774 | val, | ||
| 1775 | &dim, | ||
| 1776 | .{ .debug_output = .{ .dwarf = wip_nav } }, | ||
| 1777 | )) { | ||
| 1778 | .ok => assert(dim.items.len == wip_nav.debug_info.items.len + bytes), | ||
| 1779 | .fail => unreachable, | ||
| 1780 | } | ||
| 1781 | } | ||
| 1782 | |||
| 1752 | fn enumConstValue( | 1783 | fn enumConstValue( |
| 1753 | wip_nav: *WipNav, | 1784 | wip_nav: *WipNav, |
| 1754 | loaded_enum: InternPool.LoadedEnumType, | 1785 | loaded_enum: InternPool.LoadedEnumType, |
| ... | @@ -1814,8 +1845,8 @@ pub const WipNav = struct { | ... | @@ -1814,8 +1845,8 @@ pub const WipNav = struct { |
| 1814 | } | 1845 | } |
| 1815 | } | 1846 | } |
| 1816 | 1847 | ||
| 1817 | fn flush(wip_nav: *WipNav) UpdateError!void { | 1848 | fn flush(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void { |
| 1818 | while (wip_nav.pending_types.popOrNull()) |ty| try wip_nav.dwarf.updateType(wip_nav.pt, ty, &wip_nav.pending_types); | 1849 | while (wip_nav.pending_types.popOrNull()) |ty| try wip_nav.dwarf.updateType(wip_nav.pt, src_loc, ty, &wip_nav.pending_types); |
| 1819 | } | 1850 | } |
| 1820 | }; | 1851 | }; |
| 1821 | 1852 | ||
| ... | @@ -2171,15 +2202,15 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In | ... | @@ -2171,15 +2202,15 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2171 | try diw.writeByte(accessibility); | 2202 | try diw.writeByte(accessibility); |
| 2172 | try wip_nav.strp(nav.name.toSlice(ip)); | 2203 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2173 | try wip_nav.strp(nav.fqn.toSlice(ip)); | 2204 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| 2174 | const ty = nav_val.typeOf(zcu); | 2205 | const nav_ty = nav_val.typeOf(zcu); |
| 2175 | const ty_reloc_index = try wip_nav.refForward(); | 2206 | const nav_ty_reloc_index = try wip_nav.refForward(); |
| 2176 | try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } }); | 2207 | try wip_nav.exprloc(.{ .addr = .{ .sym = sym_index } }); |
| 2177 | try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse | 2208 | try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse |
| 2178 | ty.abiAlignment(zcu).toByteUnits().?); | 2209 | nav_ty.abiAlignment(zcu).toByteUnits().?); |
| 2179 | try diw.writeByte(@intFromBool(false)); | 2210 | try diw.writeByte(@intFromBool(false)); |
| 2180 | wip_nav.finishForward(ty_reloc_index); | 2211 | wip_nav.finishForward(nav_ty_reloc_index); |
| 2181 | try wip_nav.abbrevCode(.is_const); | 2212 | try wip_nav.abbrevCode(.is_const); |
| 2182 | try wip_nav.refType(ty); | 2213 | try wip_nav.refType(nav_ty); |
| 2183 | }, | 2214 | }, |
| 2184 | .variable => |variable| { | 2215 | .variable => |variable| { |
| 2185 | assert(file.zir_loaded); | 2216 | assert(file.zir_loaded); |
| ... | @@ -2288,20 +2319,16 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In | ... | @@ -2288,20 +2319,16 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2288 | .source_off = @intCast(wip_nav.debug_frame.items.len), | 2319 | .source_off = @intCast(wip_nav.debug_frame.items.len), |
| 2289 | }); | 2320 | }); |
| 2290 | try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes()); | 2321 | try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes()); |
| 2291 | try entry.external_relocs.append(dwarf.gpa, .{ | 2322 | try wip_nav.frameAddrSym(sym_index); |
| 2292 | .source_off = @intCast(wip_nav.debug_frame.items.len), | ||
| 2293 | .target_sym = sym_index, | ||
| 2294 | }); | ||
| 2295 | try dfw.writeByteNTimes(0, @intFromEnum(dwarf.address_size)); | ||
| 2296 | try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size)); | 2323 | try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size)); |
| 2297 | }, | 2324 | }, |
| 2298 | .eh_frame => { | 2325 | .eh_frame => { |
| 2299 | try dfw.writeInt(u32, undefined, dwarf.endian); | 2326 | try dfw.writeInt(u32, undefined, dwarf.endian); |
| 2300 | try entry.external_relocs.append(dwarf.gpa, .{ | 2327 | try wip_nav.frameExternalReloc(.{ |
| 2301 | .source_off = @intCast(wip_nav.debug_frame.items.len), | 2328 | .source_off = @intCast(wip_nav.debug_frame.items.len), |
| 2302 | .target_sym = sym_index, | 2329 | .target_sym = sym_index, |
| 2303 | }); | 2330 | }); |
| 2304 | try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes()); | 2331 | try dfw.writeInt(u32, 0, dwarf.endian); |
| 2305 | try dfw.writeInt(u32, undefined, dwarf.endian); | 2332 | try dfw.writeInt(u32, undefined, dwarf.endian); |
| 2306 | try uleb128(dfw, 0); | 2333 | try uleb128(dfw, 0); |
| 2307 | }, | 2334 | }, |
| ... | @@ -2481,12 +2508,13 @@ pub fn finishWipNav( | ... | @@ -2481,12 +2508,13 @@ pub fn finishWipNav( |
| 2481 | } | 2508 | } |
| 2482 | try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items); | 2509 | try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items); |
| 2483 | 2510 | ||
| 2484 | try wip_nav.flush(); | 2511 | try wip_nav.flush(zcu.navSrcLoc(nav_index)); |
| 2485 | } | 2512 | } |
| 2486 | 2513 | ||
| 2487 | pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) UpdateError!void { | 2514 | pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) UpdateError!void { |
| 2488 | const zcu = pt.zcu; | 2515 | const zcu = pt.zcu; |
| 2489 | const ip = &zcu.intern_pool; | 2516 | const ip = &zcu.intern_pool; |
| 2517 | const nav_src_loc = zcu.navSrcLoc(nav_index); | ||
| 2490 | const nav_val = zcu.navValue(nav_index); | 2518 | const nav_val = zcu.navValue(nav_index); |
| 2491 | 2519 | ||
| 2492 | const nav = ip.getNav(nav_index); | 2520 | const nav = ip.getNav(nav_index); |
| ... | @@ -2548,7 +2576,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2548,7 +2576,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2548 | const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index); | 2576 | const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index); |
| 2549 | errdefer _ = dwarf.navs.pop(); | 2577 | errdefer _ = dwarf.navs.pop(); |
| 2550 | 2578 | ||
| 2551 | const tag: enum { done, decl_alias } = switch (ip.indexToKey(nav_val.toIntern())) { | 2579 | const tag: enum { done, decl_alias, decl_const } = switch (ip.indexToKey(nav_val.toIntern())) { |
| 2552 | .int_type, | 2580 | .int_type, |
| 2553 | .ptr_type, | 2581 | .ptr_type, |
| 2554 | .array_type, | 2582 | .array_type, |
| ... | @@ -2623,7 +2651,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2623,7 +2651,10 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2623 | } | 2651 | } |
| 2624 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 2652 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 2625 | try wip_nav.refType(field_type); | 2653 | try wip_nav.refType(field_type); |
| 2626 | if (!is_comptime) { | 2654 | if (is_comptime) try wip_nav.blockValue( |
| 2655 | nav_src_loc, | ||
| 2656 | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), | ||
| 2657 | ) else { | ||
| 2627 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | 2658 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 2628 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 2659 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 2629 | field_type.abiAlignment(zcu).toByteUnits().?); | 2660 | field_type.abiAlignment(zcu).toByteUnits().?); |
| ... | @@ -2850,7 +2881,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2850,7 +2881,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2850 | }, | 2881 | }, |
| 2851 | .undef, | 2882 | .undef, |
| 2852 | .simple_value, | 2883 | .simple_value, |
| 2853 | .variable, | ||
| 2854 | .@"extern", | 2884 | .@"extern", |
| 2855 | .int, | 2885 | .int, |
| 2856 | .err, | 2886 | .err, |
| ... | @@ -2864,10 +2894,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2864,10 +2894,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2864 | .opt, | 2894 | .opt, |
| 2865 | .aggregate, | 2895 | .aggregate, |
| 2866 | .un, | 2896 | .un, |
| 2867 | => { | 2897 | => .decl_const, |
| 2868 | _ = dwarf.navs.pop(); | 2898 | .variable => unreachable, |
| 2869 | return; | ||
| 2870 | }, | ||
| 2871 | .func => |func| tag: { | 2899 | .func => |func| tag: { |
| 2872 | if (nav_gop.found_existing) { | 2900 | if (nav_gop.found_existing) { |
| 2873 | const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit); | 2901 | const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit); |
| ... | @@ -2918,14 +2946,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2918,14 +2946,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2918 | // memoization, not types | 2946 | // memoization, not types |
| 2919 | .memoized_call => unreachable, | 2947 | .memoized_call => unreachable, |
| 2920 | }; | 2948 | }; |
| 2949 | if (tag != .done) { | ||
| 2950 | if (nav_gop.found_existing) | ||
| 2951 | dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear() | ||
| 2952 | else | ||
| 2953 | nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit); | ||
| 2954 | wip_nav.entry = nav_gop.value_ptr.*; | ||
| 2955 | } | ||
| 2921 | switch (tag) { | 2956 | switch (tag) { |
| 2922 | .done => {}, | 2957 | .done => {}, |
| 2923 | .decl_alias => { | 2958 | .decl_alias => { |
| 2924 | if (nav_gop.found_existing) | ||
| 2925 | dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear() | ||
| 2926 | else | ||
| 2927 | nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit); | ||
| 2928 | wip_nav.entry = nav_gop.value_ptr.*; | ||
| 2929 | const diw = wip_nav.debug_info.writer(dwarf.gpa); | 2959 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2930 | try wip_nav.abbrevCode(.decl_alias); | 2960 | try wip_nav.abbrevCode(.decl_alias); |
| 2931 | try wip_nav.refType(Type.fromInterned(parent_type)); | 2961 | try wip_nav.refType(Type.fromInterned(parent_type)); |
| ... | @@ -2936,14 +2966,35 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2936,14 +2966,35 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2936 | try wip_nav.strp(nav.name.toSlice(ip)); | 2966 | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2937 | try wip_nav.refType(nav_val.toType()); | 2967 | try wip_nav.refType(nav_val.toType()); |
| 2938 | }, | 2968 | }, |
| 2969 | .decl_const => { | ||
| 2970 | const diw = wip_nav.debug_info.writer(dwarf.gpa); | ||
| 2971 | try wip_nav.abbrevCode(.decl_const); | ||
| 2972 | try wip_nav.refType(Type.fromInterned(parent_type)); | ||
| 2973 | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); | ||
| 2974 | try diw.writeInt(u32, @intCast(loc.line + 1), dwarf.endian); | ||
| 2975 | try uleb128(diw, loc.column + 1); | ||
| 2976 | try diw.writeByte(accessibility); | ||
| 2977 | try wip_nav.strp(nav.name.toSlice(ip)); | ||
| 2978 | try wip_nav.strp(nav.fqn.toSlice(ip)); | ||
| 2979 | const nav_ty = nav_val.typeOf(zcu); | ||
| 2980 | const nav_ty_reloc_index = try wip_nav.refForward(); | ||
| 2981 | try wip_nav.blockValue(nav_src_loc, nav_val); | ||
| 2982 | try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse | ||
| 2983 | nav_ty.abiAlignment(zcu).toByteUnits().?); | ||
| 2984 | try diw.writeByte(@intFromBool(false)); | ||
| 2985 | wip_nav.finishForward(nav_ty_reloc_index); | ||
| 2986 | try wip_nav.abbrevCode(.is_const); | ||
| 2987 | try wip_nav.refType(nav_ty); | ||
| 2988 | }, | ||
| 2939 | } | 2989 | } |
| 2940 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); | 2990 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); |
| 2941 | try wip_nav.flush(); | 2991 | try wip_nav.flush(nav_src_loc); |
| 2942 | } | 2992 | } |
| 2943 | 2993 | ||
| 2944 | fn updateType( | 2994 | fn updateType( |
| 2945 | dwarf: *Dwarf, | 2995 | dwarf: *Dwarf, |
| 2946 | pt: Zcu.PerThread, | 2996 | pt: Zcu.PerThread, |
| 2997 | src_loc: Zcu.LazySrcLoc, | ||
| 2947 | type_index: InternPool.Index, | 2998 | type_index: InternPool.Index, |
| 2948 | pending_types: *std.ArrayListUnmanaged(InternPool.Index), | 2999 | pending_types: *std.ArrayListUnmanaged(InternPool.Index), |
| 2949 | ) UpdateError!void { | 3000 | ) UpdateError!void { |
| ... | @@ -3000,15 +3051,10 @@ fn updateType( | ... | @@ -3000,15 +3051,10 @@ fn updateType( |
| 3000 | const ptr_child_type = Type.fromInterned(ptr_type.child); | 3051 | const ptr_child_type = Type.fromInterned(ptr_type.child); |
| 3001 | try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type); | 3052 | try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type); |
| 3002 | try wip_nav.strp(name); | 3053 | try wip_nav.strp(name); |
| 3003 | if (ptr_type.sentinel != .none) { | 3054 | if (ptr_type.sentinel != .none) try wip_nav.blockValue( |
| 3004 | const bytes = ptr_child_type.abiSize(zcu); | 3055 | src_loc, |
| 3005 | try uleb128(diw, bytes); | 3056 | Value.fromInterned(ptr_type.sentinel), |
| 3006 | const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes)); | 3057 | ); |
| 3007 | Value.fromInterned(ptr_type.sentinel).writeToMemory(pt, mem) catch |err| switch (err) { | ||
| 3008 | error.IllDefinedMemoryLayout => @memset(mem, 0), | ||
| 3009 | else => |e| return e, | ||
| 3010 | }; | ||
| 3011 | } | ||
| 3012 | try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse | 3058 | try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse |
| 3013 | ptr_child_type.abiAlignment(zcu).toByteUnits().?); | 3059 | ptr_child_type.abiAlignment(zcu).toByteUnits().?); |
| 3014 | try diw.writeByte(@intFromEnum(ptr_type.flags.address_space)); | 3060 | try diw.writeByte(@intFromEnum(ptr_type.flags.address_space)); |
| ... | @@ -3054,15 +3100,10 @@ fn updateType( | ... | @@ -3054,15 +3100,10 @@ fn updateType( |
| 3054 | const array_child_type = Type.fromInterned(array_type.child); | 3100 | const array_child_type = Type.fromInterned(array_type.child); |
| 3055 | try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type); | 3101 | try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type); |
| 3056 | try wip_nav.strp(name); | 3102 | try wip_nav.strp(name); |
| 3057 | if (array_type.sentinel != .none) { | 3103 | if (array_type.sentinel != .none) try wip_nav.blockValue( |
| 3058 | const bytes = array_child_type.abiSize(zcu); | 3104 | src_loc, |
| 3059 | try uleb128(diw, bytes); | 3105 | Value.fromInterned(array_type.sentinel), |
| 3060 | const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes)); | 3106 | ); |
| 3061 | Value.fromInterned(array_type.sentinel).writeToMemory(pt, mem) catch |err| switch (err) { | ||
| 3062 | error.IllDefinedMemoryLayout => @memset(mem, 0), | ||
| 3063 | else => |e| return e, | ||
| 3064 | }; | ||
| 3065 | } | ||
| 3066 | try wip_nav.refType(array_child_type); | 3107 | try wip_nav.refType(array_child_type); |
| 3067 | try wip_nav.abbrevCode(.array_index); | 3108 | try wip_nav.abbrevCode(.array_index); |
| 3068 | try wip_nav.refType(Type.usize); | 3109 | try wip_nav.refType(Type.usize); |
| ... | @@ -3292,7 +3333,10 @@ fn updateType( | ... | @@ -3292,7 +3333,10 @@ fn updateType( |
| 3292 | } | 3333 | } |
| 3293 | const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]); | 3334 | const field_type = Type.fromInterned(anon_struct_type.types.get(ip)[field_index]); |
| 3294 | try wip_nav.refType(field_type); | 3335 | try wip_nav.refType(field_type); |
| 3295 | if (comptime_value == .none) { | 3336 | if (comptime_value != .none) try wip_nav.blockValue( |
| 3337 | src_loc, | ||
| 3338 | Value.fromInterned(comptime_value), | ||
| 3339 | ) else { | ||
| 3296 | const field_align = field_type.abiAlignment(zcu); | 3340 | const field_align = field_type.abiAlignment(zcu); |
| 3297 | field_byte_offset = field_align.forward(field_byte_offset); | 3341 | field_byte_offset = field_align.forward(field_byte_offset); |
| 3298 | try uleb128(diw, field_byte_offset); | 3342 | try uleb128(diw, field_byte_offset); |
| ... | @@ -3359,16 +3403,13 @@ fn updateType( | ... | @@ -3359,16 +3403,13 @@ fn updateType( |
| 3359 | } | 3403 | } |
| 3360 | if (error_set_type.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 3404 | if (error_set_type.names.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3361 | }, | 3405 | }, |
| 3362 | .inferred_error_set_type => |func| switch (ip.funcIesResolvedUnordered(func)) { | 3406 | .inferred_error_set_type => |func| { |
| 3363 | .none => { | 3407 | try wip_nav.abbrevCode(.inferred_error_set_type); |
| 3364 | try wip_nav.abbrevCode(.void_type); | 3408 | try wip_nav.strp(name); |
| 3365 | try wip_nav.strp(name); | 3409 | try wip_nav.refType(Type.fromInterned(switch (ip.funcIesResolvedUnordered(func)) { |
| 3366 | }, | 3410 | .none => .anyerror_type, |
| 3367 | else => |ies| { | 3411 | else => |ies| ies, |
| 3368 | try wip_nav.abbrevCode(.inferred_error_set_type); | 3412 | })); |
| 3369 | try wip_nav.strp(name); | ||
| 3370 | try wip_nav.refType(Type.fromInterned(ies)); | ||
| 3371 | }, | ||
| 3372 | }, | 3413 | }, |
| 3373 | 3414 | ||
| 3374 | // values, not types | 3415 | // values, not types |
| ... | @@ -3400,6 +3441,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3400,6 +3441,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3400 | const zcu = pt.zcu; | 3441 | const zcu = pt.zcu; |
| 3401 | const ip = &zcu.intern_pool; | 3442 | const ip = &zcu.intern_pool; |
| 3402 | const ty = Type.fromInterned(type_index); | 3443 | const ty = Type.fromInterned(type_index); |
| 3444 | const ty_src_loc = ty.srcLoc(zcu); | ||
| 3403 | log.debug("updateContainerType({}({d}))", .{ ty.fmt(pt), @intFromEnum(type_index) }); | 3445 | log.debug("updateContainerType({}({d}))", .{ ty.fmt(pt), @intFromEnum(type_index) }); |
| 3404 | 3446 | ||
| 3405 | const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?; | 3447 | const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?; |
| ... | @@ -3447,7 +3489,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3447,7 +3489,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3447 | } | 3489 | } |
| 3448 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 3490 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3449 | try wip_nav.refType(field_type); | 3491 | try wip_nav.refType(field_type); |
| 3450 | if (!is_comptime) { | 3492 | if (is_comptime) try wip_nav.blockValue( |
| 3493 | ty_src_loc, | ||
| 3494 | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), | ||
| 3495 | ) else { | ||
| 3451 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | 3496 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 3452 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 3497 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3453 | field_type.abiAlignment(zcu).toByteUnits().?); | 3498 | field_type.abiAlignment(zcu).toByteUnits().?); |
| ... | @@ -3457,7 +3502,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3457,7 +3502,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3457 | } | 3502 | } |
| 3458 | 3503 | ||
| 3459 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); | 3504 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); |
| 3460 | try wip_nav.flush(); | 3505 | try wip_nav.flush(ty_src_loc); |
| 3461 | } else { | 3506 | } else { |
| 3462 | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); | 3507 | const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst)); |
| 3463 | assert(decl_inst.tag == .extended); | 3508 | assert(decl_inst.tag == .extended); |
| ... | @@ -3515,7 +3560,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3515,7 +3560,10 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3515 | } | 3560 | } |
| 3516 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 3561 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3517 | try wip_nav.refType(field_type); | 3562 | try wip_nav.refType(field_type); |
| 3518 | if (!is_comptime) { | 3563 | if (is_comptime) try wip_nav.blockValue( |
| 3564 | ty_src_loc, | ||
| 3565 | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), | ||
| 3566 | ) else { | ||
| 3519 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | 3567 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 3520 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 3568 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3521 | field_type.abiAlignment(zcu).toByteUnits().?); | 3569 | field_type.abiAlignment(zcu).toByteUnits().?); |
| ... | @@ -3616,7 +3664,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3616,7 +3664,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3616 | } | 3664 | } |
| 3617 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); | 3665 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); |
| 3618 | try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items); | 3666 | try dwarf.debug_loclists.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_loclists.items); |
| 3619 | try wip_nav.flush(); | 3667 | try wip_nav.flush(ty_src_loc); |
| 3620 | } | 3668 | } |
| 3621 | } | 3669 | } |
| 3622 | 3670 | ||
| ... | @@ -4085,6 +4133,7 @@ const AbbrevCode = enum { | ... | @@ -4085,6 +4133,7 @@ const AbbrevCode = enum { |
| 4085 | decl_packed_struct, | 4133 | decl_packed_struct, |
| 4086 | decl_union, | 4134 | decl_union, |
| 4087 | decl_var, | 4135 | decl_var, |
| 4136 | decl_const, | ||
| 4088 | decl_func, | 4137 | decl_func, |
| 4089 | decl_empty_func, | 4138 | decl_empty_func, |
| 4090 | decl_func_generic, | 4139 | decl_func_generic, |
| ... | @@ -4220,6 +4269,16 @@ const AbbrevCode = enum { | ... | @@ -4220,6 +4269,16 @@ const AbbrevCode = enum { |
| 4220 | .{ .external, .flag }, | 4269 | .{ .external, .flag }, |
| 4221 | }, | 4270 | }, |
| 4222 | }, | 4271 | }, |
| 4272 | .decl_const = .{ | ||
| 4273 | .tag = .constant, | ||
| 4274 | .attrs = decl_abbrev_common_attrs ++ .{ | ||
| 4275 | .{ .linkage_name, .strp }, | ||
| 4276 | .{ .type, .ref_addr }, | ||
| 4277 | .{ .const_value, .block }, | ||
| 4278 | .{ .alignment, .udata }, | ||
| 4279 | .{ .external, .flag }, | ||
| 4280 | }, | ||
| 4281 | }, | ||
| 4223 | .decl_func = .{ | 4282 | .decl_func = .{ |
| 4224 | .tag = .subprogram, | 4283 | .tag = .subprogram, |
| 4225 | .children = true, | 4284 | .children = true, |
| ... | @@ -4339,9 +4398,10 @@ const AbbrevCode = enum { | ... | @@ -4339,9 +4398,10 @@ const AbbrevCode = enum { |
| 4339 | .struct_field_comptime = .{ | 4398 | .struct_field_comptime = .{ |
| 4340 | .tag = .member, | 4399 | .tag = .member, |
| 4341 | .attrs = &.{ | 4400 | .attrs = &.{ |
| 4401 | .{ .const_expr, .flag_present }, | ||
| 4342 | .{ .name, .strp }, | 4402 | .{ .name, .strp }, |
| 4343 | .{ .type, .ref_addr }, | 4403 | .{ .type, .ref_addr }, |
| 4344 | .{ .const_expr, .flag_present }, | 4404 | .{ .default_value, .block }, |
| 4345 | }, | 4405 | }, |
| 4346 | }, | 4406 | }, |
| 4347 | .packed_struct_field = .{ | 4407 | .packed_struct_field = .{ |
src/link/Elf/ZigObject.zig+43-20| ... | @@ -957,13 +957,26 @@ pub fn getNavVAddr( | ... | @@ -957,13 +957,26 @@ pub fn getNavVAddr( |
| 957 | }; | 957 | }; |
| 958 | const this_sym = self.symbol(this_sym_index); | 958 | const this_sym = self.symbol(this_sym_index); |
| 959 | const vaddr = this_sym.address(.{}, elf_file); | 959 | const vaddr = this_sym.address(.{}, elf_file); |
| 960 | const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?; | 960 | switch (reloc_info.parent) { |
| 961 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); | 961 | .atom_index => |atom_index| { |
| 962 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ | 962 | const parent_atom = self.symbol(atom_index).atom(elf_file).?; |
| 963 | .r_offset = reloc_info.offset, | 963 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); |
| 964 | .r_info = (@as(u64, @intCast(this_sym_index)) << 32) | r_type, | 964 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ |
| 965 | .r_addend = reloc_info.addend, | 965 | .r_offset = reloc_info.offset, |
| 966 | }, self); | 966 | .r_info = (@as(u64, @intCast(this_sym_index)) << 32) | r_type, |
| 967 | .r_addend = reloc_info.addend, | ||
| 968 | }, self); | ||
| 969 | }, | ||
| 970 | .debug_output => |debug_output| switch (debug_output) { | ||
| 971 | .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{ | ||
| 972 | .source_off = @intCast(reloc_info.offset), | ||
| 973 | .target_sym = this_sym_index, | ||
| 974 | .target_off = reloc_info.addend, | ||
| 975 | }), | ||
| 976 | .plan9 => unreachable, | ||
| 977 | .none => unreachable, | ||
| 978 | }, | ||
| 979 | } | ||
| 967 | return @intCast(vaddr); | 980 | return @intCast(vaddr); |
| 968 | } | 981 | } |
| 969 | 982 | ||
| ... | @@ -976,13 +989,26 @@ pub fn getUavVAddr( | ... | @@ -976,13 +989,26 @@ pub fn getUavVAddr( |
| 976 | const sym_index = self.uavs.get(uav).?.symbol_index; | 989 | const sym_index = self.uavs.get(uav).?.symbol_index; |
| 977 | const sym = self.symbol(sym_index); | 990 | const sym = self.symbol(sym_index); |
| 978 | const vaddr = sym.address(.{}, elf_file); | 991 | const vaddr = sym.address(.{}, elf_file); |
| 979 | const parent_atom = self.symbol(reloc_info.parent_atom_index).atom(elf_file).?; | 992 | switch (reloc_info.parent) { |
| 980 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); | 993 | .atom_index => |atom_index| { |
| 981 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ | 994 | const parent_atom = self.symbol(atom_index).atom(elf_file).?; |
| 982 | .r_offset = reloc_info.offset, | 995 | const r_type = relocation.encode(.abs, elf_file.getTarget().cpu.arch); |
| 983 | .r_info = (@as(u64, @intCast(sym_index)) << 32) | r_type, | 996 | try parent_atom.addReloc(elf_file.base.comp.gpa, .{ |
| 984 | .r_addend = reloc_info.addend, | 997 | .r_offset = reloc_info.offset, |
| 985 | }, self); | 998 | .r_info = (@as(u64, @intCast(sym_index)) << 32) | r_type, |
| 999 | .r_addend = reloc_info.addend, | ||
| 1000 | }, self); | ||
| 1001 | }, | ||
| 1002 | .debug_output => |debug_output| switch (debug_output) { | ||
| 1003 | .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{ | ||
| 1004 | .source_off = @intCast(reloc_info.offset), | ||
| 1005 | .target_sym = sym_index, | ||
| 1006 | .target_off = reloc_info.addend, | ||
| 1007 | }), | ||
| 1008 | .plan9 => unreachable, | ||
| 1009 | .none => unreachable, | ||
| 1010 | }, | ||
| 1011 | } | ||
| 986 | return @intCast(vaddr); | 1012 | return @intCast(vaddr); |
| 987 | } | 1013 | } |
| 988 | 1014 | ||
| ... | @@ -1600,15 +1626,13 @@ pub fn updateNav( | ... | @@ -1600,15 +1626,13 @@ pub fn updateNav( |
| 1600 | var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, nav_index, sym_index) else null; | 1626 | var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, nav_index, sym_index) else null; |
| 1601 | defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit(); | 1627 | defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit(); |
| 1602 | 1628 | ||
| 1603 | // TODO implement .debug_info for global variables | ||
| 1604 | const res = try codegen.generateSymbol( | 1629 | const res = try codegen.generateSymbol( |
| 1605 | &elf_file.base, | 1630 | &elf_file.base, |
| 1606 | pt, | 1631 | pt, |
| 1607 | zcu.navSrcLoc(nav_index), | 1632 | zcu.navSrcLoc(nav_index), |
| 1608 | Value.fromInterned(nav_init), | 1633 | Value.fromInterned(nav_init), |
| 1609 | &code_buffer, | 1634 | &code_buffer, |
| 1610 | if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none, | 1635 | .{ .atom_index = sym_index }, |
| 1611 | .{ .parent_atom_index = sym_index }, | ||
| 1612 | ); | 1636 | ); |
| 1613 | 1637 | ||
| 1614 | const code = switch (res) { | 1638 | const code = switch (res) { |
| ... | @@ -1691,7 +1715,7 @@ fn updateLazySymbol( | ... | @@ -1691,7 +1715,7 @@ fn updateLazySymbol( |
| 1691 | &required_alignment, | 1715 | &required_alignment, |
| 1692 | &code_buffer, | 1716 | &code_buffer, |
| 1693 | .none, | 1717 | .none, |
| 1694 | .{ .parent_atom_index = symbol_index }, | 1718 | .{ .atom_index = symbol_index }, |
| 1695 | ); | 1719 | ); |
| 1696 | const code = switch (res) { | 1720 | const code = switch (res) { |
| 1697 | .ok => code_buffer.items, | 1721 | .ok => code_buffer.items, |
| ... | @@ -1780,8 +1804,7 @@ fn lowerConst( | ... | @@ -1780,8 +1804,7 @@ fn lowerConst( |
| 1780 | src_loc, | 1804 | src_loc, |
| 1781 | val, | 1805 | val, |
| 1782 | &code_buffer, | 1806 | &code_buffer, |
| 1783 | .{ .none = {} }, | 1807 | .{ .atom_index = sym_index }, |
| 1784 | .{ .parent_atom_index = sym_index }, | ||
| 1785 | ); | 1808 | ); |
| 1786 | const code = switch (res) { | 1809 | const code = switch (res) { |
| 1787 | .ok => code_buffer.items, | 1810 | .ok => code_buffer.items, |
src/link/MachO/ZigObject.zig+62-34| ... | @@ -633,20 +633,33 @@ pub fn getNavVAddr( | ... | @@ -633,20 +633,33 @@ pub fn getNavVAddr( |
| 633 | }; | 633 | }; |
| 634 | const sym = self.symbols.items[sym_index]; | 634 | const sym = self.symbols.items[sym_index]; |
| 635 | const vaddr = sym.getAddress(.{}, macho_file); | 635 | const vaddr = sym.getAddress(.{}, macho_file); |
| 636 | const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?; | 636 | switch (reloc_info.parent) { |
| 637 | try parent_atom.addReloc(macho_file, .{ | 637 | .atom_index => |atom_index| { |
| 638 | .tag = .@"extern", | 638 | const parent_atom = self.symbols.items[atom_index].getAtom(macho_file).?; |
| 639 | .offset = @intCast(reloc_info.offset), | 639 | try parent_atom.addReloc(macho_file, .{ |
| 640 | .target = sym_index, | 640 | .tag = .@"extern", |
| 641 | .addend = reloc_info.addend, | 641 | .offset = @intCast(reloc_info.offset), |
| 642 | .type = .unsigned, | 642 | .target = sym_index, |
| 643 | .meta = .{ | 643 | .addend = reloc_info.addend, |
| 644 | .pcrel = false, | 644 | .type = .unsigned, |
| 645 | .has_subtractor = false, | 645 | .meta = .{ |
| 646 | .length = 3, | 646 | .pcrel = false, |
| 647 | .symbolnum = @intCast(sym.nlist_idx), | 647 | .has_subtractor = false, |
| 648 | .length = 3, | ||
| 649 | .symbolnum = @intCast(sym.nlist_idx), | ||
| 650 | }, | ||
| 651 | }); | ||
| 648 | }, | 652 | }, |
| 649 | }); | 653 | .debug_output => |debug_output| switch (debug_output) { |
| 654 | .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{ | ||
| 655 | .source_off = @intCast(reloc_info.offset), | ||
| 656 | .target_sym = sym_index, | ||
| 657 | .target_off = reloc_info.addend, | ||
| 658 | }), | ||
| 659 | .plan9 => unreachable, | ||
| 660 | .none => unreachable, | ||
| 661 | }, | ||
| 662 | } | ||
| 650 | return vaddr; | 663 | return vaddr; |
| 651 | } | 664 | } |
| 652 | 665 | ||
| ... | @@ -659,20 +672,33 @@ pub fn getUavVAddr( | ... | @@ -659,20 +672,33 @@ pub fn getUavVAddr( |
| 659 | const sym_index = self.uavs.get(uav).?.symbol_index; | 672 | const sym_index = self.uavs.get(uav).?.symbol_index; |
| 660 | const sym = self.symbols.items[sym_index]; | 673 | const sym = self.symbols.items[sym_index]; |
| 661 | const vaddr = sym.getAddress(.{}, macho_file); | 674 | const vaddr = sym.getAddress(.{}, macho_file); |
| 662 | const parent_atom = self.symbols.items[reloc_info.parent_atom_index].getAtom(macho_file).?; | 675 | switch (reloc_info.parent) { |
| 663 | try parent_atom.addReloc(macho_file, .{ | 676 | .atom_index => |atom_index| { |
| 664 | .tag = .@"extern", | 677 | const parent_atom = self.symbols.items[atom_index].getAtom(macho_file).?; |
| 665 | .offset = @intCast(reloc_info.offset), | 678 | try parent_atom.addReloc(macho_file, .{ |
| 666 | .target = sym_index, | 679 | .tag = .@"extern", |
| 667 | .addend = reloc_info.addend, | 680 | .offset = @intCast(reloc_info.offset), |
| 668 | .type = .unsigned, | 681 | .target = sym_index, |
| 669 | .meta = .{ | 682 | .addend = reloc_info.addend, |
| 670 | .pcrel = false, | 683 | .type = .unsigned, |
| 671 | .has_subtractor = false, | 684 | .meta = .{ |
| 672 | .length = 3, | 685 | .pcrel = false, |
| 673 | .symbolnum = @intCast(sym.nlist_idx), | 686 | .has_subtractor = false, |
| 687 | .length = 3, | ||
| 688 | .symbolnum = @intCast(sym.nlist_idx), | ||
| 689 | }, | ||
| 690 | }); | ||
| 674 | }, | 691 | }, |
| 675 | }); | 692 | .debug_output => |debug_output| switch (debug_output) { |
| 693 | .dwarf => |wip_nav| try wip_nav.infoExternalReloc(.{ | ||
| 694 | .source_off = @intCast(reloc_info.offset), | ||
| 695 | .target_sym = sym_index, | ||
| 696 | .target_off = reloc_info.addend, | ||
| 697 | }), | ||
| 698 | .plan9 => unreachable, | ||
| 699 | .none => unreachable, | ||
| 700 | }, | ||
| 701 | } | ||
| 676 | return vaddr; | 702 | return vaddr; |
| 677 | } | 703 | } |
| 678 | 704 | ||
| ... | @@ -903,8 +929,7 @@ pub fn updateNav( | ... | @@ -903,8 +929,7 @@ pub fn updateNav( |
| 903 | zcu.navSrcLoc(nav_index), | 929 | zcu.navSrcLoc(nav_index), |
| 904 | Value.fromInterned(nav_init), | 930 | Value.fromInterned(nav_init), |
| 905 | &code_buffer, | 931 | &code_buffer, |
| 906 | if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none, | 932 | .{ .atom_index = sym_index }, |
| 907 | .{ .parent_atom_index = sym_index }, | ||
| 908 | ); | 933 | ); |
| 909 | 934 | ||
| 910 | const code = switch (res) { | 935 | const code = switch (res) { |
| ... | @@ -1212,11 +1237,14 @@ fn lowerConst( | ... | @@ -1212,11 +1237,14 @@ fn lowerConst( |
| 1212 | const name_str = try self.addString(gpa, name); | 1237 | const name_str = try self.addString(gpa, name); |
| 1213 | const sym_index = try self.newSymbolWithAtom(gpa, name_str, macho_file); | 1238 | const sym_index = try self.newSymbolWithAtom(gpa, name_str, macho_file); |
| 1214 | 1239 | ||
| 1215 | const res = try codegen.generateSymbol(&macho_file.base, pt, src_loc, val, &code_buffer, .{ | 1240 | const res = try codegen.generateSymbol( |
| 1216 | .none = {}, | 1241 | &macho_file.base, |
| 1217 | }, .{ | 1242 | pt, |
| 1218 | .parent_atom_index = sym_index, | 1243 | src_loc, |
| 1219 | }); | 1244 | val, |
| 1245 | &code_buffer, | ||
| 1246 | .{ .atom_index = sym_index }, | ||
| 1247 | ); | ||
| 1220 | const code = switch (res) { | 1248 | const code = switch (res) { |
| 1221 | .ok => code_buffer.items, | 1249 | .ok => code_buffer.items, |
| 1222 | .fail => |em| return .{ .fail = em }, | 1250 | .fail => |em| return .{ .fail = em }, |
| ... | @@ -1378,7 +1406,7 @@ fn updateLazySymbol( | ... | @@ -1378,7 +1406,7 @@ fn updateLazySymbol( |
| 1378 | &required_alignment, | 1406 | &required_alignment, |
| 1379 | &code_buffer, | 1407 | &code_buffer, |
| 1380 | .none, | 1408 | .none, |
| 1381 | .{ .parent_atom_index = symbol_index }, | 1409 | .{ .atom_index = symbol_index }, |
| 1382 | ); | 1410 | ); |
| 1383 | const code = switch (res) { | 1411 | const code = switch (res) { |
| 1384 | .ok => code_buffer.items, | 1412 | .ok => code_buffer.items, |
src/link/Plan9.zig+17-18| ... | @@ -422,10 +422,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, | ... | @@ -422,10 +422,7 @@ pub fn updateFunc(self: *Plan9, pt: Zcu.PerThread, func_index: InternPool.Index, |
| 422 | ); | 422 | ); |
| 423 | const code = switch (res) { | 423 | const code = switch (res) { |
| 424 | .ok => try code_buffer.toOwnedSlice(), | 424 | .ok => try code_buffer.toOwnedSlice(), |
| 425 | .fail => |em| { | 425 | .fail => |em| return zcu.failed_codegen.put(gpa, func.owner_nav, em), |
| 426 | try zcu.failed_codegen.put(gpa, func.owner_nav, em); | ||
| 427 | return; | ||
| 428 | }, | ||
| 429 | }; | 426 | }; |
| 430 | self.getAtomPtr(atom_idx).code = .{ | 427 | self.getAtomPtr(atom_idx).code = .{ |
| 431 | .code_ptr = null, | 428 | .code_ptr = null, |
| ... | @@ -463,15 +460,17 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde | ... | @@ -463,15 +460,17 @@ pub fn updateNav(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Inde |
| 463 | var code_buffer = std.ArrayList(u8).init(gpa); | 460 | var code_buffer = std.ArrayList(u8).init(gpa); |
| 464 | defer code_buffer.deinit(); | 461 | defer code_buffer.deinit(); |
| 465 | // TODO we need the symbol index for symbol in the table of locals for the containing atom | 462 | // TODO we need the symbol index for symbol in the table of locals for the containing atom |
| 466 | const res = try codegen.generateSymbol(&self.base, pt, zcu.navSrcLoc(nav_index), nav_init, &code_buffer, .none, .{ | 463 | const res = try codegen.generateSymbol( |
| 467 | .parent_atom_index = @intCast(atom_idx), | 464 | &self.base, |
| 468 | }); | 465 | pt, |
| 466 | zcu.navSrcLoc(nav_index), | ||
| 467 | nav_init, | ||
| 468 | &code_buffer, | ||
| 469 | .{ .atom_index = @intCast(atom_idx) }, | ||
| 470 | ); | ||
| 469 | const code = switch (res) { | 471 | const code = switch (res) { |
| 470 | .ok => code_buffer.items, | 472 | .ok => code_buffer.items, |
| 471 | .fail => |em| { | 473 | .fail => |em| return zcu.failed_codegen.put(gpa, nav_index, em), |
| 472 | try zcu.failed_codegen.put(gpa, nav_index, em); | ||
| 473 | return; | ||
| 474 | }, | ||
| 475 | }; | 474 | }; |
| 476 | try self.data_nav_table.ensureUnusedCapacity(gpa, 1); | 475 | try self.data_nav_table.ensureUnusedCapacity(gpa, 1); |
| 477 | const duped_code = try gpa.dupe(u8, code); | 476 | const duped_code = try gpa.dupe(u8, code); |
| ... | @@ -1116,7 +1115,7 @@ fn updateLazySymbolAtom(self: *Plan9, pt: Zcu.PerThread, sym: File.LazySymbol, a | ... | @@ -1116,7 +1115,7 @@ fn updateLazySymbolAtom(self: *Plan9, pt: Zcu.PerThread, sym: File.LazySymbol, a |
| 1116 | &required_alignment, | 1115 | &required_alignment, |
| 1117 | &code_buffer, | 1116 | &code_buffer, |
| 1118 | .none, | 1117 | .none, |
| 1119 | .{ .parent_atom_index = @as(Atom.Index, @intCast(atom_index)) }, | 1118 | .{ .atom_index = @intCast(atom_index) }, |
| 1120 | ); | 1119 | ); |
| 1121 | const code = switch (res) { | 1120 | const code = switch (res) { |
| 1122 | .ok => code_buffer.items, | 1121 | .ok => code_buffer.items, |
| ... | @@ -1373,21 +1372,21 @@ pub fn getNavVAddr( | ... | @@ -1373,21 +1372,21 @@ pub fn getNavVAddr( |
| 1373 | log.debug("getDeclVAddr for {}", .{nav.name.fmt(ip)}); | 1372 | log.debug("getDeclVAddr for {}", .{nav.name.fmt(ip)}); |
| 1374 | if (ip.indexToKey(nav.status.resolved.val) == .@"extern") { | 1373 | if (ip.indexToKey(nav.status.resolved.val) == .@"extern") { |
| 1375 | if (nav.name.eqlSlice("etext", ip)) { | 1374 | if (nav.name.eqlSlice("etext", ip)) { |
| 1376 | try self.addReloc(reloc_info.parent_atom_index, .{ | 1375 | try self.addReloc(reloc_info.parent.atom_index, .{ |
| 1377 | .target = undefined, | 1376 | .target = undefined, |
| 1378 | .offset = reloc_info.offset, | 1377 | .offset = reloc_info.offset, |
| 1379 | .addend = reloc_info.addend, | 1378 | .addend = reloc_info.addend, |
| 1380 | .type = .special_etext, | 1379 | .type = .special_etext, |
| 1381 | }); | 1380 | }); |
| 1382 | } else if (nav.name.eqlSlice("edata", ip)) { | 1381 | } else if (nav.name.eqlSlice("edata", ip)) { |
| 1383 | try self.addReloc(reloc_info.parent_atom_index, .{ | 1382 | try self.addReloc(reloc_info.parent.atom_index, .{ |
| 1384 | .target = undefined, | 1383 | .target = undefined, |
| 1385 | .offset = reloc_info.offset, | 1384 | .offset = reloc_info.offset, |
| 1386 | .addend = reloc_info.addend, | 1385 | .addend = reloc_info.addend, |
| 1387 | .type = .special_edata, | 1386 | .type = .special_edata, |
| 1388 | }); | 1387 | }); |
| 1389 | } else if (nav.name.eqlSlice("end", ip)) { | 1388 | } else if (nav.name.eqlSlice("end", ip)) { |
| 1390 | try self.addReloc(reloc_info.parent_atom_index, .{ | 1389 | try self.addReloc(reloc_info.parent.atom_index, .{ |
| 1391 | .target = undefined, | 1390 | .target = undefined, |
| 1392 | .offset = reloc_info.offset, | 1391 | .offset = reloc_info.offset, |
| 1393 | .addend = reloc_info.addend, | 1392 | .addend = reloc_info.addend, |
| ... | @@ -1400,7 +1399,7 @@ pub fn getNavVAddr( | ... | @@ -1400,7 +1399,7 @@ pub fn getNavVAddr( |
| 1400 | // otherwise, we just add a relocation | 1399 | // otherwise, we just add a relocation |
| 1401 | const atom_index = try self.seeNav(pt, nav_index); | 1400 | const atom_index = try self.seeNav(pt, nav_index); |
| 1402 | // the parent_atom_index in this case is just the decl_index of the parent | 1401 | // the parent_atom_index in this case is just the decl_index of the parent |
| 1403 | try self.addReloc(reloc_info.parent_atom_index, .{ | 1402 | try self.addReloc(reloc_info.parent.atom_index, .{ |
| 1404 | .target = atom_index, | 1403 | .target = atom_index, |
| 1405 | .offset = reloc_info.offset, | 1404 | .offset = reloc_info.offset, |
| 1406 | .addend = reloc_info.addend, | 1405 | .addend = reloc_info.addend, |
| ... | @@ -1435,7 +1434,7 @@ pub fn lowerUav( | ... | @@ -1435,7 +1434,7 @@ pub fn lowerUav( |
| 1435 | gop.value_ptr.* = index; | 1434 | gop.value_ptr.* = index; |
| 1436 | // we need to free name latex | 1435 | // we need to free name latex |
| 1437 | var code_buffer = std.ArrayList(u8).init(gpa); | 1436 | var code_buffer = std.ArrayList(u8).init(gpa); |
| 1438 | const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{ .none = {} }, .{ .parent_atom_index = index }); | 1437 | const res = try codegen.generateSymbol(&self.base, pt, src_loc, val, &code_buffer, .{ .atom_index = index }); |
| 1439 | const code = switch (res) { | 1438 | const code = switch (res) { |
| 1440 | .ok => code_buffer.items, | 1439 | .ok => code_buffer.items, |
| 1441 | .fail => |em| return .{ .fail = em }, | 1440 | .fail => |em| return .{ .fail = em }, |
| ... | @@ -1459,7 +1458,7 @@ pub fn lowerUav( | ... | @@ -1459,7 +1458,7 @@ pub fn lowerUav( |
| 1459 | 1458 | ||
| 1460 | pub fn getUavVAddr(self: *Plan9, uav: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 { | 1459 | pub fn getUavVAddr(self: *Plan9, uav: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 { |
| 1461 | const atom_index = self.uavs.get(uav).?; | 1460 | const atom_index = self.uavs.get(uav).?; |
| 1462 | try self.addReloc(reloc_info.parent_atom_index, .{ | 1461 | try self.addReloc(reloc_info.parent.atom_index, .{ |
| 1463 | .target = atom_index, | 1462 | .target = atom_index, |
| 1464 | .offset = reloc_info.offset, | 1463 | .offset = reloc_info.offset, |
| 1465 | .addend = reloc_info.addend, | 1464 | .addend = reloc_info.addend, |
src/link/Wasm/ZigObject.zig+11-9| ... | @@ -277,8 +277,7 @@ pub fn updateNav( | ... | @@ -277,8 +277,7 @@ pub fn updateNav( |
| 277 | zcu.navSrcLoc(nav_index), | 277 | zcu.navSrcLoc(nav_index), |
| 278 | nav_init, | 278 | nav_init, |
| 279 | &code_writer, | 279 | &code_writer, |
| 280 | .none, | 280 | .{ .atom_index = @intFromEnum(atom.sym_index) }, |
| 281 | .{ .parent_atom_index = @intFromEnum(atom.sym_index) }, | ||
| 282 | ); | 281 | ); |
| 283 | 282 | ||
| 284 | const code = switch (res) { | 283 | const code = switch (res) { |
| ... | @@ -520,10 +519,7 @@ fn lowerConst( | ... | @@ -520,10 +519,7 @@ fn lowerConst( |
| 520 | src_loc, | 519 | src_loc, |
| 521 | val, | 520 | val, |
| 522 | &value_bytes, | 521 | &value_bytes, |
| 523 | .none, | 522 | .{ .atom_index = @intFromEnum(atom.sym_index) }, |
| 524 | .{ | ||
| 525 | .parent_atom_index = @intFromEnum(atom.sym_index), | ||
| 526 | }, | ||
| 527 | ); | 523 | ); |
| 528 | break :code switch (result) { | 524 | break :code switch (result) { |
| 529 | .ok => value_bytes.items, | 525 | .ok => value_bytes.items, |
| ... | @@ -762,8 +758,11 @@ pub fn getNavVAddr( | ... | @@ -762,8 +758,11 @@ pub fn getNavVAddr( |
| 762 | else => {}, | 758 | else => {}, |
| 763 | } | 759 | } |
| 764 | 760 | ||
| 765 | std.debug.assert(reloc_info.parent_atom_index != 0); | 761 | std.debug.assert(reloc_info.parent.atom_index != 0); |
| 766 | const atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?; | 762 | const atom_index = wasm_file.symbol_atom.get(.{ |
| 763 | .file = zig_object.index, | ||
| 764 | .index = @enumFromInt(reloc_info.parent.atom_index), | ||
| 765 | }).?; | ||
| 767 | const atom = wasm_file.getAtomPtr(atom_index); | 766 | const atom = wasm_file.getAtomPtr(atom_index); |
| 768 | const is_wasm32 = target.cpu.arch == .wasm32; | 767 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 769 | if (ip.isFunctionType(ip.getNav(nav_index).typeOf(ip))) { | 768 | if (ip.isFunctionType(ip.getNav(nav_index).typeOf(ip))) { |
| ... | @@ -800,7 +799,10 @@ pub fn getUavVAddr( | ... | @@ -800,7 +799,10 @@ pub fn getUavVAddr( |
| 800 | const atom_index = zig_object.uavs.get(uav).?; | 799 | const atom_index = zig_object.uavs.get(uav).?; |
| 801 | const target_symbol_index = @intFromEnum(wasm_file.getAtom(atom_index).sym_index); | 800 | const target_symbol_index = @intFromEnum(wasm_file.getAtom(atom_index).sym_index); |
| 802 | 801 | ||
| 803 | const parent_atom_index = wasm_file.symbol_atom.get(.{ .file = zig_object.index, .index = @enumFromInt(reloc_info.parent_atom_index) }).?; | 802 | const parent_atom_index = wasm_file.symbol_atom.get(.{ |
| 803 | .file = zig_object.index, | ||
| 804 | .index = @enumFromInt(reloc_info.parent.atom_index), | ||
| 805 | }).?; | ||
| 804 | const parent_atom = wasm_file.getAtomPtr(parent_atom_index); | 806 | const parent_atom = wasm_file.getAtomPtr(parent_atom_index); |
| 805 | const is_wasm32 = target.cpu.arch == .wasm32; | 807 | const is_wasm32 = target.cpu.arch == .wasm32; |
| 806 | const zcu = wasm_file.base.comp.zcu.?; | 808 | const zcu = wasm_file.base.comp.zcu.?; |