Skip to content

Commit 043be1e

Browse files
committed
[RISCV] Add Hazard3 CPU
Luke Wren's Hazard3 is an open-source 32-bit RISC-V core. The core's source code and docs are available on github: https://github.com/wren6991/hazard3 The core has just hit 1.0 today, which seems to me to be a good time to add it as a named CPU in LLVM.
1 parent 0e9579c commit 043be1e

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

clang/test/Driver/riscv-cpus.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,23 @@
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=hazard3 | FileCheck -check-prefix=MCPU-HAZARD3 %s
406+
// MCPU-HAZARD3: "-target-cpu" "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" "+b"
411+
// MCPU-HAZARD3-SAME: "-target-feature" "+zicsr"
412+
// MCPU-HAZARD3-SAME: "-target-feature" "+zifencei"
413+
// MCPU-HAZARD3-SAME: "-target-feature" "+zcb"
414+
// MCPU-HAZARD3-SAME: "-target-feature" "+zcmp"
415+
// MCPU-HAZARD3-SAME: "-target-feature" "+zba"
416+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbb"
417+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbc"
418+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbkb"
419+
// MCPU-HAZARD3-SAME: "-target-feature" "+zbs"
420+
// MCPU-HAZARD3-SAME: "-target-abi" "ilp32"
421+
405422
// Check failed cases
406423

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

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,21 @@ def SPACEMIT_X60 : RISCVProcessorModel<"spacemit-x60",
454454
FeatureStdExtZvkt,
455455
FeatureStdExtZvl256b]),
456456
[TuneDLenFactor2]>;
457+
458+
def HAZARD3 : RISCVProcessorModel<"hazard3",
459+
NoSchedModel,
460+
[Feature32Bit,
461+
FeatureStdExtI,
462+
FeatureStdExtM,
463+
FeatureStdExtA,
464+
FeatureStdExtB,
465+
FeatureStdExtC,
466+
FeatureStdExtZicsr,
467+
FeatureStdExtZifencei,
468+
FeatureStdExtZba,
469+
FeatureStdExtZbb,
470+
FeatureStdExtZbc,
471+
FeatureStdExtZbs,
472+
FeatureStdExtZbkb,
473+
FeatureStdExtZcb,
474+
FeatureStdExtZcmp]>;

0 commit comments

Comments
 (0)