Remove code copied over from patch D11594. (#7590)
diff --git a/iree/compiler/Codegen/Dialect/LoweringConfig.cpp b/iree/compiler/Codegen/Dialect/LoweringConfig.cpp
index 79990d6..7548b46 100644
--- a/iree/compiler/Codegen/Dialect/LoweringConfig.cpp
+++ b/iree/compiler/Codegen/Dialect/LoweringConfig.cpp
@@ -68,77 +68,6 @@
namespace IREE {
namespace Codegen {
-namespace {
-
-// TODO(ravishankarm): The IREEFieldParser is part of the patch D111594 (where
-// it is called ::mlir::FieldParser). Remove this when the upstream change lands
-// in IREE.
-
-//===----------------------------------------------------------------------===//
-// Parse Fields
-//===----------------------------------------------------------------------===//
-
-/// Provide a template class that can be specialized by users to dispatch to
-/// parsers. Auto-generated parsers generate calls to
-/// `IREEFieldParser<T>::parse`, where `T` is the parameter storage type, to
-/// parse custom types.
-template <typename T, typename = T>
-struct IREEFieldParser;
-
-/// Parse an attribute.
-template <typename AttributeT>
-struct IREEFieldParser<
- AttributeT, std::enable_if_t<std::is_base_of<Attribute, AttributeT>::value,
- AttributeT>> {
- static FailureOr<AttributeT> parse(DialectAsmParser &parser) {
- AttributeT value;
- if (parser.parseAttribute(value)) return failure();
- return value;
- }
-};
-
-/// Parse any integer.
-template <typename IntT>
-struct IREEFieldParser<IntT,
- std::enable_if_t<std::is_integral<IntT>::value, IntT>> {
- static FailureOr<IntT> parse(DialectAsmParser &parser) {
- IntT value;
- if (parser.parseInteger(value)) return failure();
- return value;
- }
-};
-
-/// Parse a string.
-template <>
-struct IREEFieldParser<std::string> {
- static FailureOr<std::string> parse(DialectAsmParser &parser) {
- std::string value;
- if (parser.parseString(&value)) return failure();
- return value;
- }
-};
-
-/// Parse any container that supports back insertion as a list.
-template <typename ContainerT>
-struct IREEFieldParser<
- ContainerT, std::enable_if_t<std::is_member_function_pointer<decltype(
- &ContainerT::push_back)>::value,
- ContainerT>> {
- using ElementT = typename ContainerT::value_type;
- static FailureOr<ContainerT> parse(DialectAsmParser &parser) {
- ContainerT elements;
- auto elementParser = [&]() {
- auto element = IREEFieldParser<ElementT>::parse(parser);
- if (failed(element)) return failure();
- elements.push_back(element.getValue());
- return success();
- };
- if (parser.parseCommaSeparatedList(elementParser)) return failure();
- return elements;
- }
-};
-} // namespace
-
//===----------------------------------------------------------------------===//
// iree_codegen.translation.info
//===----------------------------------------------------------------------===//
@@ -186,54 +115,6 @@
return success();
}
-::mlir::Attribute TranslationInfoAttr::parse(::mlir::DialectAsmParser &parser,
- ::mlir::Type attrType) {
- ::mlir::FailureOr<StringAttr> _result_passPipeline;
- ::mlir::FailureOr<ArrayAttr> _result_workloadPerWorkgroup;
- // Parse literal '<'
- if (parser.parseLess()) return {};
- // Parse variable 'passPipeline'
- _result_passPipeline = IREEFieldParser<StringAttr>::parse(parser);
- if (failed(_result_passPipeline)) {
- parser.emitError(parser.getCurrentLocation(),
- "failed to parse IREECodegen_TranslationInfoAttr "
- "parameter 'passPipeline' which is to be a `StringAttr`");
- return {};
- }
- // Parse literal ','
- if (parser.parseComma()) return {};
- // Parse literal 'workload_per_wg'
- if (parser.parseKeyword("workload_per_wg")) return {};
- // Parse literal '='
- if (parser.parseEqual()) return {};
- // Parse variable 'workloadPerWorkgroup'
- _result_workloadPerWorkgroup = IREEFieldParser<ArrayAttr>::parse(parser);
- if (failed(_result_workloadPerWorkgroup)) {
- parser.emitError(
- parser.getCurrentLocation(),
- "failed to parse IREECodegen_TranslationInfoAttr parameter "
- "'workloadPerWorkgroup' which is to be a `ArrayAttr`");
- return {};
- }
- // Parse literal '>'
- if (parser.parseGreater()) return {};
- return TranslationInfoAttr::get(parser.getContext(),
- _result_passPipeline.getValue(),
- _result_workloadPerWorkgroup.getValue());
-}
-
-void TranslationInfoAttr::print(::mlir::DialectAsmPrinter &printer) const {
- printer << "translation.info";
- printer << "<";
- printer << getPassPipeline();
- printer << ",";
- printer << ' ' << "workload_per_wg";
- printer << ' ' << "=";
- printer << ' ';
- printer << getWorkloadPerWorkgroup();
- printer << ">";
-}
-
//===----------------------------------------------------------------------===//
// iree_codegen.lowering.config
//===----------------------------------------------------------------------===//
@@ -299,60 +180,6 @@
return success();
}
-::mlir::Attribute LoweringConfigAttr::parse(::mlir::DialectAsmParser &parser,
- ::mlir::Type attrType) {
- ::mlir::FailureOr<ArrayAttr> _result_tileSizes;
- ::mlir::FailureOr<ArrayAttr> _result_nativeVectorSize;
- // Parse literal '<'
- if (parser.parseLess()) return {};
- // Parse literal 'tile_sizes'
- if (parser.parseKeyword("tile_sizes")) return {};
- // Parse literal '='
- if (parser.parseEqual()) return {};
- // Parse variable 'tileSizes'
- _result_tileSizes = IREEFieldParser<ArrayAttr>::parse(parser);
- if (failed(_result_tileSizes)) {
- parser.emitError(parser.getCurrentLocation(),
- "failed to parse IREECodegen_LoweringConfigAttr parameter "
- "'tileSizes' which is to be a `ArrayAttr`");
- return {};
- }
- // Parse literal ','
- if (parser.parseComma()) return {};
- // Parse literal 'native_vector_size'
- if (parser.parseKeyword("native_vector_size")) return {};
- // Parse literal '='
- if (parser.parseEqual()) return {};
- // Parse variable 'nativeVectorSize'
- _result_nativeVectorSize = IREEFieldParser<ArrayAttr>::parse(parser);
- if (failed(_result_nativeVectorSize)) {
- parser.emitError(parser.getCurrentLocation(),
- "failed to parse IREECodegen_LoweringConfigAttr parameter "
- "'nativeVectorSize' which is to be a `ArrayAttr`");
- return {};
- }
- // Parse literal '>'
- if (parser.parseGreater()) return {};
- return LoweringConfigAttr::get(parser.getContext(),
- _result_tileSizes.getValue(),
- _result_nativeVectorSize.getValue());
-}
-
-void LoweringConfigAttr::print(::mlir::DialectAsmPrinter &printer) const {
- printer << "lowering.config";
- printer << "<";
- printer << "tile_sizes";
- printer << ' ' << "=";
- printer << ' ';
- printer << getTileSizes();
- printer << ",";
- printer << ' ' << "native_vector_size";
- printer << ' ' << "=";
- printer << ' ';
- printer << getNativeVectorSize();
- printer << ">";
-}
-
//===----------------------------------------------------------------------===//
// iree.compilation.info
//===----------------------------------------------------------------------===//
@@ -412,73 +239,6 @@
return success();
}
-/// Parser method that is copied from the auto-generated using `assemblyFormat`
-/// available with patch D111594. Replace after that change is in IREE.
-::mlir::Attribute CompilationInfoAttr::parse(::mlir::DialectAsmParser &parser,
- ::mlir::Type attrType) {
- ::mlir::FailureOr<LoweringConfigAttr> _result_loweringConfig;
- ::mlir::FailureOr<TranslationInfoAttr> _result_translationInfo;
- ::mlir::FailureOr<ArrayAttr> _result_workgroupSize;
- // Parse literal '<'
- if (parser.parseLess()) return {};
- // Parse variable 'loweringConfig'
- _result_loweringConfig = IREEFieldParser<LoweringConfigAttr>::parse(parser);
- if (failed(_result_loweringConfig)) {
- parser.emitError(
- parser.getCurrentLocation(),
- "failed to parse IREECodegen_CompilationInfoAttr parameter "
- "'loweringConfig' which is to be a `LoweringConfigAttr`");
- return {};
- }
- // Parse literal ','
- if (parser.parseComma()) return {};
- // Parse variable 'translationInfo'
- _result_translationInfo = IREEFieldParser<TranslationInfoAttr>::parse(parser);
- if (failed(_result_translationInfo)) {
- parser.emitError(
- parser.getCurrentLocation(),
- "failed to parse IREECodegen_CompilationInfoAttr parameter "
- "'translationInfo' which is to be a `TranslationInfoAttr`");
- return {};
- }
- // Parse literal ','
- if (parser.parseComma()) return {};
- // Parse literal 'workgroup_size'
- if (parser.parseKeyword("workgroup_size")) return {};
- // Parse literal '='
- if (parser.parseEqual()) return {};
- // Parse variable 'workgroupSize'
- _result_workgroupSize = IREEFieldParser<ArrayAttr>::parse(parser);
- if (failed(_result_workgroupSize)) {
- parser.emitError(parser.getCurrentLocation(),
- "failed to parse IREECodegen_CompilationInfoAttr "
- "parameter 'workgroupSize' which is to be a `ArrayAttr`");
- return {};
- }
- // Parse literal '>'
- if (parser.parseGreater()) return {};
- return CompilationInfoAttr::get(
- parser.getContext(), _result_loweringConfig.getValue(),
- _result_translationInfo.getValue(), _result_workgroupSize.getValue());
-}
-
-/// Printer method that is copied from the auto-generated using `assemblyFormat`
-/// available with patch D111594. Replace after that change is in IREE.
-void CompilationInfoAttr::print(::mlir::DialectAsmPrinter &printer) const {
- printer << "compilation.info";
- printer << "<";
- printer << getLoweringConfig();
- printer << ",";
- printer << ' ';
- printer << getTranslationInfo();
- printer << ",";
- printer << ' ' << "workgroup_size";
- printer << ' ' << "=";
- printer << ' ';
- printer << getWorkgroupSize();
- printer << ">";
-}
-
SmallVector<int64_t> CompilationInfoAttr::getWorkgroupSizeVals() {
ArrayAttr workgroupSizeAttr = getWorkgroupSize();
if (!workgroupSizeAttr) return {};
diff --git a/iree/compiler/Codegen/Dialect/LoweringConfig.td b/iree/compiler/Codegen/Dialect/LoweringConfig.td
index 2e7b547..0f0ec96 100644
--- a/iree/compiler/Codegen/Dialect/LoweringConfig.td
+++ b/iree/compiler/Codegen/Dialect/LoweringConfig.td
@@ -70,10 +70,9 @@
}];
- // TODO(ravishankarm): Commented out till patch D111594 lands.
- // let assemblyFormat = [{
- // `<` $passPipeline `,` `workload_per_wg` `=` $workloadPerWorkgroup `>`
- // }];
+ let assemblyFormat = [{
+ `<` $passPipeline `,` `workload_per_wg` `=` $workloadPerWorkgroup `>`
+ }];
let parameters = (ins
AttrParameter<"StringAttr", "">:$passPipeline,
@@ -112,10 +111,9 @@
}];
- // TODO(ravishankarm): Commented out till patch D111594 lands.
- // let assemblyFormat = [{
- // `<` `tile_sizes` `=` $tileSizes `,` `native_vector_size` `=` $nativeVectorSize `>`
- // }];
+ let assemblyFormat = [{
+ `<` `tile_sizes` `=` $tileSizes `,` `native_vector_size` `=` $nativeVectorSize `>`
+ }];
let parameters = (ins
AttrParameter<"ArrayAttr", "">:$tileSizes,
@@ -166,10 +164,9 @@
AttrParameter<"ArrayAttr", "">:$workgroupSize
);
- // TODO(ravishankarm): Commented out till patch D111594 lands.
- // let assemblyFormat = [{
- // `<` $loweringConfig `,` $translationInfo `,` `workgroup_size` `=` $workgroupSize `>`
- // }];
+ let assemblyFormat = [{
+ `<` $loweringConfig `,` $translationInfo `,` `workgroup_size` `=` $workgroupSize `>`
+ }];
let builders = [
AttrBuilder<(ins "TileSizesListTypeRef":$tileSizes,