Skip to content

Conversation

@whyvn
Copy link

@whyvn whyvn commented Sep 25, 2025

so it can be used with constants like

s = 0
sll $0, $0, s # works! :)

#[allow(unused_imports)] // rust-analyzer seems to think this is unused, but it's not
use mipsy_lib::InstSet;

#[cfg(feature = "rt_yaml")]
Copy link
Collaborator

@spanishpear spanishpear Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intentional?

Copy link
Author

@whyvn whyvn Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it silences rust analyser :). the commit before the cleanup replaced #[allow(unused_imports)] with #[cfg(feature = "rt_yaml")] which also worked

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect your rust analyzer is not evaluating the cfg - we want this to still be conditional - and not included on every runs. Then include str from memory only exists for mipsy web where we want it bundled in, in other contexts (cli) then it's referencing the filesystem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh icic oops sorry :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about changing it do #[cfg(feature = "rt_yaml")]?

@whyvn
Copy link
Author

whyvn commented Sep 25, 2025

actually dont merge this yet cos working on another pr that might indirectly fix this :)

@whyvn
Copy link
Author

whyvn commented Sep 25, 2025

nevermind the other pr doesnt fix it so this can be merged when ready :)

@Dylan-Brotherston
Copy link
Collaborator

Does this emit correct and easy to understand errors if the value it larger than 5 bits?
shamt may only be a 5 bit value from 0-31.
You are allowing constants up to 16 bits.

@whyvn
Copy link
Author

whyvn commented Sep 26, 2025

the errors will be the same as the imemdiate because (0..32).contains(n) is still checked

yeah they are :) same as immediates

a = 32
sll $0, $0, a
error: failed to compile `/dev/stdin`
 --> /dev/stdin:2:1
  |
2 | sll $0, $0, a
  | ^^^^^^^^^^^^^ instruction `sll` exists but was given incorrect arguments
tip: valid formats for `sll`:
  - sll $Rd, $Rt, shift
  - sll $Rd, shift
  - sll $Rd, i16, shift
  - sll $Rd, u16, shift
  - sll $Rd, i32, shift
  - sll $Rd, u32, shift

sidenote maybe it should be more clear to explicitly say something like ... shift ([0,32)) in the error because currently it feels a bit misleading. something as simple as this maybe?

-ArgumentType::Shamt => write!(f, "shift"),
+ArgumentType::Shamt => write!(f, "shift ([0,31])"),

edit: in #307 better errors are supported to be explicit about the 0..32 range instead of being a generic incorrect argument error

@whyvn
Copy link
Author

whyvn commented Sep 30, 2025

yeah k this entire pr is indirectly eclipsed by #307 . not sure if it should bother being merged?

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.

3 participants