+2021-04-16 Nelson Chu <nelson.chu@sifive.com>
+
+ PR 27436
+ * config/tc-riscv.c (riscv_ip): make operand C> work the same as >.
+ * testsuite/gas/riscv/shamt-32.d: New testcase.
+ * testsuite/gas/riscv/shamt-32.l: Likewise.
+ * testsuite/gas/riscv/shamt-32.s: Likewise.
+ * testsuite/gas/riscv/shamt-64.d: Likewise.
+ * testsuite/gas/riscv/shamt-64.l: Likewise.
+ * testsuite/gas/riscv/shamt-64.s: Likewise.
+
2021-04-16 Lifang Xia <lifang_xia@c-sky.com>
* testsuite/gas/riscv/c-zero-imm.d: Compress addi a4,a4,0 to
|| regno != 0)
break;
continue;
- case '>':
+ case '>': /* Shift amount, 0 - (XLEN-1). */
if (my_getSmallExpression (imm_expr, imm_reloc, s, p)
|| imm_expr->X_op != O_constant
- || imm_expr->X_add_number <= 0
- || imm_expr->X_add_number >= 64)
+ || (unsigned long) imm_expr->X_add_number >= xlen)
break;
ip->insn_opcode |= ENCODE_CITYPE_IMM (imm_expr->X_add_number);
rvc_imm_done:
--- /dev/null
+#as: -march=rv32i
+#objdump: -dr
+#error_output: shamt-32.l
--- /dev/null
+.*Assembler messages:
+.*:4: Error: improper shift amount \(32\)
+.*:5: Error: improper shift amount \(63\)
+.*:9: Error: improper shift amount \(32\)
+.*:10: Error: improper shift amount \(63\)
+.*:14: Error: improper shift amount \(32\)
+.*:15: Error: improper shift amount \(63\)
+.*:20: Error: improper shift amount \(32\)
+.*:21: Error: improper shift amount \(63\)
+.*:25: Error: improper shift amount \(32\)
+.*:26: Error: improper shift amount \(63\)
+.*:30: Error: improper shift amount \(32\)
+.*:31: Error: improper shift amount \(63\)
--- /dev/null
+ .option norvc
+ slli a0, a0, 0
+ slli a0, a0, 31
+ slli a0, a0, 32
+ slli a0, a0, 63
+
+ srli a0, a0, 0
+ srli a0, a0, 31
+ srli a0, a0, 32
+ srli a0, a0, 63
+
+ srai a0, a0, 0
+ srai a0, a0, 31
+ srai a0, a0, 32
+ srai a0, a0, 63
+
+ .option rvc
+ slli a0, a0, 0
+ slli a0, a0, 31
+ slli a0, a0, 32
+ slli a0, a0, 63
+
+ srli a0, a0, 0
+ srli a0, a0, 31
+ srli a0, a0, 32
+ srli a0, a0, 63
+
+ srai a0, a0, 0
+ srai a0, a0, 31
+ srai a0, a0, 32
+ srai a0, a0, 63
--- /dev/null
+#as: -march=rv64i
+#objdump: -dr
+#error_output: shamt-64.l
--- /dev/null
+.*Assembler messages:
+.*:19: Error: improper shift amount \(32\)
+.*:20: Error: improper shift amount \(63\)
+.*:24: Error: improper shift amount \(32\)
+.*:25: Error: improper shift amount \(63\)
+.*:29: Error: improper shift amount \(32\)
+.*:30: Error: improper shift amount \(63\)
--- /dev/null
+ .option norvc
+ slli a0, a0, 0
+ slli a0, a0, 31
+ slli a0, a0, 32
+ slli a0, a0, 63
+
+ srli a0, a0, 0
+ srli a0, a0, 31
+ srli a0, a0, 32
+ srli a0, a0, 63
+
+ srai a0, a0, 0
+ srai a0, a0, 31
+ srai a0, a0, 32
+ srai a0, a0, 63
+
+ slliw a0, a0, 0
+ slliw a0, a0, 31
+ slliw a0, a0, 32
+ slliw a0, a0, 63
+
+ srliw a0, a0, 0
+ srliw a0, a0, 31
+ srliw a0, a0, 32
+ srliw a0, a0, 63
+
+ sraiw a0, a0, 0
+ sraiw a0, a0, 31
+ sraiw a0, a0, 32
+ sraiw a0, a0, 63
+
+ .option rvc
+ slli a0, a0, 0
+ slli a0, a0, 31
+ slli a0, a0, 32
+ slli a0, a0, 63
+
+ srli a0, a0, 0
+ srli a0, a0, 31
+ srli a0, a0, 32
+ srli a0, a0, 63
+
+ srai a0, a0, 0
+ srai a0, a0, 31
+ srai a0, a0, 32
+ srai a0, a0, 63