[llvm] fbce4a7 - Drop some more global std::maps. NFCI.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 6 04:34:08 PST 2022
Author: Benjamin Kramer
Date: 2022-03-06T13:28:29+01:00
New Revision: fbce4a78035c32792b0a13cf1f169048b822c06b
URL: https://github.com/llvm/llvm-project/commit/fbce4a78035c32792b0a13cf1f169048b822c06b
DIFF: https://github.com/llvm/llvm-project/commit/fbce4a78035c32792b0a13cf1f169048b822c06b.diff
LOG: Drop some more global std::maps. NFCI.
Added:
Modified:
llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
llvm/lib/Target/VE/VEInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
index f7f36901e4d49..45a5bdb48f01a 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp
@@ -71,7 +71,7 @@ static uint32_t computeBucketCount(uint32_t NumStrings) {
// This list contains all StringCount, BucketCount pairs where BucketCount was
// just incremented. It ends before the first BucketCount entry where
// BucketCount * 3 would overflow a 32-bit unsigned int.
- static std::map<uint32_t, uint32_t> StringsToBuckets = {
+ static const std::pair<uint32_t, uint32_t> StringsToBuckets[] = {
{0, 1},
{1, 2},
{2, 4},
@@ -124,8 +124,9 @@ static uint32_t computeBucketCount(uint32_t NumStrings) {
{517197275, 1034394550},
{775795913, 1551591826},
{1163693870, 2327387740}};
- auto Entry = StringsToBuckets.lower_bound(NumStrings);
- assert(Entry != StringsToBuckets.end());
+ const auto *Entry = llvm::lower_bound(
+ StringsToBuckets, std::make_pair(NumStrings, 0U), llvm::less_first());
+ assert(Entry != std::end(StringsToBuckets));
return Entry->second;
}
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d6a87526c5c38..51f17b37a8d6a 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -12799,12 +12799,15 @@ SDValue AArch64TargetLowering::LowerSVEStructLoad(unsigned Intrinsic,
assert(VT.isScalableVector() && "Can only lower scalable vectors");
unsigned N, Opcode;
- static std::map<unsigned, std::pair<unsigned, unsigned>> IntrinsicMap = {
- {Intrinsic::aarch64_sve_ld2, {2, AArch64ISD::SVE_LD2_MERGE_ZERO}},
- {Intrinsic::aarch64_sve_ld3, {3, AArch64ISD::SVE_LD3_MERGE_ZERO}},
- {Intrinsic::aarch64_sve_ld4, {4, AArch64ISD::SVE_LD4_MERGE_ZERO}}};
-
- std::tie(N, Opcode) = IntrinsicMap[Intrinsic];
+ static const std::pair<unsigned, std::pair<unsigned, unsigned>>
+ IntrinsicMap[] = {
+ {Intrinsic::aarch64_sve_ld2, {2, AArch64ISD::SVE_LD2_MERGE_ZERO}},
+ {Intrinsic::aarch64_sve_ld3, {3, AArch64ISD::SVE_LD3_MERGE_ZERO}},
+ {Intrinsic::aarch64_sve_ld4, {4, AArch64ISD::SVE_LD4_MERGE_ZERO}}};
+
+ std::tie(N, Opcode) = llvm::find_if(IntrinsicMap, [&](auto P) {
+ return P.first == Intrinsic;
+ })->second;
assert(VT.getVectorElementCount().getKnownMinValue() % N == 0 &&
"invalid tuple vector type!");
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index 991d6591682c2..accc281bc5527 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -126,7 +126,7 @@ const uint32_t *RISCVRegisterInfo::getNoPreservedMask() const {
// Frame indexes representing locations of CSRs which are given a fixed location
// by save/restore libcalls.
-static const std::map<unsigned, int> FixedCSRFIMap = {
+static const std::pair<unsigned, int> FixedCSRFIMap[] = {
{/*ra*/ RISCV::X1, -1},
{/*s0*/ RISCV::X8, -2},
{/*s1*/ RISCV::X9, -3},
@@ -149,8 +149,9 @@ bool RISCVRegisterInfo::hasReservedSpillSlot(const MachineFunction &MF,
if (!RVFI->useSaveRestoreLibCalls(MF))
return false;
- auto FII = FixedCSRFIMap.find(Reg);
- if (FII == FixedCSRFIMap.end())
+ const auto *FII =
+ llvm::find_if(FixedCSRFIMap, [&](auto P) { return P.first == Reg; });
+ if (FII == std::end(FixedCSRFIMap))
return false;
FrameIdx = FII->second;
diff --git a/llvm/lib/Target/VE/VEInstrInfo.cpp b/llvm/lib/Target/VE/VEInstrInfo.cpp
index 7c1bd52018672..94ebb59c4c771 100644
--- a/llvm/lib/Target/VE/VEInstrInfo.cpp
+++ b/llvm/lib/Target/VE/VEInstrInfo.cpp
@@ -811,7 +811,7 @@ static void expandPseudoVFMK(const TargetInstrInfo &TI, MachineInstr &MI) {
// replace to pvfmk.w.up and pvfmk.w.lo
// replace to pvfmk.s.up and pvfmk.s.lo
- static std::map<unsigned, std::pair<unsigned, unsigned>> VFMKMap = {
+ static const std::pair<unsigned, std::pair<unsigned, unsigned>> VFMKMap[] = {
{VE::VFMKyal, {VE::VFMKLal, VE::VFMKLal}},
{VE::VFMKynal, {VE::VFMKLnal, VE::VFMKLnal}},
{VE::VFMKWyvl, {VE::PVFMKWUPvl, VE::PVFMKWLOvl}},
@@ -822,8 +822,9 @@ static void expandPseudoVFMK(const TargetInstrInfo &TI, MachineInstr &MI) {
unsigned Opcode = MI.getOpcode();
- auto Found = VFMKMap.find(Opcode);
- if (Found == VFMKMap.end())
+ const auto *Found =
+ llvm::find_if(VFMKMap, [&](auto P) { return P.first == Opcode; });
+ if (Found == std::end(VFMKMap))
report_fatal_error("unexpected opcode for pseudo vfmk");
unsigned OpcodeUpper = (*Found).second.first;
More information about the llvm-commits
mailing list