LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Ops.capi.test.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op C API Tests *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: Ops.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10class RamOperationLinkTests : public CAPITest {};
11
13TEST_F(RamOperationLinkTests, IsA_Ram_LoadOp) {
14 auto testOperation = createIndexOperation();
15
16 // This will always return false since `createIndex*` returns an MLIR builtin
17 EXPECT_FALSE(llzkOperationIsA_Ram_LoadOp(testOperation));
18
19 mlirOperationDestroy(testOperation);
20}
21
23TEST_F(RamOperationLinkTests, llzk_LoadOp_Build) {
24 // Returns an `arith.constant` op, which will never match the LoadOp dialect check.
25 auto testOp = createIndexOperation();
26
27 // This condition is always false, so the function is never actually called.
28 // We only verify it compiles and links correctly.
29 if (llzkOperationIsA_Ram_LoadOp(testOp)) {
30 MlirOpBuilder builder = mlirOpBuilderCreate(context);
31 MlirLocation location = mlirLocationUnknownGet(context);
32 auto dummyValue = mlirOperationGetResult(testOp, 0);
33 auto valType = createIndexType();
34
35 (void)llzkRam_LoadOpBuild(builder, location, valType, dummyValue);
36 // No need to destroy builder or op since this code never runs.
37 }
38
39 mlirOperationDestroy(testOp);
40}
41
42struct LoadOpBuildFuncHelper : public TestAnyBuildFuncHelper<CAPITest> {
43 virtual bool callIsA(MlirOperation op) override { return llzkOperationIsA_Ram_LoadOp(op); }
47 static std::unique_ptr<LoadOpBuildFuncHelper> get();
48
49protected:
51};
52
55TEST_F(CAPITest, LoadOp_build_pass) { LoadOpBuildFuncHelper::get()->run(*this); }
56
57TEST_F(RamOperationLinkTests, llzk_LoadOp_GetAddr) {
58 auto testOp = createIndexOperation();
59
60 if (llzkOperationIsA_Ram_LoadOp(testOp)) {
61 (void)llzkRam_LoadOpGetAddr(testOp);
62 }
63
64 mlirOperationDestroy(testOp);
65}
66
67TEST_F(RamOperationLinkTests, llzk_LoadOp_SetAddr) {
68 auto testOp = createIndexOperation();
69
70 if (llzkOperationIsA_Ram_LoadOp(testOp)) {
71 auto dummyValue = mlirOperationGetResult(testOp, 0);
72 llzkRam_LoadOpSetAddr(testOp, dummyValue);
73 }
74
75 mlirOperationDestroy(testOp);
76}
77
78TEST_F(RamOperationLinkTests, llzk_LoadOp_GetVal) {
79 auto testOp = createIndexOperation();
80
81 if (llzkOperationIsA_Ram_LoadOp(testOp)) {
82 (void)llzkRam_LoadOpGetVal(testOp);
83 }
84
85 mlirOperationDestroy(testOp);
86}
87
89TEST_F(RamOperationLinkTests, IsA_Ram_StoreOp) {
90 auto testOperation = createIndexOperation();
91
92 // This will always return false since `createIndex*` returns an MLIR builtin
93 EXPECT_FALSE(llzkOperationIsA_Ram_StoreOp(testOperation));
94
95 mlirOperationDestroy(testOperation);
96}
97
99TEST_F(RamOperationLinkTests, llzk_StoreOp_Build) {
100 // Returns an `arith.constant` op, which will never match the StoreOp dialect check.
101 auto testOp = createIndexOperation();
102
103 // This condition is always false, so the function is never actually called.
104 // We only verify it compiles and links correctly.
105 if (llzkOperationIsA_Ram_StoreOp(testOp)) {
106 MlirOpBuilder builder = mlirOpBuilderCreate(context);
107 MlirLocation location = mlirLocationUnknownGet(context);
108 auto dummyValue = mlirOperationGetResult(testOp, 0);
109
110 (void)llzkRam_StoreOpBuild(builder, location, dummyValue, dummyValue);
111 // No need to destroy builder or op since this code never runs.
112 }
113
114 mlirOperationDestroy(testOp);
115}
116
117struct StoreOpBuildFuncHelper : public TestAnyBuildFuncHelper<CAPITest> {
118 virtual bool callIsA(MlirOperation op) override { return llzkOperationIsA_Ram_StoreOp(op); }
122 static std::unique_ptr<StoreOpBuildFuncHelper> get();
123
124protected:
126};
127
130TEST_F(CAPITest, StoreOp_build_pass) { StoreOpBuildFuncHelper::get()->run(*this); }
131
132TEST_F(RamOperationLinkTests, llzk_StoreOp_GetAddr) {
133 auto testOp = createIndexOperation();
134
135 if (llzkOperationIsA_Ram_StoreOp(testOp)) {
136 (void)llzkRam_StoreOpGetAddr(testOp);
137 }
138
139 mlirOperationDestroy(testOp);
140}
141
142TEST_F(RamOperationLinkTests, llzk_StoreOp_SetAddr) {
143 auto testOp = createIndexOperation();
144
145 if (llzkOperationIsA_Ram_StoreOp(testOp)) {
146 auto dummyValue = mlirOperationGetResult(testOp, 0);
147 llzkRam_StoreOpSetAddr(testOp, dummyValue);
148 }
149
150 mlirOperationDestroy(testOp);
151}
152
153TEST_F(RamOperationLinkTests, llzk_StoreOp_GetVal) {
154 auto testOp = createIndexOperation();
155
156 if (llzkOperationIsA_Ram_StoreOp(testOp)) {
157 (void)llzkRam_StoreOpGetVal(testOp);
158 }
159
160 mlirOperationDestroy(testOp);
161}
162
163TEST_F(RamOperationLinkTests, llzk_StoreOp_SetVal) {
164 auto testOp = createIndexOperation();
165
166 if (llzkOperationIsA_Ram_StoreOp(testOp)) {
167 auto dummyValue = mlirOperationGetResult(testOp, 0);
168 llzkRam_StoreOpSetVal(testOp, dummyValue);
169 }
170
171 mlirOperationDestroy(testOp);
172}
TEST_F(ArrayOperationLinkTests, IsA_Array_ArrayLengthOp)
This test ensures llzkOperationIsA_Array_ArrayLengthOp links properly.
MlirOpBuilder mlirOpBuilderCreate(MlirContext ctx)
Creates a new OpBuilder for the given MLIR context.
Definition Builder.cpp:62
MlirValue llzkRam_LoadOpGetVal(MlirOperation op)
Get Val result from llzk::ram::LoadOp Operation.
void llzkRam_StoreOpSetVal(MlirOperation op, MlirValue value)
Set Val operand of llzk::ram::StoreOp Operation.
bool llzkOperationIsA_Ram_StoreOp(MlirOperation inp)
Returns true if the Operation is a llzk::ram::StoreOp.
MlirOperation llzkRam_StoreOpBuild(MlirOpBuilder builder, MlirLocation location, MlirValue addr, MlirValue val)
Build a llzk::ram::StoreOp Operation.
MlirValue llzkRam_LoadOpGetAddr(MlirOperation op)
Get Addr operand from llzk::ram::LoadOp Operation.
void llzkRam_StoreOpSetAddr(MlirOperation op, MlirValue value)
Set Addr operand of llzk::ram::StoreOp Operation.
MlirOperation llzkRam_LoadOpBuild(MlirOpBuilder builder, MlirLocation location, MlirType valType, MlirValue addr)
Build a llzk::ram::LoadOp Operation.
bool llzkOperationIsA_Ram_LoadOp(MlirOperation inp)
Returns true if the Operation is a llzk::ram::LoadOp.
void llzkRam_LoadOpSetAddr(MlirOperation op, MlirValue value)
Set Addr operand of llzk::ram::LoadOp Operation.
MlirValue llzkRam_StoreOpGetAddr(MlirOperation op)
Get Addr operand from llzk::ram::StoreOp Operation.
MlirValue llzkRam_StoreOpGetVal(MlirOperation op)
Get Val operand from llzk::ram::StoreOp Operation.
LoadOpBuildFuncHelper()=default
static std::unique_ptr< LoadOpBuildFuncHelper > get()
This method must be implemented to return a subclass of LoadOpBuildFuncHelper that at least implement...
virtual bool callIsA(MlirOperation op) override
StoreOpBuildFuncHelper()=default
static std::unique_ptr< StoreOpBuildFuncHelper > get()
This method must be implemented to return a subclass of StoreOpBuildFuncHelper that at least implemen...
virtual bool callIsA(MlirOperation op) override