================
@@ -2537,6 +2537,17 @@ LogicalResult cir::GetMemberOp::verify() {
   return mlir::success();
 }
 
+//===----------------------------------------------------------------------===//
+// GetElementOp Definitions
+//===----------------------------------------------------------------------===//
+
+LogicalResult cir::GetElementOp::verify() {
+  auto arrayTy = mlir::cast<cir::ArrayType>(getBaseType().getPointee());
+  if (getElementType() != arrayTy.getElementType())
+    return emitError() << "element type mismatch";
+  return mlir::success();
+}
----------------
xlauko wrote:

I believe this can be written directly in ODS as:

```
  TypesMatchWith<"type of 'result' matches element type of 'array'",
    "array", "result", "mlir::cast<cir::ArrayType>($_self).getElementType()">
```

we might want to create a helper trait for this as it happens a lot in CIR, 
e.g., `VecExtractOp`.

https://github.com/llvm/llvm-project/pull/172897
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to