@@ -8,7 +8,7 @@ use rustc_middle::ty::{Instance, Ty, TyCtxt};
88use  rustc_middle:: { bug,  span_bug,  ty} ; 
99use  rustc_span:: sym; 
1010use  rustc_target:: callconv:: { ArgAbi ,  FnAbi ,  PassMode } ; 
11- use  rustc_target:: spec:: WasmCAbi ; 
11+ use  rustc_target:: spec:: { BinaryFormat ,   WasmCAbi } ; 
1212
1313use  crate :: common; 
1414use  crate :: traits:: { AsmCodegenMethods ,  BuilderMethods ,  GlobalAsmOperandRef ,  MiscCodegenMethods } ; 
@@ -104,27 +104,6 @@ fn inline_to_global_operand<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
104104    } 
105105} 
106106
107- enum  AsmBinaryFormat  { 
108-     Elf , 
109-     Macho , 
110-     Coff , 
111-     Wasm , 
112- } 
113- 
114- impl  AsmBinaryFormat  { 
115-     fn  from_target ( target :  & rustc_target:: spec:: Target )  -> Self  { 
116-         if  target. is_like_windows  { 
117-             Self :: Coff 
118-         }  else  if  target. is_like_osx  { 
119-             Self :: Macho 
120-         }  else  if  target. is_like_wasm  { 
121-             Self :: Wasm 
122-         }  else  { 
123-             Self :: Elf 
124-         } 
125-     } 
126- } 
127- 
128107fn  prefix_and_suffix < ' tcx > ( 
129108    tcx :  TyCtxt < ' tcx > , 
130109    instance :  Instance < ' tcx > , 
@@ -134,7 +113,7 @@ fn prefix_and_suffix<'tcx>(
134113)  -> ( String ,  String )  { 
135114    use  std:: fmt:: Write ; 
136115
137-     let  asm_binary_format = AsmBinaryFormat :: from_target ( & tcx. sess . target ) ; 
116+     let  asm_binary_format = & tcx. sess . target . binary_format ; 
138117
139118    let  is_arm = tcx. sess . target . arch  == "arm" ; 
140119    let  is_thumb = tcx. sess . unstable_target_features . contains ( & sym:: thumb_mode) ; 
@@ -178,10 +157,13 @@ fn prefix_and_suffix<'tcx>(
178157            } 
179158            Linkage :: LinkOnceAny  | Linkage :: LinkOnceODR  | Linkage :: WeakAny  | Linkage :: WeakODR  => { 
180159                match  asm_binary_format { 
181-                     AsmBinaryFormat :: Elf  | AsmBinaryFormat :: Coff  | AsmBinaryFormat :: Wasm  => { 
160+                     BinaryFormat :: Elf 
161+                     | BinaryFormat :: Coff 
162+                     | BinaryFormat :: Wasm 
163+                     | BinaryFormat :: Xcoff  => { 
182164                        writeln ! ( w,  ".weak {asm_name}" ) ?; 
183165                    } 
184-                     AsmBinaryFormat :: Macho  => { 
166+                     BinaryFormat :: MachO  => { 
185167                        writeln ! ( w,  ".globl {asm_name}" ) ?; 
186168                        writeln ! ( w,  ".weak_definition {asm_name}" ) ?; 
187169                    } 
@@ -207,7 +189,7 @@ fn prefix_and_suffix<'tcx>(
207189    let  mut  begin = String :: new ( ) ; 
208190    let  mut  end = String :: new ( ) ; 
209191    match  asm_binary_format { 
210-         AsmBinaryFormat :: Elf  => { 
192+         BinaryFormat :: Elf  |  BinaryFormat :: Xcoff  => { 
211193            let  section = link_section. unwrap_or ( format ! ( ".text.{asm_name}" ) ) ; 
212194
213195            let  progbits = match  is_arm { 
@@ -239,7 +221,7 @@ fn prefix_and_suffix<'tcx>(
239221                writeln ! ( end,  "{}" ,  arch_suffix) . unwrap ( ) ; 
240222            } 
241223        } 
242-         AsmBinaryFormat :: Macho  => { 
224+         BinaryFormat :: MachO  => { 
243225            let  section = link_section. unwrap_or ( "__TEXT,__text" . to_string ( ) ) ; 
244226            writeln ! ( begin,  ".pushsection {},regular,pure_instructions" ,  section) . unwrap ( ) ; 
245227            writeln ! ( begin,  ".balign {align}" ) . unwrap ( ) ; 
@@ -255,7 +237,7 @@ fn prefix_and_suffix<'tcx>(
255237                writeln ! ( end,  "{}" ,  arch_suffix) . unwrap ( ) ; 
256238            } 
257239        } 
258-         AsmBinaryFormat :: Coff  => { 
240+         BinaryFormat :: Coff  => { 
259241            let  section = link_section. unwrap_or ( format ! ( ".text.{asm_name}" ) ) ; 
260242            writeln ! ( begin,  ".pushsection {},\" xr\" " ,  section) . unwrap ( ) ; 
261243            writeln ! ( begin,  ".balign {align}" ) . unwrap ( ) ; 
@@ -272,7 +254,7 @@ fn prefix_and_suffix<'tcx>(
272254                writeln ! ( end,  "{}" ,  arch_suffix) . unwrap ( ) ; 
273255            } 
274256        } 
275-         AsmBinaryFormat :: Wasm  => { 
257+         BinaryFormat :: Wasm  => { 
276258            let  section = link_section. unwrap_or ( format ! ( ".text.{asm_name}" ) ) ; 
277259
278260            writeln ! ( begin,  ".section {section},\" \" ,@" ) . unwrap ( ) ; 
0 commit comments