[ms-inline asm] Enhance the isSimpleMSAsm() function to handle operands with pointer size
directives (e.g., dword ptr [eax]). llvm-svn: 165031
This commit is contained in:
parent
feb805fcf2
commit
04d5664295
|
@ -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, \
|
||||
|
|
Loading…
Reference in New Issue