12 return llvm::isa<CallOp>(unwrap(inp));
16 intptr_t count = mlirOperationGetNumOperands(op);
17 assert(count >= 0 &&
"operand count less than start index");
22 return mlirOperationGetOperand(op, 0 + index);
26 intptr_t numOperands = mlirOperationGetNumOperands(op);
27 intptr_t startIdx = 0;
30 if (startIdx < 0 || startIdx > numOperands) {
33 if (count < 0 || count > (std::numeric_limits<intptr_t>::max() - startIdx)) {
37 intptr_t oldCount = numOperands - startIdx;
38 intptr_t newNumOperands = startIdx + count;
40 std::vector<MlirValue> newOperands(newNumOperands);
43 for (intptr_t i = 0; i < startIdx; ++i) {
44 newOperands[i] = mlirOperationGetOperand(op, i);
48 for (intptr_t i = 0; i < count; ++i) {
49 newOperands[startIdx + i] = values[i];
53 for (intptr_t i = startIdx + oldCount; i < numOperands; ++i) {
54 newOperands[i - oldCount + count] = mlirOperationGetOperand(op, i);
57 mlirOperationSetOperands(op, newNumOperands, newOperands.data());
61 intptr_t count = mlirOperationGetNumOperands(op);
62 assert(count >= 1 &&
"operand count less than start index");
67 return mlirOperationGetOperand(op, 1 + index);
71 intptr_t numOperands = mlirOperationGetNumOperands(op);
72 intptr_t startIdx = 1;
75 if (startIdx < 0 || startIdx > numOperands) {
78 if (count < 0 || count > (std::numeric_limits<intptr_t>::max() - startIdx)) {
82 intptr_t oldCount = numOperands - startIdx;
83 intptr_t newNumOperands = startIdx + count;
85 std::vector<MlirValue> newOperands(newNumOperands);
88 for (intptr_t i = 0; i < startIdx; ++i) {
89 newOperands[i] = mlirOperationGetOperand(op, i);
93 for (intptr_t i = 0; i < count; ++i) {
94 newOperands[startIdx + i] = values[i];
98 for (intptr_t i = startIdx + oldCount; i < numOperands; ++i) {
99 newOperands[i - oldCount + count] = mlirOperationGetOperand(op, i);
102 mlirOperationSetOperands(op, newNumOperands, newOperands.data());
106 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"callee"));
110 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"callee"), attr);
114 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"templateParams"));
118 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"templateParams"), attr);
122 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"numDimsPerMap"));
126 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"numDimsPerMap"), attr);
130 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"mapOpGroupSizes"));
134 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"mapOpGroupSizes"), attr);
138 intptr_t count = mlirOperationGetNumResults(op);
139 assert(count >= 0 &&
"result count less than start index");
144 return mlirOperationGetResult(op, 0 + index);
148 return llvm::cast<CallOp>(unwrap(inp)).calleeContainsWitnessGen();
152 return llvm::cast<CallOp>(unwrap(inp)).calleeIsStructCompute();
156 return wrap(llvm::cast<CallOp>(unwrap(inp)).getSingleResultTypeOfCompute());
160 return llvm::cast<CallOp>(unwrap(inp)).calleeIsStructConstrain();
164 return wrap(llvm::cast<CallOp>(unwrap(inp)).getSelfValueFromConstrain());
168 return wrap(llvm::cast<CallOp>(unwrap(inp)).getTypeSignature());
172 return llvm::cast<CallOp>(unwrap(inp)).calleeIsCompute();
176 return llvm::cast<CallOp>(unwrap(inp)).calleeIsConstrain();
180 return wrap(llvm::cast<CallOp>(unwrap(inp)).resolveCallable());
184 return wrap(llvm::cast<CallOp>(unwrap(inp)).getSelfValueFromCompute());
188 return wrap(llvm::cast<CallOp>(unwrap(inp)).getSingleResultTypeOfWitnessGen());
191MlirOperation
llzkFunction_FuncDefOpBuild(MlirOpBuilder builder, MlirLocation location, MlirIdentifier sym_name, MlirAttribute function_type, MlirAttribute arg_attrs, MlirAttribute res_attrs) {
192 MlirOperationState state = mlirOperationStateGet(mlirStringRefCreateFromCString(
"function.def"), location);
194 llvm::SmallVector<MlirNamedAttribute, 4> attributes;
195 if (!mlirAttributeIsNull(
reinterpret_cast<MlirAttribute&
>(sym_name))) {
196 attributes.push_back(mlirNamedAttributeGet(mlirIdentifierGet(ctx, mlirStringRefCreateFromCString(
"sym_name")),
reinterpret_cast<MlirAttribute&
>(sym_name)));
198 if (!mlirAttributeIsNull(function_type)) {
199 attributes.push_back(mlirNamedAttributeGet(mlirIdentifierGet(ctx, mlirStringRefCreateFromCString(
"function_type")), function_type));
201 if (!mlirAttributeIsNull(arg_attrs)) {
202 attributes.push_back(mlirNamedAttributeGet(mlirIdentifierGet(ctx, mlirStringRefCreateFromCString(
"arg_attrs")), arg_attrs));
204 if (!mlirAttributeIsNull(res_attrs)) {
205 attributes.push_back(mlirNamedAttributeGet(mlirIdentifierGet(ctx, mlirStringRefCreateFromCString(
"res_attrs")), res_attrs));
207 mlirOperationStateAddAttributes(&state, attributes.size(), attributes.data());
208 llvm::SmallVector<MlirRegion, 1> regions;
209 regions.push_back(mlirRegionCreate());
210 mlirOperationStateAddOwnedRegions(&state, regions.size(), regions.data());
216 return llvm::isa<FuncDefOp>(unwrap(inp));
220 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"sym_name"));
224 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"sym_name"), attr);
228 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"function_type"));
232 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"function_type"), attr);
236 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"arg_attrs"));
240 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"arg_attrs"), attr);
244 return mlirOperationGetAttributeByName(op, mlirStringRefCreateFromCString(
"res_attrs"));
248 mlirOperationSetAttributeByName(op, mlirStringRefCreateFromCString(
"res_attrs"), attr);
252 return mlirOperationGetRegion(op, 0);
256 return wrap(llvm::cast<FuncDefOp>(unwrap(inp)).getFullyQualifiedName(requireParent));
260 llvm::cast<FuncDefOp>(unwrap(inp)).setAllowNonNativeFieldOpsAttr(newValue);
264 return llvm::cast<FuncDefOp>(unwrap(inp)).isDeclaration();
268 return llvm::cast<FuncDefOp>(unwrap(inp)).hasAllowNonNativeFieldOpsAttr();
272 return llvm::cast<FuncDefOp>(unwrap(inp)).nameIsProduct();
276 return llvm::cast<FuncDefOp>(unwrap(inp)).hasArgPublicAttr(index);
280 return llvm::cast<FuncDefOp>(unwrap(inp)).isStructProduct();
284 return wrap(llvm::cast<FuncDefOp>(unwrap(inp)).getSelfValueFromConstrain());
288 return wrap(llvm::cast<FuncDefOp>(unwrap(inp)).getSingleResultTypeOfCompute());
292 return llvm::cast<FuncDefOp>(unwrap(inp)).hasAllowWitnessAttr();
296 return llvm::cast<FuncDefOp>(unwrap(inp)).nameIsConstrain();
300 return wrap(llvm::cast<FuncDefOp>(unwrap(inp)).getCallableRegion());
304 llvm::cast<FuncDefOp>(unwrap(inp)).setAllowConstraintAttr(newValue);
308 return wrap(llvm::cast<FuncDefOp>(unwrap(inp)).getSelfValueFromCompute());
312 return llvm::cast<FuncDefOp>(unwrap(inp)).hasAllowConstraintAttr();
316 return llvm::cast<FuncDefOp>(unwrap(inp)).isInStruct();
320 llvm::cast<FuncDefOp>(unwrap(inp)).setAllowWitnessAttr(newValue);
324 return llvm::cast<FuncDefOp>(unwrap(inp)).nameIsCompute();
328 return llvm::cast<FuncDefOp>(unwrap(inp)).isStructConstrain();
332 return llvm::cast<FuncDefOp>(unwrap(inp)).isStructCompute();
336 MlirOperationState state = mlirOperationStateGet(mlirStringRefCreateFromCString(
"function.return"), location);
337 mlirOperationStateAddOperands(&state, operandsSize, operands);
343 return llvm::isa<ReturnOp>(unwrap(inp));
347 intptr_t count = mlirOperationGetNumOperands(op);
348 assert(count >= 0 &&
"operand count less than start index");
353 return mlirOperationGetOperand(op, 0 + index);
357 intptr_t numOperands = mlirOperationGetNumOperands(op);
358 intptr_t startIdx = 0;
361 if (startIdx < 0 || startIdx > numOperands) {
364 if (count < 0 || count > (std::numeric_limits<intptr_t>::max() - startIdx)) {
368 intptr_t oldCount = numOperands - startIdx;
369 intptr_t newNumOperands = startIdx + count;
371 std::vector<MlirValue> newOperands(newNumOperands);
374 for (intptr_t i = 0; i < startIdx; ++i) {
375 newOperands[i] = mlirOperationGetOperand(op, i);
379 for (intptr_t i = 0; i < count; ++i) {
380 newOperands[startIdx + i] = values[i];
384 for (intptr_t i = startIdx + oldCount; i < numOperands; ++i) {
385 newOperands[i - oldCount + count] = mlirOperationGetOperand(op, i);
388 mlirOperationSetOperands(op, newNumOperands, newOperands.data());
MlirContext mlirOpBuilderGetContext(MlirOpBuilder builder)
Returns the MLIR context associated with builder.
MlirOperation mlirOpBuilderInsert(MlirOpBuilder builder, MlirOperation op)
Inserts op at the current insertion point of builder and returns it.
bool llzkFunction_FuncDefOpNameIsProduct(MlirOperation inp)
Return true iff the function name is FUNC_NAME_PRODUCT (if needed, a check that this FuncDefOp is loc...
MlirRegion llzkFunction_FuncDefOpGetCallableRegion(MlirOperation inp)
Required by FunctionOpInterface.
void llzkFunction_FuncDefOpSetResAttrs(MlirOperation op, MlirAttribute attr)
Set ResAttrs attribute of llzk::function::FuncDefOp Operation.
MlirOperation llzkFunction_FuncDefOpBuild(MlirOpBuilder builder, MlirLocation location, MlirIdentifier sym_name, MlirAttribute function_type, MlirAttribute arg_attrs, MlirAttribute res_attrs)
Build a llzk::function::FuncDefOp Operation.
void llzkFunction_CallOpSetMapOperands(MlirOperation op, intptr_t count, MlirValue const *values)
Set MapOperands operands of llzk::function::CallOp Operation.
MlirValue llzkFunction_ReturnOpGetOperandsAt(MlirOperation op, intptr_t index)
Get Operands operand at index from llzk::function::ReturnOp Operation.
bool llzkFunction_FuncDefOpIsStructProduct(MlirOperation inp)
Return true iff the function is within a StructDefOp and named FUNC_NAME_PRODUCT.
intptr_t llzkFunction_CallOpGetResult0Count(MlirOperation op)
Get number of Result0 results in llzk::function::CallOp Operation.
MlirAttribute llzkFunction_FuncDefOpGetFullyQualifiedName(MlirOperation inp, bool requireParent)
Return the full name for this function from the root module, including all surrounding symbol table n...
bool llzkFunction_CallOpCalleeIsStructConstrain(MlirOperation inp)
Return true iff the callee function name is FUNC_NAME_CONSTRAIN within a StructDefOp.
void llzkFunction_FuncDefOpSetFunctionType(MlirOperation op, MlirAttribute attr)
Set FunctionType attribute of llzk::function::FuncDefOp Operation.
MlirAttribute llzkFunction_CallOpGetMapOpGroupSizes(MlirOperation op)
Get MapOpGroupSizes attribute from llzk::function::CallOp Operation.
bool llzkFunction_CallOpCalleeIsCompute(MlirOperation inp)
Return true iff the callee function name is FUNC_NAME_COMPUTE (this does not check if the callee func...
MlirAttribute llzkFunction_CallOpGetTemplateParams(MlirOperation op)
Get TemplateParams attribute from llzk::function::CallOp Operation.
intptr_t llzkFunction_CallOpGetMapOperandsCount(MlirOperation op)
Get number of MapOperands operands in llzk::function::CallOp Operation.
intptr_t llzkFunction_CallOpGetArgOperandsCount(MlirOperation op)
Get number of ArgOperands operands in llzk::function::CallOp Operation.
void llzkFunction_ReturnOpSetOperands(MlirOperation op, intptr_t count, MlirValue const *values)
Set Operands operands of llzk::function::ReturnOp Operation.
bool llzkFunction_FuncDefOpHasAllowWitnessAttr(MlirOperation inp)
Return true iff the function def has the allow_witness attribute.
MlirValue llzkFunction_FuncDefOpGetSelfValueFromConstrain(MlirOperation inp)
Return the "self" value (i.e.
MlirAttribute llzkFunction_FuncDefOpGetResAttrs(MlirOperation op)
Get ResAttrs attribute from llzk::function::FuncDefOp Operation.
MlirType llzkFunction_CallOpGetSingleResultTypeOfCompute(MlirOperation inp)
Assuming the callee is FUNC_NAME_COMPUTE, return the single StructType result.
MlirOperation llzkFunction_ReturnOpBuild(MlirOpBuilder builder, MlirLocation location, intptr_t operandsSize, MlirValue const *operands)
Build a llzk::function::ReturnOp Operation.
bool llzkFunction_FuncDefOpIsDeclaration(MlirOperation inp)
Required by SymbolOpInterface.
void llzkFunction_CallOpSetCallee(MlirOperation op, MlirAttribute attr)
Set Callee attribute of llzk::function::CallOp Operation.
bool llzkFunction_CallOpCalleeContainsWitnessGen(MlirOperation inp)
Return true iff the callee function can contain witness generation code (this does not check if the c...
bool llzkFunction_FuncDefOpHasAllowConstraintAttr(MlirOperation inp)
Return true iff the function def has the allow_constraint attribute.
bool llzkFunction_FuncDefOpIsInStruct(MlirOperation inp)
Return true iff the function is within a StructDefOp.
void llzkFunction_FuncDefOpSetArgAttrs(MlirOperation op, MlirAttribute attr)
Set ArgAttrs attribute of llzk::function::FuncDefOp Operation.
void llzkFunction_FuncDefOpSetAllowConstraintAttr(MlirOperation inp, bool newValue)
Add (resp. remove) the allow_constraint attribute to (resp. from) the function def.
void llzkFunction_CallOpSetArgOperands(MlirOperation op, intptr_t count, MlirValue const *values)
Set ArgOperands operands of llzk::function::CallOp Operation.
MlirValue llzkFunction_CallOpGetSelfValueFromConstrain(MlirOperation inp)
Return the "self" value (i.e.
bool llzkFunction_FuncDefOpHasArgPublicAttr(MlirOperation inp, unsigned index)
Return true iff the argument at the given index has pub attribute.
void llzkFunction_FuncDefOpSetAllowNonNativeFieldOpsAttr(MlirOperation inp, bool newValue)
Add (resp. remove) the allow_non_native_field_ops attribute to (resp. from) the function def.
bool llzkFunction_FuncDefOpIsStructConstrain(MlirOperation inp)
Return true iff the function is within a StructDefOp and named FUNC_NAME_CONSTRAIN.
MlirValue llzkFunction_CallOpGetArgOperandsAt(MlirOperation op, intptr_t index)
Get ArgOperands operand at index from llzk::function::CallOp Operation.
MlirType llzkFunction_FuncDefOpGetSingleResultTypeOfCompute(MlirOperation inp)
Assuming the name is FUNC_NAME_COMPUTE, return the single StructType result.
void llzkFunction_CallOpSetTemplateParams(MlirOperation op, MlirAttribute attr)
Set TemplateParams attribute of llzk::function::CallOp Operation.
void llzkFunction_CallOpSetNumDimsPerMap(MlirOperation op, MlirAttribute attr)
Set NumDimsPerMap attribute of llzk::function::CallOp Operation.
bool llzkOperationIsA_Function_ReturnOp(MlirOperation inp)
Returns true if the Operation is a llzk::function::ReturnOp.
bool llzkOperationIsA_Function_CallOp(MlirOperation inp)
Returns true if the Operation is a llzk::function::CallOp.
MlirAttribute llzkFunction_CallOpGetCallee(MlirOperation op)
Get Callee attribute from llzk::function::CallOp Operation.
MlirType llzkFunction_CallOpGetSingleResultTypeOfWitnessGen(MlirOperation inp)
Assuming the callee contains witness generation code, return the single StructType result.
MlirAttribute llzkFunction_FuncDefOpGetArgAttrs(MlirOperation op)
Get ArgAttrs attribute from llzk::function::FuncDefOp Operation.
bool llzkFunction_FuncDefOpNameIsConstrain(MlirOperation inp)
Return true iff the function name is FUNC_NAME_CONSTRAIN (if needed, a check that this FuncDefOp is l...
MlirValue llzkFunction_FuncDefOpGetSelfValueFromCompute(MlirOperation inp)
Return the "self" value (i.e.
bool llzkFunction_FuncDefOpIsStructCompute(MlirOperation inp)
Return true iff the function is within a StructDefOp and named FUNC_NAME_COMPUTE.
void llzkFunction_FuncDefOpSetAllowWitnessAttr(MlirOperation inp, bool newValue)
Add (resp. remove) the allow_witness attribute to (resp. from) the function def.
intptr_t llzkFunction_ReturnOpGetOperandsCount(MlirOperation op)
Get number of Operands operands in llzk::function::ReturnOp Operation.
MlirValue llzkFunction_CallOpGetMapOperandsAt(MlirOperation op, intptr_t index)
Get MapOperands operand at index from llzk::function::CallOp Operation.
bool llzkFunction_FuncDefOpHasAllowNonNativeFieldOpsAttr(MlirOperation inp)
Return true iff the function def has the allow_non_native_field_ops attribute.
void llzkFunction_FuncDefOpSetSymName(MlirOperation op, MlirAttribute attr)
Set SymName attribute of llzk::function::FuncDefOp Operation.
MlirRegion llzkFunction_FuncDefOpGetBody(MlirOperation op)
Get Body region from llzk::function::FuncDefOp Operation.
MlirType llzkFunction_CallOpGetTypeSignature(MlirOperation inp)
Return the FunctionType inferred from the arg operands and result types of this CallOp.
MlirValue llzkFunction_CallOpGetSelfValueFromCompute(MlirOperation inp)
Return the "self" value (i.e.
bool llzkFunction_CallOpCalleeIsStructCompute(MlirOperation inp)
Return true iff the callee function name is FUNC_NAME_COMPUTE within a StructDefOp.
MlirAttribute llzkFunction_FuncDefOpGetFunctionType(MlirOperation op)
Get FunctionType attribute from llzk::function::FuncDefOp Operation.
MlirValue llzkFunction_CallOpGetResult0At(MlirOperation op, intptr_t index)
Get Result0 result at index from llzk::function::CallOp Operation.
MlirOperation llzkFunction_CallOpResolveCallable(MlirOperation inp)
Required by CallOpInterface.
bool llzkFunction_FuncDefOpNameIsCompute(MlirOperation inp)
Return true iff the function name is FUNC_NAME_COMPUTE (if needed, a check that this FuncDefOp is loc...
bool llzkOperationIsA_Function_FuncDefOp(MlirOperation inp)
Returns true if the Operation is a llzk::function::FuncDefOp.
void llzkFunction_CallOpSetMapOpGroupSizes(MlirOperation op, MlirAttribute attr)
Set MapOpGroupSizes attribute of llzk::function::CallOp Operation.
MlirAttribute llzkFunction_CallOpGetNumDimsPerMap(MlirOperation op)
Get NumDimsPerMap attribute from llzk::function::CallOp Operation.
MlirAttribute llzkFunction_FuncDefOpGetSymName(MlirOperation op)
Get SymName attribute from llzk::function::FuncDefOp Operation.
bool llzkFunction_CallOpCalleeIsConstrain(MlirOperation inp)
Return true iff the callee function name is FUNC_NAME_CONSTRAIN (this does not check if the callee fu...