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

[RISCV] Add sifive-p470 processor #102022

Merged
merged 3 commits into from
Aug 7, 2024
Merged

Conversation

michaelmaitland
Copy link
Contributor

This is an OOO core that has a vector unit. For more information see https://www.sifive.com/cores/performance-p450-470.

Use the existing P400 scheduler model. This model is missing accurate vector scheduling support, but it will be added in a follow up patch.

Other tunings can come in future patches too.

This is an OOO core that has a vector unit. For more information see
https://www.sifive.com/cores/performance-p450-470.

Use the existing P400 scheduler model. This model is missing accurate vector
scheduling support, but it will be added in a follow up patch.

Other tunings can come in future patches too.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Aug 5, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 5, 2024

@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-risc-v

Author: Michael Maitland (michaelmaitland)

Changes

This is an OOO core that has a vector unit. For more information see https://www.sifive.com/cores/performance-p450-470.

Use the existing P400 scheduler model. This model is missing accurate vector scheduling support, but it will be added in a follow up patch.

Other tunings can come in future patches too.


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

5 Files Affected:

  • (modified) clang/test/Driver/riscv-cpus.c (+10)
  • (modified) clang/test/Misc/target-invalid-cpu-note.c (+3-2)
  • (modified) llvm/docs/ReleaseNotes.rst (+1)
  • (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (-1)
  • (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+47-5)
diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 7a885cde76d6a..fc87710e0da06 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -304,6 +304,16 @@
 // MCPU-SIFIVE-P450-SAME: "-target-feature" "+zbs"
 // MCPU-SIFIVE-P450-SAME: "-target-abi" "lp64d"
 
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-p470 | FileCheck -check-prefix=MCPU-SIFIVE-P470 %s
+// MCPU-SIFIVE-P470: "-target-cpu" "sifive-p470"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+c" "-target-feature" "+v" "-target-feature" "+zic64b" "-target-feature" "+zicbom" "-target-feature" "+zicbop" "-target-feature" "+zicboz" "-target-feature" "+ziccamoa" "-target-feature" "+ziccif" "-target-feature" "+zicclsm" "-target-feature" "+ziccrse" "-target-feature" "+zicsr" "-target-feature" "+zifencei" "-target-feature" "+zihintntl" "-target-feature" "+zihintpause" "-target-feature" "+zihpm" "-target-feature" "+zmmul" "-target-feature" "+za64rs" "-target-feature" "+zfhmin"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zba" "-target-feature" "+zbb" "-target-feature" "+zbs"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvbb" "-target-feature" "+zvbc"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zve32f" "-target-feature" "+zve32x" "-target-feature" "+zve64d" "-target-feature" "+zve64f" "-target-feature" "+zve64x"
+// MCPU-SIFIVE-P470-SAME: "-target-feature" "+zvkg" "-target-feature" "+zvkn" "-target-feature" "+zvknc" "-target-feature" "+zvkned" "-target-feature" "+zvkng" "-target-feature" "+zvknhb" "-target-feature" "+zvks" "-target-feature" "+zvksc" "-target-feature" "+zvksed" "-target-feature" "+zvksg" "-target-feature" "+zvksh" "-target-feature" "+zvkt"
+// MCPU-SIFIVE-P470-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.c b/clang/test/Misc/target-invalid-cpu-note.c
index b87bced18cb2b..249bea2311549 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p470, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,5 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-p450, sifive-p470, sifive-p670, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, sifive-x280, spacemit-x60, syntacore-scr3-rv64, syntacore-scr4-rv64, veyron-v1, xiangshan-nanhu, generic, rocket, sifive-7-series{{$}}
+
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index a95cb53694e2b..1ed860de6b9dc 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -107,6 +107,7 @@ Changes to the RISC-V Backend
   the required alignment space with a sequence of `0x0` bytes (the requested
   fill value) rather than NOPs.
 * Added Syntacore SCR4 CPUs: ``-mcpu=syntacore-scr4-rv32/64``
+* ``-mcpu=sifive-p470`` was added.
 
 Changes to the WebAssembly Backend
 ----------------------------------
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td
index e278fa3fe3176..5c5e03e7782a5 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1371,7 +1371,6 @@ def NoConditionalMoveFusion  : Predicate<"!Subtarget->hasConditionalMoveFusion()
 
 def TuneSiFive7 : SubtargetFeature<"sifive7", "RISCVProcFamily", "SiFive7",
                                    "SiFive 7-Series processors">;
-
 def TuneVentanaVeyron : SubtargetFeature<"ventana-veyron", "RISCVProcFamily", "VentanaVeyron",
                                          "Ventana Veyron-Series processors">;
 
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 83d27b35cf0da..a118e1fe5e502 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -239,6 +239,12 @@ def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
                                        FeatureStdExtZbb],
                                       SiFiveX280TuneFeatures>;
 
+defvar SiFiveP400TuneFeatures = [TuneNoDefaultUnroll,
+                                 TuneConditionalCompressedMoveFusion,
+                                 TuneLUIADDIFusion,
+                                 TuneAUIPCADDIFusion,
+                                 FeaturePostRAScheduler];
+
 def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", SiFiveP400Model,
                                       [Feature64Bit,
                                        FeatureStdExtI,
@@ -266,11 +272,47 @@ def SIFIVE_P450 : RISCVProcessorModel<"sifive-p450", SiFiveP400Model,
                                        FeatureStdExtZfhmin,
                                        FeatureUnalignedScalarMem,
                                        FeatureUnalignedVectorMem],
-                                      [TuneNoDefaultUnroll,
-                                       TuneConditionalCompressedMoveFusion,
-                                       TuneLUIADDIFusion,
-                                       TuneAUIPCADDIFusion,
-                                       FeaturePostRAScheduler]>;
+                                      SiFiveP400TuneFeatures>;
+
+def SIFIVE_P470 : RISCVProcessorModel<"sifive-p470", SiFiveP400Model,
+                                      [Feature64Bit,
+                                       FeatureStdExtI,
+                                       FeatureStdExtZifencei,
+                                       FeatureStdExtM,
+                                       FeatureStdExtA,
+                                       FeatureStdExtF,
+                                       FeatureStdExtD,
+                                       FeatureStdExtC,
+                                       FeatureVendorXSiFivecdiscarddlone,
+                                       FeatureVendorXSiFivecflushdlone,
+                                       FeatureStdExtZa64rs,
+                                       FeatureStdExtZic64b,
+                                       FeatureStdExtZicbop,
+                                       FeatureStdExtZicbom,
+                                       FeatureStdExtZicboz,
+                                       FeatureStdExtZiccamoa,
+                                       FeatureStdExtZiccif,
+                                       FeatureStdExtZicclsm,
+                                       FeatureStdExtZiccrse,
+                                       FeatureStdExtZihintntl,
+                                       FeatureStdExtZihintpause,
+                                       FeatureStdExtZihpm,
+                                       FeatureStdExtZba,
+                                       FeatureStdExtZbb,
+                                       FeatureStdExtZbs,
+                                       FeatureStdExtZfhmin,
+                                       FeatureStdExtV,
+                                       FeatureStdExtZvl128b,
+                                       FeatureStdExtZvbb,
+                                       FeatureStdExtZvknc,
+                                       FeatureStdExtZvkng,
+                                       FeatureStdExtZvksc,
+                                       FeatureStdExtZvksg,
+                                       FeatureUnalignedScalarMem,
+                                       FeatureUnalignedVectorMem],
+                                      !listconcat(SiFiveP400TuneFeatures,
+                                                  [TuneNoSinkSplatOperands])>;
+
 
 def SIFIVE_P670 : RISCVProcessorModel<"sifive-p670", SiFiveP600Model,
                                       [Feature64Bit,

llvm/lib/Target/RISCV/RISCVFeatures.td Outdated Show resolved Hide resolved
clang/test/Driver/riscv-cpus.c Show resolved Hide resolved
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.

Copy link
Collaborator

@topperc topperc 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
Member

@dtcxzyw dtcxzyw left a comment

Choose a reason for hiding this comment

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

LGTM.

@michaelmaitland michaelmaitland merged commit 0c25f85 into llvm:main Aug 7, 2024
6 of 8 checks passed
@michaelmaitland michaelmaitland deleted the p470 branch August 7, 2024 12:30
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 7, 2024

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-darwin running on doug-worker-3 while building clang,llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/23/builds/1711

Here is the relevant piece of the build log for the reference:

Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'Clang :: Index/create-libclang-parsing-reproducer.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: export LSAN_OPTIONS=detect_leaks=0
+ export LSAN_OPTIONS=detect_leaks=0
+ LSAN_OPTIONS=detect_leaks=0
RUN: at line 2: rm -rf /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp
+ rm -rf /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp
RUN: at line 3: mkdir /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp
+ mkdir /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp
RUN: at line 4: env CINDEXTEST_INVOCATION_EMISSION_PATH=/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp not /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin/c-index-test -test-load-source all /Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c
+ env CINDEXTEST_INVOCATION_EMISSION_PATH=/Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp not /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin/c-index-test -test-load-source all /Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c
libclang: crash detected during parsing: {
  'source_filename' : '(null)'
  'command_line_args' : ['clang', '/Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c'],
  'unsaved_files' : [],
  'options' : 1,
}
Unable to load translation unit!
Failure: libclang crashed
RUN: at line 5: /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin/clang -cc1gen-reproducer /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp/libclang-* -v | /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin/FileCheck /Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c
+ /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin/clang -cc1gen-reproducer /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/tools/clang/test/Index/Output/create-libclang-parsing-reproducer.c.tmp/libclang-188f6c4dd4b6 -v
+ /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin/FileCheck /Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c
clang version 20.0.0git (https://github.com/llvm/llvm-project.git 0c25f85e5b88102363c0cd55e1946053d5827e99)
Target: x86_64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Volumes/RAMDisk/buildbot-root/x86_64-darwin/build/bin
Build config: +assertions
/Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c:21:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: "files":["{{.*}}.c","{{.*}}.sh"]
               ^
<stdin>:3:2: note: scanning from here
{
 ^
<stdin>:4:1: note: possible intended match here
"files":[]
^

Input file: <stdin>
Check file: /Volumes/RAMDisk/buildbot-root/x86_64-darwin/llvm-project/clang/test/Index/create-libclang-parsing-reproducer.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: REPRODUCER METAINFO: {"libclang.operation": "parse", "libclang.opts": "1"} 
           2: REPRODUCER: 
           3: { 
...

@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 7, 2024

LLVM Buildbot has detected a new failure on builder clang-arm64-windows-msvc running on linaro-armv8-windows-msvc-04 while building clang,llvm at step 5 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/161/builds/1124

Here is the relevant piece of the build log for the reference:

Step 5 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'Clang :: PCH/unsafe-buffer-usage-pragma-pch-cross-files-2.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
rm -rf C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\test\PCH\Output\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp.tmp
# executed command: rm -rf 'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\test\PCH\Output\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp.tmp'
# RUN: at line 2
mkdir -p C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\test\PCH\Output\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp.tmp
# executed command: mkdir -p 'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\test\PCH\Output\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp.tmp'
# RUN: at line 3
split-file C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\clang\test\PCH\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\test\PCH\Output\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp.tmp
# executed command: split-file 'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\clang\test\PCH\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp' 'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\tools\clang\test\PCH\Output\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp.tmp'
# .---command stderr------------
# | split-file: error: C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\clang\test\PCH\unsafe-buffer-usage-pragma-pch-cross-files-2.cpp: permission denied
# `-----------------------------
# error: command failed with exit status: 1

--

********************


TIFitis pushed a commit that referenced this pull request Aug 8, 2024
This is an OOO core that has a vector unit. For more information see
https://www.sifive.com/cores/performance-p450-470.

Use the existing P400 scheduler model. This model is missing accurate
vector scheduling support, but it will be added in a follow up patch.

Other tunings can come in future patches too.
kstoimenov pushed a commit to kstoimenov/llvm-project that referenced this pull request Aug 15, 2024
This is an OOO core that has a vector unit. For more information see
https://www.sifive.com/cores/performance-p450-470.

Use the existing P400 scheduler model. This model is missing accurate
vector scheduling support, but it will be added in a follow up patch.

Other tunings can come in future patches too.
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.

6 participants