003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/lib/Target/PowerPC
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
lib
/
Target
/
PowerPC
/
📁
..
📁
AsmParser
📁
Disassembler
📁
MCTargetDesc
📄
P9InstrResources.td
(37.36 KB)
📄
PPC.h
(4.69 KB)
📄
PPC.td
(32.37 KB)
📄
PPCAsmPrinter.cpp
(70.77 KB)
📄
PPCBoolRetToInt.cpp
(9.97 KB)
📄
PPCBranchCoalescing.cpp
(30.16 KB)
📄
PPCBranchSelector.cpp
(15.97 KB)
📄
PPCCCState.cpp
(1.08 KB)
📄
PPCCCState.h
(1.19 KB)
📄
PPCCTRLoops.cpp
(6.68 KB)
📄
PPCCallingConv.cpp
(6.19 KB)
📄
PPCCallingConv.h
(1.97 KB)
📄
PPCCallingConv.td
(16.32 KB)
📄
PPCEarlyReturn.cpp
(7.14 KB)
📄
PPCExpandISEL.cpp
(17.93 KB)
📄
PPCFastISel.cpp
(85.51 KB)
📄
PPCFrameLowering.cpp
(98.6 KB)
📄
PPCFrameLowering.h
(7.46 KB)
📄
PPCHazardRecognizers.cpp
(14.02 KB)
📄
PPCHazardRecognizers.h
(3.83 KB)
📄
PPCISelDAGToDAG.cpp
(256.88 KB)
📄
PPCISelLowering.cpp
(669.73 KB)
📄
PPCISelLowering.h
(55.9 KB)
📄
PPCInstr64Bit.td
(75.68 KB)
📄
PPCInstrAltivec.td
(77.68 KB)
📄
PPCInstrBuilder.h
(1.5 KB)
📄
PPCInstrFormats.td
(57.38 KB)
📄
PPCInstrHTM.td
(5.48 KB)
📄
PPCInstrInfo.cpp
(171.06 KB)
📄
PPCInstrInfo.h
(29.06 KB)
📄
PPCInstrInfo.td
(233.39 KB)
📄
PPCInstrPrefix.td
(41.72 KB)
📄
PPCInstrQPX.td
(57.56 KB)
📄
PPCInstrSPE.td
(49.71 KB)
📄
PPCInstrVSX.td
(223.48 KB)
📄
PPCLoopInstrFormPrep.cpp
(33.45 KB)
📄
PPCLowerMASSVEntries.cpp
(6.42 KB)
📄
PPCMCInstLower.cpp
(6.62 KB)
📄
PPCMIPeephole.cpp
(63.48 KB)
📄
PPCMachineFunctionInfo.cpp
(2.59 KB)
📄
PPCMachineFunctionInfo.h
(9.15 KB)
📄
PPCMachineScheduler.cpp
(4.03 KB)
📄
PPCMachineScheduler.h
(1.81 KB)
📄
PPCMacroFusion.cpp
(6.68 KB)
📄
PPCMacroFusion.def
(1.8 KB)
📄
PPCMacroFusion.h
(886 B)
📄
PPCPerfectShuffle.h
(397.57 KB)
📄
PPCPfmCounters.td
(705 B)
📄
PPCPreEmitPeephole.cpp
(13.36 KB)
📄
PPCQPXLoadSplat.cpp
(5.31 KB)
📄
PPCReduceCRLogicals.cpp
(28.66 KB)
📄
PPCRegisterInfo.cpp
(51.93 KB)
📄
PPCRegisterInfo.h
(6.61 KB)
📄
PPCRegisterInfo.td
(14.24 KB)
📄
PPCSchedule.td
(5.21 KB)
📄
PPCSchedule440.td
(34.57 KB)
📄
PPCScheduleA2.td
(7.85 KB)
📄
PPCScheduleE500.td
(16.59 KB)
📄
PPCScheduleE500mc.td
(20.89 KB)
📄
PPCScheduleE5500.td
(23.62 KB)
📄
PPCScheduleG3.td
(4.49 KB)
📄
PPCScheduleG4.td
(5.42 KB)
📄
PPCScheduleG4Plus.td
(6.45 KB)
📄
PPCScheduleG5.td
(7.1 KB)
📄
PPCScheduleP7.td
(22.26 KB)
📄
PPCScheduleP8.td
(23.96 KB)
📄
PPCScheduleP9.td
(12.27 KB)
📄
PPCSubtarget.cpp
(7.58 KB)
📄
PPCSubtarget.h
(13.21 KB)
📄
PPCTLSDynamicCall.cpp
(6.53 KB)
📄
PPCTOCRegDeps.cpp
(5.3 KB)
📄
PPCTargetMachine.cpp
(18.94 KB)
📄
PPCTargetMachine.h
(2.2 KB)
📄
PPCTargetObjectFile.cpp
(2.45 KB)
📄
PPCTargetObjectFile.h
(1.19 KB)
📄
PPCTargetStreamer.h
(1.02 KB)
📄
PPCTargetTransformInfo.cpp
(38.72 KB)
📄
PPCTargetTransformInfo.h
(5.6 KB)
📄
PPCVSXCopy.cpp
(5.68 KB)
📄
PPCVSXFMAMutate.cpp
(15.12 KB)
📄
PPCVSXSwapRemoval.cpp
(36.78 KB)
📄
README_P9.txt
(22.25 KB)
📁
TargetInfo
Editing: PPCLowerMASSVEntries.cpp
//===-- 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/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" #define DEBUG_TYPE "ppc-lower-massv-entries" using namespace llvm; namespace { // Length of the suffix "massv", which is specific to IBM MASSV library entries. const unsigned MASSVSuffixLength = 5; static StringRef MASSVFuncs[] = { #define TLI_DEFINE_MASSV_VECFUNCS_NAMES #include "llvm/Analysis/VecFuncs.def" }; class PPCLowerMASSVEntries : public ModulePass { public: static char ID; PPCLowerMASSVEntries() : ModulePass(ID) {} bool runOnModule(Module &M) override; StringRef getPassName() const override { return "PPC Lower MASS Entries"; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<TargetTransformInfoWrapperPass>(); } private: static bool isMASSVFunc(StringRef Name); static StringRef getCPUSuffix(const PPCSubtarget *Subtarget); static std::string createMASSVFuncName(Function &Func, const PPCSubtarget *Subtarget); bool handlePowSpecialCases(CallInst *CI, Function &Func, Module &M); bool lowerMASSVCall(CallInst *CI, Function &Func, Module &M, const PPCSubtarget *Subtarget); }; } // namespace /// Checks if the specified function name represents an entry in the MASSV /// library. bool PPCLowerMASSVEntries::isMASSVFunc(StringRef Name) { auto Iter = std::find(std::begin(MASSVFuncs), std::end(MASSVFuncs), Name); return Iter != std::end(MASSVFuncs); } // 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 Power8 and Power9 subtargets. StringRef PPCLowerMASSVEntries::getCPUSuffix(const PPCSubtarget *Subtarget) { // Assume Power8 when Subtarget is unavailable. if (!Subtarget) return "P8"; if (Subtarget->hasP9Vector()) return "P9"; if (Subtarget->hasP8Vector()) return "P8"; report_fatal_error("Unsupported Subtarget: MASSV is supported only on " "Power8 and Power9 subtargets."); } /// 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) { StringRef Suffix = getCPUSuffix(Subtarget); auto GenericName = Func.getName().drop_back(MASSVSuffixLength).str(); std::string MASSVEntryName = GenericName + Suffix.str(); return MASSVEntryName; } /// 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) { if (Func.getName() != "__powf4_massv" && Func.getName() != "__powd2_massv") return false; if (Constant *Exp = dyn_cast<Constant>(CI->getArgOperand(1))) if (ConstantFP *CFP = dyn_cast<ConstantFP>(Exp->getSplatValue())) { // If the argument is 0.75 or 0.25 it is cheaper to turn it into pow // intrinsic so that it could be optimzed as sequence of sqrt's. if (!CI->hasNoInfs() || !CI->hasApproxFunc()) return false; if (!CFP->isExactlyValue(0.75) && !CFP->isExactlyValue(0.25)) return false; if (CFP->isExactlyValue(0.25) && !CI->hasNoSignedZeros()) return false; CI->setCalledFunction( Intrinsic::getDeclaration(&M, Intrinsic::pow, CI->getType())); return true; } return false; } /// 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) { if (CI->use_empty()) return false; // Handling pow(x, 0.25), pow(x, 0.75), powf(x, 0.25), powf(x, 0.75) if (handlePowSpecialCases(CI, Func, M)) return true; std::string MASSVEntryName = createMASSVFuncName(Func, Subtarget); FunctionCallee FCache = M.getOrInsertFunction( MASSVEntryName, Func.getFunctionType(), Func.getAttributes()); CI->setCalledFunction(FCache); return true; } bool PPCLowerMASSVEntries::runOnModule(Module &M) { bool Changed = false; auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); if (!TPC) return Changed; auto &TM = TPC->getTM<PPCTargetMachine>(); const PPCSubtarget *Subtarget; for (Function &Func : M) { if (!Func.isDeclaration()) continue; if (!isMASSVFunc(Func.getName())) continue; // Call to lowerMASSVCall() invalidates the iterator over users upon // replacing the users. Precomputing the current list of users allows us to // replace all the call sites. SmallVector<User *, 4> MASSVUsers; for (auto *User: Func.users()) MASSVUsers.push_back(User); for (auto *User : MASSVUsers) { auto *CI = dyn_cast<CallInst>(User); if (!CI) continue; Subtarget = &TM.getSubtarget<PPCSubtarget>(*CI->getParent()->getParent()); Changed |= lowerMASSVCall(CI, Func, M, Subtarget); } } return Changed; } char PPCLowerMASSVEntries::ID = 0; char &llvm::PPCLowerMASSVEntriesID = PPCLowerMASSVEntries::ID; INITIALIZE_PASS(PPCLowerMASSVEntries, DEBUG_TYPE, "Lower MASSV entries", false, false) ModulePass *llvm::createPPCLowerMASSVEntriesPass() { return new PPCLowerMASSVEntries(); }
Upload File
Create Folder