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 llvm::cast<DictionaryAttr>(attr);
57 unwrap(location), unwrap(
name), llvm::cast<FunctionType>(unwrap(funcType)),
58 unwrapList(numAttrs, attrs, attrsSto), unwrappedArgAttrs
130static auto unwrapCallee(MlirOperation op) {
return llvm::cast<FuncDefOp>(unwrap(op)); }
132static auto unwrapDims(MlirAttribute attr) {
return llvm::cast<DenseI32ArrayAttr>(unwrap(attr)); }
134static auto unwrapName(MlirAttribute attr) {
return llvm::cast<SymbolRefAttr>(unwrap(attr)); }
137 CallOp, intptr_t numResults, MlirType
const *results, MlirAttribute
name, intptr_t numOperands,
138 MlirValue
const *operands
140 SmallVector<Type> resultsSto;
141 SmallVector<Value> operandsSto;
144 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
145 unwrapList(numOperands, operands, operandsSto)
151 CallOp, ToCallee, MlirOperation callee, intptr_t numOperands, MlirValue
const *operands
153 SmallVector<Value> operandsSto;
156 builder, location, unwrapCallee(callee), unwrapList(numOperands, operands, operandsSto)
162 CallOp, WithMapOperands, intptr_t numResults, MlirType
const *results, MlirAttribute
name,
163 intptr_t numMapOperands,
MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap,
164 intptr_t numArgOperands, MlirValue
const *argOperands
166 SmallVector<Type> resultsSto;
167 SmallVector<Value> argOperandsSto;
171 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
172 *mapOperandsHelper, unwrapDims(numDimsPerMap),
173 unwrapList(numArgOperands, argOperands, argOperandsSto)
179 CallOp, WithMapOperandsAndDims, intptr_t numResults, MlirType
const *results,
181 intptr_t numDimsPermMapLength, int32_t
const *numDimsPerMap, intptr_t numArgOperands,
182 MlirValue
const *argOperands
184 SmallVector<Type> resultsSto;
185 SmallVector<Value> argOperandsSto;
189 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
190 *mapOperandsHelper, ArrayRef(numDimsPerMap, numDimsPermMapLength),
191 unwrapList(numArgOperands, argOperands, argOperandsSto)
197 CallOp, ToCalleeWithMapOperands, MlirOperation callee, intptr_t numMapOperands,
198 MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap, intptr_t numArgOperands,
199 MlirValue
const *argOperands
201 SmallVector<Value> argOperandsSto;
205 builder, location, unwrapCallee(callee), *mapOperandsHelper, unwrapDims(numDimsPerMap),
206 unwrapList(numArgOperands, argOperands, argOperandsSto)
212 CallOp, ToCalleeWithMapOperandsAndDims, MlirOperation callee, intptr_t numMapOperands,
213 MlirValueRange const *mapOperands, intptr_t numDimsPermMapLength, int32_t
const *numDimsPerMap,
214 intptr_t numArgOperands, MlirValue
const *argOperands
216 SmallVector<Value> argOperandsSto;
220 builder, location, unwrapCallee(callee), *mapOperandsHelper,
221 ArrayRef(numDimsPerMap, numDimsPermMapLength),
222 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)
MlirValue llzkFuncDefOpGetSelfValueFromCompute(MlirOperation op)
Return the "self" value (i.e.
bool llzkFuncDefOpGetHasArgIsPub(MlirOperation op, unsigned argNo)
bool llzkFuncDefOpGetIsStructCompute(MlirOperation op)
MlirValue llzkFuncDefOpGetSelfValueFromConstrain(MlirOperation op)
Return the "self" value (i.e.
bool llzkCallOpGetCalleeIsConstrain(MlirOperation op)
MlirValue llzkCallOpGetSelfValueFromCompute(MlirOperation op)
Return the "self" value (i.e.
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)
MlirValue llzkCallOpGetSelfValueFromConstrain(MlirOperation op)
Return the "self" value (i.e.
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)