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