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>
38MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Polymorphic, llzk__polymorphic,
PolymorphicDialect)
45 return wrap(
TypeVarType::get(FlatSymbolRefAttr::get(StringAttr::get(unwrap(ctx), unwrap(name)))));
51 auto attr = unwrap(attrWrapper);
52 if (
auto sym = llvm::dyn_cast<FlatSymbolRefAttr>(attr)) {
55 return wrap(
TypeVarType::get(FlatSymbolRefAttr::get(llvm::cast<StringAttr>(attr))));
59 return wrap(llvm::cast<TypeVarType>(unwrap(type)).getRefName());
63 return wrap(llvm::cast<TypeVarType>(unwrap(type)).getNameRef());
71 SmallVector<Value> mapOperandsSto;
74 builder, location, llvm::cast<AffineMapAttr>(unwrap(map)),
75 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
83 SmallVector<Value> mapOperandsSto;
86 builder, location, unwrap(map),
87 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
95 SmallVector<Value> mapOperandsSto;
98 builder, location, unwrap(expr),
99 ValueRange(unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto))
111static ValueRange dimOperands(MlirOperation op) {
115static ValueRange symbolOperands(MlirOperation op) {
119static void copyValues(ValueRange in, MlirValue *out) {
120 for (
auto [n, value] : llvm::enumerate(in)) {
121 out[n] = wrap(value);
127 return static_cast<intptr_t
>(dimOperands(op).size());
134 copyValues(dimOperands(op), dst);
139 return static_cast<intptr_t
>(symbolOperands(op).size());
146 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.
MlirType llzkTypeVarTypeGetFromAttr(MlirContext, MlirAttribute attrWrapper)
Creates a llzk::polymorphic::TypeVarType from either a StringAttr or a FlatSymbolRefAttr.
MlirType llzkTypeVarTypeGet(MlirContext ctx, MlirStringRef name)
Creates a llzk::polymorphic::TypeVarType.
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.
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)