[Mlir-commits] [mlir] [WIP][mlir][EmitC] Model lvalues as a type in EmitC (PR #91475)
Gil Rapaport
llvmlistbot at llvm.org
Wed May 15 13:08:16 PDT 2024
================
@@ -76,57 +77,98 @@ static SmallVector<Value> createVariablesForResults(T op,
// the current insertion point of given rewriter.
static void assignValues(ValueRange values, SmallVector<Value> &variables,
PatternRewriter &rewriter, Location loc) {
- for (auto [value, var] : llvm::zip(values, variables))
- rewriter.create<emitc::AssignOp>(loc, var, value);
+ for (auto [value, var] : llvm::zip(values, variables)) {
+ assert(isa<emitc::LValueType>(var.getType()) &&
+ "expected var to be an lvalue type");
+ assert(!isa<emitc::LValueType>(value.getType()) &&
+ "expected value to not be an lvalue type");
+ auto assign = rewriter.create<emitc::AssignOp>(loc, var, value);
+
+ // TODO: Make sure this is safe, as this moves operations with memory
+ // effects.
+ if (auto op = dyn_cast_if_present<emitc::LValueToRValueOp>(
+ value.getDefiningOp())) {
+ rewriter.moveOpBefore(op, assign);
+ }
+ }
}
-static void lowerYield(SmallVector<Value> &resultVariables,
- PatternRewriter &rewriter, scf::YieldOp yield) {
+static void lowerYield(SmallVector<Value> &variables, PatternRewriter &rewriter,
----------------
aniragil wrote:
Is this change related to this PR?
https://github.com/llvm/llvm-project/pull/91475
More information about the Mlir-commits
mailing list