[PATCH] D11512: Fix conflict for referencing "flags" variable in X86 assembly syntax
Marina Yatsina
marina.yatsina at intel.com
Sun Jul 26 10:06:57 PDT 2015
myatsina created this revision.
myatsina added reviewers: rnk, MatzeB.
myatsina added a subscriber: llvm-commits.
myatsina set the repository for this revision to rL LLVM.
This asm instruction passes compilation:
mov eax, flags2
This asm instruction fails compilation:
mov eax, flags
When parsing the latter, the X86AsmParser “flags” should be matched to a memory location and not to the implicit EFLAGS register.
Repository:
rL LLVM
http://reviews.llvm.org/D11512
Files:
lib/Target/X86/AsmParser/X86AsmParser.cpp
Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -805,6 +805,7 @@
CreateX86AsmInstrumentation(Options, Parser.getContext(), STI));
}
+ unsigned FixMatchedRegister(unsigned RegNo);
bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) override;
void SetFrameRegister(unsigned RegNo) override;
@@ -882,6 +883,16 @@
return true;
}
+unsigned X86AsmParser::FixMatchedRegister(unsigned RegNo) {
+
+ if (isParsingInlineAsm() && RegNo == X86::EFLAGS) {
+ // Cannot address reg called "flags" - this is just an identifier!
+ return 0;
+ }
+
+ return RegNo;
+}
+
bool X86AsmParser::ParseRegister(unsigned &RegNo,
SMLoc &StartLoc, SMLoc &EndLoc) {
MCAsmParser &Parser = getParser();
@@ -909,6 +920,8 @@
if (RegNo == 0)
RegNo = MatchRegisterName(Tok.getString().lower());
+ RegNo = FixMatchedRegister(RegNo);
+
if (!is64BitMode()) {
// FIXME: This should be done using Requires<Not64BitMode> and
// Requires<In64BitMode> so "eiz" usage in 64-bit instructions can be also
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11512.30656.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150726/248da049/attachment.bin>
More information about the llvm-commits
mailing list