[cfe-commits] r165752 - in /cfe/trunk: lib/Sema/SemaStmtAsm.cpp test/CodeGen/ms-inline-asm.c

Chad Rosier mcrosier at apple.com
Thu Oct 11 14:44:42 PDT 2012


Author: mcrosier
Date: Thu Oct 11 16:44:41 2012
New Revision: 165752

URL: http://llvm.org/viewvc/llvm-project?rev=165752&view=rev
Log:
[ms-inline asm] Remove a bunch of parsing code from the front-end, which will be
reimplemented in the AsmParser where it belongs.

Modified:
    cfe/trunk/lib/Sema/SemaStmtAsm.cpp
    cfe/trunk/test/CodeGen/ms-inline-asm.c

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=165752&r1=165751&r2=165752&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Thu Oct 11 16:44:41 2012
@@ -331,28 +331,6 @@
   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;
-}
-
 // getSpelling - Get the spelling of the AsmTok token.
 static StringRef getSpelling(Sema &SemaRef, Token AsmTok) {
   StringRef Asm;
@@ -387,8 +365,7 @@
       return false;
 
   for (unsigned i = 1, e = Pieces.size(); i != e; ++i) {
-    StringRef Op = getMSInlineAsmExprName(Pieces[i]);
-    if (!TI.isValidGCCRegisterName(Op))
+    if (!TI.isValidGCCRegisterName(Pieces[i]))
       return false;
   }
   return true;
@@ -604,13 +581,7 @@
       }
 
       // Expr/Input or Output.
-      StringRef Name = getMSInlineAsmExprName(Pieces[StrIdx][i]);
-
-      // The expr may be a register.
-      // E.g., DWORD PTR [eax]
-      if (Context.getTargetInfo().isValidGCCRegisterName(Name))
-        continue;
-
+      StringRef Name = Pieces[StrIdx][i];
       if (IdentifierInfo *II = &Context.Idents.get(Name)) {
         CXXScopeSpec SS;
         UnqualifiedId Id;
@@ -669,26 +640,6 @@
         Pieces[StrIdx][j] = OutputExprNames[i];
         break;
       }
-      // Check to see if the expression is a substring of the asm piece.
-      std::pair< StringRef, StringRef > Split =	Pieces[StrIdx][j].split(' ');
-      bool isKeyword = llvm::StringSwitch<bool>(Split.first)
-        .Cases("BYTE", "byte", "WORD", "word", "DWORD", true)
-        .Cases("dword", "QWORD", "qword", "XWORD", "xword", true)
-        .Cases("XMMWORD", "xmmword", "YMMWORD", "ymmword", true)
-        .Default(false);
-      if (isKeyword &&
-          Split.second.find_first_of(OutputExprNames[i]) != StringRef::npos) {
-        // Is is a substring, do the replacement.
-        SmallString<32> Res;
-        llvm::raw_svector_ostream OS(Res);
-        OS << '$' << OpNum;
-        std::string piece = Pieces[StrIdx][j].str();
-        size_t found = piece.find(InputExprNames[i]);
-        piece.replace(found, InputExprNames[i].size(), OS.str());
-        OutputExprNames[i] = piece;
-        Pieces[StrIdx][j] = OutputExprNames[i];
-        break;
-      }
     }
   }
   for (unsigned i = 0, e = InputExprNames.size(); i != e; ++i, ++OpNum) {
@@ -704,26 +655,6 @@
         Pieces[StrIdx][j] = InputExprNames[i];
         break;
       }
-      // Check to see if the expression is a substring of the asm piece.
-      std::pair< StringRef, StringRef > Split =	Pieces[StrIdx][j].split(' ');
-      bool isKeyword = llvm::StringSwitch<bool>(Split.first)
-        .Cases("BYTE", "byte", "WORD", "word", "DWORD", true)
-        .Cases("dword", "QWORD", "qword", "XWORD", "xword", true)
-        .Cases("XMMWORD", "xmmword", "YMMWORD", "ymmword", true)
-        .Default(false);
-      if (isKeyword &&
-          Split.second.find_first_of(InputExprNames[i]) != StringRef::npos) {
-        // It is a substring, do the replacement.
-        SmallString<32> Res;
-        llvm::raw_svector_ostream OS(Res);
-        OS << '$' << OpNum;
-        std::string piece = Pieces[StrIdx][j].str();
-        size_t found = piece.find(InputExprNames[i]);
-        piece.replace(found, InputExprNames[i].size(), OS.str());
-        InputExprNames[i] = piece;
-        Pieces[StrIdx][j] = InputExprNames[i];
-        break;
-      }
     }
   }
 

Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=165752&r1=165751&r2=165752&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Thu Oct 11 16:44:41 2012
@@ -131,31 +131,7 @@
 // CHECK: call void asm sideeffect inteldialect "mov eax, $$1", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
 }
 
-void t15(void) {
-  __asm mov eax, DWORD PTR [eax]
-// CHECK: t15
-// CHECK: call void asm sideeffect inteldialect "mov eax, DWORD PTR [eax]", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
-}
-
-void t16(unsigned V) {
-  __asm mov eax, DWORD PTR [V]
-// CHECK: t16
-// CHECK: call void asm sideeffect inteldialect "mov eax, DWORD PTR [$0]", "*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}) nounwind
-}
-
-void t17(void) {
-  __asm mov eax, dword ptr [eax]
-// CHECK: t17
-// CHECK: call void asm sideeffect inteldialect "mov eax, dword ptr [eax]", "~{eax},~{dirflag},~{fpsr},~{flags}"() nounwind
-}
-
-void t18(void) {
-  __asm mov dword ptr [eax], eax
-// CHECK: t18
-// CHECK: call void asm sideeffect inteldialect "mov dword ptr [eax], eax", "~{dirflag},~{fpsr},~{flags}"() nounwind
-}
-
-unsigned t19(void) {
+unsigned t15(void) {
   unsigned i = 1, j, l = 1, m;
   __asm {
     mov eax, i
@@ -164,6 +140,6 @@
     mov m, eax
   }
   return j + m;
-// CHECK: t19
+// CHECK: t15
 // CHECK: call void asm sideeffect inteldialect "mov eax, $2\0A\09mov $0, eax\0A\09mov eax, $3\0A\09mov $1, eax", "=*m,=*m,*m,*m,~{eax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}, i32* %{{.*}}) nounwind
 }





More information about the cfe-commits mailing list