[llvm] [X86][MC] Check AdSize16 for 16-bit addressing (PR #99761)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 20 06:42:09 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Phoebe Wang (phoebewang)
<details>
<summary>Changes</summary>
Fixes: #<!-- -->99735
---
Full diff: https://github.com/llvm/llvm-project/pull/99761.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp (+4-1)
- (modified) llvm/test/MC/X86/x86-32-coverage.s (+9-1)
``````````diff
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
index 3cd0af0c7f546..6553e1cc4a930 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
@@ -691,9 +691,12 @@ void X86MCCodeEmitter::emitMemModRMByte(
unsigned BaseRegNo = BaseReg ? getX86RegNum(Base) : -1U;
+ bool IsAdSize16 = STI.hasFeature(X86::Is32Bit) &&
+ (TSFlags & X86II::AdSizeMask) == X86II::AdSize16;
+
// 16-bit addressing forms of the ModR/M byte have a different encoding for
// the R/M field and are far more limited in which registers can be used.
- if (X86_MC::is16BitMemOperand(MI, Op, STI)) {
+ if (IsAdSize16 || X86_MC::is16BitMemOperand(MI, Op, STI)) {
if (BaseReg) {
// For 32-bit addressing, the row and column values in Table 2-2 are
// basically the same. It's AX/CX/DX/BX/SP/BP/SI/DI in that order, with
diff --git a/llvm/test/MC/X86/x86-32-coverage.s b/llvm/test/MC/X86/x86-32-coverage.s
index fbe2714aed263..5475946a9d216 100644
--- a/llvm/test/MC/X86/x86-32-coverage.s
+++ b/llvm/test/MC/X86/x86-32-coverage.s
@@ -10790,7 +10790,7 @@ btcl $4, (%eax)
movdir64b 485498096, %ecx
// CHECK: movdir64b 485498096, %cx
-// CHECK: # encoding: [0x67,0x66,0x0f,0x38,0xf8,0x0d,0xf0,0x1c,0xf0,0x1c]
+// CHECK: # encoding: [0x67,0x66,0x0f,0x38,0xf8,0x0e,0xf0,0x1c]
movdir64b 485498096, %cx
// CHECK: movdir64b (%edx), %eax
@@ -10877,6 +10877,10 @@ enqcmd (%bx,%di), %di
// CHECK: encoding: [0x67,0xf2,0x0f,0x38,0xf8,0x81,0xc0,0x1f]
enqcmd 8128(%bx,%di), %ax
+// CHECK: enqcmd 485498096, %cx
+// CHECK: encoding: [0x67,0xf2,0x0f,0x38,0xf8,0x0e,0xf0,0x1c]
+enqcmd 485498096, %cx
+
// CHECK: enqcmds (%bx,%di), %di
// CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x39]
enqcmds (%bx,%di), %di
@@ -10885,6 +10889,10 @@ enqcmds (%bx,%di), %di
// CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x81,0xc0,0x1f]
enqcmds 8128(%bx,%di), %ax
+// CHECK: enqcmds 485498096, %cx
+// CHECK: encoding: [0x67,0xf3,0x0f,0x38,0xf8,0x0e,0xf0,0x1c]
+enqcmds 485498096, %cx
+
// CHECK: serialize
// CHECK: encoding: [0x0f,0x01,0xe8]
serialize
``````````
</details>
https://github.com/llvm/llvm-project/pull/99761
More information about the llvm-commits
mailing list