[llvm] [RISCV] Align MCOperandPredicates with AsmParser (PR #146184)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 20:12:03 PDT 2025
================
@@ -63,12 +63,31 @@ bool MCOperand::evaluateAsConstantImm(int64_t &Imm) const {
}
bool MCOperand::isBareSymbolRef() const {
- assert(isExpr() &&
- "isBareSymbolRef expects only expressions");
+ MCExpr::Spec Specifier;
+ return isSimpleSymbolRef(Specifier) && Specifier == 0;
+}
+
+bool MCOperand::isSimpleSymbolRef(MCExpr::Spec &Specifier) const {
+ assert(isExpr() && "isSimpleSymbolRef expects only expressions");
const MCExpr *Expr = getExpr();
MCExpr::ExprKind Kind = getExpr()->getKind();
- return Kind == MCExpr::SymbolRef &&
- cast<MCSymbolRefExpr>(Expr)->getSpecifier() == 0;
+
+ switch (Kind) {
+ case MCExpr::Binary:
+ case MCExpr::Unary:
+ case MCExpr::Constant:
+ break;
+ case MCExpr::Target:
+ // It's not clear this is right, does MCTargetExpr need another virtual method?
+ break;
+ case MCExpr::SymbolRef:
+ Specifier = cast<MCSymbolRefExpr>(Expr)->getSpecifier();
+ return true;
+ case MCExpr::Specifier:
+ Specifier = cast<MCSpecifierExpr>(Expr)->getSpecifier();
+ return true;
+ }
+ return false;
----------------
MaskRay wrote:
Looking. I have migrated most targets to use MCSpecifierExpr.
https://github.com/llvm/llvm-project/pull/146184
More information about the llvm-commits
mailing list