[cfe-commits] r117736 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp lib/CodeGen/CGStmt.cpp

Dale Johannesen dalej at apple.com
Fri Oct 29 16:12:32 PDT 2010


Author: johannes
Date: Fri Oct 29 18:12:32 2010
New Revision: 117736

URL: http://llvm.org/viewvc/llvm-project?rev=117736&view=rev
Log:
Generate bitcasts going in and out of MMX parameters
in asm's.  PR 8501, 8602988.
I don't like including Type.h where it is; the idea was
to get references to X86_MMXTy out of the common code.
Maybe there's a better way?


Modified:
    cfe/trunk/include/clang/Basic/TargetInfo.h
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=117736&r1=117735&r2=117736&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Oct 29 18:12:32 2010
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/System/DataTypes.h"
+#include "llvm/Type.h"
 #include <cassert>
 #include <vector>
 #include <string>
@@ -26,6 +27,7 @@
 namespace llvm {
 struct fltSemantics;
 class StringRef;
+class LLVMContext;
 }
 
 namespace clang {
@@ -524,6 +526,11 @@
     return 0;
   }
 
+  virtual const llvm::Type* adjustInlineAsmType(std::string& Constraint, 
+                                     const llvm::Type* Ty,
+                                     llvm::LLVMContext& Context) const {
+    return Ty;
+  }
 protected:
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
     return PointerWidth;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=117736&r1=117735&r2=117736&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Oct 29 18:12:32 2010
@@ -985,6 +985,9 @@
   }
   virtual bool validateAsmConstraint(const char *&Name,
                                      TargetInfo::ConstraintInfo &info) const;
+  virtual const llvm::Type* adjustInlineAsmType(std::string& Constraint,
+                                     const llvm::Type* Ty,
+                                     llvm::LLVMContext& Context) const;
   virtual std::string convertConstraint(const char Constraint) const;
   virtual const char *getClobbers() const {
     return "~{dirflag},~{fpsr},~{flags}";
@@ -1306,6 +1309,16 @@
   return false;
 }
 
+const llvm::Type*
+X86TargetInfo::adjustInlineAsmType(std::string& Constraint,
+                                   const llvm::Type* Ty,
+                                   llvm::LLVMContext &Context) const {
+  if (Constraint=="y" && Ty->isVectorTy())
+    return llvm::Type::getX86_MMXTy(Context);
+  return Ty;
+}
+
+
 std::string
 X86TargetInfo::convertConstraint(const char Constraint) const {
   switch (Constraint) {

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=117736&r1=117735&r2=117736&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Oct 29 18:12:32 2010
@@ -1046,6 +1046,10 @@
           ResultRegTypes.back() = ConvertType(InputTy);
         }
       }
+      if (const llvm::Type* AdjTy = 
+            Target.adjustInlineAsmType(OutputConstraint, ResultRegTypes.back(),
+                                       VMContext))
+        ResultRegTypes.back() = AdjTy;
     } else {
       ArgTypes.push_back(Dest.getAddress()->getType());
       Args.push_back(Dest.getAddress());
@@ -1109,7 +1113,10 @@
           Arg = Builder.CreateFPExt(Arg, OutputTy);
       }
     }
-
+    if (const llvm::Type* AdjTy = 
+              Target.adjustInlineAsmType(InputConstraint, Arg->getType(),
+                                         VMContext))
+      Arg = Builder.CreateBitCast(Arg, AdjTy);
 
     ArgTypes.push_back(Arg->getType());
     Args.push_back(Arg);
@@ -1204,6 +1211,8 @@
         Tmp = Builder.CreateTrunc(Tmp, TruncTy);
       } else if (TruncTy->isIntegerTy()) {
         Tmp = Builder.CreateTrunc(Tmp, TruncTy);
+      } else if (TruncTy->isVectorTy()) {
+        Tmp = Builder.CreateBitCast(Tmp, TruncTy);
       }
     }
 





More information about the cfe-commits mailing list