@@ -170,11 +170,6 @@ pub fn emitMir(emit: *Emit) Error!void {
170170 else if (emit .bin_file .cast (.macho )) | macho_file |
171171 macho_file .getZigObject ().? .getOrCreateMetadataForLazySymbol (macho_file , emit .pt , lazy_sym ) catch | err |
172172 return emit .fail ("{s} creating lazy symbol" , .{@errorName (err )})
173- else if (emit .bin_file .cast (.coff )) | coff_file |
174- if (coff_file .getOrCreateAtomForLazySymbol (emit .pt , lazy_sym )) | atom |
175- coff_file .getAtom (atom ).getSymbolIndex ().?
176- else | err |
177- return emit .fail ("{s} creating lazy symbol" , .{@errorName (err )})
178173 else if (emit .bin_file .cast (.coff2 )) | elf |
179174 @intFromEnum (try elf .lazySymbol (lazy_sym ))
180175 else
@@ -190,8 +185,6 @@ pub fn emitMir(emit: *Emit) Error!void {
190185 .type = .FUNC ,
191186 })) else if (emit .bin_file .cast (.macho )) | macho_file |
192187 try macho_file .getGlobalSymbol (extern_func .toSlice (& emit .lower .mir ).? , null )
193- else if (emit .bin_file .cast (.coff )) | coff_file |
194- try coff_file .getGlobalSymbol (extern_func .toSlice (& emit .lower .mir ).? , "compiler_rt" )
195188 else if (emit .bin_file .cast (.coff2 )) | coff | @intFromEnum (try coff .globalSymbol (
196189 extern_func .toSlice (& emit .lower .mir ).? ,
197190 switch (comp .compiler_rt_strat ) {
@@ -211,9 +204,7 @@ pub fn emitMir(emit: *Emit) Error!void {
211204 switch (lowered_inst .encoding .mnemonic ) {
212205 .call = > {
213206 reloc .target .type = .branch ;
214- if (emit .bin_file .cast (.coff )) | _ | try emit .encodeInst (try .new (.none , .call , &.{
215- .{ .mem = .initRip (.ptr , 0 ) },
216- }, emit .lower .target ), reloc_info ) else try emit .encodeInst (lowered_inst , reloc_info );
207+ try emit .encodeInst (lowered_inst , reloc_info );
217208 continue :lowered_inst ;
218209 },
219210 else = > {},
@@ -290,37 +281,6 @@ pub fn emitMir(emit: *Emit) Error!void {
290281 }, emit .lower .target ), reloc_info ),
291282 else = > unreachable ,
292283 }
293- } else if (emit .bin_file .cast (.coff )) | _ | {
294- if (reloc .target .is_extern ) switch (lowered_inst .encoding .mnemonic ) {
295- .lea = > try emit .encodeInst (try .new (.none , .mov , &.{
296- lowered_inst .ops [0 ],
297- .{ .mem = .initRip (.ptr , 0 ) },
298- }, emit .lower .target ), reloc_info ),
299- .mov = > {
300- const dst_reg = lowered_inst .ops [0 ].reg .to64 ();
301- try emit .encodeInst (try .new (.none , .mov , &.{
302- .{ .reg = dst_reg },
303- .{ .mem = .initRip (.ptr , 0 ) },
304- }, emit .lower .target ), reloc_info );
305- try emit .encodeInst (try .new (.none , .mov , &.{
306- lowered_inst .ops [0 ],
307- .{ .mem = .initSib (lowered_inst .ops [reloc .op_index ].mem .sib .ptr_size , .{ .base = .{
308- .reg = dst_reg ,
309- } }) },
310- }, emit .lower .target ), &.{});
311- },
312- else = > unreachable ,
313- } else switch (lowered_inst .encoding .mnemonic ) {
314- .lea = > try emit .encodeInst (try .new (.none , .lea , &.{
315- lowered_inst .ops [0 ],
316- .{ .mem = .initRip (.none , 0 ) },
317- }, emit .lower .target ), reloc_info ),
318- .mov = > try emit .encodeInst (try .new (.none , .mov , &.{
319- lowered_inst .ops [0 ],
320- .{ .mem = .initRip (lowered_inst .ops [reloc .op_index ].mem .sib .ptr_size , 0 ) },
321- }, emit .lower .target ), reloc_info ),
322- else = > unreachable ,
323- }
324284 } else if (emit .bin_file .cast (.coff2 )) | _ | {
325285 switch (lowered_inst .encoding .mnemonic ) {
326286 .lea = > try emit .encodeInst (try .new (.none , .lea , &.{
@@ -820,22 +780,7 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
820780 @enumFromInt (reloc .target .index ),
821781 reloc .off ,
822782 .{ .X86_64 = .@"32" },
823- ) else if (emit .bin_file .cast (.coff )) | coff_file | {
824- const atom_index = coff_file .getAtomIndexForSymbol (
825- .{ .sym_index = emit .atom_index , .file = null },
826- ).? ;
827- try coff_file .addRelocation (atom_index , .{
828- .type = if (reloc .target .is_extern ) .got else .direct ,
829- .target = if (reloc .target .is_extern )
830- coff_file .getGlobalByIndex (reloc .target .index )
831- else
832- .{ .sym_index = reloc .target .index , .file = null },
833- .offset = end_offset - 4 ,
834- .addend = @intCast (reloc .off ),
835- .pcrel = true ,
836- .length = 2 ,
837- });
838- } else if (emit .bin_file .cast (.coff2 )) | coff | try coff .addReloc (
783+ ) else if (emit .bin_file .cast (.coff2 )) | coff | try coff .addReloc (
839784 @enumFromInt (emit .atom_index ),
840785 end_offset - 4 ,
841786 @enumFromInt (reloc .target .index ),
@@ -873,21 +818,6 @@ fn encodeInst(emit: *Emit, lowered_inst: Instruction, reloc_info: []const RelocI
873818 .symbolnum = @intCast (reloc .target .index ),
874819 },
875820 });
876- } else if (emit .bin_file .cast (.coff )) | coff_file | {
877- const atom_index = coff_file .getAtomIndexForSymbol (
878- .{ .sym_index = emit .atom_index , .file = null },
879- ).? ;
880- try coff_file .addRelocation (atom_index , .{
881- .type = if (reloc .target .is_extern ) .import else .got ,
882- .target = if (reloc .target .is_extern )
883- coff_file .getGlobalByIndex (reloc .target .index )
884- else
885- .{ .sym_index = reloc .target .index , .file = null },
886- .offset = end_offset - 4 ,
887- .addend = @intCast (reloc .off ),
888- .pcrel = true ,
889- .length = 2 ,
890- });
891821 } else if (emit .bin_file .cast (.coff2 )) | coff | try coff .addReloc (
892822 @enumFromInt (emit .atom_index ),
893823 end_offset - 4 ,
0 commit comments