[llvm] [PowerPC] Add error for incorrect use of memory operands (PR #114277)
Hubert Tong via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 20:23:56 PST 2024
================
@@ -1252,14 +1259,30 @@ void PPCAsmParser::processInstruction(MCInst &Inst,
static std::string PPCMnemonicSpellCheck(StringRef S, const FeatureBitset &FBS,
unsigned VariantID = 0);
+// Check that the register+immediate memory operand is in the right position and
+// is expected by the instruction
+static bool validateMemOp(const OperandVector &Operands, bool isMemriOp) {
+ for (size_t idx = 0; idx < Operands.size(); ++idx) {
+ const PPCOperand &Op = static_cast<const PPCOperand &>(*Operands[idx]);
+ if ((idx == 3 && Op.isMemOpBase() != isMemriOp) ||
+ (idx != 3 && Op.isMemOpBase())) {
+ return false;
+ }
----------------
hubert-reinterpretcast wrote:
Logic can be expressed more succinctly:
```suggestion
if (Op.isMemOpBase() != (idx == 3 && isMemriOp))
return false;
```
https://github.com/llvm/llvm-project/pull/114277
More information about the llvm-commits
mailing list