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

@@ -57,6 +57,7 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
let mut has_sret = false;
let mut has_link = false;
let mut has_vmctx = false;
let mut has_sigid = false;
// Insert position for argument conversion code.
// We want to insert instructions before the first instruction in the entry block.
@@ -91,6 +92,10 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
assert!(!has_vmctx, "Multiple vmctx arguments found");
has_vmctx = true;
}
ArgumentPurpose::SignatureId => {
assert!(!has_sigid, "Multiple sigid arguments found");
has_sigid = true;
}
_ => panic!("Unexpected special-purpose arg {}", abi_types[abi_arg]),
}
abi_arg += 1;
@@ -145,6 +150,10 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
assert!(!has_vmctx, "Multiple vmctx arguments found");
has_vmctx = true;
}
ArgumentPurpose::SignatureId => {
assert!(!has_sigid, "Multiple sigid arguments found");
has_sigid = true;
}
}
// Just create entry block values to match here. We will use them in `handle_return_abi()`