File indexing completed on 2026-05-10 08:44:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_IR_RUNTIME_LIBCALLS_H
0015 #define LLVM_IR_RUNTIME_LIBCALLS_H
0016
0017 #include "llvm/ADT/ArrayRef.h"
0018 #include "llvm/IR/CallingConv.h"
0019 #include "llvm/Support/AtomicOrdering.h"
0020 #include "llvm/TargetParser/Triple.h"
0021
0022 namespace llvm {
0023 namespace RTLIB {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 enum Libcall {
0034 #define HANDLE_LIBCALL(code, name) code,
0035 #include "llvm/IR/RuntimeLibcalls.def"
0036 #undef HANDLE_LIBCALL
0037 };
0038
0039
0040 struct RuntimeLibcallsInfo {
0041 explicit RuntimeLibcallsInfo(const Triple &TT) {
0042 initLibcalls(TT);
0043 }
0044
0045
0046 void setLibcallName(RTLIB::Libcall Call, const char *Name) {
0047 LibcallRoutineNames[Call] = Name;
0048 }
0049
0050 void setLibcallName(ArrayRef<RTLIB::Libcall> Calls, const char *Name) {
0051 for (auto Call : Calls)
0052 setLibcallName(Call, Name);
0053 }
0054
0055
0056 const char *getLibcallName(RTLIB::Libcall Call) const {
0057 return LibcallRoutineNames[Call];
0058 }
0059
0060
0061 void setLibcallCallingConv(RTLIB::Libcall Call, CallingConv::ID CC) {
0062 LibcallCallingConvs[Call] = CC;
0063 }
0064
0065
0066 CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
0067 return LibcallCallingConvs[Call];
0068 }
0069
0070 iterator_range<const char **> getLibcallNames() {
0071 return llvm::make_range(LibcallRoutineNames,
0072 LibcallRoutineNames + RTLIB::UNKNOWN_LIBCALL);
0073 }
0074
0075 private:
0076
0077 const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1];
0078
0079
0080 CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL];
0081
0082 static bool darwinHasSinCos(const Triple &TT) {
0083 assert(TT.isOSDarwin() && "should be called with darwin triple");
0084
0085 if (TT.getArch() == Triple::x86)
0086 return false;
0087
0088 if (TT.isMacOSX())
0089 return !TT.isMacOSXVersionLT(10, 9) && TT.isArch64Bit();
0090
0091 if (TT.isiOS())
0092 return !TT.isOSVersionLT(7, 0);
0093
0094 return true;
0095 }
0096
0097
0098
0099 void initLibcalls(const Triple &TT);
0100 };
0101
0102 }
0103 }
0104
0105 #endif