LLVM 24.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/Intrinsics.h"
13#include "llvm/IR/Module.h"
15#include "llvm/IR/Type.h"
16#include "llvm/Support/Debug.h"
17#include "llvm/Support/xxhash.h"
19
20#define DEBUG_TYPE "runtime-libcalls-info"
21
22using namespace llvm;
23using namespace RTLIB;
24
25#define GET_RUNTIME_LIBCALLS_INFO
26#define GET_INIT_RUNTIME_LIBCALL_NAMES
27#define GET_SET_TARGET_RUNTIME_LIBCALL_SETS
28#define DEFINE_GET_LOOKUP_LIBCALL_IMPL_NAME
29#define GET_RUNTIME_LIBCALL_INTRINSIC_TO_LIBCALL
30#include "llvm/IR/RuntimeLibcalls.inc"
31
33 ExceptionHandling ExceptionModel,
35 EABI EABIVersion, StringRef ABIName,
36 VectorLibrary VecLib) {
37 // FIXME: The ExceptionModel parameter is to handle the field in
38 // TargetOptions. This interface fails to distinguish the forced disable
39 // case for targets which support exceptions by default. This should
40 // probably be a module flag and removed from TargetOptions.
41 if (ExceptionModel == ExceptionHandling::None)
42 ExceptionModel = TT.getDefaultExceptionHandling();
43
44 initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion, ABIName,
45 TT.getDefaultLongDoubleFormat());
46
47 // TODO: Tablegen should generate these sets
48 switch (VecLib) {
50 for (RTLIB::LibcallImpl Impl :
51 {RTLIB::impl__ZGVnN2vv_fmod, RTLIB::impl__ZGVnN4vv_fmodf,
52 RTLIB::impl__ZGVsMxvv_fmod, RTLIB::impl__ZGVsMxvv_fmodf,
53 RTLIB::impl__ZGVnN2vl8_modf, RTLIB::impl__ZGVnN4vl4_modff,
54 RTLIB::impl__ZGVsNxvl8_modf, RTLIB::impl__ZGVsNxvl4_modff,
55 RTLIB::impl__ZGVnN2vl8l8_sincos, RTLIB::impl__ZGVnN4vl4l4_sincosf,
56 RTLIB::impl__ZGVsNxvl8l8_sincos, RTLIB::impl__ZGVsNxvl4l4_sincosf,
57 RTLIB::impl__ZGVnN4vl4l4_sincospif, RTLIB::impl__ZGVnN2vl8l8_sincospi,
58 RTLIB::impl__ZGVsNxvl4l4_sincospif,
59 RTLIB::impl__ZGVsNxvl8l8_sincospi})
60 setAvailable(Impl);
61 break;
63 for (RTLIB::LibcallImpl Impl : {RTLIB::impl_armpl_svfmod_f32_x,
64 RTLIB::impl_armpl_svfmod_f64_x,
65 RTLIB::impl_armpl_vfmodq_f32,
66 RTLIB::impl_armpl_vfmodq_f64,
67 RTLIB::impl_armpl_vmodfq_f64,
68 RTLIB::impl_armpl_vmodfq_f32,
69 RTLIB::impl_armpl_svmodf_f64_x,
70 RTLIB::impl_armpl_svmodf_f32_x,
71 RTLIB::impl_armpl_vsincosq_f64,
72 RTLIB::impl_armpl_vsincosq_f32,
73 RTLIB::impl_armpl_svsincos_f64_x,
74 RTLIB::impl_armpl_svsincos_f32_x,
75 RTLIB::impl_armpl_vsincospiq_f32,
76 RTLIB::impl_armpl_vsincospiq_f64,
77 RTLIB::impl_armpl_svsincospi_f32_x,
78 RTLIB::impl_armpl_svsincospi_f64_x,
79 RTLIB::impl_armpl_svpow_f32_x,
80 RTLIB::impl_armpl_svpow_f64_x,
81 RTLIB::impl_armpl_vpowq_f32,
82 RTLIB::impl_armpl_vpowq_f64,
83 RTLIB::impl_armpl_svcbrt_f32_x,
84 RTLIB::impl_armpl_svcbrt_f64_x,
85 RTLIB::impl_armpl_vcbrtq_f32,
86 RTLIB::impl_armpl_vcbrtq_f64})
87 setAvailable(Impl);
88
89 for (RTLIB::LibcallImpl Impl :
90 {RTLIB::impl_armpl_vfmodq_f32, RTLIB::impl_armpl_vfmodq_f64,
91 RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32,
92 RTLIB::impl_armpl_vpowq_f32, RTLIB::impl_armpl_vpowq_f64,
93 RTLIB::impl_armpl_vcbrtq_f32, RTLIB::impl_armpl_vcbrtq_f64})
95 break;
97 for (RTLIB::LibcallImpl Impl :
98 {RTLIB::impl_amd_vrd2_sincos, RTLIB::impl_amd_vrd4_sincos,
99 RTLIB::impl_amd_vrd8_sincos, RTLIB::impl_amd_vrs4_sincosf,
100 RTLIB::impl_amd_vrs8_sincosf, RTLIB::impl_amd_vrs16_sincosf})
101 setAvailable(Impl);
102 break;
103 default:
104 break;
105 }
106}
107
109 // TODO: Consider the remaining module flags.
110 const Triple &TT = M.getTargetTriple();
111 initLibcalls(TT, TT.getDefaultExceptionHandling(), FloatABI::Default,
112 EABI::Default, /*ABIName=*/"", M.getLongDoubleFormat());
113}
114
115/// Set default libcall names. If a target wants to opt-out of a libcall it
116/// should be placed here.
117void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
118 ExceptionHandling ExceptionModel,
120 EABI EABIVersion, StringRef ABIName,
122 setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
123 ABIName, LongDoubleFormat);
124}
125
128RuntimeLibcallsInfo::libcallImplNameHit(uint16_t NameOffsetEntry,
129 uint16_t StrOffset) {
130 int NumAliases = 1;
131 for (uint16_t Entry : ArrayRef(RuntimeLibcallNameOffsetTable)
132 .drop_front(NameOffsetEntry + 1)) {
133 if (Entry != StrOffset)
134 break;
135 ++NumAliases;
136 }
137
138 RTLIB::LibcallImpl ImplStart = static_cast<RTLIB::LibcallImpl>(
139 &RuntimeLibcallNameOffsetTable[NameOffsetEntry] -
140 &RuntimeLibcallNameOffsetTable[0]);
141 return enum_seq(ImplStart,
142 static_cast<RTLIB::LibcallImpl>(ImplStart + NumAliases));
143}
144
145bool RuntimeLibcallsInfo::isAAPCS_ABI(const Triple &TT, StringRef ABIName) {
146 const ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
147 return TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16;
148}
149
150/// TODO: There is really no guarantee that sizeof(size_t) is equal to the index
151/// size of the default address space. This matches TargetLibraryInfo and should
152/// be kept in sync.
154 return DL.getIndexType(Ctx, /*AddressSpace=*/0);
155}
156
157std::pair<FunctionType *, AttributeList>
159 const DataLayout &DL,
160 RTLIB::LibcallImpl LibcallImpl) const {
161 // TODO: NoCallback probably unsafe in general
162 static constexpr Attribute::AttrKind CommonFnAttrs[] = {
163 Attribute::NoCallback, Attribute::NoFree, Attribute::NoSync,
164 Attribute::NoUnwind, Attribute::WillReturn};
165 static constexpr Attribute::AttrKind MemoryFnAttrs[] = {
166 Attribute::NoUnwind, Attribute::WillReturn};
167 static constexpr Attribute::AttrKind CommonPtrArgAttrs[] = {
168 Attribute::NoAlias, Attribute::WriteOnly, Attribute::NonNull};
169
170 switch (LibcallImpl) {
171 case RTLIB::impl___sincos_stret:
172 case RTLIB::impl___sincosf_stret: {
173 if (!darwinHasSinCosStret(TT)) // Non-darwin currently unexpected
174 return {};
175
176 Type *ScalarTy = LibcallImpl == RTLIB::impl___sincosf_stret
177 ? Type::getFloatTy(Ctx)
178 : Type::getDoubleTy(Ctx);
179
180 AttrBuilder FuncAttrBuilder(Ctx);
181 for (Attribute::AttrKind Attr : CommonFnAttrs)
182 FuncAttrBuilder.addAttribute(Attr);
183
184 const bool UseSret =
185 TT.isX86_32() || ((TT.isARM() || TT.isThumb()) &&
187
188 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argumentOrErrnoMemOnly(
190
191 AttributeList Attrs;
192 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
193
194 if (UseSret) {
195 AttrBuilder AttrBuilder(Ctx);
196 StructType *StructTy = StructType::get(ScalarTy, ScalarTy);
197 AttrBuilder.addStructRetAttr(StructTy);
198 AttrBuilder.addAlignmentAttr(DL.getABITypeAlign(StructTy));
200 Type::getVoidTy(Ctx), {DL.getAllocaPtrType(Ctx), ScalarTy}, false);
201
202 return {FuncTy, Attrs.addParamAttributes(Ctx, 0, AttrBuilder)};
203 }
204
205 Type *RetTy =
206 LibcallImpl == RTLIB::impl___sincosf_stret && TT.isX86_64()
207 ? static_cast<Type *>(FixedVectorType::get(ScalarTy, 2))
208 : static_cast<Type *>(StructType::get(ScalarTy, ScalarTy));
209
210 return {FunctionType::get(RetTy, {ScalarTy}, false), Attrs};
211 }
212 case RTLIB::impl_malloc:
213 case RTLIB::impl_calloc: {
214 AttrBuilder FuncAttrBuilder(Ctx);
215 for (Attribute::AttrKind Attr : MemoryFnAttrs)
216 FuncAttrBuilder.addAttribute(Attr);
217 FuncAttrBuilder.addAttribute(Attribute::NoFree);
218
220 if (LibcallImpl == RTLIB::impl_malloc)
221 AllocKind |= AllocFnKind::Uninitialized;
222
223 // TODO: Set memory attribute
224 FuncAttrBuilder.addAllocKindAttr(AllocKind);
225 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
226 FuncAttrBuilder.addAllocSizeAttr(0, LibcallImpl == RTLIB::impl_malloc
227 ? std::nullopt
228 : std::make_optional(1));
229
230 AttributeList Attrs;
231 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
232
233 {
234 AttrBuilder ArgAttrBuilder(Ctx);
235 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
236 ArgAttrBuilder.addAttribute(AK);
237
238 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoUndef);
239 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoAlias);
240 Attrs = Attrs.addParamAttribute(Ctx, 0, Attribute::NoUndef);
241 if (LibcallImpl == RTLIB::impl_calloc)
242 Attrs = Attrs.addParamAttribute(Ctx, 1, Attribute::NoUndef);
243 }
244
245 IntegerType *SizeT = getSizeTType(Ctx, DL);
246 PointerType *PtrTy = PointerType::get(Ctx, 0);
247 SmallVector<Type *, 2> ArgTys = {SizeT};
248 if (LibcallImpl == RTLIB::impl_calloc)
249 ArgTys.push_back(SizeT);
250
251 return {FunctionType::get(PtrTy, ArgTys, false), Attrs};
252 }
253 case RTLIB::impl_free: {
254 // TODO: Set memory attribute
255 AttrBuilder FuncAttrBuilder(Ctx);
256 for (Attribute::AttrKind Attr : MemoryFnAttrs)
257 FuncAttrBuilder.addAttribute(Attr);
258
259 FuncAttrBuilder.addAllocKindAttr(AllocFnKind::Free);
260 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
261
262 AttributeList Attrs;
263 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
264
265 {
266 AttrBuilder ArgAttrBuilder(Ctx);
267 ArgAttrBuilder.addAttribute(Attribute::NoUndef);
268 ArgAttrBuilder.addAttribute(Attribute::AllocatedPointer);
269 ArgAttrBuilder.addCapturesAttr(CaptureInfo::none());
270 Attrs = Attrs.addParamAttributes(Ctx, 0, ArgAttrBuilder);
271 }
272
273 return {FunctionType::get(Type::getVoidTy(Ctx), {PointerType::get(Ctx, 0)},
274 false),
275 Attrs};
276 }
277 case RTLIB::impl_sqrtf:
278 case RTLIB::impl_sqrt: {
279 AttrBuilder FuncAttrBuilder(Ctx);
280
281 for (Attribute::AttrKind Attr : CommonFnAttrs)
282 FuncAttrBuilder.addAttribute(Attr);
283 FuncAttrBuilder.addMemoryAttr(MemoryEffects::errnoMemOnly(ModRefInfo::Mod));
284
285 AttributeList Attrs;
286 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
287
288 Type *ScalarTy = LibcallImpl == RTLIB::impl_sqrtf ? Type::getFloatTy(Ctx)
289 : Type::getDoubleTy(Ctx);
290 FunctionType *FuncTy = FunctionType::get(ScalarTy, {ScalarTy}, false);
291
292 Attrs = Attrs.addRetAttribute(
294 fcNegNormal));
295 return {FuncTy, Attrs};
296 }
297 case RTLIB::impl__ZGVnN2vv_fmod:
298 case RTLIB::impl__ZGVnN4vv_fmodf:
299 case RTLIB::impl__ZGVsMxvv_fmod:
300 case RTLIB::impl__ZGVsMxvv_fmodf:
301 case RTLIB::impl_armpl_vfmodq_f32:
302 case RTLIB::impl_armpl_vfmodq_f64:
303 case RTLIB::impl_armpl_svfmod_f32_x:
304 case RTLIB::impl_armpl_svfmod_f64_x:
305 case RTLIB::impl_armpl_vpowq_f32:
306 case RTLIB::impl_armpl_vpowq_f64:
307 case RTLIB::impl_armpl_svpow_f32_x:
308 case RTLIB::impl_armpl_svpow_f64_x:
309 case RTLIB::impl_armpl_vcbrtq_f32:
310 case RTLIB::impl_armpl_vcbrtq_f64:
311 case RTLIB::impl_armpl_svcbrt_f32_x:
312 case RTLIB::impl_armpl_svcbrt_f64_x: {
313 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vv_fmodf ||
314 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
315 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
316 LibcallImpl == RTLIB::impl_armpl_vfmodq_f32 ||
317 LibcallImpl == RTLIB::impl_armpl_vpowq_f32 ||
318 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
319 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
320 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x;
321
322 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsMxvv_fmod ||
323 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
324 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
325 LibcallImpl == RTLIB::impl_armpl_svfmod_f64_x ||
326 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
327 LibcallImpl == RTLIB::impl_armpl_svpow_f64_x ||
328 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
329 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
330
331 bool HasOneArg = LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
332 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f64 ||
333 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
334 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
335
336 AttrBuilder FuncAttrBuilder(Ctx);
337
338 for (Attribute::AttrKind Attr : CommonFnAttrs)
339 FuncAttrBuilder.addAttribute(Attr);
340
341 AttributeList Attrs;
342 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
343
344 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
345 unsigned EC = IsF32 ? 4 : 2;
346 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
347
348 SmallVector<Type *, 3> ArgTys(HasOneArg ? 1 : 2, VecTy);
349 if (hasVectorMaskArgument(LibcallImpl))
350 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
351
352 FunctionType *FuncTy = FunctionType::get(VecTy, ArgTys, false);
353 return {FuncTy, Attrs};
354 }
355 case RTLIB::impl__ZGVnN2vl8_modf:
356 case RTLIB::impl__ZGVnN4vl4_modff:
357 case RTLIB::impl__ZGVsNxvl8_modf:
358 case RTLIB::impl__ZGVsNxvl4_modff:
359 case RTLIB::impl_armpl_vmodfq_f64:
360 case RTLIB::impl_armpl_vmodfq_f32:
361 case RTLIB::impl_armpl_svmodf_f64_x:
362 case RTLIB::impl_armpl_svmodf_f32_x: {
363 AttrBuilder FuncAttrBuilder(Ctx);
364
365 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4_modff ||
366 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
367 LibcallImpl == RTLIB::impl_armpl_vmodfq_f32 ||
368 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
369
370 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8_modf ||
371 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
372 LibcallImpl == RTLIB::impl_armpl_svmodf_f64_x ||
373 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
374
375 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
376 unsigned EC = IsF32 ? 4 : 2;
377 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
378
379 for (Attribute::AttrKind Attr : CommonFnAttrs)
380 FuncAttrBuilder.addAttribute(Attr);
381 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
382
383 AttributeList Attrs;
384 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
385
386 {
387 AttrBuilder ArgAttrBuilder(Ctx);
388 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
389 ArgAttrBuilder.addAttribute(AK);
390 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
391 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
392 }
393
394 PointerType *PtrTy = PointerType::get(Ctx, 0);
395 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy};
396 if (hasVectorMaskArgument(LibcallImpl))
397 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
398
399 return {FunctionType::get(VecTy, ArgTys, false), Attrs};
400 }
401 case RTLIB::impl__ZGVnN2vl8l8_sincos:
402 case RTLIB::impl__ZGVnN4vl4l4_sincosf:
403 case RTLIB::impl__ZGVsNxvl8l8_sincos:
404 case RTLIB::impl__ZGVsNxvl4l4_sincosf:
405 case RTLIB::impl_armpl_vsincosq_f64:
406 case RTLIB::impl_armpl_vsincosq_f32:
407 case RTLIB::impl_armpl_svsincos_f64_x:
408 case RTLIB::impl_armpl_svsincos_f32_x:
409 case RTLIB::impl__ZGVnN4vl4l4_sincospif:
410 case RTLIB::impl__ZGVnN2vl8l8_sincospi:
411 case RTLIB::impl__ZGVsNxvl4l4_sincospif:
412 case RTLIB::impl__ZGVsNxvl8l8_sincospi:
413 case RTLIB::impl_armpl_vsincospiq_f32:
414 case RTLIB::impl_armpl_vsincospiq_f64:
415 case RTLIB::impl_armpl_svsincospi_f32_x:
416 case RTLIB::impl_armpl_svsincospi_f64_x: {
417 AttrBuilder FuncAttrBuilder(Ctx);
418
419 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincospif ||
420 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
421 LibcallImpl == RTLIB::impl_armpl_vsincospiq_f32 ||
422 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
423 LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincosf ||
424 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
425 LibcallImpl == RTLIB::impl_armpl_vsincosq_f32 ||
426 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x;
427
428 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
429 unsigned EC = IsF32 ? 4 : 2;
430
431 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincos ||
432 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
433 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x ||
434 LibcallImpl == RTLIB::impl_armpl_svsincos_f64_x ||
435 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
436 LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincospi ||
437 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
438 LibcallImpl == RTLIB::impl_armpl_svsincospi_f64_x;
439 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
440
441 for (Attribute::AttrKind Attr : CommonFnAttrs)
442 FuncAttrBuilder.addAttribute(Attr);
443 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
444
445 AttributeList Attrs;
446 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
447
448 {
449 AttrBuilder ArgAttrBuilder(Ctx);
450 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
451 ArgAttrBuilder.addAttribute(AK);
452 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
453 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
454 Attrs = Attrs.addParamAttributes(Ctx, 2, ArgAttrBuilder);
455 }
456
457 PointerType *PtrTy = PointerType::get(Ctx, 0);
458 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy, PtrTy};
459 if (hasVectorMaskArgument(LibcallImpl))
460 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
461
462 return {FunctionType::get(Type::getVoidTy(Ctx), ArgTys, false), Attrs};
463 }
464 default:
465 return {};
466 }
467
468 return {};
469}
470
471bool RuntimeLibcallsInfo::hasVectorMaskArgument(RTLIB::LibcallImpl Impl) {
472 /// FIXME: This should be generated by tablegen and support the argument at an
473 /// arbitrary position
474 switch (Impl) {
475 case RTLIB::impl_armpl_svfmod_f32_x:
476 case RTLIB::impl_armpl_svfmod_f64_x:
477 case RTLIB::impl_armpl_svmodf_f64_x:
478 case RTLIB::impl_armpl_svmodf_f32_x:
479 case RTLIB::impl_armpl_svsincos_f32_x:
480 case RTLIB::impl_armpl_svsincos_f64_x:
481 case RTLIB::impl_armpl_svsincospi_f32_x:
482 case RTLIB::impl_armpl_svsincospi_f64_x:
483 case RTLIB::impl__ZGVsMxvv_fmod:
484 case RTLIB::impl__ZGVsMxvv_fmodf:
485 case RTLIB::impl_armpl_svpow_f32_x:
486 case RTLIB::impl_armpl_svpow_f64_x:
487 case RTLIB::impl_armpl_svcbrt_f32_x:
488 case RTLIB::impl_armpl_svcbrt_f64_x:
489 return true;
490 default:
491 return false;
492 }
493}
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:364
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:867
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(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
Definition Type.cpp:911
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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:477
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
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:282
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:306
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:287
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:286
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.
AllocFnKind
Definition Attributes.h:53
LongDoubleFormat
The floating-point format used for the target's "long double" type.
Definition CodeGen.h:67
constexpr auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
Definition Sequence.h:373
@ 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 >
ExceptionHandling
Definition CodeGen.h:54
@ None
No exception support.
Definition CodeGen.h:55
VectorLibrary
List of known vector-functions libraries.
LLVM_ABI std::pair< FunctionType *, AttributeList > getFunctionTy(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const
void setAvailable(RTLIB::LibcallImpl Impl)
static LLVM_ABI 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.