LLZK 0.1.0
Veridise's ZK Language IR
|
#include "llzk/Util/TypeHelper.h"
#include "llzk-c/Typing.h"
#include <mlir/CAPI/IR.h>
#include <mlir/CAPI/Support.h>
#include <mlir/CAPI/Wrap.h>
Go to the source code of this file.
Functions | |
void | llzkAssertValidAttrForParamOfType (MlirAttribute attr) |
This function asserts that the given Attribute kind is legal within the LLZK types that can contain Attribute parameters (i.e., ArrayType, StructType, and TypeVarType). | |
bool | llzkIsValidType (MlirType type) |
valid types: {I1, Index, String, FeltType, StructType, ArrayType, TypeVarType} | |
bool | llzkIsValidColumnType (MlirType type, MlirOperation op) |
valid types: {FeltType, StructType (with columns), ArrayType (that contains a valid column type)} | |
bool | llzkIsValidGlobalType (MlirType type) |
valid types: isValidType() - {TypeVarType} - {types with variable parameters} | |
bool | llzkIsValidEmitEqType (MlirType type) |
valid types: isValidType() - {String, StructType} (excluded via any type parameter nesting) | |
bool | llzkIsValidConstReadType (MlirType type) |
valid types: {I1, Index, FeltType, TypeVarType} | |
bool | llzkIsValidArrayElemType (MlirType type) |
valid types: isValidType() - {ArrayType} | |
bool | llzkIsValidArrayType (MlirType type) |
Checks if the type is a LLZK Array and it also contains a valid LLZK type. | |
bool | llzkIsConcreteType (MlirType type, bool allowStructParams) |
Return false iff the type contains any TypeVarType | |
bool | llzkIsSignalType (MlirType type) |
Return true iff the given type is a StructType referencing the COMPONENT_NAME_SIGNAL struct. | |
bool | llzkHasAffineMapAttr (MlirType type) |
Return true iff the given type contains an AffineMapAttr. | |
bool | llzkTypeParamsUnify (intptr_t numLhsParams, MlirAttribute const *lhsParams, intptr_t numRhsParams, MlirAttribute const *rhsParams) |
Return true iff the two ArrayRef instances containing StructType or ArrayType parameters are equivalent or could be equivalent after full instantiation of struct parameters. | |
bool | llzkArrayAttrTypeParamsUnify (MlirAttribute lhsParams, MlirAttribute rhsParams) |
Return true iff the two ArrayAttr instances containing StructType or ArrayType parameters are equivalent or could be equivalent after full instantiation of struct parameters. | |
bool | llzkTypesUnify (MlirType lhs, MlirType rhs, intptr_t nRhsReversePrefix, MlirStringRef const *rhsReversePrefix) |
Return true iff the two Type instances are equivalent or could be equivalent after full instantiation of struct parameters (if applicable within the given types). | |
bool | llzkIsMoreConcreteUnification (MlirType oldTy, MlirType newTy, bool(*knownOldToNew)(MlirType, MlirType, void *), void *userData) |
Return true iff the types unify and newTy is "more concrete" than oldTy . | |
MlirAttribute | llzkForceIntAttrType (MlirAttribute attr) |
Convert any IntegerAttr with a type other than IndexType to use IndexType. | |
bool llzkArrayAttrTypeParamsUnify | ( | MlirAttribute | lhsParams, |
MlirAttribute | rhsParams ) |
Return true
iff the two ArrayAttr instances containing StructType or ArrayType parameters are equivalent or could be equivalent after full instantiation of struct parameters.
Definition at line 60 of file Typing.cpp.
void llzkAssertValidAttrForParamOfType | ( | MlirAttribute | attr | ) |
This function asserts that the given Attribute kind is legal within the LLZK types that can contain Attribute parameters (i.e., ArrayType, StructType, and TypeVarType).
This should be used in any function that examines the attribute parameters within parameterized LLZK types to ensure that the function handles all possible cases properly, especially if more legal attributes are added in the future. Throw a fatal error if anything illegal is found, indicating that the caller of this function should be updated.
Definition at line 21 of file Typing.cpp.
MlirAttribute llzkForceIntAttrType | ( | MlirAttribute | attr | ) |
Convert any IntegerAttr with a type other than IndexType to use IndexType.
Definition at line 87 of file Typing.cpp.
bool llzkHasAffineMapAttr | ( | MlirType | type | ) |
Return true
iff the given type contains an AffineMapAttr.
Definition at line 48 of file Typing.cpp.
bool llzkIsConcreteType | ( | MlirType | type, |
bool | allowStructParams ) |
Return false
iff the type contains any TypeVarType
Definition at line 42 of file Typing.cpp.
bool llzkIsMoreConcreteUnification | ( | MlirType | oldTy, |
MlirType | newTy, | ||
bool(* | knownOldToNew )(MlirType, MlirType, void *), | ||
void * | data ) |
Return true
iff the types unify and newTy
is "more concrete" than oldTy
.
The types i1
, index
, felt.type
, and string.type
are concrete whereas poly.tvar
is not (because it may be substituted with any type during struct instantiation). When considering the attributes with array.type
and struct.type
types, we define IntegerAttr and TypeAttr as concrete, AffineMapAttr as less concrete than those, and SymbolRefAttr as least concrete.
Definition at line 75 of file Typing.cpp.
bool llzkIsSignalType | ( | MlirType | type | ) |
Return true
iff the given type is a StructType referencing the COMPONENT_NAME_SIGNAL
struct.
Definition at line 46 of file Typing.cpp.
bool llzkIsValidArrayElemType | ( | MlirType | type | ) |
valid types: isValidType() - {ArrayType}
Definition at line 38 of file Typing.cpp.
bool llzkIsValidArrayType | ( | MlirType | type | ) |
Checks if the type is a LLZK Array and it also contains a valid LLZK type.
Definition at line 40 of file Typing.cpp.
bool llzkIsValidColumnType | ( | MlirType | type, |
MlirOperation | op ) |
valid types: {FeltType, StructType (with columns), ArrayType (that contains a valid column type)}
Definition at line 27 of file Typing.cpp.
bool llzkIsValidConstReadType | ( | MlirType | type | ) |
valid types: {I1, Index, FeltType, TypeVarType}
Definition at line 36 of file Typing.cpp.
bool llzkIsValidEmitEqType | ( | MlirType | type | ) |
valid types: isValidType() - {String, StructType} (excluded via any type parameter nesting)
Definition at line 34 of file Typing.cpp.
bool llzkIsValidGlobalType | ( | MlirType | type | ) |
valid types: isValidType() - {TypeVarType} - {types with variable parameters}
Definition at line 32 of file Typing.cpp.
bool llzkIsValidType | ( | MlirType | type | ) |
valid types: {I1, Index, String, FeltType, StructType, ArrayType, TypeVarType}
Definition at line 25 of file Typing.cpp.
bool llzkTypeParamsUnify | ( | intptr_t | numLhsParams, |
MlirAttribute const * | lhsParams, | ||
intptr_t | numRhsParams, | ||
MlirAttribute const * | rhsParams ) |
Return true
iff the two ArrayRef instances containing StructType or ArrayType parameters are equivalent or could be equivalent after full instantiation of struct parameters.
Definition at line 50 of file Typing.cpp.
bool llzkTypesUnify | ( | MlirType | lhs, |
MlirType | rhs, | ||
intptr_t | nRhsReversePrefix, | ||
MlirStringRef const * | rhsReversePrefix ) |
Return true
iff the two Type instances are equivalent or could be equivalent after full instantiation of struct parameters (if applicable within the given types).
Definition at line 66 of file Typing.cpp.