Skip to content

Conversation

@wzssyqa
Copy link
Contributor

@wzssyqa wzssyqa commented May 20, 2024

Commit: d59bc6b
Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (#91949)
added +fp64 for clang, while not for clang -cc1. So

clang -cc1 -triple=mips -target-feature +msa -S

will emit an asm source file without ".module fp=64".

Commit: d59bc6b
        Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (llvm#91949)
added +fp64 for `clang`, while not for `clang -cc1`. So

   clang -cc1 -triple=mips -target-feature +msa -S

will emit an asm source file without ".module fp=64".
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 20, 2024
@llvmbot
Copy link
Member

llvmbot commented May 20, 2024

@llvm/pr-subscribers-clang

Author: YunQiang Su (wzssyqa)

Changes

Commit: d59bc6b
Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (#91949)
added +fp64 for clang, while not for clang -cc1. So

clang -cc1 -triple=mips -target-feature +msa -S

will emit an asm source file without ".module fp=64".


Full diff: https://github.com/llvm/llvm-project/pull/92728.diff

1 Files Affected:

  • (modified) clang/lib/Basic/Targets/Mips.h (+13-4)
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index f76c6ece8bf48..b6f110249fa78 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -324,6 +324,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
     FPMode = getDefaultFPMode();
     bool OddSpregGiven = false;
     bool StrictAlign = false;
+    bool FpGiven = false;
 
     for (const auto &Feature : Features) {
       if (Feature == "+single-float")
@@ -348,13 +349,16 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
         HasMSA = true;
       else if (Feature == "+nomadd4")
         DisableMadd4 = true;
-      else if (Feature == "+fp64")
+      else if (Feature == "+fp64") {
         FPMode = FP64;
-      else if (Feature == "-fp64")
+        FpGiven = true;
+      } else if (Feature == "-fp64") {
         FPMode = FP32;
-      else if (Feature == "+fpxx")
+        FpGiven = true;
+      } else if (Feature == "+fpxx") {
         FPMode = FPXX;
-      else if (Feature == "+nan2008")
+        FpGiven = true;
+      } else if (Feature == "+nan2008")
         IsNan2008 = true;
       else if (Feature == "-nan2008")
         IsNan2008 = false;
@@ -381,6 +385,11 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
     if (StrictAlign)
       HasUnalignedAccess = false;
 
+    if (HasMSA && !FpGiven) {
+      FPMode = FP64;
+      Features.push_back("+fp64");
+    }
+
     setDataLayout();
 
     return true;

@wzssyqa wzssyqa merged commit 45293b5 into llvm:main May 21, 2024
@wzssyqa wzssyqa deleted the cc1-msa-fp64 branch June 23, 2024 14:44
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Jun 26, 2024
…-gfx:d969842ea043

Local branch amd-gfx d969842 Manually Merged main:6733a505a1afb8eb4db2f6d85426d79ff0dc5eee into amd-gfx:4be7cf4eb8ab
Remote branch main 45293b5 MIPS/Clang: handleTargetFeatures, add +fp64 if +msa and no other +-fp (llvm#92728)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants