[llvm] [ms] [llvm-ml] Allow PTR casting of registers to their own size (PR #132751)
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 24 16:48:00 PDT 2025
================
@@ -2601,9 +2631,20 @@ bool X86AsmParser::parseIntelOperand(OperandVector &Operands, StringRef Name) {
return Error(Start, "rip can only be used as a base register");
// A Register followed by ':' is considered a segment override
if (Tok.isNot(AsmToken::Colon)) {
- if (PtrInOperand)
- return Error(Start, "expected memory operand after 'ptr', "
- "found register operand instead");
+ if (PtrInOperand) {
+ if (!Parser.isParsingMasm())
+ return Error(Start, "expected memory operand after 'ptr', "
+ "found register operand instead");
+
+ // If we are parsing MASM, we are allowed to cast registers to their own
+ // sizes, but not to other types.
+ if (RegSizeInBits(*getContext().getRegisterInfo(), RegNo) != Size)
+ return Error(
+ Start,
+ "cannot cast register '" +
+ StringRef(getContext().getRegisterInfo()->getName(RegNo)) +
+ "' to '" + SizeStr + "'; size does not match");
----------------
compnerd wrote:
I wouldn't mind getting a second opinion on the diagnostic that we emit.
https://github.com/llvm/llvm-project/pull/132751
More information about the llvm-commits
mailing list