Skip to content
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

fixes encodings #25

Draft
wants to merge 23 commits into
base: json
Choose a base branch
from
Draft

fixes encodings #25

wants to merge 23 commits into from

Conversation

snapdgn
Copy link

@snapdgn snapdgn commented Jun 3, 2024

Fixes: #18

WIP

ThinkOpenly and others added 22 commits March 29, 2024 08:30
In the JSON backend, currently all messages (debug text and JSON data) are emitted to stdout.

Change debug messages to be emitted to stderr by using `prerr_endline` instead of `print_endline`.

Fixes ThinkOpenly#4.
In the JSON Backend, currently all the debug output is emitted to
stderr by default.

Introduce a conditional environment variable `DEBUG_OUT` to control debug output.

Fixes ThinkOpenly#6.
New JSON field "syntax" which facilitates displaying
parenthesized operands in syntax like "lw rd,offset(rs)".

Extract operands from assembly representation ("mapping clause assembly")
instead of function signatures ("union clause ast").

Remove "identity" functions in assembly representation.
In actuality, these functions transform an opcode field into the expected
assembly representation, which could be a well-known register name or the
actual value of an offset where the field is a truncated representation.
Hardcoding these Sail function names here is at least far from ideal,
and at worst, wrong (calling a truncated value and the full value the same
name).
More thought is needed as to the best realization of assembly syntax
from the assembly representation.

Ignore "opt_spc" in assembly representations.

Move function "dequote" up due to a new use.
Use the newly available `Reporting.loc_range_to_src` function
to extract the text of the function bodies verbatim from the
Sail source. Previously, the json contained the AST text for
the functions.
Extract the instruction syntax from the `mapping clause assembly`
(rather than presuming that the operands captured separately can
accurately represent syntax. They can't.)

Make sure to preserve separators (",") and parentheses.
A previous commit broke extraction of instruction operands/types.
Fix it.
Many instructions are grouped around a similar, common implementation
with the mnemonics embedded within a list of mnemonic:name mapping, such as:
```
mapping utype_mnemonic : uop <-> string = {
  RISCV_LUI   <-> "lui",
  RISCV_AUIPC <-> "auipc"
}

mapping clause assembly = UTYPE(imm, rd, op)
  <-> utype_mnemonic(op) ^ spc() ^ reg_name(rd) ^ sep() ^ hex_bits_20(imm)
```

Add support for extracting instruction names from within the mappings if
the names are added within as attributes, for example:
```
mapping utype_mnemonic : uop <-> string = {
  $[name Load Upper Immediate]
    RISCV_LUI   <-> "lui",
  $[name Add Upper Immediate to Program Counter]
    RISCV_AUIPC <-> "auipc"
}
```
This commit enhances the JSON Backend to properly handle instructions with optional operands.
Previously, these operands were not handled correctly.

The implementation introduces two new fields:
`optional`, which indicates whether an operand is optional (boolean),
and `default`, which holds the default value if no value is specified.

for 'vle16.v':

Before:
```
{
  "operands": [
    ...
    { "name": "vm", "type": "bits(1)" }
    ...
  ]
}
```
After:
```
{
  "operands": [
    ...
    { "name": "vm", "type": "bits(1)", "optional": true, "default": "v0.t" }
    ...
  ]
}
```
Fixes: ThinkOpenly#2
@snapdgn snapdgn changed the title Fixes: #18 fixes encodings Jun 3, 2024
@ThinkOpenly
Copy link
Owner

@snapdgn , are you still working on this? Do you need to hand this off? Not urgent, just checking in.

@snapdgn
Copy link
Author

snapdgn commented Jun 27, 2024

Sorry @ThinkOpenly , just saw this. Gsoc thing is kinda taking up major chunk of my time.
If anyone else is interested, they are more than welcome to take it. Otherwise, I can return to it at my own convenience if it's not urgent (??).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JSON] slli has incorrect information
3 participants