LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
ArrayTypeHelper.h
Go to the documentation of this file.
1
//===-- ArrayTypeHelper.h ---------------------------------------*- 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
#pragma once
11
12
#include "
llzk/Dialect/Array/IR/Types.h
"
13
#include "
llzk/Dialect/LLZK/IR/AttributeHelper.h
"
14
15
#include <mlir/IR/Attributes.h>
16
#include <mlir/IR/Builders.h>
17
#include <mlir/IR/BuiltinTypes.h>
18
#include <mlir/IR/Location.h>
19
#include <mlir/IR/MLIRContext.h>
20
21
#include <llvm/ADT/ArrayRef.h>
22
#include <llvm/ADT/SmallVector.h>
23
24
#include <optional>
25
26
namespace
llzk::array
{
27
30
class
ArrayIndexGen {
31
llvm::ArrayRef<int64_t> shape;
// owned by the ArrayType from constructor
32
int64_t linearSize;
33
llvm::SmallVector<int64_t> strides;
34
35
ArrayIndexGen(
ArrayType
);
36
37
public
:
38
~ArrayIndexGen
() =
default
;
39
ArrayIndexGen
(ArrayIndexGen &&) noexcept = default;
40
ArrayIndexGen &operator=(ArrayIndexGen &&) noexcept = default;
41
ArrayIndexGen(const ArrayIndexGen &) = delete;
42
ArrayIndexGen &operator=(const ArrayIndexGen &) = delete;
43
45
static ArrayIndexGen
from
(
ArrayType
);
46
47
std::optional<
llvm
::SmallVector<
mlir
::Value>>
48
delinearize
(int64_t,
mlir
::Location,
mlir
::OpBuilder &) const;
49
50
std::optional<
llvm
::SmallVector<
mlir
::Attribute>>
delinearize
(int64_t,
mlir
::MLIRContext *) const;
51
52
template <typename InListType> std::optional<int64_t>
linearize
(InListType multiDimIndex) const;
53
54
// NOTE: If the 'multiDimIndex' is shorter than the array rank (i.e., number of dimensions), they
55
// indices are treated as the high-order/front dimensions of the array.
56
template <typename InListType>
57
std::optional<
llvm
::SmallVector<
mlir
::Attribute>>
checkAndConvert
(InListType multiDimIndex);
58
};
59
60
}
// namespace llzk::array
Types.h
AttributeHelper.h
llzk::array::ArrayIndexGen::checkAndConvert
std::optional< llvm::SmallVector< mlir::Attribute > > checkAndConvert(InListType multiDimIndex)
llzk::array::ArrayIndexGen::~ArrayIndexGen
~ArrayIndexGen()=default
llzk::array::ArrayIndexGen::ArrayIndexGen
ArrayIndexGen(ArrayIndexGen &&) noexcept=default
llzk::array::ArrayIndexGen::from
static ArrayIndexGen from(ArrayType)
Construct new ArrayIndexGen. Will assert if hasStaticShape() is false.
Definition
ArrayTypeHelper.cpp:34
llzk::array::ArrayIndexGen::linearize
std::optional< int64_t > linearize(InListType multiDimIndex) const
Definition
ArrayTypeHelper.cpp:160
llzk::array::ArrayIndexGen::delinearize
std::optional< llvm::SmallVector< mlir::Value > > delinearize(int64_t, mlir::Location, mlir::OpBuilder &) const
llzk::array::ArrayType
Definition
Types.h.inc:23
llvm
Definition
SourceRefLattice.cpp:411
llzk::array
Definition
Ops.cpp:43
mlir
Definition
ValueModel.h:30
include
llzk
Dialect
Array
Util
ArrayTypeHelper.h
Generated by
1.17.0
Copyright 2025 Veridise Inc. under the Apache License v2.0. Copyright 2026 Project LLZK under the Apache License v2.0.