Implement a Windows Baldrdash calling convention;

This commit is contained in:
Benjamin Bouvier
2019-08-14 10:39:18 +02:00
parent d8d3602257
commit 2ee35b7ea1
21 changed files with 92 additions and 55 deletions

View File

@@ -15,8 +15,10 @@ pub enum CallConv {
SystemV,
/// Windows "fastcall" convention, also used for x64 and ARM
WindowsFastcall,
/// SpiderMonkey WebAssembly convention
Baldrdash,
/// SpiderMonkey WebAssembly convention on systems using natively SystemV
BaldrdashSystemV,
/// SpiderMonkey WebAssembly convention on Windows
BaldrdashWindows,
/// Specialized convention for the probestack function
Probestack,
}
@@ -40,10 +42,27 @@ impl CallConv {
LibcallCallConv::Cold => CallConv::Cold,
LibcallCallConv::SystemV => CallConv::SystemV,
LibcallCallConv::WindowsFastcall => CallConv::WindowsFastcall,
LibcallCallConv::Baldrdash => CallConv::Baldrdash,
LibcallCallConv::BaldrdashSystemV => CallConv::BaldrdashSystemV,
LibcallCallConv::BaldrdashWindows => CallConv::BaldrdashWindows,
LibcallCallConv::Probestack => CallConv::Probestack,
}
}
/// Is the calling convention extending the Windows Fastcall ABI?
pub fn extends_windows_fastcall(&self) -> bool {
match self {
CallConv::WindowsFastcall | CallConv::BaldrdashWindows => true,
_ => false,
}
}
/// Is the calling convention extending the Baldrdash ABI?
pub fn extends_baldrdash(&self) -> bool {
match self {
CallConv::BaldrdashSystemV | CallConv::BaldrdashWindows => true,
_ => false,
}
}
}
impl fmt::Display for CallConv {
@@ -53,7 +72,8 @@ impl fmt::Display for CallConv {
CallConv::Cold => "cold",
CallConv::SystemV => "system_v",
CallConv::WindowsFastcall => "windows_fastcall",
CallConv::Baldrdash => "baldrdash",
CallConv::BaldrdashSystemV => "baldrdash_system_v",
CallConv::BaldrdashWindows => "baldrdash_windows",
CallConv::Probestack => "probestack",
})
}
@@ -67,7 +87,8 @@ impl str::FromStr for CallConv {
"cold" => Ok(CallConv::Cold),
"system_v" => Ok(CallConv::SystemV),
"windows_fastcall" => Ok(CallConv::WindowsFastcall),
"baldrdash" => Ok(CallConv::Baldrdash),
"baldrdash_system_v" => Ok(CallConv::BaldrdashSystemV),
"baldrdash_windows" => Ok(CallConv::BaldrdashWindows),
"probestack" => Ok(CallConv::Probestack),
_ => Err(()),
}