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
128static auto unwrapCallee(MlirOperation op) {
return mlir::cast<FuncDefOp>(unwrap(op)); }
130static auto unwrapDims(MlirAttribute attr) {
return mlir::cast<DenseI32ArrayAttr>(unwrap(attr)); }
132static auto unwrapName(MlirAttribute attr) {
return mlir::cast<SymbolRefAttr>(unwrap(attr)); }
135 CallOp, intptr_t numResults, MlirType
const *results, MlirAttribute
name, intptr_t numOperands,
136 MlirValue
const *operands
138 SmallVector<Type> resultsSto;
139 SmallVector<Value> operandsSto;
141 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
142 unwrapList(numOperands, operands, operandsSto)
147 CallOp, ToCallee, MlirOperation callee, intptr_t numOperands, MlirValue
const *operands
149 SmallVector<Value> operandsSto;
151 builder, location, unwrapCallee(callee), unwrapList(numOperands, operands, operandsSto)
156 CallOp, WithMapOperands, intptr_t numResults, MlirType
const *results, MlirAttribute
name,
157 intptr_t numMapOperands,
MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap,
158 intptr_t numArgOperands, MlirValue
const *argOperands
160 SmallVector<Type> resultsSto;
161 SmallVector<Value> argOperandsSto;
164 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
165 *mapOperandsHelper, unwrapDims(numDimsPerMap),
166 unwrapList(numArgOperands, argOperands, argOperandsSto)
171 CallOp, WithMapOperandsAndDims, intptr_t numResults, MlirType
const *results,
173 intptr_t numDimsPermMapLength, int32_t
const *numDimsPerMap, intptr_t numArgOperands,
174 MlirValue
const *argOperands
176 SmallVector<Type> resultsSto;
177 SmallVector<Value> argOperandsSto;
180 builder, location, unwrapList(numResults, results, resultsSto), unwrapName(
name),
181 *mapOperandsHelper, ArrayRef(numDimsPerMap, numDimsPermMapLength),
182 unwrapList(numArgOperands, argOperands, argOperandsSto)
187 CallOp, ToCalleeWithMapOperands, MlirOperation callee, intptr_t numMapOperands,
188 MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap, intptr_t numArgOperands,
189 MlirValue
const *argOperands
191 SmallVector<Value> argOperandsSto;
194 builder, location, unwrapCallee(callee), *mapOperandsHelper, unwrapDims(numDimsPerMap),
195 unwrapList(numArgOperands, argOperands, argOperandsSto)
200 CallOp, ToCalleeWithMapOperandsAndDims, MlirOperation callee, intptr_t numMapOperands,
201 MlirValueRange const *mapOperands, intptr_t numDimsPermMapLength, int32_t
const *numDimsPerMap,
202 intptr_t numArgOperands, MlirValue
const *argOperands
204 SmallVector<Value> argOperandsSto;
207 builder, location, unwrapCallee(callee), *mapOperandsHelper,
208 ArrayRef(numDimsPerMap, numDimsPermMapLength),
209 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)