mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 00:36:34 +00:00
[mlir] Migrate away from PointerUnion::{is,get} (NFC) (#122591)
Note that PointerUnion::{is,get} have been soft deprecated in PointerUnion.h: // FIXME: Replace the uses of is(), get() and dyn_cast() with // isa<T>, cast<T> and the llvm::dyn_cast<T> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
This commit is contained in:
parent
a56eb7c998
commit
4f4e2abb1a
@ -131,7 +131,7 @@ public:
|
||||
if (auto *ptr = handler.dyn_cast<mlir::SourceMgrDiagnosticHandler *>()) {
|
||||
delete ptr;
|
||||
} else {
|
||||
delete handler.get<mlir::SourceMgrDiagnosticVerifierHandler *>();
|
||||
delete cast<mlir::SourceMgrDiagnosticVerifierHandler *>(handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
AbstractSparseLattice(Value value) : AnalysisState(value) {}
|
||||
|
||||
/// Return the value this lattice is located at.
|
||||
Value getAnchor() const { return AnalysisState::getAnchor().get<Value>(); }
|
||||
Value getAnchor() const { return cast<Value>(AnalysisState::getAnchor()); }
|
||||
|
||||
/// Join the information contained in 'rhs' into this lattice. Returns
|
||||
/// if the value of the lattice changed.
|
||||
|
@ -92,7 +92,7 @@ struct constant_op_binder {
|
||||
(void)result;
|
||||
assert(succeeded(result) && "expected ConstantLike op to be foldable");
|
||||
|
||||
if (auto attr = llvm::dyn_cast<AttrT>(foldedOp.front().get<Attribute>())) {
|
||||
if (auto attr = llvm::dyn_cast<AttrT>(cast<Attribute>(foldedOp.front()))) {
|
||||
if (bind_value)
|
||||
*bind_value = attr;
|
||||
return true;
|
||||
|
@ -272,8 +272,9 @@ public:
|
||||
void dump() const { llvm::errs() << *this << "\n"; }
|
||||
|
||||
MLIRContext *getContext() const {
|
||||
return is<Attribute>() ? get<Attribute>().getContext()
|
||||
: get<Value>().getContext();
|
||||
PointerUnion pu = *this;
|
||||
return isa<Attribute>(pu) ? cast<Attribute>(pu).getContext()
|
||||
: cast<Value>(pu).getContext();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -86,7 +86,7 @@ def DataLayoutEntryInterface : AttrInterface<"DataLayoutEntryInterface"> {
|
||||
let extraClassDeclaration = [{
|
||||
/// Returns `true` if the key of this entry is a type.
|
||||
bool isTypeEntry() {
|
||||
return getKey().is<::mlir::Type>();
|
||||
return llvm::isa<::mlir::Type>(getKey());
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ struct NestedAnalysisMap {
|
||||
PassInstrumentor *getPassInstrumentor() const {
|
||||
if (auto *parent = getParent())
|
||||
return parent->getPassInstrumentor();
|
||||
return parentOrInstrumentor.get<PassInstrumentor *>();
|
||||
return cast<PassInstrumentor *>(parentOrInstrumentor);
|
||||
}
|
||||
|
||||
/// The cached analyses for nested operations.
|
||||
|
@ -84,7 +84,7 @@ void LatticeAnchor::print(raw_ostream &os) const {
|
||||
return value.print(os, OpPrintingFlags().skipRegions());
|
||||
}
|
||||
|
||||
return get<ProgramPoint *>()->print(os);
|
||||
return llvm::cast<ProgramPoint *>(*this)->print(os);
|
||||
}
|
||||
|
||||
Location LatticeAnchor::getLoc() const {
|
||||
@ -93,7 +93,7 @@ Location LatticeAnchor::getLoc() const {
|
||||
if (auto value = llvm::dyn_cast<Value>(*this))
|
||||
return value.getLoc();
|
||||
|
||||
ProgramPoint *pp = get<ProgramPoint *>();
|
||||
ProgramPoint *pp = llvm::cast<ProgramPoint *>(*this);
|
||||
if (!pp->isBlockStart())
|
||||
return pp->getPrevOp()->getLoc();
|
||||
return pp->getBlock()->getParent()->getLoc();
|
||||
|
@ -2162,7 +2162,7 @@ OperationParser::parseTrailingLocationSpecifier(OpOrArgument opOrArgument) {
|
||||
if (auto *op = llvm::dyn_cast_if_present<Operation *>(opOrArgument))
|
||||
op->setLoc(directLoc);
|
||||
else
|
||||
opOrArgument.get<BlockArgument>().setLoc(directLoc);
|
||||
cast<BlockArgument>(opOrArgument).setLoc(directLoc);
|
||||
return success();
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,11 @@ struct AttrTypeNumbering {
|
||||
};
|
||||
struct AttributeNumbering : public AttrTypeNumbering {
|
||||
AttributeNumbering(Attribute value) : AttrTypeNumbering(value) {}
|
||||
Attribute getValue() const { return value.get<Attribute>(); }
|
||||
Attribute getValue() const { return cast<Attribute>(value); }
|
||||
};
|
||||
struct TypeNumbering : public AttrTypeNumbering {
|
||||
TypeNumbering(Type value) : AttrTypeNumbering(value) {}
|
||||
Type getValue() const { return value.get<Type>(); }
|
||||
Type getValue() const { return cast<Type>(value); }
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -142,7 +142,7 @@ struct PDLIndexSymbol {
|
||||
const ast::Name *declName = decl->getName();
|
||||
return declName ? declName->getLoc() : decl->getLoc();
|
||||
}
|
||||
return definition.get<const ods::Operation *>()->getLoc();
|
||||
return cast<const ods::Operation *>(definition)->getLoc();
|
||||
}
|
||||
|
||||
/// The main definition of the symbol.
|
||||
@ -470,7 +470,7 @@ PDLDocument::findHover(const lsp::URIForFile &uri,
|
||||
if (const auto *op =
|
||||
llvm::dyn_cast_if_present<const ods::Operation *>(symbol->definition))
|
||||
return buildHoverForOpName(op, hoverRange);
|
||||
const auto *decl = symbol->definition.get<const ast::Decl *>();
|
||||
const auto *decl = cast<const ast::Decl *>(symbol->definition);
|
||||
return findHover(decl, hoverRange);
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,11 @@ struct TableGenRecordSymbol : public TableGenIndexSymbol {
|
||||
~TableGenRecordSymbol() override = default;
|
||||
|
||||
static bool classof(const TableGenIndexSymbol *symbol) {
|
||||
return symbol->definition.is<const Record *>();
|
||||
return isa<const Record *>(symbol->definition);
|
||||
}
|
||||
|
||||
/// Return the value of this symbol.
|
||||
const Record *getValue() const { return definition.get<const Record *>(); }
|
||||
const Record *getValue() const { return cast<const Record *>(definition); }
|
||||
};
|
||||
/// This class represents a single record value symbol.
|
||||
struct TableGenRecordValSymbol : public TableGenIndexSymbol {
|
||||
@ -178,12 +178,12 @@ struct TableGenRecordValSymbol : public TableGenIndexSymbol {
|
||||
~TableGenRecordValSymbol() override = default;
|
||||
|
||||
static bool classof(const TableGenIndexSymbol *symbol) {
|
||||
return symbol->definition.is<const RecordVal *>();
|
||||
return isa<const RecordVal *>(symbol->definition);
|
||||
}
|
||||
|
||||
/// Return the value of this symbol.
|
||||
const RecordVal *getValue() const {
|
||||
return definition.get<const RecordVal *>();
|
||||
return cast<const RecordVal *>(definition);
|
||||
}
|
||||
|
||||
/// The parent record of this symbol.
|
||||
|
@ -260,7 +260,7 @@ OperationFolder::processFoldResults(Operation *op,
|
||||
|
||||
// Check to see if there is a canonicalized version of this constant.
|
||||
auto res = op->getResult(i);
|
||||
Attribute attrRepl = foldResults[i].get<Attribute>();
|
||||
Attribute attrRepl = cast<Attribute>(foldResults[i]);
|
||||
if (auto *constOp =
|
||||
tryGetOrCreateConstant(uniquedConstants, dialect, attrRepl,
|
||||
res.getType(), erasedFoldedLocation)) {
|
||||
|
@ -523,7 +523,7 @@ bool GreedyPatternRewriteDriver::processWorklist() {
|
||||
}
|
||||
// Materialize Attributes as SSA values.
|
||||
Operation *constOp = op->getDialect()->materializeConstant(
|
||||
rewriter, ofr.get<Attribute>(), resultType, op->getLoc());
|
||||
rewriter, cast<Attribute>(ofr), resultType, op->getLoc());
|
||||
|
||||
if (!constOp) {
|
||||
// If materialization fails, cleanup any operations generated for
|
||||
|
Loading…
x
Reference in New Issue
Block a user