Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mips] Fix clang compile error when -march=p5600 with -mmsa #132679

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yingopq
Copy link
Contributor

@yingopq yingopq commented Mar 24, 2025

When -march=p5600 with -mmsa, the result of getISARev is 0, so report error. Append p5600 to cases mips32r5.

Fix #91948.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/pr-subscribers-clang

Author: None (yingopq)

Changes

When -march=p5600 with -mmsa, the result of getISARev is 0, so report error. Append p5600 to cases mips32r5.


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

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/Mips.cpp (+1-1)
  • (modified) clang/test/Driver/mips-abi.c (+14)
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 08f9e3c29d1ed..193a2035873ae 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -72,7 +72,7 @@ unsigned MipsTargetInfo::getISARev() const {
              .Cases("mips32", "mips64", 1)
              .Cases("mips32r2", "mips64r2", "octeon", "octeon+", 2)
              .Cases("mips32r3", "mips64r3", 3)
-             .Cases("mips32r5", "mips64r5", 5)
+             .Cases("mips32r5", "mips64r5", "p5600", 5)
              .Cases("mips32r6", "mips64r6", 6)
              .Default(0);
 }
diff --git a/clang/test/Driver/mips-abi.c b/clang/test/Driver/mips-abi.c
index f131a07888dba..14eb890c74bc0 100644
--- a/clang/test/Driver/mips-abi.c
+++ b/clang/test/Driver/mips-abi.c
@@ -115,6 +115,20 @@
 // MIPS-ARCH-P5600: "-target-cpu" "p5600"
 // MIPS-ARCH-P5600: "-target-abi" "o32"
 //
+// RUN: %clang --target=mips-linux-gnu -### -c %s \
+// RUN:        -march=p5600 -mmsa -mnan=2008 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-MSA %s
+// MIPS-ARCH-P5600-MSA: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600-MSA: "-target-feature" "+msa"
+// MIPS-ARCH-P5600-MSA: "-target-feature" "+fp64"
+//
+// RUN: %clang --target=mips-linux-gnu -### -c %s \
+// RUN:        -march=p5600 -mmsa -mnan=2008 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-NAN2008 %s
+// MIPS-ARCH-P5600-NAN2008: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600-NAN2008: "-target-feature" "+nan2008"
+// MIPS-ARCH-P5600-NAN2008: "-target-feature" "+abs2008"
+//
 // RUN: not %clang --target=mips-linux-gnu -c %s \
 // RUN:        -march=p5600 -mabi=64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-N64 %s

@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/pr-subscribers-clang-driver

Author: None (yingopq)

Changes

When -march=p5600 with -mmsa, the result of getISARev is 0, so report error. Append p5600 to cases mips32r5.


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

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/Mips.cpp (+1-1)
  • (modified) clang/test/Driver/mips-abi.c (+14)
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 08f9e3c29d1ed..193a2035873ae 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -72,7 +72,7 @@ unsigned MipsTargetInfo::getISARev() const {
              .Cases("mips32", "mips64", 1)
              .Cases("mips32r2", "mips64r2", "octeon", "octeon+", 2)
              .Cases("mips32r3", "mips64r3", 3)
-             .Cases("mips32r5", "mips64r5", 5)
+             .Cases("mips32r5", "mips64r5", "p5600", 5)
              .Cases("mips32r6", "mips64r6", 6)
              .Default(0);
 }
diff --git a/clang/test/Driver/mips-abi.c b/clang/test/Driver/mips-abi.c
index f131a07888dba..14eb890c74bc0 100644
--- a/clang/test/Driver/mips-abi.c
+++ b/clang/test/Driver/mips-abi.c
@@ -115,6 +115,20 @@
 // MIPS-ARCH-P5600: "-target-cpu" "p5600"
 // MIPS-ARCH-P5600: "-target-abi" "o32"
 //
+// RUN: %clang --target=mips-linux-gnu -### -c %s \
+// RUN:        -march=p5600 -mmsa -mnan=2008 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-MSA %s
+// MIPS-ARCH-P5600-MSA: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600-MSA: "-target-feature" "+msa"
+// MIPS-ARCH-P5600-MSA: "-target-feature" "+fp64"
+//
+// RUN: %clang --target=mips-linux-gnu -### -c %s \
+// RUN:        -march=p5600 -mmsa -mnan=2008 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-NAN2008 %s
+// MIPS-ARCH-P5600-NAN2008: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600-NAN2008: "-target-feature" "+nan2008"
+// MIPS-ARCH-P5600-NAN2008: "-target-feature" "+abs2008"
+//
 // RUN: not %clang --target=mips-linux-gnu -c %s \
 // RUN:        -march=p5600 -mabi=64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-N64 %s

@yingopq yingopq force-pushed the Fix_bug_issue_91948 branch from 6f4c2dc to 57facf0 Compare March 24, 2025 06:57
Copy link

github-actions bot commented Mar 24, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

When -march=p5600 with -mmsa, the result of getISARev is 0,
so report error. Append p5600 to cases mips32r5.

Fix llvm#91948.
@yingopq yingopq force-pushed the Fix_bug_issue_91948 branch from 57facf0 to 1d02fed Compare March 24, 2025 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' 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.

MIPS: P5600 should use nan2008, fp64, msa
2 participants