Skip to content

Commit 910a73f

Browse files
authored
[X86] Make POP imply pointer-size operands, as with PUSH for Intel syntax (#114533)
On x86-32 the word PUSH (50+rd) and POP (58+rd) instructions assume only 32-bit operands, and on x86-64 they assume only 64-bit operands; in neither case should the absence of an operand size be ambiguous. Those special case were added in f6fb780 and lacking of POP seemed an oversight. This closes #114531.
1 parent 61e50b9 commit 910a73f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4495,7 +4495,7 @@ bool X86AsmParser::matchAndEmitIntelInstruction(
44954495
// compatible with gas.
44964496
StringRef Mnemonic = (static_cast<X86Operand &>(*Operands[0])).getToken();
44974497
if (UnsizedMemOp) {
4498-
static const char *const PtrSizedInstrs[] = {"call", "jmp", "push"};
4498+
static const char *const PtrSizedInstrs[] = {"call", "jmp", "push", "pop"};
44994499
for (const char *Instr : PtrSizedInstrs) {
45004500
if (Mnemonic == Instr) {
45014501
UnsizedMemOp->Mem.Size = getPointerWidth();

llvm/test/MC/X86/intel-syntax-ambiguous.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ sub [eax], 1
3030
// gas assumes these instructions are pointer-sized by default, and we follow
3131
// suit.
3232
push [eax]
33+
pop [eax]
3334
call [eax]
3435
jmp [eax]
3536
// CHECK-NOT: error:

llvm/test/MC/X86/intel-syntax-ptr-sized.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ push [eax]
66
// CHECK: pushl (%eax)
77
call [eax]
88
// CHECK: calll *(%eax)
9+
pop [eax]
10+
// CHECK: popl (%eax)
911
jmp [eax]
1012
// CHECK: jmpl *(%eax)
1113

@@ -25,6 +27,8 @@ push [eax]
2527
// CHECK: pushw (%eax)
2628
call [eax]
2729
// CHECK: callw *(%eax)
30+
pop [eax]
31+
// CHECK: popw (%eax)
2832
jmp [eax]
2933
// CHECK: jmpw *(%eax)
3034

0 commit comments

Comments
 (0)