[llvm] [X86][MC][AsmParser] Reject H-byte regs with VEX/EVEX-encoded 8-bit RR (NDD) (PR #160039)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 24 01:03:54 PDT 2025
================
@@ -4018,9 +4018,14 @@ bool X86AsmParser::validateInstruction(MCInst &Inst, const OperandVector &Ops) {
return Error(Ops[0]->getStartLoc(), "all tmm registers must be distinct");
}
- // Check that we aren't mixing AH/BH/CH/DH with REX prefix. We only need to
- // check this with the legacy encoding, VEX/EVEX/XOP don't use REX.
- if ((TSFlags & X86II::EncodingMask) == 0) {
+ // High 8-bit regs (AH/BH/CH/DH) are incompatible with encodings that imply
+ // extended prefixes:
+ // * Legacy path that would emit a REX (e.g. uses r8..r15 or sil/dil/bpl/spl)
+ // * EVEX
+ // * REX2
+ // VEX/XOP don't use REX; they are excluded from the legacy check.
+ const unsigned Enc = TSFlags & X86II::EncodingMask;
+ if (Enc != X86II::VEX && Enc != X86II::XOP) {
MCRegister HReg;
bool UsesRex = TSFlags & X86II::REX_W;
----------------
phoebewang wrote:
I don't think we can specify REX_R/X/B in assemble.
https://github.com/llvm/llvm-project/pull/160039
More information about the llvm-commits
mailing list