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;
34 return ::mlir::success();
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();
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();
64 return attr.getValue();
72 if (!tblgen_value)
return emitError(loc,
"'string.new' op ""requires attribute 'value'");
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();
80 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
82 emitError() <<
"expected DictionaryAttr to set properties";
83 return ::mlir::failure();
87 auto &propStorage = prop.
value;
88 auto attr = dict.get(
"value");
90 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
92 propStorage = convertedAttr;
94 emitError() <<
"Invalid attribute `value` in property conversion: " << attr;
95 return ::mlir::failure();
99 return ::mlir::success();
103 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
104 ::mlir::Builder odsBuilder{ctx};
107 const auto &propStorage = prop.
value;
109 attrs.push_back(odsBuilder.getNamedAttr(
"value",
114 return odsBuilder.getDictionaryAttr(attrs);
119 return llvm::hash_combine(
120 llvm::hash_value(prop.
value.getAsOpaquePointer()));
130 if (
name ==
"value") {
131 prop.
value = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
value)>>(value);
137 if (prop.
value) attrs.append(
"value", prop.
value);
140::llvm::LogicalResult
LitStringOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
143 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr,
"value", emitError)))
144 return ::mlir::failure();
146 return ::mlir::success();
150 auto &prop = state.getOrAddProperties<
Properties>(); (void)prop;
151 if (::mlir::failed(reader.readAttribute(prop.
value)))
152 return ::mlir::failure();
153 return ::mlir::success();
157 auto &prop = getProperties(); (void)prop;
158 writer.writeAttribute(prop.
value);
163 return attr.getValue();
167 getProperties().value = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
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);
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);
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);
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);
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);
199 if (!attributes.empty()) {
200 ::mlir::OpaqueProperties 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.");
211 auto tblgen_value = getProperties().value; (void)tblgen_value;
212 if (!tblgen_value)
return emitOpError(
"requires attribute 'value'");
214 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*
this, tblgen_value,
"value")))
215 return ::mlir::failure();
217 unsigned index = 0; (void)index;
220 for (
auto v : valueGroup0) {
221 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*
this, v.getType(),
"result", index++)))
222 return ::mlir::failure();
225 return ::mlir::success();
233 ::mlir::StringAttr valueAttr;
235 if (parser.parseCustomAttributeWithFallback(valueAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
236 return ::mlir::failure();
240 auto loc = parser.getCurrentLocation();(void)loc;
241 if (parser.parseOptionalAttrDict(result.attributes))
242 return ::mlir::failure();
244 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
246 return ::mlir::failure();
249 result.addTypes(odsBuildableType0);
250 return ::mlir::success();
256 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
257 elidedAttrs.push_back(
"value");
258 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
261void LitStringOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
LitStringOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
LitStringOpAdaptor(LitStringOp op)
::llvm::LogicalResult verify(::mlir::Location loc)
::mlir::ValueRange getOperands()
static llvm::hash_code computePropertiesHash(const Properties &prop)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value)
void print(::mlir::OpAsmPrinter &_odsPrinter)
void writeProperties(::mlir::DialectBytecodeWriter &writer)
::llvm::LogicalResult verifyInvariantsImpl()
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
::mlir::Operation::result_range getODSResults(unsigned index)
::mlir::StringAttr getValueAttr()
void setValue(::llvm::StringRef attrValue)
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::llvm::LogicalResult verifyInvariants()
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
::mlir::StringAttr getValueAttrName()
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
FoldAdaptor::Properties Properties
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::llvm::StringRef getValue()
::mlir::DictionaryAttr odsAttrs
::mlir::StringAttr getValueAttr()
::llvm::StringRef getValue()
::std::optional<::mlir::OperationName > odsOpName
LitStringOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::mlir::RegionRange odsRegions
const Properties & getProperties()