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

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 14:57:43 PST 2025


================
@@ -52,6 +54,19 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
     return {};
   }
 
+  /// Emits the address of the l-value, then loads and returns the result.
+  mlir::Value emitLoadOfLValue(const Expr *e) {
+    LValue lv = cgf.emitLValue(e);
+    // FIXME: add some akin to EmitLValueAlignmentAssumption(E, V);
+    return cgf.emitLoadOfLValue(lv, e->getExprLoc()).getScalarVal();
+  }
+
+  // l-values
+  mlir::Value VisitDeclRefExpr(DeclRefExpr *e) {
+    // TODO: Handle constant emission
----------------
andykaylor wrote:

The missing code here is a call to `tryEmitAsConstant()` and there's no simple way to test whether it will do anything. I'll put in a MissingFeature assert.

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


More information about the cfe-commits mailing list