[clang] [flang] [mlir] Add basic -mtune support (PR #98517)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 11 11:59:04 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 41de50b773c1c146ddafd4d363dab3b492e4485a 2e26f0f66f070cd0b684531efc63e63e2e584dfa --extensions cpp,h -- clang/lib/Driver/ToolChains/Flang.cpp flang/include/flang/Frontend/TargetOptions.h flang/include/flang/Lower/Bridge.h flang/include/flang/Optimizer/CodeGen/Target.h flang/include/flang/Optimizer/Dialect/Support/FIRContext.h flang/lib/Frontend/CompilerInvocation.cpp flang/lib/Frontend/FrontendActions.cpp flang/lib/Lower/Bridge.cpp flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/CodeGen/Target.cpp flang/lib/Optimizer/CodeGen/TargetRewrite.cpp flang/lib/Optimizer/CodeGen/TypeConverter.cpp flang/lib/Optimizer/Dialect/Support/FIRContext.cpp flang/tools/bbc/bbc.cpp flang/tools/tco/tco.cpp flang/unittests/Optimizer/FIRContextTest.cpp mlir/lib/Target/LLVMIR/ModuleImport.cpp mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/include/flang/Optimizer/CodeGen/Target.h b/flang/include/flang/Optimizer/CodeGen/Target.h
index 2b3b2152ac..a7161152a5 100644
--- a/flang/include/flang/Optimizer/CodeGen/Target.h
+++ b/flang/include/flang/Optimizer/CodeGen/Target.h
@@ -181,7 +181,7 @@ public:
 
   llvm::StringRef getTargetCPU() const { return targetCPU; }
   llvm::StringRef getTuneCPU() const { return tuneCPU; }
-  
+
   mlir::LLVM::TargetFeaturesAttr getTargetFeatures() const {
     return targetFeatures;
   }
diff --git a/flang/include/flang/Optimizer/Dialect/Support/FIRContext.h b/flang/include/flang/Optimizer/Dialect/Support/FIRContext.h
index b69f141504..bd31aa0782 100644
--- a/flang/include/flang/Optimizer/Dialect/Support/FIRContext.h
+++ b/flang/include/flang/Optimizer/Dialect/Support/FIRContext.h
@@ -64,7 +64,7 @@ void setTuneCPU(mlir::ModuleOp mod, llvm::StringRef cpu);
 
 /// Get the tune CPU string from the Module or return a null reference.
 llvm::StringRef getTuneCPU(mlir::ModuleOp mod);
-  
+
 /// Set the target features for the module.
 void setTargetFeatures(mlir::ModuleOp mod, llvm::StringRef features);
 
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
index b52f2b9325..85bf90e475 100644
--- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
@@ -110,7 +110,7 @@ public:
     auto specifics = fir::CodeGenSpecifics::get(
         mod.getContext(), fir::getTargetTriple(mod), fir::getKindMapping(mod),
         fir::getTargetCPU(mod), fir::getTargetFeatures(mod), *dl,
-	fir::getTuneCPU(mod));
+        fir::getTuneCPU(mod));
 
     setMembers(specifics.get(), &rewriter, &*dl);
 
diff --git a/flang/tools/tco/tco.cpp b/flang/tools/tco/tco.cpp
index afaad39ce1..a8c6433310 100644
--- a/flang/tools/tco/tco.cpp
+++ b/flang/tools/tco/tco.cpp
@@ -58,8 +58,8 @@ static cl::opt<std::string> targetTriple("target",
 static cl::opt<std::string>
     targetCPU("target-cpu", cl::desc("specify a target CPU"), cl::init(""));
 
-static cl::opt<std::string>
-    tuneCPU("tune-cpu", cl::desc("specify a tune CPU"), cl::init(""));
+static cl::opt<std::string> tuneCPU("tune-cpu", cl::desc("specify a tune CPU"),
+                                    cl::init(""));
 
 static cl::opt<std::string>
     targetFeatures("target-features", cl::desc("specify the target features"),
diff --git a/flang/unittests/Optimizer/FIRContextTest.cpp b/flang/unittests/Optimizer/FIRContextTest.cpp
index dbc00a3b13..3f8b59ac94 100644
--- a/flang/unittests/Optimizer/FIRContextTest.cpp
+++ b/flang/unittests/Optimizer/FIRContextTest.cpp
@@ -64,7 +64,7 @@ TEST_F(StringAttributesTests, moduleStringAttrTest) {
 
   EXPECT_EQ(getTargetCPU(mod), targetCPU);
   EXPECT_EQ(getTuneCPU(mod), tuneCPU);
-  
+
   auto features = getTargetFeatures(mod);
   auto featuresList = features.getFeatures();
   EXPECT_EQ(features.getFeaturesString(), targetFeatures);

``````````

</details>


https://github.com/llvm/llvm-project/pull/98517


More information about the cfe-commits mailing list