Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

SLLI: Possibly wrong decoding? #172

Description

@mablinov

This concerns the SLLI encoding. From the spec, the rv32i SLLI instruction is encoded as follows:

slli-32
So, the leftmost field has 7 bits of opcode space, and then theres a 5 bit shamt field.

As for the 64 bit variant, its encoded differently:
slli-64

Now we only have 6 bits of opcode space on the left, because we steal one bit for the 64-bit shift amount encoding.

Now consider the following opcode:
0000000 11111 00000 001 00000 0010011 = 0x1F01013

The test.s:

.attribute arch, "rv32i"
start:
	.word 0x1F01013

disassembly:

00000000 <start>:
   0:	01f01013          	slli	zero,zero,0x1f

Ok, makes sense, we shift left by an immedate amount of 31 bits.
If we do the following however:

0000001 00000 00000 001 00000 0010011 = 0x2001013
We've "incremented" the shamt by one, but as per the rv32i v2.2 spec, the shamt is 0, and bit 0 of the leftmost opcode[6:0] field is now set, so it shouldn't be a "SLLI" anymore (atleast not in rv32i).

test.s:

.attribute arch, "rv32i"

start:
	.word 0x2001013

disassembling test.o:

test:
00000000 <start>:
   0:	02001013          	slli	zero,zero,0x20

That is SLLI in rv64i, but not in rv32i, right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions