[llvm] 910a73f - [X86] Make POP imply pointer-size operands, as with PUSH for Intel syntax (#114533)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 17:07:27 PST 2024


Author: LIU Hao
Date: 2024-11-04T17:07:24-08:00
New Revision: 910a73f3aa56388028d87e319862580daaf03152

URL: https://github.com/llvm/llvm-project/commit/910a73f3aa56388028d87e319862580daaf03152
DIFF: https://github.com/llvm/llvm-project/commit/910a73f3aa56388028d87e319862580daaf03152.diff

LOG: [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
f6fb78089060818b4352b540abc44da4f62b95ef and lacking of POP seemed an
oversight.

This closes https://github.com/llvm/llvm-project/issues/114531.

Added: 
    

Modified: 
    llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
    llvm/test/MC/X86/intel-syntax-ambiguous.s
    llvm/test/MC/X86/intel-syntax-ptr-sized.s

Removed: 
    


################################################################################
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