[PATCH] D14607: MS inline asm: produce "ambiguous" error when encountering "<type> ptr <reg name>"
Marina Yatsina via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 04:20:05 PST 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254607: [X86] MS inline asm: produce error when encountering "<type> ptr <reg name>" (authored by myatsina).
Changed prior to commit:
http://reviews.llvm.org/D14607?vs=41214&id=41739#toc
Repository:
rL LLVM
http://reviews.llvm.org/D14607
Files:
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/trunk/test/MC/X86/intel-syntax-ambiguous.s
Index: llvm/trunk/test/MC/X86/intel-syntax-ambiguous.s
===================================================================
--- llvm/trunk/test/MC/X86/intel-syntax-ambiguous.s
+++ llvm/trunk/test/MC/X86/intel-syntax-ambiguous.s
@@ -45,3 +45,15 @@
fadd "?half@?0??bar@@YAXXZ at 4NA"
// CHECK: error: ambiguous operand size for instruction 'fadd'
+
+// Instruction line with PTR inside check that they don't accept register as memory.
+
+// CHECK: error: expected memory operand after 'ptr', found register operand instead
+// CHECK: andps xmm1, xmmword ptr xmm1
+andps xmm1, xmmword ptr xmm1
+// CHECK: error: expected memory operand after 'ptr', found register operand instead
+// CHECK: andps xmmword ptr xmm1, xmm1
+andps xmmword ptr xmm1, xmm1
+// CHECK: error: expected memory operand after 'ptr', found register operand instead
+// CHECK: mov dword ptr eax, ebx
+mov dword ptr eax, ebx
Index: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1693,12 +1693,14 @@
return ParseIntelOperator(IOK_TYPE);
}
+ bool PtrInOperand = false;
unsigned Size = getIntelMemOperandSize(Tok.getString());
if (Size) {
Parser.Lex(); // Eat operand size (e.g., byte, word).
if (Tok.getString() != "PTR" && Tok.getString() != "ptr")
return ErrorOperand(Tok.getLoc(), "Expected 'PTR' or 'ptr' token!");
Parser.Lex(); // Eat ptr.
+ PtrInOperand = true;
}
Start = Tok.getLoc();
@@ -1754,9 +1756,16 @@
if (!ParseRegister(RegNo, Start, End)) {
// If this is a segment register followed by a ':', then this is the start
// of a segment override, otherwise this is a normal register reference.
- if (getLexer().isNot(AsmToken::Colon))
+ // In case it is a normal register and there is ptr in the operand this
+ // is an error
+ if (getLexer().isNot(AsmToken::Colon)){
+ if (PtrInOperand){
+ return ErrorOperand(Start, "expected memory operand after "
+ "'ptr', found register operand instead");
+ }
return X86Operand::CreateReg(RegNo, Start, End);
-
+ }
+
return ParseIntelSegmentOverride(/*SegReg=*/RegNo, Start, Size);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14607.41739.patch
Type: text/x-patch
Size: 2347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/4d3139c2/attachment.bin>
More information about the llvm-commits
mailing list