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/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
143/// TODO: There is really no guarantee that sizeof(size_t) is equal to the index
144/// size of the default address space. This matches TargetLibraryInfo and should
145/// be kept in sync.
147 return DL.getIndexType(Ctx, /*AddressSpace=*/0);
148}
149
150std::pair<FunctionType *, AttributeList>
152 const DataLayout &DL,
153 RTLIB::LibcallImpl LibcallImpl) const {
154 // TODO: NoCallback probably unsafe in general
155 static constexpr Attribute::AttrKind CommonFnAttrs[] = {
156 Attribute::NoCallback, Attribute::NoFree, Attribute::NoSync,
157 Attribute::NoUnwind, Attribute::WillReturn};
158 static constexpr Attribute::AttrKind MemoryFnAttrs[] = {
159 Attribute::NoUnwind, Attribute::WillReturn};
160 static constexpr Attribute::AttrKind CommonPtrArgAttrs[] = {
161 Attribute::NoAlias, Attribute::WriteOnly, Attribute::NonNull};
162
163 switch (LibcallImpl) {
164 case RTLIB::impl___sincos_stret:
165 case RTLIB::impl___sincosf_stret: {
166 if (!darwinHasSinCosStret(TT)) // Non-darwin currently unexpected
167 return {};
168
169 Type *ScalarTy = LibcallImpl == RTLIB::impl___sincosf_stret
170 ? Type::getFloatTy(Ctx)
171 : Type::getDoubleTy(Ctx);
172
173 AttrBuilder FuncAttrBuilder(Ctx);
174 for (Attribute::AttrKind Attr : CommonFnAttrs)
175 FuncAttrBuilder.addAttribute(Attr);
176
177 const bool UseSret =
178 TT.isX86_32() || ((TT.isARM() || TT.isThumb()) &&
180
181 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argumentOrErrnoMemOnly(
183
184 AttributeList Attrs;
185 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
186
187 if (UseSret) {
188 AttrBuilder AttrBuilder(Ctx);
189 StructType *StructTy = StructType::get(ScalarTy, ScalarTy);
190 AttrBuilder.addStructRetAttr(StructTy);
191 AttrBuilder.addAlignmentAttr(DL.getABITypeAlign(StructTy));
193 Type::getVoidTy(Ctx), {DL.getAllocaPtrType(Ctx), ScalarTy}, false);
194
195 return {FuncTy, Attrs.addParamAttributes(Ctx, 0, AttrBuilder)};
196 }
197
198 Type *RetTy =
199 LibcallImpl == RTLIB::impl___sincosf_stret && TT.isX86_64()
200 ? static_cast<Type *>(FixedVectorType::get(ScalarTy, 2))
201 : static_cast<Type *>(StructType::get(ScalarTy, ScalarTy));
202
203 return {FunctionType::get(RetTy, {ScalarTy}, false), Attrs};
204 }
205 case RTLIB::impl_malloc:
206 case RTLIB::impl_calloc: {
207 AttrBuilder FuncAttrBuilder(Ctx);
208 for (Attribute::AttrKind Attr : MemoryFnAttrs)
209 FuncAttrBuilder.addAttribute(Attr);
210 FuncAttrBuilder.addAttribute(Attribute::NoFree);
211
213 if (LibcallImpl == RTLIB::impl_malloc)
214 AllocKind |= AllocFnKind::Uninitialized;
215
216 // TODO: Set memory attribute
217 FuncAttrBuilder.addAllocKindAttr(AllocKind);
218 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
219 FuncAttrBuilder.addAllocSizeAttr(0, LibcallImpl == RTLIB::impl_malloc
220 ? std::nullopt
221 : std::make_optional(1));
222
223 AttributeList Attrs;
224 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
225
226 {
227 AttrBuilder ArgAttrBuilder(Ctx);
228 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
229 ArgAttrBuilder.addAttribute(AK);
230
231 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoUndef);
232 Attrs = Attrs.addRetAttribute(Ctx, Attribute::NoAlias);
233 Attrs = Attrs.addParamAttribute(Ctx, 0, Attribute::NoUndef);
234 if (LibcallImpl == RTLIB::impl_calloc)
235 Attrs = Attrs.addParamAttribute(Ctx, 1, Attribute::NoUndef);
236 }
237
238 IntegerType *SizeT = getSizeTType(Ctx, DL);
239 PointerType *PtrTy = PointerType::get(Ctx, 0);
240 SmallVector<Type *, 2> ArgTys = {SizeT};
241 if (LibcallImpl == RTLIB::impl_calloc)
242 ArgTys.push_back(SizeT);
243
244 return {FunctionType::get(PtrTy, ArgTys, false), Attrs};
245 }
246 case RTLIB::impl_free: {
247 // TODO: Set memory attribute
248 AttrBuilder FuncAttrBuilder(Ctx);
249 for (Attribute::AttrKind Attr : MemoryFnAttrs)
250 FuncAttrBuilder.addAttribute(Attr);
251
252 FuncAttrBuilder.addAllocKindAttr(AllocFnKind::Free);
253 FuncAttrBuilder.addAttribute("alloc-family", "malloc");
254
255 AttributeList Attrs;
256 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
257
258 {
259 AttrBuilder ArgAttrBuilder(Ctx);
260 ArgAttrBuilder.addAttribute(Attribute::NoUndef);
261 ArgAttrBuilder.addAttribute(Attribute::AllocatedPointer);
262 ArgAttrBuilder.addCapturesAttr(CaptureInfo::none());
263 Attrs = Attrs.addParamAttributes(Ctx, 0, ArgAttrBuilder);
264 }
265
266 return {FunctionType::get(Type::getVoidTy(Ctx), {PointerType::get(Ctx, 0)},
267 false),
268 Attrs};
269 }
270 case RTLIB::impl_sqrtf:
271 case RTLIB::impl_sqrt: {
272 AttrBuilder FuncAttrBuilder(Ctx);
273
274 for (Attribute::AttrKind Attr : CommonFnAttrs)
275 FuncAttrBuilder.addAttribute(Attr);
276 FuncAttrBuilder.addMemoryAttr(MemoryEffects::errnoMemOnly(ModRefInfo::Mod));
277
278 AttributeList Attrs;
279 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
280
281 Type *ScalarTy = LibcallImpl == RTLIB::impl_sqrtf ? Type::getFloatTy(Ctx)
282 : Type::getDoubleTy(Ctx);
283 FunctionType *FuncTy = FunctionType::get(ScalarTy, {ScalarTy}, false);
284
285 Attrs = Attrs.addRetAttribute(
287 fcNegNormal));
288 return {FuncTy, Attrs};
289 }
290 case RTLIB::impl__ZGVnN2vv_fmod:
291 case RTLIB::impl__ZGVnN4vv_fmodf:
292 case RTLIB::impl__ZGVsMxvv_fmod:
293 case RTLIB::impl__ZGVsMxvv_fmodf:
294 case RTLIB::impl_armpl_vfmodq_f32:
295 case RTLIB::impl_armpl_vfmodq_f64:
296 case RTLIB::impl_armpl_svfmod_f32_x:
297 case RTLIB::impl_armpl_svfmod_f64_x:
298 case RTLIB::impl_armpl_vpowq_f32:
299 case RTLIB::impl_armpl_vpowq_f64:
300 case RTLIB::impl_armpl_svpow_f32_x:
301 case RTLIB::impl_armpl_svpow_f64_x:
302 case RTLIB::impl_armpl_vcbrtq_f32:
303 case RTLIB::impl_armpl_vcbrtq_f64:
304 case RTLIB::impl_armpl_svcbrt_f32_x:
305 case RTLIB::impl_armpl_svcbrt_f64_x: {
306 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vv_fmodf ||
307 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
308 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
309 LibcallImpl == RTLIB::impl_armpl_vfmodq_f32 ||
310 LibcallImpl == RTLIB::impl_armpl_vpowq_f32 ||
311 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
312 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
313 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x;
314
315 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsMxvv_fmod ||
316 LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
317 LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
318 LibcallImpl == RTLIB::impl_armpl_svfmod_f64_x ||
319 LibcallImpl == RTLIB::impl_armpl_svpow_f32_x ||
320 LibcallImpl == RTLIB::impl_armpl_svpow_f64_x ||
321 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
322 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
323
324 bool HasOneArg = LibcallImpl == RTLIB::impl_armpl_vcbrtq_f32 ||
325 LibcallImpl == RTLIB::impl_armpl_vcbrtq_f64 ||
326 LibcallImpl == RTLIB::impl_armpl_svcbrt_f32_x ||
327 LibcallImpl == RTLIB::impl_armpl_svcbrt_f64_x;
328
329 AttrBuilder FuncAttrBuilder(Ctx);
330
331 for (Attribute::AttrKind Attr : CommonFnAttrs)
332 FuncAttrBuilder.addAttribute(Attr);
333
334 AttributeList Attrs;
335 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
336
337 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
338 unsigned EC = IsF32 ? 4 : 2;
339 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
340
341 SmallVector<Type *, 3> ArgTys(HasOneArg ? 1 : 2, VecTy);
342 if (hasVectorMaskArgument(LibcallImpl))
343 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
344
345 FunctionType *FuncTy = FunctionType::get(VecTy, ArgTys, false);
346 return {FuncTy, Attrs};
347 }
348 case RTLIB::impl__ZGVnN2vl8_modf:
349 case RTLIB::impl__ZGVnN4vl4_modff:
350 case RTLIB::impl__ZGVsNxvl8_modf:
351 case RTLIB::impl__ZGVsNxvl4_modff:
352 case RTLIB::impl_armpl_vmodfq_f64:
353 case RTLIB::impl_armpl_vmodfq_f32:
354 case RTLIB::impl_armpl_svmodf_f64_x:
355 case RTLIB::impl_armpl_svmodf_f32_x: {
356 AttrBuilder FuncAttrBuilder(Ctx);
357
358 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4_modff ||
359 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
360 LibcallImpl == RTLIB::impl_armpl_vmodfq_f32 ||
361 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
362
363 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8_modf ||
364 LibcallImpl == RTLIB::impl__ZGVsNxvl4_modff ||
365 LibcallImpl == RTLIB::impl_armpl_svmodf_f64_x ||
366 LibcallImpl == RTLIB::impl_armpl_svmodf_f32_x;
367
368 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
369 unsigned EC = IsF32 ? 4 : 2;
370 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
371
372 for (Attribute::AttrKind Attr : CommonFnAttrs)
373 FuncAttrBuilder.addAttribute(Attr);
374 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
375
376 AttributeList Attrs;
377 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
378
379 {
380 AttrBuilder ArgAttrBuilder(Ctx);
381 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
382 ArgAttrBuilder.addAttribute(AK);
383 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
384 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
385 }
386
387 PointerType *PtrTy = PointerType::get(Ctx, 0);
388 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy};
389 if (hasVectorMaskArgument(LibcallImpl))
390 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
391
392 return {FunctionType::get(VecTy, ArgTys, false), Attrs};
393 }
394 case RTLIB::impl__ZGVnN2vl8l8_sincos:
395 case RTLIB::impl__ZGVnN4vl4l4_sincosf:
396 case RTLIB::impl__ZGVsNxvl8l8_sincos:
397 case RTLIB::impl__ZGVsNxvl4l4_sincosf:
398 case RTLIB::impl_armpl_vsincosq_f64:
399 case RTLIB::impl_armpl_vsincosq_f32:
400 case RTLIB::impl_armpl_svsincos_f64_x:
401 case RTLIB::impl_armpl_svsincos_f32_x:
402 case RTLIB::impl__ZGVnN4vl4l4_sincospif:
403 case RTLIB::impl__ZGVnN2vl8l8_sincospi:
404 case RTLIB::impl__ZGVsNxvl4l4_sincospif:
405 case RTLIB::impl__ZGVsNxvl8l8_sincospi:
406 case RTLIB::impl_armpl_vsincospiq_f32:
407 case RTLIB::impl_armpl_vsincospiq_f64:
408 case RTLIB::impl_armpl_svsincospi_f32_x:
409 case RTLIB::impl_armpl_svsincospi_f64_x: {
410 AttrBuilder FuncAttrBuilder(Ctx);
411
412 bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincospif ||
413 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
414 LibcallImpl == RTLIB::impl_armpl_vsincospiq_f32 ||
415 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
416 LibcallImpl == RTLIB::impl__ZGVnN4vl4l4_sincosf ||
417 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
418 LibcallImpl == RTLIB::impl_armpl_vsincosq_f32 ||
419 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x;
420
421 Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
422 unsigned EC = IsF32 ? 4 : 2;
423
424 bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincos ||
425 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincosf ||
426 LibcallImpl == RTLIB::impl_armpl_svsincos_f32_x ||
427 LibcallImpl == RTLIB::impl_armpl_svsincos_f64_x ||
428 LibcallImpl == RTLIB::impl__ZGVsNxvl4l4_sincospif ||
429 LibcallImpl == RTLIB::impl__ZGVsNxvl8l8_sincospi ||
430 LibcallImpl == RTLIB::impl_armpl_svsincospi_f32_x ||
431 LibcallImpl == RTLIB::impl_armpl_svsincospi_f64_x;
432 VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
433
434 for (Attribute::AttrKind Attr : CommonFnAttrs)
435 FuncAttrBuilder.addAttribute(Attr);
436 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(ModRefInfo::Mod));
437
438 AttributeList Attrs;
439 Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
440
441 {
442 AttrBuilder ArgAttrBuilder(Ctx);
443 for (Attribute::AttrKind AK : CommonPtrArgAttrs)
444 ArgAttrBuilder.addAttribute(AK);
445 ArgAttrBuilder.addAlignmentAttr(DL.getABITypeAlign(VecTy));
446 Attrs = Attrs.addParamAttributes(Ctx, 1, ArgAttrBuilder);
447 Attrs = Attrs.addParamAttributes(Ctx, 2, ArgAttrBuilder);
448 }
449
450 PointerType *PtrTy = PointerType::get(Ctx, 0);
451 SmallVector<Type *, 4> ArgTys = {VecTy, PtrTy, PtrTy};
452 if (hasVectorMaskArgument(LibcallImpl))
453 ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
454
455 return {FunctionType::get(Type::getVoidTy(Ctx), ArgTys, false), Attrs};
456 }
457 default:
458 return {};
459 }
460
461 return {};
462}
463
464bool RuntimeLibcallsInfo::hasVectorMaskArgument(RTLIB::LibcallImpl Impl) {
465 /// FIXME: This should be generated by tablegen and support the argument at an
466 /// arbitrary position
467 switch (Impl) {
468 case RTLIB::impl_armpl_svfmod_f32_x:
469 case RTLIB::impl_armpl_svfmod_f64_x:
470 case RTLIB::impl_armpl_svmodf_f64_x:
471 case RTLIB::impl_armpl_svmodf_f32_x:
472 case RTLIB::impl_armpl_svsincos_f32_x:
473 case RTLIB::impl_armpl_svsincos_f64_x:
474 case RTLIB::impl_armpl_svsincospi_f32_x:
475 case RTLIB::impl_armpl_svsincospi_f64_x:
476 case RTLIB::impl__ZGVsMxvv_fmod:
477 case RTLIB::impl__ZGVsMxvv_fmodf:
478 case RTLIB::impl_armpl_svpow_f32_x:
479 case RTLIB::impl_armpl_svpow_f64_x:
480 case RTLIB::impl_armpl_svcbrt_f32_x:
481 case RTLIB::impl_armpl_svcbrt_f64_x:
482 return true;
483 default:
484 return false;
485 }
486}
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
ExceptionHandling
Definition CodeGen.h:54
@ None
No exception support.
Definition CodeGen.h:55
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 >
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.