diff options
author | Coby Tayree <coby.tayree@intel.com> | 2017-07-24 07:04:55 +0000 |
---|---|---|
committer | Coby Tayree <coby.tayree@intel.com> | 2017-07-24 07:04:55 +0000 |
commit | c48388d3d3017ba1dd060dc17722bd44c6aa042b (patch) | |
tree | fc86222cacd9fb89b8e9523e7e39ba0ce1bc30a3 | |
parent | 6c5c6aa9d8d66d431240c75725d62400fc78bf00 (diff) | |
download | bcm5719-llvm-c48388d3d3017ba1dd060dc17722bd44c6aa042b.tar.gz bcm5719-llvm-c48388d3d3017ba1dd060dc17722bd44c6aa042b.zip |
[X86][InlineAsm][Ms Compatibility]Prefer variable name over a register when the two collides
On MS-style, the following snippet:
int eax;
__asm mov eax, ebx
should yield loading of ebx, into the location pointed by the variable eax
This patch sees to it.
Currently, a reg-to-reg move would have been invoked.
clang: D34740
Differential Revision: https://reviews.llvm.org/D34739
llvm-svn: 308866
-rw-r--r-- | llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index c1d216c8b7a..31951c928f2 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -944,7 +944,8 @@ bool X86AsmParser::ParseRegister(unsigned &RegNo, EndLoc = Tok.getEndLoc(); if (Tok.isNot(AsmToken::Identifier)) { - if (isParsingIntelSyntax()) return true; + if (isParsingIntelSyntax()) + return true; return Error(StartLoc, "invalid register name", SMRange(StartLoc, EndLoc)); } @@ -955,6 +956,16 @@ bool X86AsmParser::ParseRegister(unsigned &RegNo, if (RegNo == 0) RegNo = MatchRegisterName(Tok.getString().lower()); + // In MS inline-asm we allow variables to be named as registers, and + // give them precedence over actual registers + // However - we require the match to be case sensitive + if (isParsingInlineAsm() && isParsingIntelSyntax() && RegNo) { + StringRef LineBuf(Tok.getIdentifier().data()); + InlineAsmIdentifierInfo Info; + if (SemaCallback->LookupInlineAsmIdentifier(LineBuf, Info, false)) + return true; + } + // The "flags" register cannot be referenced directly. // Treat it as an identifier instead. if (isParsingInlineAsm() && isParsingIntelSyntax() && RegNo == X86::EFLAGS) |