llvm.org GIT mirror llvm / 3a64f19
[X86] MS inline asm: produce error when encountering "<type> ptr <reg name>" Currently "<type> ptr <reg name>" treated as <reg name> in MS inline asm, ignoring the "<type> ptr" completely and possibly ignoring the intention of the user. Fixed llvm to produce an error when encountering "<type> ptr <reg name>" operands. For example: andpd xmm1,xmmword ptr xmm1 --> andpd xmm1, xmm1 though andpd has 2 possible matching formats - andpd xmm, xmm/m128 Patch by: ziv.izhar@intel.com Differential Revision: http://reviews.llvm.org/D14607 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254607 91177308-0d34-0410-b5e6-96231b3b80d8 Marina Yatsina 4 years ago
2 changed file(s) with 23 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
16921692 return ParseIntelOperator(IOK_TYPE);
16931693 }
16941694
1695 bool PtrInOperand = false;
16951696 unsigned Size = getIntelMemOperandSize(Tok.getString());
16961697 if (Size) {
16971698 Parser.Lex(); // Eat operand size (e.g., byte, word).
16981699 if (Tok.getString() != "PTR" && Tok.getString() != "ptr")
16991700 return ErrorOperand(Tok.getLoc(), "Expected 'PTR' or 'ptr' token!");
17001701 Parser.Lex(); // Eat ptr.
1702 PtrInOperand = true;
17011703 }
17021704 Start = Tok.getLoc();
17031705
17531755 if (!ParseRegister(RegNo, Start, End)) {
17541756 // If this is a segment register followed by a ':', then this is the start
17551757 // of a segment override, otherwise this is a normal register reference.
1756 if (getLexer().isNot(AsmToken::Colon))
1758 // In case it is a normal register and there is ptr in the operand this
1759 // is an error
1760 if (getLexer().isNot(AsmToken::Colon)){
1761 if (PtrInOperand){
1762 return ErrorOperand(Start, "expected memory operand after "
1763 "'ptr', found register operand instead");
1764 }
17571765 return X86Operand::CreateReg(RegNo, Start, End);
1758
1766 }
1767
17591768 return ParseIntelSegmentOverride(/*SegReg=*/RegNo, Start, Size);
17601769 }
17611770
4444
4545 fadd "?half@?0??bar@@YAXXZ@4NA"
4646 // CHECK: error: ambiguous operand size for instruction 'fadd'
47
48 // Instruction line with PTR inside check that they don't accept register as memory.
49
50 // CHECK: error: expected memory operand after 'ptr', found register operand instead
51 // CHECK: andps xmm1, xmmword ptr xmm1
52 andps xmm1, xmmword ptr xmm1
53 // CHECK: error: expected memory operand after 'ptr', found register operand instead
54 // CHECK: andps xmmword ptr xmm1, xmm1
55 andps xmmword ptr xmm1, xmm1
56 // CHECK: error: expected memory operand after 'ptr', found register operand instead
57 // CHECK: mov dword ptr eax, ebx
58 mov dword ptr eax, ebx