-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[MLIR] Turn RemarkFormat
into an enum class (NFC)
#158733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is fixing a gcc warning and aligning with the other enums in the file.
@llvm/pr-subscribers-mlir Author: Mehdi Amini (joker-eph) ChangesThis is fixing a gcc warning and aligning with the other enums in the file. Full diff: https://github.com/llvm/llvm-project/pull/158733.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
index 7b83f10573645..0fbe15fa2e0db 100644
--- a/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
+++ b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
@@ -38,7 +38,7 @@ enum class VerbosityLevel {
ErrorsWarningsAndRemarks
};
-using RemarkFormat = enum {
+enum class RemarkFormat {
REMARK_FORMAT_STDOUT,
REMARK_FORMAT_YAML,
REMARK_FORMAT_BITSTREAM,
@@ -264,7 +264,7 @@ class MlirOptMainConfig {
bool allowUnregisteredDialectsFlag = false;
/// Remark format
- RemarkFormat remarkFormatFlag = REMARK_FORMAT_STDOUT;
+ RemarkFormat remarkFormatFlag = RemarkFormat::REMARK_FORMAT_STDOUT;
/// Remark file to output to
std::string remarksOutputFileFlag = "";
/// Remark filters
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 4f3b2eda7e69b..30fd384f3977c 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -216,13 +216,14 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
llvm::cl::desc("Specify the format for remark output."),
cl::location(remarkFormatFlag),
llvm::cl::value_desc("format"),
- llvm::cl::init(REMARK_FORMAT_STDOUT),
- llvm::cl::values(
- clEnumValN(REMARK_FORMAT_STDOUT, "emitRemark",
- "Print as emitRemark to command-line"),
- clEnumValN(REMARK_FORMAT_YAML, "yaml", "Print yaml file"),
- clEnumValN(REMARK_FORMAT_BITSTREAM, "bitstream",
- "Print bitstream file")),
+ llvm::cl::init(RemarkFormat::REMARK_FORMAT_STDOUT),
+ llvm::cl::values(clEnumValN(RemarkFormat::REMARK_FORMAT_STDOUT,
+ "emitRemark",
+ "Print as emitRemark to command-line"),
+ clEnumValN(RemarkFormat::REMARK_FORMAT_YAML, "yaml",
+ "Print yaml file"),
+ clEnumValN(RemarkFormat::REMARK_FORMAT_BITSTREAM,
+ "bitstream", "Print bitstream file")),
llvm::cl::cat(remarkCategory)};
static cl::opt<std::string, /*ExternalStorage=*/true> remarksAll(
@@ -525,13 +526,13 @@ performActions(raw_ostream &os,
mlir::MLIRContext &ctx = *context;
switch (config.getRemarkFormat()) {
- case REMARK_FORMAT_STDOUT:
+ case RemarkFormat::REMARK_FORMAT_STDOUT:
if (failed(mlir::remark::enableOptimizationRemarks(
ctx, nullptr, cats, true /*printAsEmitRemarks*/)))
return failure();
break;
- case REMARK_FORMAT_YAML: {
+ case RemarkFormat::REMARK_FORMAT_YAML: {
std::string file = config.getRemarksOutputFile().empty()
? "mlir-remarks.yaml"
: config.getRemarksOutputFile();
@@ -541,7 +542,7 @@ performActions(raw_ostream &os,
break;
}
- case REMARK_FORMAT_BITSTREAM: {
+ case RemarkFormat::REMARK_FORMAT_BITSTREAM: {
std::string file = config.getRemarksOutputFile().empty()
? "mlir-remarks.bitstream"
: config.getRemarksOutputFile();
|
@llvm/pr-subscribers-mlir-core Author: Mehdi Amini (joker-eph) ChangesThis is fixing a gcc warning and aligning with the other enums in the file. Full diff: https://github.com/llvm/llvm-project/pull/158733.diff 2 Files Affected:
diff --git a/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
index 7b83f10573645..0fbe15fa2e0db 100644
--- a/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
+++ b/mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h
@@ -38,7 +38,7 @@ enum class VerbosityLevel {
ErrorsWarningsAndRemarks
};
-using RemarkFormat = enum {
+enum class RemarkFormat {
REMARK_FORMAT_STDOUT,
REMARK_FORMAT_YAML,
REMARK_FORMAT_BITSTREAM,
@@ -264,7 +264,7 @@ class MlirOptMainConfig {
bool allowUnregisteredDialectsFlag = false;
/// Remark format
- RemarkFormat remarkFormatFlag = REMARK_FORMAT_STDOUT;
+ RemarkFormat remarkFormatFlag = RemarkFormat::REMARK_FORMAT_STDOUT;
/// Remark file to output to
std::string remarksOutputFileFlag = "";
/// Remark filters
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 4f3b2eda7e69b..30fd384f3977c 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -216,13 +216,14 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
llvm::cl::desc("Specify the format for remark output."),
cl::location(remarkFormatFlag),
llvm::cl::value_desc("format"),
- llvm::cl::init(REMARK_FORMAT_STDOUT),
- llvm::cl::values(
- clEnumValN(REMARK_FORMAT_STDOUT, "emitRemark",
- "Print as emitRemark to command-line"),
- clEnumValN(REMARK_FORMAT_YAML, "yaml", "Print yaml file"),
- clEnumValN(REMARK_FORMAT_BITSTREAM, "bitstream",
- "Print bitstream file")),
+ llvm::cl::init(RemarkFormat::REMARK_FORMAT_STDOUT),
+ llvm::cl::values(clEnumValN(RemarkFormat::REMARK_FORMAT_STDOUT,
+ "emitRemark",
+ "Print as emitRemark to command-line"),
+ clEnumValN(RemarkFormat::REMARK_FORMAT_YAML, "yaml",
+ "Print yaml file"),
+ clEnumValN(RemarkFormat::REMARK_FORMAT_BITSTREAM,
+ "bitstream", "Print bitstream file")),
llvm::cl::cat(remarkCategory)};
static cl::opt<std::string, /*ExternalStorage=*/true> remarksAll(
@@ -525,13 +526,13 @@ performActions(raw_ostream &os,
mlir::MLIRContext &ctx = *context;
switch (config.getRemarkFormat()) {
- case REMARK_FORMAT_STDOUT:
+ case RemarkFormat::REMARK_FORMAT_STDOUT:
if (failed(mlir::remark::enableOptimizationRemarks(
ctx, nullptr, cats, true /*printAsEmitRemarks*/)))
return failure();
break;
- case REMARK_FORMAT_YAML: {
+ case RemarkFormat::REMARK_FORMAT_YAML: {
std::string file = config.getRemarksOutputFile().empty()
? "mlir-remarks.yaml"
: config.getRemarksOutputFile();
@@ -541,7 +542,7 @@ performActions(raw_ostream &os,
break;
}
- case REMARK_FORMAT_BITSTREAM: {
+ case RemarkFormat::REMARK_FORMAT_BITSTREAM: {
std::string file = config.getRemarksOutputFile().empty()
? "mlir-remarks.bitstream"
: config.getRemarksOutputFile();
|
This is fixing a gcc warning and aligning with the other enums in the file.
This is fixing a gcc warning and aligning with the other enums in the file.