Skip to content

[RISCV] Add -mcpu=sifive-p550. #122164

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

Merged
merged 1 commit into from
Jan 9, 2025
Merged

[RISCV] Add -mcpu=sifive-p550. #122164

merged 1 commit into from
Jan 9, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jan 8, 2025

This is the CPU in SiFive's HiFive Premier P550 development board.

Scheduler model will come in a later patch.

This is the CPU in SiFive's HiFive Premier P550 development board.

Scheduler model will come in a later patch.
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:RISC-V clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jan 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Craig Topper (topperc)

Changes

This is the CPU in SiFive's HiFive Premier P550 development board.

Scheduler model will come in a later patch.


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

4 Files Affected:

  • (modified) clang/test/Driver/riscv-cpus.c (+13)
  • (modified) clang/test/Misc/target-invalid-cpu-note/riscv.c (+2)
  • (modified) llvm/docs/ReleaseNotes.md (+1)
  • (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+19)
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 1b09945620f8c3..e97b6940662d9f 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -433,6 +433,19 @@
 // MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkt"
 // MCPU-SIFIVE-P470-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-p550 | FileCheck -check-prefix=MCPU-SIFIVE-P550 %s
+// MCPU-SIFIVE-P550: "-nostdsysteminc" "-target-cpu" "sifive-p550"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+m"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+a"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+f"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+d"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+c"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+zicsr"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+zifencei"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+zba"
+// MCPU-SIFIVE-P550-SAME: "-target-feature" "+zbb"
+// MCPU-SIFIVE-P550-SAME: "-target-abi" "lp64d"
+
 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-p670 | FileCheck -check-prefix=MCPU-SIFIVE-P670 %s
 // MCPU-SIFIVE-P670: "-target-cpu" "sifive-p670"
 // MCPU-SIFIVE-P670-SAME: "-target-feature" "+m"
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index fc8536d99cb804..fb54dcb5b3a93a 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -29,6 +29,7 @@
 // RISCV64-SAME: {{^}}, rocket-rv64
 // RISCV64-SAME: {{^}}, sifive-p450
 // RISCV64-SAME: {{^}}, sifive-p470
+// RISCV64-SAME: {{^}}, sifive-p550
 // RISCV64-SAME: {{^}}, sifive-p670
 // RISCV64-SAME: {{^}}, sifive-s21
 // RISCV64-SAME: {{^}}, sifive-s51
@@ -77,6 +78,7 @@
 // TUNE-RISCV64-SAME: {{^}}, rocket-rv64
 // TUNE-RISCV64-SAME: {{^}}, sifive-p450
 // TUNE-RISCV64-SAME: {{^}}, sifive-p470
+// TUNE-RISCV64-SAME: {{^}}, sifive-p550
 // TUNE-RISCV64-SAME: {{^}}, sifive-p670
 // TUNE-RISCV64-SAME: {{^}}, sifive-s21
 // TUNE-RISCV64-SAME: {{^}}, sifive-s51
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 159bd5cea973f8..3463dc8339fd8f 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -198,6 +198,7 @@ Changes to the RISC-V Backend
 * `-mcpu=syntacore-scr7` was added.
 * `-mcpu=tt-ascalon-d8` was added.
 * `-mcpu=mips-p8700` was added.
+* `-mcpu=sifive-p550` was added.
 * The `Zacas` extension is no longer marked as experimental.
 * Added Smdbltrp, Ssdbltrp extensions to -march.
 * The `Smmpm`, `Smnpm`, `Ssnpm`, `Supm`, and `Sspm` pointer masking extensions
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 61c7c21367036f..6dfed7ddeb9f63 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -321,6 +321,25 @@ def SIFIVE_P470 : RISCVProcessorModel<"sifive-p470", SiFiveP400Model,
                                                   [TuneNoSinkSplatOperands,
                                                    TuneVXRMPipelineFlush])>;
 
+defvar SiFiveP500TuneFeatures = [TuneNoDefaultUnroll,
+                                 TuneConditionalCompressedMoveFusion,
+                                 TuneLUIADDIFusion,
+                                 TuneAUIPCADDIFusion,
+                                 TunePostRAScheduler];
+
+def SIFIVE_P550 : RISCVProcessorModel<"sifive-p550", NoSchedModel,
+                                      [Feature64Bit,
+                                       FeatureStdExtI,
+                                       FeatureStdExtZifencei,
+                                       FeatureStdExtM,
+                                       FeatureStdExtA,
+                                       FeatureStdExtF,
+                                       FeatureStdExtD,
+                                       FeatureStdExtC,
+                                       FeatureStdExtZba,
+                                       FeatureStdExtZbb],
+                                      SiFiveP500TuneFeatures>;
+
 def SIFIVE_P670 : RISCVProcessorModel<"sifive-p670", SiFiveP600Model,
                                       !listconcat(RVA22U64Features,
                                       [FeatureStdExtV,

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@topperc topperc merged commit 5d03235 into llvm:main Jan 9, 2025
13 checks passed
@topperc topperc deleted the pr/p550-cpu branch January 9, 2025 05:02
@camel-cdr
Copy link

camel-cdr commented Jan 9, 2025

I thought the P550 was supposed to support RV64GCB, but that would require Zbs support, which isn't listed here.

@topperc
Copy link
Collaborator Author

topperc commented Jan 9, 2025

I thought the P550 was supposed to support RV64GCB, but that would require Zbs support, which isn't listed here.

The P550 version in the HiFive Premier board does not support Zbs. ISA string from /proc/cpuinfo is rv64imafdch_zicsr_zifencei_zba_zbb_sscofpmf

@wangpc-pp
Copy link
Contributor

I thought the P550 was supposed to support RV64GCB, but that would require Zbs support, which isn't listed here.

The P550 version in the HiFive Premier board does not support Zbs. ISA string from /proc/cpuinfo is rv64imafdch_zicsr_zifencei_zba_zbb_sscofpmf

That's weird. Basically, remving Zbs won't save any area. Is it because the kernel is using wrong device tree without Zbs?

@topperc
Copy link
Collaborator Author

topperc commented Jan 10, 2025

I thought the P550 was supposed to support RV64GCB, but that would require Zbs support, which isn't listed here.

The P550 version in the HiFive Premier board does not support Zbs. ISA string from /proc/cpuinfo is rv64imafdch_zicsr_zifencei_zba_zbb_sscofpmf

That's weird. Basically, remving Zbs won't save any area. Is it because the kernel is using wrong device tree without Zbs?

The hardware does not implement Zbs. SiFive originally announced a P550 based board 2 years ago. The design has been frozen for a while and Zbs was not included. It's taken longer than intended to get a board out.

@topperc
Copy link
Collaborator Author

topperc commented Jan 10, 2025

I thought the P550 was supposed to support RV64GCB, but that would require Zbs support, which isn't listed here.

The P550 version in the HiFive Premier board does not support Zbs. ISA string from /proc/cpuinfo is rv64imafdch_zicsr_zifencei_zba_zbb_sscofpmf

That's weird. Basically, remving Zbs won't save any area. Is it because the kernel is using wrong device tree without Zbs?

The hardware does not implement Zbs. SiFive originally announced a P550 based board 2 years ago. The design has been frozen for a while and Zbs was not included. It's taken longer than intended to get a board out.

The ISA is specified in this document on page 69 https://www.sifive.com/document-file/eic7700x-datasheet available here https://www.sifive.com/boards/hifive-premier-p550

@camel-cdr
Copy link

camel-cdr commented Jan 10, 2025

The ISA is specified in this document too https://www.sifive.com/document-file/eic7700x-datasheet available here https://www.sifive.com/boards/hifive-premier-p550

None of the documentation is consistant nor complete reguarding the ISA:

I wasn't able to find any other documentation reguarding ISA.

@topperc
Copy link
Collaborator Author

topperc commented Jan 10, 2025

The ISA is specified in this document too https://www.sifive.com/document-file/eic7700x-datasheet available here https://www.sifive.com/boards/hifive-premier-p550

None of the documentation is consistant nor complete reguarding the ISA:

I wasn't able to find any other documentation reguarding ISA.

Page 69 of https://www.sifive.com/document-file/eic7700x-datasheet seems to be the best reference. I'll try to get the other documents fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants