================
@@ -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>(
----------------
andykaylor wrote:

I think it needs to be a manual list because it's never going to be the 
complete list. These are just the types we intend to handle here, with other 
types going to the Default() handler.

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

Reply via email to