r238731 - [MS ABI] Be a little more defensive wrt vector types

David Majnemer david.majnemer at gmail.com
Mon Jun 1 00:41:38 PDT 2015


Author: majnemer
Date: Mon Jun  1 02:41:37 2015
New Revision: 238731

URL: http://llvm.org/viewvc/llvm-project?rev=238731&view=rev
Log:
[MS ABI] Be a little more defensive wrt vector types

We probably shouldn't say that all appropriately sized vector types are
intel vector types (i.e. __m128, etc.) as they don't exist for all
architectures.  While this is largely academic, it'd save some debugging
if we supported such a platform.

Modified:
    cfe/trunk/lib/AST/MicrosoftMangle.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=238731&r1=238730&r2=238731&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Mon Jun  1 02:41:37 2015
@@ -2021,23 +2021,29 @@ void MicrosoftCXXNameMangler::mangleType
   uint64_t Width = getASTContext().getTypeSize(T);
   // Pattern match exactly the typedefs in our intrinsic headers.  Anything that
   // doesn't match the Intel types uses a custom mangling below.
-  bool IntelVector = true;
-  if (Width == 64 && ET->getKind() == BuiltinType::LongLong) {
-    Out << "T__m64";
-  } else if (Width == 128 || Width == 256) {
-    if (ET->getKind() == BuiltinType::Float)
-      Out << "T__m" << Width;
-    else if (ET->getKind() == BuiltinType::LongLong)
-      Out << "T__m" << Width << 'i';
-    else if (ET->getKind() == BuiltinType::Double)
-      Out << "U__m" << Width << 'd';
-    else
-      IntelVector = false;
+  bool IsBuiltin = true;
+  llvm::Triple::ArchType AT =
+      getASTContext().getTargetInfo().getTriple().getArch();
+  if (AT == llvm::Triple::x86 || AT == llvm::Triple::x86_64) {
+    if (Width == 64 && ET->getKind() == BuiltinType::LongLong) {
+      Out << "T__m64";
+    } else if (Width >= 128) {
+      if (ET->getKind() == BuiltinType::Float)
+        Out << "T__m" << Width;
+      else if (ET->getKind() == BuiltinType::LongLong)
+        Out << "T__m" << Width << 'i';
+      else if (ET->getKind() == BuiltinType::Double)
+        Out << "U__m" << Width << 'd';
+      else
+        IsBuiltin = false;
+    } else {
+      IsBuiltin = false;
+    }
   } else {
-    IntelVector = false;
+    IsBuiltin = false;
   }
 
-  if (!IntelVector) {
+  if (!IsBuiltin) {
     // The MS ABI doesn't have a special mangling for vector types, so we define
     // our own mangling to handle uses of __vector_size__ on user-specified
     // types, and for extensions like __v4sf.





More information about the cfe-commits mailing list