//===-- IntrinsicLowering.cpp - Intrinsic Lowering default implementation -===// // // 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 the IntrinsicLowering class. // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; /// This function is used when we want to lower an intrinsic call to a call of /// an external function. This handles hard cases such as when there was already /// a prototype for the external function, but that prototype doesn't match the /// arguments we expect to pass in. template <class ArgIt> static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI, ArgIt ArgBegin, ArgIt ArgEnd, Type *RetTy) { … } /// Emit the code to lower bswap of V before the specified instruction IP. static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) { … } /// Emit the code to lower ctpop of V before the specified instruction IP. static Value *LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP) { … } /// Emit the code to lower ctlz of V before the specified instruction IP. static Value *LowerCTLZ(LLVMContext &Context, Value *V, Instruction *IP) { … } static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname, const char *Dname, const char *LDname) { … } void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { … } bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { … }