This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add Smaia and Ssaia extensions support
ClosedPublic

Authored by 4vtomat on Apr 11 2023, 8:10 PM.

Diff Detail

Event Timeline

4vtomat created this revision.Apr 11 2023, 8:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 8:10 PM
4vtomat requested review of this revision.Apr 11 2023, 8:10 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 11 2023, 8:10 PM

You need to update llvm/docs/RISCVUsage.rst too.

4vtomat updated this revision to Diff 512655.Apr 11 2023, 10:14 PM

Resolved Kito's comment.

asb added a comment.Apr 12 2023, 2:08 AM

This extension doesn't appear to be ratified but you've listed it in the table of ratified extensions and treated it as a ratified extension in RISCVISAInfo.cpp. I know that given we don't do checking for CSR names the distinction feels a bit academic, but I don't think this is the best approach. For CSR only extensions like this my feeling is we should review a patch like this ahead of ratification, but not land until it's actually ratified. One of the main goals (from my perspective at least) for allowing not-yet-ratified extensions upstream was to allow collaboration on the implementation, but given the simplicity of CSR-only extensions I'm not sure the cost/benefit makes sense vs just waiting for ratification when we can be sure the assigned numbers won't change. I'd be open to counter arguments though.

reames added a subscriber: reames.Apr 12 2023, 10:56 AM

I would be fine landing this as experimental before ratification. I see no real downside to doing that, and would essentially leave it the judgement of the patch author as to whether just waiting until ratification or doing the extra work for staging as experimental is worthwhile.

asb added a comment.Apr 12 2023, 11:40 AM

I would be fine landing this as experimental before ratification. I see no real downside to doing that

My concern would be that as we don't gate CSR names on enabling the relevant extension, people could start using CSR names and encodings that could change, without opting in via -menable-experimental-extensions, perhaps not realising that they're using the unratified version. OTOH, you could argue it was user error from the start by not trying to specify all the needed extensions in the ISA naming string.

4vtomat updated this revision to Diff 516137.Apr 23 2023, 2:56 AM

Resolved Alex's comment. Moved both of extensions to experimental.

My concern would be that as we don't gate CSR names on enabling the relevant extension, people could start using CSR names and encodings that could change, without opting in via -menable-experimental-extensions, perhaps not realising that they're using the unratified version. OTOH, you could argue it was user error from the start by not trying to specify all the needed extensions in the ISA naming string.

We decide don't gate CSR before, but I am wondering maybe we should gate those CSR if they are defined by a unratified/experimental ext., and remove the checking once it ratified, since it might change the name or CSR number before ratified.

asb added a comment.Apr 26 2023, 7:41 AM

My concern would be that as we don't gate CSR names on enabling the relevant extension, people could start using CSR names and encodings that could change, without opting in via -menable-experimental-extensions, perhaps not realising that they're using the unratified version. OTOH, you could argue it was user error from the start by not trying to specify all the needed extensions in the ISA naming string.

We decide don't gate CSR before, but I am wondering maybe we should gate those CSR if they are defined by a unratified/experimental ext., and remove the checking once it ratified, since it might change the name or CSR number before ratified.

That's definitely a risk, but at least when people try to do the "right" thing and specify the extension name in the ISA string, they'll quickly find out that the version supported in the compiler is experimental. Given the cost of marking such CSR extensions as experimental is near-zero, I think we might as well. I agree gating the CSR names might also make sense, but then we're back to the effort of testing this. I think our conclusions before were that nobody is particularly opposed to doing finer grained control of CSRs for new extensions at least (it's more problematic for the older CSRs given spec changes to move CSRs to separate extensions), so I think it would be find if someone wanted to implement that. I don't think we need that as a pre-requisite for this patch though, IMHO.

My concern would be that as we don't gate CSR names on enabling the relevant extension, people could start using CSR names and encodings that could change, without opting in via -menable-experimental-extensions, perhaps not realising that they're using the unratified version. OTOH, you could argue it was user error from the start by not trying to specify all the needed extensions in the ISA naming string.

We decide don't gate CSR before, but I am wondering maybe we should gate those CSR if they are defined by a unratified/experimental ext., and remove the checking once it ratified, since it might change the name or CSR number before ratified.

I think I agree with Kito here. Requiring gating for experimental extensions even if we don't gate ratified ones seems like a good way to address the issue of name collision risk in experimental extensions.

I'm less concerned about number reassignment. I'm most concerned that the same name might be reused across two extensions in a mutually incompatible way. This would clearly get fixed before both were ratified, but well, the entire point of experimental is that they not yet ratified.

asb added a comment.Apr 26 2023, 7:51 AM

FWIW, I've reviewed the CSR numbers vs the spec so LGTM from that perspective.

kito-cheng accepted this revision.Apr 28 2023, 12:27 AM
This revision is now accepted and ready to land.Apr 28 2023, 12:27 AM
This revision was automatically updated to reflect the committed changes.
asb added a comment.May 3 2023, 3:53 AM

Just noting for posterity that we discussed this at last week's RISC-V sync-up call and I think the tentative conclusion (there weren't particularly strong views) was that experiments CSRs should really be gated by -menable-experimental-extensions, with the CSR names gated so as to avoid the issues mentioned here.