Add helper routines for special-purpose arguments.

- ArgumentType::special() creates a new special-purpose argument without
  assigning it to a register location.
- Signature::special_arg_index() funds a unique special-purpose
  argument.
- Function::special_arg() finds a special-purpose argument by value.

Also add a new "sigid" argument purpose which will be used for runtime
signature checks in WebAssembly indirect calls.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-13 11:35:33 -07:00
parent ef27c3daf0
commit eb42a2547e
3 changed files with 44 additions and 1 deletions

View File

@@ -135,6 +135,16 @@ impl Function {
pub fn display<'a, I: Into<Option<&'a TargetIsa>>>(&'a self, isa: I) -> DisplayFunction<'a> {
DisplayFunction(self, isa.into())
}
/// Find a presumed unique special-purpose function argument value.
///
/// Returns the value of the last `purpose` argument, or `None` if no such argument exists.
pub fn special_arg(&self, purpose: ir::ArgumentPurpose) -> Option<ir::Value> {
let entry = self.layout.entry_block().expect("Function is empty");
self.signature.special_arg_index(purpose).map(|i| {
self.dfg.ebb_args(entry)[i]
})
}
}
/// Wrapper type capable of displaying a `Function` with correct ISA annotations.