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;
34 return ::mlir::success();
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();
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();
75 auto attr = ::llvm::cast<::mlir::StringAttr>(
getProperties().value);
81 return attr.getValue();
89 if (!tblgen_value)
return emitError(loc,
"'string.new' op ""requires attribute 'value'");
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();
102 return {std::next(getOperation()->operand_begin(), valueRange.first),
103 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
112 return {std::next(getOperation()->result_begin(), valueRange.first),
113 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
117 return ::llvm::cast<::mlir::TypedValue<::llzk::string::StringType>>(*
getODSResults(0).begin());
121 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
123 emitError() <<
"expected DictionaryAttr to set properties";
124 return ::mlir::failure();
128 auto &propStorage = prop.
value;
129 auto attr = dict.get(
"value");
132 emitError() <<
"expected key entry for value in DictionaryAttr to set "
134 return ::mlir::failure();
136 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
138 propStorage = convertedAttr;
140 emitError() <<
"Invalid attribute `value` in property conversion: " << attr;
141 return ::mlir::failure();
145 return ::mlir::success();
149 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
150 ::mlir::Builder odsBuilder{ctx};
153 const auto &propStorage = prop.
value;
155 attrs.push_back(odsBuilder.getNamedAttr(
"value",
160 return odsBuilder.getDictionaryAttr(attrs);
165 return llvm::hash_combine(
166 llvm::hash_value(prop.
value.getAsOpaquePointer()));
176 if (name ==
"value") {
177 prop.
value = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
value)>>(value);
183 if (prop.
value) attrs.append(
"value", prop.
value);
186::mlir::LogicalResult
LitStringOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
189 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr,
"value", emitError)))
190 return ::mlir::failure();
192 return ::mlir::success();
196 auto &prop = state.getOrAddProperties<
Properties>(); (void)prop;
197 if (::mlir::failed(reader.readAttribute(prop.
value)))
198 return ::mlir::failure();
199 return ::mlir::success();
203 auto &prop = getProperties(); (void)prop;
204 writer.writeAttribute(prop.
value);
208 return ::llvm::cast<::mlir::StringAttr>(getProperties().value);
213 return attr.getValue();
221 (*this)->setAttr(
getValueAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue));
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);
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);
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);
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);
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);
255 auto tblgen_value = getProperties().value; (void)tblgen_value;
256 if (!tblgen_value)
return emitOpError(
"requires attribute 'value'");
258 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*
this, tblgen_value,
"value")))
259 return ::mlir::failure();
261 unsigned index = 0; (void)index;
264 for (
auto v : valueGroup0) {
265 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*
this, v.getType(),
"result", index++)))
266 return ::mlir::failure();
269 return ::mlir::success();
277 ::mlir::StringAttr valueAttr;
279 if (parser.parseCustomAttributeWithFallback(valueAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
280 return ::mlir::failure();
284 auto loc = parser.getCurrentLocation();(void)loc;
285 if (parser.parseOptionalAttrDict(result.attributes))
286 return ::mlir::failure();
288 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
290 return ::mlir::failure();
293 result.addTypes(odsBuildableType0);
294 return ::mlir::success();
300 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
301 elidedAttrs.push_back(
"value");
302 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
305void LitStringOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
LitStringOpAdaptor(LitStringOp op)
::mlir::LogicalResult verify(::mlir::Location loc)
LitStringOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
::mlir::ValueRange getOperands()
::mlir::LogicalResult verifyInvariants()
static llvm::hash_code computePropertiesHash(const Properties &prop)
void setValueAttr(::mlir::StringAttr attr)
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)
::mlir::TypedValue<::llzk::string::StringType > getResult()
::mlir::LogicalResult verifyInvariantsImpl()
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
::mlir::StringAttr getValueAttr()
::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)
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
void setValue(::llvm::StringRef attrValue)
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::mlir::Operation::operand_range getODSOperands(unsigned index)
::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
::mlir::Operation::result_range getODSResults(unsigned index)
::llvm::StringRef getValue()
::mlir::DictionaryAttr odsAttrs
::llvm::StringRef getValue()
::mlir::DictionaryAttr getAttributes()
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
::mlir::StringAttr getValueAttr()
LitStringOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
::std::optional<::mlir::OperationName > odsOpName
::mlir::RegionRange odsRegions
const Properties & getProperties()