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 mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes,
47  MlirType const *argumentTypes, bool isVarArg) {
48  SmallVector<Type, 2> argumentStorage;
50  unwrap(resultType),
51  unwrapList(nArgumentTypes, argumentTypes, argumentStorage), isVarArg));
52 }
53 
54 bool mlirTypeIsALLVMStructType(MlirType type) {
55  return isa<LLVM::LLVMStructType>(unwrap(type));
56 }
57 
58 bool mlirLLVMStructTypeIsLiteral(MlirType type) {
59  return !cast<LLVM::LLVMStructType>(unwrap(type)).isIdentified();
60 }
61 
62 intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type) {
63  return cast<LLVM::LLVMStructType>(unwrap(type)).getBody().size();
64 }
65 
66 MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position) {
67  return wrap(cast<LLVM::LLVMStructType>(unwrap(type)).getBody()[position]);
68 }
69 
70 bool mlirLLVMStructTypeIsPacked(MlirType type) {
71  return cast<LLVM::LLVMStructType>(unwrap(type)).isPacked();
72 }
73 
75  return wrap(cast<LLVM::LLVMStructType>(unwrap(type)).getName());
76 }
77 
78 bool mlirLLVMStructTypeIsOpaque(MlirType type) {
79  return cast<LLVM::LLVMStructType>(unwrap(type)).isOpaque();
80 }
81 
82 MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes,
83  MlirType const *fieldTypes,
84  bool isPacked) {
85  SmallVector<Type> fieldStorage;
87  unwrap(ctx), unwrapList(nFieldTypes, fieldTypes, fieldStorage),
88  isPacked));
89 }
90 
91 MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc,
92  intptr_t nFieldTypes,
93  MlirType const *fieldTypes,
94  bool isPacked) {
95  SmallVector<Type> fieldStorage;
97  [loc]() { return emitError(unwrap(loc)); }, unwrap(loc)->getContext(),
98  unwrapList(nFieldTypes, fieldTypes, fieldStorage), isPacked));
99 }
100 
101 MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name) {
102  return wrap(LLVMStructType::getOpaque(unwrap(name), unwrap(ctx)));
103 }
104 
105 MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name) {
106  return wrap(LLVMStructType::getIdentified(unwrap(ctx), unwrap(name)));
107 }
108 
109 MlirType mlirLLVMStructTypeIdentifiedNewGet(MlirContext ctx, MlirStringRef name,
110  intptr_t nFieldTypes,
111  MlirType const *fieldTypes,
112  bool isPacked) {
113  SmallVector<Type> fields;
115  unwrap(ctx), unwrap(name), unwrapList(nFieldTypes, fieldTypes, fields),
116  isPacked));
117 }
118 
120  intptr_t nFieldTypes,
121  MlirType const *fieldTypes,
122  bool isPacked) {
123  SmallVector<Type> fields;
124  return wrap(
125  cast<LLVM::LLVMStructType>(unwrap(structType))
126  .setBody(unwrapList(nFieldTypes, fieldTypes, fields), isPacked));
127 }
128 
129 MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx,
130  unsigned int opcode,
131  intptr_t nArguments,
132  uint64_t const *arguments) {
133  auto list = ArrayRef<uint64_t>(arguments, nArguments);
134  return wrap(DIExpressionElemAttr::get(unwrap(ctx), opcode, list));
135 }
136 
137 MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations,
138  MlirAttribute const *operations) {
139  SmallVector<Attribute> attrStorage;
140  attrStorage.reserve(nOperations);
141 
143  unwrap(ctx),
144  llvm::map_to_vector(
145  unwrapList(nOperations, operations, attrStorage),
146  [](Attribute a) { return cast<DIExpressionElemAttr>(a); })));
147 }
148 
149 MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx) {
150  return wrap(DINullTypeAttr::get(unwrap(ctx)));
151 }
152 
153 MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
154  MlirAttribute name,
155  uint64_t sizeInBits,
156  MlirLLVMTypeEncoding encoding) {
157 
158  return wrap(DIBasicTypeAttr::get(
159  unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
160 }
161 
162 MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId) {
163  return wrap(
164  DICompositeTypeAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
165 }
166 
168  MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
169  MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
170  MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
171  uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
172  MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
173  MlirAttribute associated) {
174  SmallVector<Attribute> elementsStorage;
175  elementsStorage.reserve(nElements);
176 
178  unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf, tag,
179  cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(file)), line,
180  cast<DIScopeAttr>(unwrap(scope)), cast<DITypeAttr>(unwrap(baseType)),
181  DIFlags(flags), sizeInBits, alignInBits,
182  llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
183  [](Attribute a) { return cast<DINodeAttr>(a); }),
184  cast<DIExpressionAttr>(unwrap(dataLocation)),
185  cast<DIExpressionAttr>(unwrap(rank)),
186  cast<DIExpressionAttr>(unwrap(allocated)),
187  cast<DIExpressionAttr>(unwrap(associated))));
188 }
189 
191  MlirContext ctx, unsigned int tag, MlirAttribute name,
192  MlirAttribute baseType, uint64_t sizeInBits, uint32_t alignInBits,
193  uint64_t offsetInBits, int64_t dwarfAddressSpace, MlirAttribute extraData) {
194  std::optional<unsigned> addressSpace = std::nullopt;
195  if (dwarfAddressSpace >= 0)
196  addressSpace = (unsigned)dwarfAddressSpace;
198  unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
199  cast<DITypeAttr>(unwrap(baseType)), sizeInBits, alignInBits, offsetInBits,
200  addressSpace, cast<DINodeAttr>(unwrap(extraData))));
201 }
202 
204  MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
205  uint32_t alignInBits, MlirAttribute stringLength,
206  MlirAttribute stringLengthExp, MlirAttribute stringLocationExp,
207  MlirLLVMTypeEncoding encoding) {
209  unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, alignInBits,
210  cast<DIVariableAttr>(unwrap(stringLength)),
211  cast<DIExpressionAttr>(unwrap(stringLengthExp)),
212  cast<DIExpressionAttr>(unwrap(stringLocationExp)), encoding));
213 }
214 
215 MlirAttribute
216 mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType) {
217  return wrap(cast<DIDerivedTypeAttr>(unwrap(diDerivedType)).getBaseType());
218 }
219 
220 MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, MlirLLVMCConv cconv) {
221  return wrap(CConvAttr::get(unwrap(ctx), CConv(cconv)));
222 }
223 
224 MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, MlirLLVMComdat comdat) {
225  return wrap(ComdatAttr::get(unwrap(ctx), comdat::Comdat(comdat)));
226 }
227 
228 MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage) {
229  return wrap(LinkageAttr::get(unwrap(ctx), linkage::Linkage(linkage)));
230 }
231 
232 MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name,
233  MlirAttribute directory) {
234  return wrap(DIFileAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
235  cast<StringAttr>(unwrap(directory))));
236 }
237 
238 MlirAttribute
239 mlirLLVMDICompileUnitAttrGet(MlirContext ctx, MlirAttribute id,
240  unsigned int sourceLanguage, MlirAttribute file,
241  MlirAttribute producer, bool isOptimized,
242  MlirLLVMDIEmissionKind emissionKind,
243  MlirLLVMDINameTableKind nameTableKind) {
245  unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
246  cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
247  isOptimized, DIEmissionKind(emissionKind),
248  DINameTableKind(nameTableKind)));
249 }
250 
251 MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value) {
252  return wrap(DIFlagsAttr::get(unwrap(ctx), DIFlags(value)));
253 }
254 
255 MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx,
256  MlirAttribute scope,
257  MlirAttribute file,
258  unsigned int line,
259  unsigned int column) {
260  return wrap(
261  DILexicalBlockAttr::get(unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
262  cast<DIFileAttr>(unwrap(file)), line, column));
263 }
264 
265 MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx,
266  MlirAttribute scope,
267  MlirAttribute file,
268  unsigned int discriminator) {
270  unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
271  cast<DIFileAttr>(unwrap(file)), discriminator));
272 }
273 
275  MlirContext ctx, MlirAttribute scope, MlirAttribute name,
276  MlirAttribute diFile, unsigned int line, unsigned int arg,
277  unsigned int alignInBits, MlirAttribute diType, int64_t flags) {
279  unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
280  cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(diFile)), line,
281  arg, alignInBits, cast<DITypeAttr>(unwrap(diType)), DIFlags(flags)));
282 }
283 
284 MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
285  unsigned int callingConvention,
286  intptr_t nTypes,
287  MlirAttribute const *types) {
288  SmallVector<Attribute> attrStorage;
289  attrStorage.reserve(nTypes);
290 
292  unwrap(ctx), callingConvention,
293  llvm::map_to_vector(unwrapList(nTypes, types, attrStorage),
294  [](Attribute a) { return cast<DITypeAttr>(a); })));
295 }
296 
297 MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId) {
298  return wrap(DISubprogramAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
299 }
300 
302  MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
303  MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
304  MlirAttribute linkageName, MlirAttribute file, unsigned int line,
305  unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
306  intptr_t nRetainedNodes, MlirAttribute const *retainedNodes,
307  intptr_t nAnnotations, MlirAttribute const *annotations) {
308  SmallVector<Attribute> nodesStorage;
309  nodesStorage.reserve(nRetainedNodes);
310 
311  SmallVector<Attribute> annotationsStorage;
312  annotationsStorage.reserve(nAnnotations);
313 
315  unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf,
316  cast<DistinctAttr>(unwrap(id)),
317  cast<DICompileUnitAttr>(unwrap(compileUnit)),
318  cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
319  cast<StringAttr>(unwrap(linkageName)), cast<DIFileAttr>(unwrap(file)),
320  line, scopeLine, DISubprogramFlags(subprogramFlags),
321  cast<DISubroutineTypeAttr>(unwrap(type)),
322  llvm::map_to_vector(
323  unwrapList(nRetainedNodes, retainedNodes, nodesStorage),
324  [](Attribute a) { return cast<DINodeAttr>(a); }),
325  llvm::map_to_vector(
326  unwrapList(nAnnotations, annotations, annotationsStorage),
327  [](Attribute a) { return cast<DINodeAttr>(a); })));
328 }
329 
330 MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram) {
331  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getScope());
332 }
333 
334 unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram) {
335  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getLine();
336 }
337 
338 unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram) {
339  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getScopeLine();
340 }
341 
342 MlirAttribute
343 mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram) {
344  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getCompileUnit());
345 }
346 
347 MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram) {
348  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getFile());
349 }
350 
351 MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram) {
352  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getType());
353 }
354 
355 MlirAttribute mlirLLVMDIModuleAttrGet(MlirContext ctx, MlirAttribute file,
356  MlirAttribute scope, MlirAttribute name,
357  MlirAttribute configMacros,
358  MlirAttribute includePath,
359  MlirAttribute apinotes, unsigned int line,
360  bool isDecl) {
361  return wrap(DIModuleAttr::get(
362  unwrap(ctx), cast<DIFileAttr>(unwrap(file)),
363  cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
364  cast<StringAttr>(unwrap(configMacros)),
365  cast<StringAttr>(unwrap(includePath)), cast<StringAttr>(unwrap(apinotes)),
366  line, isDecl));
367 }
368 
369 MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule) {
370  return wrap(cast<DIModuleAttr>(unwrap(diModule)).getScope());
371 }
372 
374  MlirContext ctx, unsigned int tag, MlirAttribute scope,
375  MlirAttribute entity, MlirAttribute file, unsigned int line,
376  MlirAttribute name, intptr_t nElements, MlirAttribute const *elements) {
377  SmallVector<Attribute> elementsStorage;
378  elementsStorage.reserve(nElements);
380  unwrap(ctx), tag, cast<DIScopeAttr>(unwrap(scope)),
381  cast<DINodeAttr>(unwrap(entity)), cast<DIFileAttr>(unwrap(file)), line,
382  cast<StringAttr>(unwrap(name)),
383  llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
384  [](Attribute a) { return cast<DINodeAttr>(a); })));
385 }
386 
387 MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name,
388  MlirAttribute value) {
389  return wrap(DIAnnotationAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
390  cast<StringAttr>(unwrap(value))));
391 }
bool mlirLLVMStructTypeIsLiteral(MlirType type)
Returns true if the type is a literal (unnamed) LLVM struct type.
Definition: LLVM.cpp:58
MlirAttribute mlirLLVMLinkageAttrGet(MlirContext ctx, MlirLLVMLinkage linkage)
Creates a LLVM Linkage attribute.
Definition: LLVM.cpp:228
MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram)
Gets the file from this DISubprogramAttr.
Definition: LLVM.cpp:347
MlirType mlirLLVMFunctionTypeGet(MlirType resultType, intptr_t nArgumentTypes, MlirType const *argumentTypes, bool isVarArg)
Creates an llvm.func type.
Definition: LLVM.cpp:46
MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule)
Gets the scope of this DIModuleAttr.
Definition: LLVM.cpp:369
intptr_t mlirLLVMStructTypeGetNumElementTypes(MlirType type)
Returns the number of fields in the struct.
Definition: LLVM.cpp:62
MlirAttribute mlirLLVMDINullTypeAttrGet(MlirContext ctx)
Creates a LLVM DINullType attribute.
Definition: LLVM.cpp:149
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:119
MlirAttribute mlirLLVMDIFileAttrGet(MlirContext ctx, MlirAttribute name, MlirAttribute directory)
Creates a LLVM DIFileAttr attribute.
Definition: LLVM.cpp:232
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:239
bool mlirTypeIsALLVMStructType(MlirType type)
Returns true if the type is an LLVM dialect struct type.
Definition: LLVM.cpp:54
MlirStringRef mlirLLVMStructTypeGetIdentifier(MlirType type)
Returns the identifier of the identified struct.
Definition: LLVM.cpp:74
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:203
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:167
MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram)
Gets the scope from this DISubprogramAttr.
Definition: LLVM.cpp:330
MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int line, unsigned int column)
Creates a LLVM DILexicalBlock attribute.
Definition: LLVM.cpp:255
MlirAttribute mlirLLVMDIExpressionElemAttrGet(MlirContext ctx, unsigned int opcode, intptr_t nArguments, uint64_t const *arguments)
Creates a LLVM DIExpressionElem attribute.
Definition: LLVM.cpp:129
MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId)
Creates a self-referencing LLVM DICompositeType attribute.
Definition: LLVM.cpp:162
MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits, MlirLLVMTypeEncoding encoding)
Creates a LLVM DIBasicType attribute.
Definition: LLVM.cpp:153
MlirAttribute mlirLLVMComdatAttrGet(MlirContext ctx, MlirLLVMComdat comdat)
Creates a LLVM Comdat attribute.
Definition: LLVM.cpp:224
MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId)
Creates a self-referencing LLVM DISubprogramAttr attribute.
Definition: LLVM.cpp:297
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:373
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:109
MlirType mlirLLVMStructTypeGetElementType(MlirType type, intptr_t position)
Returns the positions-th field of the struct.
Definition: LLVM.cpp:66
MlirType mlirLLVMStructTypeOpaqueGet(MlirContext ctx, MlirStringRef name)
Definition: LLVM.cpp:101
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:351
MlirAttribute mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram)
Gets the compile unit from this DISubprogram.
Definition: LLVM.cpp:343
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:355
MlirAttribute mlirLLVMCConvAttrGet(MlirContext ctx, MlirLLVMCConv cconv)
Creates a LLVM CConv attribute.
Definition: LLVM.cpp:220
MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name, MlirAttribute value)
Creates a LLVM DIAnnotation attribute.
Definition: LLVM.cpp:387
MlirType mlirLLVMStructTypeLiteralGetChecked(MlirLocation loc, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type if possible.
Definition: LLVM.cpp:91
MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int discriminator)
Creates a LLVM DILexicalBlockFile attribute.
Definition: LLVM.cpp:265
MlirAttribute mlirLLVMDIExpressionAttrGet(MlirContext ctx, intptr_t nOperations, MlirAttribute const *operations)
Creates a LLVM DIExpression attribute.
Definition: LLVM.cpp:137
bool mlirLLVMStructTypeIsPacked(MlirType type)
Returns true if the struct is packed.
Definition: LLVM.cpp:70
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:301
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:251
MlirType mlirLLVMStructTypeIdentifiedGet(MlirContext ctx, MlirStringRef name)
Creates an LLVM identified struct type with no body.
Definition: LLVM.cpp:105
MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx, unsigned int callingConvention, intptr_t nTypes, MlirAttribute const *types)
Creates a LLVM DISubroutineTypeAttr attribute.
Definition: LLVM.cpp:284
MlirAttribute mlirLLVMDIDerivedTypeAttrGetBaseType(MlirAttribute diDerivedType)
Gets the base type from a LLVM DIDerivedType attribute.
Definition: LLVM.cpp:216
bool mlirLLVMStructTypeIsOpaque(MlirType type)
Returns true is the struct is explicitly opaque (will not have a body) or uninitialized (will eventua...
Definition: LLVM.cpp:78
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:334
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:274
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:338
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:190
MlirType mlirLLVMStructTypeLiteralGet(MlirContext ctx, intptr_t nFieldTypes, MlirType const *fieldTypes, bool isPacked)
Creates an LLVM literal (unnamed) struct type.
Definition: LLVM.cpp:82
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
Definition: Registration.h:36
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
static LLVMStructType getLiteralChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, ArrayRef< Type > types, bool isPacked=false)
Definition: LLVMTypes.cpp:458
static LLVMStructType getLiteral(MLIRContext *context, ArrayRef< Type > types, bool isPacked=false)
Gets or creates a literal struct with the given body in the provided context.
Definition: LLVMTypes.cpp:452
static LLVMStructType getNewIdentified(MLIRContext *context, StringRef name, ArrayRef< Type > elements, bool isPacked=false)
Gets a new identified struct with the given body.
Definition: LLVMTypes.cpp:435
static LLVMStructType getIdentified(MLIRContext *context, StringRef name)
Gets or creates an identified struct with the given name in the provided context.
Definition: LLVMTypes.cpp:424
static LLVMStructType getOpaque(StringRef name, MLIRContext *context)
Gets or creates an intentionally-opaque identified struct.
Definition: LLVMTypes.cpp:464
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
MlirLLVMDINameTableKind
Definition: LLVM.h:284
MlirLLVMLinkage
Definition: LLVM.h:177
MlirLLVMComdat
Definition: LLVM.h:164
MlirLLVMCConv
Definition: LLVM.h:109
MlirLLVMDIEmissionKind
Definition: LLVM.h:276
MlirLLVMTypeEncoding
Definition: LLVM.h:208
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