Skip to content

Conversation

joker-eph
Copy link
Collaborator

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.
@joker-eph joker-eph requested a review from grypp September 15, 2025 20:19
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Sep 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 15, 2025

@llvm/pr-subscribers-mlir

Author: Mehdi Amini (joker-eph)

Changes

This 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:

  • (modified) mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h (+2-2)
  • (modified) mlir/lib/Tools/mlir-opt/MlirOptMain.cpp (+11-10)
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();

@llvmbot
Copy link
Member

llvmbot commented Sep 15, 2025

@llvm/pr-subscribers-mlir-core

Author: Mehdi Amini (joker-eph)

Changes

This 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:

  • (modified) mlir/include/mlir/Tools/mlir-opt/MlirOptMain.h (+2-2)
  • (modified) mlir/lib/Tools/mlir-opt/MlirOptMain.cpp (+11-10)
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();

@joker-eph joker-eph merged commit 7936b6f into llvm:main Sep 16, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:core MLIR Core Infrastructure mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants