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

Add support for RV32IM without division #45

Open
luismarques opened this issue Sep 26, 2017 · 4 comments
Open

Add support for RV32IM without division #45

luismarques opened this issue Sep 26, 2017 · 4 comments

Comments

@luismarques
Copy link
Contributor

Could we add something like -mattr=+m,-div or -mattr=+mul to generate multiplication instructions but not division (and remainder, etc.) instructions?

I'm not the only one who wants this. For instance: https://twitter.com/jangray/status/877188603440316416

@luismarques luismarques changed the title Add support for RV32iM without division Add support for RV32IM without division Sep 26, 2017
@jrrk
Copy link
Member

jrrk commented Sep 26, 2017 via email

@asb
Copy link
Member

asb commented Sep 27, 2017

This sort of thing has also come up on the mailing lists. I think it's inevitable we'll need to support this sort of flexibility, though it's not clear exactly how it should be expressed (specifically, are there lots of cases beyond the mul/div issues where you need this fine-grained approach?).

There's also the issue with the "U-mode" instructions like rdcycle, which sadly will trap on M-mode only implementations. I wish implementers of M-mode-only cores would just alias it to reading the M-mode cycle CSR to give us a single common ISA baseline, but it seems that's not the preferred approach. If targeting one of these cores, it would be nice if LLVM knew to complain when trying to use rdcycle.

Different "profiles" has been discussed as one potential approach, but nobody has really elaborated how this would work, and enumerated what these profiles might look like. Whatever the solution, we should try and coordinate with GCC to keep a uniform interface.

@matthiasgoergens
Copy link

Also + - * / form a closed group so it is inelegant to leave one out.

What do you mean by 'closed group'? The for operations you mention form a field. If you leave out division, you get a ring which is also an important structure, and not at all 'inelegant'.

@jrrk
Copy link
Member

jrrk commented Jan 11, 2023

I meant inelegant from an engineering standpoint, not mathematically. Without division, the programmer would have to know that divisions were performed in a slow software loop, and apply appropriate workarounds, for example division by some constant c might be replaced by multiplying by (2^16)/c, with associated rounding issues to be considered. In my hand-waving way I represented a closed group as being a set of integers which applied to any of those operators would always lead to another integer (if you exclude the irritating divide by zero case). Anyway, I think the statute of limitations has run out on that remark since I said it over five years ago.

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

4 participants