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)],
|
||||
returns: vec![],
|
||||
call_conv: CallConv::SystemV,
|
||||
argument_bytes: None,
|
||||
};
|
||||
module
|
||||
.declare_function("abc", Linkage::Local, &sig)
|
||||
@@ -36,7 +35,6 @@ fn define_simple_function(module: &mut Module<SimpleJITBackend>) -> FuncId {
|
||||
params: vec![],
|
||||
returns: vec![],
|
||||
call_conv: CallConv::SystemV,
|
||||
argument_bytes: None,
|
||||
};
|
||||
|
||||
let func_id = module
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
use ir::{ArgumentLoc, ExternalName, SigRef, Type};
|
||||
use isa::{RegInfo, RegUnit};
|
||||
use settings::CallConv;
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
use std::vec::Vec;
|
||||
@@ -29,13 +28,6 @@ pub struct Signature {
|
||||
|
||||
/// Calling convention.
|
||||
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 {
|
||||
@@ -45,7 +37,6 @@ impl Signature {
|
||||
params: Vec::new(),
|
||||
returns: Vec::new(),
|
||||
call_conv,
|
||||
argument_bytes: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,25 +45,6 @@ impl Signature {
|
||||
self.params.clear();
|
||||
self.returns.clear();
|
||||
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.
|
||||
@@ -421,16 +393,9 @@ mod tests {
|
||||
sig.returns.push(AbiParam::new(B8));
|
||||
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.
|
||||
sig.params[0].location = ArgumentLoc::Stack(24);
|
||||
sig.compute_argument_bytes();
|
||||
assert_eq!(sig.argument_bytes, Some(28));
|
||||
sig.params[1].location = ArgumentLoc::Stack(8);
|
||||
|
||||
// Writing ABI-annotated signatures.
|
||||
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.
|
||||
fn legalize_signature(signature: &mut Signature, current: bool, isa: &TargetIsa) {
|
||||
isa.legalize_signature(signature, current);
|
||||
signature.compute_argument_bytes();
|
||||
}
|
||||
|
||||
/// Legalize the entry block parameters after `func`'s signature has been legalized.
|
||||
|
||||
@@ -1160,11 +1160,6 @@ impl<'a> Verifier<'a> {
|
||||
) -> VerifierStepResult<()> {
|
||||
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 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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user