1//===-- Ops.td ---------------------------------------------*- tablegen -*-===//
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
8//===----------------------------------------------------------------------===//
13include "mlir/Interfaces/SideEffectInterfaces.td"
15include "llzk/Dialect/Felt/IR/Types.td"
16include "llzk/Dialect/RAM/IR/Dialect.td"
17include "llzk/Dialect/Function/IR/OpTraits.td"
19class RAMDialectOp<string mnemonic, list<Trait> traits = []>
20 : Op<RAMDialect, mnemonic, traits>;
22def LLZK_LoadOp : RAMDialectOp<"load", [WitnessGen, MemoryEffects<[MemRead]>]> {
23 let summary = "read a value from memory";
25 Reads the felt stored at cell `%addr` of the flat, cell-addressed RAM.
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.
34 %val = ram.load %addr : !felt.type
38 let arguments = (ins Index:$addr);
39 let results = (outs LLZK_FeltType:$val);
41 let assemblyFormat = [{
42 $addr `:` type($val) attr-dict
47 : RAMDialectOp<"store", [WitnessGen, MemoryEffects<[MemWrite]>]> {
48 let summary = "write a value to memory";
50 Writes felt `%val` to cell `%addr` of the flat, cell-addressed RAM.
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.
59 ram.store %addr, %val : !felt.type
63 let arguments = (ins Index:$addr, LLZK_FeltType:$val);
65 let assemblyFormat = [{
66 $addr `,` $val `:` type($val) attr-dict