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:: WasmCAbi ;
12
10
13
11
use crate :: common;
14
12
use crate :: traits:: { AsmCodegenMethods , BuilderMethods , GlobalAsmOperandRef , MiscCodegenMethods } ;
@@ -287,12 +285,7 @@ fn prefix_and_suffix<'tcx>(
287
285
writeln ! ( begin, "{}" , arch_prefix) . unwrap ( ) ;
288
286
}
289
287
writeln ! ( begin, "{asm_name}:" ) . unwrap ( ) ;
290
- writeln ! (
291
- begin,
292
- ".functype {asm_name} {}" ,
293
- wasm_functype( tcx, fn_abi, instance. def_id( ) )
294
- )
295
- . unwrap ( ) ;
288
+ writeln ! ( begin, ".functype {asm_name} {}" , wasm_functype( tcx, fn_abi) ) . unwrap ( ) ;
296
289
297
290
writeln ! ( end) . unwrap ( ) ;
298
291
// .size is ignored for function symbols, so we can skip it
@@ -306,7 +299,7 @@ fn prefix_and_suffix<'tcx>(
306
299
/// The webassembly type signature for the given function.
307
300
///
308
301
/// Used by the `.functype` directive on wasm targets.
309
- fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > , def_id : DefId ) -> String {
302
+ fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ) -> String {
310
303
let mut signature = String :: with_capacity ( 64 ) ;
311
304
312
305
let ptr_type = match tcx. data_layout . pointer_size . bits ( ) {
@@ -315,17 +308,6 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
315
308
other => bug ! ( "wasm pointer size cannot be {other} bits" ) ,
316
309
} ;
317
310
318
- // FIXME: remove this once the wasm32-unknown-unknown ABI is fixed
319
- // please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
320
- // basically the commit introducing this comment should be reverted
321
- if let PassMode :: Pair { .. } = fn_abi. ret . mode {
322
- let _ = WasmCAbi :: Legacy ;
323
- span_bug ! (
324
- tcx. def_span( def_id) ,
325
- "cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
326
- ) ;
327
- }
328
-
329
311
let hidden_return = matches ! ( fn_abi. ret. mode, PassMode :: Indirect { .. } ) ;
330
312
331
313
signature. push ( '(' ) ;
@@ -339,7 +321,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
339
321
340
322
let mut it = fn_abi. args . iter ( ) . peekable ( ) ;
341
323
while let Some ( arg_abi) = it. next ( ) {
342
- wasm_type ( tcx , & mut signature, arg_abi, ptr_type, def_id ) ;
324
+ wasm_type ( & mut signature, arg_abi, ptr_type) ;
343
325
if it. peek ( ) . is_some ( ) {
344
326
signature. push_str ( ", " ) ;
345
327
}
@@ -348,35 +330,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
348
330
signature. push_str ( ") -> (" ) ;
349
331
350
332
if !hidden_return {
351
- wasm_type ( tcx , & mut signature, & fn_abi. ret , ptr_type, def_id ) ;
333
+ wasm_type ( & mut signature, & fn_abi. ret , ptr_type) ;
352
334
}
353
335
354
336
signature. push ( ')' ) ;
355
337
356
338
signature
357
339
}
358
340
359
- fn wasm_type < ' tcx > (
360
- tcx : TyCtxt < ' tcx > ,
361
- signature : & mut String ,
362
- arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > ,
363
- ptr_type : & ' static str ,
364
- def_id : DefId ,
365
- ) {
341
+ fn wasm_type < ' tcx > ( signature : & mut String , arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > , ptr_type : & ' static str ) {
366
342
match arg_abi. mode {
367
343
PassMode :: Ignore => { /* do nothing */ }
368
344
PassMode :: Direct ( _) => {
369
345
let direct_type = match arg_abi. layout . backend_repr {
370
346
BackendRepr :: Scalar ( scalar) => wasm_primitive ( scalar. primitive ( ) , ptr_type) ,
371
347
BackendRepr :: Vector { .. } => "v128" ,
372
- BackendRepr :: Memory { .. } => {
373
- // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
374
- let _ = WasmCAbi :: Legacy ;
375
- span_bug ! (
376
- tcx. def_span( def_id) ,
377
- "cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
378
- ) ;
379
- }
380
348
other => unreachable ! ( "unexpected BackendRepr: {:?}" , other) ,
381
349
} ;
382
350
0 commit comments