20#include <mlir/CAPI/AffineMap.h>
21#include <mlir/CAPI/Registration.h>
22#include <mlir/CAPI/Support.h>
23#include <mlir/CAPI/Wrap.h>
24#include <mlir/IR/BuiltinAttributes.h>
26#include <mlir-c/Support.h>
28#include <llvm/ADT/STLExtras.h>
46 mlir::cast<SymbolRefAttr>(unwrap(
name)), mlir::cast<ArrayAttr>(unwrap(params))
52 SmallVector<Attribute> paramsSto;
54 mlir::cast<SymbolRefAttr>(unwrap(
name)), unwrapList(numParams, params, paramsSto)
61 return wrap(mlir::cast<StructType>(unwrap(type)).getNameRef());
65 return wrap(mlir::cast<StructType>(unwrap(type)).getParams());
75 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getType());
79 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getType(mlir::cast<ArrayAttr>(unwrap(attr))));
83 Builder builder(unwrap(op)->getContext());
84 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getFieldDef(builder.getStringAttr(unwrap(
name))));
88 for (
auto [offset, field] : llvm::enumerate(mlir::cast<StructDefOp>(unwrap(op)).getFieldDefs())) {
89 dst[offset] = wrap(field);
94 return static_cast<intptr_t
>(mlir::cast<StructDefOp>(unwrap(op)).getFieldDefs().size());
98 return wrap(mlir::cast<StructDefOp>(unwrap(op)).hasColumns());
102 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getComputeFuncOp());
106 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getConstrainFuncOp());
111 auto header = mlir::cast<StructDefOp>(unwrap(op)).getHeaderString();
112 *strSize =
static_cast<intptr_t
>(header.size()) + 1;
113 char *dst = alloc_string(*strSize);
114 dst[header.size()] = 0;
115 memcpy(dst, header.data(), header.size());
120 Builder builder(unwrap(op)->getContext());
121 return mlir::cast<StructDefOp>(unwrap(op)).hasParamNamed(builder.getStringAttr(unwrap(
name)));
125 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getFullyQualifiedName());
129 return mlir::cast<StructDefOp>(unwrap(op)).isMainComponent();
139 return mlir::cast<FieldDefOp>(unwrap(op)).hasPublicAttr();
143 mlir::cast<FieldDefOp>(unwrap(op)).setPublicAttr(value);
154 builder, location, unwrap(fieldType), unwrap(
component),
155 unwrap(builder)->getStringAttr(unwrap(
name))
161 MlirAffineMap map,
MlirValueRange mapOperands, int32_t numDimsPerMap
163 SmallVector<Value> mapOperandsSto;
164 auto nameAttr = unwrap(builder)->getStringAttr(unwrap(
name));
165 auto mapAttr = AffineMapAttr::get(unwrap(map));
167 builder, location, unwrap(fieldType), unwrap(
component), nameAttr, mapAttr,
168 unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto), numDimsPerMap
174 MlirStringRef
name, MlirStringRef symbol
176 auto nameAttr = unwrap(builder)->getStringAttr(unwrap(
name));
178 builder, location, unwrap(fieldType), unwrap(
component), nameAttr,
179 FlatSymbolRefAttr::get(unwrap(builder)->getStringAttr(unwrap(symbol)))
187 auto nameAttr = unwrap(builder)->getStringAttr(unwrap(
name));
189 builder, location, unwrap(fieldType), unwrap(
component), nameAttr,
190 unwrap(builder)->getI64IntegerAttr(distance)
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Polymorphic, llzk__polymorphic, llzk::polymorphic::PolymorphicDialect) MlirType llzkTypeVarTypeGet(MlirContext ctx
void llzkFieldDefOpSetPublicAttr(MlirOperation op, bool value)
Sets the public attribute in the given field.
bool llzkFieldDefOpGetHasPublicAttr(MlirOperation op)
const char * llzkStructDefOpGetHeaderString(MlirOperation op, intptr_t *strSize, char *(*alloc_string)(size_t))
Returns the header string of the struct.
void llzkStructDefOpGetFieldDefs(MlirOperation op, MlirOperation *dst)
Fills the given array with the FieldDefOp operations inside this struct.
MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op)
Returns a StringAttr with the fully qualified name of the struct.
MlirType llzkStructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute attr)
Returns the associated StructType to this op using the given const params instead of the parameters d...
bool llzkStructDefOpGetHasParamName(MlirOperation op, MlirStringRef name)
MlirType llzkStructTypeGetWithAttrs(MlirAttribute name, intptr_t numParams, MlirAttribute const *params)
Creates a llzk::component::StructType with an array of parameters.
MlirAttribute llzkStructTypeGetParams(MlirType type)
Returns the parameter of a llzk::component::StructType as an ArrayAttr.
MlirType llzkStructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params)
Creates a llzk::component::StructType with an ArrayAttr as parameters.
bool llzkOperationIsAFieldDefOp(MlirOperation op)
bool llzkStructDefOpGetIsMainComponent(MlirOperation op)
bool llzkTypeIsAStructType(MlirType type)
MlirOperation llzkStructDefOpGetFieldDef(MlirOperation op, MlirStringRef name)
Returns the operation that defines the field with the given name, if present.
MlirOperation llzkStructDefOpGetComputeFuncOp(MlirOperation op)
Returns the FuncDefOp operation that defines the witness computation of the struct.
MlirAttribute llzkStructTypeGetName(MlirType type)
Returns the fully qualified name of a llzk::component::StructType.
intptr_t llzkStructDefOpGetNumFieldDefs(MlirOperation op)
Returns the number of FieldDefOp operations defined in this struct.
bool llzkOperationIsAStructDefOp(MlirOperation op)
MlirType llzkStructTypeGet(MlirAttribute name)
Creates a llzk::component::StructType.
MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op)
Returns the FuncDefOp operation that defines the constraints of the struct.
MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op)
Returns true if the struct has fields marked as columns.
MlirType llzkStructDefOpGetType(MlirOperation op)
Returns the associated StructType to this op using the const params defined by the op.
static StructType get(::mlir::SymbolRefAttr structName)
#define LLZK_DEFINE_OP_BUILD_METHOD(op,...)
#define LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD(op, suffix,...)
mlir::Operation * create(MlirOpBuilder cBuilder, MlirLocation cLocation, Args &&...args)
Creates a new operation using an ODS build method.