17#include <mlir/CAPI/IR.h>
18#include <mlir/CAPI/Pass.h>
19#include <mlir/CAPI/Registration.h>
20#include <mlir/CAPI/Wrap.h>
21#include <mlir/IR/Attributes.h>
22#include <mlir/IR/BuiltinAttributes.h>
25#include <mlir-c/Pass.h>
27#include <llvm/ADT/SmallVectorExtras.h>
35static NamedAttribute unwrap(MlirNamedAttribute attr) {
36 return NamedAttribute(unwrap(attr.name), unwrap(attr.attribute));
46 MlirLocation location, MlirStringRef
name, MlirType funcType, intptr_t numAttrs,
47 MlirNamedAttribute
const *attrs, intptr_t numArgAttrs, MlirAttribute
const *argAttrs
49 SmallVector<NamedAttribute> attrsSto;
50 SmallVector<Attribute> argAttrsSto;
51 SmallVector<DictionaryAttr> unwrappedArgAttrs =
52 llvm::map_to_vector(unwrapList(numArgAttrs, argAttrs, argAttrsSto), [](
auto attr) {
53 return mlir::cast<DictionaryAttr>(attr);
56 unwrap(location), unwrap(
name), mlir::cast<FunctionType>(unwrap(funcType)),
57 unwrapList(numAttrs, attrs, attrsSto), unwrappedArgAttrs
116static auto unwrapCallee(MlirOperation op) {
return mlir::cast<FuncDefOp>(unwrap(op)); }
118static auto unwrapDims(MlirAttribute attr) {
return mlir::cast<DenseI32ArrayAttr>(unwrap(attr)); }
120static auto unwrapName(MlirAttribute attr) {
return mlir::cast<SymbolRefAttr>(unwrap(attr)); }
123 CallOp, intptr_t numResults, MlirType
const *results, MlirAttribute
name, intptr_t numOperands,
124 MlirValue
const *operands
126 SmallVector<Type> resultsSto;
127 SmallVector<Value> operandsSto;
129 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
130 unwrapList(numOperands, operands, operandsSto)
135 CallOp, ToCallee, MlirOperation callee, intptr_t numOperands, MlirValue
const *operands
137 SmallVector<Value> operandsSto;
139 builder, location, unwrapCallee(callee), unwrapList(numOperands, operands, operandsSto)
144 CallOp, WithMapOperands, intptr_t numResults, MlirType
const *results, MlirAttribute
name,
145 intptr_t numMapOperands,
MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap,
146 intptr_t numArgOperands, MlirValue
const *argOperands
148 SmallVector<Type> resultsSto;
149 SmallVector<Value> argOperandsSto;
152 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
153 *mapOperandsHelper, unwrapDims(numDimsPerMap),
154 unwrapList(numArgOperands, argOperands, argOperandsSto)
159 CallOp, WithMapOperandsAndDims, intptr_t numResults, MlirType
const *results,
161 intptr_t numDimsPermMapLength, int32_t
const *numDimsPerMap, intptr_t numArgOperands,
162 MlirValue
const *argOperands
164 SmallVector<Type> resultsSto;
165 SmallVector<Value> argOperandsSto;
168 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
169 *mapOperandsHelper, ArrayRef(numDimsPerMap, numDimsPermMapLength),
170 unwrapList(numArgOperands, argOperands, argOperandsSto)
175 CallOp, ToCalleeWithMapOperands, MlirOperation callee, intptr_t numMapOperands,
176 MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap, intptr_t numArgOperands,
177 MlirValue
const *argOperands
179 SmallVector<Value> argOperandsSto;
182 builder, location, unwrapCallee(callee), *mapOperandsHelper, unwrapDims(numDimsPerMap),
183 unwrapList(numArgOperands, argOperands, argOperandsSto)
188 CallOp, ToCalleeWithMapOperandsAndDims, MlirOperation callee, intptr_t numMapOperands,
189 MlirValueRange const *mapOperands, intptr_t numDimsPermMapLength, int32_t
const *numDimsPerMap,
190 intptr_t numArgOperands, MlirValue
const *argOperands
192 SmallVector<Value> argOperandsSto;
195 builder, location, unwrapCallee(callee), *mapOperandsHelper,
196 ArrayRef(numDimsPerMap, numDimsPermMapLength),
197 unwrapList(numArgOperands, argOperands, argOperandsSto)
bool llzkFuncDefOpGetHasAllowWitnessAttr(MlirOperation op)
MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the function is the compute function returns its StructType result.
MlirType llzkCallOpGetCalleeType(MlirOperation op)
Returns the FunctionType of the callee.
MlirOperation llzkFuncDefOpCreateWithAttrsAndArgAttrs(MlirLocation location, MlirStringRef name, MlirType funcType, intptr_t numAttrs, MlirNamedAttribute const *attrs, intptr_t numArgAttrs, MlirAttribute const *argAttrs)
Creates a FuncDefOp with the given attributes and argument attributes.
bool llzkFuncDefOpGetNameIsConstrain(MlirOperation op)
bool llzkCallOpGetCalleeIsStructConstrain(MlirOperation op)
bool llzkFuncDefOpGetIsInStruct(MlirOperation op)
bool llzkFuncDefOpGetHasArgIsPub(MlirOperation op, unsigned argNo)
bool llzkFuncDefOpGetIsStructCompute(MlirOperation op)
bool llzkCallOpGetCalleeIsConstrain(MlirOperation op)
void llzkFuncDefOpSetAllowConstraintAttr(MlirOperation op, bool value)
Sets the allow_constraint attribute in the FuncDefOp operation.
bool llzkCallOpGetCalleeIsStructCompute(MlirOperation op)
MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the callee is the compute function, returns its StructType result.
bool llzkFuncDefOpGetIsStructConstrain(MlirOperation op)
bool llzkOperationIsAFuncDefOp(MlirOperation op)
bool llzkCallOpGetCalleeIsCompute(MlirOperation op)
bool llzkOperationIsACallOp(MlirOperation op)
bool llzkFuncDefOpGetNameIsCompute(MlirOperation op)
bool llzkFuncDefOpGetHasAllowConstraintAttr(MlirOperation op)
MlirAttribute llzkFuncDefOpGetFullyQualifiedName(MlirOperation op)
Returns the fully qualified name of the function.
void llzkFuncDefOpSetAllowWitnessAttr(MlirOperation op, bool value)
Sets the allow_witness attribute in the FuncDefOp operation.
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Polymorphic, llzk__polymorphic, llzk::polymorphic::PolymorphicDialect) MlirType llzkTypeVarTypeGet(MlirContext ctx
Helper for unwrapping the C arguments for the map operands.
static FuncDefOp create(::mlir::Location location, ::llvm::StringRef name, ::mlir::FunctionType type, ::llvm::ArrayRef<::mlir::NamedAttribute > attrs={})
#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.
auto unwrap_cast(auto &from)