| author | |
| committer | |
| log | 02f38d7749e5260dc2f48caef10390dd8d3cede5 |
| tree | b20c72678ae41e51bfd6b9c1e10ab5aaa3112297 |
| parent | 89db24ec6d6195cc10f17bf21dd9bf23e6ff1bf1 |
2 files changed, 9 insertions(+), 19 deletions(-)
src/arch/riscv64/CodeGen.zig+4-12| ... | ... | @@ -1415,9 +1415,8 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void { |
| 1415 | 1415 | .ty = enum_ty, |
| 1416 | 1416 | }) catch |err| |
| 1417 | 1417 | return func.fail("{s} creating lazy symbol", .{@errorName(err)}); |
| 1418 | const sym = zo.symbol(sym_index); | |
| 1419 | 1418 | |
| 1420 | try func.genSetReg(Type.u64, data_reg, .{ .lea_symbol = .{ .sym = sym.esym_index } }); | |
| 1419 | try func.genSetReg(Type.u64, data_reg, .{ .lea_symbol = .{ .sym = sym_index } }); | |
| 1421 | 1420 | |
| 1422 | 1421 | const cmp_reg, const cmp_lock = try func.allocReg(.int); |
| 1423 | 1422 | defer func.register_manager.unlockReg(cmp_lock); |
| ... | ... | @@ -4949,12 +4948,11 @@ fn genCall( |
| 4949 | 4948 | if (func.bin_file.cast(link.File.Elf)) |elf_file| { |
| 4950 | 4949 | const zo = elf_file.zigObjectPtr().?; |
| 4951 | 4950 | const sym_index = try zo.getOrCreateMetadataForDecl(elf_file, func_val.owner_decl); |
| 4952 | const sym = zo.symbol(sym_index); | |
| 4953 | 4951 | |
| 4954 | 4952 | if (func.mod.pic) { |
| 4955 | 4953 | return func.fail("TODO: genCall pic", .{}); |
| 4956 | 4954 | } else { |
| 4957 | try func.genSetReg(Type.u64, .ra, .{ .load_symbol = .{ .sym = sym.esym_index } }); | |
| 4955 | try func.genSetReg(Type.u64, .ra, .{ .load_symbol = .{ .sym = sym_index } }); | |
| 4958 | 4956 | _ = try func.addInst(.{ |
| 4959 | 4957 | .tag = .jalr, |
| 4960 | 4958 | .data = .{ .i_type = .{ |
| ... | ... | @@ -7827,12 +7825,11 @@ fn airTagName(func: *Func, inst: Air.Inst.Index) !void { |
| 7827 | 7825 | const zo = elf_file.zigObjectPtr().?; |
| 7828 | 7826 | const sym_index = zo.getOrCreateMetadataForLazySymbol(elf_file, pt, lazy_sym) catch |err| |
| 7829 | 7827 | return func.fail("{s} creating lazy symbol", .{@errorName(err)}); |
| 7830 | const sym = zo.symbol(sym_index); | |
| 7831 | 7828 | |
| 7832 | 7829 | if (func.mod.pic) { |
| 7833 | 7830 | return func.fail("TODO: airTagName pic", .{}); |
| 7834 | 7831 | } else { |
| 7835 | try func.genSetReg(Type.u64, .ra, .{ .load_symbol = .{ .sym = sym.esym_index } }); | |
| 7832 | try func.genSetReg(Type.u64, .ra, .{ .load_symbol = .{ .sym = sym_index } }); | |
| 7836 | 7833 | _ = try func.addInst(.{ |
| 7837 | 7834 | .tag = .jalr, |
| 7838 | 7835 | .data = .{ .i_type = .{ |
| ... | ... | @@ -8050,12 +8047,7 @@ fn genTypedValue(func: *Func, val: Value) InnerError!MCValue { |
| 8050 | 8047 | return error.CodegenFail; |
| 8051 | 8048 | }; |
| 8052 | 8049 | switch (lf.tag) { |
| 8053 | .elf => { | |
| 8054 | const elf_file = lf.cast(link.File.Elf).?; | |
| 8055 | const zo = elf_file.zigObjectPtr().?; | |
| 8056 | const local = zo.symbol(local_sym_index); | |
| 8057 | return MCValue{ .undef = local.esym_index }; | |
| 8058 | }, | |
| 8050 | .elf => return MCValue{ .undef = local_sym_index }, | |
| 8059 | 8051 | else => unreachable, |
| 8060 | 8052 | } |
| 8061 | 8053 | } |
src/arch/x86_64/CodeGen.zig+5-7| ... | ... | @@ -12329,7 +12329,6 @@ fn genCall(self: *Self, info: union(enum) { |
| 12329 | 12329 | if (self.bin_file.cast(link.File.Elf)) |elf_file| { |
| 12330 | 12330 | const zo = elf_file.zigObjectPtr().?; |
| 12331 | 12331 | const sym_index = try zo.getOrCreateMetadataForDecl(elf_file, func.owner_decl); |
| 12332 | const sym = zo.symbol(sym_index); | |
| 12333 | 12332 | if (self.mod.pic) { |
| 12334 | 12333 | const callee_reg: Register = switch (resolved_cc) { |
| 12335 | 12334 | .SysV => callee: { |
| ... | ... | @@ -12346,14 +12345,14 @@ fn genCall(self: *Self, info: union(enum) { |
| 12346 | 12345 | try self.genSetReg( |
| 12347 | 12346 | callee_reg, |
| 12348 | 12347 | Type.usize, |
| 12349 | .{ .load_symbol = .{ .sym = sym.esym_index } }, | |
| 12348 | .{ .load_symbol = .{ .sym = sym_index } }, | |
| 12350 | 12349 | .{}, |
| 12351 | 12350 | ); |
| 12352 | 12351 | try self.asmRegister(.{ ._, .call }, callee_reg); |
| 12353 | 12352 | } else try self.asmMemory(.{ ._, .call }, .{ |
| 12354 | 12353 | .base = .{ .reloc = .{ |
| 12355 | 12354 | .atom_index = try self.owner.getSymbolIndex(self), |
| 12356 | .sym_index = sym.esym_index, | |
| 12355 | .sym_index = sym_index, | |
| 12357 | 12356 | } }, |
| 12358 | 12357 | .mod = .{ .rm = .{ .size = .qword } }, |
| 12359 | 12358 | }); |
| ... | ... | @@ -15324,14 +15323,13 @@ fn genLazySymbolRef( |
| 15324 | 15323 | const zo = elf_file.zigObjectPtr().?; |
| 15325 | 15324 | const sym_index = zo.getOrCreateMetadataForLazySymbol(elf_file, pt, lazy_sym) catch |err| |
| 15326 | 15325 | return self.fail("{s} creating lazy symbol", .{@errorName(err)}); |
| 15327 | const sym = zo.symbol(sym_index); | |
| 15328 | 15326 | if (self.mod.pic) { |
| 15329 | 15327 | switch (tag) { |
| 15330 | 15328 | .lea, .call => try self.genSetReg(reg, Type.usize, .{ |
| 15331 | .load_symbol = .{ .sym = sym.esym_index }, | |
| 15329 | .load_symbol = .{ .sym = sym_index }, | |
| 15332 | 15330 | }, .{}), |
| 15333 | 15331 | .mov => try self.genSetReg(reg, Type.usize, .{ |
| 15334 | .load_symbol = .{ .sym = sym.esym_index }, | |
| 15332 | .load_symbol = .{ .sym = sym_index }, | |
| 15335 | 15333 | }, .{}), |
| 15336 | 15334 | else => unreachable, |
| 15337 | 15335 | } |
| ... | ... | @@ -15343,7 +15341,7 @@ fn genLazySymbolRef( |
| 15343 | 15341 | } else { |
| 15344 | 15342 | const reloc = bits.Symbol{ |
| 15345 | 15343 | .atom_index = try self.owner.getSymbolIndex(self), |
| 15346 | .sym_index = sym.esym_index, | |
| 15344 | .sym_index = sym_index, | |
| 15347 | 15345 | }; |
| 15348 | 15346 | switch (tag) { |
| 15349 | 15347 | .lea, .mov => try self.asmRegisterMemory(.{ ._, .mov }, reg.to64(), .{ |