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
11#include "llvm/IR/Intrinsics.h"
12#include "llvm/IR/Module.h"
14#include "llvm/IR/Type.h"
16
17#define DEBUG_TYPE "runtime-libcalls-info"
18
19using namespace llvm;
20using namespace RTLIB;
21
22#define GET_RUNTIME_LIBCALLS_INFO
23#define GET_INIT_RUNTIME_LIBCALL_NAMES
24#define GET_INIT_RUNTIME_LIBCALL_SIGNATURES
25#define GET_RUNTIME_LIBCALL_ATTRIBUTES
26#define GET_RUNTIME_LIBCALL_MASKED_VECTOR_LIBCALL_MAPPING
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
32static RuntimeLibrary getVectorRuntimeLibrary(VectorLibrary VecLib) {
33 switch (VecLib) {
35 break;
37 return RuntimeLibrary::accelerate;
39 return RuntimeLibrary::darwin_libsystem_m;
41 return RuntimeLibrary::libmvec;
43 return RuntimeLibrary::massv;
45 return RuntimeLibrary::svml;
47 return RuntimeLibrary::sleefgnuabi;
49 return RuntimeLibrary::armpl;
51 return RuntimeLibrary::amdlibm;
52 }
53
54 llvm_unreachable("no RuntimeLibrary for VectorLibrary");
55}
56
58 const Triple &TT, ExceptionHandling ExceptionModel, unsigned WCharSize,
59 FloatABI::ABIType FloatABI, std::optional<LongDoubleFormat> LDblFormat,
60 StringRef ABIName, VectorLibrary VecLib)
61 : WCharSize(WCharSize ? WCharSize : TT.getDefaultWCharSize()),
62 LongDoubleFmt(LDblFormat.value_or(TT.getDefaultLongDoubleFormat())),
63 ABIName(ABIName) {
64 // Only an unspecified model resolves to the triple default; None is left as
65 // an explicit disable.
66 if (ExceptionModel == ExceptionHandling::Default)
67 ExceptionModel = TT.getDefaultExceptionHandling();
68
69 initLibcalls(TT, ExceptionModel, FloatABI, ABIName, LongDoubleFmt);
70
71 if (VecLib != VectorLibrary::NoLibrary) {
72 setAvailableLibraryLibcalls(getVectorRuntimeLibrary(VecLib), TT,
73 ExceptionModel, FloatABI, ABIName,
74 LongDoubleFmt);
75 }
76}
77
78// TODO: Consider the remaining module flags.
80 VectorLibrary VecLib)
81 : RuntimeLibcallsInfo(M.getTargetTriple(), M.getExceptionModel(),
82 M.getWCharSize(), M.getFloatABI(),
83 M.getLongDoubleFormat(), ABIName, VecLib) {}
84
85RTLIB::Libcall RuntimeLibcallsInfo::selectLongDoubleLibcall(
86 RTLIB::Libcall F80, RTLIB::Libcall F128, RTLIB::Libcall PPCF128) const {
87 switch (LongDoubleFmt) {
89 return F80;
91 return F128;
93 return PPCF128;
96 // These long double formats aren't properly handled, but we also don't emit
97 // calls for them. TODO: We could fix the avr_sin/avr_cos hack if we handled
98 // the float case.
99 return RTLIB::UNKNOWN_LIBCALL;
100 }
101
102 llvm_unreachable("unhandled long double format");
103}
104
105bool RuntimeLibcallsInfo::isLibraryAvailable(RuntimeLibrary Library) const {
106 // TODO: Drive this from module-level state (e.g. the linked runtime). For now
107 // every named library is reported as available.
108 return true;
109}
110
111void RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(
112 const Triple &TT, ExceptionHandling ExceptionModel,
113 FloatABI::ABIType FloatABI, StringRef ABIName,
115 CallingConv::ID DefaultCC = getDefaultLibcallCallingConv(
116 TT, ExceptionModel, FloatABI, ABIName, LongDoubleFormat);
117 if (DefaultCC != CallingConv::C)
118 llvm::fill(LibcallImplCallingConvs, DefaultCC);
119
120 for (RTLIB::RuntimeLibrary Library : getDefaultRuntimeLibraries(TT)) {
121 if (isLibraryAvailable(Library))
122 setAvailableLibraryLibcalls(Library, TT, ExceptionModel, FloatABI,
123 ABIName, LongDoubleFormat);
124 }
125}
126
127/// Set default libcall names. If a target wants to opt-out of a libcall it
128/// should be placed here.
129void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
130 ExceptionHandling ExceptionModel,
131 FloatABI::ABIType FloatABI,
132 StringRef ABIName,
134 setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, ABIName,
136}
137
139iota_range<RTLIB::LibcallImpl>
140RuntimeLibcallsInfo::libcallImplNameHit(uint16_t NameOffsetEntry,
141 uint16_t StrOffset) {
142 int NumAliases = 1;
143 for (uint16_t Entry : ArrayRef(RuntimeLibcallNameOffsetTable)
144 .drop_front(NameOffsetEntry + 1)) {
145 if (Entry != StrOffset)
146 break;
147 ++NumAliases;
148 }
149
150 RTLIB::LibcallImpl ImplStart = static_cast<RTLIB::LibcallImpl>(
151 &RuntimeLibcallNameOffsetTable[NameOffsetEntry] -
152 &RuntimeLibcallNameOffsetTable[0]);
153 return enum_seq(ImplStart,
154 static_cast<RTLIB::LibcallImpl>(ImplStart + NumAliases));
155}
156
157bool RuntimeLibcallsInfo::isAAPCS_ABI(const Triple &TT, StringRef ABIName) {
158 const ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
159 return TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16;
160}
161
162// PowerPC64, Sparc64, SystemZ, VE need signext/zeroext on i32 parameters and
163// returns corresponding to C-level ints and unsigned ints.
164static bool shouldExtI32(const Triple &T) {
165 return T.isPPC64() || T.getArch() == Triple::sparcv9 ||
166 T.getArch() == Triple::systemz || T.getArch() == Triple::ve;
167}
168
169// LoongArch, Mips, and riscv64, on the other hand, need signext on i32
170// parameters corresponding to both signed and unsigned ints.
171static bool shouldSignExtI32Param(const Triple &T) {
172 return T.isLoongArch() || T.isMIPS() || T.isRISCV64();
173}
174
175// LoongArch and riscv64 need signext on i32 returns corresponding to both
176// signed and unsigned ints.
177static bool shouldSignExtI32Return(const Triple &T) {
178 return T.isLoongArch() || T.isRISCV64();
179}
180
182 bool &ShouldExtI32Return,
183 bool &ShouldSignExtI32Param,
184 bool &ShouldSignExtI32Return,
185 const Triple &T) {
186 ShouldExtI32Param = ShouldExtI32Return = shouldExtI32(T);
187 ShouldSignExtI32Param = shouldSignExtI32Param(T);
188 ShouldSignExtI32Return = shouldSignExtI32Return(T);
189}
190
191static bool shouldZExtBool(const Triple &T) {
192 return !T.isAArch64() && !T.isOSDarwin();
193}
194
196 bool &ShouldZExtBoolParam, bool &ShouldZExtBoolReturn, const Triple &T) {
197 ShouldZExtBoolParam = ShouldZExtBoolReturn = shouldZExtBool(T);
198}
199
200/// TODO: There is really no guarantee that sizeof(size_t) is equal to the index
201/// size of the default address space. This matches TargetLibraryInfo and should
202/// be kept in sync.
204 return DL.getIndexType(Ctx, /*AddressSpace=*/0);
205}
206
207static unsigned getIntSize(const Triple &TT) {
209}
210
211static unsigned getLongSize(const Triple &TT, const DataLayout &DL) {
212 if (TT.isOSWindowsOrUEFI() && !TT.isWindowsCygwinEnvironment())
213 return 32;
214 return std::max(32u, DL.getPointerSizeInBits(/*AS=*/0));
215}
216
217// TODO: NoCallback probably unsafe in general
218static constexpr Attribute::AttrKind CommonFnAttrs[] = {
219 Attribute::NoCallback, Attribute::NoFree, Attribute::NoSync,
220 Attribute::NoUnwind, Attribute::WillReturn};
221
223 switch (Format) {
225 return Type::getFloatTy(Ctx);
227 return Type::getDoubleTy(Ctx);
229 return Type::getX86_FP80Ty(Ctx);
231 return Type::getFP128Ty(Ctx);
233 return Type::getPPC_FP128Ty(Ctx);
234 }
235
236 llvm_unreachable("unhandled long double format");
237}
238
239static Type *getInt128Type(LLVMContext &Ctx, const Triple &TT) {
240 if (TT.isOSWindowsOrUEFI() && TT.isX86_64())
242 return Type::getInt128Ty(Ctx);
243}
244
245static Type *convertToIRType(FuncArgTypeID ID, LLVMContext &Ctx,
246 const Triple &TT, const DataLayout &DL,
247 unsigned WCharSize, LongDoubleFormat LdblFormat) {
248 // FIXME: Use the llvm/ABI library to get accurate IR types and attributes.
249 switch (ID) {
250 case Void:
251 return Type::getVoidTy(Ctx);
252 case Bool:
253 return IntegerType::get(Ctx, 1);
254 case Int8:
255 case UInt8:
256 return IntegerType::get(Ctx, 8);
257 case Int16:
258 case UInt16:
259 return IntegerType::get(Ctx, 16);
260 case Int32:
261 case UInt32:
262 return IntegerType::get(Ctx, 32);
263 case Int:
264 case UInt:
265 case IntPlus:
266 case UIntPlus:
267 case IntX:
268 case UIntX:
269 return IntegerType::get(Ctx, getIntSize(TT));
270 case Long:
271 case ULong:
272 return IntegerType::get(Ctx, getLongSize(TT, DL));
273 case Int64:
274 case UInt64:
275 case LLong:
276 case ULLong:
277 return IntegerType::get(Ctx, 64);
278 case Int128:
279 case UInt128:
280 return getInt128Type(Ctx, TT);
281 case SizeT:
282 case SSizeT:
283 return getSizeTType(Ctx, DL);
284 case CmpResult:
285 if (TT.isAArch64() || TT.isAMDGPU() || TT.isWasm())
286 return Type::getInt32Ty(Ctx);
287 if (TT.isAVR())
288 return Type::getInt8Ty(Ctx);
289 return IntegerType::get(Ctx, TT.getArchPointerBitWidth());
290 case Half:
291 return Type::getHalfTy(Ctx);
292 case BFloat:
293 return Type::getBFloatTy(Ctx);
294 case Flt:
295 case Floating:
296 return Type::getFloatTy(Ctx);
297 case Dbl:
298 return Type::getDoubleTy(Ctx);
299 case LDbl:
300 return getLongDoubleType(Ctx, LdblFormat);
301 case X86FP80:
302 return Type::getX86_FP80Ty(Ctx);
303 case FP128:
304 return Type::getFP128Ty(Ctx);
305 case PPCFP128:
306 return Type::getPPC_FP128Ty(Ctx);
307 case Ptr:
308 return PointerType::get(Ctx, 0);
309 case AllocaPtr:
310 return DL.getAllocaPtrType(Ctx);
311 case V2F32:
313 case V4F32:
315 case V8F32:
317 case V16F32:
318 return FixedVectorType::get(Type::getFloatTy(Ctx), 16);
319 case NXV4F32:
321 case V2F64:
323 case V4F64:
325 case V8F64:
327 case NXV2F64:
329 case NXV2I1:
331 case NXV4I1:
333 case V2I32:
335 case V4I32:
337 case V8I32:
339 case V16I32:
340 return FixedVectorType::get(Type::getInt32Ty(Ctx), 16);
341 case NXV2I32:
343 case NXV4I32:
345 default:
346 break;
347 }
348
349 ArrayRef<FuncArgTypeID> EltIDs = getStructElementTypes(ID);
350 if (EltIDs.empty())
351 return nullptr;
352
354 for (FuncArgTypeID EltID : EltIDs)
355 EltTys.push_back(
356 convertToIRType(EltID, Ctx, TT, DL, WCharSize, LdblFormat));
357 return StructType::get(Ctx, EltTys);
358}
359
360static std::optional<bool> isSignedIntArgType(FuncArgTypeID ID) {
361 switch (ID) {
362 case Int8:
363 case Int16:
364 case Int32:
365 case Int:
366 case IntPlus:
367 case Long:
368 case Int64:
369 case LLong:
370 case Int128:
371 case SSizeT:
372 return true;
373 case UInt8:
374 case UInt16:
375 case UInt32:
376 case UInt:
377 case UIntPlus:
378 case ULong:
379 case UIntX:
380 case UInt64:
381 case ULLong:
382 case UInt128:
383 case SizeT:
384 return false;
385 default:
386 return std::nullopt;
387 }
388}
389
390static Attribute::AttrKind getIntExtAttr(FuncArgTypeID ID, Type *Ty,
391 const Triple &TT, bool IsReturn) {
392 if (ID == Bool)
393 return shouldZExtBool(TT) ? Attribute::ZExt : Attribute::None;
394
395 std::optional<bool> Signed = isSignedIntArgType(ID);
396 if (!Signed || !Ty->isIntegerTy())
397 return Attribute::None;
398
399 // All targets currently extend types narrower than int according to their
400 // signedness, but this could become target dependent if a target needs it.
401 unsigned Bits = Ty->getIntegerBitWidth();
402 unsigned IntBits = getIntSize(TT);
403
404 if (Bits < IntBits)
405 return *Signed ? Attribute::SExt : Attribute::ZExt;
406 if (Bits != 32 || IntBits != 32)
407 return Attribute::None;
408 if (shouldExtI32(TT))
409 return *Signed ? Attribute::SExt : Attribute::ZExt;
410 if (IsReturn ? shouldSignExtI32Return(TT) : shouldSignExtI32Param(TT))
411 return Attribute::SExt;
412 return Attribute::None;
413}
414
415static FuncArgTypeID getCPairElementType(FuncArgTypeID ID) {
416 switch (ID) {
417 case CFltPair:
418 return Flt;
419 case CDblPair:
420 return Dbl;
421 default:
422 return NoFuncArgType;
423 }
424}
425
426std::pair<Type *, Type *>
427RuntimeLibcallsInfo::lowerCPairReturn(const Triple &TT, Type *EltTy) const {
428 Type *PairTy = StructType::get(EltTy, EltTy);
429 // These return small structs in memory.
430 if (TT.isX86_32() ||
431 ((TT.isARM() || TT.isThumb()) && !isAAPCS_ABI(TT, ABIName)))
432 return {Type::getVoidTy(EltTy->getContext()), PairTy};
433 // x86-64 SysV returns a pair of floats packed in one SSE register.
434 if (TT.isX86_64() && !TT.isOSWindows() && EltTy->isFloatTy())
435 return {FixedVectorType::get(EltTy, 2), nullptr};
436 return {PairTy, nullptr};
437}
438
439std::pair<FunctionType *, AttributeList>
441 LLVMContext &Ctx, const Triple &TT, const DataLayout &DL,
442 RTLIB::LibcallImpl LibcallImpl) const {
443 const FuncArgTypeID *ProtoTypes =
444 &SignatureTable[SignatureOffset[LibcallImpl]];
445
446 if (ProtoTypes[0] == NoFuncArgType || ProtoTypes[0] == Variable ||
447 ProtoTypes[0] == ThreadLocalVariable)
448 return {};
449
450 FuncArgTypeID LastID = ProtoTypes[0];
453 Type *RetTy;
454 AttributeSet RetAttrs;
455 if (FuncArgTypeID EltID = getCPairElementType(LastID);
456 EltID != NoFuncArgType) {
457 Type *EltTy = convertToIRType(EltID, Ctx, TT, DL, WCharSize, LongDoubleFmt);
458 Type *SRetTy;
459 std::tie(RetTy, SRetTy) = lowerCPairReturn(TT, EltTy);
460 if (SRetTy) {
461 AttrBuilder SRetAttrs(Ctx);
462 SRetAttrs.addStructRetAttr(SRetTy);
463 SRetAttrs.addAlignmentAttr(DL.getABITypeAlign(SRetTy));
464 ArgTys.push_back(DL.getAllocaPtrType(Ctx));
465 ArgAttrs.push_back(AttributeSet::get(Ctx, SRetAttrs));
466 }
467 } else {
468 RetTy = convertToIRType(LastID, Ctx, TT, DL, WCharSize, LongDoubleFmt);
469 if (Attribute::AttrKind AK =
470 getIntExtAttr(LastID, RetTy, TT, /*IsReturn=*/true))
471 RetAttrs = AttributeSet::get(Ctx, Attribute::get(Ctx, AK));
472 if (isInRegStruct(LastID))
473 RetAttrs = RetAttrs.addAttribute(Ctx, Attribute::InReg);
474 }
475 RetAttrs = RetAttrs.addAttributes(
476 Ctx, getLibcallImplRetAttributes(Ctx, LibcallImpl));
477
478 unsigned FirstArgNo = ArgTys.size();
479 bool IsVarArg = false;
480 unsigned Idx = 1;
481 for (FuncArgTypeID TyID = ProtoTypes[Idx]; TyID != NoFuncArgType;
482 TyID = ProtoTypes[++Idx]) {
483 if (TyID == Ellip) {
484 // The ellipsis ends the protoype list so it must be followed by
485 // NoFuncArgType.
486 assert(ProtoTypes[Idx + 1] == NoFuncArgType);
487 IsVarArg = true;
488 break;
489 }
490
491 if (TyID == Same)
492 TyID = LastID;
493 else
494 LastID = TyID;
495
496 Type *ArgTy = convertToIRType(TyID, Ctx, TT, DL, WCharSize, LongDoubleFmt);
497 ArgTys.push_back(ArgTy);
498
499 AttributeSet ArgAttrSet;
500 if (Attribute::AttrKind AK =
501 getIntExtAttr(TyID, ArgTy, TT, /*IsReturn=*/false))
502 ArgAttrSet = AttributeSet::get(Ctx, Attribute::get(Ctx, AK));
503 ArgAttrs.push_back(ArgAttrSet);
504 }
505
506 for (const LibcallArgAttrs &Static :
507 getLibcallImplArgAttributes(LibcallImpl)) {
508 assert(FirstArgNo + Static.ArgNo < ArgAttrs.size() &&
509 "attributes for nonexistent argument");
510 AttributeSet StaticAttrs = getLibcallArgAttributeSet(Ctx, Static.AttrSetID);
511 if (Static.PointeeType != NoFuncArgType) {
512 Type *PointeeTy = convertToIRType(Static.PointeeType, Ctx, TT, DL,
513 WCharSize, LongDoubleFmt);
514 Type *AlignTy =
515 Static.AlignToElement ? PointeeTy->getScalarType() : PointeeTy;
516 SmallVector<Attribute, 2> PointeeAttrs = {
517 Attribute::getWithAlignment(Ctx, DL.getABITypeAlign(AlignTy))};
518 TypeSize Size = DL.getTypeStoreSize(PointeeTy);
519 if (!Size.isScalable()) {
520 PointeeAttrs.push_back(
521 Attribute::getWithDereferenceableBytes(Ctx, Size.getFixedValue()));
522 }
523
524 StaticAttrs = StaticAttrs.addSortedAttributes(Ctx, PointeeAttrs);
525 }
526
527 AttributeSet &ArgAttrSet = ArgAttrs[FirstArgNo + Static.ArgNo];
528 ArgAttrSet = ArgAttrSet.addAttributes(Ctx, StaticAttrs);
529 }
530
531 return {FunctionType::get(RetTy, ArgTys, IsVarArg),
532 AttributeList::get(Ctx, getLibcallImplFnAttributes(Ctx, LibcallImpl),
533 RetAttrs, ArgAttrs)};
534}
535
536Type *
538 const DataLayout &DL,
539 RTLIB::LibcallImpl LibcallImpl) const {
540 const FuncArgTypeID *ProtoTypes =
541 &SignatureTable[SignatureOffset[LibcallImpl]];
542 if (ProtoTypes[0] != Variable && ProtoTypes[0] != ThreadLocalVariable)
543 return nullptr;
544 return convertToIRType(ProtoTypes[1], Ctx, TT, DL, WCharSize, LongDoubleFmt);
545}
546
548 Module &M, RTLIB::LibcallImpl LibcallImpl) const {
549 assert(!isVariable(LibcallImpl) && "not a function declaration");
550
551 FunctionType *FuncTy;
552 AttributeList FuncAttrs;
553 std::tie(FuncTy, FuncAttrs) = getFunctionTy(
554 M.getContext(), M.getTargetTriple(), M.getDataLayout(), LibcallImpl);
555
556 // TODO: Every libcall should have a known signature.
557 if (!FuncTy) {
558 FuncTy = FunctionType::get(Type::getVoidTy(M.getContext()), {},
559 /*IsVarArg=*/true);
560 }
561
562 return M.getOrInsertFunction(
563 getLibcallImplName(LibcallImpl), FuncTy, [&](Function &F) {
564 F.setAttributes(FuncAttrs);
565 F.setCallingConv(getLibcallImplCallingConv(LibcallImpl));
566 });
567}
568
570 Module &M, RTLIB::LibcallImpl LibcallImpl) const {
571 assert(isVariable(LibcallImpl) && "not a variable declaration");
572
573 StringRef Name = getLibcallImplName(LibcallImpl);
574 if (GlobalValue *GV = M.getNamedValue(Name))
575 return GV;
576
577 Type *VarTy = getVariableType(M.getContext(), M.getTargetTriple(),
578 M.getDataLayout(), LibcallImpl);
579 return new GlobalVariable(
580 M, VarTy, /*isConstant=*/false, GlobalValue::ExternalLinkage, nullptr,
581 Name, nullptr,
584}
585
586std::pair<FunctionType *, AttributeList>
588 const DataLayout &DL,
589 RTLIB::LibcallImpl LibcallImpl) const {
590 switch (LibcallImpl) {
591 // FIXME: Should also include __sincospi[f]_stret
592 case RTLIB::impl___sincos_stret:
593 case RTLIB::impl___sincosf_stret: {
594 auto [FuncTy, Attrs] = getDefaultFunctionTy(Ctx, TT, DL, LibcallImpl);
595 bool UseSRet = FuncTy->getNumParams() != 0 &&
596 Attrs.hasParamAttr(0, Attribute::StructRet);
597 AttrBuilder FuncAttrBuilder(Ctx);
599 FuncAttrBuilder.addAttribute(Attr);
600 FuncAttrBuilder.addMemoryAttr(MemoryEffects::argMemOnly(
602 return {FuncTy, Attrs.addFnAttributes(Ctx, FuncAttrBuilder)};
603 }
604 default:
605 break;
606 }
607
608 return getDefaultFunctionTy(Ctx, TT, DL, LibcallImpl);
609}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
constexpr LLT V2F32
constexpr LLT V2F64
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:376
Utilities for dealing with flags related to floating point properties and mode controls.
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
std::pair< MCSymbol *, MachineModuleInfoImpl::StubValueTy > PairTy
#define T
static Type * getLongDoubleType(LLVMContext &Ctx, LongDoubleFormat Format)
static bool shouldZExtBool(const Triple &T)
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 bool shouldExtI32(const Triple &T)
static RuntimeLibrary getVectorRuntimeLibrary(VectorLibrary VecLib)
static Attribute::AttrKind getIntExtAttr(FuncArgTypeID ID, Type *Ty, const Triple &TT, bool IsReturn)
static Type * getInt128Type(LLVMContext &Ctx, const Triple &TT)
static constexpr Attribute::AttrKind CommonFnAttrs[]
static bool shouldSignExtI32Param(const Triple &T)
static unsigned getIntSize(const Triple &TT)
static bool shouldSignExtI32Return(const Triple &T)
static Type * convertToIRType(FuncArgTypeID ID, LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, unsigned WCharSize, LongDoubleFormat LdblFormat)
static std::optional< bool > isSignedIntArgType(FuncArgTypeID ID)
static FuncArgTypeID getCPairElementType(FuncArgTypeID ID)
static unsigned getLongSize(const Triple &TT, const DataLayout &DL)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
This class holds the attributes for a particular argument, parameter, function, or return value.
Definition Attributes.h:448
LLVM_ABI AttributeSet addAttributes(LLVMContext &C, AttributeSet AS) const
Add attributes to the attribute set.
LLVM_ABI AttributeSet addSortedAttributes(LLVMContext &C, ArrayRef< Attribute > Attrs) const
Add attributes to the attribute set, replacing attributes of the same kind.
static LLVM_ABI AttributeSet get(LLVMContext &C, const AttrBuilder &B)
LLVM_ABI AttributeSet addAttribute(LLVMContext &C, Attribute::AttrKind Kind) const
Add an argument attribute.
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
static LLVM_ABI Attribute getWithDereferenceableBytes(LLVMContext &Context, uint64_t Bytes)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
Definition Attributes.h:126
@ None
No attributes have been set.
Definition Attributes.h:128
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
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:838
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
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.
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
Class to represent integer types.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:333
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:76
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
Definition ModRef.h:143
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
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:882
static LLVM_ABI ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition Type.cpp:860
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
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:462
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 IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:295
static LLVM_ABI IntegerType * getInt128Ty(LLVMContext &C)
Definition Type.cpp:296
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:294
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition Type.h:155
static LLVM_ABI Type * getPPC_FP128Ty(LLVMContext &C)
Definition Type.cpp:277
static LLVM_ABI Type * getFP128Ty(LLVMContext &C)
Definition Type.cpp:276
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
Definition Type.cpp:267
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:292
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition Type.h:370
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition Type.h:130
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
Definition Type.cpp:291
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
Definition Type.cpp:272
static LLVM_ABI Type * getX86_FP80Ty(LLVMContext &C)
Definition Type.cpp:275
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
Definition Type.cpp:271
static LLVM_ABI Type * getBFloatTy(LLVMContext &C)
Definition Type.cpp:270
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
Definition Type.cpp:269
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1775
LongDoubleFormat
The floating-point format used for the target's "long double" type.
Definition CodeGen.h:117
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
@ Default
Not specified; resolve to the target's default model.
Definition CodeGen.h:55
VectorLibrary
List of known vector-functions libraries.
LLVM_ABI FunctionCallee getOrInsertLibcallDecl(Module &M, RTLIB::LibcallImpl LibcallImpl) const
static bool isVariable(RTLIB::LibcallImpl LibcallImpl)
static LLVM_ABI ArrayRef< RTLIB::RuntimeLibrary > getDefaultRuntimeLibraries(const Triple &TT)
Return the runtime libraries enabled by default for TT.
LLVM_ABI GlobalValue * getOrInsertImplGlobal(Module &M, RTLIB::LibcallImpl LibcallImpl) const
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
static unsigned getIntSize(const Triple &TT)
Get size of a C-level int or unsigned int, in bits.
LLVM_ABI Type * getVariableType(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const
LLVM_ABI std::pair< FunctionType *, AttributeList > getFunctionTy(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const
static LLVM_ABI void initExtensionsForTriple(bool &ShouldExtI32Param, bool &ShouldExtI32Return, bool &ShouldSignExtI32Param, bool &ShouldSignExtI32Return, const Triple &T)
Determine the extension attributes needed for i32 parameters and returns corresponding to C-level int...
static bool isThreadLocalVariable(RTLIB::LibcallImpl LibcallImpl)
static LLVM_ABI void initBoolExtensionsForTriple(bool &ShouldZExtBoolParam, bool &ShouldZExtBoolReturn, const Triple &T)
Determine whether bool parameters and returns need zeroext on T.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl)
Get the libcall routine name for the specified libcall implementation.
LLVM_ABI std::pair< FunctionType *, AttributeList > getDefaultFunctionTy(LLVMContext &Ctx, const Triple &TT, const DataLayout &DL, RTLIB::LibcallImpl LibcallImpl) const
Get the C-type function signature of the Libcall if provided, and convert it to IR FunctionType and A...