[PATCH] D22585: [MC][X86] Fix Intel Operand assembly parsing for .set ids
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 13:10:16 PDT 2016
niravd created this revision.
niravd added a reviewer: rnk.
niravd added a subscriber: llvm-commits.
Fix intel syntax special case identifier operands that refer to a constant
(e.g. .set <ID> n) to be interpreted as immediate not memory in parsing.
https://reviews.llvm.org/D22585
Files:
lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/X86/intel-syntax-encoding.s
Index: test/MC/X86/intel-syntax-encoding.s
===================================================================
--- test/MC/X86/intel-syntax-encoding.s
+++ test/MC/X86/intel-syntax-encoding.s
@@ -76,3 +76,6 @@
// CHECK: encoding: [0xca,0x08,0x00]
retf 8
+ .set FOO, 2
+ cmp eax, FOO
+// CHECK: encoding: [0x83,0xf8,0x02]
Index: lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1615,7 +1615,8 @@
if (!isParsingInlineAsm()) {
if (getParser().parsePrimaryExpr(Val, End))
return ErrorOperand(Tok.getLoc(), "unknown token in expression");
-
+ if (Val->getKind() == MCExpr::Constant)
+ return X86Operand::CreateImm(Val, Start, End);
return X86Operand::CreateMem(getPointerWidth(), Val, Start, End, Size);
}
@@ -1625,9 +1626,10 @@
/*Unevaluated=*/false, End))
return nullptr;
- if (!getLexer().is(AsmToken::LBrac))
+ if (getLexer().isNot(AsmToken::LBrac)){
return CreateMemForInlineAsm(/*SegReg=*/0, Val, /*BaseReg=*/0, /*IndexReg=*/0,
/*Scale=*/1, Start, End, Size, Identifier, Info);
+ }
Parser.Lex(); // Eat '['
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22585.64740.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160720/a8fe8e87/attachment.bin>
More information about the llvm-commits
mailing list