aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmtAsm.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-10-02 18:51:05 +0000
committerChad Rosier <mcrosier@apple.com>2012-10-02 18:51:05 +0000
commit180d9d98fb51c7f6719d56a73bfd09400502986c (patch)
treeed54f8a07f0a18b50a34600e5a48bb6619a86502 /lib/Sema/SemaStmtAsm.cpp
parentad90d1074b280ee018b1ca593cf53cd9b072c116 (diff)
[ms-inline asm] Enhance the isSimpleMSAsm() function to handle operands with pointer size
directives (e.g., dword ptr [eax]). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmtAsm.cpp')
-rw-r--r--lib/Sema/SemaStmtAsm.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp
index 81ae7e70e4..3c3a9eb0b5 100644
--- a/lib/Sema/SemaStmtAsm.cpp
+++ b/lib/Sema/SemaStmtAsm.cpp
@@ -331,6 +331,28 @@ static bool isMSAsmKeyword(StringRef Name) {
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 @@ static bool isSimpleMSAsm(std::vector<StringRef> &Pieces,
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 @@ static bool buildMSAsmStrings(Sema &SemaRef,
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, \