Skip to content

Commit a164e36

Browse files
artemiy-volkovMichielDerhaeg
authored andcommitted
arcv: add scheduling information for the Synopsys RMX-100 CPU
This commit introduces a new -mtune=rmx100 tuning option together with relevant scheduler definitions. Instruction latencies and costs are based on the "RMX-100 Technical Reference Manual" document (revision 0.4, 13 September 2023) and are subject to change. The changes have been verified by running the Dhrystone and Coremark benchmarks and observing expected (small) improvements compared to the -mtune=generic results. Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
1 parent e520fe0 commit a164e36

File tree

6 files changed

+140
-1
lines changed

6 files changed

+140
-1
lines changed

gcc/config/riscv/arcv-rmx100.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
;; DFA scheduling description of the Synopsys RMX-100 cpu
2+
;; for GNU C compiler
3+
;; Copyright (C) 2023 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_CSR" "arcv_rmx100")
25+
(define_cpu_unit "arcv_rmx100_FPU" "arcv_rmx100")
26+
(define_cpu_unit "arcv_rmx100_MPY" "arcv_rmx100")
27+
(define_cpu_unit "arcv_rmx100_DIV" "arcv_rmx100")
28+
(define_cpu_unit "arcv_rmx100_DMP" "arcv_rmx100")
29+
30+
;; Instruction reservation for arithmetic instructions.
31+
(define_insn_reservation "arcv_rmx100_alu_arith" 1
32+
(and (eq_attr "tune" "arcv_rmx100")
33+
(eq_attr "type" "unknown, const, arith, shift, slt, multi, auipc, nop,
34+
logical, move, atomic, mvpair, bitmanip, clz, ctz, cpop,
35+
zicond, condmove, clmul, min, max, minu, maxu, rotate"))
36+
"arcv_rmx100_ALU")
37+
38+
(define_insn_reservation "arcv_rmx100_jmp_insn" 1
39+
(and (eq_attr "tune" "arcv_rmx100")
40+
(eq_attr "type" "branch, jump, call, jalr, ret, trap"))
41+
"arcv_rmx100_ALU")
42+
43+
; DIV insn: latency may be overridden by a define_bypass
44+
(define_insn_reservation "arcv_rmx100_div_insn" 35
45+
(and (eq_attr "tune" "arcv_rmx100")
46+
(eq_attr "type" "idiv"))
47+
"arcv_rmx100_DIV*35")
48+
49+
; MPY insn: latency may be overridden by a define_bypass
50+
(define_insn_reservation "arcv_rmx100_mpy32_insn" 9
51+
(and (eq_attr "tune" "arcv_rmx100")
52+
(eq_attr "type" "imul"))
53+
"arcv_rmx100_MPY")
54+
55+
(define_insn_reservation "arcv_rmx100_load_insn" 3
56+
(and (eq_attr "tune" "arcv_rmx100")
57+
(eq_attr "type" "load,fpload"))
58+
"arcv_rmx100_DMP,nothing*2")
59+
60+
(define_insn_reservation "arcv_rmx100_store_insn" 1
61+
(and (eq_attr "tune" "arcv_rmx100")
62+
(eq_attr "type" "store,fpstore"))
63+
"arcv_rmx100_DMP")
64+
65+
(define_insn_reservation "arcv_rmx100_farith_insn" 2
66+
(and (eq_attr "tune" "arcv_rmx100")
67+
(eq_attr "type" "fadd,fmul,fmadd,fcmp"))
68+
"arcv_rmx100_FPU*2")
69+
70+
(define_insn_reservation "arcv_rmx100_fdiv_insn" 17
71+
(and (eq_attr "tune" "arcv_rmx100")
72+
(eq_attr "type" "fdiv,fsqrt"))
73+
"arcv_rmx100_FPU*17")
74+
75+
(define_insn_reservation "arcv_rmx100_xfer" 2
76+
(and (eq_attr "tune" "arcv_rmx100")
77+
(eq_attr "type" "fmove,mtc,mfc,fcvt,fcvt_f2i,fcvt_i2f"))
78+
"arcv_rmx100_FPU*2")
79+
80+
;;(define_insn_reservation "core" 1
81+
;; (eq_attr "type" "block, brk, dmb, flag, lr, sr, sync")
82+
;; "arcv_rmx100_ALU0 + arcv_rmx100_ALU1 + arcv_rmx100_DMP + arcv_rmx100_MPY + arcv_rmx100_MPY64 + arcv_rmx100_DIV")
83+
84+
(define_insn_reservation "arcv_rmx100_fmul_half" 5
85+
(and (eq_attr "tune" "arcv_rmx100")
86+
(and (eq_attr "type" "fadd,fmul,fmadd")
87+
(eq_attr "mode" "HF")))
88+
"arcv_rmx100_FPU")
89+
90+
(define_insn_reservation "arcv_rmx100_fmul_single" 5
91+
(and (eq_attr "tune" "arcv_rmx100")
92+
(and (eq_attr "type" "fadd,fmul,fmadd")
93+
(eq_attr "mode" "SF")))
94+
"arcv_rmx100_FPU")
95+
96+
(define_insn_reservation "arcv_rmx100_fmul_double" 7
97+
(and (eq_attr "tune" "arcv_rmx100")
98+
(and (eq_attr "type" "fadd,fmul,fmadd")
99+
(eq_attr "mode" "DF")))
100+
"arcv_rmx100_FPU")
101+
102+
(define_insn_reservation "arcv_rmx100_fdiv" 20
103+
(and (eq_attr "tune" "arcv_rmx100")
104+
(eq_attr "type" "fdiv"))
105+
"arcv_rmx100_FPU*20")
106+
107+
(define_insn_reservation "arcv_rmx100_fsqrt" 25
108+
(and (eq_attr "tune" "arcv_rmx100")
109+
(eq_attr "type" "fsqrt"))
110+
"arcv_rmx100_FPU*25")

gcc/config/riscv/riscv-cores.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ RISCV_TUNE("xt-c920", generic, generic_ooo_tune_info)
5050
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)
53+
RISCV_TUNE("arc-v-rmx-100-series", arcv_rmx100, arcv_rmx100_tune_info)
5354
RISCV_TUNE("generic-ooo", generic_ooo, generic_ooo_tune_info)
5455
RISCV_TUNE("size", generic, optimize_size_tune_info)
5556
RISCV_TUNE("mips-p8700", mips_p8700, mips_p8700_tune_info)

gcc/config/riscv/riscv-opts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ enum riscv_microarchitecture_type {
6161
generic_ooo,
6262
mips_p8700,
6363
tt_ascalon_d8,
64+
arcv_rmx100,
6465
};
6566
extern enum riscv_microarchitecture_type riscv_microarchitecture;
6667

gcc/config/riscv/riscv.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,30 @@ static const struct riscv_tune_param tt_ascalon_d8_tune_info = {
685685
true, /* prefer-agnostic. */
686686
};
687687

688+
/* Costs to use when optimizing for Synopsys RMX-100. */
689+
static const struct riscv_tune_param arcv_rmx100_tune_info = {
690+
{COSTS_N_INSNS (2), COSTS_N_INSNS (2)}, /* fp_add */
691+
{COSTS_N_INSNS (2), COSTS_N_INSNS (2)}, /* fp_mul */
692+
{COSTS_N_INSNS (17), COSTS_N_INSNS (17)}, /* fp_div */
693+
{COSTS_N_INSNS (2), COSTS_N_INSNS (2)}, /* int_mul */
694+
{COSTS_N_INSNS (17), COSTS_N_INSNS (17)}, /* int_div */
695+
1, /* issue_rate */
696+
4, /* branch_cost */
697+
2, /* memory_cost */
698+
4, /* fmv_cost */
699+
false, /* slow_unaligned_access */
700+
false, /* vector_unaligned_access */
701+
false, /* use_divmod_expansion */
702+
false, /* overlap_op_by_pieces */
703+
true, /* use_zero_stride_load */
704+
false, /* speculative_sched_vsetvl */
705+
RISCV_FUSE_NOTHING, /* fusible_ops */
706+
NULL, /* vector cost */
707+
NULL, /* function_align */
708+
NULL, /* jump_align */
709+
NULL, /* loop_align */
710+
};
711+
688712
/* Costs to use when optimizing for size. */
689713
static const struct riscv_tune_param optimize_size_tune_info = {
690714
{COSTS_N_INSNS (1), COSTS_N_INSNS (1)}, /* fp_add */

gcc/config/riscv/riscv.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@
672672
;; Microarchitectures we know how to tune for.
673673
;; Keep this in sync with enum riscv_microarchitecture.
674674
(define_attr "tune"
675-
"generic,sifive_7,sifive_p400,sifive_p600,xiangshan,generic_ooo,mips_p8700,tt_ascalon_d8"
675+
"generic,sifive_7,sifive_p400,sifive_p600,xiangshan,generic_ooo,mips_p8700,tt_ascalon_d8,arcv_rmx100"
676676
(const (symbol_ref "((enum attr_tune) riscv_microarchitecture)")))
677677

678678
;; Describe a user's asm statement.
@@ -4990,3 +4990,4 @@
49904990
(include "generic-vector-ooo.md")
49914991
(include "generic-ooo.md")
49924992
(include "tt-ascalon-d8.md")
4993+
(include "arcv-rmx100.md")

gcc/doc/riscv-mtune.texi

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

5151
@samp{xiangshan-kunminghu},
5252

53+
@samp{arc-v-rmx-100-series},
54+
5355
@samp{generic-ooo},
5456

5557
@samp{size},

0 commit comments

Comments
 (0)