//===-- PPCGenScalarMASSEntries.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 transformation converts standard math functions into their // corresponding MASS (scalar) entries for PowerPC targets. // Following are examples of such conversion: // tanh ---> __xl_tanh_finite // Such lowering is legal under the fast-math option. // //===----------------------------------------------------------------------===// #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 … usingnamespacellvm; namespace { class PPCGenScalarMASSEntries : public ModulePass { … }; } // namespace // Returns true if 'afn' flag exists on the call instruction with the math // function bool PPCGenScalarMASSEntries::isCandidateSafeToLower(const CallInst &CI) const { … } // Returns true if 'nnan', 'ninf' and 'nsz' flags exist on the call instruction // with the math function bool PPCGenScalarMASSEntries::isFiniteCallSafe(const CallInst &CI) const { … } /// Lowers scalar math functions to scalar MASS functions. /// e.g.: tanh --> __xl_tanh_finite or __xl_tanh /// Both function prototype and its callsite is updated during lowering. bool PPCGenScalarMASSEntries::createScalarMASSCall(StringRef MASSEntry, CallInst &CI, Function &Func) const { … } bool PPCGenScalarMASSEntries::runOnModule(Module &M) { … } char PPCGenScalarMASSEntries::ID = …; char &llvm::PPCGenScalarMASSEntriesID = …; INITIALIZE_PASS(…) ModulePass *llvm::createPPCGenScalarMASSEntriesPass() { … }