diff options
author | Nelson Chu <nelson.chu@sifive.com> | 2023-11-24 15:46:56 +0800 |
---|---|---|
committer | Nelson Chu <nelson@rivosinc.com> | 2023-12-01 09:29:07 +0800 |
commit | 248bf6de04032c666cbbd8d3278efa60b6059660 (patch) | |
tree | 2d4ddc632b91b3f3058b55d6d16868afca30472a /gas/config/tc-riscv.c | |
parent | ea1bd007428cb20df9a36a049d3a0ccd9ae74894 (diff) | |
download | gdb-248bf6de04032c666cbbd8d3278efa60b6059660.zip gdb-248bf6de04032c666cbbd8d3278efa60b6059660.tar.gz gdb-248bf6de04032c666cbbd8d3278efa60b6059660.tar.bz2 |
RISC-V: Add SiFive custom vector coprocessor interface instructions v1.0
SiFive has define as set of flexible instruction for extending vector
coprocessor, it able to encoding opcode like .insn but with predefined
format.
List of instructions:
sf.vc.x
sf.vc.i
sf.vc.vv
sf.vc.xv
sf.vc.iv
sf.vc.fv
sf.vc.vvv
sf.vc.xvv
sf.vc.ivv
sf.vc.fvv
sf.vc.vvw
sf.vc.xvw
sf.vc.ivw
sf.vc.fvw
sf.vc.v.x
sf.vc.v.i
sf.vc.v.vv
sf.vc.v.xv
sf.vc.v.iv
sf.vc.v.fv
sf.vc.v.vvv
sf.vc.v.xvv
sf.vc.v.ivv
sf.vc.v.fvv
sf.vc.v.vvw
sf.vc.v.xvw
sf.vc.v.ivw
sf.vc.v.fvw
Spec of Xsfvcp
https://www.sifive.com/document-file/sifive-vector-coprocessor-interface-vcix-software
Co-authored-by: Hau Hsu <hau.hsu@sifive.com>
Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
Diffstat (limited to 'gas/config/tc-riscv.c')
-rw-r--r-- | gas/config/tc-riscv.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 04738d5..9365b87 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -1499,6 +1499,24 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length) goto unknown_validate_operand; } break; + case 's': /* Vendor-specific (SiFive) operands. */ + switch (*++oparg) + { + case 'd': USE_BITS (OP_MASK_RD, OP_SH_RD); break; + case 't': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break; + case 'O': + switch (*++oparg) + { + case '2': USE_BITS (OP_MASK_XSO2, OP_SH_XSO2); break; + case '1': USE_BITS (OP_MASK_XSO1, OP_SH_XSO1); break; + default: + goto unknown_validate_operand; + } + break; + default: + goto unknown_validate_operand; + } + break; default: goto unknown_validate_operand; } @@ -3616,6 +3634,56 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr, } break; + case 's': /* Vendor-specific (SiFive) operands. */ +#define UIMM_BITFIELD_VAL(S, E) (1 << ((E) - (S) + 1)) +#define ENCODE_UIMM_BIT_FIELD(NAME, IP, EXPR, RELOC, ASARG, \ + START, END) \ + do \ + { \ + if (my_getOpcodeExpression (EXPR, RELOC, ASARG) \ + || EXPR->X_op != O_constant \ + || EXPR->X_add_number < 0 \ + || EXPR->X_add_number >= UIMM_BITFIELD_VAL (START, END)) \ + { \ + as_bad (_("bad value for <bit-%s-%s> " \ + "field, value must be 0...%d"), \ + #START, #END, UIMM_BITFIELD_VAL (START, END)); \ + break; \ + } \ + INSERT_OPERAND (NAME, *IP, EXPR->X_add_number); \ + EXPR->X_op = O_absent; \ + ASARG = expr_parse_end; \ + } \ + while (0); + switch (*++oparg) + { + case 'd': /* Xsd */ + ENCODE_UIMM_BIT_FIELD + (RD, ip, imm_expr, imm_reloc, asarg, 7, 11); + continue; + case 't': /* Xst */ + ENCODE_UIMM_BIT_FIELD + (RS2, ip, imm_expr, imm_reloc, asarg, 20, 24) + continue; + case 'O': + switch (*++oparg) + { + case '2': /* XsO2 */ + ENCODE_UIMM_BIT_FIELD + (XSO2, ip, imm_expr, imm_reloc, asarg, 26, 27); + continue; + case '1': /* XsO1 */ + ENCODE_UIMM_BIT_FIELD + (XSO1, ip, imm_expr, imm_reloc, asarg, 26, 26); + continue; + } + default: + goto unknown_riscv_ip_operand; + } +#undef UIMM_BITFIELD_VAL +#undef ENCODE_UIMM_BIT_FIELD + break; + default: goto unknown_riscv_ip_operand; } |