[flang] Make default quad precision kind target dependent
authorPeixin-Qiao <qiaopeixin@huawei.com>
Tue, 25 Oct 2022 02:15:34 +0000 (10:15 +0800)
committerPeixin-Qiao <qiaopeixin@huawei.com>
Tue, 25 Oct 2022 02:15:34 +0000 (10:15 +0800)
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

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

index 5a33f5b..951b8d1 100644 (file)
@@ -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.
index 5324a05..07da32e 100644 (file)
@@ -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