Skip to content

Commit 682b1c3

Browse files
RISC-V: Add Synopsys RMX-100 series pipeline description.
This patch introduces the pipeline description for the Synopsys RMX-100 series processor to the RISC-V GCC backend. The RMX-100 has a short, three-stage, in-order execution pipeline with configurable multiply unit options. The option -mmpy-option was added to control which version of the MPY unit the core has and what the latency of multiply instructions should be similar to ARCv2 cores (see gcc/config/arc/arc.opt:60). gcc/ChangeLog: * config/riscv/riscv-cores.def (RISCV_TUNE): Add arc-v-rmx-100-series. * config/riscv/riscv-opts.h (enum riscv_microarchitecture_type): Add arcv_rmx100. (enum arcv_mpy_option_enum): New enum for ARC-V multiply options. * config/riscv/riscv-protos.h (arcv_mpy_1c_bypass_p): New declaration. (arcv_mpy_2c_bypass_p): New declaration. (arcv_mpy_10c_bypass_p): New declaration. * config/riscv/riscv.cc (arcv_mpy_1c_bypass_p): New function. (arcv_mpy_2c_bypass_p): New function. (arcv_mpy_10c_bypass_p): New function. * config/riscv/riscv.md: Add arcv_rmx100. * config/riscv/riscv.opt: New option for RMX-100 multiply unit configuration. * doc/riscv-mtune.texi: Document arc-v-rmx-100-series. * config/riscv/arcv-rmx100.md: New file. Co-authored-by: Artemiy Volkov <artemiyv@acm.org> Co-authored-by: Michiel Derhaeg <michiel@synopsys.com> Signed-off-by: Luis Silva <luiss@synopsys.com>
1 parent 4951c8b commit 682b1c3

8 files changed

Lines changed: 186 additions & 1 deletion

File tree

gcc/config/riscv/arcv-rmx100.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
;; DFA scheduling description of the Synopsys RMX-100 cpu
2+
;; for GNU C compiler
3+
;; Copyright (C) 2025 Free Software Foundation, Inc.
4+
5+
;; This file is part of GCC.
6+
7+
;; GCC is free software; you can redistribute it and/or modify
8+
;; it under the terms of the GNU General Public License as published by
9+
;; the Free Software Foundation; either version 3, or (at your option)
10+
;; any later version.
11+
12+
;; GCC is distributed in the hope that it will be useful,
13+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
;; GNU General Public License for more details.
16+
17+
;; You should have received a copy of the GNU General Public License
18+
;; along with GCC; see the file COPYING3. If not see
19+
;; <http://www.gnu.org/licenses/>.
20+
21+
(define_automaton "arcv_rmx100")
22+
23+
(define_cpu_unit "arcv_rmx100_ALU" "arcv_rmx100")
24+
(define_cpu_unit "arcv_rmx100_FPU" "arcv_rmx100")
25+
(define_cpu_unit "arcv_rmx100_MPY" "arcv_rmx100")
26+
(define_cpu_unit "arcv_rmx100_DIV" "arcv_rmx100")
27+
(define_cpu_unit "arcv_rmx100_DMP" "arcv_rmx100")
28+
29+
;; Instruction reservation for arithmetic instructions.
30+
(define_insn_reservation "arcv_rmx100_alu_arith" 1
31+
(and (eq_attr "tune" "arcv_rmx100")
32+
(eq_attr "type" "unknown, const, arith, shift, slt, multi, auipc, nop,
33+
logical, move, atomic, mvpair, bitmanip, clz, ctz, cpop,
34+
zicond, condmove, clmul, min, max, minu, maxu, rotate"))
35+
"arcv_rmx100_ALU")
36+
37+
(define_insn_reservation "arcv_rmx100_jmp_insn" 1
38+
(and (eq_attr "tune" "arcv_rmx100")
39+
(eq_attr "type" "branch, jump, call, jalr, ret, trap"))
40+
"arcv_rmx100_ALU")
41+
42+
; DIV insn: latency may be overridden by a define_bypass
43+
(define_insn_reservation "arcv_rmx100_div_insn" 35
44+
(and (eq_attr "tune" "arcv_rmx100")
45+
(eq_attr "type" "idiv"))
46+
"arcv_rmx100_DIV*35")
47+
48+
; MPY insn: latency may be overridden by a define_bypass
49+
(define_insn_reservation "arcv_rmx100_mpy32_insn" 9
50+
(and (eq_attr "tune" "arcv_rmx100")
51+
(eq_attr "type" "imul"))
52+
"arcv_rmx100_MPY")
53+
54+
(define_insn_reservation "arcv_rmx100_load_insn" 3
55+
(and (eq_attr "tune" "arcv_rmx100")
56+
(eq_attr "type" "load"))
57+
"arcv_rmx100_DMP,nothing*2")
58+
59+
(define_insn_reservation "arcv_rmx100_store_insn" 1
60+
(and (eq_attr "tune" "arcv_rmx100")
61+
(eq_attr "type" "store,fpstore"))
62+
"arcv_rmx100_DMP")
63+
64+
;; FPU scheduling. FIXME: This is based on the "fast" unit for now, the "slow"
65+
;; option remains to be implemented later (together with the -mfpu flag).
66+
67+
(define_insn_reservation "arcv_rmx100_fpload_insn" 3
68+
(and (eq_attr "tune" "arcv_rmx100")
69+
(eq_attr "type" "fpload"))
70+
"arcv_rmx100_DMP,nothing*2")
71+
72+
(define_insn_reservation "arcv_rmx100_farith_insn" 2
73+
(and (eq_attr "tune" "arcv_rmx100")
74+
(eq_attr "type" "fadd,fcmp"))
75+
"arcv_rmx100_FPU,nothing")
76+
77+
(define_insn_reservation "arcv_rmx100_xfer" 1
78+
(and (eq_attr "tune" "arcv_rmx100")
79+
(eq_attr "type" "fmove,mtc,mfc,fcvt,fcvt_f2i,fcvt_i2f"))
80+
"arcv_rmx100_FPU")
81+
82+
(define_insn_reservation "arcv_rmx100_fmul_insn" 2
83+
(and (eq_attr "tune" "arcv_rmx100")
84+
(eq_attr "type" "fmul"))
85+
"arcv_rmx100_FPU,nothing")
86+
87+
(define_insn_reservation "arcv_rmx100_fmac_insn" 2
88+
(and (eq_attr "tune" "arcv_rmx100")
89+
(eq_attr "type" "fmadd"))
90+
"arcv_rmx100_FPU,nothing")
91+
92+
(define_insn_reservation "arcv_rmx100_fdiv_insn" 10
93+
(and (eq_attr "tune" "arcv_rmx100")
94+
(eq_attr "type" "fdiv,fsqrt"))
95+
"arcv_rmx100_FPU")
96+
97+
98+
(define_bypass 1 "arcv_rmx100_mpy32_insn"
99+
"arcv_rmx100_*" "arcv_mpy_1c_bypass_p")
100+
(define_bypass 2 "arcv_rmx100_mpy32_insn"
101+
"arcv_rmx100_*" "arcv_mpy_2c_bypass_p")
102+
103+
(define_bypass 9 "arcv_rmx100_div_insn" "arcv_rmx100_*" "arcv_mpy_1c_bypass_p")
104+
(define_bypass 9 "arcv_rmx100_div_insn" "arcv_rmx100_*" "arcv_mpy_2c_bypass_p")

gcc/config/riscv/riscv-cores.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ RISCV_TUNE("xt-c920v2", generic, generic_ooo_tune_info)
5151
RISCV_TUNE("xiangshan-nanhu", xiangshan, xiangshan_nanhu_tune_info)
5252
RISCV_TUNE("xiangshan-kunminghu", xiangshan, generic_ooo_tune_info)
5353
RISCV_TUNE("spacemit-x60", spacemit_x60, spacemit_x60_tune_info)
54+
RISCV_TUNE("arc-v-rmx-100-series", arcv_rmx100, arcv_rmx100_tune_info)
5455
RISCV_TUNE("arc-v-rhx-100-series", arcv_rhx100, arcv_rhx100_tune_info)
5556
RISCV_TUNE("generic-ooo", generic_ooo, generic_ooo_tune_info)
5657
RISCV_TUNE("size", generic, optimize_size_tune_info)

gcc/config/riscv/riscv-opts.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ enum riscv_microarchitecture_type {
6565
andes_23_series,
6666
andes_45_series,
6767
spacemit_x60,
68+
arcv_rmx100,
6869
arcv_rhx100,
6970
};
7071
extern enum riscv_microarchitecture_type riscv_microarchitecture;
@@ -93,6 +94,13 @@ enum rvv_max_lmul_enum {
9394
RVV_CONV_DYNAMIC = 10
9495
};
9596

97+
/* ARC-V multiply option. */
98+
enum arcv_mpy_option_enum {
99+
ARCV_MPY_OPTION_1C = 1,
100+
ARCV_MPY_OPTION_2C = 2,
101+
ARCV_MPY_OPTION_10C = 8,
102+
};
103+
96104
enum riscv_multilib_select_kind {
97105
/* Select multilib by builtin way. */
98106
select_by_builtin,

gcc/config/riscv/riscv-protos.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ extern int arcv_sched_adjust_priority (rtx_insn *, int);
849849
extern int arcv_sched_adjust_cost (rtx_insn *, int, int);
850850
extern bool arcv_can_issue_more_p (int, int);
851851
extern int arcv_sched_variable_issue (rtx_insn *, int);
852+
extern bool arcv_mpy_1c_bypass_p (rtx_insn *, rtx_insn *);
853+
extern bool arcv_mpy_2c_bypass_p (rtx_insn *, rtx_insn *);
854+
extern bool arcv_mpy_10c_bypass_p (rtx_insn *, rtx_insn *);
852855

853856
extern bool strided_load_broadcast_p (void);
854857
extern bool riscv_prefer_agnostic_p (void);

gcc/config/riscv/riscv.cc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,31 @@ static const struct riscv_tune_param andes_45_tune_info = {
838838
true, /* prefer-agnostic. */
839839
};
840840

841+
/* Costs to use when optimizing for Synopsys RMX-100. */
842+
static const struct riscv_tune_param arcv_rmx100_tune_info = {
843+
{COSTS_N_INSNS (2), COSTS_N_INSNS (2)}, /* fp_add */
844+
{COSTS_N_INSNS (2), COSTS_N_INSNS (2)}, /* fp_mul */
845+
{COSTS_N_INSNS (17), COSTS_N_INSNS (17)}, /* fp_div */
846+
{COSTS_N_INSNS (2), COSTS_N_INSNS (2)}, /* int_mul */
847+
{COSTS_N_INSNS (17), COSTS_N_INSNS (17)}, /* int_div */
848+
1, /* issue_rate */
849+
4, /* branch_cost */
850+
2, /* memory_cost */
851+
4, /* fmv_cost */
852+
false, /* slow_unaligned_access */
853+
false, /* vector_unaligned_access */
854+
false, /* use_divmod_expansion */
855+
false, /* overlap_op_by_pieces */
856+
true, /* use_zero_stride_load */
857+
false, /* speculative_sched_vsetvl */
858+
RISCV_FUSE_NOTHING, /* fusible_ops */
859+
NULL, /* vector cost */
860+
NULL, /* function_align */
861+
NULL, /* jump_align */
862+
NULL, /* loop_align */
863+
true, /* prefer-agnostic. */
864+
};
865+
841866
/* Costs to use when optimizing for Synopsys RHX-100. */
842867
static const struct riscv_tune_param arcv_rhx100_tune_info = {
843868
{COSTS_N_INSNS (4), COSTS_N_INSNS (5)}, /* fp_add */
@@ -10731,6 +10756,30 @@ riscv_store_data_bypass_p (rtx_insn *out_insn, rtx_insn *in_insn)
1073110756
return store_data_bypass_p (out_insn, in_insn);
1073210757
}
1073310758

10759+
/* Implement one boolean function for each of the values of the
10760+
arcv_mpy_option enum, for the needs of arcv-rmx100.md. */
10761+
10762+
bool
10763+
arcv_mpy_1c_bypass_p (rtx_insn *out_insn ATTRIBUTE_UNUSED,
10764+
rtx_insn *in_insn ATTRIBUTE_UNUSED)
10765+
{
10766+
return arcv_mpy_option == ARCV_MPY_OPTION_1C;
10767+
}
10768+
10769+
bool
10770+
arcv_mpy_2c_bypass_p (rtx_insn *out_insn ATTRIBUTE_UNUSED,
10771+
rtx_insn *in_insn ATTRIBUTE_UNUSED)
10772+
{
10773+
return arcv_mpy_option == ARCV_MPY_OPTION_2C;
10774+
}
10775+
10776+
bool
10777+
arcv_mpy_10c_bypass_p (rtx_insn *out_insn ATTRIBUTE_UNUSED,
10778+
rtx_insn *in_insn ATTRIBUTE_UNUSED)
10779+
{
10780+
return arcv_mpy_option == ARCV_MPY_OPTION_10C;
10781+
}
10782+
1073410783
/* Implement TARGET_SECONDARY_MEMORY_NEEDED.
1073510784

1073610785
When floating-point registers are wider than integer ones, moves between

gcc/config/riscv/riscv.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@
675675
(define_attr "tune"
676676
"generic,sifive_7,sifive_p400,sifive_p600,xiangshan,generic_ooo,mips_p8700,
677677
tt_ascalon_d8,andes_25_series,andes_23_series,andes_45_series,spacemit_x60,
678-
arcv_rhx100"
678+
arcv_rmx100,arcv_rhx100"
679679
(const (symbol_ref "((enum attr_tune) riscv_microarchitecture)")))
680680

681681
;; Describe a user's asm statement.
@@ -5125,4 +5125,5 @@
51255125
(include "andes-25-series.md")
51265126
(include "andes-45-series.md")
51275127
(include "spacemit-x60.md")
5128+
(include "arcv-rmx100.md")
51285129
(include "arcv-rhx100.md")

gcc/config/riscv/riscv.opt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,20 @@ Specifies whether the fence.tso instruction should be used.
423423
mautovec-segment
424424
Target Integer Var(riscv_mautovec_segment) Init(1)
425425
Enable (default) or disable generation of vector segment load/store instructions.
426+
427+
Enum
428+
Name(arcv_mpy_option) Type(enum arcv_mpy_option_enum)
429+
Valid arguments to -mmpy_option=:
430+
431+
EnumValue
432+
Enum(arcv_mpy_option) String(1c) Value(ARCV_MPY_OPTION_1C)
433+
434+
EnumValue
435+
Enum(arcv_mpy_option) String(2c) Value(ARCV_MPY_OPTION_2C)
436+
437+
EnumValue
438+
Enum(arcv_mpy_option) String(10c) Value(ARCV_MPY_OPTION_10C)
439+
440+
mmpy-option=
441+
Target RejectNegative Joined Enum(arcv_mpy_option) Var(arcv_mpy_option) Init(ARCV_MPY_OPTION_2C)
442+
The type of MPY unit used by the RMX-100 core (to be used in combination with -mtune=arc-v-rmx-100-series) (default: 2c).

gcc/doc/riscv-mtune.texi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ particular CPU name. Permissible values for this option are:
5252

5353
@samp{spacemit-x60},
5454

55+
@samp{arc-v-rmx-100-series},
56+
5557
@samp{arc-v-rhx-100-series},
5658

5759
@samp{generic-ooo},

0 commit comments

Comments
 (0)