Thanks you, Kito!
    After Zmmul finishes the public review and merge into 
riscv/riscv-isa-manuel, I will send a new patch if anything changes.
Liao Shihua


> -----原始邮件-----
&gt; 发件人: "Kito Cheng" <kito.ch...@gmail.com>
&gt; 发送时间: 2022-03-01 21:59:47 (星期二)
&gt; 收件人: "廖仕华" <shi...@iscas.ac.cn>
&gt; 抄送: "GCC Patches" <gcc-patches@gcc.gnu.org>, "Philipp Tomsich" 
<philipp.toms...@vrull.eu>, jiawei <jia...@iscas.ac.cn>
&gt; 主题: Re: [PATCH] RISC-V:Add support for ZMMUL extension
&gt; 
&gt; LGTM for GCC 13, I'll commit that once stage 1 is open again.
&gt; 
&gt; On Mon, Feb 14, 2022 at 10:26 AM <shi...@iscas.ac.cn> wrote:
&gt; &gt;
&gt; &gt; From: LiaoShihua <shi...@iscas.ac.cn>
&gt; &gt;
&gt; &gt;       ZMMUL extension is Multiply only extension for RISC-V.It 
implements the multiplication subset of the M extension.
&gt; &gt;       The encodings are identical to those of the corresponding 
M-extension instructions.
&gt; &gt;       When You both use M extension add ZMMUL extension, it will 
warning "-mdiv cannot use when the ZMMUL extension is present"
&gt; &gt;
&gt; &gt; gcc\ChangeLog:
&gt; &gt;
&gt; &gt;         * common/config/riscv/riscv-common.cc:Add support for ZMMUL 
extension
&gt; &gt;         * config/riscv/riscv-opts.h (MASK_ZMMUL):Likewise
&gt; &gt;         (TARGET_ZMMUL):Likewise
&gt; &gt;         * config/riscv/riscv.cc (riscv_option_override):Likewise
&gt; &gt;         * config/riscv/riscv.md:Likewise
&gt; &gt;         * config/riscv/riscv.opt:Likewise
&gt; &gt; ---
&gt; &gt;  gcc/common/config/riscv/riscv-common.cc |  3 +++
&gt; &gt;  gcc/config/riscv/riscv-opts.h           |  3 +++
&gt; &gt;  gcc/config/riscv/riscv.cc               |  4 +++-
&gt; &gt;  gcc/config/riscv/riscv.md               | 28 
++++++++++++-------------
&gt; &gt;  gcc/config/riscv/riscv.opt              |  3 +++
&gt; &gt;  5 files changed, 26 insertions(+), 15 deletions(-)
&gt; &gt;
&gt; &gt; diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
&gt; &gt; index a904893b9ed..fec6c25eb04 100644
&gt; &gt; --- a/gcc/common/config/riscv/riscv-common.cc
&gt; &gt; +++ b/gcc/common/config/riscv/riscv-common.cc
&gt; &gt; @@ -185,6 +185,8 @@ static const struct riscv_ext_version 
riscv_ext_version_table[] =
&gt; &gt;    {"zvl32768b", ISA_SPEC_CLASS_NONE, 1, 0},
&gt; &gt;    {"zvl65536b", ISA_SPEC_CLASS_NONE, 1, 0},
&gt; &gt;
&gt; &gt; +  {"zmmul", ISA_SPEC_CLASS_NONE, 0, 1},
&gt; &gt; +
&gt; &gt;    /* Terminate the list.  */
&gt; &gt;    {NULL, ISA_SPEC_CLASS_NONE, 0, 0}
&gt; &gt;  };
&gt; &gt; @@ -1080,6 +1082,7 @@ static const riscv_ext_flag_table_t 
riscv_ext_flag_table[] =
&gt; &gt;    {"zvl32768b", &amp;gcc_options::x_riscv_zvl_flags, MASK_ZVL32768B},
&gt; &gt;    {"zvl65536b", &amp;gcc_options::x_riscv_zvl_flags, MASK_ZVL65536B},
&gt; &gt;
&gt; &gt; +  {"zmmul",    &amp;gcc_options::x_riscv_zmmul_subext, MASK_ZMMUL},
&gt; &gt;
&gt; &gt;    {NULL, NULL, 0}
&gt; &gt;  };
&gt; &gt; diff --git a/gcc/config/riscv/riscv-opts.h 
b/gcc/config/riscv/riscv-opts.h
&gt; &gt; index 929e4e3a7c5..47e25628635 100644
&gt; &gt; --- a/gcc/config/riscv/riscv-opts.h
&gt; &gt; +++ b/gcc/config/riscv/riscv-opts.h
&gt; &gt; @@ -136,4 +136,7 @@ enum stack_protector_guard {
&gt; &gt;  #define TARGET_ZVL32768B ((riscv_zvl_flags &amp; MASK_ZVL32768B) != 
0)
&gt; &gt;  #define TARGET_ZVL65536B ((riscv_zvl_flags &amp; MASK_ZVL65536B) != 
0)
&gt; &gt;
&gt; &gt; +#define MASK_ZMMUL      (1 &lt;&lt; 0)
&gt; &gt; +#define TARGET_ZMMUL    ((riscv_zmmul_subext &amp; MASK_ZMMUL) != 0)
&gt; &gt; +
&gt; &gt;  #endif /* ! GCC_RISCV_OPTS_H */
&gt; &gt; diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
&gt; &gt; index 6885b4bbad2..bbd5c288da9 100644
&gt; &gt; --- a/gcc/config/riscv/riscv.cc
&gt; &gt; +++ b/gcc/config/riscv/riscv.cc
&gt; &gt; @@ -4974,8 +4974,10 @@ riscv_option_override (void)
&gt; &gt;
&gt; &gt;    /* The presence of the M extension implies that division 
instructions
&gt; &gt;       are present, so include them unless explicitly disabled.  */
&gt; &gt; -  if (TARGET_MUL &amp;&amp; (target_flags_explicit &amp; MASK_DIV) 
== 0)
&gt; &gt; +  if (!TARGET_ZMMUL &amp;&amp; TARGET_MUL &amp;&amp; 
(target_flags_explicit &amp; MASK_DIV) == 0)
&gt; &gt;      target_flags |= MASK_DIV;
&gt; &gt; +  else if(TARGET_ZMMUL &amp;&amp; TARGET_MUL &amp;&amp; 
(target_flags_explicit &amp; MASK_DIV) == 0)
&gt; &gt; +    warning (0, "%&lt;-mdiv%&gt; cannot use when the %<zmmul%> 
extension is present");
&gt; &gt;    else if (!TARGET_MUL &amp;&amp; TARGET_DIV)
&gt; &gt;      error ("%&lt;-mdiv%&gt; requires %&lt;-march%&gt; to subsume the 
%<m%> extension");
&gt; &gt;
&gt; &gt; diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
&gt; &gt; index b3c5bce842a..6dee2fb681a 100644
&gt; &gt; --- a/gcc/config/riscv/riscv.md
&gt; &gt; +++ b/gcc/config/riscv/riscv.md
&gt; &gt; @@ -756,7 +756,7 @@
&gt; &gt;    [(set (match_operand:SI          0 "register_operand" "=r")
&gt; &gt;         (mult:SI (match_operand:SI 1 "register_operand" " r")
&gt; &gt;                  (match_operand:SI 2 "register_operand" " r")))]
&gt; &gt; -  "TARGET_MUL"
&gt; &gt; +  "TARGET_ZMMUL || TARGET_MUL"
&gt; &gt;    { return TARGET_64BIT ? "mulw\t%0,%1,%2" : "mul\t%0,%1,%2"; }
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "SI")])
&gt; &gt; @@ -765,7 +765,7 @@
&gt; &gt;    [(set (match_operand:DI          0 "register_operand" "=r")
&gt; &gt;         (mult:DI (match_operand:DI 1 "register_operand" " r")
&gt; &gt;                  (match_operand:DI 2 "register_operand" " r")))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;    "mul\t%0,%1,%2"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "DI")])
&gt; &gt; @@ -775,7 +775,7 @@
&gt; &gt;         (mult:GPR (match_operand:GPR 1 "register_operand" " r")
&gt; &gt;                   (match_operand:GPR 2 "register_operand" " r")))
&gt; &gt;     (label_ref (match_operand 3 "" ""))]
&gt; &gt; -  "TARGET_MUL"
&gt; &gt; +  "TARGET_ZMMUL || TARGET_MUL"
&gt; &gt;  {
&gt; &gt;    if (TARGET_64BIT &amp;&amp; <mode>mode == SImode)
&gt; &gt;      {
&gt; &gt; @@ -820,7 +820,7 @@
&gt; &gt;         (mult:GPR (match_operand:GPR 1 "register_operand" " r")
&gt; &gt;                   (match_operand:GPR 2 "register_operand" " r")))
&gt; &gt;     (label_ref (match_operand 3 "" ""))]
&gt; &gt; -  "TARGET_MUL"
&gt; &gt; +  "TARGET_ZMMUL || TARGET_MUL"
&gt; &gt;  {
&gt; &gt;    if (TARGET_64BIT &amp;&amp; <mode>mode == SImode)
&gt; &gt;      {
&gt; &gt; @@ -866,7 +866,7 @@
&gt; &gt;         (sign_extend:DI
&gt; &gt;             (mult:SI (match_operand:SI 1 "register_operand" " r")
&gt; &gt;                      (match_operand:SI 2 "register_operand" " r"))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;    "mulw\t%0,%1,%2"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "SI")])
&gt; &gt; @@ -877,7 +877,7 @@
&gt; &gt;           (match_operator:SI 3 "subreg_lowpart_operator"
&gt; &gt;             [(mult:DI (match_operand:DI 1 "register_operand" " r")
&gt; &gt;                       (match_operand:DI 2 "register_operand" " 
r"))])))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;    "mulw\t%0,%1,%2"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "SI")])
&gt; &gt; @@ -895,7 +895,7 @@
&gt; &gt;    [(set (match_operand:TI                         0 
"register_operand")
&gt; &gt;         (mult:TI (any_extend:TI (match_operand:DI 1 
"register_operand"))
&gt; &gt;                  (any_extend:TI (match_operand:DI 2 
"register_operand"))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;  {
&gt; &gt;    rtx low = gen_reg_rtx (DImode);
&gt; &gt;    emit_insn (gen_muldi3 (low, operands[1], operands[2]));
&gt; &gt; @@ -917,7 +917,7 @@
&gt; &gt;                      (any_extend:TI
&gt; &gt;                        (match_operand:DI 2 "register_operand" " r")))
&gt; &gt;             (const_int 64))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;    "mulh<u>\t%0,%1,%2"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "DI")])
&gt; &gt; @@ -926,7 +926,7 @@
&gt; &gt;    [(set (match_operand:TI                          0 
"register_operand")
&gt; &gt;         (mult:TI (zero_extend:TI (match_operand:DI 1 
"register_operand"))
&gt; &gt;                  (sign_extend:TI (match_operand:DI 2 
"register_operand"))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;  {
&gt; &gt;    rtx low = gen_reg_rtx (DImode);
&gt; &gt;    emit_insn (gen_muldi3 (low, operands[1], operands[2]));
&gt; &gt; @@ -948,7 +948,7 @@
&gt; &gt;                      (sign_extend:TI
&gt; &gt;                        (match_operand:DI 2 "register_operand" " r")))
&gt; &gt;             (const_int 64))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; TARGET_64BIT"
&gt; &gt;    "mulhsu\t%0,%2,%1"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "DI")])
&gt; &gt; @@ -959,7 +959,7 @@
&gt; &gt;                    (match_operand:SI 1 "register_operand" " r"))
&gt; &gt;                  (any_extend:DI
&gt; &gt;                    (match_operand:SI 2 "register_operand" " r"))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; !TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; !TARGET_64BIT"
&gt; &gt;  {
&gt; &gt;    rtx temp = gen_reg_rtx (SImode);
&gt; &gt;    emit_insn (gen_mulsi3 (temp, operands[1], operands[2]));
&gt; &gt; @@ -978,7 +978,7 @@
&gt; &gt;                      (any_extend:DI
&gt; &gt;                        (match_operand:SI 2 "register_operand" " r")))
&gt; &gt;             (const_int 32))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; !TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; !TARGET_64BIT"
&gt; &gt;    "mulh<u>\t%0,%1,%2"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "SI")])
&gt; &gt; @@ -990,7 +990,7 @@
&gt; &gt;                    (match_operand:SI 1 "register_operand" " r"))
&gt; &gt;                  (sign_extend:DI
&gt; &gt;                    (match_operand:SI 2 "register_operand" " r"))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; !TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; !TARGET_64BIT"
&gt; &gt;  {
&gt; &gt;    rtx temp = gen_reg_rtx (SImode);
&gt; &gt;    emit_insn (gen_mulsi3 (temp, operands[1], operands[2]));
&gt; &gt; @@ -1009,7 +1009,7 @@
&gt; &gt;                      (sign_extend:DI
&gt; &gt;                        (match_operand:SI 2 "register_operand" " r")))
&gt; &gt;             (const_int 32))))]
&gt; &gt; -  "TARGET_MUL &amp;&amp; !TARGET_64BIT"
&gt; &gt; +  "(TARGET_ZMMUL || TARGET_MUL) &amp;&amp; !TARGET_64BIT"
&gt; &gt;    "mulhsu\t%0,%2,%1"
&gt; &gt;    [(set_attr "type" "imul")
&gt; &gt;     (set_attr "mode" "SI")])
&gt; &gt; diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
&gt; &gt; index 9fffc08220d..46f695b97d3 100644
&gt; &gt; --- a/gcc/config/riscv/riscv.opt
&gt; &gt; +++ b/gcc/config/riscv/riscv.opt
&gt; &gt; @@ -209,6 +209,9 @@ int riscv_vector_eew_flags
&gt; &gt;  TargetVariable
&gt; &gt;  int riscv_zvl_flags
&gt; &gt;
&gt; &gt; +TargetVariable
&gt; &gt; +int riscv_zmmul_subext
&gt; &gt; +
&gt; &gt;  Enum
&gt; &gt;  Name(isa_spec_class) Type(enum riscv_isa_spec_class)
&gt; &gt;  Supported ISA specs (for use with the -misa-spec= option):
&gt; &gt; --
&gt; &gt; 2.31.1.windows.1
&gt; &gt;
</u></u></mode></mode></m%></zmmul%></shi...@iscas.ac.cn></shi...@iscas.ac.cn></jia...@iscas.ac.cn></philipp.toms...@vrull.eu></gcc-patches@gcc.gnu.org></shi...@iscas.ac.cn></kito.ch...@gmail.com>

Reply via email to