]> granicus.if.org Git - clang/commitdiff
When an MMX output variable is tied to the input variable, we have to implicitly
authorBill Wendling <isanbard@gmail.com>
Thu, 22 Mar 2012 23:25:07 +0000 (23:25 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 22 Mar 2012 23:25:07 +0000 (23:25 +0000)
cast the value to x86_mmx. This gives the ASM string the correct call signature.
<rdar://problem/10919182>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153290 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
test/CodeGen/asm-inout.c

index e65c5f468f584e1de0d5f5a2272a7a57f95a129c..670167b9590990687be44b8a14906e6b2f72cb46 100644 (file)
@@ -1507,6 +1507,11 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
       llvm::Value *Arg = EmitAsmInputLValue(S, Info, Dest, InputExpr->getType(),
                                             InOutConstraints);
 
+      if (llvm::Type* AdjTy =
+            getTargetHooks().adjustInlineAsmType(*this, OutputConstraint,
+                                                 Arg->getType()))
+        Arg = Builder.CreateBitCast(Arg, AdjTy);
+
       if (Info.allowsRegister())
         InOutConstraints += llvm::utostr(i);
       else
@@ -1565,7 +1570,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
         }
       }
     }
-    if (llvm::Type* AdjTy = 
+    if (llvm::Type* AdjTy =
               getTargetHooks().adjustInlineAsmType(*this, InputConstraint,
                                                    Arg->getType()))
       Arg = Builder.CreateBitCast(Arg, AdjTy);
index ce524fe70fe973987d7e14f4a8b34e0ef01c44d5..423bc4e82a94eb8a460543801683201365746c12 100644 (file)
@@ -37,3 +37,12 @@ int test4(volatile int *addr) {
   return (int)oldval;
 // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
 }
+
+// <rdar://problem/10919182> - This should have both inputs be of type x86_mmx.
+// CHECK: @test5
+typedef long long __m64 __attribute__((__vector_size__(8)));
+__m64 test5(__m64 __A, __m64 __B) {
+  // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.}}, x86_mmx %{{.}})
+  asm("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
+  return __A;
+}