This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add errors for mixing Zcmp with C/Zcd and D.
ClosedPublic

Authored by craig.topper on Jun 16 2023, 11:16 AM.

Details

Summary

We already had an error for Zcmt though it appears to be untested
Add similar one for Zcmp along with tests for both.

Factor the code to share the strings as much as possible.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 16 2023, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 11:16 AM
craig.topper requested review of this revision.Jun 16 2023, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2023, 11:16 AM
VincentWu added inline comments.Jun 16 2023, 11:14 PM
llvm/lib/Support/RISCVISAInfo.cpp
900–901

I found there might be a problem about predicate of Zcd

Zcd contains: c.fld, c.fldsp, c.fsd, c.fsdsp, witch is a subset of D ext.
it directly depends on Zca instead of C ext.

Thus, c.fld, c.fldsp, c.fsd, c.fsdsp are valid when HasZcd || (HasD && HasC)

Zcmp is directly incompatible with Zcd, so there should be two error msg

'Zcmp' extension is incompatible with 'Zcd'
and 'Zcmp' extension is incompatible with both 'C' and 'D' are enabled

900–901

same problem also happens on MC layer.

I am trying to fix it by

def HasCompressedDoubleFloat
    : Predicate<"Subtarget->hasStdExtZcd() || (Subtarget->hasStdExtC() && Subtarget->hasStdExtC())">,
                AssemblerPredicate<(any_of FeatureStdExtZcd, (all_of FeatureStdExtD, FeatureStdExtC)),
                                   "'Zcd' (Compressed Double-Precision Floating-Point Instructions) or "
                                   "both 'C' (Compressed Instructions) and "
                                   "'D' (Double-Precision Floating-Point)">;

but it seems AssemblerPredicate can't process nested conditions

craig.topper added inline comments.Jun 16 2023, 11:52 PM
llvm/lib/Support/RISCVISAInfo.cpp
900–901

I don't think the Zcd instructions should be enabled without D. That's not a very useful behavior. There wouldn't be much point in making CPU support Zcd without D.

craig.topper added inline comments.Jun 17 2023, 12:09 AM
llvm/lib/Support/RISCVISAInfo.cpp
900–901

I think Zcd might imply D and Zcf on RV32 might imply F. That was stated by Krste here https://lists.riscv.org/g/tech-code-size/message/1544

I think even the normative text can state Zcf requires F and Zcd
requires D (which means it also requires F).  It's OK for normative
text to be redundant at times, and I think this would reduce
confusion.
This revision is now accepted and ready to land.Jun 20 2023, 10:24 PM
This revision was landed with ongoing or failed builds.Jun 21 2023, 12:11 AM
This revision was automatically updated to reflect the committed changes.