On 9/2/25 12:59 AM, Kuan-Lin Chen wrote:
This patch adds support for the XAndesperf ISA extension.
The 32-bit AndeStar V5 extension includes branch instructions,
load effective address instructions, and string processing
instructions for performance improvement.
New INSN patterns are added into the new file andes.md
as a seprated vender extension.

gcc/ChangeLog:

        * config/riscv/constraints.md (Ou07): New constraint.
        (ads_Bext): New constraint.
        * config/riscv/iterators.md (ANYLE32): New iterator.
        (sizen): New iterator.
        (sh_limit): New iterator.
        (sh_bit): New iterator.
        (cs): New iterator.
        * config/riscv/predicates.md (ads_branch_bbcs_operand): New predicate.
        (ads_branch_bimm_operand): New predicate.
        (ads_imm_extract_operand): New predicate.
        (ads_extract_size_imm_si): New predicate.
        (ads_extract_size_imm_di): New predicate.
        (const_int5_operand): New predicate.
        * config/riscv/riscv-builtins.cc:
        Add new AVAIL andesperf32 and andesperf64.
        Add new define RISCV_ATYPE_DI.
        * config/riscv/riscv-ftypes.def: New DEF_RISCV_FTYPE.
        * config/riscv/riscv.cc
        (riscv_extend_cost): Cost for pattern 'bfo'.
        (riscv_rtx_costs): Cost for XAndesperf extension.
        * config/riscv/riscv.md: Add support for XAndesperf to patterns
        zero_extendsidi2_internal, zero_extendhi2, extendsidi2_internal,
        extend<SHORT:mode><SUPERQI:mode>2, <any_extract:optab><GPR:mode>3
        and branch_on_bit.
        * config/riscv/vector-iterators.md
         (sz): Add sign_extract and zero_extract.
        * config/riscv/andes.def: New file for vender Andes.
        * config/riscv/andes.md: New file for vender Andes.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/riscv.exp: Add runtest for subdir xandes.
        * gcc.target/riscv/xandes/xandesperf-1.c: New test.
        * gcc.target/riscv/xandes/xandesperf-10.c: New test.
        * gcc.target/riscv/xandes/xandesperf-2.c: New test.
        * gcc.target/riscv/xandes/xandesperf-3.c: New test.
        * gcc.target/riscv/xandes/xandesperf-4.c: New test.
        * gcc.target/riscv/xandes/xandesperf-5.c: New test.
        * gcc.target/riscv/xandes/xandesperf-6.c: New test.
        * gcc.target/riscv/xandes/xandesperf-7.c: New test.
        * gcc.target/riscv/xandes/xandesperf-8.c: New test.
        * gcc.target/riscv/xandes/xandesperf-9.c: New test.



+
+;;
+;;  ....................
+;;
+;;     LOAD ADDRESS
+;;
+;;  ....................
+;;
+
+(define_insn "lea_h<mode>"
+  [(set (match_operand:P                   0 "register_operand" "=r")
+       (plus:P (ashift:P (match_operand:P 1 "register_operand" " r")
+                         (const_int 1))
+               (match_operand:P           2 "register_operand" " r")))]
+  "TARGET_XANDESPERF"
+  { return "nds.lea.h\t%0,%2,%1"; }
+  [(set_attr "type" "arith")
+   (set_attr "mode" "<MODE>")])
+
+(define_insn "lea_w<mode>"
+  [(set (match_operand:P                   0 "register_operand" "=r")
+       (plus:P (ashift:P (match_operand:P 1 "register_operand" " r")
+                         (const_int 2))
+               (match_operand:P           2 "register_operand" " r")))]
+  "TARGET_XANDESPERF"
+  { return "nds.lea.w\t%0,%2,%1"; }
+  [(set_attr "type" "arith")
+   (set_attr "mode" "<MODE>")])
So you might consider a cleanup where you squash those patterns into a single pattern. We should already have a suitable predicate for the shift count since we have shNadd patterns. Then you just need an output modifier to select between h, w and d based on the shift count.

You might also consider simplifying the output template. It doesn't really need to be a C fragment. So instead of

{ return "whatever"; }

Just use:

"whatever"

IMHO, those are cleanups you can submit after integration.

Similarly for the zero-extend variants.


@@ -4941,3 +4945,4 @@
  (include "sifive-p600.md")
  (include "generic-vector-ooo.md")
  (include "generic-ooo.md")
+(include "andes.md")
This is in the section for scheduler pipeline models. There's a separate section for for Vendor extensions. I've moved it up.

I've pushed this to the trunk.

jeff


Reply via email to