Bug 27158 - RISC-V port still has UJ instruction type references
Summary: RISC-V port still has UJ instruction type references
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-07 23:09 UTC by Jim Wilson
Modified: 2021-02-22 01:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Wilson 2021-01-07 23:09:16 UTC
RISC-V ISA v2.1 has a UJ instruction format that got renamed to J in ISA v2.2.  But the source code still has references to the obsolete UJ instruction format.

rohan:2349$ grep UJ include/opcode/riscv.h
#define EXTRACT_UJTYPE_IMM(x) \
#define ENCODE_UJTYPE_IMM(x) \
#define VALID_UJTYPE_IMM(x) (EXTRACT_UJTYPE_IMM(ENCODE_UJTYPE_IMM(x)) == (x))
#define RISCV_UJTYPE(insn, rd, target) \
  ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ENCODE_UJTYPE_IMM(target))
rohan:2350$ 

These should be renmaed from UJTYPE to JTYPE.

This is just a minor quality of implementation issue and does not need to be fixed before the release branch is made in a few days.

We still support .insh uj, ... but we can't change that without the risk of breaking old user code that references the old instruction format name.
Comment 1 Nelson Chu 2021-01-22 09:42:21 UTC
Yeah and we also meet the same issue as SB type, it was changed to B-type in the new spec.
Comment 2 Sourceware Commits 2021-02-19 03:54:54 UTC
The master branch has been updated by Nelson Chu <nelsonc1225@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5a9f5403c75c8ae1f4935a9a0904949f52d9e3aa

commit 5a9f5403c75c8ae1f4935a9a0904949f52d9e3aa
Author: Nelson Chu <nelson.chu@sifive.com>
Date:   Tue Jan 26 18:02:38 2021 +0800

    RISC-V: PR27158, fixed UJ/SB types and added CSS/CL/CS types for .insn.
    
    * Renamed obsolete UJ/SB types and RVC types, also added CSS/CL(CS) types,
    
    [VALID/EXTRACT/ENCODE macros]
    BTYPE_IMM:            Renamed from SBTYPE_IMM.
    JTYPE_IMM:            Renamed from UJTYPE_IMM.
    CITYPE_IMM:           Renamed from RVC_IMM.
    CITYPE_LUI_IMM:       Renamed from RVC_LUI_IMM.
    CITYPE_ADDI16SP_IMM:  Renamed from RVC_ADDI16SP_IMM.
    CITYPE_LWSP_IMM:      Renamed from RVC_LWSP_IMM.
    CITYPE_LDSP_IMM:      Renamed from RVC_LDSP_IMM.
    CIWTYPE_IMM:          Renamed from RVC_UIMM8.
    CIWTYPE_ADDI4SPN_IMM: Renamed from RVC_ADDI4SPN_IMM.
    CSSTYPE_IMM:          Added for .insn without special encoding.
    CSSTYPE_SWSP_IMM:     Renamed from RVC_SWSP_IMM.
    CSSTYPE_SDSP_IMM:     Renamed from RVC_SDSP_IMM.
    CLTYPE_IMM:           Added for .insn without special encoding.
    CLTYPE_LW_IMM:        Renamed from RVC_LW_IMM.
    CLTYPE_LD_IMM:        Renamed from RVC_LD_IMM.
    RVC_SIMM3:            Unused and removed.
    CBTYPE_IMM:           Renamed from RVC_B_IMM.
    CJTYPE_IMM:           Renamed from RVC_J_IMM.
    
    * Added new operands and removed the unused ones,
    
    C5: Unsigned CL(CS) immediate, added for .insn directive.
    C6: Unsigned CSS immediate, added for .insn directive.
    Ci: Unused and removed.
    C<: Unused and removed.
    
    bfd/
        PR 27158
        * elfnn-riscv.c (perform_relocation): Updated encoding macros.
        (_bfd_riscv_relax_call): Likewise.
        (_bfd_riscv_relax_lui): Likewise.
        * elfxx-riscv.c (howto_table): Likewise.
    gas/
        PR 27158
        * config/tc-riscv.c (riscv_ip): Updated encoding macros.
        (md_apply_fix): Likewise.
        (md_convert_frag_branch): Likewise.
        (validate_riscv_insn): Likewise.  Also arranged operands, including
        added C5 and C6 operands, and removed unused Ci and C< operands.
        * doc/c-riscv.texi: Updated and added CSS/CL/CS types.
        * testsuite/gas/riscv/insn.d: Added CSS/CL/CS instructions.
        * testsuite/gas/riscv/insn.s: Likewise.
    gdb/
        PR 27158
        * riscv-tdep.c (decode_ci_type_insn): Updated encoding macros.
        (decode_j_type_insn): Likewise.
        (decode_cj_type_insn): Likewise.
        (decode_b_type_insn): Likewise.
        (decode): Likewise.
    include/
        PR 27158
        * opcode/riscv.h: Updated encoding macros.
    opcodes/
        PR 27158
        * riscv-dis.c (print_insn_args): Updated encoding macros.
        * riscv-opc.c (MASK_RVC_IMM): defined to ENCODE_CITYPE_IMM.
        (match_c_addi16sp): Updated encoding macros.
        (match_c_lui): Likewise.
        (match_c_lui_with_hint): Likewise.
        (match_c_addi4spn): Likewise.
        (match_c_slli): Likewise.
        (match_slli_as_c_slli): Likewise.
        (match_c_slli64): Likewise.
        (match_srxi_as_c_srxi): Likewise.
        (riscv_insn_types): Added .insn css/cl/cs.
    sim/
        PR 27158
        * riscv/sim-main.c (execute_i): Updated encoding macros.
Comment 3 Nelson Chu 2021-02-22 01:10:26 UTC
Marked resolved/fixed.