[WebAssembly] Fix macro metaprogram to not duplicate code as much.

No functionality change intended.

llvm-svn: 325947
This commit is contained in:
Benjamin Kramer 2018-02-23 20:13:03 +00:00
parent 1246a8d6e7
commit ae87f86ec4
1 changed files with 11 additions and 7 deletions

View File

@ -465,15 +465,19 @@ ManagedStatic<RuntimeLibcallSignatureTable> RuntimeLibcallSignatures;
struct StaticLibcallNameMap {
StringMap<RTLIB::Libcall> Map;
StaticLibcallNameMap() {
#define HANDLE_LIBCALL(code, name) \
if ((const char *)name && \
RuntimeLibcallSignatures->Table[RTLIB::code] != unsupported) { \
assert(Map.find(StringRef::withNullAsEmpty(name)) == Map.end() && \
"duplicate libcall names in name map"); \
Map[StringRef::withNullAsEmpty(name)] = RTLIB::code; \
}
static constexpr std::pair<const char *, RTLIB::Libcall> NameLibcalls[] = {
#define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code},
#include "llvm/CodeGen/RuntimeLibcalls.def"
#undef HANDLE_LIBCALL
};
for (const auto &NameLibcall : NameLibcalls) {
if (NameLibcall.first != nullptr &&
RuntimeLibcallSignatures->Table[NameLibcall.second] != unsupported) {
assert(Map.find(NameLibcall.first) == Map.end() &&
"duplicate libcall names in name map");
Map[NameLibcall.first] = NameLibcall.second;
}
}
}
};