On Mon, Mar 25, 2013 at 6:25 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi rjmccall,<br>
<br>
The only vector types a user can pass from MSVC code to clang code are<br>
the ones from *mmintrin.h, so we only have to match the MSVC mangling<br>
for these types. MSVC mangles the __m128 family of types as tag types,<br>
which we match. For other vector types, we emit a unique tag type<br>
mangling that won't match anything produced by MSVC.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D576" target="_blank">http://llvm-reviews.chandlerc.com/D576</a><br>
<br>
Files:<br>
lib/AST/MicrosoftMangle.cpp<br>
test/CodeGenCXX/mangle-ms-vector-types.cpp<br>
<br>
Index: lib/AST/MicrosoftMangle.cpp<br>
===================================================================<br>
--- lib/AST/MicrosoftMangle.cpp<br>
+++ lib/AST/MicrosoftMangle.cpp<br>
@@ -1519,12 +1519,45 @@<br>
<br>
void MicrosoftCXXNameMangler::mangleType(const VectorType *T,<br>
SourceRange Range) {<br>
- DiagnosticsEngine &Diags = Context.getDiags();<br>
- unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,<br>
- "cannot mangle this vector type yet");<br>
- Diags.Report(Range.getBegin(), DiagID)<br>
- << Range;<br>
+ if (!T->getElementType()->isBuiltinType()) {<br>
+ DiagnosticsEngine &Diags = Context.getDiags();<br>
+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,<br>
+ "cannot mangle vectors of non-builtin types");<br>
+ Diags.Report(Range.getBegin(), DiagID)<br>
+ << Range;<br>
+ }<br>
+<br>
+ const BuiltinType *ET = T->getElementType()->getAs<BuiltinType>();<br>
+ uint64_t Width = getASTContext().getTypeSize(T);<br>
+ // Pattern match exactly the typedefs in our intrinsic headers. Anything that<br>
+ // doesn't match the Intel types uses a custom mangling below.<br>
+ bool IntelVector = true;<br>
+ if (Width == 64 && ET->getKind() == BuiltinType::LongLong) {<br>
+ Out << "T__m64";<br>
+ } else if (Width == 128 || Width == 256) {<br>
+ if (ET->getKind() == BuiltinType::Float)<br>
+ Out << "T__m" << Width;<br>
+ else if (ET->getKind() == BuiltinType::LongLong)<br>
+ Out << "T__m" << Width << 'i';<br>
+ else if (ET->getKind() == BuiltinType::Double)<br>
+ Out << "U__m" << Width << 'd';<br>
+ else<br>
+ IntelVector = false; // Has to be float.<br></blockquote><div><br></div><div>This comment seems misleading: 'long long' isn't a floating-point type.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ } else {<br>
+ IntelVector = false;<br>
+ }<br>
+<br>
+ if (!IntelVector) {<br>
+ // The MS ABI doesn't have a special mangling for vector types, so we define<br>
+ // our own mangling to handle uses of __vector_size__ on user-specified<br>
+ // types, and for extensions like __v4sf.<br>
+ Out << "T__clang_vec" << T->getNumElements() << '_';<br>
+ mangleType(ET, Range);<br>
+ }<br>
+<br>
+ Out << "@@";<br>
}<br>
+<br>
void MicrosoftCXXNameMangler::mangleType(const ExtVectorType *T,<br>
SourceRange Range) {<br>
DiagnosticsEngine &Diags = Context.getDiags();<br>
Index: test/CodeGenCXX/mangle-ms-vector-types.cpp<br>
===================================================================<br>
--- /dev/null<br>
+++ test/CodeGenCXX/mangle-ms-vector-types.cpp<br>
@@ -0,0 +1,30 @@<br>
+// RUN: %clang_cc1 -fms-extensions -ffreestanding -target-feature +avx -emit-llvm %s -o - -cxx-abi microsoft -triple=i686-pc-win32 | FileCheck %s<br>
+<br>
+#include <xmmintrin.h><br>
+#include <emmintrin.h><br>
+#include <immintrin.h><br>
+<br>
+void foo64(__m64) {}<br>
+// CHECK: define void @"\01?foo64@@YAXT__m64@@@Z"<br>
+<br>
+void foo128(__m128) {}<br>
+// CHECK: define void @"\01?foo128@@YAXT__m128@@@Z"<br>
+<br>
+void foo128d(__m128d) {}<br>
+// CHECK: define void @"\01?foo128d@@YAXU__m128d@@@Z"<br>
+<br>
+void foo128i(__m128i) {}<br>
+// CHECK: define void @"\01?foo128i@@YAXT__m128i@@@Z"<br>
+<br>
+void foo256(__m256) {}<br>
+// CHECK: define void @"\01?foo256@@YAXT__m256@@@Z"<br>
+<br>
+void foo256d(__m256d) {}<br>
+// CHECK: define void @"\01?foo256d@@YAXU__m256d@@@Z"<br>
+<br>
+void foo256i(__m256i) {}<br>
+// CHECK: define void @"\01?foo256i@@YAXT__m256i@@@Z"<br>
+<br>
+// We have a custom mangling for vector types not standardized by Intel.<br>
+void foov8hi(__v8hi) {}<br>
+// CHECK: define void @"\01?foov8hi@@YAXT__clang_vec8_F@@@Z"<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br>