[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 4/5] target/riscv: progressively load the instruction duri
From: |
Alex Bennée |
Subject: |
Re: [PATCH v1 4/5] target/riscv: progressively load the instruction during decode |
Date: |
Fri, 07 Feb 2020 16:47:30 +0000 |
User-agent: |
mu4e 1.3.7; emacs 27.0.60 |
Robert Foley <address@hidden> writes:
> Hi,
> On Fri, 7 Feb 2020 at 10:01, Alex Bennée <address@hidden> wrote:
>> -static void decode_RV32_64C0(DisasContext *ctx)
>> +static void decode_RV32_64C0(DisasContext *ctx, uint16_t opcode)
>> {
>> - uint8_t funct3 = extract32(ctx->opcode, 13, 3);
>> - uint8_t rd_rs2 = GET_C_RS2S(ctx->opcode);
>> - uint8_t rs1s = GET_C_RS1S(ctx->opcode);
>> + uint8_t funct3 = extract32(opcode, 13, 3);
>
> We noticed that a uint16_t opcode is passed into this function and
> then passed on to extract32().
> This is a minor point, but the extract32() will validate the start and
> length values passed in according to 32 bits, not 16 bits.
> static inline uint32_t extract32(uint32_t value, int start, int length)
> {
> assert(start >= 0 && length > 0 && length <= 32 - start);
> Since we have an extract32() and extract64(), maybe we could add an
> extract16() and use it here?
Yeah - I did consider if it would be worth adding a extract16 helper.
There are a fair number of places in the code base where uint16_t is
silently promoted to a uint32_t (and a couple where it is downcast).
I guess 16 bit instruction words are common enough we should support
them in the utils.
--
Alex Bennée