LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Typing.h
Go to the documentation of this file.
1//===-- Typing.h - C API for llzk types ---------------------------*- C -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9//
10// This header declares functions that check for properties of types
11// in different llzk constructs.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLZK_C_TYPING_H
16#define LLZK_C_TYPING_H
17
18#include <mlir-c/IR.h>
19#include <mlir-c/Support.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
31MLIR_CAPI_EXPORTED void llzkAssertValidAttrForParamOfType(MlirAttribute attr);
32
34MLIR_CAPI_EXPORTED bool llzkIsValidType(MlirType type);
35
38MLIR_CAPI_EXPORTED bool llzkIsValidColumnType(MlirType type, MlirOperation op);
39
41MLIR_CAPI_EXPORTED bool llzkIsValidGlobalType(MlirType type);
42
44MLIR_CAPI_EXPORTED bool llzkIsValidEmitEqType(MlirType type);
45
47MLIR_CAPI_EXPORTED bool llzkIsValidConstReadType(MlirType type);
48
50MLIR_CAPI_EXPORTED bool llzkIsValidArrayElemType(MlirType type);
51
53MLIR_CAPI_EXPORTED bool llzkIsValidArrayType(MlirType type);
54
56MLIR_CAPI_EXPORTED bool llzkIsConcreteType(MlirType type, bool allowStructParams);
57
60MLIR_CAPI_EXPORTED bool llzkIsSignalType(MlirType type);
61
63MLIR_CAPI_EXPORTED bool llzkHasAffineMapAttr(MlirType type);
64
67MLIR_CAPI_EXPORTED bool llzkTypeParamsUnify(
68 intptr_t, MlirAttribute const *lhsParams, intptr_t, MlirAttribute const *rhsParams
69);
70
73MLIR_CAPI_EXPORTED bool
74llzkArrayAttrTypeParamsUnify(MlirAttribute lhsParams, MlirAttribute rhsParams);
75
78MLIR_CAPI_EXPORTED bool llzkTypesUnify(
79 MlirType lhs, MlirType rhs, intptr_t nRhsReversePrefix, MlirStringRef const *rhsReversePrefix
80);
81
88MLIR_CAPI_EXPORTED bool llzkIsMoreConcreteUnification(
89 MlirType oldTy, MlirType newTy, bool (*knownOldToNew)(MlirType, MlirType, void *), void *data
90);
91
93MLIR_CAPI_EXPORTED MlirAttribute llzkForceIntAttrType(MlirAttribute attr);
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif
MLIR_CAPI_EXPORTED bool llzkIsValidType(MlirType type)
valid types: {I1, Index, String, FeltType, StructType, ArrayType, TypeVarType}
Definition Typing.cpp:25
MLIR_CAPI_EXPORTED bool llzkIsValidArrayType(MlirType type)
Checks if the type is a LLZK Array and it also contains a valid LLZK type.
Definition Typing.cpp:40
MLIR_CAPI_EXPORTED 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...
Definition Typing.cpp:66
MLIR_CAPI_EXPORTED MlirAttribute llzkForceIntAttrType(MlirAttribute attr)
Convert any IntegerAttr with a type other than IndexType to use IndexType.
Definition Typing.cpp:87
MLIR_CAPI_EXPORTED 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.
Definition Typing.cpp:75
MLIR_CAPI_EXPORTED bool llzkIsValidConstReadType(MlirType type)
valid types: {I1, Index, FeltType, TypeVarType}
Definition Typing.cpp:36
MLIR_CAPI_EXPORTED bool llzkHasAffineMapAttr(MlirType type)
Return true iff the given type contains an AffineMapAttr.
Definition Typing.cpp:48
MLIR_CAPI_EXPORTED bool llzkIsValidArrayElemType(MlirType type)
valid types: isValidType() - {ArrayType}
Definition Typing.cpp:38
MLIR_CAPI_EXPORTED bool llzkTypeParamsUnify(intptr_t, MlirAttribute const *lhsParams, intptr_t, MlirAttribute const *rhsParams)
Return true iff the two ArrayRef instances containing StructType or ArrayType parameters are equivale...
Definition Typing.cpp:50
MLIR_CAPI_EXPORTED bool llzkIsValidEmitEqType(MlirType type)
valid types: isValidType() - {String, StructType} (excluded via any type parameter nesting)
Definition Typing.cpp:34
MLIR_CAPI_EXPORTED bool llzkIsValidGlobalType(MlirType type)
valid types: isValidType() - {TypeVarType} - {types with variable parameters}
Definition Typing.cpp:32
MLIR_CAPI_EXPORTED bool llzkArrayAttrTypeParamsUnify(MlirAttribute lhsParams, MlirAttribute rhsParams)
Return true iff the two ArrayAttr instances containing StructType or ArrayType parameters are equival...
Definition Typing.cpp:60
MLIR_CAPI_EXPORTED void llzkAssertValidAttrForParamOfType(MlirAttribute attr)
This function asserts that the given Attribute kind is legal within the LLZK types that can contain A...
Definition Typing.cpp:21
MLIR_CAPI_EXPORTED bool llzkIsSignalType(MlirType type)
Return true iff the given type is a StructType referencing the COMPONENT_NAME_SIGNAL struct.
Definition Typing.cpp:46
MLIR_CAPI_EXPORTED bool llzkIsConcreteType(MlirType type, bool allowStructParams)
Return false iff the type contains any TypeVarType
Definition Typing.cpp:42
MLIR_CAPI_EXPORTED bool llzkIsValidColumnType(MlirType type, MlirOperation op)
valid types: {FeltType, StructType (with columns), ArrayType (that contains a valid column type)}
Definition Typing.cpp:27