@@ -80,6 +80,19 @@ LogicalResult mlir::substrait::FixedCharAttr::verify(
8080 return success ();
8181}
8282
83+ LogicalResult mlir::substrait::FixedBinaryAttr::verify (
84+ llvm::function_ref<mlir::InFlightDiagnostic()> emitError, StringAttr value,
85+ FixedBinaryType type) {
86+ FixedBinaryType fixedBinaryType = mlir::dyn_cast<FixedBinaryType>(type);
87+ if (fixedBinaryType == nullptr )
88+ return emitError () << " expected a fixed binary type" ;
89+ int32_t value_length = value.size ();
90+ if (value_length != fixedBinaryType.getLength ())
91+ return emitError () << " value length must be " << fixedBinaryType.getLength ()
92+ << " characters." ;
93+ return success ();
94+ }
95+
8396LogicalResult mlir::substrait::IntervalYearMonthAttr::verify (
8497 llvm::function_ref<mlir::InFlightDiagnostic()> emitError, int32_t year,
8598 int32_t month) {
@@ -358,6 +371,32 @@ void printDecimalNumber(AsmPrinter &printer, DecimalType type,
358371 printer << " P = " << type.getPrecision () << " , S = " << type.getScale ();
359372}
360373
374+ ParseResult parseFixedBinaryLiteral (AsmParser &parser, StringAttr &value,
375+ FixedBinaryType &type) {
376+ std::string valueStr;
377+ // Parse fixed binary value as quoted string.
378+ if (parser.parseString (&valueStr))
379+ return failure ();
380+
381+ // Create `FixedBinaryType`.
382+ auto emitError = [&]() {
383+ return parser.emitError (parser.getCurrentLocation ());
384+ };
385+ MLIRContext *context = parser.getContext ();
386+ uint32_t length = valueStr.size ();
387+ if (!(type = FixedBinaryType::getChecked (emitError, context, length)))
388+ return failure ();
389+
390+ value = parser.getBuilder ().getStringAttr (valueStr);
391+
392+ return success ();
393+ }
394+
395+ void printFixedBinaryLiteral (AsmPrinter &printer, StringAttr value,
396+ FixedBinaryType type) {
397+ printer << value;
398+ }
399+
361400// ===----------------------------------------------------------------------===//
362401// Substrait operations
363402// ===----------------------------------------------------------------------===//
0 commit comments