//===-- PPCLowerMASSVEntries.cpp ------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements lowering of MASSV (SIMD) entries for specific PowerPC // subtargets. // Following is an example of a conversion specific to Power9 subtarget: // __sind2_massv ---> __sind2_P9 // //===----------------------------------------------------------------------===// #include "PPC.h" #include "PPCSubtarget.h" #include "PPCTargetMachine.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #define DEBUG_TYPE … usingnamespacellvm; namespace { static StringRef MASSVFuncs[] = …; class PPCLowerMASSVEntries : public ModulePass { … }; } // namespace /// Checks if the specified function name represents an entry in the MASSV /// library. bool PPCLowerMASSVEntries::isMASSVFunc(StringRef Name) { … } // FIXME: /// Returns a string corresponding to the specified PowerPC subtarget. e.g.: /// "_P8" for Power8, "_P9" for Power9. The string is used as a suffix while /// generating subtarget-specific MASSV library functions. Current support /// includes minimum subtarget Power8 for Linux and Power7 for AIX. StringRef PPCLowerMASSVEntries::getCPUSuffix(const PPCSubtarget *Subtarget) { … } /// Creates PowerPC subtarget-specific name corresponding to the specified /// generic MASSV function, and the PowerPC subtarget. std::string PPCLowerMASSVEntries::createMASSVFuncName(Function &Func, const PPCSubtarget *Subtarget) { … } /// If there are proper fast-math flags, this function creates llvm.pow /// intrinsics when the exponent is 0.25 or 0.75. bool PPCLowerMASSVEntries::handlePowSpecialCases(CallInst *CI, Function &Func, Module &M) { … } /// Lowers generic MASSV entries to PowerPC subtarget-specific MASSV entries. /// e.g.: __sind2_massv --> __sind2_P9 for a Power9 subtarget. /// Both function prototypes and their callsites are updated during lowering. bool PPCLowerMASSVEntries::lowerMASSVCall(CallInst *CI, Function &Func, Module &M, const PPCSubtarget *Subtarget) { … } bool PPCLowerMASSVEntries::runOnModule(Module &M) { … } char PPCLowerMASSVEntries::ID = …; char &llvm::PPCLowerMASSVEntriesID = …; INITIALIZE_PASS(…) ModulePass *llvm::createPPCLowerMASSVEntriesPass() { … }