[flang-commits] [flang] 686a951 - [flang] Make default quad precision kind target dependent

via flang-commits flang-commits at lists.llvm.org
Mon Oct 24 19:16:52 PDT 2022


Author: Peixin-Qiao
Date: 2022-10-25T10:15:34+08:00
New Revision: 686a951d4b0e006ee2f6e3c0d35ae41b9ee455f9

URL: https://github.com/llvm/llvm-project/commit/686a951d4b0e006ee2f6e3c0d35ae41b9ee455f9
DIFF: https://github.com/llvm/llvm-project/commit/686a951d4b0e006ee2f6e3c0d35ae41b9ee455f9.diff

LOG: [flang] Make default quad precision kind target dependent

The quad precision kind is defined as 8 by default in
flang/include/flang/Common/default-kinds.h. However, it should be target
dependent. This fixes the default quad precision kind when the target
is on X86_64.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D136581

Added: 
    

Modified: 
    flang/lib/Frontend/CompilerInstance.cpp
    flang/test/Semantics/kinds04_q10.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Frontend/CompilerInstance.cpp b/flang/lib/Frontend/CompilerInstance.cpp
index 5a33f5b26c9fb..951b8d179bed0 100644
--- a/flang/lib/Frontend/CompilerInstance.cpp
+++ b/flang/lib/Frontend/CompilerInstance.cpp
@@ -17,6 +17,7 @@
 #include "flang/Parser/parsing.h"
 #include "flang/Parser/provenance.h"
 #include "flang/Semantics/semantics.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
@@ -143,6 +144,11 @@ void CompilerInstance::clearOutputFiles(bool eraseFiles) {
 bool CompilerInstance::executeAction(FrontendAction &act) {
   auto &invoc = this->getInvocation();
 
+  llvm::Triple targetTriple{llvm::Triple(invoc.getTargetOpts().triple)};
+  if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
+    invoc.getDefaultKinds().set_quadPrecisionKind(10);
+  }
+
   // Set some sane defaults for the frontend.
   invoc.setDefaultFortranOpts();
   // Update the fortran options based on user-based input.

diff  --git a/flang/test/Semantics/kinds04_q10.f90 b/flang/test/Semantics/kinds04_q10.f90
index 5324a05c222d6..07da32e92c0f7 100644
--- a/flang/test/Semantics/kinds04_q10.f90
+++ b/flang/test/Semantics/kinds04_q10.f90
@@ -1,4 +1,4 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1
+! RUN: %python %S/test_errors.py %s %flang_fc1 -triple x86_64-unknown-linux-gnu
 ! C716 If both kind-param and exponent-letter appear, exponent-letter
 ! shall be E. (As an extension we also allow an exponent-letter which matches
 ! the kind-param)
@@ -7,10 +7,8 @@
 !
 ! This test is for x86_64, where exponent-letter 'q' is for
 ! 10-byte extended precision
-! REQUIRES: x86-registered-target
 ! UNSUPPORTED: system-windows
-! XFAIL: *
-!WARNING: THIS TEST HAS BEEN DISABLED UNTIL IT CAN BE PROPERLY CONFIGURED
+
 subroutine s(var)
   real :: realvar1 = 4.0E6_4
   real :: realvar2 = 4.0D6


        


More information about the flang-commits mailing list