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;
92 default:
93 break;
94 }
95}
96
98 : RuntimeLibcallsInfo(M.getTargetTriple()) {
99 // TODO: Consider module flags
100}
101
102/// Set default libcall names. If a target wants to opt-out of a libcall it
103/// should be placed here.
104void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
105 ExceptionHandling ExceptionModel,
107 EABI EABIVersion, StringRef ABIName) {
108 setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
109 ABIName);
110}
111
114RuntimeLibcallsInfo::libcallImplNameHit(uint16_t NameOffsetEntry,
115 uint16_t StrOffset) {
116 int NumAliases = 1;
117 for (uint16_t Entry : ArrayRef(RuntimeLibcallNameOffsetTable)
118 .drop_front(NameOffsetEntry + 1)) {
119 if (Entry != StrOffset)
120 break;
121 ++NumAliases;
122 }
123
124 RTLIB::LibcallImpl ImplStart = static_cast<RTLIB::LibcallImpl>(
125 &RuntimeLibcallNameOffsetTable[NameOffsetEntry] -
126 &RuntimeLibcallNameOffsetTable[0]);
127 return enum_seq(ImplStart,
128 static_cast<RTLIB::LibcallImpl>(ImplStart + NumAliases));
129}
130
131bool RuntimeLibcallsInfo::isAAPCS_ABI(const Triple &TT, StringRef ABIName) {
132 const ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
133 return TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16;
134}
135
136bool RuntimeLibcallsInfo::darwinHasExp10(const Triple &TT) {
137 switch (TT.getOS()) {
138 case Triple::MacOSX:
139 return !TT.isMacOSXVersionLT(10, 9);
140 case Triple::IOS:
141 return !TT.isOSVersionLT(7, 0);
143 case Triple::TvOS:
144 case Triple::WatchOS:
145 case Triple::XROS:
146 case Triple::BridgeOS:
147 return true;
148 default:
149 return false;
150 }
151}
152
153/// TODO: There is really no guarantee that sizeof(size_t) is equal to the index
154/// size of the default address space. This matches TargetLibraryInfo and should
155/// be kept in sync.
157 return DL.getIndexType(Ctx, /*AddressSpace=*/0);
158}
159
160std::pair<FunctionType *, AttributeList>
162 const DataLayout &DL,
163 RTLIB::LibcallImpl LibcallImpl) const {
164 // TODO: NoCallback probably unsafe in general
165 static constexpr Attribute::AttrKind CommonFnAttrs[] = {
166 Attribute::MustProgress, Attribute::NoCallback, Attribute::NoFree,
167 Attribute::NoSync, Attribute::NoUnwind, Attribute::WillReturn};
168 static constexpr Attribute::AttrKind MemoryFnAttrs[] = {
169 Attribute::MustProgress, Attribute::NoUnwind, Attribute::WillReturn};
170 static constexpr Attribute::AttrKind CommonPtrArgAttrs[] = {
171 Attribute::NoAlias, Attribute::WriteOnly, Attribute::NonNull};
172
173 switch (LibcallImpl) {
174 case RTLIB::impl___sincos_stret:
175 case RTLIB::impl___sincosf_stret: {
176 if (!darwinHasSinCosStret(TT)) // Non-darwin currently unexpected
177 return {};
178
179 Type *ScalarTy = LibcallImpl == RTLIB::impl___sincosf_stret
180 ? Type::getFloatTy(Ctx)
181 : Type::getDoubleTy(Ctx);
182
183 AttrBuilder FuncAttrBuilder(Ctx);
184 for (Attribute::AttrKind Attr : CommonFnAttrs)
185 FuncAttrBuilder.addAttribute(Attr);
186
187 const bool UseSret =
188 TT.isX86_32() || ((TT.isARM() || TT.isThumb()) &&
190
191 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argumentOrErrnoMemOnly(
193
194 AttributeList Attrs;
195 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
196
197 if (UseSret) {
198 AttrBuilder AttrBuilder(Ctx);
199 StructType *StructTy = StructType::get(ScalarTy, ScalarTy);
200 AttrBuilder.addStructRetAttr(StructTy);
201 AttrBuilder.addAlignmentAttr(DL.getABITypeAlign(StructTy));
203 Type::getVoidTy(Ctx), {DL.getAllocaPtrType(Ctx), ScalarTy}, false);
204
205 return {FuncTy, Attrs.addParamAttributes(Ctx, 0, AttrBuilder)};
206 }
207
208 Type *RetTy =
209 LibcallImpl == RTLIB::impl___sincosf_stret && TT.isX86_64()
210 ? static_cast<Type *>(FixedVectorType::get(ScalarTy, 2))
211 : static_cast<Type *>(StructType::get(ScalarTy, ScalarTy));
212
213 return {FunctionType::get(RetTy, {ScalarTy}, false), Attrs};
214 }
215 case RTLIB::impl_malloc:
216 case RTLIB::impl_calloc: {
217 AttrBuilder FuncAttrBuilder(Ctx);
218 for (Attribute::AttrKind Attr : MemoryFnAttrs)
219 FuncAttrBuilder.addAttribute(Attr);
220 FuncAttrBuilder.addAttribute(Attribute::NoFree);
221
223 if (LibcallImpl == RTLIB::impl_malloc)
224 AllocKind |= AllocFnKind::Uninitialized;
225
226 // TODO: Set memory attribute
227 FuncAttrBuilder.addAllocKindAttr(AllocKind);
228 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
229 FuncAttrBuilder.addAllocSizeAttr(0, LibcallImpl == RTLIB::impl_malloc
230 ? std::nullopt
231 : std::make_optional(1));
232
233 AttributeList Attrs;
234 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
235
236 {
237 AttrBuilder ArgAttrBuilder(Ctx);
238 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
239 ArgAttrBuilder.addAttribute(AK);
240
241 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoUndef);
242 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoAlias);
243 Attrs = Attrs.addParamAttribute(Ctx, 0, Attribute::NoUndef);
244 if (LibcallImpl == RTLIB::impl_calloc)
245 Attrs = Attrs.addParamAttribute(Ctx, 1, Attribute::NoUndef);
246 }
247
248 IntegerType *SizeT = getSizeTType(Ctx, DL);
249 PointerType *PtrTy = PointerType::get(Ctx, 0);
250 SmallVector<Type *, 2> ArgTys = {SizeT};
251 if (LibcallImpl == RTLIB::impl_calloc)
252 ArgTys.push_back(SizeT);
253
254 return {FunctionType::get(PtrTy, ArgTys, false), Attrs};
255 }
256 case RTLIB::impl_free: {
257 // TODO: Set memory attribute
258 AttrBuilder FuncAttrBuilder(Ctx);
259 for (Attribute::AttrKind Attr : MemoryFnAttrs)
260 FuncAttrBuilder.addAttribute(Attr);
261
262 FuncAttrBuilder.addAllocKindAttr(AllocFnKind::Free);
263 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
264
265 AttributeList Attrs;
266 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
267
268 {
269 AttrBuilder ArgAttrBuilder(Ctx);
270 ArgAttrBuilder.addAttribute(Attribute::NoUndef);
271 ArgAttrBuilder.addAttribute(Attribute::AllocatedPointer);
272 ArgAttrBuilder.addCapturesAttr(CaptureInfo::none());
273 Attrs = Attrs.addParamAttributes(Ctx, 0, ArgAttrBuilder);
274 }
275
276 return {FunctionType::get(Type::getVoidTy(Ctx), {PointerType::get(Ctx, 0)},
277 false),
278 Attrs};
279 }
280 case RTLIB::impl_sqrtf:
281 case RTLIB::impl_sqrt: {
282 AttrBuilder FuncAttrBuilder(Ctx);
283
284 for (Attribute::AttrKind Attr : CommonFnAttrs)
285 FuncAttrBuilder.addAttribute(Attr);
286 FuncAttrBuilder.addMemoryAttr(MemoryEffects::errnoMemOnly(ModRefInfo::Mod));
287
288 AttributeList Attrs;
289 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
290
291 Type *ScalarTy = LibcallImpl == RTLIB::impl_sqrtf ? Type::getFloatTy(Ctx)
292 : Type::getDoubleTy(Ctx);
293 FunctionType *FuncTy = FunctionType::get(ScalarTy, {ScalarTy}, false);
294
295 Attrs = Attrs.addRetAttribute(
297 fcNegNormal));
298 return {FuncTy, Attrs};
299 }
300 case RTLIB::impl__ZGVnN2vv_fmod:
301 case RTLIB::impl__ZGVnN4vv_fmodf:
302 case RTLIB::impl__ZGVsMxvv_fmod:
303 case RTLIB::impl__ZGVsMxvv_fmodf:
304 case RTLIB::impl_armpl_vfmodq_f32:
305 case RTLIB::impl_armpl_vfmodq_f64:
306 case RTLIB::impl_armpl_svfmod_f32_x:
307 case RTLIB::impl_armpl_svfmod_f64_x:
308 case RTLIB::impl_armpl_vpowq_f32:
309 case RTLIB::impl_armpl_vpowq_f64:
310 case RTLIB::impl_armpl_svpow_f32_x:
311 case RTLIB::impl_armpl_svpow_f64_x:
312 case RTLIB::impl_armpl_vcbrtq_f32:
313 case RTLIB::impl_armpl_vcbrtq_f64:
314 case RTLIB::impl_armpl_svcbrt_f32_x:
315 case RTLIB::impl_armpl_svcbrt_f64_x: {
316 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vv_fmodf ||
317 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
318 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
319 LibcallImpl == RTLIB::impl_armpl_vfmodq_f32 ||
320 LibcallImpl == RTLIB::impl_armpl_vpowq_f32 ||
321 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
322 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
323 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x;
324
325 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsMxvv_fmod ||
326 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
327 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
328 LibcallImpl == RTLIB::impl_armpl_svfmod_f64_x ||
329 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
330 LibcallImpl == RTLIB::impl_armpl_svpow_f64_x ||
331 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
332 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
333
334 bool HasOneArg = LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
335 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f64 ||
336 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
337 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
338
339 AttrBuilder FuncAttrBuilder(Ctx);
340
341 for (Attribute::AttrKind Attr : CommonFnAttrs)
342 FuncAttrBuilder.addAttribute(Attr);
343
344 AttributeList Attrs;
345 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
346
347 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
348 unsigned EC = IsF32 ? 4 : 2;
349 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
350
351 SmallVector<Type *, 3> ArgTys(HasOneArg ? 1 : 2, VecTy);
352 if (hasVectorMaskArgument(LibcallImpl))
353 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
354
355 FunctionType *FuncTy = FunctionType::get(VecTy, ArgTys, false);
356 return {FuncTy, Attrs};
357 }
358 case RTLIB::impl__ZGVnN2vl8_modf:
359 case RTLIB::impl__ZGVnN4vl4_modff:
360 case RTLIB::impl__ZGVsNxvl8_modf:
361 case RTLIB::impl__ZGVsNxvl4_modff:
362 case RTLIB::impl_armpl_vmodfq_f64:
363 case RTLIB::impl_armpl_vmodfq_f32:
364 case RTLIB::impl_armpl_svmodf_f64_x:
365 case RTLIB::impl_armpl_svmodf_f32_x: {
366 AttrBuilder FuncAttrBuilder(Ctx);
367
368 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4_modff ||
369 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
370 LibcallImpl == RTLIB::impl_armpl_vmodfq_f32 ||
371 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
372
373 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8_modf ||
374 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
375 LibcallImpl == RTLIB::impl_armpl_svmodf_f64_x ||
376 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
377
378 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
379 unsigned EC = IsF32 ? 4 : 2;
380 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
381
382 for (Attribute::AttrKind Attr : CommonFnAttrs)
383 FuncAttrBuilder.addAttribute(Attr);
384 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
385
386 AttributeList Attrs;
387 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
388
389 {
390 AttrBuilder ArgAttrBuilder(Ctx);
391 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
392 ArgAttrBuilder.addAttribute(AK);
393 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
394 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
395 }
396
397 PointerType *PtrTy = PointerType::get(Ctx, 0);
398 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy};
399 if (hasVectorMaskArgument(LibcallImpl))
400 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
401
402 return {FunctionType::get(VecTy, ArgTys, false), Attrs};
403 }
404 case RTLIB::impl__ZGVnN2vl8l8_sincos:
405 case RTLIB::impl__ZGVnN4vl4l4_sincosf:
406 case RTLIB::impl__ZGVsNxvl8l8_sincos:
407 case RTLIB::impl__ZGVsNxvl4l4_sincosf:
408 case RTLIB::impl_armpl_vsincosq_f64:
409 case RTLIB::impl_armpl_vsincosq_f32:
410 case RTLIB::impl_armpl_svsincos_f64_x:
411 case RTLIB::impl_armpl_svsincos_f32_x:
412 case RTLIB::impl__ZGVnN4vl4l4_sincospif:
413 case RTLIB::impl__ZGVnN2vl8l8_sincospi:
414 case RTLIB::impl__ZGVsNxvl4l4_sincospif:
415 case RTLIB::impl__ZGVsNxvl8l8_sincospi:
416 case RTLIB::impl_armpl_vsincospiq_f32:
417 case RTLIB::impl_armpl_vsincospiq_f64:
418 case RTLIB::impl_armpl_svsincospi_f32_x:
419 case RTLIB::impl_armpl_svsincospi_f64_x: {
420 AttrBuilder FuncAttrBuilder(Ctx);
421
422 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincospif ||
423 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
424 LibcallImpl == RTLIB::impl_armpl_vsincospiq_f32 ||
425 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
426 LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincosf ||
427 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
428 LibcallImpl == RTLIB::impl_armpl_vsincosq_f32 ||
429 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x;
430
431 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
432 unsigned EC = IsF32 ? 4 : 2;
433
434 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincos ||
435 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
436 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x ||
437 LibcallImpl == RTLIB::impl_armpl_svsincos_f64_x ||
438 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
439 LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincospi ||
440 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
441 LibcallImpl == RTLIB::impl_armpl_svsincospi_f64_x;
442 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
443
444 for (Attribute::AttrKind Attr : CommonFnAttrs)
445 FuncAttrBuilder.addAttribute(Attr);
446 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
447
448 AttributeList Attrs;
449 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
450
451 {
452 AttrBuilder ArgAttrBuilder(Ctx);
453 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
454 ArgAttrBuilder.addAttribute(AK);
455 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
456 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
457 Attrs = Attrs.addParamAttributes(Ctx, 2, ArgAttrBuilder);
458 }
459
460 PointerType *PtrTy = PointerType::get(Ctx, 0);
461 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy, PtrTy};
462 if (hasVectorMaskArgument(LibcallImpl))
463 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
464
465 return {FunctionType::get(Type::getVoidTy(Ctx), ArgTys, false), Attrs};
466 }
467 default:
468 return {};
469 }
470
471 return {};
472}
473
474bool RuntimeLibcallsInfo::hasVectorMaskArgument(RTLIB::LibcallImpl Impl) {
475 /// FIXME: This should be generated by tablegen and support the argument at an
476 /// arbitrary position
477 switch (Impl) {
478 case RTLIB::impl_armpl_svfmod_f32_x:
479 case RTLIB::impl_armpl_svfmod_f64_x:
480 case RTLIB::impl_armpl_svmodf_f64_x:
481 case RTLIB::impl_armpl_svmodf_f32_x:
482 case RTLIB::impl_armpl_svsincos_f32_x:
483 case RTLIB::impl_armpl_svsincos_f64_x:
484 case RTLIB::impl_armpl_svsincospi_f32_x:
485 case RTLIB::impl_armpl_svsincospi_f64_x:
486 case RTLIB::impl__ZGVsMxvv_fmod:
487 case RTLIB::impl__ZGVsMxvv_fmodf:
488 case RTLIB::impl_armpl_svpow_f32_x:
489 case RTLIB::impl_armpl_svpow_f64_x:
490 case RTLIB::impl_armpl_svcbrt_f32_x:
491 case RTLIB::impl_armpl_svcbrt_f64_x:
492 return true;
493 default:
494 return false;
495 }
496}
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:407
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:802
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:413
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:45
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:280
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:293
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:285
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:284
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.
Definition Types.h:26
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.