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());
80 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getType(mlir::cast<ArrayAttr>(unwrap(attr))));
84 Builder builder(unwrap(op)->getContext());
85 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getFieldDef(builder.getStringAttr(unwrap(
name))));
89 for (
auto [offset, field] : llvm::enumerate(mlir::cast<StructDefOp>(unwrap(op)).getFieldDefs())) {
90 dst[offset] = wrap(field);
95 return static_cast<intptr_t
>(mlir::cast<StructDefOp>(unwrap(op)).getFieldDefs().size());
99 return wrap(mlir::cast<StructDefOp>(unwrap(op)).hasColumns());
103 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getComputeFuncOp());
107 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getConstrainFuncOp());
112 auto header = mlir::cast<StructDefOp>(unwrap(op)).getHeaderString();
113 *strSize =
static_cast<intptr_t
>(header.size()) + 1;
114 char *dst = alloc_string(*strSize);
115 dst[header.size()] = 0;
116 memcpy(dst, header.data(), header.size());
121 Builder builder(unwrap(op)->getContext());
122 return mlir::cast<StructDefOp>(unwrap(op)).hasParamNamed(builder.getStringAttr(unwrap(
name)));
126 return wrap(mlir::cast<StructDefOp>(unwrap(op)).getFullyQualifiedName());
130 return mlir::cast<StructDefOp>(unwrap(op)).isMainComponent();
140 return mlir::cast<FieldDefOp>(unwrap(op)).hasPublicAttr();
144 mlir::cast<FieldDefOp>(unwrap(op)).setPublicAttr(value);
155 builder, location, unwrap(fieldType), unwrap(
component),
156 unwrap(builder)->getStringAttr(unwrap(
name))
162 MlirAffineMap map,
MlirValueRange mapOperands, int32_t numDimsPerMap
164 SmallVector<Value> mapOperandsSto;
165 auto nameAttr = unwrap(builder)->getStringAttr(unwrap(
name));
166 auto mapAttr = AffineMapAttr::get(unwrap(map));
168 builder, location, unwrap(fieldType), unwrap(
component), nameAttr, mapAttr,
169 unwrapList(mapOperands.
size, mapOperands.
values, mapOperandsSto), numDimsPerMap
175 MlirStringRef
name, MlirStringRef symbol
177 auto nameAttr = unwrap(builder)->getStringAttr(unwrap(
name));
179 builder, location, unwrap(fieldType), unwrap(
component), nameAttr,
180 FlatSymbolRefAttr::get(unwrap(builder)->getStringAttr(unwrap(symbol)))
188 auto nameAttr = unwrap(builder)->getStringAttr(unwrap(
name));
190 builder, location, unwrap(fieldType), unwrap(
component), nameAttr,
191 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.