MLIR  20.0.0git
LLVM.cpp
Go to the documentation of this file.
1 //===- LLVM.cpp - C Interface for LLVM dialect ----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "mlir-c/Dialect/LLVM.h"
10 #include "mlir-c/IR.h"
11 #include "mlir-c/Support.h"
12 #include "mlir/CAPI/Registration.h"
13 #include "mlir/CAPI/Wrap.h"
17 #include "llvm-c/Core.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/SmallVectorExtras.h"
20 
21 using namespace mlir;
22 using namespace mlir::LLVM;
23 
25 
26 MlirType mlirLLVMPointerTypeGet(MlirContext ctx, unsigned addressSpace) {
27  return wrap(LLVMPointerType::get(unwrap(ctx), addressSpace));
28 }
29 
30 bool mlirTypeIsALLVMPointerType(MlirType type) {
31  return isa<LLVM::LLVMPointerType>(unwrap(type));
32 }
33 
34 unsigned mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType) {
35  return cast<LLVM::LLVMPointerType>(unwrap(pointerType)).getAddressSpace();
36 }
37 
38 MlirType mlirLLVMVoidTypeGet(MlirContext ctx) {
39  return wrap(LLVMVoidType::get(unwrap(ctx)));
40 }
41 
42 MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements) {
43  return wrap(LLVMArrayType::get(unwrap(elementType), numElements));
44 }
45 
46 MlirType mlirLLVMArrayTypeGetElementType(MlirType type) {
47  return wrap(cast<LLVM::LLVMArrayType>(unwrap(type)).getElementType());
48 }
49 
50 MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
51  MlirType const *argumentTypes, bool isVarArg) {
52  SmallVector<Type, 2> argumentStorage;
54  unwrap(resultType),
55  unwrapList(nArgumentTypes, argumentTypes, argumentStorage), isVarArg));
56 }
57 
58 bool mlirTypeIsALLVMStructType(MlirType type) {
59  return isa<LLVM::LLVMStructType>(unwrap(type));
60 }
61 
62 bool mlirLLVMStructTypeIsLiteral(MlirType type) {
63  return !cast<LLVM::LLVMStructType>(unwrap(type)).isIdentified();
64 }
65 
66 intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type) {
67  return cast<LLVM::LLVMStructType>(unwrap(type)).getBody().size();
68 }
69 
70 MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position) {
71  return wrap(cast<LLVM::LLVMStructType>(unwrap(type)).getBody()[position]);
72 }
73 
74 bool mlirLLVMStructTypeIsPacked(MlirType type) {
75  return cast<LLVM::LLVMStructType>(unwrap(type)).isPacked();
76 }
77 
79  return wrap(cast<LLVM::LLVMStructType>(unwrap(type)).getName());
80 }
81 
82 bool mlirLLVMStructTypeIsOpaque(MlirType type) {
83  return cast<LLVM::LLVMStructType>(unwrap(type)).isOpaque();
84 }
85 
86 MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes,
87  MlirType const *fieldTypes,
88  bool isPacked) {
89  SmallVector<Type> fieldStorage;
90  return wrap(LLVMStructType::getLiteral(
91  unwrap(ctx), unwrapList(nFieldTypes, fieldTypes, fieldStorage),
92  isPacked));
93 }
94 
95 MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc,
96  intptr_t nFieldTypes,
97  MlirType const *fieldTypes,
98  bool isPacked) {
99  SmallVector<Type> fieldStorage;
100  return wrap(LLVMStructType::getLiteralChecked(
101  [loc]() { return emitError(unwrap(loc)); }, unwrap(loc)->getContext(),
102  unwrapList(nFieldTypes, fieldTypes, fieldStorage), isPacked));
103 }
104 
105 MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name) {
106  return wrap(LLVMStructType::getOpaque(unwrap(name), unwrap(ctx)));
107 }
108 
109 MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name) {
110  return wrap(LLVMStructType::getIdentified(unwrap(ctx), unwrap(name)));
111 }
112 
113 MlirType mlirLLVMStructTypeIdentifiedNewGet(MlirContext ctx, MlirStringRef name,
114  intptr_t nFieldTypes,
115  MlirType const *fieldTypes,
116  bool isPacked) {
117  SmallVector<Type> fields;
118  return wrap(LLVMStructType::getNewIdentified(
119  unwrap(ctx), unwrap(name), unwrapList(nFieldTypes, fieldTypes, fields),
120  isPacked));
121 }
122 
124  intptr_t nFieldTypes,
125  MlirType const *fieldTypes,
126  bool isPacked) {
127  SmallVector<Type> fields;
128  return wrap(
129  cast<LLVM::LLVMStructType>(unwrap(structType))
130  .setBody(unwrapList(nFieldTypes, fieldTypes, fields), isPacked));
131 }
132 
133 MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
134  unsigned int opcode,
135  intptr_t nArguments,
136  uint64_t const *arguments) {
137  auto list = ArrayRef<uint64_t>(arguments, nArguments);
138  return wrap(DIExpressionElemAttr::get(unwrap(ctx), opcode, list));
139 }
140 
141 MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
142  MlirAttribute const *operations) {
143  SmallVector<Attribute> attrStorage;
144  attrStorage.reserve(nOperations);
145 
147  unwrap(ctx),
148  llvm::map_to_vector(
149  unwrapList(nOperations, operations, attrStorage),
150  [](Attribute a) { return cast<DIExpressionElemAttr>(a); })));
151 }
152 
153 MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
154  return wrap(DINullTypeAttr::get(unwrap(ctx)));
155 }
156 
157 MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
158  MlirAttribute name,
159  uint64_t sizeInBits,
160  MlirLLVMTypeEncoding encoding) {
161 
162  return wrap(DIBasicTypeAttr::get(
163  unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
164 }
165 
166 MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId) {
167  return wrap(
168  DICompositeTypeAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
169 }
170 
172  MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
173  MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
174  MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
175  uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
176  MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
177  MlirAttribute associated) {
178  SmallVector<Attribute> elementsStorage;
179  elementsStorage.reserve(nElements);
180 
182  unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf, tag,
183  cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(file)), line,
184  cast<DIScopeAttr>(unwrap(scope)), cast<DITypeAttr>(unwrap(baseType)),
185  DIFlags(flags), sizeInBits, alignInBits,
186  llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
187  [](Attribute a) { return cast<DINodeAttr>(a); }),
188  cast<DIExpressionAttr>(unwrap(dataLocation)),
189  cast<DIExpressionAttr>(unwrap(rank)),
190  cast<DIExpressionAttr>(unwrap(allocated)),
191  cast<DIExpressionAttr>(unwrap(associated))));
192 }
193 
195  MlirContext ctx, unsigned int tag, MlirAttribute name,
196  MlirAttribute baseType, uint64_t sizeInBits, uint32_t alignInBits,
197  uint64_t offsetInBits, int64_t dwarfAddressSpace, MlirAttribute extraData) {
198  std::optional<unsigned> addressSpace = std::nullopt;
199  if (dwarfAddressSpace >= 0)
200  addressSpace = (unsigned)dwarfAddressSpace;
202  unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
203  cast<DITypeAttr>(unwrap(baseType)), sizeInBits, alignInBits, offsetInBits,
204  addressSpace, cast<DINodeAttr>(unwrap(extraData))));
205 }
206 
208  MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
209  uint32_t alignInBits, MlirAttribute stringLength,
210  MlirAttribute stringLengthExp, MlirAttribute stringLocationExp,
211  MlirLLVMTypeEncoding encoding) {
213  unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, alignInBits,
214  cast<DIVariableAttr>(unwrap(stringLength)),
215  cast<DIExpressionAttr>(unwrap(stringLengthExp)),
216  cast<DIExpressionAttr>(unwrap(stringLocationExp)), encoding));
217 }
218 
219 MlirAttribute
220 mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType) {
221  return wrap(cast<DIDerivedTypeAttr>(unwrap(diDerivedType)).getBaseType());
222 }
223 
224 MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, MlirLLVMCConv cconv) {
225  return wrap(CConvAttr::get(unwrap(ctx), CConv(cconv)));
226 }
227 
228 MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, MlirLLVMComdat comdat) {
229  return wrap(ComdatAttr::get(unwrap(ctx), comdat::Comdat(comdat)));
230 }
231 
232 MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage) {
233  return wrap(LinkageAttr::get(unwrap(ctx), linkage::Linkage(linkage)));
234 }
235 
236 MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name,
237  MlirAttribute directory) {
238  return wrap(DIFileAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
239  cast<StringAttr>(unwrap(directory))));
240 }
241 
242 MlirAttribute
243 mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id,
244  unsigned int sourceLanguage, MlirAttribute file,
245  MlirAttribute producer, bool isOptimized,
246  MlirLLVMDIEmissionKind emissionKind,
247  MlirLLVMDINameTableKind nameTableKind) {
249  unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
250  cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
251  isOptimized, DIEmissionKind(emissionKind),
252  DINameTableKind(nameTableKind)));
253 }
254 
255 MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value) {
256  return wrap(DIFlagsAttr::get(unwrap(ctx), DIFlags(value)));
257 }
258 
259 MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx,
260  MlirAttribute scope,
261  MlirAttribute file,
262  unsigned int line,
263  unsigned int column) {
264  return wrap(
265  DILexicalBlockAttr::get(unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
266  cast<DIFileAttr>(unwrap(file)), line, column));
267 }
268 
269 MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx,
270  MlirAttribute scope,
271  MlirAttribute file,
272  unsigned int discriminator) {
274  unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
275  cast<DIFileAttr>(unwrap(file)), discriminator));
276 }
277 
279  MlirContext ctx, MlirAttribute scope, MlirAttribute name,
280  MlirAttribute diFile, unsigned int line, unsigned int arg,
281  unsigned int alignInBits, MlirAttribute diType, int64_t flags) {
283  unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
284  cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(diFile)), line,
285  arg, alignInBits, cast<DITypeAttr>(unwrap(diType)), DIFlags(flags)));
286 }
287 
288 MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
289  unsigned int callingConvention,
290  intptr_t nTypes,
291  MlirAttribute const *types) {
292  SmallVector<Attribute> attrStorage;
293  attrStorage.reserve(nTypes);
294 
296  unwrap(ctx), callingConvention,
297  llvm::map_to_vector(unwrapList(nTypes, types, attrStorage),
298  [](Attribute a) { return cast<DITypeAttr>(a); })));
299 }
300 
301 MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId) {
302  return wrap(DISubprogramAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
303 }
304 
306  MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
307  MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
308  MlirAttribute linkageName, MlirAttribute file, unsigned int line,
309  unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
310  intptr_t nRetainedNodes, MlirAttribute const *retainedNodes,
311  intptr_t nAnnotations, MlirAttribute const *annotations) {
312  SmallVector<Attribute> nodesStorage;
313  nodesStorage.reserve(nRetainedNodes);
314 
315  SmallVector<Attribute> annotationsStorage;
316  annotationsStorage.reserve(nAnnotations);
317 
319  unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf,
320  cast<DistinctAttr>(unwrap(id)),
321  cast<DICompileUnitAttr>(unwrap(compileUnit)),
322  cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
323  cast<StringAttr>(unwrap(linkageName)), cast<DIFileAttr>(unwrap(file)),
324  line, scopeLine, DISubprogramFlags(subprogramFlags),
325  cast<DISubroutineTypeAttr>(unwrap(type)),
326  llvm::map_to_vector(
327  unwrapList(nRetainedNodes, retainedNodes, nodesStorage),
328  [](Attribute a) { return cast<DINodeAttr>(a); }),
329  llvm::map_to_vector(
330  unwrapList(nAnnotations, annotations, annotationsStorage),
331  [](Attribute a) { return cast<DINodeAttr>(a); })));
332 }
333 
334 MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram) {
335  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getScope());
336 }
337 
338 unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram) {
339  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getLine();
340 }
341 
342 unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram) {
343  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getScopeLine();
344 }
345 
346 MlirAttribute
347 mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram) {
348  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getCompileUnit());
349 }
350 
351 MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram) {
352  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getFile());
353 }
354 
355 MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram) {
356  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getType());
357 }
358 
359 MlirAttribute mlirLLVMDIModuleAttrGet(MlirContext ctx, MlirAttribute file,
360  MlirAttribute scope, MlirAttribute name,
361  MlirAttribute configMacros,
362  MlirAttribute includePath,
363  MlirAttribute apinotes, unsigned int line,
364  bool isDecl) {
365  return wrap(DIModuleAttr::get(
366  unwrap(ctx), cast<DIFileAttr>(unwrap(file)),
367  cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
368  cast<StringAttr>(unwrap(configMacros)),
369  cast<StringAttr>(unwrap(includePath)), cast<StringAttr>(unwrap(apinotes)),
370  line, isDecl));
371 }
372 
373 MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule) {
374  return wrap(cast<DIModuleAttr>(unwrap(diModule)).getScope());
375 }
376 
378  MlirContext ctx, unsigned int tag, MlirAttribute scope,
379  MlirAttribute entity, MlirAttribute file, unsigned int line,
380  MlirAttribute name, intptr_t nElements, MlirAttribute const *elements) {
381  SmallVector<Attribute> elementsStorage;
382  elementsStorage.reserve(nElements);
384  unwrap(ctx), tag, cast<DIScopeAttr>(unwrap(scope)),
385  cast<DINodeAttr>(unwrap(entity)), cast<DIFileAttr>(unwrap(file)), line,
386  cast<StringAttr>(unwrap(name)),
387  llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
388  [](Attribute a) { return cast<DINodeAttr>(a); })));
389 }
390 
391 MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name,
392  MlirAttribute value) {
393  return wrap(DIAnnotationAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
394  cast<StringAttr>(unwrap(value))));
395 }
bool mlirLLVMStructTypeIsLiteral(MlirType type)
Returns true if the type is a literal (unnamed) LLVM struct type.
Definition: LLVM.cpp:62
MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage)
Creates a LLVM Linkage attribute.
Definition: LLVM.cpp:232
MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram)
Gets the file from this DISubprogramAttr.
Definition: LLVM.cpp:351
MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes, MlirType const *argumentTypes, bool isVarArg)
Creates an llvm.func type.
Definition: LLVM.cpp:50
MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule)
Gets the scope of this DIModuleAttr.
Definition: LLVM.cpp:373
intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type)
Returns the number of fields in the struct.
Definition: LLVM.cpp:66
MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx)
Creates a LLVM DINullType attribute.
Definition: LLVM.cpp:153
MlirType mlirLLVMArrayTypeGetElementType(MlirType type)
Returns the element type of the llvm.array type.
Definition: LLVM.cpp:46
MlirLogicalResult mlirLLVMStructTypeSetBody(MlirType structType, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Sets the body of the identified struct if it hasn't been set yet.
Definition: LLVM.cpp:123
MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name, MlirAttribute directory)
Creates a LLVM DIFileAttr attribute.
Definition: LLVM.cpp:236
MlirAttribute mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage, MlirAttribute file, MlirAttribute producer, bool isOptimized, MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind)
Creates a LLVM DICompileUnit attribute.
Definition: LLVM.cpp:243
bool mlirTypeIsALLVMStructType(MlirType type)
Returns true if the type is an LLVM dialect struct type.
Definition: LLVM.cpp:58
MlirStringRef mlirLLVMStructTypeGetIdentifier(MlirType type)
Returns the identifier of the identified struct.
Definition: LLVM.cpp:78
MlirAttribute mlirLLVMDIStringTypeAttrGet(MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits, uint32_t alignInBits, MlirAttribute stringLength, MlirAttribute stringLengthExp, MlirAttribute stringLocationExp, MlirLLVMTypeEncoding encoding)
Definition: LLVM.cpp:207
MlirAttribute mlirLLVMDICompositeTypeAttrGet(MlirContext ctx, MlirAttribute recId, bool isRecSelf, 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, MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated, MlirAttribute associated)
Creates a LLVM DICompositeType attribute.
Definition: LLVM.cpp:171
MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram)
Gets the scope from this DISubprogramAttr.
Definition: LLVM.cpp:334
MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int line, unsigned int column)
Creates a LLVM DILexicalBlock attribute.
Definition: LLVM.cpp:259
MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx, unsigned int opcode, intptr_t nArguments, uint64_t const *arguments)
Creates a LLVM DIExpressionElem attribute.
Definition: LLVM.cpp:133
MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId)
Creates a self-referencing LLVM DICompositeType attribute.
Definition: LLVM.cpp:166
MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits, MlirLLVMTypeEncoding encoding)
Creates a LLVM DIBasicType attribute.
Definition: LLVM.cpp:157
MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, MlirLLVMComdat comdat)
Creates a LLVM Comdat attribute.
Definition: LLVM.cpp:228
MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId)
Creates a self-referencing LLVM DISubprogramAttr attribute.
Definition: LLVM.cpp:301
MlirType mlirLLVMVoidTypeGet(MlirContext ctx)
Creates an llmv.void type.
Definition: LLVM.cpp:38
MlirAttribute mlirLLVMDIImportedEntityAttrGet(MlirContext ctx, unsigned int tag, MlirAttribute scope, MlirAttribute entity, MlirAttribute file, unsigned int line, MlirAttribute name, intptr_t nElements, MlirAttribute const *elements)
Creates a LLVM DIImportedEntityAttr attribute.
Definition: LLVM.cpp:377
MlirType mlirLLVMStructTypeIdentifiedNewGet(MlirContext ctx, MlirStringRef name, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM identified struct type with no body and a name starting with the given prefix.
Definition: LLVM.cpp:113
MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position)
Returns the positions-th field of the struct.
Definition: LLVM.cpp:70
MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name)
Definition: LLVM.cpp:105
MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements)
Creates an llvm.array type.
Definition: LLVM.cpp:42
MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram)
Gets the type from this DISubprogramAttr.
Definition: LLVM.cpp:355
MlirAttribute mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram)
Gets the compile unit from this DISubprogram.
Definition: LLVM.cpp:347
MlirAttribute mlirLLVMDIModuleAttrGet(MlirContext ctx, MlirAttribute file, MlirAttribute scope, MlirAttribute name, MlirAttribute configMacros, MlirAttribute includePath, MlirAttribute apinotes, unsigned int line, bool isDecl)
Creates a LLVM DIModuleAttr attribute.
Definition: LLVM.cpp:359
MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, MlirLLVMCConv cconv)
Creates a LLVM CConv attribute.
Definition: LLVM.cpp:224
MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name, MlirAttribute value)
Creates a LLVM DIAnnotation attribute.
Definition: LLVM.cpp:391
MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type if possible.
Definition: LLVM.cpp:95
MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int discriminator)
Creates a LLVM DILexicalBlockFile attribute.
Definition: LLVM.cpp:269
MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations, MlirAttribute const *operations)
Creates a LLVM DIExpression attribute.
Definition: LLVM.cpp:141
bool mlirLLVMStructTypeIsPacked(MlirType type)
Returns true if the struct is packed.
Definition: LLVM.cpp:74
MlirAttribute mlirLLVMDISubprogramAttrGet(MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id, MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name, MlirAttribute linkageName, MlirAttribute file, unsigned int line, unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type, intptr_t nRetainedNodes, MlirAttribute const *retainedNodes, intptr_t nAnnotations, MlirAttribute const *annotations)
Creates a LLVM DISubprogramAttr attribute.
Definition: LLVM.cpp:305
unsigned mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType)
Returns address space of llvm.ptr.
Definition: LLVM.cpp:34
MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value)
Creates a LLVM DIFlags attribute.
Definition: LLVM.cpp:255
MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name)
Creates an LLVM identified struct type with no body.
Definition: LLVM.cpp:109
MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx, unsigned int callingConvention, intptr_t nTypes, MlirAttribute const *types)
Creates a LLVM DISubroutineTypeAttr attribute.
Definition: LLVM.cpp:288
MlirAttribute mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType)
Gets the base type from a LLVM DIDerivedType attribute.
Definition: LLVM.cpp:220
bool mlirLLVMStructTypeIsOpaque(MlirType type)
Returns true is the struct is explicitly opaque (will not have a body) or uninitialized (will eventua...
Definition: LLVM.cpp:82
bool mlirTypeIsALLVMPointerType(MlirType type)
Returns true if the type is an LLVM dialect pointer type.
Definition: LLVM.cpp:30
unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram)
Gets the line from this DISubprogramAttr.
Definition: LLVM.cpp:338
MlirAttribute mlirLLVMDILocalVariableAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute name, MlirAttribute diFile, unsigned int line, unsigned int arg, unsigned int alignInBits, MlirAttribute diType, int64_t flags)
Creates a LLVM DILocalVariableAttr attribute.
Definition: LLVM.cpp:278
MlirType mlirLLVMPointerTypeGet(MlirContext ctx, unsigned addressSpace)
Creates an llvm.ptr type.
Definition: LLVM.cpp:26
unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram)
Gets the scope line from this DISubprogram.
Definition: LLVM.cpp:342
MlirAttribute mlirLLVMDIDerivedTypeAttrGet(MlirContext ctx, unsigned int tag, MlirAttribute name, MlirAttribute baseType, uint64_t sizeInBits, uint32_t alignInBits, uint64_t offsetInBits, int64_t dwarfAddressSpace, MlirAttribute extraData)
Creates a LLVM DIDerivedType attribute.
Definition: LLVM.cpp:194
MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type.
Definition: LLVM.cpp:86
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
Definition: Registration.h:36
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
Definition: SPIRVOps.cpp:215
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition: Wrap.h:40
Attributes are known-constant values of operations.
Definition: Attributes.h:25
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
MlirLLVMDINameTableKind
Definition: LLVM.h:287
MlirLLVMLinkage
Definition: LLVM.h:180
MlirLLVMComdat
Definition: LLVM.h:167
MlirLLVMCConv
Definition: LLVM.h:112
MlirLLVMDIEmissionKind
Definition: LLVM.h:279
MlirLLVMTypeEncoding
Definition: LLVM.h:211
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition: CallGraph.h:229
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
Definition: Utils.cpp:305
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
A logical result value, essentially a boolean with named states.
Definition: Support.h:116
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition: Support.h:73