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

Include optional operands #2

Closed
ThinkOpenly opened this issue Nov 10, 2023 · 2 comments
Closed

Include optional operands #2

ThinkOpenly opened this issue Nov 10, 2023 · 2 comments

Comments

@ThinkOpenly
Copy link
Owner

Some instructions have optional operands, and these are not handled properly.
The functions which get mapped to the string with the operand (or without) are currently treated as "identity" functions and essentially ignored while the operand is preserved. The separator is generally emitted by these functions as well, so that is lost as well, leading to syntaxes like:

vle16.v        vd,(rs1)vm

These situations may require the "syntax" field resolving to a list of strings instead of the current strings with something like:

"syntaxes": [ "vd,(rs1)", "vd,(rs1),vm" ]
@snapdgn
Copy link

snapdgn commented Mar 28, 2024

looking into this!

@ThinkOpenly
Copy link
Owner Author

I just thought of one additional piece of information needed here: the value to be used if there is no value specified. This was suggested in Slack:

{
  "operands": [
    { "name": "rs1", "type": "regidx", "optional": false },
    { "name": "rd", "type": "regidx", "optional": false },
    { "name": "vm", "type": "flag", "optional": true }
  ]
}

Modifying that to add a default value might look like:

{
  "operands": [
    { "name": "rs1", "type": "regidx", "optional": false },
    { "name": "rd", "type": "regidx", "optional": false },
    { "name": "vm", "type": "flag", "optional": true, default: "v0.t" }
  ]
}

snapdgn added a commit to snapdgn/sail that referenced this issue Apr 11, 2024
snapdgn added a commit to snapdgn/sail that referenced this issue Apr 11, 2024
snapdgn added a commit to snapdgn/sail that referenced this issue May 23, 2024
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
ThinkOpenly pushed a commit that referenced this issue Jun 17, 2024
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: #2
ThinkOpenly pushed a commit that referenced this issue Sep 16, 2024
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: #2
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

No branches or pull requests

2 participants