LLVM 22.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/Support/Debug.h"
12#include "llvm/Support/xxhash.h"
14
15#define DEBUG_TYPE "runtime-libcalls-info"
16
17using namespace llvm;
18using namespace RTLIB;
19
20#define GET_INIT_RUNTIME_LIBCALL_NAMES
21#define GET_SET_TARGET_RUNTIME_LIBCALL_SETS
22#define DEFINE_GET_LOOKUP_LIBCALL_IMPL_NAME
23#include "llvm/IR/RuntimeLibcalls.inc"
24
25/// Set default libcall names. If a target wants to opt-out of a libcall it
26/// should be placed here.
27void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
28 ExceptionHandling ExceptionModel,
30 EABI EABIVersion, StringRef ABIName) {
31 setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
32 ABIName);
33}
34
36iota_range<RTLIB::LibcallImpl>
37RuntimeLibcallsInfo::libcallImplNameHit(uint16_t NameOffsetEntry,
38 uint16_t StrOffset) {
39 int NumAliases = 1;
40 for (uint16_t Entry : ArrayRef(RuntimeLibcallNameOffsetTable)
41 .drop_front(NameOffsetEntry + 1)) {
42 if (Entry != StrOffset)
43 break;
44 ++NumAliases;
45 }
46
47 RTLIB::LibcallImpl ImplStart = static_cast<RTLIB::LibcallImpl>(
48 &RuntimeLibcallNameOffsetTable[NameOffsetEntry] -
49 &RuntimeLibcallNameOffsetTable[0]);
50 return enum_seq(ImplStart,
51 static_cast<RTLIB::LibcallImpl>(ImplStart + NumAliases));
52}
53
54bool RuntimeLibcallsInfo::isAAPCS_ABI(const Triple &TT, StringRef ABIName) {
55 const ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
56 return TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16;
57}
58
59bool RuntimeLibcallsInfo::darwinHasExp10(const Triple &TT) {
60 switch (TT.getOS()) {
61 case Triple::MacOSX:
62 return !TT.isMacOSXVersionLT(10, 9);
63 case Triple::IOS:
64 return !TT.isOSVersionLT(7, 0);
66 case Triple::TvOS:
67 case Triple::WatchOS:
68 case Triple::XROS:
70 return true;
71 default:
72 return false;
73 }
74}
#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
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
This is an optimization pass for GlobalISel generic memory operations.
auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
Definition Sequence.h:337
ExceptionHandling
Definition CodeGen.h:53
ArrayRef(const T &OneElt) -> ArrayRef< T >
EABI
Definition CodeGen.h:73