[Mlir-commits] [mlir] [MLIR] Add llvm (debug) attributes to CAPI (PR #83992)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Wed Mar 6 01:35:57 PST 2024


================
@@ -110,3 +119,222 @@ MlirLogicalResult mlirLLVMStructTypeSetBody(MlirType structType,
       cast<LLVM::LLVMStructType>(unwrap(structType))
           .setBody(unwrapList(nFieldTypes, fieldTypes, fields), isPacked));
 }
+
+MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
+                                              unsigned int opcode,
+                                              intptr_t nArguments,
+                                              uint64_t const *arguments) {
+  auto list = mlir::ArrayRef<uint64_t>(arguments, nArguments);
+  return wrap(DIExpressionElemAttr::get(unwrap(ctx), opcode, list));
+}
+
+MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
+                                          MlirAttribute const *operations) {
+  SmallVector<Attribute, 2> attrStorage;
+  attrStorage.reserve(nOperations);
+  mlir::ArrayRef<Attribute> tempList =
+      unwrapList(nOperations, operations, attrStorage);
+
+  SmallVector<DIExpressionElemAttr, 2> diExpressionElemStorage;
+  diExpressionElemStorage.reserve(tempList.size());
+
+  for (auto attr : tempList) {
+    diExpressionElemStorage.push_back(attr.cast<DIExpressionElemAttr>());
+  }
----------------
ftynse wrote:

Nit: `llvm::map_to_vector` replaces all of this with a nice little lambda.

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


More information about the Mlir-commits mailing list