23
23
#include " llvm/Support/Compiler.h"
24
24
#include " llvm/TargetParser/Triple.h"
25
25
26
+ // / TableGen will produce 2 enums, RTLIB::Libcall and
27
+ // / RTLIB::LibcallImpl. RTLIB::Libcall describes abstract functionality the
28
+ // / compiler may choose to access, RTLIB::LibcallImpl describes a particular ABI
29
+ // / implementation, which includes a name and type signature.
26
30
#define GET_RUNTIME_LIBCALL_ENUM
27
31
#include " llvm/IR/RuntimeLibcalls.inc"
28
32
#undef GET_RUNTIME_LIBCALL_ENUM
@@ -48,38 +52,46 @@ struct RuntimeLibcallsInfo {
48
52
FloatABI::ABIType FloatABI = FloatABI::Default,
49
53
EABI EABIVersion = EABI::Default, StringRef ABIName = " " ) {
50
54
initSoftFloatCmpLibcallPredicates ();
51
- initDefaultLibCallNames ();
55
+ initDefaultLibCallImpls ();
52
56
initLibcalls (TT, ExceptionModel, FloatABI, EABIVersion, ABIName);
53
57
}
54
58
55
59
// / Rename the default libcall routine name for the specified libcall.
56
- void setLibcallName (RTLIB::Libcall Call, const char *Name) {
57
- LibcallRoutineNames[Call] = Name;
58
- }
59
-
60
- void setLibcallName (ArrayRef<RTLIB::Libcall> Calls, const char *Name) {
61
- for (auto Call : Calls)
62
- setLibcallName (Call, Name);
60
+ void setLibcallImpl (RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
61
+ LibcallImpls[Call] = Impl;
63
62
}
64
63
65
64
// / Get the libcall routine name for the specified libcall.
65
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
66
66
const char *getLibcallName (RTLIB::Libcall Call) const {
67
- return LibcallRoutineNames[Call];
67
+ return LibCallImplNames[LibcallImpls[Call]];
68
+ }
69
+
70
+ // / Get the libcall routine name for the specified libcall implementation.
71
+ const char *getLibcallImplName (RTLIB::LibcallImpl CallImpl) const {
72
+ return LibCallImplNames[CallImpl];
73
+ }
74
+
75
+ // / Return the lowering's selection of implementation call for \p Call
76
+ RTLIB::LibcallImpl getLibcallImpl (RTLIB::Libcall Call) const {
77
+ return LibcallImpls[Call];
68
78
}
69
79
70
80
// / Set the CallingConv that should be used for the specified libcall.
81
+ // FIXME: This should be a function of RTLIB::LibcallImpl
71
82
void setLibcallCallingConv (RTLIB::Libcall Call, CallingConv::ID CC) {
72
83
LibcallCallingConvs[Call] = CC;
73
84
}
74
85
75
86
// / Get the CallingConv that should be used for the specified libcall.
87
+ // FIXME: This should be a function of RTLIB::LibcallImpl
76
88
CallingConv::ID getLibcallCallingConv (RTLIB::Libcall Call) const {
77
89
return LibcallCallingConvs[Call];
78
90
}
79
91
80
- ArrayRef<const char *> getLibcallNames () const {
81
- // Trim UNKNOWN_LIBCALL from the end
82
- return ArrayRef (LibcallRoutineNames). drop_back ();
92
+ ArrayRef<RTLIB::LibcallImpl> getLibcallImpls () const {
93
+ // Trim Unsupported from the start
94
+ return ArrayRef (LibcallImpls). drop_front ();
83
95
}
84
96
85
97
// / Get the comparison predicate that's to be used to test the result of the
@@ -91,6 +103,7 @@ struct RuntimeLibcallsInfo {
91
103
}
92
104
93
105
// FIXME: This should be removed. This should be private constant.
106
+ // FIXME: This should be a function of RTLIB::LibcallImpl
94
107
void setSoftFloatCmpLibcallPredicate (RTLIB::Libcall Call,
95
108
CmpInst::Predicate Pred) {
96
109
SoftFloatCompareLibcallPredicates[Call] = Pred;
@@ -107,11 +120,12 @@ struct RuntimeLibcallsInfo {
107
120
}
108
121
109
122
private:
110
- static const char * const
111
- DefaultLibcallRoutineNames [RTLIB::UNKNOWN_LIBCALL + 1 ];
123
+ static const RTLIB::LibcallImpl
124
+ DefaultLibcallImpls [RTLIB::UNKNOWN_LIBCALL + 1 ];
112
125
113
- // / Stores the name each libcall.
114
- const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1 ] = {nullptr };
126
+ // / Stores the implementation choice for each each libcall.
127
+ RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1 ] = {
128
+ RTLIB::Unsupported};
115
129
116
130
static_assert (static_cast <int >(CallingConv::C) == 0 ,
117
131
" default calling conv should be encoded as 0" );
@@ -127,6 +141,13 @@ struct RuntimeLibcallsInfo {
127
141
// opcode.
128
142
CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL];
129
143
144
+ // / Names of concrete implementations of runtime calls. e.g. __ashlsi3 for
145
+ // / SHL_I32
146
+ static const char *const LibCallImplNames[RTLIB::NumLibcallImpls];
147
+
148
+ // / Map from a concrete LibcallImpl implementation to its RTLIB::Libcall kind.
149
+ static const RTLIB::Libcall ImplToLibcall[RTLIB::NumLibcallImpls];
150
+
130
151
static bool darwinHasSinCosStret (const Triple &TT) {
131
152
assert (TT.isOSDarwin () && " should be called with darwin triple" );
132
153
// Don't bother with 32 bit x86.
@@ -148,7 +169,7 @@ struct RuntimeLibcallsInfo {
148
169
(TT.isAndroid () && !TT.isAndroidVersionLT (9 ));
149
170
}
150
171
151
- void initDefaultLibCallNames ();
172
+ void initDefaultLibCallImpls ();
152
173
153
174
// / Generated by tablegen.
154
175
void setPPCLibCallNameOverrides ();
0 commit comments