@@ -8,7 +8,7 @@ use rustc_middle::ty::{Instance, Ty, TyCtxt};
8
8
use rustc_middle:: { bug, span_bug, ty} ;
9
9
use rustc_span:: sym;
10
10
use rustc_target:: callconv:: { ArgAbi , FnAbi , PassMode } ;
11
- use rustc_target:: spec:: WasmCAbi ;
11
+ use rustc_target:: spec:: { BinaryFormat , WasmCAbi } ;
12
12
13
13
use crate :: common;
14
14
use crate :: traits:: { AsmCodegenMethods , BuilderMethods , GlobalAsmOperandRef , MiscCodegenMethods } ;
@@ -104,27 +104,6 @@ fn inline_to_global_operand<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
104
104
}
105
105
}
106
106
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
-
128
107
fn prefix_and_suffix < ' tcx > (
129
108
tcx : TyCtxt < ' tcx > ,
130
109
instance : Instance < ' tcx > ,
@@ -134,7 +113,7 @@ fn prefix_and_suffix<'tcx>(
134
113
) -> ( String , String ) {
135
114
use std:: fmt:: Write ;
136
115
137
- let asm_binary_format = AsmBinaryFormat :: from_target ( & tcx. sess . target ) ;
116
+ let asm_binary_format = & tcx. sess . target . binary_format ;
138
117
139
118
let is_arm = tcx. sess . target . arch == "arm" ;
140
119
let is_thumb = tcx. sess . unstable_target_features . contains ( & sym:: thumb_mode) ;
@@ -178,10 +157,13 @@ fn prefix_and_suffix<'tcx>(
178
157
}
179
158
Linkage :: LinkOnceAny | Linkage :: LinkOnceODR | Linkage :: WeakAny | Linkage :: WeakODR => {
180
159
match asm_binary_format {
181
- AsmBinaryFormat :: Elf | AsmBinaryFormat :: Coff | AsmBinaryFormat :: Wasm => {
160
+ BinaryFormat :: Elf
161
+ | BinaryFormat :: Coff
162
+ | BinaryFormat :: Wasm
163
+ | BinaryFormat :: Xcoff => {
182
164
writeln ! ( w, ".weak {asm_name}" ) ?;
183
165
}
184
- AsmBinaryFormat :: Macho => {
166
+ BinaryFormat :: MachO => {
185
167
writeln ! ( w, ".globl {asm_name}" ) ?;
186
168
writeln ! ( w, ".weak_definition {asm_name}" ) ?;
187
169
}
@@ -207,7 +189,7 @@ fn prefix_and_suffix<'tcx>(
207
189
let mut begin = String :: new ( ) ;
208
190
let mut end = String :: new ( ) ;
209
191
match asm_binary_format {
210
- AsmBinaryFormat :: Elf => {
192
+ BinaryFormat :: Elf | BinaryFormat :: Xcoff => {
211
193
let section = link_section. unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
212
194
213
195
let progbits = match is_arm {
@@ -239,7 +221,7 @@ fn prefix_and_suffix<'tcx>(
239
221
writeln ! ( end, "{}" , arch_suffix) . unwrap ( ) ;
240
222
}
241
223
}
242
- AsmBinaryFormat :: Macho => {
224
+ BinaryFormat :: MachO => {
243
225
let section = link_section. unwrap_or ( "__TEXT,__text" . to_string ( ) ) ;
244
226
writeln ! ( begin, ".pushsection {},regular,pure_instructions" , section) . unwrap ( ) ;
245
227
writeln ! ( begin, ".balign {align}" ) . unwrap ( ) ;
@@ -255,7 +237,7 @@ fn prefix_and_suffix<'tcx>(
255
237
writeln ! ( end, "{}" , arch_suffix) . unwrap ( ) ;
256
238
}
257
239
}
258
- AsmBinaryFormat :: Coff => {
240
+ BinaryFormat :: Coff => {
259
241
let section = link_section. unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
260
242
writeln ! ( begin, ".pushsection {},\" xr\" " , section) . unwrap ( ) ;
261
243
writeln ! ( begin, ".balign {align}" ) . unwrap ( ) ;
@@ -272,7 +254,7 @@ fn prefix_and_suffix<'tcx>(
272
254
writeln ! ( end, "{}" , arch_suffix) . unwrap ( ) ;
273
255
}
274
256
}
275
- AsmBinaryFormat :: Wasm => {
257
+ BinaryFormat :: Wasm => {
276
258
let section = link_section. unwrap_or ( format ! ( ".text.{asm_name}" ) ) ;
277
259
278
260
writeln ! ( begin, ".section {section},\" \" ,@" ) . unwrap ( ) ;
0 commit comments