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:
@@ -6,7 +6,7 @@ use regalloc::AllocatableSet;
|
|||||||
use settings as shared_settings;
|
use settings as shared_settings;
|
||||||
use super::registers::{GPR, FPR, RU};
|
use super::registers::{GPR, FPR, RU};
|
||||||
use abi::{ArgAction, ValueConversion, ArgAssigner, legalize_args};
|
use abi::{ArgAction, ValueConversion, ArgAssigner, legalize_args};
|
||||||
use ir::{ArgumentType, ArgumentLoc, ArgumentExtension};
|
use ir::{ArgumentType, ArgumentPurpose, ArgumentLoc, ArgumentExtension};
|
||||||
|
|
||||||
/// Argument registers for x86-64
|
/// Argument registers for x86-64
|
||||||
static ARG_GPRS: [RU; 6] = [RU::rdi, RU::rsi, RU::rdx, RU::rcx, RU::r8, RU::r9];
|
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.
|
// Try to use a GPR.
|
||||||
if !ty.is_float() && self.gpr_used < self.gpr.len() {
|
if !ty.is_float() && self.gpr_used < self.gpr.len() {
|
||||||
let reg = self.gpr[self.gpr_used] as RegUnit;
|
let reg = self.gpr[self.gpr_used] as RegUnit;
|
||||||
|
|||||||
Reference in New Issue
Block a user