-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Mnemonic field to CoreDSL Syntax #80
Comments
Neat! I agree that this would be important to support more real-world extensions. @PhilippvK can you present this proposal in the WG call on 13/3? |
I can present it next Monday! |
I talked with @AtomCrafty about allowing dots in the instruction name. Having two kinds of identifiers is actually not possible because the lexer cannot distinguish them when tokenizing the input. We could a) allow strings for the name
or b) parse ID-with-dots as expressions (which would require some processing in the downstream tools, though the effort should be manageable, as instruction names are not references anywhere else). Thoughts? |
I figured out that the They have register-register load/store instructions with and without Post-Increment which share the same mnemonic but use differend assembly arguments for differentiation (beside the encoding of course):
Using the mnemonic as CoreDSL identifier leads to two instructions with the same name which can lead to issues. In my opinion these identifiers should be unique, even if only the encoding is used on the backend side. Hence I would prefer to use the following syntax:
Would you now agree, that the |
There is no objection wrt. to the possibility if specifying a mnemonic. But I'm a bit hessitant to add keywords to the language itself.
Since the frontend is not validating the content of the string this would be a minor change in the grammar and validation framework (@AtomCrafty correct my if I'm wrong) |
I believe that would be a pure grammar change. The frontend doesn't perform any validation on the assembly field. |
@eyck I am totally fine with that proposal as long as it is properly documented in the manual |
SGTM! |
Frontend support has been implemented. I'll leave this issue open to track the necessary changes to the spec. |
Motivation
With CoreDSL 2 instruction names can not include dots (
.
) while there are many extensions using names with a dot (see first & second example). While this might be neglectible for HLS and ISS, it affects further integrations, such as disassembler-Generation.Therefore I propose to add an optional
mnemonic:
field to the CoreDSL 2 syntax which can be used to provide the actual instruction name if the name used in CoreDSL does not match the real one.In addition I oftern run into situation where combining multiple instructions (which minor differences in the encoding/behavior) into a single one (see second & third example below), which of course will end up having an invalid name for that instructions.
To deal with this sort of problem I would like to be able to use similar formating options as already allowed for the
assembly:
field. For dealing with more complex types of instructions (having non-trivial mappings between encoding/operands and names) we would need to come up with a more powerful variant of this feature (see third example)Examples
Mnemonics with a dot: Custom Multiply-Accumulate (Pulp/CoreV)
Spec: https://github.com/openhwgroup/cv32e40p/blob/master/docs/source/instruction_set_extensions.rst#mac-encoding
Usage:
cv.mac rd, rs1, rs2
Before:
Problems:
After:
Potential problems:
mnemonic
field is optionalTrivial mnemonic formatting: Vector Strided Segment Loads (RVV)
See: https://github.com/openhwgroup/cv32e40p/blob/master/docs/source/instruction_set_extensions.rst#mac-encoding
Usage:
vlsseg<nfields>e<eew>.v vd, (rs1), rs2, vm
Details:
nfields=1...8
eew=8,16,32,64
For now let's only consider nfields. (
eew
has non-trivial encoding)Before (combined):
Problems:
Before (separate):
Problems:
After (combined):
Potential problems:
{imm:#08x}
style formatting similary to assembly definition?Non-trivial mnemonic formatting : Byte Unpacking (RVP)
Spec: https://github.com/riscv/riscv-p-spec/blob/master/P-ext-proposal.adoc#sunpkd810-sunpkd820-sunpkd830-sunpkd831-sunpkd832
Usage:
SUNPKD810 rd, rs1
(Signed Unpacking Bytes 1 & 0)SUNPKD820 rd, rs1
(Signed Unpacking Bytes 2 & 0)SUNPKD830 rd, rs1
(Signed Unpacking Bytes 3 & 0)SUNPKD831 rd, rs1
(Signed Unpacking Bytes 3 & 1)SUNPKD832 rd, rs1
(Signed Unpacking Bytes 3 & 2)Details:
Before (combined):
Problems:
Before (separate):
Problems:
Before (separate + helper function):
Problem:
After (combined only):
Potential problems:
{name(...)}
is also allowed and backend-implementation specific which is a bit unintuitive. With the proposed change, this could be implemented as (external) function instead.The text was updated successfully, but these errors were encountered: