On 9/25/21 19:30, WANG Xuerui wrote: > Signed-off-by: WANG Xuerui <g...@xen0n.name> > Reviewed-by: Richard Henderson <richard.hender...@linaro.org> > --- > tcg/loongarch64/tcg-target.c.inc | 137 +++++++++++++++++++++++++++++++ > 1 file changed, 137 insertions(+)
> +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) > +{ > + if (ret == arg) { > + return true; > + } > + switch (type) { > + case TCG_TYPE_I32: > + case TCG_TYPE_I64: > + /* > + * Conventional register-register move used in LoongArch is > + * `or dst, src, zero`. > + */ > + tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO); > + break; > + default: > + g_assert_not_reached(); > + } > + return true; > +} > +static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, > + tcg_target_long val) > +{ > + /* > + * LoongArch conventionally loads 64-bit immediates in at most 4 steps, > + * with dedicated instructions for filling the respective bitfields > + * below: > + * > + * 6 5 4 3 > + * 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 > + * +-----------------------+---------------------------------------+... > + * | hi52 | hi32 | > + * +-----------------------+---------------------------------------+... > + * 3 2 1 > + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 > + * ...+-------------------------------------+-------------------------+ > + * | hi12 | lo | > + * ...+-------------------------------------+-------------------------+ > + * > + * Check if val belong to one of the several fast cases, before falling > + * back to the slow path. > + */ Lovely :) Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org>