File indexing completed on 2026-05-10 08:44:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_TRANSFORMS_UTILS_BUILDLIBCALLS_H
0015 #define LLVM_TRANSFORMS_UTILS_BUILDLIBCALLS_H
0016
0017 #include "llvm/Analysis/TargetLibraryInfo.h"
0018
0019 namespace llvm {
0020 class Value;
0021 class DataLayout;
0022 class IRBuilderBase;
0023
0024
0025
0026
0027
0028
0029
0030
0031 bool inferNonMandatoryLibFuncAttrs(Module *M, StringRef Name,
0032 const TargetLibraryInfo &TLI);
0033 bool inferNonMandatoryLibFuncAttrs(Function &F, const TargetLibraryInfo &TLI);
0034
0035
0036
0037 FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI,
0038 LibFunc TheLibFunc, FunctionType *T,
0039 AttributeList AttributeList);
0040 FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI,
0041 LibFunc TheLibFunc, FunctionType *T);
0042 template <typename... ArgsTy>
0043 FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI,
0044 LibFunc TheLibFunc, AttributeList AttributeList,
0045 Type *RetTy, ArgsTy... Args) {
0046 SmallVector<Type*, sizeof...(ArgsTy)> ArgTys{Args...};
0047 return getOrInsertLibFunc(M, TLI, TheLibFunc,
0048 FunctionType::get(RetTy, ArgTys, false),
0049 AttributeList);
0050 }
0051
0052 template <typename... ArgsTy>
0053 FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI,
0054 LibFunc TheLibFunc, Type *RetTy, ArgsTy... Args) {
0055 return getOrInsertLibFunc(M, TLI, TheLibFunc, AttributeList{}, RetTy,
0056 Args...);
0057 }
0058
0059 template <typename... ArgsTy>
0060 FunctionCallee
0061 getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI,
0062 LibFunc TheLibFunc, AttributeList AttributeList,
0063 FunctionType *Invalid, ArgsTy... Args) = delete;
0064
0065
0066
0067
0068
0069
0070 void markRegisterParameterAttributes(Function *F);
0071
0072
0073
0074 bool isLibFuncEmittable(const Module *M, const TargetLibraryInfo *TLI,
0075 LibFunc TheLibFunc);
0076 bool isLibFuncEmittable(const Module *M, const TargetLibraryInfo *TLI,
0077 StringRef Name);
0078
0079
0080
0081 bool hasFloatFn(const Module *M, const TargetLibraryInfo *TLI, Type *Ty,
0082 LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn);
0083
0084
0085
0086 StringRef getFloatFn(const Module *M, const TargetLibraryInfo *TLI, Type *Ty,
0087 LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn,
0088 LibFunc &TheLibFunc);
0089
0090
0091
0092
0093 Value *emitStrLen(Value *Ptr, IRBuilderBase &B, const DataLayout &DL,
0094 const TargetLibraryInfo *TLI);
0095
0096
0097
0098
0099 Value *emitStrDup(Value *Ptr, IRBuilderBase &B, const TargetLibraryInfo *TLI);
0100
0101
0102
0103
0104 Value *emitStrChr(Value *Ptr, char C, IRBuilderBase &B,
0105 const TargetLibraryInfo *TLI);
0106
0107
0108 Value *emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B,
0109 const DataLayout &DL, const TargetLibraryInfo *TLI);
0110
0111
0112
0113 Value *emitStrCpy(Value *Dst, Value *Src, IRBuilderBase &B,
0114 const TargetLibraryInfo *TLI);
0115
0116
0117
0118 Value *emitStpCpy(Value *Dst, Value *Src, IRBuilderBase &B,
0119 const TargetLibraryInfo *TLI);
0120
0121
0122
0123 Value *emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B,
0124 const TargetLibraryInfo *TLI);
0125
0126
0127
0128 Value *emitStpNCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B,
0129 const TargetLibraryInfo *TLI);
0130
0131
0132
0133 Value *emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize,
0134 IRBuilderBase &B, const DataLayout &DL,
0135 const TargetLibraryInfo *TLI);
0136
0137
0138 Value *emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B,
0139 const DataLayout &DL, const TargetLibraryInfo *TLI);
0140
0141
0142
0143 Value *emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B,
0144 const DataLayout &DL, const TargetLibraryInfo *TLI);
0145
0146
0147 Value *emitMemRChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B,
0148 const DataLayout &DL, const TargetLibraryInfo *TLI);
0149
0150
0151 Value *emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B,
0152 const DataLayout &DL, const TargetLibraryInfo *TLI);
0153
0154
0155 Value *emitBCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B,
0156 const DataLayout &DL, const TargetLibraryInfo *TLI);
0157
0158
0159 Value *emitMemCCpy(Value *Ptr1, Value *Ptr2, Value *Val, Value *Len,
0160 IRBuilderBase &B, const TargetLibraryInfo *TLI);
0161
0162
0163 Value *emitSNPrintf(Value *Dest, Value *Size, Value *Fmt,
0164 ArrayRef<Value *> Args, IRBuilderBase &B,
0165 const TargetLibraryInfo *TLI);
0166
0167
0168 Value *emitSPrintf(Value *Dest, Value *Fmt, ArrayRef<Value *> VariadicArgs,
0169 IRBuilderBase &B, const TargetLibraryInfo *TLI);
0170
0171
0172 Value *emitStrCat(Value *Dest, Value *Src, IRBuilderBase &B,
0173 const TargetLibraryInfo *TLI);
0174
0175
0176 Value *emitStrLCpy(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B,
0177 const TargetLibraryInfo *TLI);
0178
0179
0180 Value *emitStrLCat(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B,
0181 const TargetLibraryInfo *TLI);
0182
0183
0184 Value *emitStrNCat(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B,
0185 const TargetLibraryInfo *TLI);
0186
0187
0188 Value *emitVSNPrintf(Value *Dest, Value *Size, Value *Fmt, Value *VAList,
0189 IRBuilderBase &B, const TargetLibraryInfo *TLI);
0190
0191
0192 Value *emitVSPrintf(Value *Dest, Value *Fmt, Value *VAList, IRBuilderBase &B,
0193 const TargetLibraryInfo *TLI);
0194
0195
0196
0197
0198
0199 Value *emitUnaryFloatFnCall(Value *Op, const TargetLibraryInfo *TLI,
0200 StringRef Name, IRBuilderBase &B,
0201 const AttributeList &Attrs);
0202
0203
0204
0205 Value *emitUnaryFloatFnCall(Value *Op, const TargetLibraryInfo *TLI,
0206 LibFunc DoubleFn, LibFunc FloatFn,
0207 LibFunc LongDoubleFn, IRBuilderBase &B,
0208 const AttributeList &Attrs);
0209
0210
0211
0212
0213
0214 Value *emitBinaryFloatFnCall(Value *Op1, Value *Op2,
0215 const TargetLibraryInfo *TLI,
0216 StringRef Name, IRBuilderBase &B,
0217 const AttributeList &Attrs);
0218
0219
0220
0221 Value *emitBinaryFloatFnCall(Value *Op1, Value *Op2,
0222 const TargetLibraryInfo *TLI, LibFunc DoubleFn,
0223 LibFunc FloatFn, LibFunc LongDoubleFn,
0224 IRBuilderBase &B, const AttributeList &Attrs);
0225
0226
0227 Value *emitPutChar(Value *Char, IRBuilderBase &B,
0228 const TargetLibraryInfo *TLI);
0229
0230
0231 Value *emitPutS(Value *Str, IRBuilderBase &B, const TargetLibraryInfo *TLI);
0232
0233
0234
0235 Value *emitFPutC(Value *Char, Value *File, IRBuilderBase &B,
0236 const TargetLibraryInfo *TLI);
0237
0238
0239
0240 Value *emitFPutS(Value *Str, Value *File, IRBuilderBase &B,
0241 const TargetLibraryInfo *TLI);
0242
0243
0244
0245 Value *emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilderBase &B,
0246 const DataLayout &DL, const TargetLibraryInfo *TLI);
0247
0248
0249 Value *emitMalloc(Value *Num, IRBuilderBase &B, const DataLayout &DL,
0250 const TargetLibraryInfo *TLI);
0251
0252
0253 Value *emitCalloc(Value *Num, Value *Size, IRBuilderBase &B,
0254 const TargetLibraryInfo &TLI, unsigned AddrSpace);
0255
0256
0257 Value *emitHotColdNew(Value *Num, IRBuilderBase &B,
0258 const TargetLibraryInfo *TLI, LibFunc NewFunc,
0259 uint8_t HotCold);
0260 Value *emitHotColdNewNoThrow(Value *Num, Value *NoThrow, IRBuilderBase &B,
0261 const TargetLibraryInfo *TLI, LibFunc NewFunc,
0262 uint8_t HotCold);
0263 Value *emitHotColdNewAligned(Value *Num, Value *Align, IRBuilderBase &B,
0264 const TargetLibraryInfo *TLI, LibFunc NewFunc,
0265 uint8_t HotCold);
0266 Value *emitHotColdNewAlignedNoThrow(Value *Num, Value *Align, Value *NoThrow,
0267 IRBuilderBase &B,
0268 const TargetLibraryInfo *TLI,
0269 LibFunc NewFunc, uint8_t HotCold);
0270 Value *emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B,
0271 const TargetLibraryInfo *TLI,
0272 LibFunc NewFunc, uint8_t HotCold);
0273 Value *emitHotColdSizeReturningNewAligned(Value *Num, Value *Align,
0274 IRBuilderBase &B,
0275 const TargetLibraryInfo *TLI,
0276 LibFunc NewFunc, uint8_t HotCold);
0277 }
0278
0279 #endif