LLVM 23.0.0git
RuntimeLibcalls.cpp
Go to the documentation of this file.
1//===- RuntimeLibcalls.cpp - Interface for runtime libcalls -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
12#include "llvm/IR/Module.h"
14#include "llvm/Support/Debug.h"
15#include "llvm/Support/xxhash.h"
17
18#define DEBUG_TYPE "runtime-libcalls-info"
19
20using namespace llvm;
21using namespace RTLIB;
22
23#define GET_RUNTIME_LIBCALLS_INFO
24#define GET_INIT_RUNTIME_LIBCALL_NAMES
25#define GET_SET_TARGET_RUNTIME_LIBCALL_SETS
26#define DEFINE_GET_LOOKUP_LIBCALL_IMPL_NAME
27#include "llvm/IR/RuntimeLibcalls.inc"
28
30 ExceptionHandling ExceptionModel,
32 EABI EABIVersion, StringRef ABIName,
33 VectorLibrary VecLib) {
34 // FIXME: The ExceptionModel parameter is to handle the field in
35 // TargetOptions. This interface fails to distinguish the forced disable
36 // case for targets which support exceptions by default. This should
37 // probably be a module flag and removed from TargetOptions.
38 if (ExceptionModel == ExceptionHandling::None)
39 ExceptionModel = TT.getDefaultExceptionHandling();
40
41 initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion, ABIName);
42
43 // TODO: Tablegen should generate these sets
44 switch (VecLib) {
46 for (RTLIB::LibcallImpl Impl :
47 {RTLIB::impl__ZGVnN2vv_fmod, RTLIB::impl__ZGVnN4vv_fmodf,
48 RTLIB::impl__ZGVsMxvv_fmod, RTLIB::impl__ZGVsMxvv_fmodf,
49 RTLIB::impl__ZGVnN2vl8_modf, RTLIB::impl__ZGVnN4vl4_modff,
50 RTLIB::impl__ZGVsNxvl8_modf, RTLIB::impl__ZGVsNxvl4_modff,
51 RTLIB::impl__ZGVnN2vl8l8_sincos, RTLIB::impl__ZGVnN4vl4l4_sincosf,
52 RTLIB::impl__ZGVsNxvl8l8_sincos, RTLIB::impl__ZGVsNxvl4l4_sincosf,
53 RTLIB::impl__ZGVnN4vl4l4_sincospif, RTLIB::impl__ZGVnN2vl8l8_sincospi,
54 RTLIB::impl__ZGVsNxvl4l4_sincospif,
55 RTLIB::impl__ZGVsNxvl8l8_sincospi})
56 setAvailable(Impl);
57 break;
59 for (RTLIB::LibcallImpl Impl : {RTLIB::impl_armpl_svfmod_f32_x,
60 RTLIB::impl_armpl_svfmod_f64_x,
61 RTLIB::impl_armpl_vfmodq_f32,
62 RTLIB::impl_armpl_vfmodq_f64,
63 RTLIB::impl_armpl_vmodfq_f64,
64 RTLIB::impl_armpl_vmodfq_f32,
65 RTLIB::impl_armpl_svmodf_f64_x,
66 RTLIB::impl_armpl_svmodf_f32_x,
67 RTLIB::impl_armpl_vsincosq_f64,
68 RTLIB::impl_armpl_vsincosq_f32,
69 RTLIB::impl_armpl_svsincos_f64_x,
70 RTLIB::impl_armpl_svsincos_f32_x,
71 RTLIB::impl_armpl_vsincospiq_f32,
72 RTLIB::impl_armpl_vsincospiq_f64,
73 RTLIB::impl_armpl_svsincospi_f32_x,
74 RTLIB::impl_armpl_svsincospi_f64_x,
75 RTLIB::impl_armpl_svpow_f32_x,
76 RTLIB::impl_armpl_svpow_f64_x,
77 RTLIB::impl_armpl_vpowq_f32,
78 RTLIB::impl_armpl_vpowq_f64,
79 RTLIB::impl_armpl_svcbrt_f32_x,
80 RTLIB::impl_armpl_svcbrt_f64_x,
81 RTLIB::impl_armpl_vcbrtq_f32,
82 RTLIB::impl_armpl_vcbrtq_f64})
83 setAvailable(Impl);
84
85 for (RTLIB::LibcallImpl Impl :
86 {RTLIB::impl_armpl_vfmodq_f32, RTLIB::impl_armpl_vfmodq_f64,
87 RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32,
88 RTLIB::impl_armpl_vpowq_f32, RTLIB::impl_armpl_vpowq_f64,
89 RTLIB::impl_armpl_vcbrtq_f32, RTLIB::impl_armpl_vcbrtq_f64})
91 break;
93 for (RTLIB::LibcallImpl Impl :
94 {RTLIB::impl_amd_vrd2_sincos, RTLIB::impl_amd_vrd4_sincos,
95 RTLIB::impl_amd_vrd8_sincos, RTLIB::impl_amd_vrs4_sincosf,
96 RTLIB::impl_amd_vrs8_sincosf, RTLIB::impl_amd_vrs16_sincosf})
97 setAvailable(Impl);
98 break;
99 default:
100 break;
101 }
102}
103
105 : RuntimeLibcallsInfo(M.getTargetTriple()) {
106 // TODO: Consider module flags
107}
108
109/// Set default libcall names. If a target wants to opt-out of a libcall it
110/// should be placed here.
111void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
112 ExceptionHandling ExceptionModel,
114 EABI EABIVersion, StringRef ABIName) {
115 setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
116 ABIName);
117}
118
121RuntimeLibcallsInfo::libcallImplNameHit(uint16_t NameOffsetEntry,
122 uint16_t StrOffset) {
123 int NumAliases = 1;
124 for (uint16_t Entry : ArrayRef(RuntimeLibcallNameOffsetTable)
125 .drop_front(NameOffsetEntry + 1)) {
126 if (Entry != StrOffset)
127 break;
128 ++NumAliases;
129 }
130
131 RTLIB::LibcallImpl ImplStart = static_cast<RTLIB::LibcallImpl>(
132 &RuntimeLibcallNameOffsetTable[NameOffsetEntry] -
133 &RuntimeLibcallNameOffsetTable[0]);
134 return enum_seq(ImplStart,
135 static_cast<RTLIB::LibcallImpl>(ImplStart + NumAliases));
136}
137
138bool RuntimeLibcallsInfo::isAAPCS_ABI(const Triple &TT, StringRef ABIName) {
139 const ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
140 return TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16;
141}
142
143bool RuntimeLibcallsInfo::darwinHasExp10(const Triple &TT) {
144 switch (TT.getOS()) {
145 case Triple::MacOSX:
146 return !TT.isMacOSXVersionLT(10, 9);
147 case Triple::IOS:
148 return !TT.isOSVersionLT(7, 0);
150 case Triple::TvOS:
151 case Triple::WatchOS:
152 case Triple::XROS:
153 case Triple::BridgeOS:
154 return true;
155 default:
156 return false;
157 }
158}
159
160/// TODO: There is really no guarantee that sizeof(size_t) is equal to the index
161/// size of the default address space. This matches TargetLibraryInfo and should
162/// be kept in sync.
164 return DL.getIndexType(Ctx, /*AddressSpace=*/0);
165}
166
167std::pair<FunctionType *, AttributeList>
169 const DataLayout &DL,
170 RTLIB::LibcallImpl LibcallImpl) const {
171 // TODO: NoCallback probably unsafe in general
172 static constexpr Attribute::AttrKind CommonFnAttrs[] = {
173 Attribute::NoCallback, Attribute::NoFree, Attribute::NoSync,
174 Attribute::NoUnwind, Attribute::WillReturn};
175 static constexpr Attribute::AttrKind MemoryFnAttrs[] = {
176 Attribute::NoUnwind, Attribute::WillReturn};
177 static constexpr Attribute::AttrKind CommonPtrArgAttrs[] = {
178 Attribute::NoAlias, Attribute::WriteOnly, Attribute::NonNull};
179
180 switch (LibcallImpl) {
181 case RTLIB::impl___sincos_stret:
182 case RTLIB::impl___sincosf_stret: {
183 if (!darwinHasSinCosStret(TT)) // Non-darwin currently unexpected
184 return {};
185
186 Type *ScalarTy = LibcallImpl == RTLIB::impl___sincosf_stret
187 ? Type::getFloatTy(Ctx)
188 : Type::getDoubleTy(Ctx);
189
190 AttrBuilder FuncAttrBuilder(Ctx);
191 for (Attribute::AttrKind Attr : CommonFnAttrs)
192 FuncAttrBuilder.addAttribute(Attr);
193
194 const bool UseSret =
195 TT.isX86_32() || ((TT.isARM() || TT.isThumb()) &&
197
198 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argumentOrErrnoMemOnly(
200
201 AttributeList Attrs;
202 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
203
204 if (UseSret) {
205 AttrBuilder AttrBuilder(Ctx);
206 StructType *StructTy = StructType::get(ScalarTy, ScalarTy);
207 AttrBuilder.addStructRetAttr(StructTy);
208 AttrBuilder.addAlignmentAttr(DL.getABITypeAlign(StructTy));
210 Type::getVoidTy(Ctx), {DL.getAllocaPtrType(Ctx), ScalarTy}, false);
211
212 return {FuncTy, Attrs.addParamAttributes(Ctx, 0, AttrBuilder)};
213 }
214
215 Type *RetTy =
216 LibcallImpl == RTLIB::impl___sincosf_stret && TT.isX86_64()
217 ? static_cast<Type *>(FixedVectorType::get(ScalarTy, 2))
218 : static_cast<Type *>(StructType::get(ScalarTy, ScalarTy));
219
220 return {FunctionType::get(RetTy, {ScalarTy}, false), Attrs};
221 }
222 case RTLIB::impl_malloc:
223 case RTLIB::impl_calloc: {
224 AttrBuilder FuncAttrBuilder(Ctx);
225 for (Attribute::AttrKind Attr : MemoryFnAttrs)
226 FuncAttrBuilder.addAttribute(Attr);
227 FuncAttrBuilder.addAttribute(Attribute::NoFree);
228
230 if (LibcallImpl == RTLIB::impl_malloc)
231 AllocKind |= AllocFnKind::Uninitialized;
232
233 // TODO: Set memory attribute
234 FuncAttrBuilder.addAllocKindAttr(AllocKind);
235 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
236 FuncAttrBuilder.addAllocSizeAttr(0, LibcallImpl == RTLIB::impl_malloc
237 ? std::nullopt
238 : std::make_optional(1));
239
240 AttributeList Attrs;
241 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
242
243 {
244 AttrBuilder ArgAttrBuilder(Ctx);
245 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
246 ArgAttrBuilder.addAttribute(AK);
247
248 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoUndef);
249 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoAlias);
250 Attrs = Attrs.addParamAttribute(Ctx, 0, Attribute::NoUndef);
251 if (LibcallImpl == RTLIB::impl_calloc)
252 Attrs = Attrs.addParamAttribute(Ctx, 1, Attribute::NoUndef);
253 }
254
255 IntegerType *SizeT = getSizeTType(Ctx, DL);
256 PointerType *PtrTy = PointerType::get(Ctx, 0);
257 SmallVector<Type *, 2> ArgTys = {SizeT};
258 if (LibcallImpl == RTLIB::impl_calloc)
259 ArgTys.push_back(SizeT);
260
261 return {FunctionType::get(PtrTy, ArgTys, false), Attrs};
262 }
263 case RTLIB::impl_free: {
264 // TODO: Set memory attribute
265 AttrBuilder FuncAttrBuilder(Ctx);
266 for (Attribute::AttrKind Attr : MemoryFnAttrs)
267 FuncAttrBuilder.addAttribute(Attr);
268
269 FuncAttrBuilder.addAllocKindAttr(AllocFnKind::Free);
270 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
271
272 AttributeList Attrs;
273 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
274
275 {
276 AttrBuilder ArgAttrBuilder(Ctx);
277 ArgAttrBuilder.addAttribute(Attribute::NoUndef);
278 ArgAttrBuilder.addAttribute(Attribute::AllocatedPointer);
279 ArgAttrBuilder.addCapturesAttr(CaptureInfo::none());
280 Attrs = Attrs.addParamAttributes(Ctx, 0, ArgAttrBuilder);
281 }
282
283 return {FunctionType::get(Type::getVoidTy(Ctx), {PointerType::get(Ctx, 0)},
284 false),
285 Attrs};
286 }
287 case RTLIB::impl_sqrtf:
288 case RTLIB::impl_sqrt: {
289 AttrBuilder FuncAttrBuilder(Ctx);
290
291 for (Attribute::AttrKind Attr : CommonFnAttrs)
292 FuncAttrBuilder.addAttribute(Attr);
293 FuncAttrBuilder.addMemoryAttr(MemoryEffects::errnoMemOnly(ModRefInfo::Mod));
294
295 AttributeList Attrs;
296 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
297
298 Type *ScalarTy = LibcallImpl == RTLIB::impl_sqrtf ? Type::getFloatTy(Ctx)
299 : Type::getDoubleTy(Ctx);
300 FunctionType *FuncTy = FunctionType::get(ScalarTy, {ScalarTy}, false);
301
302 Attrs = Attrs.addRetAttribute(
304 fcNegNormal));
305 return {FuncTy, Attrs};
306 }
307 case RTLIB::impl__ZGVnN2vv_fmod:
308 case RTLIB::impl__ZGVnN4vv_fmodf:
309 case RTLIB::impl__ZGVsMxvv_fmod:
310 case RTLIB::impl__ZGVsMxvv_fmodf:
311 case RTLIB::impl_armpl_vfmodq_f32:
312 case RTLIB::impl_armpl_vfmodq_f64:
313 case RTLIB::impl_armpl_svfmod_f32_x:
314 case RTLIB::impl_armpl_svfmod_f64_x:
315 case RTLIB::impl_armpl_vpowq_f32:
316 case RTLIB::impl_armpl_vpowq_f64:
317 case RTLIB::impl_armpl_svpow_f32_x:
318 case RTLIB::impl_armpl_svpow_f64_x:
319 case RTLIB::impl_armpl_vcbrtq_f32:
320 case RTLIB::impl_armpl_vcbrtq_f64:
321 case RTLIB::impl_armpl_svcbrt_f32_x:
322 case RTLIB::impl_armpl_svcbrt_f64_x: {
323 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vv_fmodf ||
324 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
325 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
326 LibcallImpl == RTLIB::impl_armpl_vfmodq_f32 ||
327 LibcallImpl == RTLIB::impl_armpl_vpowq_f32 ||
328 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
329 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
330 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x;
331
332 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsMxvv_fmod ||
333 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
334 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
335 LibcallImpl == RTLIB::impl_armpl_svfmod_f64_x ||
336 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
337 LibcallImpl == RTLIB::impl_armpl_svpow_f64_x ||
338 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
339 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
340
341 bool HasOneArg = LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
342 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f64 ||
343 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
344 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
345
346 AttrBuilder FuncAttrBuilder(Ctx);
347
348 for (Attribute::AttrKind Attr : CommonFnAttrs)
349 FuncAttrBuilder.addAttribute(Attr);
350
351 AttributeList Attrs;
352 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
353
354 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
355 unsigned EC = IsF32 ? 4 : 2;
356 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
357
358 SmallVector<Type *, 3> ArgTys(HasOneArg ? 1 : 2, VecTy);
359 if (hasVectorMaskArgument(LibcallImpl))
360 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
361
362 FunctionType *FuncTy = FunctionType::get(VecTy, ArgTys, false);
363 return {FuncTy, Attrs};
364 }
365 case RTLIB::impl__ZGVnN2vl8_modf:
366 case RTLIB::impl__ZGVnN4vl4_modff:
367 case RTLIB::impl__ZGVsNxvl8_modf:
368 case RTLIB::impl__ZGVsNxvl4_modff:
369 case RTLIB::impl_armpl_vmodfq_f64:
370 case RTLIB::impl_armpl_vmodfq_f32:
371 case RTLIB::impl_armpl_svmodf_f64_x:
372 case RTLIB::impl_armpl_svmodf_f32_x: {
373 AttrBuilder FuncAttrBuilder(Ctx);
374
375 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4_modff ||
376 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
377 LibcallImpl == RTLIB::impl_armpl_vmodfq_f32 ||
378 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
379
380 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8_modf ||
381 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
382 LibcallImpl == RTLIB::impl_armpl_svmodf_f64_x ||
383 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
384
385 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
386 unsigned EC = IsF32 ? 4 : 2;
387 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
388
389 for (Attribute::AttrKind Attr : CommonFnAttrs)
390 FuncAttrBuilder.addAttribute(Attr);
391 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
392
393 AttributeList Attrs;
394 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
395
396 {
397 AttrBuilder ArgAttrBuilder(Ctx);
398 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
399 ArgAttrBuilder.addAttribute(AK);
400 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
401 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
402 }
403
404 PointerType *PtrTy = PointerType::get(Ctx, 0);
405 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy};
406 if (hasVectorMaskArgument(LibcallImpl))
407 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
408
409 return {FunctionType::get(VecTy, ArgTys, false), Attrs};
410 }
411 case RTLIB::impl__ZGVnN2vl8l8_sincos:
412 case RTLIB::impl__ZGVnN4vl4l4_sincosf:
413 case RTLIB::impl__ZGVsNxvl8l8_sincos:
414 case RTLIB::impl__ZGVsNxvl4l4_sincosf:
415 case RTLIB::impl_armpl_vsincosq_f64:
416 case RTLIB::impl_armpl_vsincosq_f32:
417 case RTLIB::impl_armpl_svsincos_f64_x:
418 case RTLIB::impl_armpl_svsincos_f32_x:
419 case RTLIB::impl__ZGVnN4vl4l4_sincospif:
420 case RTLIB::impl__ZGVnN2vl8l8_sincospi:
421 case RTLIB::impl__ZGVsNxvl4l4_sincospif:
422 case RTLIB::impl__ZGVsNxvl8l8_sincospi:
423 case RTLIB::impl_armpl_vsincospiq_f32:
424 case RTLIB::impl_armpl_vsincospiq_f64:
425 case RTLIB::impl_armpl_svsincospi_f32_x:
426 case RTLIB::impl_armpl_svsincospi_f64_x: {
427 AttrBuilder FuncAttrBuilder(Ctx);
428
429 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincospif ||
430 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
431 LibcallImpl == RTLIB::impl_armpl_vsincospiq_f32 ||
432 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
433 LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincosf ||
434 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
435 LibcallImpl == RTLIB::impl_armpl_vsincosq_f32 ||
436 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x;
437
438 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
439 unsigned EC = IsF32 ? 4 : 2;
440
441 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincos ||
442 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
443 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x ||
444 LibcallImpl == RTLIB::impl_armpl_svsincos_f64_x ||
445 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
446 LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincospi ||
447 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
448 LibcallImpl == RTLIB::impl_armpl_svsincospi_f64_x;
449 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
450
451 for (Attribute::AttrKind Attr : CommonFnAttrs)
452 FuncAttrBuilder.addAttribute(Attr);
453 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
454
455 AttributeList Attrs;
456 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
457
458 {
459 AttrBuilder ArgAttrBuilder(Ctx);
460 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
461 ArgAttrBuilder.addAttribute(AK);
462 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
463 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
464 Attrs = Attrs.addParamAttributes(Ctx, 2, ArgAttrBuilder);
465 }
466
467 PointerType *PtrTy = PointerType::get(Ctx, 0);
468 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy, PtrTy};
469 if (hasVectorMaskArgument(LibcallImpl))
470 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
471
472 return {FunctionType::get(Type::getVoidTy(Ctx), ArgTys, false), Attrs};
473 }
474 default:
475 return {};
476 }
477
478 return {};
479}
480
481bool RuntimeLibcallsInfo::hasVectorMaskArgument(RTLIB::LibcallImpl Impl) {
482 /// FIXME: This should be generated by tablegen and support the argument at an
483 /// arbitrary position
484 switch (Impl) {
485 case RTLIB::impl_armpl_svfmod_f32_x:
486 case RTLIB::impl_armpl_svfmod_f64_x:
487 case RTLIB::impl_armpl_svmodf_f64_x:
488 case RTLIB::impl_armpl_svmodf_f32_x:
489 case RTLIB::impl_armpl_svsincos_f32_x:
490 case RTLIB::impl_armpl_svsincos_f64_x:
491 case RTLIB::impl_armpl_svsincospi_f32_x:
492 case RTLIB::impl_armpl_svsincospi_f64_x:
493 case RTLIB::impl__ZGVsMxvv_fmod:
494 case RTLIB::impl__ZGVsMxvv_fmodf:
495 case RTLIB::impl_armpl_svpow_f32_x:
496 case RTLIB::impl_armpl_svpow_f64_x:
497 case RTLIB::impl_armpl_svcbrt_f32_x:
498 case RTLIB::impl_armpl_svcbrt_f64_x:
499 return true;
500 default:
501 return false;
502 }
503}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_ATTRIBUTE_ALWAYS_INLINE
LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do so, mark a method "always...
Definition Compiler.h:356
Utilities for dealing with flags related to floating point properties and mode controls.
Module.h This file contains the declarations for the Module class.
static IntegerType * getSizeTType(LLVMContext &Ctx, const DataLayout &DL)
TODO: There is really no guarantee that sizeof(size_t) is equal to the index size of the default addr...
static LLVM_ABI Attribute getWithNoFPClass(LLVMContext &Context, FPClassTest Mask)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition Attributes.h:124
static CaptureInfo none()
Create CaptureInfo that does not capture any components of the pointer.
Definition ModRef.h:427
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:873
Class to represent function types.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Class to represent integer types.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Definition ModRef.h:143
static MemoryEffectsBase errnoMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Definition ModRef.h:154
static MemoryEffectsBase argumentOrErrnoMemOnly(ModRefInfo ArgMR=ModRefInfo::ModRef, ModRefInfo ErrnoMR=ModRefInfo::ModRef)
Definition ModRef.h:198
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Class to represent pointers.
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.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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.
Definition Type.cpp:483
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:286
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:310
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:291
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:290
Base class of all SIMD vector types.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
LLVM_ABI LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
@ AArch64_VectorCall
Used between AArch64 Advanced SIMD functions.
This is an optimization pass for GlobalISel generic memory operations.
auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
Definition Sequence.h:337
AllocFnKind
Definition Attributes.h:53
ExceptionHandling
Definition CodeGen.h:53
@ None
No exception support.
Definition CodeGen.h:54
@ Mod
The access may modify the value stored in memory.
Definition ModRef.h:34
@ NoModRef
The access neither references nor modifies the value stored in memory.
Definition ModRef.h:30
ArrayRef(const T &OneElt) -> ArrayRef< T >
VectorLibrary
List of known vector-functions libraries.
EABI
Definition CodeGen.h:73
std::pair< FunctionType *, AttributeList > getFunctionTy(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const
void setAvailable(RTLIB::LibcallImpl Impl)
static bool hasVectorMaskArgument(RTLIB::LibcallImpl Impl)
Returns true if the function has a vector mask argument, which is assumed to be the last argument.
void setLibcallImplCallingConv(RTLIB::LibcallImpl Call, CallingConv::ID CC)
Set the CallingConv that should be used for the specified libcall implementation.