diff options
author | Jan Beulich <jbeulich@suse.com> | 2023-11-24 09:53:55 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2023-11-24 09:53:55 +0100 |
commit | eb5e952f95423bc6ae18457ccc359c8b6c0fa387 (patch) | |
tree | 994586ba8306938b1ce354c07585987ef5d3dec0 /gas | |
parent | 27b33966b18ed8bf1701a60999448224b1d28273 (diff) | |
download | binutils-eb5e952f95423bc6ae18457ccc359c8b6c0fa387.zip binutils-eb5e952f95423bc6ae18457ccc359c8b6c0fa387.tar.gz binutils-eb5e952f95423bc6ae18457ccc359c8b6c0fa387.tar.bz2 |
RISC-V: reduce redundancy in sign/zero extension macro insn handling
Fold M_{S,Z}EXTH, deriving signed-ness from the incoming mnemonic. Fold
riscv_ext()'s calls md_assemblef(), the first of which were entirely
identical, while the other pair differed in just a single character.
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/tc-riscv.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 3222bd1..04738d5 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -1960,16 +1960,9 @@ load_const (int reg, expressionS *ep) static void riscv_ext (int destreg, int srcreg, unsigned shift, bool sign) { - if (sign) - { - md_assemblef ("slli x%d, x%d, 0x%x", destreg, srcreg, shift); - md_assemblef ("srai x%d, x%d, 0x%x", destreg, destreg, shift); - } - else - { - md_assemblef ("slli x%d, x%d, 0x%x", destreg, srcreg, shift); - md_assemblef ("srli x%d, x%d, 0x%x", destreg, destreg, shift); - } + md_assemblef ("slli x%d, x%d, %#x", destreg, srcreg, shift); + md_assemblef ("sr%ci x%d, x%d, %#x", + sign ? 'a' : 'l', destreg, destreg, shift); } /* Expand RISC-V Vector macros into one or more instructions. */ @@ -2093,8 +2086,8 @@ macro (struct riscv_cl_insn *ip, expressionS *imm_expr, riscv_call (rd, rs1, imm_expr, *imm_reloc); break; - case M_ZEXTH: - riscv_ext (rd, rs1, xlen - 16, false); + case M_EXTH: + riscv_ext (rd, rs1, xlen - 16, *ip->insn_mo->name == 's'); break; case M_ZEXTW: @@ -2105,10 +2098,6 @@ macro (struct riscv_cl_insn *ip, expressionS *imm_expr, riscv_ext (rd, rs1, xlen - 8, true); break; - case M_SEXTH: - riscv_ext (rd, rs1, xlen - 16, true); - break; - case M_VMSGE: vector_macro (ip); break; |