[flang-commits] [flang] [Flang] remove real 10 test for ppc (NFC) (PR #73911)

via flang-commits flang-commits at lists.llvm.org
Mon Dec 4 14:31:38 PST 2023


https://github.com/madanial0 updated https://github.com/llvm/llvm-project/pull/73911

>From b793beb97047610aa4781ef6e1019f50a88cde2d Mon Sep 17 00:00:00 2001
From: Mark Danial <madanial at dixon.rtp.raleigh.ibm.com>
Date: Thu, 30 Nov 2023 02:23:48 -0500
Subject: [PATCH 1/3] [Flang] remove real 10 test for ppc (NFC)

---
 flang/unittests/Evaluate/real.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index 9701082898388..dca1ebfa2db50 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -14,7 +14,9 @@ using Real2 = Scalar<Type<TypeCategory::Real, 2>>;
 using Real3 = Scalar<Type<TypeCategory::Real, 3>>;
 using Real4 = Scalar<Type<TypeCategory::Real, 4>>;
 using Real8 = Scalar<Type<TypeCategory::Real, 8>>;
+#ifndef __PPC__
 using Real10 = Scalar<Type<TypeCategory::Real, 10>>;
+#endif
 using Real16 = Scalar<Type<TypeCategory::Real, 16>>;
 using Integer4 = Scalar<Type<TypeCategory::Integer, 4>>;
 using Integer8 = Scalar<Type<TypeCategory::Integer, 8>>;
@@ -538,7 +540,9 @@ void roundTest(int rm, Rounding rounding, std::uint32_t opds) {
   basicTests<Real3>(rm, rounding);
   basicTests<Real4>(rm, rounding);
   basicTests<Real8>(rm, rounding);
+#ifndef __PPC__
   basicTests<Real10>(rm, rounding);
+#endif
   basicTests<Real16>(rm, rounding);
   ScopedHostFloatingPointEnvironment::SetRounding(rounding);
   subsetTests<std::uint32_t, float, Real4>(rm, rounding, opds);

>From 441cefec627c4735d265fa3aeff5ef4bcf9876d0 Mon Sep 17 00:00:00 2001
From: Mark Danial <madanial at dixon.rtp.raleigh.ibm.com>
Date: Tue, 21 Nov 2023 12:18:40 -0500
Subject: [PATCH 2/3] Pass the correct path to getIntriniscDir and
 getOpenMPHeadersDir

---
 .../include/flang/Frontend/CompilerInvocation.h  |  6 ++++++
 flang/lib/Frontend/CompilerInvocation.cpp        | 16 ++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/flang/include/flang/Frontend/CompilerInvocation.h b/flang/include/flang/Frontend/CompilerInvocation.h
index 229aa75748f72..b345806586e04 100644
--- a/flang/include/flang/Frontend/CompilerInvocation.h
+++ b/flang/include/flang/Frontend/CompilerInvocation.h
@@ -101,6 +101,8 @@ class CompilerInvocation : public CompilerInvocationBase {
 
   bool warnAsErr = false;
 
+  const char *argv0;
+
   /// This flag controls the unparsing and is used to decide whether to print
   /// out the semantically analyzed version of an object or expression or the
   /// plain version that does not include any information from semantic
@@ -190,6 +192,8 @@ class CompilerInvocation : public CompilerInvocationBase {
     return enableConformanceChecks;
   }
 
+  const char *getArgv0() { return argv0; }
+
   bool &getEnableUsageChecks() { return enableUsageChecks; }
   const bool &getEnableUsageChecks() const { return enableUsageChecks; }
 
@@ -223,6 +227,8 @@ class CompilerInvocation : public CompilerInvocationBase {
   void setEnableUsageChecks() { enableUsageChecks = true; }
 
   /// Useful setters
+  void setArgv0(const char *dir) { argv0 = dir; }
+
   void setModuleDir(std::string &dir) { moduleDir = dir; }
 
   void setModuleFileSuffix(const char *suffix) {
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 1c09ae9c281eb..9d672956b8a6c 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -689,19 +689,19 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
 }
 
 // Generate the path to look for intrinsic modules
-static std::string getIntrinsicDir() {
+static std::string getIntrinsicDir(const char *argv) {
   // TODO: Find a system independent API
   llvm::SmallString<128> driverPath;
-  driverPath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+  driverPath.assign(llvm::sys::fs::getMainExecutable(argv, nullptr));
   llvm::sys::path::remove_filename(driverPath);
   driverPath.append("/../include/flang/");
   return std::string(driverPath);
 }
 
 // Generate the path to look for OpenMP headers
-static std::string getOpenMPHeadersDir() {
+static std::string getOpenMPHeadersDir(const char *argv) {
   llvm::SmallString<128> includePath;
-  includePath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+  includePath.assign(llvm::sys::fs::getMainExecutable(argv, nullptr));
   llvm::sys::path::remove_filename(includePath);
   includePath.append("/../include/flang/OpenMP/");
   return std::string(includePath);
@@ -1205,6 +1205,8 @@ bool CompilerInvocation::createFromArgs(
     }
   }
 
+  res.setArgv0(argv0);
+
   return success;
 }
 
@@ -1247,7 +1249,8 @@ void CompilerInvocation::setDefaultFortranOpts() {
 
   // Add the location of omp_lib.h to the search directories. Currently this is
   // identical to the modules' directory.
-  fortranOptions.searchDirectories.emplace_back(getOpenMPHeadersDir());
+  fortranOptions.searchDirectories.emplace_back(
+      getOpenMPHeadersDir(getArgv0()));
 
   fortranOptions.isFixedForm = false;
 }
@@ -1312,7 +1315,8 @@ void CompilerInvocation::setFortranOpts() {
       preprocessorOptions.searchDirectoriesFromIntrModPath.end());
 
   //  Add the default intrinsic module directory
-  fortranOptions.intrinsicModuleDirectories.emplace_back(getIntrinsicDir());
+  fortranOptions.intrinsicModuleDirectories.emplace_back(
+      getIntrinsicDir(getArgv0()));
 
   // Add the directory supplied through -J/-module-dir to the list of search
   // directories

>From 3821fd251d087c99b5b10df547a5e3fc09676344 Mon Sep 17 00:00:00 2001
From: Mark Danial <madanial at dixon.rtp.raleigh.ibm.com>
Date: Mon, 4 Dec 2023 17:31:09 -0500
Subject: [PATCH 3/3] [flang] Run real 10 test on x86 only (NFC)

---
 flang/unittests/Evaluate/real.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/flang/unittests/Evaluate/real.cpp b/flang/unittests/Evaluate/real.cpp
index dca1ebfa2db50..ccbaf81f054cb 100644
--- a/flang/unittests/Evaluate/real.cpp
+++ b/flang/unittests/Evaluate/real.cpp
@@ -14,7 +14,7 @@ using Real2 = Scalar<Type<TypeCategory::Real, 2>>;
 using Real3 = Scalar<Type<TypeCategory::Real, 3>>;
 using Real4 = Scalar<Type<TypeCategory::Real, 4>>;
 using Real8 = Scalar<Type<TypeCategory::Real, 8>>;
-#ifndef __PPC__
+#ifdef __x86_64__
 using Real10 = Scalar<Type<TypeCategory::Real, 10>>;
 #endif
 using Real16 = Scalar<Type<TypeCategory::Real, 16>>;
@@ -540,7 +540,7 @@ void roundTest(int rm, Rounding rounding, std::uint32_t opds) {
   basicTests<Real3>(rm, rounding);
   basicTests<Real4>(rm, rounding);
   basicTests<Real8>(rm, rounding);
-#ifndef __PPC__
+#ifdef __x86_64__
   basicTests<Real10>(rm, rounding);
 #endif
   basicTests<Real16>(rm, rounding);



More information about the flang-commits mailing list