1//===- SMTArrayOps.td - SMT array operations ---------------*- tablegen -*-===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//===----------------------------------------------------------------------===//
9#ifndef MLIR_DIALECT_SMT_IR_SMTARRAYOPS_TD
10#define MLIR_DIALECT_SMT_IR_SMTARRAYOPS_TD
12include "llzk/Dialect/SMT/IR/SMTDialect.td"
13include "llzk/Dialect/SMT/IR/SMTAttributes.td"
14include "llzk/Dialect/SMT/IR/SMTTypes.td"
15include "mlir/Interfaces/SideEffectInterfaces.td"
17class SMTArrayOp<string mnemonic, list<Trait> traits = []>
18 : SMTOp<"array."#mnemonic, traits>;
23 TypesMatchWith<"summary", "array", "index",
24 "cast<ArrayType>($_self).getDomainType()">,
25 TypesMatchWith<"summary", "array", "value",
26 "cast<ArrayType>($_self).getRangeType()">,
27 AllTypesMatch<["array", "result"]>,
29 let summary = "stores a value at a given index and returns the new array";
31 This operation returns a new array which is the same as the 'array' operand
32 except that the value at the given 'index' is changed to the given 'value'.
33 The semantics are equivalent to the 'store' operator described in the
34 [SMT ArrayEx theory](https://smtlib.cs.uiowa.edu/Theories/ArraysEx.smt2) of
35 the SMT-LIB standard 2.7.
38 let arguments = (ins ArrayType:$array, AnySMTType:$index, AnySMTType:$value);
39 let results = (outs ArrayType:$result);
41 let assemblyFormat = [{
42 $array `[` $index `]` `,` $value attr-dict `:` qualified(type($array))
49 TypesMatchWith<"summary", "array", "index",
50 "cast<ArrayType>($_self).getDomainType()">,
51 TypesMatchWith<"summary", "array", "result",
52 "cast<ArrayType>($_self).getRangeType()">,
54 let summary = "get the value stored in the array at the given index";
56 This operation is retuns the value stored in the given array at the given
57 index. The semantics are equivalent to the `select` operator defined in the
58 [SMT ArrayEx theory](https://smtlib.cs.uiowa.edu/Theories/ArraysEx.smt2) of
59 the SMT-LIB standard 2.7.
62 let arguments = (ins ArrayType:$array, AnySMTType:$index);
63 let results = (outs AnySMTType:$result);
65 let assemblyFormat = [{
66 $array `[` $index `]` attr-dict `:` qualified(type($array))
71 : SMTArrayOp<"broadcast", [Pure,
73 "summary", "result", "value",
74 "cast<ArrayType>($_self).getRangeType()">,
76 let summary = "construct an array with the given value stored at every index";
78 This operation represents a broadcast of the 'value' operand to all indices
79 of the array. It is equivalent to
81 %0 = smt.declare_fun "array" : !smt.array<[!smt.int -> !smt.bool]>
82 %1 = smt.forall ["idx"] {
84 %2 = smt.array.select %0[%idx] : !smt.array<[!smt.int -> !smt.bool]>
85 %3 = smt.eq %value, %2 : !smt.bool
86 smt.yield %3 : !smt.bool
92 In SMT-LIB, this is frequently written as
93 `((as const (Array Int Bool)) value)`.
96 let arguments = (ins AnySMTType:$value);
97 let results = (outs ArrayType:$result);
99 let assemblyFormat = "$value attr-dict `:` qualified(type($result))";
102#endif // MLIR_DIALECT_SMT_IR_SMTARRAYOPS_TD