1
1
use rustc_abi:: { BackendRepr , Float , Integer , Primitive , RegKind } ;
2
2
use rustc_attr_parsing:: InstructionSetAttr ;
3
- use rustc_hir:: def_id:: DefId ;
4
3
use rustc_middle:: mir:: mono:: { Linkage , MonoItem , MonoItemData , Visibility } ;
5
4
use rustc_middle:: mir:: { Body , InlineAsmOperand } ;
6
5
use rustc_middle:: ty:: layout:: { FnAbiOf , HasTyCtxt , HasTypingEnv , LayoutOf } ;
7
6
use rustc_middle:: ty:: { Instance , Ty , TyCtxt } ;
8
- use rustc_middle:: { bug, span_bug , ty} ;
7
+ use rustc_middle:: { bug, ty} ;
9
8
use rustc_span:: sym;
10
9
use rustc_target:: callconv:: { ArgAbi , FnAbi , PassMode } ;
11
- use rustc_target:: spec:: { BinaryFormat , WasmCAbi } ;
10
+ use rustc_target:: spec:: BinaryFormat ;
12
11
13
12
use crate :: common;
14
13
use crate :: traits:: { AsmCodegenMethods , BuilderMethods , GlobalAsmOperandRef , MiscCodegenMethods } ;
@@ -268,12 +267,7 @@ fn prefix_and_suffix<'tcx>(
268
267
writeln ! ( begin, "{}" , arch_prefix) . unwrap ( ) ;
269
268
}
270
269
writeln ! ( begin, "{asm_name}:" ) . unwrap ( ) ;
271
- writeln ! (
272
- begin,
273
- ".functype {asm_name} {}" ,
274
- wasm_functype( tcx, fn_abi, instance. def_id( ) )
275
- )
276
- . unwrap ( ) ;
270
+ writeln ! ( begin, ".functype {asm_name} {}" , wasm_functype( tcx, fn_abi) ) . unwrap ( ) ;
277
271
278
272
writeln ! ( end) . unwrap ( ) ;
279
273
// .size is ignored for function symbols, so we can skip it
@@ -287,7 +281,7 @@ fn prefix_and_suffix<'tcx>(
287
281
/// The webassembly type signature for the given function.
288
282
///
289
283
/// Used by the `.functype` directive on wasm targets.
290
- fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > , def_id : DefId ) -> String {
284
+ fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ) -> String {
291
285
let mut signature = String :: with_capacity ( 64 ) ;
292
286
293
287
let ptr_type = match tcx. data_layout . pointer_size . bits ( ) {
@@ -296,17 +290,6 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
296
290
other => bug ! ( "wasm pointer size cannot be {other} bits" ) ,
297
291
} ;
298
292
299
- // FIXME: remove this once the wasm32-unknown-unknown ABI is fixed
300
- // please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
301
- // basically the commit introducing this comment should be reverted
302
- if let PassMode :: Pair { .. } = fn_abi. ret . mode {
303
- let _ = WasmCAbi :: Legacy ;
304
- span_bug ! (
305
- tcx. def_span( def_id) ,
306
- "cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
307
- ) ;
308
- }
309
-
310
293
let hidden_return = matches ! ( fn_abi. ret. mode, PassMode :: Indirect { .. } ) ;
311
294
312
295
signature. push ( '(' ) ;
@@ -320,7 +303,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
320
303
321
304
let mut it = fn_abi. args . iter ( ) . peekable ( ) ;
322
305
while let Some ( arg_abi) = it. next ( ) {
323
- wasm_type ( tcx , & mut signature, arg_abi, ptr_type, def_id ) ;
306
+ wasm_type ( & mut signature, arg_abi, ptr_type) ;
324
307
if it. peek ( ) . is_some ( ) {
325
308
signature. push_str ( ", " ) ;
326
309
}
@@ -329,35 +312,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
329
312
signature. push_str ( ") -> (" ) ;
330
313
331
314
if !hidden_return {
332
- wasm_type ( tcx , & mut signature, & fn_abi. ret , ptr_type, def_id ) ;
315
+ wasm_type ( & mut signature, & fn_abi. ret , ptr_type) ;
333
316
}
334
317
335
318
signature. push ( ')' ) ;
336
319
337
320
signature
338
321
}
339
322
340
- fn wasm_type < ' tcx > (
341
- tcx : TyCtxt < ' tcx > ,
342
- signature : & mut String ,
343
- arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > ,
344
- ptr_type : & ' static str ,
345
- def_id : DefId ,
346
- ) {
323
+ fn wasm_type < ' tcx > ( signature : & mut String , arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > , ptr_type : & ' static str ) {
347
324
match arg_abi. mode {
348
325
PassMode :: Ignore => { /* do nothing */ }
349
326
PassMode :: Direct ( _) => {
350
327
let direct_type = match arg_abi. layout . backend_repr {
351
328
BackendRepr :: Scalar ( scalar) => wasm_primitive ( scalar. primitive ( ) , ptr_type) ,
352
329
BackendRepr :: Vector { .. } => "v128" ,
353
- BackendRepr :: Memory { .. } => {
354
- // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
355
- let _ = WasmCAbi :: Legacy ;
356
- span_bug ! (
357
- tcx. def_span( def_id) ,
358
- "cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
359
- ) ;
360
- }
361
330
other => unreachable ! ( "unexpected BackendRepr: {:?}" , other) ,
362
331
} ;
363
332
0 commit comments