Subzero: fix calling C functions on Windows x86
Bug: b/142132927
Change-Id: I1221f85a6a84c8ff54d900b8acb444764f18cf40
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37274
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 29bc817..e070dd3 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -315,9 +315,9 @@
case R_386_32:
*patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
break;
- // case R_386_PC32:
- // *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
- // break;
+ case R_386_PC32:
+ *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
+ break;
default:
ASSERT(false && "Unsupported relocation type");
return nullptr;
@@ -3487,7 +3487,14 @@
RValue<Pointer<Byte>> ConstantPointer(void const * ptr)
{
- return RValue<Pointer<Byte>>(V(::context->getConstantInt64(reinterpret_cast<intptr_t>(ptr))));
+ if (sizeof(void*) == 8)
+ {
+ return RValue<Pointer<Byte>>(V(::context->getConstantInt64(reinterpret_cast<intptr_t>(ptr))));
+ }
+ else
+ {
+ return RValue<Pointer<Byte>>(V(::context->getConstantInt32(reinterpret_cast<intptr_t>(ptr))));
+ }
}
Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> argTys)
diff --git a/third_party/subzero/src/IceTargetLoweringX8632Traits.h b/third_party/subzero/src/IceTargetLoweringX8632Traits.h
index 8924692..09e449c 100644
--- a/third_party/subzero/src/IceTargetLoweringX8632Traits.h
+++ b/third_party/subzero/src/IceTargetLoweringX8632Traits.h
@@ -317,6 +317,18 @@
return ByteRegs[RegNum];
}
+ static bool isXmm(RegNumT RegNum) {
+ static const bool IsXmm[RegisterSet::Reg_NUM] = {
+#define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \
+ isGPR, is64, is32, is16, is8, isXmm, is64To8, is32To8, is16To8, \
+ isTrunc8Rcvr, isAhRcvr, aliases) \
+ isXmm,
+ REGX8632_TABLE
+#undef X
+ };
+ return IsXmm[RegNum];
+ }
+
static XmmRegister getEncodedXmm(RegNumT RegNum) {
static const XmmRegister XmmRegs[RegisterSet::Reg_NUM] = {
#define X(val, encode, name, base, scratch, preserved, stackptr, frameptr, \