-
Notifications
You must be signed in to change notification settings - Fork 9
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
How would you feel about macrofying more of the implementation? #106
Comments
Macros would probably be fine? Long ago when the crate was made RA was pretty bad at expanding macros and so couldn't give code suggestions of macro functions and stuff, but these days it's usually pretty good about it. A particular function can always just not be a macro if necessary, but for the simple functions a macro is probably fine. On a slightly similar note: I've seen |
Out of curiosity, what issues did you encounter with |
I'll admit I didn't investigate the situation extremely closely at the time, but by mixing All that said, while typing this message I remembered that this crate is only |
Mmm... sounds bug-report-worthy to me if you reproduce it again someday. Searching a bit through rustc issues, there seems to have been a number of issues concerning funky soundness issues linked to LLVM inlining before, hopefully that was one of those that got fixed... At least one of them happened in the presence of |
While investigating #105 and #104, I noticed that there is a lot of duplicated patterns in the code, like this sort of function declaration header...
...and most implementations follow a very simple pattern like "pass through the elements to the intrinsic, possibly with some .0 access, and get the result back" or "get the immediate const and use it as the rightmost argument to the intrinsic".
Replacing as many of these patterns as possible with code generation macros would have some advantages:
#[must_use]
, but you did not do it everywhere in a seemingly inconsistent way which suggests you forgot / did not find the motivation to propagate it).It would also have some maintainability drawbacks: even declarative macros have quite arcane syntax that makes them hard to write, debug and extend. So more suffering when you or someone else needs to edit the macro. Also IDE-style tooling like rust-analyzer tends to just give up inside of macros, so things like autoformat and autocompletion may not work as nicely as usual when editing code.
On the neutral side, there are some things we can't do with (declarative) macros and still need to copy-paste by hand if we're not ready to go all the way to procedural macros (which I would not advise). This most importantly includes links to the intrinsics in the documentation.
To help gauge the tradeoff, I tried my hand at a quick prototype that does the codegen work for the small adx instruction set using declarative macros. The macro would obviously get more complex as more instruction sets are added, but I think this already gives a fairly good feeling of what the end result would look like : HadrienG2/safe_arch@main...HadrienG2:safe_arch:macrofy .
How would you feel about this change?
The text was updated successfully, but these errors were encountered: