Skip to content

Commit 832ca74

Browse files
authored
[RISCV] Add Andes N45/NX45 processor definition (llvm#136670)
Andes N45/NX45 are 32/64bit in-order dual-issue 8-stage pipeline CPU architecture implementing the RV[32|64]IMAFDC_Zba_Zbb_Zbs ISA extensions. They are developed by Andes Technology https://www.andestech.com, a RISC-V IP provider. The overviews for N45/NX45: https://www.andestech.com/en/products-solutions/andescore-processors/riscv-n45/ https://www.andestech.com/en/products-solutions/andescore-processors/riscv-nx45/ Scheduling model will be implemented in a later PR.
1 parent 1a78ef9 commit 832ca74

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

clang/test/Driver/riscv-cpus.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,3 +692,37 @@
692692

693693
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=syntacore-scr7 | FileCheck -check-prefix=MTUNE-SYNTACORE-SCR7 %s
694694
// MTUNE-SYNTACORE-SCR7: "-tune-cpu" "syntacore-scr7"
695+
696+
// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-n45 | FileCheck -check-prefix=MCPU-ANDES-N45 %s
697+
// MCPU-ANDES-N45: "-target-cpu" "andes-n45"
698+
// MCPU-ANDES-N45-SAME: "-target-feature" "+m"
699+
// MCPU-ANDES-N45-SAME: "-target-feature" "+a"
700+
// MCPU-ANDES-N45-SAME: "-target-feature" "+f"
701+
// MCPU-ANDES-N45-SAME: "-target-feature" "+d"
702+
// MCPU-ANDES-N45-SAME: "-target-feature" "+c"
703+
// MCPU-ANDES-N45-SAME: "-target-feature" "+zicsr"
704+
// MCPU-ANDES-N45-SAME: "-target-feature" "+zifencei"
705+
// MCPU-ANDES-N45-SAME: "-target-feature" "+zba"
706+
// MCPU-ANDES-N45-SAME: "-target-feature" "+zbb"
707+
// MCPU-ANDES-N45-SAME: "-target-feature" "+zbs"
708+
// MCPU-ANDES-N45-SAME: "-target-abi" "ilp32d"
709+
710+
// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=andes-n45 | FileCheck -check-prefix=MTUNE-ANDES-N45 %s
711+
// MTUNE-ANDES-N45: "-tune-cpu" "andes-n45"
712+
713+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=andes-nx45 | FileCheck -check-prefix=MCPU-ANDES-NX45 %s
714+
// MCPU-ANDES-NX45: "-target-cpu" "andes-nx45"
715+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+m"
716+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+a"
717+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+f"
718+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+d"
719+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+c"
720+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+zicsr"
721+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+zifencei"
722+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+zba"
723+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+zbb"
724+
// MCPU-ANDES-NX45-SAME: "-target-feature" "+zbs"
725+
// MCPU-ANDES-NX45-SAME: "-target-abi" "lp64d"
726+
727+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-nx45 | FileCheck -check-prefix=MTUNE-ANDES-NX45 %s
728+
// MTUNE-ANDES-NX45: "-tune-cpu" "andes-nx45"

clang/test/Misc/target-invalid-cpu-note/riscv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
66
// RISCV32: error: unknown target CPU 'not-a-cpu'
77
// RISCV32-NEXT: note: valid target CPU values are:
8-
// RISCV32-SAME: {{^}} generic-rv32
8+
// RISCV32-SAME: {{^}} andes-n45
9+
// RISCV32-SAME: {{^}}, generic-rv32
910
// RISCV32-SAME: {{^}}, rocket-rv32
1011
// RISCV32-SAME: {{^}}, rp2350-hazard3
1112
// RISCV32-SAME: {{^}}, sifive-e20
@@ -24,7 +25,8 @@
2425
// RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
2526
// RISCV64: error: unknown target CPU 'not-a-cpu'
2627
// RISCV64-NEXT: note: valid target CPU values are:
27-
// RISCV64-SAME: {{^}} generic-rv64
28+
// RISCV64-SAME: {{^}} andes-nx45
29+
// RISCV64-SAME: {{^}}, generic-rv64
2830
// RISCV64-SAME: {{^}}, mips-p8700
2931
// RISCV64-SAME: {{^}}, rocket-rv64
3032
// RISCV64-SAME: {{^}}, sifive-p450
@@ -52,7 +54,8 @@
5254
// RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
5355
// TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
5456
// TUNE-RISCV32-NEXT: note: valid target CPU values are:
55-
// TUNE-RISCV32-SAME: {{^}} generic-rv32
57+
// TUNE-RISCV32-SAME: {{^}} andes-n45
58+
// TUNE-RISCV32-SAME: {{^}}, generic-rv32
5659
// TUNE-RISCV32-SAME: {{^}}, rocket-rv32
5760
// TUNE-RISCV32-SAME: {{^}}, rp2350-hazard3
5861
// TUNE-RISCV32-SAME: {{^}}, sifive-e20
@@ -75,7 +78,8 @@
7578
// RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
7679
// TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
7780
// TUNE-RISCV64-NEXT: note: valid target CPU values are:
78-
// TUNE-RISCV64-SAME: {{^}} generic-rv64
81+
// TUNE-RISCV64-SAME: {{^}} andes-nx45
82+
// TUNE-RISCV64-SAME: {{^}}, generic-rv64
7983
// TUNE-RISCV64-SAME: {{^}}, mips-p8700
8084
// TUNE-RISCV64-SAME: {{^}}, rocket-rv64
8185
// TUNE-RISCV64-SAME: {{^}}, sifive-p450

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ Changes to the RISC-V Backend
168168
and branch and linker relaxation. This can be disabled with ``.option noexact``,
169169
which is also the default.
170170
* `-mcpu=xiangshan-kunminghu` was added.
171+
* `-mcpu=andes-n45` and `-mcpu=andes-nx45` were added.
171172

172173
Changes to the WebAssembly Backend
173174
----------------------------------

llvm/lib/Target/RISCV/RISCVProcessors.td

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,29 @@ def RP2350_HAZARD3 : RISCVProcessorModel<"rp2350-hazard3",
625625
FeatureStdExtZbkb,
626626
FeatureStdExtZcb,
627627
FeatureStdExtZcmp]>;
628+
629+
def ANDES_N45 : RISCVProcessorModel<"andes-n45",
630+
NoSchedModel,
631+
[Feature32Bit,
632+
FeatureStdExtI,
633+
FeatureStdExtZicsr,
634+
FeatureStdExtZifencei,
635+
FeatureStdExtM,
636+
FeatureStdExtA,
637+
FeatureStdExtF,
638+
FeatureStdExtD,
639+
FeatureStdExtC,
640+
FeatureStdExtB]>;
641+
642+
def ANDES_NX45 : RISCVProcessorModel<"andes-nx45",
643+
NoSchedModel,
644+
[Feature64Bit,
645+
FeatureStdExtI,
646+
FeatureStdExtZicsr,
647+
FeatureStdExtZifencei,
648+
FeatureStdExtM,
649+
FeatureStdExtA,
650+
FeatureStdExtF,
651+
FeatureStdExtD,
652+
FeatureStdExtC,
653+
FeatureStdExtB]>;

0 commit comments

Comments
 (0)