-
Notifications
You must be signed in to change notification settings - Fork 1
riscv_dis_support_special_encodings
- Status: WITHDRAWN
splitted to multiple patchsets - Branch:
riscv-dis-support-special-encodings
- Tracking PR: #17 (view Pull Request and Diff)
- Mailing List:
- Not yet
-
Combined floating point enhancements
It also touches floating point instructions. But rebasing this patch onriscv-float-combined
is not hard. -
Cleaning: Opcode Tidying (Batch 1)
It also touches definition offence.i
. Easy to rebase.
There are some instructions that their operation is not mathematically affected by rm
(rounding mode) bits.
fcvt.s.h
fcvt.d.h
fcvt.q.h
fcvt.d.w
fcvt.d.wu
fcvt.d.s
fcvt.q.w
fcvt.q.wu
fcvt.q.s
fcvt.q.d
-
fcvt.q.l
(RV64 only) -
fcvt.q.lu
(RV64 only)
On such instructions, only RNE
-rounding variant (with rm
bits of 0b000
) are correctly disassembled (except fcvt.q.l
and fcvt.q.lu
, that supported rounding mode operand in the past). While RNE
is the default (and preferred) rounding mode on such instructions, all other valid variants are disassembled as invalid instructions.
S Pawan Kumar (@pawks) proposed a patch by adding instruction variants with rounding modes. I'm okay with his patch but I have a small concern whether it may be too aggressive.
So, I chose rather conservative approach first. It contains complete disassembler support and stub assembler support (which generates error when used). Bigger disassembler problem is resolved only with this and we can easily modify the code to support @pawks' proposal.
-
no-aliases
disassembler option is required to decode additional (non-default) rounding modes.
- On
fcvt.q.l
andfcvt.q.lu
, show a warning when a rounding mode is specified. - On other instructions (listed above), show an error.
It reserves two additional operand types !M
and !m
(reserving one-character operand types seemed too much). Is it okay?
Quoting the ISA Manual,
2.7 Memory Ordering Instructions
... The unused fields in the
FENCE
instructions—rs1 and rd—are reserved for finer-grain fences in future extensions. For forward compatibility, base implementations shall ignore these fields, and standard software shall zero these fields. Likewise, many fm and predecessor/successor set settings in Table 2.2 are also reserved for future use. Base implementations shall treat all such reserved configurations as normal fences with fm=0000
, and standard software shall use only non-reserved configurations.
Chapter 3: “Zifencei” Instruction-Fetch Fence, Version 2.0
... The unused fields in the
FENCE.I
instruction, imm[11:0], rs1, and rd, are reserved for finer-grain fences in future extensions. For forward compatibility, base implementations shall ignore these fields, and standard software shall zero these fields.
Those reserved fields/combinations are supposed to be zero for compatibility still can be valid as FENCE
-like instructions. Note that there's no useful if we supported those fields on the assembler.
However, GNU Binutils' disassembler can be treated as a base implementation and this patchset tries to simulate the behavior described in the ISA Manual.
To support this behavior, I added ~
special operand modifier. Any fields after ~
are ignored but considered used by the assembler. This is required because just removing MASK_RD
(for example) from mask value of FENCE
-like instructions results in an internal error (because rd field is not used).
On FENCE.I
, non-zero rd and rs1 are ignored and printed as a fence.i
instruction.
On FENCE
,
- Non-zero rd, non-zero rs1 are ignored.
- Reserved fm+pred+succ combinations are considered regular fence (fm is ignored but pred and succ are respected).
- Print reserved
fence.tso
as afence.tso
instruction (with no operands). - Print reserved
fence
as afence
instruction with two operands.