This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Prevent __builtin_riscv_orc_b_64 from being compiled RV32 target.
ClosedPublic

Authored by craig.topper on Apr 6 2021, 12:19 PM.

Details

Summary

The backend can't handle this and will throw a fatal error from
type legalization. It's easy enough to fix that for this intrinsic
by just splitting the IR intrinsic since it works on individual bytes.

There will be other intrinsics in the future that would be harder
to support through splitting, for example grev, gorc, and shfl. Those
would require a compare and a select be inserted to check the MSB of
their control input.

This patch adds support for preventing this in the frontend with
a nice diagnostic.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 6 2021, 12:19 PM
craig.topper requested review of this revision.Apr 6 2021, 12:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2021, 12:19 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
frasercrmck added inline comments.Apr 8 2021, 1:49 AM
clang/lib/Basic/Targets/RISCV.cpp
259

What's the difference between this new feature and riscv64 above?

craig.topper added inline comments.Apr 8 2021, 8:25 AM
clang/lib/Basic/Targets/RISCV.cpp
259

The name I added to initFeatureMap has to match the feature name in RISCV.td because it will end up in the target-features attribute in IR.

SemaChecking just calls hasFeature, but CodeGenFunction also checks builtin features using the feature map. We check features in SemaChecking because the CodeGenFunction diagnostic isn’t phrased well for RISCV.

frasercrmck accepted this revision.Apr 8 2021, 8:54 AM
frasercrmck added inline comments.
clang/lib/Basic/Targets/RISCV.cpp
259

Ah I see, so since it has to match our "64bit" SubtargetFeature we can't reuse "riscv64"? Thanks.

This revision is now accepted and ready to land.Apr 8 2021, 8:54 AM
craig.topper added inline comments.Apr 8 2021, 9:11 AM
clang/lib/Basic/Targets/RISCV.cpp
259

Correct.