This is an archive of the discontinued LLVM Phabricator instance.

[Flang][RISCV] Adding intrinsics of RV64 Zb* extentions
Needs ReviewPublic

Authored by sunshaoce on Jun 5 2023, 2:17 AM.

Details

Summary

Similiar to D143951. These intrinsics have been added in clang/Basic/BuiltinsRISCV.def.

Diff Detail

Event Timeline

sunshaoce created this revision.Jun 5 2023, 2:17 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 5 2023, 2:17 AM
sunshaoce requested review of this revision.Jun 5 2023, 2:17 AM
pscoro added inline comments.Jun 5 2023, 6:25 AM
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
562

FYI there is a patch open: https://reviews.llvm.org/D151812 that replaces all of these static mlir::FunctionType generators with a single generic function..

If this patch lands first I will rebase the other patch to replace genIntIntFuncType. Are you ok with rebasing this patch if the other patch lands first?

sunshaoce marked an inline comment as done.Jun 5 2023, 7:05 AM
sunshaoce added inline comments.
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
562

Thank you for the reminder! I will rebase this patch according to the situation.

pscoro added inline comments.Jun 5 2023, 10:08 AM
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
1019

As another FYI, we plan on moving all our PowerPC-specific code out of IntrinsicCall.cpp/.h after the function type generator patch lands (https://reviews.llvm.org/D151812). There is no review yet for this planned patch since we are waiting for the function type generator patch to land first as a dependency. I expect that RISCV may be interested in a similar approach (in a future patch) to help with keeping standard intrinsics separate from intrinsic extensions.

The basic structure of this future patch is new PPCIntrinsicCall.cpp/.h files that define a struct PPCIntrinsicLibrary : public IntrinsicLibrary that contains the generator functions for PPC-specific intrinsics and we moved the definitions of ppcHandlers, ppcMathOperations to PPCIntrinsicCall.h

I will try to remember to link the patch here when its created if this patch is still open

sunshaoce marked 2 inline comments as done.Jun 5 2023, 10:51 AM
sunshaoce added inline comments.
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
1019

Based on your information, I will wait for the PPC-related intrinsics land before modifying the RISCV-related intrinsics. Thank you very much for your contribution in this regard, especially in relation to vector-related aspects, which has been of great help to RISC-V.

sunshaoce updated this revision to Diff 532361.Jun 16 2023, 8:46 PM
sunshaoce marked an inline comment as done.

Rebased

sunshaoce updated this revision to Diff 532401.Jun 17 2023, 7:36 AM

As the PPC-related D151812 and D152460 have already landed, I think it's time to start reviewing this patch. Thanks!

Did you check somewhere that the zb* extension is available?

sunshaoce updated this revision to Diff 532774.Jun 19 2023, 7:03 PM

Added a check for whether Zb* extensions are enabled

sunshaoce updated this revision to Diff 534216.Jun 24 2023, 7:52 AM

Fix the occasional error: No explicit type declared for '__builtin_c_ptr'

Fix CI failure

Does anything prevent the use of i64 intrinsics on RV32? The RISC-V backend does not have support for that.

flang/lib/Optimizer/Builder/RISCVIntrinsicCall.cpp
23

RISCV -> RISC-V

craig.topper added inline comments.Jul 3 2023, 10:44 AM
flang/test/Lower/RISCV/riscv-zbkb-intrinsics.f90
20

Zip and unzip are RV32-only instructions. This is an RV64 test.

sunshaoce updated this revision to Diff 537207.Jul 4 2023, 8:53 PM
sunshaoce marked an inline comment as done.

Because flang does not support RISC-V 32 currently, I have temporarily removed the zip and unzip instructions.

sunshaoce retitled this revision from [Flang][RISCV] Adding intrinsics of zb* extention to [Flang][RISCV] Adding intrinsics of RV64 Zb* extentions.Jul 4 2023, 8:55 PM
tschuett added inline comments.Jul 4 2023, 10:48 PM
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
1187

Does this check include 32 and 64 modes?

sunshaoce marked an inline comment as done.Jul 5 2023, 12:39 AM
sunshaoce added inline comments.
flang/lib/Optimizer/Builder/IntrinsicCall.cpp
1187

Yes, this is reserved for RV32.

sunshaoce updated this revision to Diff 540330.Jul 14 2023, 2:20 AM

Try to fix build fails