[llvm] MC: Make POP imply pointer-size operands, as with PUSH (PR #114533)
LIU Hao via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 07:34:53 PDT 2024
https://github.com/lhmouse updated https://github.com/llvm/llvm-project/pull/114533
>From 6dab8dc195cde9073b93ab1ee7125d8614db68c3 Mon Sep 17 00:00:00 2001
From: LIU Hao <lh_mouse at 126.com>
Date: Fri, 1 Nov 2024 19:54:19 +0800
Subject: [PATCH] MC: Make POP imply pointer-size operands, as with PUSH
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 f6fb78089060818b4352b540abc44da4f62b95ef
and lack of POP seemed an oversight.
This closes https://github.com/llvm/llvm-project/issues/114531.
Signed-off-by: LIU Hao <lh_mouse at 126.com>
---
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 2 +-
llvm/test/MC/X86/intel-syntax-ambiguous.s | 1 +
llvm/test/MC/X86/intel-syntax-ptr-sized.s | 4 ++++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index ae30d4dfc70f53..5a0d98da4146ee 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -4495,7 +4495,7 @@ bool X86AsmParser::matchAndEmitIntelInstruction(
// compatible with gas.
StringRef Mnemonic = (static_cast<X86Operand &>(*Operands[0])).getToken();
if (UnsizedMemOp) {
- static const char *const PtrSizedInstrs[] = {"call", "jmp", "push"};
+ static const char *const PtrSizedInstrs[] = {"call", "jmp", "push", "pop"};
for (const char *Instr : PtrSizedInstrs) {
if (Mnemonic == Instr) {
UnsizedMemOp->Mem.Size = getPointerWidth();
diff --git a/llvm/test/MC/X86/intel-syntax-ambiguous.s b/llvm/test/MC/X86/intel-syntax-ambiguous.s
index e90cca820043b5..ea38feefe24591 100644
--- a/llvm/test/MC/X86/intel-syntax-ambiguous.s
+++ b/llvm/test/MC/X86/intel-syntax-ambiguous.s
@@ -30,6 +30,7 @@ sub [eax], 1
// gas assumes these instructions are pointer-sized by default, and we follow
// suit.
push [eax]
+pop [eax]
call [eax]
jmp [eax]
// CHECK-NOT: error:
diff --git a/llvm/test/MC/X86/intel-syntax-ptr-sized.s b/llvm/test/MC/X86/intel-syntax-ptr-sized.s
index a360557eaa6a42..0393d8c84dfba5 100644
--- a/llvm/test/MC/X86/intel-syntax-ptr-sized.s
+++ b/llvm/test/MC/X86/intel-syntax-ptr-sized.s
@@ -6,6 +6,8 @@ push [eax]
// CHECK: pushl (%eax)
call [eax]
// CHECK: calll *(%eax)
+pop [eax]
+// CHECK: popl (%eax)
jmp [eax]
// CHECK: jmpl *(%eax)
@@ -25,6 +27,8 @@ push [eax]
// CHECK: pushw (%eax)
call [eax]
// CHECK: callw *(%eax)
+pop [eax]
+// CHECK: popw (%eax)
jmp [eax]
// CHECK: jmpw *(%eax)
More information about the llvm-commits
mailing list