Revert "Wasm-bindgen abi compat using cast_to"
This reverts commit 903c553f4a
.
This commit is contained in:
parent
903c553f4a
commit
eb99ea5142
3 changed files with 9 additions and 49 deletions
|
@ -2860,7 +2860,7 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(msg) = self.adjust_for_cabi(cx, &cx.tcx().sess.target_features, abi) {
|
if let Err(msg) = self.adjust_for_cabi(cx, abi) {
|
||||||
cx.tcx().sess.fatal(&msg);
|
cx.tcx().sess.fatal(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,6 @@ pub enum PassMode {
|
||||||
// Hack to disable non_upper_case_globals only for the bitflags! and not for the rest
|
// Hack to disable non_upper_case_globals only for the bitflags! and not for the rest
|
||||||
// of this module
|
// of this module
|
||||||
pub use attr_impl::ArgAttribute;
|
pub use attr_impl::ArgAttribute;
|
||||||
use rustc_data_structures::stable_set::FxHashSet;
|
|
||||||
use rustc_span::Symbol;
|
|
||||||
|
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
|
@ -594,12 +592,7 @@ pub struct FnAbi<'a, Ty> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Ty> FnAbi<'a, Ty> {
|
impl<'a, Ty> FnAbi<'a, Ty> {
|
||||||
pub fn adjust_for_cabi<C>(
|
pub fn adjust_for_cabi<C>(&mut self, cx: &C, abi: spec::abi::Abi) -> Result<(), String>
|
||||||
&mut self,
|
|
||||||
cx: &C,
|
|
||||||
target_features: &FxHashSet<Symbol>,
|
|
||||||
abi: spec::abi::Abi,
|
|
||||||
) -> Result<(), String>
|
|
||||||
where
|
where
|
||||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
||||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
|
||||||
|
@ -640,7 +633,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
||||||
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
|
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
|
||||||
"wasm32" => match cx.target_spec().os.as_str() {
|
"wasm32" => match cx.target_spec().os.as_str() {
|
||||||
"emscripten" | "wasi" => wasm32::compute_abi_info(cx, self),
|
"emscripten" | "wasi" => wasm32::compute_abi_info(cx, self),
|
||||||
_ => wasm32_bindgen_compat::compute_abi_info(cx, target_features, self),
|
_ => wasm32_bindgen_compat::compute_abi_info(self),
|
||||||
},
|
},
|
||||||
"asmjs" => wasm32::compute_abi_info(cx, self),
|
"asmjs" => wasm32::compute_abi_info(cx, self),
|
||||||
a => return Err(format!("unrecognized arch \"{}\" in target specification", a)),
|
a => return Err(format!("unrecognized arch \"{}\" in target specification", a)),
|
||||||
|
|
|
@ -5,58 +5,25 @@
|
||||||
// can be fixed to work with the correct ABI. See #63649 for further
|
// can be fixed to work with the correct ABI. See #63649 for further
|
||||||
// discussion.
|
// discussion.
|
||||||
|
|
||||||
use rustc_data_structures::stable_set::FxHashSet;
|
use crate::abi::call::{ArgAbi, FnAbi};
|
||||||
use rustc_span::Symbol;
|
|
||||||
|
|
||||||
use crate::abi::call::{ArgAbi, FnAbi, Uniform};
|
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
|
||||||
use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
|
|
||||||
|
|
||||||
fn classify_ret<'a, Ty, C>(cx: &C, target_features: &FxHashSet<Symbol>, ret: &mut ArgAbi<'a, Ty>)
|
|
||||||
where
|
|
||||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
|
||||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
|
||||||
{
|
|
||||||
if ret.layout.is_aggregate() {
|
|
||||||
if let Some(unit) = ret.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) {
|
|
||||||
let size = ret.layout.size;
|
|
||||||
if unit.size == size || target_features.contains(&Symbol::intern("multivalue")) {
|
|
||||||
ret.cast_to(Uniform { unit, total: size });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret.extend_integer_width_to(32);
|
ret.extend_integer_width_to(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
|
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
|
||||||
where
|
|
||||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
|
||||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
|
||||||
{
|
|
||||||
if arg.layout.is_aggregate() {
|
|
||||||
if let Some(unit) = arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) {
|
|
||||||
let size = arg.layout.size;
|
|
||||||
arg.cast_to(Uniform { unit, total: size });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arg.extend_integer_width_to(32);
|
arg.extend_integer_width_to(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compute_abi_info<'a, Ty, C>(
|
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
||||||
cx: &C,
|
|
||||||
target_features: &FxHashSet<Symbol>,
|
|
||||||
fn_abi: &mut FnAbi<'a, Ty>,
|
|
||||||
) where
|
|
||||||
Ty: TyAndLayoutMethods<'a, C> + Copy,
|
|
||||||
C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
|
|
||||||
{
|
|
||||||
if !fn_abi.ret.is_ignore() {
|
if !fn_abi.ret.is_ignore() {
|
||||||
classify_ret(cx, target_features, &mut fn_abi.ret);
|
classify_ret(&mut fn_abi.ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
for arg in &mut fn_abi.args {
|
for arg in &mut fn_abi.args {
|
||||||
if arg.is_ignore() {
|
if arg.is_ignore() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
classify_arg(cx, arg);
|
classify_arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue