Handle special-purpose arguments in the Intel ABI.

The VMContext and SignatureId arguments are passed in fixed registers
for the spiderwasm calling convention.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-13 12:04:14 -07:00
parent eb42a2547e
commit 45f50120ef

View File

@@ -6,7 +6,7 @@ use regalloc::AllocatableSet;
use settings as shared_settings;
use super::registers::{GPR, FPR, RU};
use abi::{ArgAction, ValueConversion, ArgAssigner, legalize_args};
use ir::{ArgumentType, ArgumentLoc, ArgumentExtension};
use ir::{ArgumentType, ArgumentPurpose, ArgumentLoc, ArgumentExtension};
/// Argument registers for x86-64
static ARG_GPRS: [RU; 6] = [RU::rdi, RU::rsi, RU::rdx, RU::rcx, RU::r8, RU::r9];
@@ -64,6 +64,24 @@ impl ArgAssigner for Args {
}
}
// Handle special-purpose arguments.
// TODO: The registers below are for `spiderwasm`. Should we check the calling convention?
if ty.is_int() {
match arg.purpose {
// This is SpiderMonkey's `WasmTlsReg`.
ArgumentPurpose::VMContext => {
return ArgumentLoc::Reg(if self.pointer_bits == 64 {
RU::r14
} else {
RU::rsi
} as RegUnit).into()
}
// This is SpiderMonkey's `WasmTableCallSigReg`.
ArgumentPurpose::SignatureId => return ArgumentLoc::Reg(RU::rbx as RegUnit).into(),
_ => {}
}
}
// Try to use a GPR.
if !ty.is_float() && self.gpr_used < self.gpr.len() {
let reg = self.gpr[self.gpr_used] as RegUnit;