[Mlir-commits] [mlir] [MLIR] Add llvm (debug) attributes to CAPI (PR #83992)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Wed Mar 6 01:35:58 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>());
+ }
+
+ return wrap(DIExpressionAttr::get(unwrap(ctx), diExpressionElemStorage));
+}
+
+MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
+ return wrap(DINullTypeAttr::get(unwrap(ctx)));
+}
+
+MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
+ MlirAttribute name,
+ uint64_t sizeInBits,
+ unsigned int encoding) {
+ return wrap(DIBasicTypeAttr::get(
+ unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
+}
+
+MlirAttribute mlirLLVMDICompositeTypeAttrGet(
+ MlirContext ctx, unsigned int tag, MlirAttribute name, MlirAttribute file,
+ uint32_t line, MlirAttribute scope, MlirAttribute baseType, int64_t flags,
+ uint64_t sizeInBits, uint64_t alignInBits, intptr_t nElements,
+ MlirAttribute const *elements) {
+ SmallVector<Attribute, 2> elementsStorage;
+ elementsStorage.reserve(nElements);
+
+ mlir::ArrayRef<Attribute> tempList =
+ unwrapList(nElements, elements, elementsStorage);
+
+ SmallVector<DINodeAttr, 2> diNodesStorage;
+ diNodesStorage.reserve(tempList.size());
+
+ for (auto attr : tempList) {
+ diNodesStorage.push_back(attr.cast<DINodeAttr>());
+ }
+
+ return wrap(DICompositeTypeAttr::get(
+ unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
+ cast<DIFileAttr>(unwrap(file)), line, cast<DIScopeAttr>(unwrap(scope)),
+ cast<DITypeAttr>(unwrap(baseType)), DIFlags(flags), sizeInBits,
+ alignInBits, diNodesStorage));
+}
+
+MlirAttribute mlirLLVMDIDerivedTypeAttrGet(MlirContext ctx, unsigned int tag,
+ MlirAttribute name,
+ MlirAttribute baseType,
+ uint64_t sizeInBits,
+ uint32_t alignInBits,
+ uint64_t offsetInBits) {
+ return wrap(DIDerivedTypeAttr::get(unwrap(ctx), tag,
+ cast<StringAttr>(unwrap(name)),
+ cast<DITypeAttr>(unwrap(baseType)),
+ sizeInBits, alignInBits, offsetInBits));
+}
+
+MlirAttribute
+mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType) {
+ return wrap(cast<DIDerivedTypeAttr>(unwrap(diDerivedType)).getBaseType());
+}
+
+MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, uint64_t cconv) {
+ return wrap(CConvAttr::get(unwrap(ctx), CConv(cconv)));
+}
+
+MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, uint64_t comdat) {
+ return wrap(ComdatAttr::get(unwrap(ctx), comdat::Comdat(comdat)));
----------------
ftynse wrote:
Can we please expose enums as C enums anot not magic numbers? Here and below.
https://github.com/llvm/llvm-project/pull/83992
More information about the Mlir-commits
mailing list