Skip to content

Conversation

@tclin914
Copy link
Contributor

@tclin914 tclin914 commented Jun 5, 2025

Enables the use of -mtune=andes-45-series to generate code optimized with
the Andes 45 series scheduling model and tuning features.

Enables the use of `-mtune=andes-45-series` to generate code optimized with
the Andes 45 series scheduling model and tuning features.
@tclin914 tclin914 requested review from lenary, mshockwave and topperc June 5, 2025 05:31
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:RISC-V labels Jun 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2025

@llvm/pr-subscribers-clang

Author: Jim Lin (tclin914)

Changes

Enables the use of -mtune=andes-45-series to generate code optimized with
the Andes 45 series scheduling model and tuning features.


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

3 Files Affected:

  • (modified) clang/test/Misc/target-invalid-cpu-note/riscv.c (+2)
  • (modified) llvm/docs/ReleaseNotes.md (+1)
  • (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+3)
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index 66952755e9159..d736695b48835 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -77,6 +77,7 @@
 // TUNE-RISCV32-SAME: {{^}}, syntacore-scr3-rv32
 // TUNE-RISCV32-SAME: {{^}}, syntacore-scr4-rv32
 // TUNE-RISCV32-SAME: {{^}}, syntacore-scr5-rv32
+// TUNE-RISCV32-SAME: {{^}}, andes-45-series
 // TUNE-RISCV32-SAME: {{^}}, generic
 // TUNE-RISCV32-SAME: {{^}}, generic-ooo
 // TUNE-RISCV32-SAME: {{^}}, rocket
@@ -114,6 +115,7 @@
 // TUNE-RISCV64-SAME: {{^}}, veyron-v1
 // TUNE-RISCV64-SAME: {{^}}, xiangshan-kunminghu
 // TUNE-RISCV64-SAME: {{^}}, xiangshan-nanhu
+// TUNE-RISCV64-SAME: {{^}}, andes-45-series
 // TUNE-RISCV64-SAME: {{^}}, generic
 // TUNE-RISCV64-SAME: {{^}}, generic-ooo
 // TUNE-RISCV64-SAME: {{^}}, rocket
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 7d734f2e258e6..73f9f8db425ba 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -209,6 +209,7 @@ Changes to the RISC-V Backend
 * `-mcpu=andes-a25` and `-mcpu=andes-ax25` were added.
 * The `Shlcofideleg` extension was added.
 * `-mcpu=sifive-x390` was added.
+* `-mtune=andes-45-series` was added.
 
 Changes to the WebAssembly Backend
 ----------------------------------
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td
index cfc0957ea88f8..de6f0ecfce737 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -722,6 +722,9 @@ def ANDES_AX25 : RISCVProcessorModel<"andes-ax25",
                                       FeatureStdExtZbc,
                                       FeatureVendorXAndesPerf]>;
 
+def ANDES_45 : RISCVTuneProcessorModel<"andes-45-series",
+                                       Andes45Model>;
+
 def ANDES_N45 : RISCVProcessorModel<"andes-n45",
                                     Andes45Model,
                                     [Feature32Bit,

@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2025

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

Author: Jim Lin (tclin914)

Changes

Enables the use of -mtune=andes-45-series to generate code optimized with
the Andes 45 series scheduling model and tuning features.


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

3 Files Affected:

  • (modified) clang/test/Misc/target-invalid-cpu-note/riscv.c (+2)
  • (modified) llvm/docs/ReleaseNotes.md (+1)
  • (modified) llvm/lib/Target/RISCV/RISCVProcessors.td (+3)
diff --git a/clang/test/Misc/target-invalid-cpu-note/riscv.c b/clang/test/Misc/target-invalid-cpu-note/riscv.c
index 66952755e9159..d736695b48835 100644
--- a/clang/test/Misc/target-invalid-cpu-note/riscv.c
+++ b/clang/test/Misc/target-invalid-cpu-note/riscv.c
@@ -77,6 +77,7 @@
 // TUNE-RISCV32-SAME: {{^}}, syntacore-scr3-rv32
 // TUNE-RISCV32-SAME: {{^}}, syntacore-scr4-rv32
 // TUNE-RISCV32-SAME: {{^}}, syntacore-scr5-rv32
+// TUNE-RISCV32-SAME: {{^}}, andes-45-series
 // TUNE-RISCV32-SAME: {{^}}, generic
 // TUNE-RISCV32-SAME: {{^}}, generic-ooo
 // TUNE-RISCV32-SAME: {{^}}, rocket
@@ -114,6 +115,7 @@
 // TUNE-RISCV64-SAME: {{^}}, veyron-v1
 // TUNE-RISCV64-SAME: {{^}}, xiangshan-kunminghu
 // TUNE-RISCV64-SAME: {{^}}, xiangshan-nanhu
+// TUNE-RISCV64-SAME: {{^}}, andes-45-series
 // TUNE-RISCV64-SAME: {{^}}, generic
 // TUNE-RISCV64-SAME: {{^}}, generic-ooo
 // TUNE-RISCV64-SAME: {{^}}, rocket
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 7d734f2e258e6..73f9f8db425ba 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -209,6 +209,7 @@ Changes to the RISC-V Backend
 * `-mcpu=andes-a25` and `-mcpu=andes-ax25` were added.
 * The `Shlcofideleg` extension was added.
 * `-mcpu=sifive-x390` was added.
+* `-mtune=andes-45-series` was added.
 
 Changes to the WebAssembly Backend
 ----------------------------------
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td b/llvm/lib/Target/RISCV/RISCVProcessors.td
index cfc0957ea88f8..de6f0ecfce737 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -722,6 +722,9 @@ def ANDES_AX25 : RISCVProcessorModel<"andes-ax25",
                                       FeatureStdExtZbc,
                                       FeatureVendorXAndesPerf]>;
 
+def ANDES_45 : RISCVTuneProcessorModel<"andes-45-series",
+                                       Andes45Model>;
+
 def ANDES_N45 : RISCVProcessorModel<"andes-n45",
                                     Andes45Model,
                                     [Feature32Bit,

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

@tclin914 tclin914 merged commit 2a8c7d3 into llvm:main Jun 6, 2025
15 checks passed
@tclin914 tclin914 deleted the mtune-andes-45-series branch June 6, 2025 03:34
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 6, 2025

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

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

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 :: Misc/target-invalid-cpu-note/riscv.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
not /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc -triple riscv32 -target-cpu not-a-cpu -fsyntax-only /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c --check-prefix RISCV32 # RUN: at line 5
+ not /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc -triple riscv32 -target-cpu not-a-cpu -fsyntax-only /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c
+ /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c --check-prefix RISCV32
not /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc -triple riscv64 -target-cpu not-a-cpu -fsyntax-only /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c --check-prefix RISCV64 # RUN: at line 27
+ /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c --check-prefix RISCV64
+ not /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc -triple riscv64 -target-cpu not-a-cpu -fsyntax-only /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c
not /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c 2>&1 | /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c --check-prefix TUNE-RISCV32 # RUN: at line 60
+ not /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c
+ /buildbot/worker/arc-folder/build/bin/FileCheck /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c --check-prefix TUNE-RISCV32
/buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c:80:23: error: TUNE-RISCV32-SAME: expected string not found in input
// TUNE-RISCV32-SAME: {{^}}, andes-45-series
                      ^
<stdin>:2:286: note: scanning from here
note: valid target CPU values are: andes-a25, andes-a45, andes-n45, generic-rv32, rocket-rv32, rp2350-hazard3, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, syntacore-scr4-rv32, syntacore-scr5-rv32, generic, generic-ooo, rocket, sifive-7-series
                                                                                                                                                                                                                                                                                             ^
<stdin>:2:315: note: possible intended match here
note: valid target CPU values are: andes-a25, andes-a45, andes-n45, generic-rv32, rocket-rv32, rp2350-hazard3, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, syntacore-scr4-rv32, syntacore-scr5-rv32, generic, generic-ooo, rocket, sifive-7-series
                                                                                                                                                                                                                                                                                                                          ^

Input file: <stdin>
Check file: /buildbot/worker/arc-folder/llvm-project/clang/test/Misc/target-invalid-cpu-note/riscv.c

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

Input was:
<<<<<<
           1: error: unknown target CPU 'not-a-cpu' 
           2: note: valid target CPU values are: andes-a25, andes-a45, andes-n45, generic-rv32, rocket-rv32, rp2350-hazard3, sifive-e20, sifive-e21, sifive-e24, sifive-e31, sifive-e34, sifive-e76, syntacore-scr1-base, syntacore-scr1-max, syntacore-scr3-rv32, syntacore-scr4-rv32, syntacore-scr5-rv32, generic, generic-ooo, rocket, sifive-7-series 
same:80'0                                                                                                                                                                                                                                                                                                  X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
same:80'1                                                                                                                                                                                                                                                                                                                               ?                   possible intended match
>>>>>>

--

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


@tclin914
Copy link
Contributor Author

tclin914 commented Jun 6, 2025

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

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

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

I’m not sure why the test fails to find the string andes-45-series, since it works fine on my local machine.

@mshockwave
Copy link
Member

LLVM Buildbot has detected a new failure on builder arc-builder running on arc-worker while building clang,llvm at step 6 "test-build-unified-tree-check-all".
Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/17084
Here is the relevant piece of the build log for the reference

I’m not sure why the test fails to find the string andes-45-series, since it works fine on my local machine.

I also noticed that the this specific buildbot, arc-builder, tends to throw confusing errors like this when we added a new -mcpu.

@jrtc27
Copy link
Collaborator

jrtc27 commented Jun 6, 2025

LLVM Buildbot has detected a new failure on builder arc-builder running on arc-worker while building clang,llvm at step 6 "test-build-unified-tree-check-all".
Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/17084
Here is the relevant piece of the build log for the reference

I’m not sure why the test fails to find the string andes-45-series, since it works fine on my local machine.

I also noticed that the this specific buildbot, arc-builder, tends to throw confusing errors like this when we added a new -mcpu.

@LilyHe789

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:RISC-V clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants