[clang] [CIR] Upstream basic alloca and load support (PR #128792)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 10:23:16 PST 2025


================
@@ -65,7 +80,27 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
         cgf.getLoc(e->getExprLoc()), type,
         builder.getCIRBoolAttr(e->getValue()));
   }
+
+  mlir::Value VisitCastExpr(CastExpr *E);
+
+  /// Emit a conversion from the specified type to the specified destination
+  /// type, both of which are CIR scalar types.
+  /// TODO: do we need ScalarConversionOpts here? Should be done in another
+  /// pass.
+  mlir::Value emitScalarConversion(mlir::Value src, QualType srcType,
+                                   QualType dstType, SourceLocation loc) {
+    // No sort of type conversion is implemented yet, but the path for implicit
+    // paths goes through here even if the type isn't being changed.
+    srcType = cgf.getContext().getCanonicalType(srcType);
+    dstType = cgf.getContext().getCanonicalType(dstType);
+    if (srcType == dstType)
----------------
andykaylor wrote:

It's going to be expanded to handle mixed types, so I don't think it makes sense to reduce the implementation now only to have to break it apart later.

https://github.com/llvm/llvm-project/pull/128792


More information about the cfe-commits mailing list