yaxunl created this revision.
yaxunl added a reviewer: b-sumner.
Herald added subscribers: t-tye, Anastasia, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

In MSVC wchar_t and wint_t are unsigned short. There is static_assert in MSVC 
headers checking that.

Since HIP and OpenCL share the same device library on windows, we have to 
define wchar_t and
wint_t to match MSVC on windows.

This should not affect OpenCL since OpenCL does not use wchar_t or wint_t.


https://reviews.llvm.org/D57831

Files:
  lib/Basic/Targets/AMDGPU.cpp
  test/SemaCXX/amdgpu-wchar.cxx


Index: test/SemaCXX/amdgpu-wchar.cxx
===================================================================
--- /dev/null
+++ test/SemaCXX/amdgpu-wchar.cxx
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple amdgcn -std=c++11 %s
+
+typedef __WINT_TYPE__ wint_t;
+
+#if _WIN32
+static_assert(sizeof(wchar_t)==2, "fail");
+static_assert(sizeof(wint_t)==2, "fail");
+#else
+static_assert(sizeof(wchar_t)==4, "fail");
+static_assert(sizeof(wint_t)==4, "fail");
+#endif
Index: lib/Basic/Targets/AMDGPU.cpp
===================================================================
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -260,6 +260,10 @@
   }
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+#if _WIN32
+  WCharType = UnsignedShort;
+  WIntType = UnsignedShort;
+#endif
 }
 
 void AMDGPUTargetInfo::adjust(LangOptions &Opts) {


Index: test/SemaCXX/amdgpu-wchar.cxx
===================================================================
--- /dev/null
+++ test/SemaCXX/amdgpu-wchar.cxx
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple amdgcn -std=c++11 %s
+
+typedef __WINT_TYPE__ wint_t;
+
+#if _WIN32
+static_assert(sizeof(wchar_t)==2, "fail");
+static_assert(sizeof(wint_t)==2, "fail");
+#else
+static_assert(sizeof(wchar_t)==4, "fail");
+static_assert(sizeof(wint_t)==4, "fail");
+#endif
Index: lib/Basic/Targets/AMDGPU.cpp
===================================================================
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -260,6 +260,10 @@
   }
 
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+#if _WIN32
+  WCharType = UnsignedShort;
+  WIntType = UnsignedShort;
+#endif
 }
 
 void AMDGPUTargetInfo::adjust(LangOptions &Opts) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D57831: AMDGPU:... Yaxun Liu via Phabricator via cfe-commits

Reply via email to