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 = llvm::dyn_cast<FlatSymbolRefAttr>(attr)) {
59 return wrap(
TypeVarType::get(FlatSymbolRefAttr::get(llvm::cast<StringAttr>(attr))));
63 return wrap(llvm::cast<TypeVarType>(unwrap(type)).getRefName());
67 return wrap(llvm::cast<TypeVarType>(unwrap(type)).getNameRef());
75 SmallVector<Value> mapOperandsSto;
78 builder, location, llvm::cast<AffineMapAttr>(unwrap(map)),
79 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
87 SmallVector<Value> mapOperandsSto;
90 builder, location, unwrap(map),
91 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
99 SmallVector<Value> mapOperandsSto;
102 builder, location, unwrap(expr),
103 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
115static ValueRange dimOperands(MlirOperation op) {
119static ValueRange symbolOperands(MlirOperation op) {
123static void copyValues(ValueRange in, MlirValue *out) {
124 for (
auto [n, value] : llvm::enumerate(in)) {
125 out[n] = wrap(value);
131 return static_cast<intptr_t
>(dimOperands(op).size());
138 copyValues(dimOperands(op), dst);
143 return static_cast<intptr_t
>(symbolOperands(op).size());
150 copyValues(symbolOperands(op), dst);
MlirStringRef llzkTypeVarTypeGetNameRef(MlirType type)
Returns the var name of the TypeVarType as a StringRef.
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
MlirType llzkTypeVarTypeGetFromAttr(MlirContext, MlirAttribute attrWrapper)
Creates a llzk::polymorphic::TypeVarType from either a StringAttr or a FlatSymbolRefAttr.
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)