Commit e81e8b3c by Antonio Maiorano

Subzero: fix calling C functions on Windows x64

This change addresses the following issues: * Microsoft x64 ABI assigns registers to the first four arguments by argument position, not by type count. * Microsoft x64 ABI expects caller to allocate space to copy 4 register arguments to stack, called the Shadow Store or Home Space. * Fix bug where preserved register area size was not computed correctly when Xmm registers were being preserved, as it was assuming all preserved registers were 8 bytes large. Bug: b/142132927 Change-Id: Ibc2d82ab117c062eed2e7f66109c9d6bbdc09a8b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37272Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 01a7adc9
......@@ -160,7 +160,7 @@ namespace rr
{
const Capabilities Caps =
{
false, // CallSupported
true, // CallSupported
false, // CoroutinesSupported
};
......
......@@ -694,6 +694,12 @@ public:
(void)ArgNum;
return RegNumT();
}
// Given the absolute argument position and argument position by type, return
// the register index to assign it to.
static SizeT getArgIndex(SizeT argPos, SizeT argPosByType) {
(void)argPos;
return argPosByType;
};
/// The number of bits in a byte
static constexpr uint32_t X86_CHAR_BIT = 8;
......
......@@ -742,6 +742,15 @@ public:
assert(Ty == IceType_i64 || Ty == IceType_i32);
return getGprForType(Ty, GprForArgNum[ArgNum]);
}
// Given the absolute argument position and argument position by type, return
// the register index to assign it to.
static SizeT getArgIndex(SizeT argPos, SizeT argPosByType) {
// Microsoft x64 ABI: register is selected by arg position (e.g. 1st int as
// 2nd param goes into 2nd int reg)
(void)argPosByType;
return argPos;
};
#else
// System V x86-64 calling convention:
//
......@@ -774,6 +783,12 @@ public:
assert(Ty == IceType_i64 || Ty == IceType_i32);
return getGprForType(Ty, GprForArgNum[ArgNum]);
}
// Given the absolute argument position and argument position by type, return
// the register index to assign it to.
static SizeT getArgIndex(SizeT argPos, SizeT argPosByType) {
(void)argPos;
return argPosByType;
}
#endif
/// Whether scalar floating point arguments are passed in XMM registers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment