Skip to content

Commit a874174

Browse files
committed
[RISCV] Add Hazard3 Core as taped out for RP2350
Luke Wren's Hazard3 is a configurable, open-source 32-bit RISC-V core. The core's source code and docs are available on github: https://github.com/wren6991/hazard3 This is the RISC-V core used in the RP2350, a recently announced SoC by Raspberry Pi (which also contains Arm cores): https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf We have agreed to name this `-mcpu` option `rp2350-hazard3`, and it reflects exactly the options configured in the RP2350 chips. Notably, the Zbc is not configured, and nor is B because the `misa.B` bit is not either.
1 parent 0e9579c commit a874174

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

clang/test/Driver/riscv-cpus.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,21 @@
402402
// MCPU-SIFIVE-P670-SAME: "-target-feature" "+zvkt"
403403
// MCPU-SIFIVE-P670-SAME: "-target-abi" "lp64d"
404404

405+
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rp2350-hazard3 | FileCheck -check-prefix=MCPU-HAZARD3 %s
406+
// MCPU-HAZARD3: "-target-cpu" "rp2350-hazard3"
407+
// MCPU-HAZARD3-SAME: "-target-feature" "+m"
408+
// MCPU-HAZARD3-SAME: "-target-feature" "+a"
409+
// MCPU-HAZARD3-SAME: "-target-feature" "+c"
410+
// MCPU-HAZARD3-SAME: "-target-feature" "+zicsr"
411+
// MCPU-HAZARD3-SAME: "-target-feature" "+zifencei"
412+
// MCPU-HAZARD3-SAME: "-target-feature" "+zcb"
413+
// MCPU-HAZARD3-SAME: "-target-feature" "+zcmp"
414+
// MCPU-HAZARD3-SAME: "-target-feature" "+zba"
415+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbb"
416+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbkb"
417+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbs"
418+
// MCPU-HAZARD3-SAME: "-target-abi" "ilp32"
419+
405420
// Check failed cases
406421

407422
// RUN: not %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | FileCheck -check-prefix=FAIL-MCPU-NAME %s

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// RISCV32-NEXT: note: valid target CPU values are:
66
// RISCV32-SAME: generic-rv32,
77
// RISCV32-SAME: rocket-rv32,
8+
// RISCV32-SAME: rp2350-hazard3,
89
// RISCV32-SAME: sifive-e20,
910
// RISCV32-SAME: sifive-e21,
1011
// RISCV32-SAME: sifive-e24,
@@ -46,6 +47,7 @@
4647
// TUNE-RISCV32-NEXT: note: valid target CPU values are:
4748
// TUNE-RISCV32-SAME: generic-rv32,
4849
// TUNE-RISCV32-SAME: rocket-rv32,
50+
// TUNE-RISCV32-SAME: rp2350-hazard3,
4951
// TUNE-RISCV32-SAME: sifive-e20,
5052
// TUNE-RISCV32-SAME: sifive-e21,
5153
// TUNE-RISCV32-SAME: sifive-e24,

llvm/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Changes to the RISC-V Backend
108108
fill value) rather than NOPs.
109109
* Added Syntacore SCR4 and SCR5 CPUs: ``-mcpu=syntacore-scr4/5-rv32/64``
110110
* ``-mcpu=sifive-p470`` was added.
111+
* Added Hazard3 CPU: ``-mcpu=hazard3`` (32-bit only).
111112
* Fixed length vector support using RVV instructions now requires VLEN>=64. This
112113
means Zve32x and Zve32f will also require Zvl64b. The prior support was
113114
largely untested.

llvm/lib/Target/RISCV/RISCVProcessors.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,19 @@ def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
454454
FeatureStdExtZvkt,
455455
FeatureStdExtZvl256b]),
456456
[TuneDLenFactor2]>;
457+
458+
def RP2350_HAZARD3 : RISCVProcessorModel<"rp2350-hazard3",
459+
NoSchedModel,
460+
[Feature32Bit,
461+
FeatureStdExtI,
462+
FeatureStdExtM,
463+
FeatureStdExtA,
464+
FeatureStdExtC,
465+
FeatureStdExtZicsr,
466+
FeatureStdExtZifencei,
467+
FeatureStdExtZba,
468+
FeatureStdExtZbb,
469+
FeatureStdExtZbs,
470+
FeatureStdExtZbkb,
471+
FeatureStdExtZcb,
472+
FeatureStdExtZcmp]>;

0 commit comments

Comments
 (0)