Map ieee_fma intrinsic to LLVM IR as llvm.fma.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Most target architectures support FMA and related instructions, and there's a standard IEEE_FMA generic function in the intrinsic module IEEE_ARITHMETIC in Fortran 2018. Please implement FMA in a way that is not just for RISC-V.
Address @klausler's comment. And, I’m not sure if the fmadd intrinsic is in the right place in the intrinsic.md.
Don't add a new nonstandard intrinsic when the standard already has a standard name for FMA, namely the procedure IEEE_FMA in the intrinsic module IEEE_ARITHMETIC. See subclause 17.11.4 in Fortran 2018.
The technique that has worked for us in the implementation of other procedures in intrinsic modules is to first declare a builtin intrinsic procedure, say "builtin_fma", in the module fortran_builtins, and then rename it in the intrinsic module via "use fortran_builtins, only: ieee_fma => builtin_fma". Then implement "builtin_fma" like any other standard intrinsic function. If you look in fortran_builtins for declarations of other INTRINSIC procedures, you'll be able to find useful examples.
flang/lib/Evaluate/intrinsics.cpp | ||
---|---|---|
884 | IEEE_FMA doesn't work for COMPLEX. Use "SameReal" here, not "SameFloating". |
IEEE_FMA doesn't work for COMPLEX. Use "SameReal" here, not "SameFloating".