xref: /llvm-project/mlir/include/mlir-c/Dialect/LLVM.h (revision 5656cbca52545e608f6fb8b7c9a778c7c9b4b468)
135d4593eSAdam Paszke //===-- mlir-c/Dialect/LLVM.h - C API for LLVM --------------------*- C -*-===//
235d4593eSAdam Paszke //
335d4593eSAdam Paszke // Part of the LLVM Project, under the Apache License v2.0 with LLVM
435d4593eSAdam Paszke // Exceptions.
535d4593eSAdam Paszke // See https://llvm.org/LICENSE.txt for license information.
635d4593eSAdam Paszke // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
735d4593eSAdam Paszke //
835d4593eSAdam Paszke //===----------------------------------------------------------------------===//
935d4593eSAdam Paszke 
1035d4593eSAdam Paszke #ifndef MLIR_C_DIALECT_LLVM_H
1135d4593eSAdam Paszke #define MLIR_C_DIALECT_LLVM_H
1235d4593eSAdam Paszke 
1335d4593eSAdam Paszke #include "mlir-c/IR.h"
143714f937SEdgar #include "mlir-c/Support.h"
1535d4593eSAdam Paszke 
1635d4593eSAdam Paszke #ifdef __cplusplus
1735d4593eSAdam Paszke extern "C" {
1835d4593eSAdam Paszke #endif
1935d4593eSAdam Paszke 
2035d4593eSAdam Paszke MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(LLVM, llvm);
2135d4593eSAdam Paszke 
2235d4593eSAdam Paszke /// Creates an llvm.ptr type.
2346edbce4SChristian Ulmann MLIR_CAPI_EXPORTED MlirType mlirLLVMPointerTypeGet(MlirContext ctx,
2435d4593eSAdam Paszke                                                    unsigned addressSpace);
2535d4593eSAdam Paszke 
2679d4d165SMaksim Levental /// Returns `true` if the type is an LLVM dialect pointer type.
2779d4d165SMaksim Levental MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMPointerType(MlirType type);
2879d4d165SMaksim Levental 
2979d4d165SMaksim Levental /// Returns address space of llvm.ptr
3079d4d165SMaksim Levental MLIR_CAPI_EXPORTED unsigned
3179d4d165SMaksim Levental mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType);
3279d4d165SMaksim Levental 
338a2720d8SAdam Paszke /// Creates an llmv.void type.
348a2720d8SAdam Paszke MLIR_CAPI_EXPORTED MlirType mlirLLVMVoidTypeGet(MlirContext ctx);
358a2720d8SAdam Paszke 
368a2720d8SAdam Paszke /// Creates an llvm.array type.
378a2720d8SAdam Paszke MLIR_CAPI_EXPORTED MlirType mlirLLVMArrayTypeGet(MlirType elementType,
388a2720d8SAdam Paszke                                                  unsigned numElements);
398a2720d8SAdam Paszke 
408345a95aSWilliam Moses /// Returns the element type of the llvm.array type.
418345a95aSWilliam Moses MLIR_CAPI_EXPORTED MlirType mlirLLVMArrayTypeGetElementType(MlirType type);
428345a95aSWilliam Moses 
438a2720d8SAdam Paszke /// Creates an llvm.func type.
448a2720d8SAdam Paszke MLIR_CAPI_EXPORTED MlirType
458a2720d8SAdam Paszke mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
468a2720d8SAdam Paszke                         MlirType const *argumentTypes, bool isVarArg);
478a2720d8SAdam Paszke 
48*5656cbcaSWilliam Moses /// Returns the number of input types.
49*5656cbcaSWilliam Moses MLIR_CAPI_EXPORTED intptr_t mlirLLVMFunctionTypeGetNumInputs(MlirType type);
50*5656cbcaSWilliam Moses 
51*5656cbcaSWilliam Moses /// Returns the pos-th input type.
52*5656cbcaSWilliam Moses MLIR_CAPI_EXPORTED MlirType mlirLLVMFunctionTypeGetInput(MlirType type,
53*5656cbcaSWilliam Moses                                                          intptr_t pos);
54*5656cbcaSWilliam Moses 
55bd8fcf75SOleksandr "Alex" Zinenko /// Returns `true` if the type is an LLVM dialect struct type.
56bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED bool mlirTypeIsALLVMStructType(MlirType type);
57bd8fcf75SOleksandr "Alex" Zinenko 
58bd8fcf75SOleksandr "Alex" Zinenko /// Returns `true` if the type is a literal (unnamed) LLVM struct type.
59bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsLiteral(MlirType type);
60bd8fcf75SOleksandr "Alex" Zinenko 
61bd8fcf75SOleksandr "Alex" Zinenko /// Returns the number of fields in the struct. Asserts if the struct is opaque
62bd8fcf75SOleksandr "Alex" Zinenko /// or not yet initialized.
63bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type);
64bd8fcf75SOleksandr "Alex" Zinenko 
65bd8fcf75SOleksandr "Alex" Zinenko /// Returns the `positions`-th field of the struct. Asserts if the struct is
66bd8fcf75SOleksandr "Alex" Zinenko /// opaque, not yet initialized or if the position is out of range.
67bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeGetElementType(MlirType type,
68bd8fcf75SOleksandr "Alex" Zinenko                                                              intptr_t position);
69bd8fcf75SOleksandr "Alex" Zinenko 
70bd8fcf75SOleksandr "Alex" Zinenko /// Returns `true` if the struct is packed.
71bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsPacked(MlirType type);
72bd8fcf75SOleksandr "Alex" Zinenko 
73bd8fcf75SOleksandr "Alex" Zinenko /// Returns the identifier of the identified struct. Asserts that the struct is
74bd8fcf75SOleksandr "Alex" Zinenko /// identified, i.e., not literal.
75bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMStructTypeGetIdentifier(MlirType type);
76bd8fcf75SOleksandr "Alex" Zinenko 
77bd8fcf75SOleksandr "Alex" Zinenko /// Returns `true` is the struct is explicitly opaque (will not have a body) or
78bd8fcf75SOleksandr "Alex" Zinenko /// uninitialized (will eventually have a body).
79bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED bool mlirLLVMStructTypeIsOpaque(MlirType type);
80bd8fcf75SOleksandr "Alex" Zinenko 
81bd8fcf75SOleksandr "Alex" Zinenko /// Creates an LLVM literal (unnamed) struct type. This may assert if the fields
82bd8fcf75SOleksandr "Alex" Zinenko /// have types not compatible with the LLVM dialect. For a graceful failure, use
83bd8fcf75SOleksandr "Alex" Zinenko /// the checked version.
848a2720d8SAdam Paszke MLIR_CAPI_EXPORTED MlirType
858a2720d8SAdam Paszke mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes,
868a2720d8SAdam Paszke                              MlirType const *fieldTypes, bool isPacked);
878a2720d8SAdam Paszke 
88bd8fcf75SOleksandr "Alex" Zinenko /// Creates an LLVM literal (unnamed) struct type if possible. Emits a
89bd8fcf75SOleksandr "Alex" Zinenko /// diagnostic at the given location and returns null otherwise.
90bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirType
91bd8fcf75SOleksandr "Alex" Zinenko mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc, intptr_t nFieldTypes,
92bd8fcf75SOleksandr "Alex" Zinenko                                     MlirType const *fieldTypes, bool isPacked);
93bd8fcf75SOleksandr "Alex" Zinenko 
94bd8fcf75SOleksandr "Alex" Zinenko /// Creates an LLVM identified struct type with no body. If a struct type with
95bd8fcf75SOleksandr "Alex" Zinenko /// this name already exists in the context, returns that type. Use
96bd8fcf75SOleksandr "Alex" Zinenko /// mlirLLVMStructTypeIdentifiedNewGet to create a fresh struct type,
97bd8fcf75SOleksandr "Alex" Zinenko /// potentially renaming it. The body should be set separatelty by calling
98bd8fcf75SOleksandr "Alex" Zinenko /// mlirLLVMStructTypeSetBody, if it isn't set already.
99bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx,
100bd8fcf75SOleksandr "Alex" Zinenko                                                             MlirStringRef name);
101bd8fcf75SOleksandr "Alex" Zinenko 
102bd8fcf75SOleksandr "Alex" Zinenko /// Creates an LLVM identified struct type with no body and a name starting with
103bd8fcf75SOleksandr "Alex" Zinenko /// the given prefix. If a struct with the exact name as the given prefix
104bd8fcf75SOleksandr "Alex" Zinenko /// already exists, appends an unspecified suffix to the name so that the name
105bd8fcf75SOleksandr "Alex" Zinenko /// is unique in context.
106bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeIdentifiedNewGet(
107bd8fcf75SOleksandr "Alex" Zinenko     MlirContext ctx, MlirStringRef name, intptr_t nFieldTypes,
108bd8fcf75SOleksandr "Alex" Zinenko     MlirType const *fieldTypes, bool isPacked);
109bd8fcf75SOleksandr "Alex" Zinenko 
110bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx,
111bd8fcf75SOleksandr "Alex" Zinenko                                                         MlirStringRef name);
112bd8fcf75SOleksandr "Alex" Zinenko 
113bd8fcf75SOleksandr "Alex" Zinenko /// Sets the body of the identified struct if it hasn't been set yet. Returns
114bd8fcf75SOleksandr "Alex" Zinenko /// whether the operation was successful.
115bd8fcf75SOleksandr "Alex" Zinenko MLIR_CAPI_EXPORTED MlirLogicalResult
116bd8fcf75SOleksandr "Alex" Zinenko mlirLLVMStructTypeSetBody(MlirType structType, intptr_t nFieldTypes,
117bd8fcf75SOleksandr "Alex" Zinenko                           MlirType const *fieldTypes, bool isPacked);
118bd8fcf75SOleksandr "Alex" Zinenko 
1193714f937SEdgar enum MlirLLVMCConv {
1203714f937SEdgar   MlirLLVMCConvC = 0,
1213714f937SEdgar   MlirLLVMCConvFast = 8,
1223714f937SEdgar   MlirLLVMCConvCold = 9,
1233714f937SEdgar   MlirLLVMCConvGHC = 10,
1243714f937SEdgar   MlirLLVMCConvHiPE = 11,
1253714f937SEdgar   MlirLLVMCConvAnyReg = 13,
1263714f937SEdgar   MlirLLVMCConvPreserveMost = 14,
1273714f937SEdgar   MlirLLVMCConvPreserveAll = 15,
1283714f937SEdgar   MlirLLVMCConvSwift = 16,
1293714f937SEdgar   MlirLLVMCConvCXX_FAST_TLS = 17,
1303714f937SEdgar   MlirLLVMCConvTail = 18,
1313714f937SEdgar   MlirLLVMCConvCFGuard_Check = 19,
1323714f937SEdgar   MlirLLVMCConvSwiftTail = 20,
1333714f937SEdgar   MlirLLVMCConvX86_StdCall = 64,
1343714f937SEdgar   MlirLLVMCConvX86_FastCall = 65,
1353714f937SEdgar   MlirLLVMCConvARM_APCS = 66,
1363714f937SEdgar   MlirLLVMCConvARM_AAPCS = 67,
1373714f937SEdgar   MlirLLVMCConvARM_AAPCS_VFP = 68,
1383714f937SEdgar   MlirLLVMCConvMSP430_INTR = 69,
1393714f937SEdgar   MlirLLVMCConvX86_ThisCall = 70,
1403714f937SEdgar   MlirLLVMCConvPTX_Kernel = 71,
1413714f937SEdgar   MlirLLVMCConvPTX_Device = 72,
1423714f937SEdgar   MlirLLVMCConvSPIR_FUNC = 75,
1433714f937SEdgar   MlirLLVMCConvSPIR_KERNEL = 76,
1443714f937SEdgar   MlirLLVMCConvIntel_OCL_BI = 77,
1453714f937SEdgar   MlirLLVMCConvX86_64_SysV = 78,
1463714f937SEdgar   MlirLLVMCConvWin64 = 79,
1473714f937SEdgar   MlirLLVMCConvX86_VectorCall = 80,
1483714f937SEdgar   MlirLLVMCConvDUMMY_HHVM = 81,
1493714f937SEdgar   MlirLLVMCConvDUMMY_HHVM_C = 82,
1503714f937SEdgar   MlirLLVMCConvX86_INTR = 83,
1513714f937SEdgar   MlirLLVMCConvAVR_INTR = 84,
1523714f937SEdgar   MlirLLVMCConvAVR_BUILTIN = 86,
1533714f937SEdgar   MlirLLVMCConvAMDGPU_VS = 87,
1543714f937SEdgar   MlirLLVMCConvAMDGPU_GS = 88,
1553714f937SEdgar   MlirLLVMCConvAMDGPU_CS = 90,
1563714f937SEdgar   MlirLLVMCConvAMDGPU_KERNEL = 91,
1573714f937SEdgar   MlirLLVMCConvX86_RegCall = 92,
1583714f937SEdgar   MlirLLVMCConvAMDGPU_HS = 93,
1593714f937SEdgar   MlirLLVMCConvMSP430_BUILTIN = 94,
1603714f937SEdgar   MlirLLVMCConvAMDGPU_LS = 95,
1613714f937SEdgar   MlirLLVMCConvAMDGPU_ES = 96,
1623714f937SEdgar   MlirLLVMCConvAArch64_VectorCall = 97,
1633714f937SEdgar   MlirLLVMCConvAArch64_SVE_VectorCall = 98,
1643714f937SEdgar   MlirLLVMCConvWASM_EmscriptenInvoke = 99,
1653714f937SEdgar   MlirLLVMCConvAMDGPU_Gfx = 100,
1663714f937SEdgar   MlirLLVMCConvM68k_INTR = 101,
1673714f937SEdgar };
1683714f937SEdgar typedef enum MlirLLVMCConv MlirLLVMCConv;
1693714f937SEdgar 
1703714f937SEdgar /// Creates a LLVM CConv attribute.
1713714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx,
1723714f937SEdgar                                                       MlirLLVMCConv cconv);
1733714f937SEdgar 
1743714f937SEdgar enum MlirLLVMComdat {
1753714f937SEdgar   MlirLLVMComdatAny = 0,
1763714f937SEdgar   MlirLLVMComdatExactMatch = 1,
1773714f937SEdgar   MlirLLVMComdatLargest = 2,
1783714f937SEdgar   MlirLLVMComdatNoDeduplicate = 3,
1793714f937SEdgar   MlirLLVMComdatSameSize = 4,
1803714f937SEdgar };
1813714f937SEdgar typedef enum MlirLLVMComdat MlirLLVMComdat;
1823714f937SEdgar 
1833714f937SEdgar /// Creates a LLVM Comdat attribute.
1843714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx,
1853714f937SEdgar                                                        MlirLLVMComdat comdat);
1863714f937SEdgar 
1873714f937SEdgar enum MlirLLVMLinkage {
1884e6f812eSHenrich Lauko   MlirLLVMLinkageExternal = 0,
1894e6f812eSHenrich Lauko   MlirLLVMLinkageAvailableExternally = 1,
1904e6f812eSHenrich Lauko   MlirLLVMLinkageLinkonce = 2,
1914e6f812eSHenrich Lauko   MlirLLVMLinkageLinkonceODR = 3,
1923714f937SEdgar   MlirLLVMLinkageWeak = 4,
1934e6f812eSHenrich Lauko   MlirLLVMLinkageWeakODR = 5,
1943714f937SEdgar   MlirLLVMLinkageAppending = 6,
1954e6f812eSHenrich Lauko   MlirLLVMLinkageInternal = 7,
1964e6f812eSHenrich Lauko   MlirLLVMLinkagePrivate = 8,
1974e6f812eSHenrich Lauko   MlirLLVMLinkageExternWeak = 9,
1984e6f812eSHenrich Lauko   MlirLLVMLinkageCommon = 10,
1993714f937SEdgar };
2003714f937SEdgar typedef enum MlirLLVMLinkage MlirLLVMLinkage;
2013714f937SEdgar 
2023714f937SEdgar /// Creates a LLVM Linkage attribute.
2033714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
2043714f937SEdgar mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage);
2053714f937SEdgar 
2063714f937SEdgar /// Creates a LLVM DINullType attribute.
2073714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx);
2083714f937SEdgar 
2093714f937SEdgar /// Creates a LLVM DIExpressionElem attribute.
2103714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
2113714f937SEdgar mlirLLVMDIExpressionElemAttrGet(MlirContext ctx, unsigned int opcode,
2123714f937SEdgar                                 intptr_t nArguments, uint64_t const *arguments);
2133714f937SEdgar 
2143714f937SEdgar /// Creates a LLVM DIExpression attribute.
2153714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIExpressionAttrGet(
2163714f937SEdgar     MlirContext ctx, intptr_t nOperations, MlirAttribute const *operations);
2173714f937SEdgar 
2183714f937SEdgar enum MlirLLVMTypeEncoding {
2193714f937SEdgar   MlirLLVMTypeEncodingAddress = 0x1,
2203714f937SEdgar   MlirLLVMTypeEncodingBoolean = 0x2,
2213714f937SEdgar   MlirLLVMTypeEncodingComplexFloat = 0x31,
2223714f937SEdgar   MlirLLVMTypeEncodingFloatT = 0x4,
2233714f937SEdgar   MlirLLVMTypeEncodingSigned = 0x5,
2243714f937SEdgar   MlirLLVMTypeEncodingSignedChar = 0x6,
2253714f937SEdgar   MlirLLVMTypeEncodingUnsigned = 0x7,
2263714f937SEdgar   MlirLLVMTypeEncodingUnsignedChar = 0x08,
2273714f937SEdgar   MlirLLVMTypeEncodingImaginaryFloat = 0x09,
2283714f937SEdgar   MlirLLVMTypeEncodingPackedDecimal = 0x0a,
2293714f937SEdgar   MlirLLVMTypeEncodingNumericString = 0x0b,
2303714f937SEdgar   MlirLLVMTypeEncodingEdited = 0x0c,
2313714f937SEdgar   MlirLLVMTypeEncodingSignedFixed = 0x0d,
2323714f937SEdgar   MlirLLVMTypeEncodingUnsignedFixed = 0x0e,
2333714f937SEdgar   MlirLLVMTypeEncodingDecimalFloat = 0x0f,
2343714f937SEdgar   MlirLLVMTypeEncodingUTF = 0x10,
2353714f937SEdgar   MlirLLVMTypeEncodingUCS = 0x11,
2363714f937SEdgar   MlirLLVMTypeEncodingASCII = 0x12,
2373714f937SEdgar   MlirLLVMTypeEncodingLoUser = 0x80,
2383714f937SEdgar   MlirLLVMTypeEncodingHiUser = 0xff,
2393714f937SEdgar };
2403714f937SEdgar typedef enum MlirLLVMTypeEncoding MlirLLVMTypeEncoding;
2413714f937SEdgar 
2423714f937SEdgar /// Creates a LLVM DIBasicType attribute.
2433714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIBasicTypeAttrGet(
2443714f937SEdgar     MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
2453714f937SEdgar     MlirLLVMTypeEncoding encoding);
2463714f937SEdgar 
24775197553STobias Gysi /// Creates a self-referencing LLVM DICompositeType attribute.
24875197553STobias Gysi MLIR_CAPI_EXPORTED MlirAttribute
24975197553STobias Gysi mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId);
25075197553STobias Gysi 
2513714f937SEdgar /// Creates a LLVM DICompositeType attribute.
2523714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
25375197553STobias Gysi     MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
25475197553STobias Gysi     MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
2551e8dad3bSBilly Zhu     MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
256d8038373SAbid Qadeer     uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
257d8038373SAbid Qadeer     MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
258d8038373SAbid Qadeer     MlirAttribute associated);
2593714f937SEdgar 
2605c35b63dSWilliam G Hatch /// Creates a LLVM DIDerivedType attribute.  Note that `dwarfAddressSpace` is an
2615c35b63dSWilliam G Hatch /// optional field, where `MLIR_CAPI_DWARF_ADDRESS_SPACE_NULL` indicates null
2625c35b63dSWilliam G Hatch /// and non-negative values indicate a value present.
2633714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIDerivedTypeAttrGet(
2643714f937SEdgar     MlirContext ctx, unsigned int tag, MlirAttribute name,
2653714f937SEdgar     MlirAttribute baseType, uint64_t sizeInBits, uint32_t alignInBits,
2665c35b63dSWilliam G Hatch     uint64_t offsetInBits, int64_t dwarfAddressSpace, MlirAttribute extraData);
2675c35b63dSWilliam G Hatch 
2684f320e6aSAbid Qadeer MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIStringTypeAttrGet(
2694f320e6aSAbid Qadeer     MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
2704f320e6aSAbid Qadeer     uint32_t alignInBits, MlirAttribute stringLength,
2714f320e6aSAbid Qadeer     MlirAttribute stringLengthExp, MlirAttribute stringLocationExp,
2724f320e6aSAbid Qadeer     MlirLLVMTypeEncoding encoding);
2734f320e6aSAbid Qadeer 
2745c35b63dSWilliam G Hatch /// Constant to represent std::nullopt for dwarfAddressSpace to omit the field.
2755c35b63dSWilliam G Hatch #define MLIR_CAPI_DWARF_ADDRESS_SPACE_NULL -1
2763714f937SEdgar 
2773714f937SEdgar /// Gets the base type from a LLVM DIDerivedType attribute.
2783714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
2793714f937SEdgar mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType);
2803714f937SEdgar 
2813714f937SEdgar /// Creates a LLVM DIFileAttr attribute.
2823714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx,
2833714f937SEdgar                                                        MlirAttribute name,
2843714f937SEdgar                                                        MlirAttribute directory);
2853714f937SEdgar 
2863714f937SEdgar enum MlirLLVMDIEmissionKind {
2873714f937SEdgar   MlirLLVMDIEmissionKindNone = 0,
2883714f937SEdgar   MlirLLVMDIEmissionKindFull = 1,
2893714f937SEdgar   MlirLLVMDIEmissionKindLineTablesOnly = 2,
2903714f937SEdgar   MlirLLVMDIEmissionKindDebugDirectivesOnly = 3,
2913714f937SEdgar };
2923714f937SEdgar typedef enum MlirLLVMDIEmissionKind MlirLLVMDIEmissionKind;
2933714f937SEdgar 
2946f633685SBilly Zhu enum MlirLLVMDINameTableKind {
2956f633685SBilly Zhu   MlirLLVMDINameTableKindDefault = 0,
2966f633685SBilly Zhu   MlirLLVMDINameTableKindGNU = 1,
2976f633685SBilly Zhu   MlirLLVMDINameTableKindNone = 2,
2986f633685SBilly Zhu   MlirLLVMDINameTableKindApple = 3,
2996f633685SBilly Zhu };
3006f633685SBilly Zhu typedef enum MlirLLVMDINameTableKind MlirLLVMDINameTableKind;
3016f633685SBilly Zhu 
3023714f937SEdgar /// Creates a LLVM DICompileUnit attribute.
3033714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompileUnitAttrGet(
3043714f937SEdgar     MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
3053714f937SEdgar     MlirAttribute file, MlirAttribute producer, bool isOptimized,
3066f633685SBilly Zhu     MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind);
3073714f937SEdgar 
3083714f937SEdgar /// Creates a LLVM DIFlags attribute.
3093714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx,
3103714f937SEdgar                                                         uint64_t value);
3113714f937SEdgar 
3123714f937SEdgar /// Creates a LLVM DILexicalBlock attribute.
3133714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILexicalBlockAttrGet(
3143714f937SEdgar     MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int line,
3153714f937SEdgar     unsigned int column);
3163714f937SEdgar 
3173714f937SEdgar /// Creates a LLVM DILexicalBlockFile attribute.
3183714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(
3193714f937SEdgar     MlirContext ctx, MlirAttribute scope, MlirAttribute file,
3203714f937SEdgar     unsigned int discriminator);
3213714f937SEdgar 
3223714f937SEdgar /// Creates a LLVM DILocalVariableAttr attribute.
3233714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILocalVariableAttrGet(
3243714f937SEdgar     MlirContext ctx, MlirAttribute scope, MlirAttribute name,
3253714f937SEdgar     MlirAttribute diFile, unsigned int line, unsigned int arg,
326ef8de68fSWalter Erquinigo     unsigned int alignInBits, MlirAttribute diType, int64_t flags);
3273714f937SEdgar 
32875197553STobias Gysi /// Creates a self-referencing LLVM DISubprogramAttr attribute.
32975197553STobias Gysi MLIR_CAPI_EXPORTED MlirAttribute
33075197553STobias Gysi mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId);
33175197553STobias Gysi 
3323714f937SEdgar /// Creates a LLVM DISubprogramAttr attribute.
3333714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDISubprogramAttrGet(
33475197553STobias Gysi     MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
33575197553STobias Gysi     MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
33675197553STobias Gysi     MlirAttribute linkageName, MlirAttribute file, unsigned int line,
33775197553STobias Gysi     unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
3382918e779SWalter Erquinigo     intptr_t nRetainedNodes, MlirAttribute const *retainedNodes,
3392918e779SWalter Erquinigo     intptr_t nAnnotations, MlirAttribute const *annotations);
3402918e779SWalter Erquinigo 
3412918e779SWalter Erquinigo /// Creates a LLVM DIAnnotation attribute.
3422918e779SWalter Erquinigo MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIAnnotationAttrGet(
3432918e779SWalter Erquinigo     MlirContext ctx, MlirAttribute name, MlirAttribute value);
3443714f937SEdgar 
3453714f937SEdgar /// Gets the scope from this DISubprogramAttr.
3463714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
3473714f937SEdgar mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram);
3483714f937SEdgar 
3493714f937SEdgar /// Gets the line from this DISubprogramAttr.
3503714f937SEdgar MLIR_CAPI_EXPORTED unsigned int
3513714f937SEdgar mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram);
3523714f937SEdgar 
3533714f937SEdgar /// Gets the scope line from this DISubprogram.
3543714f937SEdgar MLIR_CAPI_EXPORTED unsigned int
3553714f937SEdgar mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram);
3563714f937SEdgar 
3573714f937SEdgar /// Gets the compile unit from this DISubprogram.
3583714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
3593714f937SEdgar mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram);
3603714f937SEdgar 
3613714f937SEdgar /// Gets the file from this DISubprogramAttr.
3623714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
3633714f937SEdgar mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram);
3643714f937SEdgar 
3653714f937SEdgar /// Gets the type from this DISubprogramAttr.
3663714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
3673714f937SEdgar mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram);
3683714f937SEdgar 
3693714f937SEdgar /// Creates a LLVM DISubroutineTypeAttr attribute.
3703714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
3713714f937SEdgar mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx, unsigned int callingConvention,
3723714f937SEdgar                                 intptr_t nTypes, MlirAttribute const *types);
3733714f937SEdgar 
3743714f937SEdgar /// Creates a LLVM DIModuleAttr attribute.
3753714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIModuleAttrGet(
3763714f937SEdgar     MlirContext ctx, MlirAttribute file, MlirAttribute scope,
3773714f937SEdgar     MlirAttribute name, MlirAttribute configMacros, MlirAttribute includePath,
3783714f937SEdgar     MlirAttribute apinotes, unsigned int line, bool isDecl);
3793714f937SEdgar 
380bc4bedd5SAbid Qadeer /// Creates a LLVM DIImportedEntityAttr attribute.
381bc4bedd5SAbid Qadeer MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIImportedEntityAttrGet(
38275197553STobias Gysi     MlirContext ctx, unsigned int tag, MlirAttribute scope,
38375197553STobias Gysi     MlirAttribute entity, MlirAttribute file, unsigned int line,
38475197553STobias Gysi     MlirAttribute name, intptr_t nElements, MlirAttribute const *elements);
385bc4bedd5SAbid Qadeer 
3863714f937SEdgar /// Gets the scope of this DIModuleAttr.
3873714f937SEdgar MLIR_CAPI_EXPORTED MlirAttribute
3883714f937SEdgar mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule);
3893714f937SEdgar 
39035d4593eSAdam Paszke #ifdef __cplusplus
39135d4593eSAdam Paszke }
39235d4593eSAdam Paszke #endif
39335d4593eSAdam Paszke 
39435d4593eSAdam Paszke #endif // MLIR_C_DIALECT_LLVM_H
395