Hi Philippe,

On 9/21/21 17:58, Philippe Mathieu-Daudé wrote:
On 9/20/21 10:04, WANG Xuerui wrote:
Signed-off-by: WANG Xuerui <g...@xen0n.name>
---
  tcg/loongarch/tcg-insn-defs.c.inc | 1080 +++++++++++++++++++++++++++++
  1 file changed, 1080 insertions(+)
  create mode 100644 tcg/loongarch/tcg-insn-defs.c.inc

+static int32_t encode_dj_slots(LoongArchInsn opc, uint32_t d, uint32_t j)
+{
Can we move the range check to the callee and avoid masking the values
in the caller?

       tcg_debug_assert(d < 0x20);
       tcg_debug_assert(j < 0x20);

Making use of tcg_debug_assert would be rather nice, but in fact different instructions could have differently sized fields start from the same offset. Take the "bstrpick.w" and "bstrpick.d" instructions, they belong to DJUk5Um5 and DJUk6Um6 formats respectively; the "Uk5" and "Uk6" fields both start from the 10th bit but have different value ranges. So the range checks necessarily live in encoders for the individual formats.


Reply via email to