LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Ops.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: Ops.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10#ifdef GET_OP_LIST
11#undef GET_OP_LIST
12
14#endif // GET_OP_LIST
15
16#ifdef GET_OP_CLASSES
17#undef GET_OP_CLASSES
18
19
20//===----------------------------------------------------------------------===//
21// Local Utility Method Definitions
22//===----------------------------------------------------------------------===//
23
24namespace llzk {
25namespace string {
26
27static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops0(
28 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
29 unsigned valueIndex) {
30 if (!((::llvm::isa<::llzk::string::StringType>(type)))) {
31 return op->emitOpError(valueKind) << " #" << valueIndex
32 << " must be string type, but got " << type;
33 }
34 return ::mlir::success();
35}
36
37static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
38 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
39 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
40 return emitError() << "attribute '" << attrName
41 << "' failed to satisfy constraint: string attribute";
42 return ::mlir::success();
43}
44static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
45 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
46 return __mlir_ods_local_attr_constraint_Ops0(attr, attrName, [op]() {
47 return op->emitOpError();
48 });
49}
50} // namespace string
51} // namespace llzk
52namespace llzk {
53namespace string {
54
55//===----------------------------------------------------------------------===//
56// ::llzk::string::LitStringOp definitions
57//===----------------------------------------------------------------------===//
58
59namespace detail {
60LitStringOpGenericAdaptorBase::LitStringOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs)
61 odsOpName.emplace("string.new", odsAttrs.getContext());
62}
63
65
66std::pair<unsigned, unsigned> LitStringOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
67 return {index, 1};
68}
69
71 return odsAttrs;
72}
73
75 auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().value);
76 return attr;
77}
78
80 auto attr = getValueAttr();
81 return attr.getValue();
82}
83
84} // namespace detail
86
87::mlir::LogicalResult LitStringOpAdaptor::verify(::mlir::Location loc) {
88 auto tblgen_value = getProperties().value; (void)tblgen_value;
89 if (!tblgen_value) return emitError(loc, "'string.new' op ""requires attribute 'value'");
90
91 if (tblgen_value && !((::llvm::isa<::mlir::StringAttr>(tblgen_value))))
92 return emitError(loc, "'string.new' op ""attribute 'value' failed to satisfy constraint: string attribute");
93 return ::mlir::success();
94}
95
96std::pair<unsigned, unsigned> LitStringOp::getODSOperandIndexAndLength(unsigned index) {
97 return {index, 1};
98}
99
100::mlir::Operation::operand_range LitStringOp::getODSOperands(unsigned index) {
101 auto valueRange = getODSOperandIndexAndLength(index);
102 return {std::next(getOperation()->operand_begin(), valueRange.first),
103 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
104}
105
106std::pair<unsigned, unsigned> LitStringOp::getODSResultIndexAndLength(unsigned index) {
107 return {index, 1};
108}
109
110::mlir::Operation::result_range LitStringOp::getODSResults(unsigned index) {
111 auto valueRange = getODSResultIndexAndLength(index);
112 return {std::next(getOperation()->result_begin(), valueRange.first),
113 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
114}
115
116::mlir::TypedValue<::llzk::string::StringType> LitStringOp::getResult() {
117 return ::llvm::cast<::mlir::TypedValue<::llzk::string::StringType>>(*getODSResults(0).begin());
118}
119
120::mlir::LogicalResult LitStringOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
121 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
122 if (!dict) {
123 emitError() << "expected DictionaryAttr to set properties";
124 return ::mlir::failure();
125 }
126
127 {
128 auto &propStorage = prop.value;
129 auto attr = dict.get("value");
130 if (attr || /*isRequired=*/true) {
131 if (!attr) {
132 emitError() << "expected key entry for value in DictionaryAttr to set "
133 "Properties.";
134 return ::mlir::failure();
135 }
136 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
137 if (convertedAttr) {
138 propStorage = convertedAttr;
139 } else {
140 emitError() << "Invalid attribute `value` in property conversion: " << attr;
141 return ::mlir::failure();
142 }
143 }
144 }
145 return ::mlir::success();
146}
147
148::mlir::Attribute LitStringOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
149 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
150 ::mlir::Builder odsBuilder{ctx};
151
152 {
153 const auto &propStorage = prop.value;
154 if (propStorage)
155 attrs.push_back(odsBuilder.getNamedAttr("value",
156 propStorage));
157 }
158
159 if (!attrs.empty())
160 return odsBuilder.getDictionaryAttr(attrs);
161 return {};
162}
163
164llvm::hash_code LitStringOp::computePropertiesHash(const Properties &prop) {
165 return llvm::hash_combine(
166 llvm::hash_value(prop.value.getAsOpaquePointer()));
167}
168
169std::optional<mlir::Attribute> LitStringOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
170 if (name == "value")
171 return prop.value;
172 return std::nullopt;
173}
174
175void LitStringOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
176 if (name == "value") {
177 prop.value = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.value)>>(value);
178 return;
179 }
180}
181
182void LitStringOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
183 if (prop.value) attrs.append("value", prop.value);
184}
185
186::mlir::LogicalResult LitStringOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
187 {
188 ::mlir::Attribute attr = attrs.get(getValueAttrName(opName));
189 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr, "value", emitError)))
190 return ::mlir::failure();
191 }
192 return ::mlir::success();
193}
194
195::mlir::LogicalResult LitStringOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
196 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
197 if (::mlir::failed(reader.readAttribute(prop.value)))
198 return ::mlir::failure();
199 return ::mlir::success();
200}
201
202void LitStringOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
203 auto &prop = getProperties(); (void)prop;
204 writer.writeAttribute(prop.value);
205}
206
207::mlir::StringAttr LitStringOp::getValueAttr() {
208 return ::llvm::cast<::mlir::StringAttr>(getProperties().value);
209}
210
211::llvm::StringRef LitStringOp::getValue() {
212 auto attr = getValueAttr();
213 return attr.getValue();
214}
215
216void LitStringOp::setValueAttr(::mlir::StringAttr attr) {
217 (*this)->setAttr(getValueAttrName(), attr);
218}
219
220void LitStringOp::setValue(::llvm::StringRef attrValue) {
221 (*this)->setAttr(getValueAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue));
222}
223
224void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value) {
225 odsState.getOrAddProperties<Properties>().value = value;
226 odsState.addTypes(result);
227}
228
229void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr value) {
230 odsState.getOrAddProperties<Properties>().value = value;
231 assert(resultTypes.size() == 1u && "mismatched number of results");
232 odsState.addTypes(resultTypes);
233}
234
235void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::llvm::StringRef value) {
236 odsState.getOrAddProperties<Properties>().value = odsBuilder.getStringAttr(value);
237 odsState.addTypes(result);
238}
239
240void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef value) {
241 odsState.getOrAddProperties<Properties>().value = odsBuilder.getStringAttr(value);
242 assert(resultTypes.size() == 1u && "mismatched number of results");
243 odsState.addTypes(resultTypes);
244}
245
246void LitStringOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
247 assert(operands.size() == 0u && "mismatched number of parameters");
248 odsState.addOperands(operands);
249 odsState.addAttributes(attributes);
250 assert(resultTypes.size() == 1u && "mismatched number of return types");
251 odsState.addTypes(resultTypes);
252}
253
254::mlir::LogicalResult LitStringOp::verifyInvariantsImpl() {
255 auto tblgen_value = getProperties().value; (void)tblgen_value;
256 if (!tblgen_value) return emitOpError("requires attribute 'value'");
257
258 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*this, tblgen_value, "value")))
259 return ::mlir::failure();
260 {
261 unsigned index = 0; (void)index;
262 auto valueGroup0 = getODSResults(0);
263
264 for (auto v : valueGroup0) {
265 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "result", index++)))
266 return ::mlir::failure();
267 }
268 }
269 return ::mlir::success();
270}
271
272::mlir::LogicalResult LitStringOp::verifyInvariants() {
273 return verifyInvariantsImpl();
274}
275
276::mlir::ParseResult LitStringOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
277 ::mlir::StringAttr valueAttr;
278
279 if (parser.parseCustomAttributeWithFallback(valueAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
280 return ::mlir::failure();
281 }
282 if (valueAttr) result.getOrAddProperties<LitStringOp::Properties>().value = valueAttr;
283 {
284 auto loc = parser.getCurrentLocation();(void)loc;
285 if (parser.parseOptionalAttrDict(result.attributes))
286 return ::mlir::failure();
287 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
288 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
289 })))
290 return ::mlir::failure();
291 }
292 ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::llzk::string::StringType>();
293 result.addTypes(odsBuildableType0);
294 return ::mlir::success();
295}
296
297void LitStringOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
298 _odsPrinter << ' ';
299 _odsPrinter.printAttributeWithoutType(getValueAttr());
300 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
301 elidedAttrs.push_back("value");
302 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
303}
304
305void LitStringOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
306}
307
308} // namespace string
309} // namespace llzk
310MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::string::LitStringOp)
311
312
313#endif // GET_OP_CLASSES
314
LitStringOpAdaptor(LitStringOp op)
Definition Ops.cpp.inc:85
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:87
LitStringOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:82
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:272
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:164
void setValueAttr(::mlir::StringAttr attr)
Definition Ops.cpp.inc:216
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value)
Definition Ops.cpp.inc:224
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:297
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:202
::mlir::TypedValue<::llzk::string::StringType > getResult()
Definition Ops.cpp.inc:116
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:254
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:120
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:182
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:96
::mlir::StringAttr getValueAttr()
Definition Ops.cpp.inc:207
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:276
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:169
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:305
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:106
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:186
void setValue(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:220
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:195
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:100
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:148
::mlir::StringAttr getValueAttrName()
Definition Ops.h.inc:127
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:175
FoldAdaptor::Properties Properties
Definition Ops.h.inc:121
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:110
::llvm::StringRef getValue()
Definition Ops.cpp.inc:211
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:66
LitStringOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:60
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:59