template <>
struct DenseMapInfo<mlir::ProgramPoint>
: public DenseMapInfo<mlir::ProgramPoint::ParentTy> {};
+
+// Allow llvm::cast style functions.
+template <typename To>
+struct CastInfo<To, mlir::ProgramPoint>
+ : public CastInfo<To, mlir::ProgramPoint::PointerUnion> {};
+
+template <typename To>
+struct CastInfo<To, const mlir::ProgramPoint>
+ : public CastInfo<To, const mlir::ProgramPoint::PointerUnion> {};
+
} // end namespace llvm
#endif // MLIR_ANALYSIS_DATAFLOWFRAMEWORK_H
} // namespace LLVM
} // namespace mlir
+namespace llvm {
+
+// Allow llvm::cast style functions.
+template <typename To>
+struct CastInfo<To, mlir::LLVM::GEPArg>
+ : public CastInfo<To, mlir::LLVM::GEPArg::PointerUnion> {};
+
+template <typename To>
+struct CastInfo<To, const mlir::LLVM::GEPArg>
+ : public CastInfo<To, const mlir::LLVM::GEPArg::PointerUnion> {};
+
+} // namespace llvm
+
#endif // MLIR_DIALECT_LLVMIR_LLVMDIALECT_H_
void dump() const { llvm::errs() << *this << "\n"; }
};
+// Temporarily exit the MLIR namespace to add casting support as later code in
+// this uses it. The CastInfo must come after the OpFoldResult definition and
+// before any cast function calls depending on CastInfo.
+
+} // namespace mlir
+
+namespace llvm {
+
+// Allow llvm::cast style functions.
+template <typename To>
+struct CastInfo<To, mlir::OpFoldResult>
+ : public CastInfo<To, mlir::OpFoldResult::PointerUnion> {};
+
+template <typename To>
+struct CastInfo<To, const mlir::OpFoldResult>
+ : public CastInfo<To, const mlir::OpFoldResult::PointerUnion> {};
+
+} // namespace llvm
+
+namespace mlir {
+
/// Allow printing to a stream.
inline raw_ostream &operator<<(raw_ostream &os, OpFoldResult ofr) {
- if (Value value = ofr.dyn_cast<Value>())
+ if (Value value = llvm::dyn_cast_if_present<Value>(ofr))
value.print(os);
else
- ofr.dyn_cast<Attribute>().print(os);
+ llvm::dyn_cast_if_present<Attribute>(ofr).print(os);
return os;
}
-
/// Allow printing to a stream.
inline raw_ostream &operator<<(raw_ostream &os, OpState op) {
op.print(os, OpPrintingFlags().useLocalScope());
return failure();
if (OpFoldResult result = Trait::foldTrait(op, operands)) {
- if (result.template dyn_cast<Value>() != op->getResult(0))
+ if (llvm::dyn_cast_if_present<Value>(result) != op->getResult(0))
results.push_back(result);
return success();
}
// If the fold failed or was in-place, try to fold the traits of the
// operation.
- if (!result || result.template dyn_cast<Value>() == op->getResult(0)) {
+ if (!result ||
+ llvm::dyn_cast_if_present<Value>(result) == op->getResult(0)) {
if (succeeded(op_definition_impl::foldTraits<Traits<ConcreteType>...>(
op, operands, results)))
return success();
}
static bool isEqual(T lhs, T rhs) { return lhs == rhs; }
};
-
} // namespace llvm
#endif
} // end namespace mlir
+namespace llvm {
+
+// Allow llvm::cast style functions.
+template <typename To>
+struct CastInfo<To, mlir::IRUnit>
+ : public CastInfo<To, mlir::IRUnit::PointerUnion> {};
+
+template <typename To>
+struct CastInfo<To, const mlir::IRUnit>
+ : public CastInfo<To, const mlir::IRUnit::PointerUnion> {};
+
+} // namespace llvm
+
#endif // MLIR_IR_UNIT_H
namespace llvm {
+// Allow llvm::cast style functions.
template <typename To>
struct CastInfo<To, mlir::CallInterfaceCallable>
: public CastInfo<To, mlir::CallInterfaceCallable::PointerUnion> {};
+template <typename To>
+struct CastInfo<To, const mlir::CallInterfaceCallable>
+ : public CastInfo<To, const mlir::CallInterfaceCallable::PointerUnion> {};
+
} // namespace llvm
#endif // MLIR_INTERFACES_CALLINTERFACES_H