[Mlir-commits] [mlir] [WIP][mlir][EmitC] Model lvalues as a type in EmitC (PR #91475)
Matthias Gehre
llvmlistbot at llvm.org
Mon May 13 02:23:51 PDT 2024
================
@@ -698,6 +703,47 @@ LogicalResult emitc::LiteralOp::verify() {
return emitOpError() << "value must not be empty";
return success();
}
+
+//===----------------------------------------------------------------------===//
+// LValueToRValueOp
+//===----------------------------------------------------------------------===//
+
+LogicalResult emitc::LValueToRValueOp::verify() {
+ Type operandType = getOperand().getType();
+ Type resultType = getResult().getType();
+ if (!llvm::isa<emitc::LValueType>(operandType))
+ return emitOpError("operand must be a lvalue");
+ if (llvm::cast<emitc::LValueType>(operandType).getValue() != resultType)
+ return emitOpError("types must match");
+
+ Value result = getResult();
+ if (!result.hasOneUse()) {
----------------
mgehre-amd wrote:
And in the places where the lvalue-to-rvalue conversion matters (like loading from a global variable or from an array), assigning to a local variable (i.e. copying) is exactly the semantics we want.
https://github.com/llvm/llvm-project/pull/91475
More information about the Mlir-commits
mailing list