Skip to content

Commit 4155cdc

Browse files
authored
Mips: Remove manual libcall name search and table (#168595)
This should really check if the libcall is known supported. For now mips doesn't configure its RuntimeLibcallsInfo correctly, and does not have any of the mips16 calls in it. For now there isn't a way to add them without triggering conflicting cases in tablegen, so keep parsing the raw name as it was before.
1 parent 124fa5c commit 4155cdc

File tree

1 file changed

+32
-67
lines changed

1 file changed

+32
-67
lines changed

llvm/lib/Target/Mips/Mips16ISelLowering.cpp

Lines changed: 32 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ static cl::opt<bool> DontExpandCondPseudos16(
3131
cl::Hidden);
3232

3333
namespace {
34-
struct Mips16Libcall {
35-
RTLIB::Libcall Libcall;
36-
RTLIB::LibcallImpl Impl;
37-
const char *Name; // FIXME: Remove this
38-
39-
bool operator<(const Mips16Libcall &RHS) const {
40-
return std::strcmp(Name, RHS.Name) < 0;
41-
}
42-
};
43-
4434
struct Mips16IntrinsicHelperType{
4535
const char* Name;
4636
const char* Helper;
@@ -52,56 +42,27 @@ struct Mips16IntrinsicHelperType{
5242
return std::strcmp(Name, RHS.Name) == 0;
5343
}
5444
};
55-
}
45+
} // namespace
5646

5747
// Libcalls for which no helper is generated. Sorted by name for binary search.
58-
static const Mips16Libcall HardFloatLibCalls[] = {
59-
{RTLIB::ADD_F64, RTLIB::impl___mips16_adddf3, "__mips16_adddf3"},
60-
{RTLIB::ADD_F32, RTLIB::impl___mips16_addsf3, "__mips16_addsf3"},
61-
{RTLIB::DIV_F64, RTLIB::impl___mips16_divdf3, "__mips16_divdf3"},
62-
{RTLIB::DIV_F32, RTLIB::impl___mips16_divsf3, "__mips16_divsf3"},
63-
{RTLIB::OEQ_F64, RTLIB::impl___mips16_eqdf2, "__mips16_eqdf2"},
64-
{RTLIB::OEQ_F32, RTLIB::impl___mips16_eqsf2, "__mips16_eqsf2"},
65-
{RTLIB::FPEXT_F32_F64, RTLIB::impl___mips16_extendsfdf2,
66-
"__mips16_extendsfdf2"},
67-
{RTLIB::FPTOSINT_F64_I32, RTLIB::impl___mips16_fix_truncdfsi,
68-
"__mips16_fix_truncdfsi"},
69-
{RTLIB::FPTOSINT_F32_I32, RTLIB::impl___mips16_fix_truncsfsi,
70-
"__mips16_fix_truncsfsi"},
71-
{RTLIB::SINTTOFP_I32_F64, RTLIB::impl___mips16_floatsidf,
72-
"__mips16_floatsidf"},
73-
{RTLIB::SINTTOFP_I32_F32, RTLIB::impl___mips16_floatsisf,
74-
"__mips16_floatsisf"},
75-
{RTLIB::UINTTOFP_I32_F64, RTLIB::impl___mips16_floatunsidf,
76-
"__mips16_floatunsidf"},
77-
{RTLIB::UINTTOFP_I32_F32, RTLIB::impl___mips16_floatunsisf,
78-
"__mips16_floatunsisf"},
79-
{RTLIB::OGE_F64, RTLIB::impl___mips16_gedf2, "__mips16_gedf2"},
80-
{RTLIB::OGE_F32, RTLIB::impl___mips16_gesf2, "__mips16_gesf2"},
81-
{RTLIB::OGT_F64, RTLIB::impl___mips16_gtdf2, "__mips16_gtdf2"},
82-
{RTLIB::OGT_F32, RTLIB::impl___mips16_gtsf2, "__mips16_gtsf2"},
83-
{RTLIB::OLE_F64, RTLIB::impl___mips16_ledf2, "__mips16_ledf2"},
84-
{RTLIB::OLE_F32, RTLIB::impl___mips16_lesf2, "__mips16_lesf2"},
85-
{RTLIB::OLT_F64, RTLIB::impl___mips16_ltdf2, "__mips16_ltdf2"},
86-
{RTLIB::OLT_F32, RTLIB::impl___mips16_ltsf2, "__mips16_ltsf2"},
87-
{RTLIB::MUL_F64, RTLIB::impl___mips16_muldf3, "__mips16_muldf3"},
88-
{RTLIB::MUL_F32, RTLIB::impl___mips16_mulsf3, "__mips16_mulsf3"},
89-
{RTLIB::UNE_F64, RTLIB::impl___mips16_nedf2, "__mips16_nedf2"},
90-
{RTLIB::UNE_F32, RTLIB::impl___mips16_nesf2, "__mips16_nesf2"},
91-
{RTLIB::UNKNOWN_LIBCALL, RTLIB::impl___mips16_ret_dc,
92-
"__mips16_ret_dc"}, // No associated libcall.
93-
{RTLIB::UNKNOWN_LIBCALL, RTLIB::impl___mips16_ret_df,
94-
"__mips16_ret_df"}, // No associated libcall.
95-
{RTLIB::UNKNOWN_LIBCALL, RTLIB::impl___mips16_ret_sc,
96-
"__mips16_ret_sc"}, // No associated libcall.
97-
{RTLIB::UNKNOWN_LIBCALL, RTLIB::impl___mips16_ret_sf,
98-
"__mips16_ret_sf"}, // No associated libcall.
99-
{RTLIB::SUB_F64, RTLIB::impl___mips16_subdf3, "__mips16_subdf3"},
100-
{RTLIB::SUB_F32, RTLIB::impl___mips16_subsf3, "__mips16_subsf3"},
101-
{RTLIB::FPROUND_F64_F32, RTLIB::impl___mips16_truncdfsf2,
102-
"__mips16_truncdfsf2"},
103-
{RTLIB::UO_F64, RTLIB::impl___mips16_unorddf2, "__mips16_unorddf2"},
104-
{RTLIB::UO_F32, RTLIB::impl___mips16_unordsf2, "__mips16_unordsf2"}};
48+
static const RTLIB::LibcallImpl HardFloatLibCalls[] = {
49+
RTLIB::impl___mips16_adddf3, RTLIB::impl___mips16_addsf3,
50+
RTLIB::impl___mips16_divdf3, RTLIB::impl___mips16_divsf3,
51+
RTLIB::impl___mips16_eqdf2, RTLIB::impl___mips16_eqsf2,
52+
RTLIB::impl___mips16_extendsfdf2, RTLIB::impl___mips16_fix_truncdfsi,
53+
RTLIB::impl___mips16_fix_truncsfsi, RTLIB::impl___mips16_floatsidf,
54+
RTLIB::impl___mips16_floatsisf, RTLIB::impl___mips16_floatunsidf,
55+
RTLIB::impl___mips16_floatunsisf, RTLIB::impl___mips16_gedf2,
56+
RTLIB::impl___mips16_gesf2, RTLIB::impl___mips16_gtdf2,
57+
RTLIB::impl___mips16_gtsf2, RTLIB::impl___mips16_ledf2,
58+
RTLIB::impl___mips16_lesf2, RTLIB::impl___mips16_ltdf2,
59+
RTLIB::impl___mips16_ltsf2, RTLIB::impl___mips16_muldf3,
60+
RTLIB::impl___mips16_mulsf3, RTLIB::impl___mips16_nedf2,
61+
RTLIB::impl___mips16_nesf2, RTLIB::impl___mips16_ret_dc,
62+
RTLIB::impl___mips16_ret_df, RTLIB::impl___mips16_ret_sc,
63+
RTLIB::impl___mips16_ret_sf, RTLIB::impl___mips16_subdf3,
64+
RTLIB::impl___mips16_subsf3, RTLIB::impl___mips16_truncdfsf2,
65+
RTLIB::impl___mips16_unorddf2, RTLIB::impl___mips16_unordsf2};
10566

10667
static const Mips16IntrinsicHelperType Mips16IntrinsicHelper[] = {
10768
{"__fixunsdfsi", "__mips16_call_stub_2" },
@@ -261,8 +222,9 @@ void Mips16TargetLowering::setMips16HardFloatLibCalls() {
261222
for (unsigned I = 0; I != std::size(HardFloatLibCalls); ++I) {
262223
assert((I == 0 || HardFloatLibCalls[I - 1] < HardFloatLibCalls[I]) &&
263224
"Array not sorted!");
264-
if (HardFloatLibCalls[I].Libcall != RTLIB::UNKNOWN_LIBCALL)
265-
setLibcallImpl(HardFloatLibCalls[I].Libcall, HardFloatLibCalls[I].Impl);
225+
RTLIB::Libcall LC =
226+
RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(HardFloatLibCalls[I]);
227+
setLibcallImpl(LC, HardFloatLibCalls[I]);
266228
}
267229
}
268230

@@ -417,6 +379,14 @@ const char* Mips16TargetLowering::
417379
return result;
418380
}
419381

382+
static bool isMips16HardFloatLibcall(StringRef Name) {
383+
// FIXME: Use getSupportedLibcallImpl instead of blindly parsing the name.
384+
iota_range<RTLIB::LibcallImpl> ParsedLibcalls =
385+
RTLIB::RuntimeLibcallsInfo::lookupLibcallImplName(Name);
386+
return !ParsedLibcalls.empty() &&
387+
binary_search(HardFloatLibCalls, *ParsedLibcalls.begin());
388+
}
389+
420390
void Mips16TargetLowering::
421391
getOpndList(SmallVectorImpl<SDValue> &Ops,
422392
std::deque< std::pair<unsigned, SDValue> > &RegsToPass,
@@ -437,10 +407,7 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
437407
//
438408
bool LookupHelper = true;
439409
if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(CLI.Callee)) {
440-
Mips16Libcall Find = {RTLIB::UNKNOWN_LIBCALL, RTLIB::Unsupported,
441-
S->getSymbol()};
442-
443-
if (llvm::binary_search(HardFloatLibCalls, Find))
410+
if (isMips16HardFloatLibcall(S->getSymbol()))
444411
LookupHelper = false;
445412
else {
446413
const char *Symbol = S->getSymbol();
@@ -478,10 +445,8 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
478445
}
479446
} else if (GlobalAddressSDNode *G =
480447
dyn_cast<GlobalAddressSDNode>(CLI.Callee)) {
481-
Mips16Libcall Find = {RTLIB::UNKNOWN_LIBCALL, RTLIB::Unsupported,
482-
G->getGlobal()->getName().data()};
483448

484-
if (llvm::binary_search(HardFloatLibCalls, Find))
449+
if (isMips16HardFloatLibcall(G->getGlobal()->getName()))
485450
LookupHelper = false;
486451
}
487452
if (LookupHelper)

0 commit comments

Comments
 (0)