[cfe-commits] r165031 - /cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Chad Rosier mcrosier at apple.com
Tue Oct 2 11:51:05 PDT 2012


Author: mcrosier
Date: Tue Oct  2 13:51:05 2012
New Revision: 165031

URL: http://llvm.org/viewvc/llvm-project?rev=165031&view=rev
Log:
[ms-inline asm] Enhance the isSimpleMSAsm() function to handle operands with pointer size
directives (e.g., dword ptr [eax]).

Modified:
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=165031&r1=165030&r2=165031&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Oct  2 13:51:05 2012
@@ -331,6 +331,28 @@
   return Ret;
 }
 
+// Check to see if the expression is a substring of the asm operand.
+static StringRef getMSInlineAsmExprName(StringRef Name) {
+  // Strip off the size directives.
+  // E.g., DWORD PTR [V] -> V
+  if (Name.startswith("BYTE") || Name.startswith("byte") ||
+      Name.startswith("WORD") || Name.startswith("word") ||
+      Name.startswith("DWORD") || Name.startswith("dword") ||
+      Name.startswith("QWORD") || Name.startswith("qword") ||
+      Name.startswith("XWORD") || Name.startswith("xword") ||
+      Name.startswith("XMMWORD") || Name.startswith("xmmword") ||
+      Name.startswith("YMMWORD") || Name.startswith("ymmword")) {
+    std::pair< StringRef, StringRef > SplitName = Name.split(' ');
+    assert((SplitName.second.startswith("PTR") ||
+            SplitName.second.startswith("ptr")) &&
+           "Expected PTR/ptr!");
+    SplitName = SplitName.second.split('[');
+    SplitName = SplitName.second.split(']');
+    return SplitName.first;
+  }
+  return Name;
+}
+
 // getIdentifierInfo - Given a Name and a range of tokens, find the associated
 // IdentifierInfo*.
 static IdentifierInfo *getIdentifierInfo(StringRef Name,
@@ -377,9 +399,11 @@
   if (isMSAsmKeyword(Pieces[0]))
       return false;
 
-  for (unsigned i = 1, e = Pieces.size(); i != e; ++i)
-    if (!TI.isValidGCCRegisterName(Pieces[i]))
+  for (unsigned i = 1, e = Pieces.size(); i != e; ++i) {
+    StringRef Op = getMSInlineAsmExprName(Pieces[i]);
+    if (!TI.isValidGCCRegisterName(Op))
       return false;
+  }
   return true;
 }
 
@@ -458,28 +482,6 @@
   return false;
 }
 
-// Check to see if the expression is a substring of the asm operand.
-static StringRef getMSInlineAsmExprName(StringRef Name) {
-  // Strip off the size directives.
-  // E.g., DWORD PTR [V] -> V
-  if (Name.startswith("BYTE") || Name.startswith("byte") ||
-      Name.startswith("WORD") || Name.startswith("word") ||
-      Name.startswith("DWORD") || Name.startswith("dword") ||
-      Name.startswith("QWORD") || Name.startswith("qword") ||
-      Name.startswith("XWORD") || Name.startswith("xword") ||
-      Name.startswith("XMMWORD") || Name.startswith("xmmword") ||
-      Name.startswith("YMMWORD") || Name.startswith("ymmword")) {
-    std::pair< StringRef, StringRef > SplitName = Name.split(' ');
-    assert((SplitName.second.startswith("PTR") ||
-            SplitName.second.startswith("ptr")) &&
-           "Expected PTR/ptr!");
-    SplitName = SplitName.second.split('[');
-    SplitName = SplitName.second.split(']');
-    return SplitName.first;
-  }
-  return Name;
-}
-
 #define DEF_SIMPLE_MSASM(STR)                                                \
   MSAsmStmt *NS =                                                            \
     new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true,   \





More information about the cfe-commits mailing list