Preserve rsi and rdi when using Microsoft x86-64 calling convention.
Also, their priority is lowered so that registers which are scratch on both
Unix and Windows are preferred by the register allocator.
BUG=swiftshader:22
Change-Id: Id55d8c8b8c106947e3041a082099069d7c6c6ed0
Reviewed-on: https://chromium-review.googlesource.com/404503
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Tested-by: Jim Stichnoth <stichnot@chromium.org>
diff --git a/src/IceTargetLoweringX8664Traits.h b/src/IceTargetLoweringX8664Traits.h
index 5e3e3c1..a50bdd3 100644
--- a/src/IceTargetLoweringX8664Traits.h
+++ b/src/IceTargetLoweringX8664Traits.h
@@ -702,7 +702,7 @@
static RegNumT getRdxOrDie() { return RegisterSet::Reg_rdx; }
-#if defined(_MSC_VER)
+#if defined(_WIN32)
// Microsoft x86-64 calling convention:
//
// * The first four arguments of vector/fp type, regardless of their
@@ -730,7 +730,7 @@
assert(Ty == IceType_i64 || Ty == IceType_i32);
return getGprForType(Ty, GprForArgNum[ArgNum]);
}
-#else // !defined(_MSC_VER)
+#elif defined(__unix__)
// System V x86-64 calling convention:
//
// * The first eight arguments of vector/fp type, regardless of their
@@ -762,7 +762,9 @@
assert(Ty == IceType_i64 || Ty == IceType_i32);
return getGprForType(Ty, GprForArgNum[ArgNum]);
}
-#endif // !defined(_MSC_VER)
+#else
+#error "Unsupported platform"
+#endif
/// Whether scalar floating point arguments are passed in XMM registers
static constexpr bool X86_PASS_SCALAR_FP_IN_XMM = true;