================ @@ -37,63 +37,78 @@ using namespace llvm; namespace cir { namespace direct { -class CIRAttrToValue : public CirAttrVisitor<CIRAttrToValue, mlir::Value> { +class CIRAttrToValue { public: CIRAttrToValue(mlir::Operation *parentOp, mlir::ConversionPatternRewriter &rewriter, const mlir::TypeConverter *converter) : parentOp(parentOp), rewriter(rewriter), converter(converter) {} - mlir::Value lowerCirAttrAsValue(mlir::Attribute attr) { return visit(attr); } - - mlir::Value visitCirIntAttr(cir::IntAttr intAttr) { - mlir::Location loc = parentOp->getLoc(); - return rewriter.create<mlir::LLVM::ConstantOp>( - loc, converter->convertType(intAttr.getType()), intAttr.getValue()); - } - - mlir::Value visitCirFPAttr(cir::FPAttr fltAttr) { - mlir::Location loc = parentOp->getLoc(); - return rewriter.create<mlir::LLVM::ConstantOp>( - loc, converter->convertType(fltAttr.getType()), fltAttr.getValue()); + mlir::Value visit(mlir::Attribute attr) { + return llvm::TypeSwitch<mlir::Attribute, mlir::Value>(attr) + .Case<cir::IntAttr, cir::FPAttr, cir::ConstPtrAttr>( ---------------- erichkeane wrote:
Its a shame this is such a manual list/sub-par interface here :/ it would be way neater if it was able to deduce these. *sigh* That said, I think this is quite a bit of a nicer interface, so I'm ok with it. https://github.com/llvm/llvm-project/pull/129293 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits