[cfe-commits] r70670 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/Sema/asm.c

Chris Lattner sabre at nondot.org
Sun May 3 00:04:27 PDT 2009


Author: lattner
Date: Sun May  3 02:04:21 2009
New Revision: 70670

URL: http://llvm.org/viewvc/llvm-project?rev=70670&view=rev
Log:
If we have mismatched integer tied operands, but the operand
number is not mentioned in the asm string, let it past sema. 
Right now these are currently rejected by the llvm code generator
but this will be fixed next.

Modified:
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/test/Sema/asm.c

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=70670&r1=70669&r2=70670&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun May  3 02:04:21 2009
@@ -1039,7 +1039,7 @@
     if (!Info.hasTiedOperand()) continue;
     
     unsigned TiedTo = Info.getTiedOperand();
-    Expr *OutputExpr     = Exprs[TiedTo];
+    Expr *OutputExpr = Exprs[TiedTo];
     Expr *InputExpr = Exprs[i+NumOutputs];
     QualType InTy = InputExpr->getType();
     QualType OutTy = OutputExpr->getType();
@@ -1055,6 +1055,25 @@
       // int*.
       if (Context.getTypeSize(OutTy) == Context.getTypeSize(InTy))
         continue;
+      
+      // If the input and output operands are not mentioned in the asm string,
+      // then we can promote them and the asm string won't notice.  Check this
+      // case now.
+      bool MentionedInput = false;
+      bool MentionedOutput = false;
+      for (unsigned i = 0, e = Pieces.size(); i != e; ++i) {
+        if (!Pieces[i].isOperand()) continue;
+        MentionedInput |= Pieces[i].getOperandNo() == i+NumOutputs;
+        MentionedOutput |= Pieces[i].getOperandNo() == TiedTo;
+      }
+      
+      // If neither the input nor the output was mentioned in the asm string,
+      // and if the output was a register, just extend the shorter one to the
+      // size of the larger one.
+      // TODO: if only the larger one is mentioned, we could also support this.
+      if (!MentionedInput && !MentionedOutput &&
+          OutputConstraintInfos[TiedTo].allowsRegister())
+        continue;
     }
     
     Diag(InputExpr->getLocStart(),

Modified: cfe/trunk/test/Sema/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=70670&r1=70669&r2=70670&view=diff

==============================================================================
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Sun May  3 02:04:21 2009
@@ -73,6 +73,6 @@
 // PR4077
 int test7(unsigned long long b) {
   int a;
-  asm volatile("foo " : "=a" (a) :"0" (b)); // expected-error {{input with type 'unsigned long long' matching output with type 'int'}}
+  asm volatile("foo %0 %1" : "=a" (a) :"0" (b)); // expected-error {{input with type 'unsigned long long' matching output with type 'int'}}
   return a;
 }





More information about the cfe-commits mailing list