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 
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  cast<DIExpressionAttr>(unwrap(dataLocation)),
201  cast<DIExpressionAttr>(unwrap(rank)),
202  cast<DIExpressionAttr>(unwrap(allocated)),
203  cast<DIExpressionAttr>(unwrap(associated)),
204  llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
205  [](Attribute a) { return cast<DINodeAttr>(a); })));
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 
257  MlirContext ctx, MlirAttribute id, unsigned int sourceLanguage,
258  MlirAttribute file, MlirAttribute producer, bool isOptimized,
259  MlirLLVMDIEmissionKind emissionKind, MlirLLVMDINameTableKind nameTableKind,
260  MlirAttribute splitDebugFilename) {
262  unwrap(ctx), cast<DistinctAttr>(unwrap(id)), sourceLanguage,
263  cast<DIFileAttr>(unwrap(file)), cast<StringAttr>(unwrap(producer)),
264  isOptimized, DIEmissionKind(emissionKind), DINameTableKind(nameTableKind),
265  cast<StringAttr>(unwrap(splitDebugFilename))));
266 }
267 
268 MlirAttribute mlirLLVMDIFlagsAttrGet(MlirContext ctx, uint64_t value) {
269  return wrap(DIFlagsAttr::get(unwrap(ctx), DIFlags(value)));
270 }
271 
272 MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx,
273  MlirAttribute scope,
274  MlirAttribute file,
275  unsigned int line,
276  unsigned int column) {
277  return wrap(
278  DILexicalBlockAttr::get(unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
279  cast<DIFileAttr>(unwrap(file)), line, column));
280 }
281 
282 MlirAttribute mlirLLVMDILexicalBlockFileAttrGet(MlirContext ctx,
283  MlirAttribute scope,
284  MlirAttribute file,
285  unsigned int discriminator) {
287  unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
288  cast<DIFileAttr>(unwrap(file)), discriminator));
289 }
290 
292  MlirContext ctx, MlirAttribute scope, MlirAttribute name,
293  MlirAttribute diFile, unsigned int line, unsigned int arg,
294  unsigned int alignInBits, MlirAttribute diType, int64_t flags) {
296  unwrap(ctx), cast<DIScopeAttr>(unwrap(scope)),
297  cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(diFile)), line,
298  arg, alignInBits, cast<DITypeAttr>(unwrap(diType)), DIFlags(flags)));
299 }
300 
301 MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
302  unsigned int callingConvention,
303  intptr_t nTypes,
304  MlirAttribute const *types) {
305  SmallVector<Attribute> attrStorage;
306  attrStorage.reserve(nTypes);
307 
309  unwrap(ctx), callingConvention,
310  llvm::map_to_vector(unwrapList(nTypes, types, attrStorage),
311  [](Attribute a) { return cast<DITypeAttr>(a); })));
312 }
313 
314 MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId) {
315  return wrap(DISubprogramAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
316 }
317 
319  MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
320  MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
321  MlirAttribute linkageName, MlirAttribute file, unsigned int line,
322  unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
323  intptr_t nRetainedNodes, MlirAttribute const *retainedNodes,
324  intptr_t nAnnotations, MlirAttribute const *annotations) {
325  SmallVector<Attribute> nodesStorage;
326  nodesStorage.reserve(nRetainedNodes);
327 
328  SmallVector<Attribute> annotationsStorage;
329  annotationsStorage.reserve(nAnnotations);
330 
332  unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf,
333  cast<DistinctAttr>(unwrap(id)),
334  cast<DICompileUnitAttr>(unwrap(compileUnit)),
335  cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
336  cast<StringAttr>(unwrap(linkageName)), cast<DIFileAttr>(unwrap(file)),
337  line, scopeLine, DISubprogramFlags(subprogramFlags),
338  cast<DISubroutineTypeAttr>(unwrap(type)),
339  llvm::map_to_vector(
340  unwrapList(nRetainedNodes, retainedNodes, nodesStorage),
341  [](Attribute a) { return cast<DINodeAttr>(a); }),
342  llvm::map_to_vector(
343  unwrapList(nAnnotations, annotations, annotationsStorage),
344  [](Attribute a) { return cast<DINodeAttr>(a); })));
345 }
346 
347 MlirAttribute mlirLLVMDISubprogramAttrGetScope(MlirAttribute diSubprogram) {
348  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getScope());
349 }
350 
351 unsigned int mlirLLVMDISubprogramAttrGetLine(MlirAttribute diSubprogram) {
352  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getLine();
353 }
354 
355 unsigned int mlirLLVMDISubprogramAttrGetScopeLine(MlirAttribute diSubprogram) {
356  return cast<DISubprogramAttr>(unwrap(diSubprogram)).getScopeLine();
357 }
358 
359 MlirAttribute
360 mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram) {
361  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getCompileUnit());
362 }
363 
364 MlirAttribute mlirLLVMDISubprogramAttrGetFile(MlirAttribute diSubprogram) {
365  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getFile());
366 }
367 
368 MlirAttribute mlirLLVMDISubprogramAttrGetType(MlirAttribute diSubprogram) {
369  return wrap(cast<DISubprogramAttr>(unwrap(diSubprogram)).getType());
370 }
371 
372 MlirAttribute mlirLLVMDIModuleAttrGet(MlirContext ctx, MlirAttribute file,
373  MlirAttribute scope, MlirAttribute name,
374  MlirAttribute configMacros,
375  MlirAttribute includePath,
376  MlirAttribute apinotes, unsigned int line,
377  bool isDecl) {
378  return wrap(DIModuleAttr::get(
379  unwrap(ctx), cast<DIFileAttr>(unwrap(file)),
380  cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
381  cast<StringAttr>(unwrap(configMacros)),
382  cast<StringAttr>(unwrap(includePath)), cast<StringAttr>(unwrap(apinotes)),
383  line, isDecl));
384 }
385 
386 MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule) {
387  return wrap(cast<DIModuleAttr>(unwrap(diModule)).getScope());
388 }
389 
391  MlirContext ctx, unsigned int tag, MlirAttribute scope,
392  MlirAttribute entity, MlirAttribute file, unsigned int line,
393  MlirAttribute name, intptr_t nElements, MlirAttribute const *elements) {
394  SmallVector<Attribute> elementsStorage;
395  elementsStorage.reserve(nElements);
397  unwrap(ctx), tag, cast<DIScopeAttr>(unwrap(scope)),
398  cast<DINodeAttr>(unwrap(entity)), cast<DIFileAttr>(unwrap(file)), line,
399  cast<StringAttr>(unwrap(name)),
400  llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
401  [](Attribute a) { return cast<DINodeAttr>(a); })));
402 }
403 
404 MlirAttribute mlirLLVMDIAnnotationAttrGet(MlirContext ctx, MlirAttribute name,
405  MlirAttribute value) {
406  return wrap(DIAnnotationAttr::get(unwrap(ctx), cast<StringAttr>(unwrap(name)),
407  cast<StringAttr>(unwrap(value))));
408 }
static Type getElementType(Type type)
Determine the element type of type.
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:364
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:386
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
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:347
MlirAttribute mlirLLVMDILexicalBlockAttrGet(MlirContext ctx, MlirAttribute scope, MlirAttribute file, unsigned int line, unsigned int column)
Creates a LLVM DILexicalBlock attribute.
Definition: LLVM.cpp:272
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:314
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:390
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:368
MlirAttribute mlirLLVMDISubprogramAttrGetCompileUnit(MlirAttribute diSubprogram)
Gets the compile unit from this DISubprogram.
Definition: LLVM.cpp:360
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:372
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:404
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:282
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:256
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:318
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:268
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:301
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:351
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:291
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:355
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 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:304
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