[Mlir-commits] [mlir] [MLIR][LLVM] Attach kernel metadata representation to `llvm.func` (PR #101314)
Tobias Gysi
llvmlistbot at llvm.org
Thu Aug 1 02:40:34 PDT 2024
================
@@ -226,6 +241,129 @@ static LogicalResult setNoaliasScopesAttr(const llvm::MDNode *node,
return success();
}
+/// Extract constant integer value from metadata if this is constant. Return
+/// `std::nullopt` otherwise.
+static std::optional<int32_t> parseIntegerMD(llvm::Metadata *md) {
+ auto *c = llvm::dyn_cast_or_null<llvm::ConstantAsMetadata>(md);
+ if (!c)
+ return {};
+
+ auto *ci = dyn_cast<llvm::ConstantInt>(c->getValue());
----------------
gysit wrote:
```suggestion
auto *intConstant = dyn_cast<llvm::ConstantInt>(c->getValue());
```
nit: I would go for a longer name as well.
https://github.com/llvm/llvm-project/pull/101314
More information about the Mlir-commits
mailing list