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 ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
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 ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
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 ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
45 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
46 return __mlir_ods_local_attr_constraint_Ops1(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(LitStringOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
61
63 auto attr = getValueAttr();
64 return attr.getValue();
65}
66
67} // namespace detail
69
70::llvm::LogicalResult LitStringOpAdaptor::verify(::mlir::Location loc) {
71 auto tblgen_value = getProperties().value; (void)tblgen_value;
72 if (!tblgen_value) return emitError(loc, "'string.new' op ""requires attribute 'value'");
73
74 if (tblgen_value && !((::llvm::isa<::mlir::StringAttr>(tblgen_value))))
75 return emitError(loc, "'string.new' op ""attribute 'value' failed to satisfy constraint: string attribute");
76 return ::mlir::success();
77}
78
79::llvm::LogicalResult LitStringOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
80 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
81 if (!dict) {
82 emitError() << "expected DictionaryAttr to set properties";
83 return ::mlir::failure();
84 }
85
86 {
87 auto &propStorage = prop.value;
88 auto attr = dict.get("value");
89 if (attr) {
90 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
91 if (convertedAttr) {
92 propStorage = convertedAttr;
93 } else {
94 emitError() << "Invalid attribute `value` in property conversion: " << attr;
95 return ::mlir::failure();
96 }
97 }
98 }
99 return ::mlir::success();
100}
101
102::mlir::Attribute LitStringOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
103 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
104 ::mlir::Builder odsBuilder{ctx};
105
106 {
107 const auto &propStorage = prop.value;
108 if (propStorage)
109 attrs.push_back(odsBuilder.getNamedAttr("value",
110 propStorage));
111 }
112
113 if (!attrs.empty())
114 return odsBuilder.getDictionaryAttr(attrs);
115 return {};
116}
117
118llvm::hash_code LitStringOp::computePropertiesHash(const Properties &prop) {
119 return llvm::hash_combine(
120 llvm::hash_value(prop.value.getAsOpaquePointer()));
121}
122
123std::optional<mlir::Attribute> LitStringOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
124 if (name == "value")
125 return prop.value;
126 return std::nullopt;
127}
128
129void LitStringOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
130 if (name == "value") {
131 prop.value = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.value)>>(value);
132 return;
133 }
134}
135
136void LitStringOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
137 if (prop.value) attrs.append("value", prop.value);
138}
139
140::llvm::LogicalResult LitStringOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
141 {
142 ::mlir::Attribute attr = attrs.get(getValueAttrName(opName));
143 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "value", emitError)))
144 return ::mlir::failure();
145 }
146 return ::mlir::success();
147}
148
149::llvm::LogicalResult LitStringOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
150 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
151 if (::mlir::failed(reader.readAttribute(prop.value)))
152 return ::mlir::failure();
153 return ::mlir::success();
154}
155
156void LitStringOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
157 auto &prop = getProperties(); (void)prop;
158 writer.writeAttribute(prop.value);
159}
160
161::llvm::StringRef LitStringOp::getValue() {
162 auto attr = getValueAttr();
163 return attr.getValue();
164}
165
166void LitStringOp::setValue(::llvm::StringRef attrValue) {
167 getProperties().value = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
168}
169
170void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value) {
171 odsState.getOrAddProperties<Properties>().value = value;
172 odsState.addTypes(result);
173}
174
175void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr value) {
176 odsState.getOrAddProperties<Properties>().value = value;
177 assert(resultTypes.size() == 1u && "mismatched number of results");
178 odsState.addTypes(resultTypes);
179}
180
181void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::llvm::StringRef value) {
182 odsState.getOrAddProperties<Properties>().value = odsBuilder.getStringAttr(value);
183 odsState.addTypes(result);
184}
185
186void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef value) {
187 odsState.getOrAddProperties<Properties>().value = odsBuilder.getStringAttr(value);
188 assert(resultTypes.size() == 1u && "mismatched number of results");
189 odsState.addTypes(resultTypes);
190}
191
192void LitStringOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
193 assert(operands.size() == 0u && "mismatched number of parameters");
194 odsState.addOperands(operands);
195 odsState.addAttributes(attributes);
196 assert(resultTypes.size() == 1u && "mismatched number of return types");
197 odsState.addTypes(resultTypes);
198
199 if (!attributes.empty()) {
200 ::mlir::OpaqueProperties properties =
201 &odsState.getOrAddProperties<LitStringOp::Properties>();
202 std::optional<::mlir::RegisteredOperationName> info =
203 odsState.name.getRegisteredInfo();
204 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
205 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
206 ::llvm::report_fatal_error("Property conversion failed.");
207 }
208}
209
210::llvm::LogicalResult LitStringOp::verifyInvariantsImpl() {
211 auto tblgen_value = getProperties().value; (void)tblgen_value;
212 if (!tblgen_value) return emitOpError("requires attribute 'value'");
213
214 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_value, "value")))
215 return ::mlir::failure();
216 {
217 unsigned index = 0; (void)index;
218 auto valueGroup0 = getODSResults(0);
219
220 for (auto v : valueGroup0) {
221 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
222 return ::mlir::failure();
223 }
224 }
225 return ::mlir::success();
226}
227
228::llvm::LogicalResult LitStringOp::verifyInvariants() {
229 return verifyInvariantsImpl();
230}
231
232::mlir::ParseResult LitStringOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
233 ::mlir::StringAttr valueAttr;
234
235 if (parser.parseCustomAttributeWithFallback(valueAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
236 return ::mlir::failure();
237 }
238 if (valueAttr) result.getOrAddProperties<LitStringOp::Properties>().value = valueAttr;
239 {
240 auto loc = parser.getCurrentLocation();(void)loc;
241 if (parser.parseOptionalAttrDict(result.attributes))
242 return ::mlir::failure();
243 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
244 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
245 })))
246 return ::mlir::failure();
247 }
248 ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::llzk::string::StringType>();
249 result.addTypes(odsBuildableType0);
250 return ::mlir::success();
251}
252
253void LitStringOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
254 _odsPrinter << ' ';
255 _odsPrinter.printAttributeWithoutType(getValueAttr());
256 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
257 elidedAttrs.push_back("value");
258 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
259}
260
261void LitStringOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
262}
263
264} // namespace string
265} // namespace llzk
266MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::string::LitStringOp)
267
268
269#endif // GET_OP_CLASSES
270
MlirStringRef name
Definition Poly.cpp:48
LitStringOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:85
LitStringOpAdaptor(LitStringOp op)
Definition Ops.cpp.inc:68
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:70
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:118
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value)
Definition Ops.cpp.inc:170
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:253
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:156
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:210
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:136
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:232
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:123
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:261
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:160
::mlir::StringAttr getValueAttr()
Definition Ops.h.inc:179
void setValue(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:166
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:149
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:228
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:140
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:102
::mlir::StringAttr getValueAttrName()
Definition Ops.h.inc:134
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:129
FoldAdaptor::Properties Properties
Definition Ops.h.inc:128
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:79
::llvm::StringRef getValue()
Definition Ops.cpp.inc:161
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:50
LitStringOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:54