Remove Signature's argument_bytes field.
It's not currently used. If we do need such information, it would be better to compute it on demand.
This commit is contained in:
@@ -19,7 +19,6 @@ fn error_on_incompatible_sig_in_declare_function() {
|
|||||||
params: vec![AbiParam::new(types::I64)],
|
params: vec![AbiParam::new(types::I64)],
|
||||||
returns: vec![],
|
returns: vec![],
|
||||||
call_conv: CallConv::SystemV,
|
call_conv: CallConv::SystemV,
|
||||||
argument_bytes: None,
|
|
||||||
};
|
};
|
||||||
module
|
module
|
||||||
.declare_function("abc", Linkage::Local, &sig)
|
.declare_function("abc", Linkage::Local, &sig)
|
||||||
@@ -36,7 +35,6 @@ fn define_simple_function(module: &mut Module<SimpleJITBackend>) -> FuncId {
|
|||||||
params: vec![],
|
params: vec![],
|
||||||
returns: vec![],
|
returns: vec![],
|
||||||
call_conv: CallConv::SystemV,
|
call_conv: CallConv::SystemV,
|
||||||
argument_bytes: None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let func_id = module
|
let func_id = module
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
use ir::{ArgumentLoc, ExternalName, SigRef, Type};
|
use ir::{ArgumentLoc, ExternalName, SigRef, Type};
|
||||||
use isa::{RegInfo, RegUnit};
|
use isa::{RegInfo, RegUnit};
|
||||||
use settings::CallConv;
|
use settings::CallConv;
|
||||||
use std::cmp;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
@@ -29,13 +28,6 @@ pub struct Signature {
|
|||||||
|
|
||||||
/// Calling convention.
|
/// Calling convention.
|
||||||
pub call_conv: CallConv,
|
pub call_conv: CallConv,
|
||||||
|
|
||||||
/// When the signature has been legalized to a specific ISA, this holds the size of the
|
|
||||||
/// argument array on the stack. Before legalization, this is `None`.
|
|
||||||
///
|
|
||||||
/// This can be computed from the legalized `params` array as the maximum (offset plus
|
|
||||||
/// byte size) of the `ArgumentLoc::Stack(offset)` argument.
|
|
||||||
pub argument_bytes: Option<u32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Signature {
|
impl Signature {
|
||||||
@@ -45,7 +37,6 @@ impl Signature {
|
|||||||
params: Vec::new(),
|
params: Vec::new(),
|
||||||
returns: Vec::new(),
|
returns: Vec::new(),
|
||||||
call_conv,
|
call_conv,
|
||||||
argument_bytes: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,25 +45,6 @@ impl Signature {
|
|||||||
self.params.clear();
|
self.params.clear();
|
||||||
self.returns.clear();
|
self.returns.clear();
|
||||||
self.call_conv = call_conv;
|
self.call_conv = call_conv;
|
||||||
self.argument_bytes = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compute the size of the stack arguments and mark signature as legalized.
|
|
||||||
///
|
|
||||||
/// Even if there are no stack arguments, this will set `params` to `Some(0)` instead
|
|
||||||
/// of `None`. This indicates that the signature has been legalized.
|
|
||||||
pub fn compute_argument_bytes(&mut self) {
|
|
||||||
let bytes = self
|
|
||||||
.params
|
|
||||||
.iter()
|
|
||||||
.filter_map(|arg| match arg.location {
|
|
||||||
ArgumentLoc::Stack(offset) if offset >= 0 => {
|
|
||||||
Some(offset as u32 + arg.value_type.bytes())
|
|
||||||
}
|
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.fold(0, cmp::max);
|
|
||||||
self.argument_bytes = Some(bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an object that can display `self` with correct register names.
|
/// Return an object that can display `self` with correct register names.
|
||||||
@@ -421,16 +393,9 @@ mod tests {
|
|||||||
sig.returns.push(AbiParam::new(B8));
|
sig.returns.push(AbiParam::new(B8));
|
||||||
assert_eq!(sig.to_string(), "(i32, i32x4) -> f32, b8 baldrdash");
|
assert_eq!(sig.to_string(), "(i32, i32x4) -> f32, b8 baldrdash");
|
||||||
|
|
||||||
// Test the offset computation algorithm.
|
|
||||||
assert_eq!(sig.argument_bytes, None);
|
|
||||||
sig.params[1].location = ArgumentLoc::Stack(8);
|
|
||||||
sig.compute_argument_bytes();
|
|
||||||
// An `i32x4` at offset 8 requires a 24-byte argument array.
|
|
||||||
assert_eq!(sig.argument_bytes, Some(24));
|
|
||||||
// Order does not matter.
|
// Order does not matter.
|
||||||
sig.params[0].location = ArgumentLoc::Stack(24);
|
sig.params[0].location = ArgumentLoc::Stack(24);
|
||||||
sig.compute_argument_bytes();
|
sig.params[1].location = ArgumentLoc::Stack(8);
|
||||||
assert_eq!(sig.argument_bytes, Some(28));
|
|
||||||
|
|
||||||
// Writing ABI-annotated signatures.
|
// Writing ABI-annotated signatures.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ pub fn legalize_libcall_signature(signature: &mut Signature, isa: &TargetIsa) {
|
|||||||
/// `current` is true if this is the signature for the current function.
|
/// `current` is true if this is the signature for the current function.
|
||||||
fn legalize_signature(signature: &mut Signature, current: bool, isa: &TargetIsa) {
|
fn legalize_signature(signature: &mut Signature, current: bool, isa: &TargetIsa) {
|
||||||
isa.legalize_signature(signature, current);
|
isa.legalize_signature(signature, current);
|
||||||
signature.compute_argument_bytes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Legalize the entry block parameters after `func`'s signature has been legalized.
|
/// Legalize the entry block parameters after `func`'s signature has been legalized.
|
||||||
|
|||||||
@@ -1160,11 +1160,6 @@ impl<'a> Verifier<'a> {
|
|||||||
) -> VerifierStepResult<()> {
|
) -> VerifierStepResult<()> {
|
||||||
let sig = &self.func.dfg.signatures[sig_ref];
|
let sig = &self.func.dfg.signatures[sig_ref];
|
||||||
|
|
||||||
// Before legalization, there's nothing to check.
|
|
||||||
if sig.argument_bytes.is_none() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let args = self.func.dfg.inst_variable_args(inst);
|
let args = self.func.dfg.inst_variable_args(inst);
|
||||||
let expected_args = &sig.params[..];
|
let expected_args = &sig.params[..];
|
||||||
|
|
||||||
|
|||||||
@@ -919,10 +919,6 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if sig.params.iter().all(|a| a.location.is_assigned()) {
|
|
||||||
sig.compute_argument_bytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(sig)
|
Ok(sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user