Skip to content

Commit 5d6d8a2

Browse files
committed
[RISCV] Add SiFive cores to the CPU option
Add the SiFive cores E76 and U74 using the SiFive 7 series microarchitecture. Differential Revision: https://reviews.llvm.org/D88759
1 parent ed88d96 commit 5d6d8a2

File tree

4 files changed

+39
-11
lines changed

4 files changed

+39
-11
lines changed

clang/test/Driver/riscv-cpus.c

+19-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// MCPU-ROCKET64: "-nostdsysteminc" "-target-cpu" "rocket-rv64"
88
// MCPU-ROCKET64: "-target-feature" "+64bit"
99

10-
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=bullet-rv32 | FileCheck -check-prefix=MCPU-BULLET32 %s
11-
// MCPU-BULLET32: "-nostdsysteminc" "-target-cpu" "bullet-rv32"
10+
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-7-rv32 | FileCheck -check-prefix=MCPU-SIFIVE7-32 %s
11+
// MCPU-SIFIVE7-32: "-nostdsysteminc" "-target-cpu" "sifive-7-rv32"
1212

13-
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=bullet-rv64 | FileCheck -check-prefix=MCPU-BULLET64 %s
14-
// MCPU-BULLET64: "-nostdsysteminc" "-target-cpu" "bullet-rv64"
15-
// MCPU-BULLET64: "-target-feature" "+64bit"
13+
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-7-rv64 | FileCheck -check-prefix=MCPU-SIFIVE7-64 %s
14+
// MCPU-SIFIVE7-64: "-nostdsysteminc" "-target-cpu" "sifive-7-rv64"
15+
// MCPU-SIFIVE7-64: "-target-feature" "+64bit"
1616

1717
// mcpu with default march
1818
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck -check-prefix=MCPU-SIFIVE-U54 %s
@@ -28,6 +28,20 @@
2828
// MCPU-ABI-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit"
2929
// MCPU-ABI-SIFIVE-U54: "-target-abi" "lp64"
3030

31+
// mcpu with default march
32+
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-e76 | FileCheck -check-prefix=MCPU-SIFIVE-E76 %s
33+
// MCPU-SIFIVE-E76: "-nostdsysteminc" "-target-cpu" "sifive-e76"
34+
// MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
35+
// MCPU-SIFIVE-E76: "-target-feature" "+c"
36+
// MCPU-SIFIVE-E76: "-target-abi" "lp64d"
37+
38+
// mcpu with mabi option
39+
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u74 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U74 %s
40+
// MCPU-ABI-SIFIVE-U74: "-nostdsysteminc" "-target-cpu" "sifive-u74"
41+
// MCPU-ABI-SIFIVE-U74: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
42+
// MCPU-ABI-SIFIVE-U74: "-target-feature" "+c" "-target-feature" "+64bit"
43+
// MCPU-ABI-SIFIVE-U74: "-target-abi" "lp64"
44+
3145
// march overwrite mcpu's default march
3246
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -march=rv32imc | FileCheck -check-prefix=MCPU-MARCH %s
3347
// MCPU-MARCH: "-nostdsysteminc" "-target-cpu" "sifive-e31" "-target-feature" "+m" "-target-feature" "+c"

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@
191191

192192
// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
193193
// RISCV32: error: unknown target CPU 'not-a-cpu'
194-
// RISCV32: note: valid target CPU values are: generic-rv32, rocket-rv32, bullet-rv32, sifive-e31
194+
// RISCV32: note: valid target CPU values are: generic-rv32, rocket-rv32, sifive-7-rv32, sifive-e31, sifive-e76
195195

196196
// RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
197197
// RISCV64: error: unknown target CPU 'not-a-cpu'
198-
// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, bullet-rv64, sifive-u54
198+
// RISCV64: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-u54, sifive-u74

llvm/include/llvm/Support/RISCVTargetParser.def

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""})
77
PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""})
88
PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""})
99
PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""})
10-
PROC(BULLET_RV32, {"bullet-rv32"}, FK_NONE, {""})
11-
PROC(BULLET_RV64, {"bullet-rv64"}, FK_64BIT, {""})
10+
PROC(BULLET_RV32, {"sifive-7-rv32"}, FK_NONE, {""})
11+
PROC(BULLET_RV64, {"sifive-7-rv64"}, FK_64BIT, {""})
1212
PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"})
1313
PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
14+
PROC(SIFIVE_E76, {"sifive-e76"}, FK_NONE, {"rv32imafc"})
15+
PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
1416

1517
#undef PROC

llvm/lib/Target/RISCV/RISCV.td

+14-2
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
228228
def : ProcessorModel<"rocket-rv32", RocketModel, []>;
229229
def : ProcessorModel<"rocket-rv64", RocketModel, [Feature64Bit]>;
230230

231-
def : ProcessorModel<"bullet-rv32", BulletModel, []>;
232-
def : ProcessorModel<"bullet-rv64", BulletModel, [Feature64Bit]>;
231+
def : ProcessorModel<"sifive-7-rv32", BulletModel, []>;
232+
def : ProcessorModel<"sifive-7-rv64", BulletModel, [Feature64Bit]>;
233233

234234
def : ProcessorModel<"sifive-e31", RocketModel, [FeatureStdExtM,
235235
FeatureStdExtA,
@@ -242,6 +242,18 @@ def : ProcessorModel<"sifive-u54", RocketModel, [Feature64Bit,
242242
FeatureStdExtD,
243243
FeatureStdExtC]>;
244244

245+
def : ProcessorModel<"sifive-e76", BulletModel, [FeatureStdExtM,
246+
FeatureStdExtA,
247+
FeatureStdExtF,
248+
FeatureStdExtC]>;
249+
250+
def : ProcessorModel<"sifive-u74", BulletModel, [Feature64Bit,
251+
FeatureStdExtM,
252+
FeatureStdExtA,
253+
FeatureStdExtF,
254+
FeatureStdExtD,
255+
FeatureStdExtC]>;
256+
245257
//===----------------------------------------------------------------------===//
246258
// Define the RISC-V target.
247259
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)