15#include <mlir/CAPI/IR.h>
16#include <mlir/CAPI/Support.h>
17#include <mlir/CAPI/Wrap.h>
18#include <mlir/IR/BuiltinAttributes.h>
19#include <mlir/IR/Iterators.h>
21#include <mlir-c/BuiltinAttributes.h>
39 return wrap(result->
get());
44 unwrap(op)->replaceUsesOfWith(unwrap(oldValue), unwrap(newValue));
48static mlir::WalkResult unwrap(MlirWalkResult result) {
50 case MlirWalkResultAdvance:
51 return mlir::WalkResult::advance();
53 case MlirWalkResultInterrupt:
54 return mlir::WalkResult::interrupt();
56 case MlirWalkResultSkip:
57 return mlir::WalkResult::skip();
59 llvm_unreachable(
"unknown result in WalkResult::unwrap");
63 MlirOperation
from, MlirOperationWalkCallback callback,
void *userData, MlirWalkOrder walkOrder
66 case MlirWalkPreOrder:
67 unwrap(
from)->walk<WalkOrder::PreOrder, ReverseIterator>([callback, userData](Operation *op) {
68 return unwrap(callback(wrap(op), userData));
71 case MlirWalkPostOrder:
72 unwrap(
from)->walk<WalkOrder::PostOrder, ReverseIterator>([callback, userData](Operation *op) {
73 return unwrap(callback(wrap(op), userData));
83template <
typename T>
void appendElems(T
const *src, intptr_t srcSize, T *&dst, intptr_t &dstSize) {
84 assert(srcSize >= 0 &&
"Negative source size");
85 assert(dstSize >= 0 &&
"Negative destination size");
86 dst =
static_cast<T *
>(std::realloc(dst, (srcSize + dstSize) *
sizeof(T)));
87 assert(dst &&
"Failed to increase the size of buffer");
88 std::memcpy(dst + dstSize, src, srcSize *
sizeof(T));
130 maybeDeallocArray(builder);
143 int32_t
const *dimsPerMap
145 assertArraysAreInSync(builder);
148 assertArraysAreInSync(builder);
161 assert(mlirAttributeIsADenseI32Array(attribute) &&
"Attribute is not a DenseI32Array");
162 maybeDeallocArray(builder);
172 size_t realSize = attrData.size() *
sizeof(
decltype(attrData)::value_type);
173 builder->
dimsPerMap.
array =
static_cast<int32_t *
>(std::malloc(realSize));
175 builder->
nDimsPerMap =
static_cast<intptr_t
>(attrData.size());
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
void llzkSymbolLookupResultDestroy(LlzkSymbolLookupResult result)
Destroys the lookup result, releasing its resources.
void llzkAffineMapOperandsBuilderSetDimsPerMapFromAttr(LlzkAffineMapOperandsBuilder *builder, MlirAttribute attribute)
Sets the number of dimensions per map to the given attribute.
void llzkAffineMapOperandsBuilderConvertDimsPerMapToArray(LlzkAffineMapOperandsBuilder *builder)
Converts the list of dimensions defined as an attribute into an array.
MlirOperation LlzkSymbolLookupResultGetOperation(LlzkSymbolLookupResult wrapped)
Returns the looked up Operation.
void mlirOperationWalkReverse(MlirOperation from, MlirOperationWalkCallback callback, void *userData, MlirWalkOrder walkOrder)
Walks operation op in walkOrder, with operations at the same nesting level traversed in reverse order...
void llzkAffineMapOperandsBuilderConvertDimsPerMapToAttr(LlzkAffineMapOperandsBuilder *builder, MlirContext context)
Converts the list of dimensions defined as an array into an attribute.
MlirAttribute llzkAffineMapOperandsBuilderGetDimsPerMapAttr(LlzkAffineMapOperandsBuilder builder, MlirContext context)
Returns the number of dimensions per map represented as an attribute.
void llzkAffineMapOperandsBuilderAppendOperands(LlzkAffineMapOperandsBuilder *builder, intptr_t n, MlirValueRange const *mapOperands)
Appends the value ranges to the list of map operands.
void llzkAffineMapOperandsBuilderAppendDimCount(LlzkAffineMapOperandsBuilder *builder, intptr_t n, int32_t const *dimsPerMap)
Appends a dimension count to the list of dimensions per map.
void mlirOperationReplaceUsesOfWith(MlirOperation op, MlirValue oldValue, MlirValue newValue)
Note: Duplicated from upstream LLVM. Available in 21.1.8 and later.
LlzkAffineMapOperandsBuilder llzkAffineMapOperandsBuilderCreate()
Creates a new struct. The owner is responsible for cleaning the struct.
void llzkAffineMapOperandsBuilderAppendOperandsWithDimCount(LlzkAffineMapOperandsBuilder *builder, intptr_t n, MlirValueRange const *mapOperands, int32_t const *dimsPerMap)
Appends the value ranges to the list of map operands and indicates how many of these operands are dim...
void llzkAffineMapOperandsBuilderDestroy(LlzkAffineMapOperandsBuilder *builder)
Destroys the struct releasing its resources.
This file defines methods symbol lookup across LLZK operations and included files.
auto unwrap_cast(auto &from)
Encapsulates the arguments related to affine maps that are common in operation constructors that supp...
union LlzkAffineMapOperandsBuilder::@126363357317107207232312003203325156066212176243 dimsPerMap
intptr_t nDimsPerMap
Set to a negative number to indicate that dimsPerMap.attr must be used instead of dimsPerMap....
MlirValueRange * mapOperands
int32_t * array
List of dimension counts.