LLVM: lib/Analysis/TargetLibraryInfo.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

21using namespace llvm;

22

27 "No vector functions library"),

29 "Accelerate framework"),

31 "Darwin_libsystem_m", "Darwin libsystem_m"),

33 "GLIBC Vector Math library"),

35 "IBM MASS vector library"),

37 "Intel SVML library"),

39 "SIMD Library for Evaluating Elementary Functions"),

41 "Arm Performance Libraries"),

43 "AMD vector math library")));

44

45StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =

46 {

47#define TLI_DEFINE_STRING

48#include "llvm/Analysis/TargetLibraryInfo.def"

49};

50

52 assert(!VectorFnName.empty() && "Vector function name must not be empty.");

55 Out << VABIPrefix << "_" << ScalarFnName << "(" << VectorFnName << ")";

56 return std::string(Out.str());

57}

58

59

61 Void = 0,

62 Bool,

67 Long,

68 IntX,

70 LLong,

73 Flt,

74 Dbl,

75 LDbl,

77 Ptr,

79 Ellip,

80 Same,

81};

82

84

86#define TLI_DEFINE_SIG

87#include "llvm/Analysis/TargetLibraryInfo.def"

88};

89

91 "Missing library function signatures");

92

94

95 if (T.isOSDarwin())

96 return false;

97

98

100 return false;

101

102 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9))

103 return false;

104

105 if (T.isiOS() && T.isOSVersionLT(7, 0))

106 return false;

107

108 return true;

109}

110

112

113

114 if (TT.isOSLinux())

115 return TT.isGNUEnvironment() || TT.isMusl();

116

117

118 return TT.isOSFreeBSD() || TT.isOSSolaris();

119}

120

123 switch (CC) {

124 default:

125 return false;

127 return true;

131

132

133

134 if (Triple(TT).isiOS())

135 return false;

136

137 if (!FuncTy->getReturnType()->isPointerTy() &&

138 !FuncTy->getReturnType()->isIntegerTy() &&

139 !FuncTy->getReturnType()->isVoidTy())

140 return false;

141

142 for (auto *Param : FuncTy->params()) {

143 if (!Param->isPointerTy() && !Param->isIntegerTy())

144 return false;

145 }

146 return true;

147 }

148 }

149 return false;

150}

151

153 return ::isCallingConvCCompatible(CI->getCallingConv(),

156}

157

159 return ::isCallingConvCCompatible(F->getCallingConv(),

160 F->getParent()->getTargetTriple(),

161 F->getFunctionType());

162}

163

165 bool ShouldExtI32Param, ShouldExtI32Return;

166 bool ShouldSignExtI32Param, ShouldSignExtI32Return;

168 ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param,

169 ShouldSignExtI32Return, T);

174

175

176

177

178 TLI.setIntSize(T.isArch16Bit() ? 16 : 32);

179}

180

181

182

183

186

187

198

199

200

201 if (T.isAMDGPU()) {

203 TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);

204 TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);

205 return;

206 }

207

208

209

210 if (T.isMacOSX()) {

211

217

218 if (T.isMacOSXVersionLT(10, 5)) {

222 }

223 } else if (T.isiOS()) {

224 if (T.isOSVersionLT(3, 0)) {

228 }

229 } else if (T.isWatchOS()) {

233 }

234

242 }

243

246

247 if (T.isMacOSX() && T.getArch() == Triple::x86 &&

248 T.isMacOSXVersionLT(10, 7)) {

249

250

251

252

253

256 }

257

258

264 }

265

266

271 }

272

273 if (T.isOSWindows() && T.isOSCygMing()) {

274

275

276

277

278

279 bool hasPartialC99 = true;

280 if (T.isKnownWindowsMSVCEnvironment()) {

282 hasPartialC99 = (Version.getMajor() == 0 || Version.getMajor() >= 19);

283 }

284

285

288 bool hasPartialFloat = (isARM ||

290

291

292 if (!hasPartialFloat) {

316 }

317 if (!isARM)

321

322

349

350

351 if (!hasPartialC99) {

379 if (hasPartialFloat)

381 else

395 }

396

397

418

419

420

444 }

445

446 if (T.isOSWindows() && T.isWindowsCygwinEnvironment()) {

447

480

481

482

483

485 }

486

487

488 if (T.isOSMSVCRT()) {

489

493 TLI.setUnavailable(LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t);

501 TLI.setUnavailable(LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t);

509 TLI.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t);

512 TLI.setUnavailable(LibFunc_ZnamRKSt9nothrow_t12__hot_cold_t);

514 TLI.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t);

518 TLI.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t);

521 TLI.setUnavailable(LibFunc_ZnwmRKSt9nothrow_t12__hot_cold_t);

523 TLI.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t);

525 TLI.setUnavailable(LibFunc_ZnwmSt11align_val_t12__hot_cold_t);

526 TLI.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t);

528 TLI.setUnavailable(LibFunc_ZnamSt11align_val_t12__hot_cold_t);

529 TLI.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t);

531 TLI.setUnavailable(LibFunc_size_returning_new_hot_cold);

532 TLI.setUnavailable(LibFunc_size_returning_new_aligned);

533 TLI.setUnavailable(LibFunc_size_returning_new_aligned_hot_cold);

534 } else {

535

539 TLI.setUnavailable(LibFunc_msvc_new_longlong_nothrow);

541 TLI.setUnavailable(LibFunc_msvc_delete_ptr32_nothrow);

544 TLI.setUnavailable(LibFunc_msvc_delete_ptr64_nothrow);

545 TLI.setUnavailable(LibFunc_msvc_delete_ptr64_longlong);

547 TLI.setUnavailable(LibFunc_msvc_new_array_int_nothrow);

549 TLI.setUnavailable(LibFunc_msvc_new_array_longlong_nothrow);

551 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32_nothrow);

552 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32_int);

554 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64_nothrow);

555 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64_longlong);

556 }

557

558 switch (T.getOS()) {

560

561

562

564 if (T.isMacOSXVersionLT(10, 9)) {

567 } else {

570 }

571 break;

577 if (T.isWatchOS() &&

578 (T.isOSVersionLT(7, 0) || (T.isOSVersionLT(9, 0) && T.isX86()))) {

581 } else {

584 }

585 break;

587

588

589

590

591

592

593 [[fallthrough]];

594 default:

598 }

599

600

601

602

603

604

605 switch (T.getOS()) {

614 break;

615 default:

617 }

618

619

620

621

622 switch (T.getOS()) {

631 break;

632 default:

634 }

635

636

637

638

639

640 if (T.isOSFreeBSD()) {

644 }

645

646

647

648 if (T.isOSLinux() || T.isGNUEnvironment()) {

655

656 if (T.isAndroid() && T.isMusl())

668

669

670

671

672

718 }

719

720 if ((T.isOSLinux() && T.isGNUEnvironment()) ||

721 (T.isAndroid() && T.isAndroidVersionLT(28))) {

722

733 }

734

735 if (T.isAndroid() && T.isAndroidVersionLT(21)) {

738 }

739

740 if (T.isPS()) {

741

743

744

745

753 TLI.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t);

757 TLI.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t);

758

759

778

779

828

829

867 }

868

869

870

871

872

873

874

875

876

877

878

879

880 if (T.isNVPTX()) {

885

886

887

888

889

890

891

892

893

894 TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);

895 TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);

896 } else {

898 }

899

900

901 if (T.isOSAIX()) {

906 }

907

908 if (T.isOSAIX())

910

912}

913

914

915

916

921}

922

924

925 memset(AvailableArray, 0, sizeof(AvailableArray));

927}

928

930

931 memset(AvailableArray, -1, sizeof(AvailableArray));

932

934}

935

937 : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),

938 ShouldExtI32Return(TLI.ShouldExtI32Return),

939 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),

940 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),

941 SizeOfInt(TLI.SizeOfInt) {

942 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));

943 VectorDescs = TLI.VectorDescs;

944 ScalarDescs = TLI.ScalarDescs;

945}

946

948 : CustomNames(std::move(TLI.CustomNames)),

949 ShouldExtI32Param(TLI.ShouldExtI32Param),

950 ShouldExtI32Return(TLI.ShouldExtI32Return),

951 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),

952 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),

953 SizeOfInt(TLI.SizeOfInt) {

954 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),

955 AvailableArray);

956 VectorDescs = TLI.VectorDescs;

957 ScalarDescs = TLI.ScalarDescs;

958}

959

961 CustomNames = TLI.CustomNames;

962 ShouldExtI32Param = TLI.ShouldExtI32Param;

963 ShouldExtI32Return = TLI.ShouldExtI32Return;

964 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;

965 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;

966 SizeOfInt = TLI.SizeOfInt;

967 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));

968 return *this;

969}

970

972 CustomNames = std::move(TLI.CustomNames);

973 ShouldExtI32Param = TLI.ShouldExtI32Param;

974 ShouldExtI32Return = TLI.ShouldExtI32Return;

975 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;

976 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;

977 SizeOfInt = TLI.SizeOfInt;

978 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),

979 AvailableArray);

980 return *this;

981}

982

984

985

988

989

990

992}

993

997 unsigned Idx = 0;

999 for (const auto &Func : StandardNames)

1000 Indices[Func] = static_cast<LibFunc>(Idx++);

1001 return Indices;

1002}

1003

1006 if (funcName.empty())

1007 return false;

1008

1011

1012 if (auto Loc = Indices.find(funcName); Loc != Indices.end()) {

1013 F = Loc->second;

1014 return true;

1015 }

1016 return false;

1017}

1018

1019

1020

1022 unsigned SizeTBits) {

1023 switch (ArgTy) {

1032 case Int:

1039

1048 case Flt:

1050 case Dbl:

1052

1057 case Ptr:

1061 default:

1062 break;

1063 }

1064

1066}

1067

1070 int SizeTSizeBits) {

1071 switch (F) {

1072 case LibFunc_size_returning_new: {

1073 if (FTy.getNumParams() != 1 ||

1074 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits)) {

1075 return false;

1076 }

1077 } break;

1078 case LibFunc_size_returning_new_hot_cold: {

1079 if (FTy.getNumParams() != 2 ||

1080 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||

1081 !FTy.getParamType(1)->isIntegerTy(8)) {

1082 return false;

1083 }

1084 } break;

1085 case LibFunc_size_returning_new_aligned: {

1086 if (FTy.getNumParams() != 2 ||

1087 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||

1088 !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits)) {

1089 return false;

1090 }

1091 } break;

1092 case LibFunc_size_returning_new_aligned_hot_cold:

1093 if (FTy.getNumParams() != 3 ||

1094 !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||

1095 !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits) ||

1096 !FTy.getParamType(2)->isIntegerTy(8)) {

1097 return false;

1098 }

1099 break;

1100 default:

1101 return false;

1102 }

1103

1104 auto &Context = M.getContext();

1107 Context, {PtrTy, Type::getIntNTy(Context, SizeTSizeBits)});

1108 return FTy.getReturnType() == SizedPtrTy;

1109}

1110

1111bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,

1113 const Module &M) const {

1114 unsigned NumParams = FTy.getNumParams();

1115

1116 switch (F) {

1117

1118 case LibFunc_cabs:

1119 case LibFunc_cabsf:

1120 case LibFunc_cabsl: {

1121 Type *RetTy = FTy.getReturnType();

1122 if (RetTy->isFloatingPointTy())

1123 return false;

1124

1125 Type *ParamTy = FTy.getParamType(0);

1126

1127

1128

1129 if (NumParams == 1)

1132 else if (NumParams == 2)

1133 return ParamTy == RetTy && FTy.getParamType(1) == RetTy;

1134

1135 return false;

1136 }

1137

1138

1139 case LibFunc_sincospi_stret:

1140 case LibFunc_sincospif_stret: {

1141 if (NumParams != 1)

1142 return false;

1143

1144 Type *RetTy = FTy.getReturnType();

1145 Type *ParamTy = FTy.getParamType(0);

1146 if (auto *Ty = dyn_cast(RetTy)) {

1147 if (Ty->getNumElements() != 2)

1148 return false;

1149 return (Ty->getElementType(0) == ParamTy &&

1150 Ty->getElementType(1) == ParamTy);

1151 }

1152

1153 if (auto *Ty = dyn_cast(RetTy)) {

1154 if (Ty->getNumElements() != 2)

1155 return false;

1156 return Ty->getElementType() == ParamTy;

1157 }

1158

1159 return false;

1160 }

1161

1162

1163 case LibFunc_size_returning_new:

1164 case LibFunc_size_returning_new_hot_cold:

1165 case LibFunc_size_returning_new_aligned:

1166 case LibFunc_size_returning_new_aligned_hot_cold:

1168 default:

1169 break;

1170 }

1171

1174 unsigned Idx = 0;

1175

1176

1177

1178

1179 Type *Ty = FTy.getReturnType(), *LastTy = Ty;

1181 for (auto TyID : ProtoTypes) {

1182 if (Idx && TyID == Void)

1183

1184

1185 break;

1186

1187 if (TyID == Ellip) {

1188

1189

1190

1191 assert(Idx == ProtoTypes.size() - 1 || ProtoTypes[Idx + 1] == Void);

1192 return FTy.isFunctionVarArg();

1193 }

1194

1195 if (TyID == Same) {

1196 assert(Idx != 0 && "Type ID 'Same' must not be first!");

1197 if (Ty != LastTy)

1198 return false;

1199 } else {

1200 if (!Ty || matchType(TyID, Ty, IntBits, SizeTBits))

1201 return false;

1202 LastTy = Ty;

1203 }

1204

1205 if (Idx == NumParams) {

1206

1207

1208 Ty = nullptr;

1210 continue;

1211 }

1212

1213 Ty = FTy.getParamType(Idx++);

1214 }

1215

1216

1217

1218 return Idx == NumParams + 1 && !FTy.isFunctionVarArg();

1219}

1220

1223

1224

1225

1227

1229 assert(M && "Expecting FDecl to be connected to a Module.");

1230

1231 if (FDecl.LibFuncCache == Function::UnknownLibFunc)

1234

1235 if (FDecl.LibFuncCache == NotLibFunc)

1236 return false;

1237

1238 F = FDecl.LibFuncCache;

1239 return isValidProtoForLibFunc(*FDecl.getFunctionType(), F, *M);

1240}

1241

1244

1245 if (Opcode != Instruction::FRem || (!Ty->isDoubleTy() && !Ty->isFloatTy()))

1246 return false;

1247

1248 F = Ty->isDoubleTy() ? LibFunc_fmod : LibFunc_fmodf;

1249 return true;

1250}

1251

1253 memset(AvailableArray, 0, sizeof(AvailableArray));

1254}

1255

1257 return LHS.getScalarFnName() < RHS.getScalarFnName();

1258}

1259

1261 return LHS.getVectorFnName() < RHS.getVectorFnName();

1262}

1263

1265 return LHS.getScalarFnName() < S;

1266}

1267

1271

1274}

1275

1277#define TLI_DEFINE_ACCELERATE_VECFUNCS

1278#include "llvm/Analysis/VecFuncs.def"

1279#undef TLI_DEFINE_ACCELERATE_VECFUNCS

1280};

1281

1283#define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS

1284#include "llvm/Analysis/VecFuncs.def"

1285#undef TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS

1286};

1287

1289#define TLI_DEFINE_LIBMVEC_X86_VECFUNCS

1290#include "llvm/Analysis/VecFuncs.def"

1291#undef TLI_DEFINE_LIBMVEC_X86_VECFUNCS

1292};

1293

1295#define TLI_DEFINE_MASSV_VECFUNCS

1296#include "llvm/Analysis/VecFuncs.def"

1297#undef TLI_DEFINE_MASSV_VECFUNCS

1298};

1299

1301#define TLI_DEFINE_SVML_VECFUNCS

1302#include "llvm/Analysis/VecFuncs.def"

1303#undef TLI_DEFINE_SVML_VECFUNCS

1304};

1305

1307#define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS

1308#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \

1309 {SCAL, VEC, VF, false, VABI_PREFIX},

1310#include "llvm/Analysis/VecFuncs.def"

1311#undef TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS

1312};

1314#define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS

1315#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \

1316 {SCAL, VEC, VF, false, VABI_PREFIX},

1317#include "llvm/Analysis/VecFuncs.def"

1318#undef TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS

1319};

1321#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS

1322#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \

1323 {SCAL, VEC, VF, MASK, VABI_PREFIX},

1324#include "llvm/Analysis/VecFuncs.def"

1325#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS

1326};

1327

1329#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV

1330#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \

1331 {SCAL, VEC, VF, MASK, VABI_PREFIX},

1332#include "llvm/Analysis/VecFuncs.def"

1333#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV

1334};

1335

1337#define TLI_DEFINE_ARMPL_VECFUNCS

1338#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \

1339 {SCAL, VEC, VF, MASK, VABI_PREFIX},

1340#include "llvm/Analysis/VecFuncs.def"

1341#undef TLI_DEFINE_ARMPL_VECFUNCS

1342};

1343

1345#define TLI_DEFINE_AMDLIBM_VECFUNCS

1346#define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \

1347 {SCAL, VEC, VF, MASK, VABI_PREFIX},

1348#include "llvm/Analysis/VecFuncs.def"

1349#undef TLI_DEFINE_AMDLIBM_VECFUNCS

1350};

1351

1354 switch (VecLib) {

1357 break;

1358 }

1361 break;

1362 }

1365 break;

1366 }

1369 break;

1370 }

1371 case SVML: {

1373 break;

1374 }

1376 switch (TargetTriple.getArch()) {

1377 default:

1378 break;

1384 break;

1387 break;

1388 }

1389 break;

1390 }

1392 switch (TargetTriple.getArch()) {

1393 default:

1394 break;

1398 break;

1399 }

1400 break;

1401 }

1404 break;

1405 }

1407 break;

1408 }

1409}

1410

1413 if (funcName.empty())

1414 return false;

1415

1416 std::vector::const_iterator I =

1418 return I != VectorDescs.end() && StringRef(I->getScalarFnName()) == funcName;

1419}

1420

1423 bool Masked) const {

1425 if (VD)

1428}

1429

1432 bool Masked) const {

1434 if (F.empty())

1435 return nullptr;

1436 std::vector::const_iterator I =

1438 while (I != VectorDescs.end() && StringRef(I->getScalarFnName()) == F) {

1439 if ((I->getVectorizationFactor() == VF) && (I->isMasked() == Masked))

1440 return &(*I);

1441 ++I;

1442 }

1443 return nullptr;

1444}

1445

1448 if (!BaselineInfoImpl)

1449 BaselineInfoImpl =

1452}

1453

1455 if (auto *ShortWChar = cast_or_null(

1456 M.getModuleFlag("wchar_size")))

1457 return cast(ShortWChar->getValue())->getZExtValue();

1458 return 0;

1459}

1460

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471 return M.getDataLayout().getIndexSizeInBits(0);

1472}

1473

1477}

1478

1482}

1483

1488}

1489

1493

1495

1496

1498 "Target Library Information", false, true)

1500

1502

1507

1508

1511 if (ScalarF.empty())

1512 return;

1513

1514 std::vector::const_iterator I =

1516 while (I != VectorDescs.end() && StringRef(I->getScalarFnName()) == ScalarF) {

1518 I->getVectorizationFactor().isScalable() ? &ScalableVF : &FixedVF;

1520 *VF = I->getVectorizationFactor();

1521 ++I;

1522 }

1523}

#define clEnumValN(ENUMVAL, FLAGNAME, DESC)

This file contains the declarations for the subclasses of Constant, which represent the different fla...

Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx

This file defines the DenseMap class.

Module.h This file contains the declarations for the Module class.

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

This file defines the SmallString class.

static bool hasSinCosPiStret(const Triple &T)

static StringRef sanitizeFunctionName(StringRef funcName)

static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)

Initialize the set of available library functions based on the specified target triple.

static const VecDesc VecFuncs_MASSV[]

static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)

Initialize the set of available library functions based on the specified target triple.

static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits, unsigned SizeTBits)

static bool hasBcmp(const Triple &TT)

static const VecDesc VecFuncs_SLEEFGNUABI_VF2[]

static void initializeBase(TargetLibraryInfoImpl &TLI, const Triple &T)

static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)

static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS)

static const VecDesc VecFuncs_SLEEFGNUABI_VF4[]

static const FuncProtoTy Signatures[]

static bool isCallingConvCCompatible(CallingConv::ID CC, StringRef TT, FunctionType *FuncTy)

static const VecDesc VecFuncs_ArmPL[]

const VecDesc VecFuncs_AMDLIBM[]

static bool isValidProtoForSizeReturningNew(const FunctionType &FTy, LibFunc F, const Module &M, int SizeTSizeBits)

static const VecDesc VecFuncs_LIBMVEC_X86[]

static const VecDesc VecFuncs_DarwinLibSystemM[]

static const VecDesc VecFuncs_SVML[]

static cl::opt< TargetLibraryInfoImpl::VectorLibrary > ClVectorLibrary("vector-library", cl::Hidden, cl::desc("Vector functions library"), cl::init(TargetLibraryInfoImpl::NoLibrary), cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none", "No vector functions library"), clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate", "Accelerate framework"), clEnumValN(TargetLibraryInfoImpl::DarwinLibSystemM, "Darwin_libsystem_m", "Darwin libsystem_m"), clEnumValN(TargetLibraryInfoImpl::LIBMVEC_X86, "LIBMVEC-X86", "GLIBC Vector Math library"), clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV", "IBM MASS vector library"), clEnumValN(TargetLibraryInfoImpl::SVML, "SVML", "Intel SVML library"), clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI, "sleefgnuabi", "SIMD Library for Evaluating Elementary Functions"), clEnumValN(TargetLibraryInfoImpl::ArmPL, "ArmPL", "Arm Performance Libraries"), clEnumValN(TargetLibraryInfoImpl::AMDLIBM, "AMDLIBM", "AMD vector math library")))

std::array< FuncArgTypeID, 8 > FuncProtoTy

static const VecDesc VecFuncs_SLEEFGNUABI_VFScalable[]

static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)

static const VecDesc VecFuncs_Accelerate[]

static const VecDesc VecFuncs_SLEEFGNUABI_VFScalableRISCV[]

static DenseMap< StringRef, LibFunc > buildIndexMap(ArrayRef< StringLiteral > StandardNames)

A container for analyses that lazily runs them and caches their results.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

CallingConv::ID getCallingConv() const

FunctionType * getFunctionType() const

iterator find(const_arg_type_t< KeyT > Val)

void reserve(size_type NumEntries)

Grow the densemap so that it can contain at least NumEntries items before resizing again.

static constexpr ElementCount getScalable(ScalarTy MinVal)

static constexpr ElementCount getFixed(ScalarTy MinVal)

FunctionType * getFunctionType() const

Returns the FunctionType for me.

bool isIntrinsic() const

isIntrinsic - Returns true if the function's name starts with "llvm.".

static StringRef dropLLVMManglingEscape(StringRef Name)

If the given string begins with the GlobalValue name mangling escape character '\1',...

Module * getParent()

Get the module that this global value is contained inside of...

ImmutablePass class - This class is used to provide information that does not need to be run.

const Module * getModule() const

Return the module owning the function this instruction belongs to or nullptr it the function does not...

A Module instance is used to store all the information related to an LLVM module.

const std::string & getTargetTriple() const

Get the target triple which is a string describing the target host.

static PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

static PointerType * get(Type *ElementType, unsigned AddressSpace)

This constructs a pointer to an object of the specified type in a numbered address space.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...

StringRef - Represent a constant reference to a string, i.e.

constexpr bool empty() const

empty - Check if the string is empty.

bool contains(StringRef Other) const

Return true if the given string is a substring of *this, and false otherwise.

Class to represent struct types.

static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)

This static method is the primary way to create a literal StructType.

TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)

Implementation of the target library information.

void setShouldExtI32Param(bool Val)

Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...

void setShouldExtI32Return(bool Val)

Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...

unsigned getWCharSize(const Module &M) const

Returns the size of the wchar_t type in bytes or 0 if the size is unknown.

bool getLibFunc(StringRef funcName, LibFunc &F) const

Searches for a particular function name.

void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const

Returns the largest vectorization factor used in the list of vector functions.

bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const

Return true if the function F has a vector equivalent with vectorization factor VF.

void setShouldSignExtI32Param(bool Val)

Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...

void setAvailableWithName(LibFunc F, StringRef Name)

Forces a function to be marked as available and provide an alternate name that must be used.

unsigned getIntSize() const

Get size of a C-level int or unsigned int, in bits.

void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib, const llvm::Triple &TargetTriple)

Calls addVectorizableFunctions with a known preset of functions for the given vector library.

void setIntSize(unsigned Bits)

Initialize the C-level size of an integer.

unsigned getSizeTSize(const Module &M) const

Returns the size of the size_t type in bits.

void addVectorizableFunctions(ArrayRef< VecDesc > Fns)

Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...

const VecDesc * getVectorMappingInfo(StringRef F, const ElementCount &VF, bool Masked) const

Return a pointer to a VecDesc object holding all info for scalar to vector mappings in TLI for the eq...

static bool isCallingConvCCompatible(CallBase *CI)

Returns true if call site / callee has cdecl-compatible calling conventions.

void setShouldSignExtI32Return(bool Val)

Set to true iff i32 results from library functions should have signext attribute if they correspond t...

TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)

void disableAllFunctions()

Disables all builtins.

VectorLibrary

List of known vector-functions libraries.

void setUnavailable(LibFunc F)

Forces a function to be marked as unavailable.

StringRef getVectorizedFunction(StringRef F, const ElementCount &VF, bool Masked) const

Return the name of the equivalent of F, vectorized with factor VF.

void setAvailable(LibFunc F)

Forces a function to be marked as available.

TargetLibraryInfoWrapperPass()

Provides information about what library functions are available for the current target.

static void initExtensionsForTriple(bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)

Triple - Helper class for working with autoconf configuration names.

ArchType getArch() const

Get the parsed architecture type of this triple.

The instances of the Type class are immutable: once they are created, they are never changed.

bool isArrayTy() const

True if this is an instance of ArrayType.

bool isPointerTy() const

True if this is an instance of PointerType.

Type * getArrayElementType() const

bool isFloatTy() const

Return true if this is 'float', a 32-bit IEEE fp type.

uint64_t getArrayNumElements() const

static IntegerType * getIntNTy(LLVMContext &C, unsigned N)

bool isStructTy() const

True if this is an instance of StructType.

bool isDoubleTy() const

Return true if this is 'double', a 64-bit IEEE fp type.

bool isFloatingPointTy() const

Return true if this is one of the floating-point types.

bool isIntegerTy() const

True if this is an instance of IntegerType.

TypeSize getPrimitiveSizeInBits() const LLVM_READONLY

Return the basic size of this type if it is a primitive type.

bool isVoidTy() const

Return true if this is 'void'.

StringRef getName() const

Return a constant reference to the value's name.

Provides info so a possible vectorization of a function can be computed.

std::string getVectorFunctionABIVariantString() const

Returns a vector function ABI variant string on the form: ZGV(<...

StringRef getVectorFnName() const

Represents a version number in the form major[.minor[.subminor[.build]]].

static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)

A raw_ostream that writes to an SmallVector or SmallString.

StringRef str() const

Return a StringRef for the vector contents.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ ARM_APCS

ARM Procedure Calling Standard (obsolete, but still used on some targets).

@ ARM_AAPCS

ARM Architecture Procedure Calling Standard calling convention (aka EABI).

@ ARM_AAPCS_VFP

Same as ARM_AAPCS, but uses hard floating point ABI.

@ C

The default llvm calling convention, compatible with C.

ValuesClass values(OptsTy... Options)

Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...

initializer< Ty > init(const Ty &Val)

This is an optimization pass for GlobalISel generic memory operations.

void append_range(Container &C, Range &&R)

Wrapper function to append range R to container C.

void sort(IteratorTy Start, IteratorTy End)

auto lower_bound(R &&Range, T &&Value)

Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)

Implement std::hash so that hash_code can be used in STL containers.

A special type used by analysis passes to provide an address that identifies that particular analysis...