MLIR 22.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
10#include "mlir-c/IR.h"
11#include "mlir-c/Support.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
21using namespace mlir;
22using namespace mlir::LLVM;
23
25
26MlirType mlirLLVMPointerTypeGet(MlirContext ctx, unsigned addressSpace) {
27 return wrap(LLVMPointerType::get(unwrap(ctx), addressSpace));
28}
29
31 return wrap(LLVM::LLVMPointerType::name);
32}
33
35 return wrap(LLVM::LLVMPointerType::getTypeID());
36}
37
38bool mlirTypeIsALLVMPointerType(MlirType type) {
39 return isa<LLVM::LLVMPointerType>(unwrap(type));
40}
41
42unsigned mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType) {
43 return cast<LLVM::LLVMPointerType>(unwrap(pointerType)).getAddressSpace();
44}
45
46MlirType mlirLLVMVoidTypeGet(MlirContext ctx) {
47 return wrap(LLVMVoidType::get(unwrap(ctx)));
48}
49
50MlirStringRef mlirLLVMVoidTypeGetName(void) { return wrap(LLVMVoidType::name); }
51
52MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements) {
53 return wrap(LLVMArrayType::get(unwrap(elementType), numElements));
54}
55
57 return wrap(LLVMArrayType::name);
58}
59
60MlirType mlirLLVMArrayTypeGetElementType(MlirType type) {
61 return wrap(cast<LLVM::LLVMArrayType>(unwrap(type)).getElementType());
62}
63
64MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
65 MlirType const *argumentTypes, bool isVarArg) {
66 SmallVector<Type, 2> argumentStorage;
67 return wrap(LLVMFunctionType::get(
68 unwrap(resultType),
69 unwrapList(nArgumentTypes, argumentTypes, argumentStorage), isVarArg));
70}
71
73 return wrap(LLVMFunctionType::name);
74}
75
77 return llvm::cast<LLVM::LLVMFunctionType>(unwrap(type)).getNumParams();
78}
79
80MlirType mlirLLVMFunctionTypeGetInput(MlirType type, intptr_t pos) {
81 assert(pos >= 0 && "pos in array must be positive");
82 return wrap(llvm::cast<LLVM::LLVMFunctionType>(unwrap(type))
83 .getParamType(static_cast<unsigned>(pos)));
84}
85
86MlirType mlirLLVMFunctionTypeGetReturnType(MlirType type) {
87 return wrap(llvm::cast<LLVM::LLVMFunctionType>(unwrap(type)).getReturnType());
88}
89
90bool mlirTypeIsALLVMStructType(MlirType type) {
91 return isa<LLVM::LLVMStructType>(unwrap(type));
92}
93
95 return wrap(LLVM::LLVMStructType::getTypeID());
96}
97
99 return wrap(LLVM::LLVMStructType::name);
100}
101
102bool mlirLLVMStructTypeIsLiteral(MlirType type) {
103 return !cast<LLVM::LLVMStructType>(unwrap(type)).isIdentified();
104}
105
107 return cast<LLVM::LLVMStructType>(unwrap(type)).getBody().size();
108}
109
110MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position) {
111 return wrap(cast<LLVM::LLVMStructType>(unwrap(type)).getBody()[position]);
112}
113
114bool mlirLLVMStructTypeIsPacked(MlirType type) {
115 return cast<LLVM::LLVMStructType>(unwrap(type)).isPacked();
116}
117
119 return wrap(cast<LLVM::LLVMStructType>(unwrap(type)).getName());
120}
121
122bool mlirLLVMStructTypeIsOpaque(MlirType type) {
123 return cast<LLVM::LLVMStructType>(unwrap(type)).isOpaque();
124}
125
126MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes,
127 MlirType const *fieldTypes,
128 bool isPacked) {
129 SmallVector<Type> fieldStorage;
130 return wrap(LLVMStructType::getLiteral(
131 unwrap(ctx), unwrapList(nFieldTypes, fieldTypes, fieldStorage),
132 isPacked));
133}
134
135MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc,
136 intptr_t nFieldTypes,
137 MlirType const *fieldTypes,
138 bool isPacked) {
139 SmallVector<Type> fieldStorage;
140 return wrap(LLVMStructType::getLiteralChecked(
141 [loc]() { return emitError(unwrap(loc)); }, unwrap(loc)->getContext(),
142 unwrapList(nFieldTypes, fieldTypes, fieldStorage), isPacked));
143}
144
145MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name) {
146 return wrap(LLVMStructType::getOpaque(unwrap(name), unwrap(ctx)));
147}
148
149MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name) {
150 return wrap(LLVMStructType::getIdentified(unwrap(ctx), unwrap(name)));
151}
152
154 intptr_t nFieldTypes,
155 MlirType const *fieldTypes,
156 bool isPacked) {
157 SmallVector<Type> fields;
158 return wrap(LLVMStructType::getNewIdentified(
159 unwrap(ctx), unwrap(name), unwrapList(nFieldTypes, fieldTypes, fields),
160 isPacked));
161}
162
164 intptr_t nFieldTypes,
165 MlirType const *fieldTypes,
166 bool isPacked) {
167 SmallVector<Type> fields;
168 return wrap(
169 cast<LLVM::LLVMStructType>(unwrap(structType))
170 .setBody(unwrapList(nFieldTypes, fieldTypes, fields), isPacked));
171}
172
173MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
174 unsigned int opcode,
175 intptr_t nArguments,
176 uint64_t const *arguments) {
177 auto list = ArrayRef<uint64_t>(arguments, nArguments);
178 return wrap(DIExpressionElemAttr::get(unwrap(ctx), opcode, list));
179}
180
182 return wrap(DIExpressionElemAttr::name);
183}
184
185MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
186 MlirAttribute const *operations) {
187 SmallVector<Attribute> attrStorage;
188 attrStorage.reserve(nOperations);
189
190 return wrap(DIExpressionAttr::get(
191 unwrap(ctx),
192 llvm::map_to_vector(unwrapList(nOperations, operations, attrStorage),
193 llvm::CastTo<DIExpressionElemAttr>)));
194}
195
197 return wrap(DIExpressionAttr::name);
198}
199
200MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
201 return wrap(DINullTypeAttr::get(unwrap(ctx)));
202}
203
205 return wrap(DINullTypeAttr::name);
206}
207
208MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
209 MlirAttribute name,
210 uint64_t sizeInBits,
211 MlirLLVMTypeEncoding encoding) {
212
213 return wrap(DIBasicTypeAttr::get(
214 unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
215}
216
218 return wrap(DIBasicTypeAttr::name);
219}
220
221MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId) {
222 return wrap(
223 DICompositeTypeAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
224}
225
227 MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
228 MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
229 MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
230 uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
231 MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
232 MlirAttribute associated) {
233 SmallVector<Attribute> elementsStorage;
234 elementsStorage.reserve(nElements);
235
236 return wrap(DICompositeTypeAttr::get(
237 unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf, tag,
238 cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(file)), line,
239 cast<DIScopeAttr>(unwrap(scope)), cast<DITypeAttr>(unwrap(baseType)),
240 DIFlags(flags), sizeInBits, alignInBits,
241 cast<DIExpressionAttr>(unwrap(dataLocation)),
242 cast<DIExpressionAttr>(unwrap(rank)),
243 cast<DIExpressionAttr>(unwrap(allocated)),
244 cast<DIExpressionAttr>(unwrap(associated)),
245 llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
246 llvm::CastTo<DINodeAttr>)));
247}
248
250 return wrap(DICompositeTypeAttr::name);
251}
252
254 MlirContext ctx, unsigned int tag, MlirAttribute name,
255 MlirAttribute baseType, uint64_t sizeInBits, uint32_t alignInBits,
256 uint64_t offsetInBits, int64_t dwarfAddressSpace, MlirAttribute extraData) {
257 std::optional<unsigned> addressSpace = std::nullopt;
258 if (dwarfAddressSpace >= 0)
259 addressSpace = (unsigned)dwarfAddressSpace;
260 return wrap(DIDerivedTypeAttr::get(
261 unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
262 cast<DITypeAttr>(unwrap(baseType)), sizeInBits, alignInBits, offsetInBits,
263 addressSpace, cast<DINodeAttr>(unwrap(extraData))));
264}
265
267 return wrap(DIDerivedTypeAttr::name);
268}
269
271 MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
272 uint32_t alignInBits, MlirAttribute stringLength,
273 MlirAttribute stringLengthExp, MlirAttribute stringLocationExp,
274 MlirLLVMTypeEncoding encoding) {
275 return wrap(DIStringTypeAttr::get(
276 unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, alignInBits,
277 cast<DIVariableAttr>(unwrap(stringLength)),
278 cast<DIExpressionAttr>(unwrap(stringLengthExp)),
279 cast<DIExpressionAttr>(unwrap(stringLocationExp)), encoding));
280}
281
283 return wrap(DIStringTypeAttr::name);
284}
285
286MlirAttribute
287mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType) {
288 return wrap(cast<DIDerivedTypeAttr>(unwrap(diDerivedType)).getBaseType());
289}
290
291MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, MlirLLVMCConv cconv) {
292 return wrap(CConvAttr::get(unwrap(ctx), CConv(cconv)));
293}
294
295MlirStringRef mlirLLVMCConvAttrGetName(void) { return wrap(CConvAttr::name); }
296
297MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, MlirLLVMComdat comdat) {
298 return wrap(ComdatAttr::get(unwrap(ctx), comdat::Comdat(comdat)));
299}
300
301MlirStringRef mlirLLVMComdatAttrGetName(void) { return wrap(ComdatAttr::name); }
302
303MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage) {
304 return wrap(LinkageAttr::get(unwrap(ctx), linkage::Linkage(linkage)));
305}
306
308 return wrap(LinkageAttr::name);
309}
310
311MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name,
312 MlirAttribute directory) {
313 return wrap(DIFileAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
314 cast<StringAttr>(unwrap(directory))));
315}
316
317MlirStringRef mlirLLVMDIFileAttrGetName(void) { return wrap(DIFileAttr::name); }
318
320 MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
321 MlirAttribute file, MlirAttribute producer, bool isOptimized,
322 MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind,
323 MlirAttribute splitDebugFilename) {
324 return wrap(DICompileUnitAttr::get(
325 unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
326 cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
327 isOptimized, DIEmissionKind(emissionKind), DINameTableKind(nameTableKind),
328 cast<StringAttr>(unwrap(splitDebugFilename))));
329}
330
332 return wrap(DICompileUnitAttr::name);
333}
334
335MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value) {
336 return wrap(DIFlagsAttr::get(unwrap(ctx), DIFlags(value)));
337}
338
340 return wrap(DIFlagsAttr::name);
341}
342
343MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx,
344 MlirAttribute scope,
345 MlirAttribute file,
346 unsigned int line,
347 unsigned int column) {
348 return wrap(
349 DILexicalBlockAttr::get(unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
350 cast<DIFileAttr>(unwrap(file)), line, column));
351}
352
354 return wrap(DILexicalBlockAttr::name);
355}
356
357MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx,
358 MlirAttribute scope,
359 MlirAttribute file,
360 unsigned int discriminator) {
361 return wrap(DILexicalBlockFileAttr::get(
362 unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
363 cast<DIFileAttr>(unwrap(file)), discriminator));
364}
365
367 return wrap(DILexicalBlockFileAttr::name);
368}
369
371 MlirContext ctx, MlirAttribute scope, MlirAttribute name,
372 MlirAttribute diFile, unsigned int line, unsigned int arg,
373 unsigned int alignInBits, MlirAttribute diType, int64_t flags) {
374 return wrap(DILocalVariableAttr::get(
375 unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
376 cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(diFile)), line,
377 arg, alignInBits, cast<DITypeAttr>(unwrap(diType)), DIFlags(flags)));
378}
379
381 return wrap(DILocalVariableAttr::name);
382}
383
384MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
385 unsigned int callingConvention,
386 intptr_t nTypes,
387 MlirAttribute const *types) {
388 SmallVector<Attribute> attrStorage;
389 attrStorage.reserve(nTypes);
390
391 return wrap(DISubroutineTypeAttr::get(
392 unwrap(ctx), callingConvention,
393 llvm::map_to_vector(unwrapList(nTypes, types, attrStorage),
394 llvm::CastTo<DITypeAttr>)));
395}
396
398 return wrap(DISubroutineTypeAttr::name);
399}
400
401MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId) {
402 return wrap(DISubprogramAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
403}
404
406 MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
407 MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
408 MlirAttribute linkageName, MlirAttribute file, unsigned int line,
409 unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
410 intptr_t nRetainedNodes, MlirAttribute const *retainedNodes,
411 intptr_t nAnnotations, MlirAttribute const *annotations) {
412 SmallVector<Attribute> nodesStorage;
413 nodesStorage.reserve(nRetainedNodes);
414
415 SmallVector<Attribute> annotationsStorage;
416 annotationsStorage.reserve(nAnnotations);
417
418 return wrap(DISubprogramAttr::get(
419 unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf,
420 cast<DistinctAttr>(unwrap(id)),
421 cast<DICompileUnitAttr>(unwrap(compileUnit)),
422 cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
423 cast<StringAttr>(unwrap(linkageName)), cast<DIFileAttr>(unwrap(file)),
424 line, scopeLine, DISubprogramFlags(subprogramFlags),
425 cast<DISubroutineTypeAttr>(unwrap(type)),
426 llvm::map_to_vector(
427 unwrapList(nRetainedNodes, retainedNodes, nodesStorage),
428 llvm::CastTo<DINodeAttr>),
429 llvm::map_to_vector(
430 unwrapList(nAnnotations, annotations, annotationsStorage),
431 llvm::CastTo<DINodeAttr>)));
432}
433
435 return wrap(DISubprogramAttr::name);
436}
437
438MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram) {
439 return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getScope());
440}
441
442unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram) {
443 return cast<DISubprogramAttr>(unwrap(diSubprogram)).getLine();
444}
445
446unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram) {
447 return cast<DISubprogramAttr>(unwrap(diSubprogram)).getScopeLine();
448}
449
450MlirAttribute
451mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram) {
452 return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getCompileUnit());
453}
454
455MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram) {
456 return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getFile());
457}
458
459MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram) {
460 return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getType());
461}
462
463MlirAttribute mlirLLVMDIModuleAttrGet(MlirContext ctx, MlirAttribute file,
464 MlirAttribute scope, MlirAttribute name,
465 MlirAttribute configMacros,
466 MlirAttribute includePath,
467 MlirAttribute apinotes, unsigned int line,
468 bool isDecl) {
469 return wrap(DIModuleAttr::get(
470 unwrap(ctx), cast<DIFileAttr>(unwrap(file)),
471 cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
472 cast<StringAttr>(unwrap(configMacros)),
473 cast<StringAttr>(unwrap(includePath)), cast<StringAttr>(unwrap(apinotes)),
474 line, isDecl));
475}
476
478 return wrap(DIModuleAttr::name);
479}
480
481MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule) {
482 return wrap(cast<DIModuleAttr>(unwrap(diModule)).getScope());
483}
484
486 MlirContext ctx, unsigned int tag, MlirAttribute scope,
487 MlirAttribute entity, MlirAttribute file, unsigned int line,
488 MlirAttribute name, intptr_t nElements, MlirAttribute const *elements) {
489 SmallVector<Attribute> elementsStorage;
490 elementsStorage.reserve(nElements);
491 return wrap(DIImportedEntityAttr::get(
492 unwrap(ctx), tag, cast<DIScopeAttr>(unwrap(scope)),
493 cast<DINodeAttr>(unwrap(entity)), cast<DIFileAttr>(unwrap(file)), line,
494 cast<StringAttr>(unwrap(name)),
495 llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
496 llvm::CastTo<DINodeAttr>)));
497}
498
500 return wrap(DIImportedEntityAttr::name);
501}
502
503MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name,
504 MlirAttribute value) {
505 return wrap(DIAnnotationAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
506 cast<StringAttr>(unwrap(value))));
507}
508
510 return wrap(DIAnnotationAttr::name);
511}
static Type getElementType(Type type)
Determine the element type of type.
MlirStringRef mlirLLVMDIFlagsAttrGetName(void)
Definition LLVM.cpp:339
MlirStringRef mlirLLVMDIModuleAttrGetName(void)
Definition LLVM.cpp:477
MlirStringRef mlirLLVMDIAnnotationAttrGetName(void)
Definition LLVM.cpp:509
bool mlirLLVMStructTypeIsLiteral(MlirType type)
Returns true if the type is a literal (unnamed) LLVM struct type.
Definition LLVM.cpp:102
MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage)
Creates a LLVM Linkage attribute.
Definition LLVM.cpp:303
MlirStringRef mlirLLVMDIImportedEntityAttrGetName(void)
Definition LLVM.cpp:499
MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram)
Gets the file from this DISubprogramAttr.
Definition LLVM.cpp:455
MlirStringRef mlirLLVMDICompileUnitAttrGetName(void)
Definition LLVM.cpp:331
MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes, MlirType const *argumentTypes, bool isVarArg)
Creates an llvm.func type.
Definition LLVM.cpp:64
MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule)
Gets the scope of this DIModuleAttr.
Definition LLVM.cpp:481
MlirStringRef mlirLLVMDISubroutineTypeAttrGetName(void)
Definition LLVM.cpp:397
MlirType mlirLLVMFunctionTypeGetInput(MlirType type, intptr_t pos)
Returns the pos-th input type.
Definition LLVM.cpp:80
MlirStringRef mlirLLVMCConvAttrGetName(void)
Definition LLVM.cpp:295
MlirStringRef mlirLLVMDILexicalBlockAttrGetName(void)
Definition LLVM.cpp:353
MlirStringRef mlirLLVMDIStringTypeAttrGetName(void)
Definition LLVM.cpp:282
intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type)
Returns the number of fields in the struct.
Definition LLVM.cpp:106
MlirStringRef mlirLLVMStructTypeGetName(void)
Definition LLVM.cpp:98
intptr_t mlirLLVMFunctionTypeGetNumInputs(MlirType type)
Returns the number of input types.
Definition LLVM.cpp:76
MlirStringRef mlirLLVMDILexicalBlockFileAttrGetName(void)
Definition LLVM.cpp:366
MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx)
Creates a LLVM DINullType attribute.
Definition LLVM.cpp:200
MlirStringRef mlirLLVMPointerTypeGetName(void)
Definition LLVM.cpp:30
MlirStringRef mlirLLVMDIFileAttrGetName(void)
Definition LLVM.cpp:317
MlirType mlirLLVMArrayTypeGetElementType(MlirType type)
Returns the element type of the llvm.array type.
Definition LLVM.cpp:60
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:163
MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name, MlirAttribute directory)
Creates a LLVM DIFileAttr attribute.
Definition LLVM.cpp:311
MlirTypeID mlirLLVMPointerTypeGetTypeID()
Definition LLVM.cpp:34
bool mlirTypeIsALLVMStructType(MlirType type)
Returns true if the type is an LLVM dialect struct type.
Definition LLVM.cpp:90
MlirStringRef mlirLLVMStructTypeGetIdentifier(MlirType type)
Returns the identifier of the identified struct.
Definition LLVM.cpp:118
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:270
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:226
MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram)
Gets the scope from this DISubprogramAttr.
Definition LLVM.cpp:438
MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int line, unsigned int column)
Creates a LLVM DILexicalBlock attribute.
Definition LLVM.cpp:343
MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx, unsigned int opcode, intptr_t nArguments, uint64_t const *arguments)
Creates a LLVM DIExpressionElem attribute.
Definition LLVM.cpp:173
MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId)
Creates a self-referencing LLVM DICompositeType attribute.
Definition LLVM.cpp:221
MlirStringRef mlirLLVMArrayTypeGetName(void)
Definition LLVM.cpp:56
MlirTypeID mlirLLVMStructTypeGetTypeID()
Definition LLVM.cpp:94
MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits, MlirLLVMTypeEncoding encoding)
Creates a LLVM DIBasicType attribute.
Definition LLVM.cpp:208
MlirType mlirLLVMFunctionTypeGetReturnType(MlirType type)
Returns the return type of the function type.
Definition LLVM.cpp:86
MlirStringRef mlirLLVMDINullTypeAttrGetName(void)
Definition LLVM.cpp:204
MlirStringRef mlirLLVMDIDerivedTypeAttrGetName(void)
Definition LLVM.cpp:266
MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, MlirLLVMComdat comdat)
Creates a LLVM Comdat attribute.
Definition LLVM.cpp:297
MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId)
Creates a self-referencing LLVM DISubprogramAttr attribute.
Definition LLVM.cpp:401
MlirType mlirLLVMVoidTypeGet(MlirContext ctx)
Creates an llmv.void type.
Definition LLVM.cpp:46
MlirStringRef mlirLLVMDIBasicTypeAttrGetName(void)
Definition LLVM.cpp:217
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:485
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:153
MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position)
Returns the positions-th field of the struct.
Definition LLVM.cpp:110
MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name)
Definition LLVM.cpp:145
MlirType mlirLLVMArrayTypeGet(MlirType elementType, unsigned numElements)
Creates an llvm.array type.
Definition LLVM.cpp:52
MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram)
Gets the type from this DISubprogramAttr.
Definition LLVM.cpp:459
MlirAttribute mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram)
Gets the compile unit from this DISubprogram.
Definition LLVM.cpp:451
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:463
MlirStringRef mlirLLVMDICompositeTypeAttrGetName(void)
Definition LLVM.cpp:249
MlirStringRef mlirLLVMDIExpressionAttrGetName(void)
Definition LLVM.cpp:196
MlirStringRef mlirLLVMComdatAttrGetName(void)
Definition LLVM.cpp:301
MlirStringRef mlirLLVMDILocalVariableAttrGetName(void)
Definition LLVM.cpp:380
MlirStringRef mlirLLVMDISubprogramAttrGetName(void)
Definition LLVM.cpp:434
MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, MlirLLVMCConv cconv)
Creates a LLVM CConv attribute.
Definition LLVM.cpp:291
MlirStringRef mlirLLVMLinkageAttrGetName(void)
Definition LLVM.cpp:307
MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name, MlirAttribute value)
Creates a LLVM DIAnnotation attribute.
Definition LLVM.cpp:503
MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type if possible.
Definition LLVM.cpp:135
MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int discriminator)
Creates a LLVM DILexicalBlockFile attribute.
Definition LLVM.cpp:357
MlirAttribute mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage, MlirAttribute file, MlirAttribute producer, bool isOptimized, MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind, MlirAttribute splitDebugFilename)
Creates a LLVM DICompileUnit attribute.
Definition LLVM.cpp:319
MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations, MlirAttribute const *operations)
Creates a LLVM DIExpression attribute.
Definition LLVM.cpp:185
bool mlirLLVMStructTypeIsPacked(MlirType type)
Returns true if the struct is packed.
Definition LLVM.cpp:114
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:405
unsigned mlirLLVMPointerTypeGetAddressSpace(MlirType pointerType)
Returns address space of llvm.ptr.
Definition LLVM.cpp:42
MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value)
Creates a LLVM DIFlags attribute.
Definition LLVM.cpp:335
MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name)
Creates an LLVM identified struct type with no body.
Definition LLVM.cpp:149
MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx, unsigned int callingConvention, intptr_t nTypes, MlirAttribute const *types)
Creates a LLVM DISubroutineTypeAttr attribute.
Definition LLVM.cpp:384
MlirAttribute mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType)
Gets the base type from a LLVM DIDerivedType attribute.
Definition LLVM.cpp:287
bool mlirLLVMStructTypeIsOpaque(MlirType type)
Returns true is the struct is explicitly opaque (will not have a body) or uninitialized (will eventua...
Definition LLVM.cpp:122
bool mlirTypeIsALLVMPointerType(MlirType type)
Returns true if the type is an LLVM dialect pointer type.
Definition LLVM.cpp:38
unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram)
Gets the line from this DISubprogramAttr.
Definition LLVM.cpp:442
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:370
MlirStringRef mlirLLVMVoidTypeGetName(void)
Definition LLVM.cpp:50
unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram)
Gets the scope line from this DISubprogram.
Definition LLVM.cpp:446
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:253
MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type.
Definition LLVM.cpp:126
MlirStringRef mlirLLVMDIExpressionElemAttrGetName(void)
Definition LLVM.cpp:181
MlirStringRef mlirLLVMFunctionTypeGetName(void)
Definition LLVM.cpp:72
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition Wrap.h:40
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition Diagnostics.h:24
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition Diagnostics.h:19
MlirLLVMDINameTableKind
Definition LLVM.h:333
MLIR_CAPI_EXPORTED MlirType mlirLLVMPointerTypeGet(MlirContext ctx, unsigned addressSpace)
Creates an llvm.ptr type.
Definition LLVM.cpp:26
MlirLLVMLinkage
Definition LLVM.h:208
MlirLLVMComdat
Definition LLVM.h:193
MlirLLVMCConv
Definition LLVM.h:136
MlirLLVMDIEmissionKind
Definition LLVM.h:325
MlirLLVMTypeEncoding
Definition LLVM.h:247
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:304
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
A logical result value, essentially a boolean with named states.
Definition Support.h:118
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:75