Skip to content

[MLIR][TableGen] Error on APInt parameter without custom comparator #135970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 22, 2025
Prev Previous commit
Next Next commit
fixup! [MLIR][TableGen] Warn on APInt parameter without custom compar…
…ator
  • Loading branch information
Jezurko committed Apr 16, 2025
commit 5992ca8420bdd135de158247bd4cfa0ab24f52df
19 changes: 9 additions & 10 deletions mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,16 +679,15 @@ void DefGen::emitStorageClass() {
// Emit the storage class members as public, at the very end of the struct.
storageCls->finalize();
for (auto &param : params) {
if (param.getCppType().contains("APInt") &&
!param.hasCustomComparator()) {
PrintWarning(
def.getLoc(),
"Using a raw APInt parameter without a custom comparator is "
"discouraged because an assert in the equality operator is "
"triggered when the two APInts have different bit widths. This can "
"lead to unexpected crashes. Consider using an `APIntParameter` or "
"providing a custom comparator.");
}
if (param.getCppType().contains("APInt") && !param.hasCustomComparator()) {
PrintWarning(
def.getLoc(),
"Using a raw APInt parameter without a custom comparator is "
"discouraged because an assert in the equality operator is "
"triggered when the two APInts have different bit widths. This can "
"lead to unexpected crashes. Consider using an `APIntParameter` or "
"providing a custom comparator.");
}
storageCls->declare<Field>(param.getCppType(), param.getName());
}
}
Expand Down
Loading