]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/abi/call/wasm32_bindgen_compat.rs
Auto merge of #68414 - michaelwoerister:share-drop-glue, r=alexcrichton
[rust.git] / src / librustc_target / abi / call / wasm32_bindgen_compat.rs
1 // This is not and has never been a correct C ABI for WebAssembly, but
2 // for a long time this was the C ABI that Rust used. wasm-bindgen
3 // depends on ABI details for this ABI and is incompatible with the
4 // correct C ABI, so this ABI is being kept around until wasm-bindgen
5 // can be fixed to work with the correct ABI. See #63649 for further
6 // discussion.
7
8 use crate::abi::call::{ArgAbi, FnAbi};
9
10 fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
11     ret.extend_integer_width_to(32);
12 }
13
14 fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
15     arg.extend_integer_width_to(32);
16 }
17
18 pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
19     if !fn_abi.ret.is_ignore() {
20         classify_ret(&mut fn_abi.ret);
21     }
22
23     for arg in &mut fn_abi.args {
24         if arg.is_ignore() {
25             continue;
26         }
27         classify_arg(arg);
28     }
29 }