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

1

2

3

4

5

6

7

8

9

10

11

12

22using namespace llvm;

23

24#define GET_TARGET_LIBRARY_INFO_STRING_TABLE

25#include "llvm/Analysis/TargetLibraryInfo.inc"

26

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

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

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

33}

34

35#define GET_TARGET_LIBRARY_INFO_SIGNATURE_TABLE

36#include "llvm/Analysis/TargetLibraryInfo.inc"

37

39

40 if (T.isOSDarwin())

41 return false;

42

43

45 return false;

46

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

48 return false;

49

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

51 return false;

52

53 return true;

54}

55

57

58

59 if (TT.isOSLinux())

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

61

62

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

64}

65

68 switch (CC) {

69 default:

70 return false;

72 return true;

76

77

78

79 if (TT.isiOS())

80 return false;

81

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

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

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

85 return false;

86

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

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

89 return false;

90 }

91 return true;

92 }

93 }

94 return false;

95}

96

102

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

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

106 F->getFunctionType());

107}

108

110 bool ShouldExtI32Param, ShouldExtI32Return;

111 bool ShouldSignExtI32Param, ShouldSignExtI32Return;

113 ShouldExtI32Param, ShouldExtI32Return, ShouldSignExtI32Param,

114 ShouldSignExtI32Return, T);

119

120

121

122

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

124}

125

126

127

128

132

133

144

145

146

147 if (T.isAMDGPU()) {

149 TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);

150 TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);

151 return;

152 }

153

154

155

156

157 if (T.isDXIL()) {

159 return;

160 }

161

162

163

164 if (T.isMacOSX()) {

165

171

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

176 }

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

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

182 }

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

187 }

188

196 }

197

200

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

202 T.isMacOSXVersionLT(10, 7)) {

203

204

205

206

207

210 }

211

212

218 }

219

220

225 }

226

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

228

229

230

231

232

233 bool hasPartialC99 = true;

234 if (T.isKnownWindowsMSVCEnvironment()) {

235 VersionTuple Version = T.getEnvironmentVersion();

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

237 }

238

239

242 bool hasPartialFloat = (isARM ||

244

245

246 if (!hasPartialFloat) {

270 }

271 if (!isARM)

275

276

303

304

305 if (!hasPartialC99) {

333 if (hasPartialFloat)

335 else

353 }

354

355

378

379

380

404 }

405

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

407

440

441

442

443

445 }

446

447

448 if (T.isOSMSVCRT()) {

449

453 TLI.setUnavailable(LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t);

461 TLI.setUnavailable(LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t);

469 TLI.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t);

472 TLI.setUnavailable(LibFunc_ZnamRKSt9nothrow_t12__hot_cold_t);

474 TLI.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t);

478 TLI.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t);

481 TLI.setUnavailable(LibFunc_ZnwmRKSt9nothrow_t12__hot_cold_t);

483 TLI.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t);

485 TLI.setUnavailable(LibFunc_ZnwmSt11align_val_t12__hot_cold_t);

486 TLI.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t);

488 TLI.setUnavailable(LibFunc_ZnamSt11align_val_t12__hot_cold_t);

489 TLI.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t);

491 TLI.setUnavailable(LibFunc_size_returning_new_hot_cold);

492 TLI.setUnavailable(LibFunc_size_returning_new_aligned);

493 TLI.setUnavailable(LibFunc_size_returning_new_aligned_hot_cold);

494 } else {

495

499 TLI.setUnavailable(LibFunc_msvc_new_longlong_nothrow);

501 TLI.setUnavailable(LibFunc_msvc_delete_ptr32_nothrow);

504 TLI.setUnavailable(LibFunc_msvc_delete_ptr64_nothrow);

505 TLI.setUnavailable(LibFunc_msvc_delete_ptr64_longlong);

507 TLI.setUnavailable(LibFunc_msvc_new_array_int_nothrow);

509 TLI.setUnavailable(LibFunc_msvc_new_array_longlong_nothrow);

511 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32_nothrow);

512 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr32_int);

514 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64_nothrow);

515 TLI.setUnavailable(LibFunc_msvc_delete_array_ptr64_longlong);

516 }

517

518 switch (T.getOS()) {

520

521

522

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

527 } else {

530 }

531 break;

537 if (T.isWatchOS() &&

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

541 } else {

544 }

545 break;

547

548

549

550

551

552

553 [[fallthrough]];

554 default:

558 }

559

560

561

562

563

564

565 switch (T.getOS()) {

574 break;

575 default:

577 }

578

579

580

581

582 switch (T.getOS()) {

591 break;

592 default:

594 }

595

596

597

598

599

600 if (T.isOSFreeBSD()) {

604 }

605

606

607

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

615

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

628

629

630

631

632

678 }

679

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

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

682

693 }

694

695 if (T.isPS()) {

696

698

699

700

708 TLI.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t);

712 TLI.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t);

713

714

733

734

784

785

823 }

824

825 if (T.isOSFreeBSD()) {

836

851 }

852

853

854

855

856

857

858

859

860

861

862

863

864 if (T.isNVPTX()) {

869

870

871

872

873

874

875

876

877

878 TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);

879 TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);

880 } else {

882 }

883

884

885 if (T.isOSAIX()) {

890 }

891

892 if (T.isOSAIX())

894

896}

897

898

899

900

907

910

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

912

913 initialize(*this, T, StandardNamesStrTable, VecLib);

914}

915

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

918 ShouldExtI32Return(TLI.ShouldExtI32Return),

919 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),

920 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),

921 SizeOfInt(TLI.SizeOfInt) {

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

923 VectorDescs = TLI.VectorDescs;

924 ScalarDescs = TLI.ScalarDescs;

925}

926

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

929 ShouldExtI32Param(TLI.ShouldExtI32Param),

930 ShouldExtI32Return(TLI.ShouldExtI32Return),

931 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),

932 ShouldSignExtI32Return(TLI.ShouldSignExtI32Return),

933 SizeOfInt(TLI.SizeOfInt) {

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

935 AvailableArray);

936 VectorDescs = TLI.VectorDescs;

937 ScalarDescs = TLI.ScalarDescs;

938}

939

941 CustomNames = TLI.CustomNames;

942 ShouldExtI32Param = TLI.ShouldExtI32Param;

943 ShouldExtI32Return = TLI.ShouldExtI32Return;

944 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;

945 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;

946 SizeOfInt = TLI.SizeOfInt;

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

948 return *this;

949}

950

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

953 ShouldExtI32Param = TLI.ShouldExtI32Param;

954 ShouldExtI32Return = TLI.ShouldExtI32Return;

955 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;

956 ShouldSignExtI32Return = TLI.ShouldSignExtI32Return;

957 SizeOfInt = TLI.SizeOfInt;

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

959 AvailableArray);

960 return *this;

961}

962

973

977 unsigned Idx = 0;

978 Indices.reserve(LibFunc::NumLibFuncs);

979 for (const auto &Func : StandardNames)

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

981 return Indices;

982}

983

986 if (funcName.empty())

987 return false;

988

991

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

993 F = Loc->second;

994 return true;

995 }

996 return false;

997}

998

999

1000

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

1002 unsigned SizeTBits) {

1003 switch (ArgTy) {

1004 case Void:

1005 return Ty->isVoidTy();

1006 case Bool:

1007 return Ty->isIntegerTy(8);

1008 case Int16:

1009 return Ty->isIntegerTy(16);

1010 case Int32:

1011 return Ty->isIntegerTy(32);

1012 case Int:

1013 return Ty->isIntegerTy(IntBits);

1014 case IntPlus:

1015 return Ty->isIntegerTy() && Ty->getPrimitiveSizeInBits() >= IntBits;

1016 case IntX:

1017 return Ty->isIntegerTy();

1018 case Long:

1019

1020 return Ty->isIntegerTy() && Ty->getPrimitiveSizeInBits() >= IntBits;

1021 case Int64:

1022 return Ty->isIntegerTy(64);

1023 case LLong:

1024 return Ty->isIntegerTy(64);

1025 case SizeT:

1026 case SSizeT:

1027 return Ty->isIntegerTy(SizeTBits);

1028 case Flt:

1029 return Ty->isFloatTy();

1030 case Dbl:

1031 return Ty->isDoubleTy();

1032

1033 case LDbl:

1034 return Ty->isFloatingPointTy();

1036 return Ty->isFloatingPointTy();

1037 case Ptr:

1038 return Ty->isPointerTy();

1039 case Struct:

1040 return Ty->isStructTy();

1041 default:

1042 break;

1043 }

1044

1046}

1047

1050 int SizeTSizeBits) {

1051 switch (F) {

1052 case LibFunc_size_returning_new: {

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

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

1055 return false;

1056 }

1057 } break;

1058 case LibFunc_size_returning_new_hot_cold: {

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

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

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

1062 return false;

1063 }

1064 } break;

1065 case LibFunc_size_returning_new_aligned: {

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

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

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

1069 return false;

1070 }

1071 } break;

1072 case LibFunc_size_returning_new_aligned_hot_cold:

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

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

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

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

1077 return false;

1078 }

1079 break;

1080 default:

1081 return false;

1082 }

1083

1084 auto &Context = M.getContext();

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

1088 return FTy.getReturnType() == SizedPtrTy;

1089}

1090

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

1092 LibFunc F,

1093 const Module &M) const {

1094 unsigned NumParams = FTy.getNumParams();

1095

1096 switch (F) {

1097

1098 case LibFunc_cabs:

1099 case LibFunc_cabsf:

1100 case LibFunc_cabsl: {

1101 Type *RetTy = FTy.getReturnType();

1103 return false;

1104

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

1106

1107

1108

1109 if (NumParams == 1)

1112 else if (NumParams == 2)

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

1114

1115 return false;

1116 }

1117

1118

1119 case LibFunc_sincospi_stret:

1120 case LibFunc_sincospif_stret: {

1121 if (NumParams != 1)

1122 return false;

1123

1124 Type *RetTy = FTy.getReturnType();

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

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

1128 return false;

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

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

1131 }

1132

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

1135 return false;

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

1137 }

1138

1139 return false;

1140 }

1141

1142

1143 case LibFunc_size_returning_new:

1144 case LibFunc_size_returning_new_hot_cold:

1145 case LibFunc_size_returning_new_aligned:

1146 case LibFunc_size_returning_new_aligned_hot_cold:

1148 default:

1149 break;

1150 }

1151

1154 unsigned Idx = 0;

1155

1156

1157

1158

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

1160 const auto *ProtoTypes = &SignatureTable[SignatureOffset[F]];

1161 for (auto TyID = ProtoTypes[Idx]; TyID != NoFuncArgType;

1162 TyID = ProtoTypes[++Idx]) {

1163 if (TyID == NoFuncArgType)

1164 break;

1165

1166 if (TyID == Ellip) {

1167

1168

1169

1170 assert(ProtoTypes[Idx] == NoFuncArgType ||

1171 ProtoTypes[Idx + 1] == NoFuncArgType);

1172 return FTy.isFunctionVarArg();

1173 }

1174

1175 if (TyID == Same) {

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

1177 if (Ty != LastTy)

1178 return false;

1179 } else {

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

1181 return false;

1182 LastTy = Ty;

1183 }

1184

1185 if (Idx == NumParams) {

1186

1187

1188 Ty = nullptr;

1189 continue;

1190 }

1191

1192 Ty = FTy.getParamType(Idx);

1193 }

1194

1195

1196

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

1198}

1199

1201 LibFunc &F) const {

1202

1203

1204

1206

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

1209

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

1212 FDecl.LibFuncCache = NotLibFunc;

1213

1214 if (FDecl.LibFuncCache == NotLibFunc)

1215 return false;

1216

1217 F = FDecl.LibFuncCache;

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

1219}

1220

1222 LibFunc &F) const {

1223

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

1225 return false;

1226

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

1228 return true;

1229}

1230

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

1233}

1234

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

1237}

1238

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

1241}

1242

1244 return LHS.getScalarFnName() < S;

1245}

1246

1254

1256#define TLI_DEFINE_ACCELERATE_VECFUNCS

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

1258#undef TLI_DEFINE_ACCELERATE_VECFUNCS

1259};

1260

1262#define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS

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

1264#undef TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS

1265};

1266

1268#define TLI_DEFINE_LIBMVEC_X86_VECFUNCS

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

1270#undef TLI_DEFINE_LIBMVEC_X86_VECFUNCS

1271};

1272

1274#define TLI_DEFINE_LIBMVEC_AARCH64_VECFUNCS

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

1276 {SCAL, VEC, VF, MASK, VABI_PREFIX, CC},

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

1278#undef TLI_DEFINE_LIBMVEC_AARCH64_VECFUNCS

1279};

1280

1282#define TLI_DEFINE_MASSV_VECFUNCS

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

1284#undef TLI_DEFINE_MASSV_VECFUNCS

1285};

1286

1288#define TLI_DEFINE_SVML_VECFUNCS

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

1290#undef TLI_DEFINE_SVML_VECFUNCS

1291};

1292

1294#define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS

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

1296 {SCAL, VEC, VF, false, VABI_PREFIX, std::nullopt},

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

1298#undef TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS

1299};

1301#define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS

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

1303 {SCAL, VEC, VF, false, VABI_PREFIX, std::nullopt},

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

1305#undef TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS

1306};

1308#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS

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

1310 {SCAL, VEC, VF, MASK, VABI_PREFIX, std::nullopt},

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

1312#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS

1313};

1314

1316#define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV

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

1318 {SCAL, VEC, VF, MASK, VABI_PREFIX, std::nullopt},

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

1320#undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV

1321};

1322

1324#define TLI_DEFINE_ARMPL_VECFUNCS

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

1326 {SCAL, VEC, VF, MASK, VABI_PREFIX, CC},

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

1328#undef TLI_DEFINE_ARMPL_VECFUNCS

1329};

1330

1332#define TLI_DEFINE_AMDLIBM_VECFUNCS

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

1334 {SCAL, VEC, VF, MASK, VABI_PREFIX, std::nullopt},

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

1336#undef TLI_DEFINE_AMDLIBM_VECFUNCS

1337};

1338

1341 switch (VecLib) {

1344 break;

1345 }

1348 break;

1349 }

1351 switch (TargetTriple.getArch()) {

1352 default:

1353 break;

1357 break;

1361 break;

1362 }

1363 break;

1364 }

1367 break;

1368 }

1371 break;

1372 }

1374 switch (TargetTriple.getArch()) {

1375 default:

1376 break;

1382 break;

1385 break;

1386 }

1387 break;

1388 }

1390 switch (TargetTriple.getArch()) {

1391 default:

1392 break;

1396 break;

1397 }

1398 break;

1399 }

1402 break;

1403 }

1405 break;

1406 }

1407}

1408

1411 if (funcName.empty())

1412 return false;

1413

1414 std::vector::const_iterator I =

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

1417}

1418

1421 bool Masked) const {

1423 if (VD)

1426}

1427

1430 bool Masked) const {

1432 if (F.empty())

1433 return nullptr;

1434 std::vector::const_iterator I =

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

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

1438 return &(*I);

1439 ++I;

1440 }

1441 return nullptr;

1442}

1443

1446 if (!BaselineInfoImpl)

1449}

1450

1453 M.getModuleFlag("wchar_size")))

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

1455 return 0;

1456}

1457

1459

1460

1461

1462

1463

1464

1465

1466

1467

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

1469}

1470

1473

1476

1480

1484

1486

1487

1489 "Target Library Information", false, true)

1491

1493

1498

1499

1502 if (ScalarF.empty())

1503 return;

1504

1505 std::vector::const_iterator I =

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

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

1511 *VF = I->getVectorizationFactor();

1512 ++I;

1513 }

1514}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

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

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)

This file defines the SmallString class.

static bool hasSinCosPiStret(const Triple &T)

Definition TargetLibraryInfo.cpp:38

static bool isCallingConvCCompatible(CallingConv::ID CC, const Triple &TT, FunctionType *FuncTy)

Definition TargetLibraryInfo.cpp:66

static StringRef sanitizeFunctionName(StringRef funcName)

Definition TargetLibraryInfo.cpp:963

static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)

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

Definition TargetLibraryInfo.cpp:901

static const VecDesc VecFuncs_MASSV[]

Definition TargetLibraryInfo.cpp:1281

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

Definition TargetLibraryInfo.cpp:1001

static bool hasBcmp(const Triple &TT)

Definition TargetLibraryInfo.cpp:56

static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)

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

Definition TargetLibraryInfo.cpp:129

static const VecDesc VecFuncs_SLEEFGNUABI_VF2[]

Definition TargetLibraryInfo.cpp:1293

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

Definition TargetLibraryInfo.cpp:109

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

Definition TargetLibraryInfo.cpp:1235

static const VecDesc VecFuncs_LIBMVEC_AARCH64[]

Definition TargetLibraryInfo.cpp:1273

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

Definition TargetLibraryInfo.cpp:1239

static const VecDesc VecFuncs_SLEEFGNUABI_VF4[]

Definition TargetLibraryInfo.cpp:1300

static DenseMap< StringRef, LibFunc > buildIndexMap(const llvm::StringTable &StandardNames)

Definition TargetLibraryInfo.cpp:975

static const VecDesc VecFuncs_ArmPL[]

Definition TargetLibraryInfo.cpp:1323

const VecDesc VecFuncs_AMDLIBM[]

Definition TargetLibraryInfo.cpp:1331

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

Definition TargetLibraryInfo.cpp:1048

static const VecDesc VecFuncs_LIBMVEC_X86[]

Definition TargetLibraryInfo.cpp:1267

static const VecDesc VecFuncs_DarwinLibSystemM[]

Definition TargetLibraryInfo.cpp:1261

static const VecDesc VecFuncs_SVML[]

Definition TargetLibraryInfo.cpp:1287

static const VecDesc VecFuncs_SLEEFGNUABI_VFScalable[]

Definition TargetLibraryInfo.cpp:1307

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

Definition TargetLibraryInfo.cpp:1243

static const VecDesc VecFuncs_Accelerate[]

Definition TargetLibraryInfo.cpp:1255

static const VecDesc VecFuncs_SLEEFGNUABI_VFScalableRISCV[]

Definition TargetLibraryInfo.cpp:1315

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)

Class to represent function types.

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...

LLVM_ABI 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 Triple & getTargetTriple() const

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

static LLVM_ABI 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...

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.

A table of densely packed, null-terminated strings indexed by offset.

Class to represent struct types.

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

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

LLVM_ABI TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)

Definition TargetLibraryInfo.cpp:1444

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 ...

LLVM_ABI unsigned getWCharSize(const Module &M) const

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

Definition TargetLibraryInfo.cpp:1451

LLVM_ABI bool getLibFunc(StringRef funcName, LibFunc &F) const

Searches for a particular function name.

Definition TargetLibraryInfo.cpp:984

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

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

Definition TargetLibraryInfo.cpp:1494

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.

TargetLibraryInfoImpl()=delete

unsigned getIntSize() const

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

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

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

Definition TargetLibraryInfo.cpp:1339

void setIntSize(unsigned Bits)

Initialize the C-level size of an integer.

LLVM_ABI unsigned getSizeTSize(const Module &M) const

Returns the size of the size_t type in bits.

Definition TargetLibraryInfo.cpp:1458

LLVM_ABI void addVectorizableFunctions(ArrayRef< VecDesc > Fns)

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

Definition TargetLibraryInfo.cpp:1247

LLVM_ABI 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...

Definition TargetLibraryInfo.cpp:1429

static LLVM_ABI bool isCallingConvCCompatible(CallBase *CI)

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

Definition TargetLibraryInfo.cpp:97

void setShouldSignExtI32Return(bool Val)

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

LLVM_ABI TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)

Definition TargetLibraryInfo.cpp:940

LLVM_ABI void disableAllFunctions()

Disables all builtins.

Definition TargetLibraryInfo.cpp:1231

void setUnavailable(LibFunc F)

Forces a function to be marked as unavailable.

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

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

Definition TargetLibraryInfo.cpp:1419

void setAvailable(LibFunc F)

Forces a function to be marked as available.

TargetLibraryInfoWrapperPass()

The default constructor should not be used and is only for pass manager initialization purposes.

Definition TargetLibraryInfo.cpp:1471

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.

Type * getArrayElementType() const

LLVM_ABI uint64_t getArrayNumElements() const

bool isFloatingPointTy() const

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

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

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

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

LLVM_ABI std::string getVectorFunctionABIVariantString() const

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

Definition TargetLibraryInfo.cpp:27

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.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ 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.

This is an optimization pass for GlobalISel generic memory operations.

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

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

Wrapper function to append range R to container C.

auto cast_or_null(const Y &Val)

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.

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

VectorLibrary

List of known vector-functions libraries.

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

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...