[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());
+  if (!ci)
+    return {};
+
+  return ci->getValue().getSExtValue();
+}
+
+/// Convert an `MDNode` to an LLVM dialect `VecTypeHintAttr` if possible.
----------------
gysit wrote:

```suggestion
/// Converts the provided metadata node `md` to an LLVM dialect VecTypeHintAttr if possible.
```
ultra nit: Similarly I would use the backticks for the function arguments only.

https://github.com/llvm/llvm-project/pull/101314


More information about the Mlir-commits mailing list