LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Ops.td
Go to the documentation of this file.
1//===-- Ops.td ---------------------------------------------*- tablegen -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2026 Project LLZK
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLZK_RAM_OPS
11#define LLZK_RAM_OPS
12
13include "mlir/Interfaces/SideEffectInterfaces.td"
14
15include "llzk/Dialect/Felt/IR/Types.td"
16include "llzk/Dialect/RAM/IR/Dialect.td"
17include "llzk/Dialect/Function/IR/OpTraits.td"
18
19class RAMDialectOp<string mnemonic, list<Trait> traits = []>
20 : Op<RAMDialect, mnemonic, traits>;
21
22def LLZK_LoadOp : RAMDialectOp<"load", [WitnessGen, MemoryEffects<[MemRead]>]> {
23 let summary = "read a value from memory";
24 let description = [{
25 Reads the felt stored at cell `%addr` of the flat, cell-addressed RAM.
26
27 `%addr` is a slot index. Each cell holds exactly one
28 `!felt.type` value; producers storing other types (booleans, integers,
29 composites) must widen or lay them out across cells themselves.
30
31 Example:
32
33 ```llzk
34 %val = ram.load %addr : !felt.type
35 ```
36 }];
37
38 let arguments = (ins Index:$addr);
39 let results = (outs LLZK_FeltType:$val);
40
41 let assemblyFormat = [{
42 $addr `:` type($val) attr-dict
43 }];
44}
45
46def LLZK_StoreOp
47 : RAMDialectOp<"store", [WitnessGen, MemoryEffects<[MemWrite]>]> {
48 let summary = "write a value to memory";
49 let description = [{
50 Writes felt `%val` to cell `%addr` of the flat, cell-addressed RAM.
51
52 `%addr` is a slot index. Each cell holds exactly one
53 `!felt.type` value; producers storing other types (booleans, integers,
54 composites) must widen or lay them out across cells themselves.
55
56 Example:
57
58 ```llzk
59 ram.store %addr, %val : !felt.type
60 ```
61 }];
62
63 let arguments = (ins Index:$addr, LLZK_FeltType:$val);
64
65 let assemblyFormat = [{
66 $addr `,` $val `:` type($val) attr-dict
67 }];
68}
69
70#endif // LLZK_RAM_OPS