19#include <mlir/CAPI/AffineExpr.h>
20#include <mlir/CAPI/AffineMap.h>
21#include <mlir/CAPI/Pass.h>
22#include <mlir/CAPI/Registration.h>
23#include <mlir/CAPI/Wrap.h>
24#include <mlir/IR/BuiltinAttributes.h>
25#include <mlir/Support/LLVM.h>
27#include <mlir-c/Pass.h>
29static void registerLLZKPolymorphicTransformationPasses() {
49 return wrap(
TypeVarType::get(FlatSymbolRefAttr::get(StringAttr::get(unwrap(ctx), unwrap(
name)))));
55 auto attr = unwrap(attrWrapper);
56 if (
auto sym = mlir::dyn_cast<FlatSymbolRefAttr>(attr)) {
59 return wrap(
TypeVarType::get(FlatSymbolRefAttr::get(mlir::cast<StringAttr>(attr))));
63 return wrap(mlir::cast<TypeVarType>(unwrap(type)).getRefName());
67 return wrap(mlir::cast<TypeVarType>(unwrap(type)).getNameRef());
75 SmallVector<Value> mapOperandsSto;
77 builder, location, mlir::cast<AffineMapAttr>(unwrap(map)),
78 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
85 SmallVector<Value> mapOperandsSto;
87 builder, location, unwrap(map),
88 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
95 SmallVector<Value> mapOperandsSto;
97 builder, location, unwrap(expr),
98 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
109static ValueRange dimOperands(MlirOperation op) {
113static ValueRange symbolOperands(MlirOperation op) {
117static void copyValues(ValueRange in, MlirValue *out) {
118 for (
auto [n, value] : llvm::enumerate(in)) {
119 out[n] = wrap(value);
125 return static_cast<intptr_t
>(dimOperands(op).size());
132 copyValues(dimOperands(op), dst);
137 return static_cast<intptr_t
>(symbolOperands(op).size());
144 copyValues(symbolOperands(op), dst);
MlirStringRef llzkTypeVarTypeGetNameRef(MlirType type)
Returns the var name of the TypeVarType as a StringRef.
MlirType llzkTypeVarTypeGetFromAttr(MlirContext ctx, MlirAttribute attrWrapper)
Creates a llzk::polymorphic::TypeVarType from either a StringAttr or a FlatSymbolRefAttr.
MlirAffineMap llzkApplyMapOpGetAffineMap(MlirOperation op)
Returns the affine map associated with the op.
bool llzkTypeIsATypeVarType(MlirType type)
intptr_t llzkApplyMapOpGetNumDimOperands(MlirOperation op)
Returns the number of operands that correspond to dimensions in the affine map.
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Polymorphic, llzk__polymorphic, llzk::polymorphic::PolymorphicDialect) MlirType llzkTypeVarTypeGet(MlirContext ctx
MlirAttribute llzkTypeVarTypeGetName(MlirType type)
Returns the var name of the TypeVarType as a FlatSymbolRefAttr.
void llzkApplyMapOpGetDimOperands(MlirOperation op, MlirValue *dst)
Writes into the destination buffer the operands that correspond to dimensions in the affine map.
intptr_t llzkApplyMapOpGetNumSymbolOperands(MlirOperation op)
Returns the number of operands that correspond to symbols in the affine map.
bool llzkOperationIsAApplyMapOp(MlirOperation op)
void llzkApplyMapOpGetSymbolOperands(MlirOperation op, MlirValue *dst)
Writes into the destination buffer the operands that correspond to symbols in the affine map.
MLIR_CAPI_EXPORTED MlirType llzkTypeVarTypeGet(MlirContext context, MlirStringRef value)
Creates a llzk::polymorphic::TypeVarType.
static TypeVarType get(::mlir::MLIRContext *context, ::mlir::FlatSymbolRefAttr nameRef)
#define LLZK_DEFINE_OP_BUILD_METHOD(op,...)
#define LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD(op, suffix,...)
void registerTransformationPasses()
mlir::Operation * create(MlirOpBuilder cBuilder, MlirLocation cLocation, Args &&...args)
Creates a new operation using an ODS build method.
auto unwrap_cast(auto &from)