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#undef GET_INIT_RUNTIME_LIBCALL_NAMES
25#undef GET_SET_TARGET_RUNTIME_LIBCALL_SETS
26#undef DEFINE_GET_LOOKUP_LIBCALL_IMPL_NAME
27
28/// Set default libcall names. If a target wants to opt-out of a libcall it
29/// should be placed here.
30void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
31 ExceptionHandling ExceptionModel,
33 EABI EABIVersion, StringRef ABIName) {
34 setTargetRuntimeLibcallSets(TT, ExceptionModel, FloatABI, EABIVersion,
35 ABIName);
36}
37
39iota_range<RTLIB::LibcallImpl>
40RuntimeLibcallsInfo::libcallImplNameHit(uint16_t NameOffsetEntry,
41 uint16_t StrOffset) {
42 int NumAliases = 1;
43 for (uint16_t Entry : ArrayRef(RuntimeLibcallNameOffsetTable)
44 .drop_front(NameOffsetEntry + 1)) {
45 if (Entry != StrOffset)
46 break;
47 ++NumAliases;
48 }
49
50 RTLIB::LibcallImpl ImplStart = static_cast<RTLIB::LibcallImpl>(
51 &RuntimeLibcallNameOffsetTable[NameOffsetEntry] -
52 &RuntimeLibcallNameOffsetTable[0]);
53 return enum_seq(ImplStart,
54 static_cast<RTLIB::LibcallImpl>(ImplStart + NumAliases));
55}
56
57bool RuntimeLibcallsInfo::isAAPCS_ABI(const Triple &TT, StringRef ABIName) {
58 const ARM::ARMABI TargetABI = ARM::computeTargetABI(TT, ABIName);
59 return TargetABI == ARM::ARM_ABI_AAPCS || TargetABI == ARM::ARM_ABI_AAPCS16;
60}
61
62bool RuntimeLibcallsInfo::darwinHasExp10(const Triple &TT) {
63 switch (TT.getOS()) {
64 case Triple::MacOSX:
65 return !TT.isMacOSXVersionLT(10, 9);
66 case Triple::IOS:
67 return !TT.isOSVersionLT(7, 0);
69 case Triple::TvOS:
70 case Triple::WatchOS:
71 case Triple::XROS:
73 return true;
74 default:
75 return false;
76 }
77}
#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