@@ -994,32 +994,36 @@ class EmitterBase {
994
994
const VectorType *getVectorType (const ScalarType *ST, unsigned Lanes) {
995
995
std::tuple<ScalarTypeKind, unsigned , unsigned > key (ST->kind (),
996
996
ST->sizeInBits (), Lanes);
997
- if (VectorTypes.find (key) == VectorTypes.end ())
998
- VectorTypes[key] = std::make_unique<VectorType>(ST, Lanes);
999
- return VectorTypes[key].get ();
997
+ auto [It, Inserted] = VectorTypes.try_emplace (key);
998
+ if (Inserted)
999
+ It->second = std::make_unique<VectorType>(ST, Lanes);
1000
+ return It->second .get ();
1000
1001
}
1001
1002
const VectorType *getVectorType (const ScalarType *ST) {
1002
1003
return getVectorType (ST, 128 / ST->sizeInBits ());
1003
1004
}
1004
1005
const MultiVectorType *getMultiVectorType (unsigned Registers,
1005
1006
const VectorType *VT) {
1006
1007
std::pair<std::string, unsigned > key (VT->cNameBase (), Registers);
1007
- if (MultiVectorTypes.find (key) == MultiVectorTypes.end ())
1008
- MultiVectorTypes[key] = std::make_unique<MultiVectorType>(Registers, VT);
1009
- return MultiVectorTypes[key].get ();
1008
+ auto [It, Inserted] = MultiVectorTypes.try_emplace (key);
1009
+ if (Inserted)
1010
+ It->second = std::make_unique<MultiVectorType>(Registers, VT);
1011
+ return It->second .get ();
1010
1012
}
1011
1013
const PredicateType *getPredicateType (unsigned Lanes) {
1012
1014
unsigned key = Lanes;
1013
- if (PredicateTypes.find (key) == PredicateTypes.end ())
1014
- PredicateTypes[key] = std::make_unique<PredicateType>(Lanes);
1015
- return PredicateTypes[key].get ();
1015
+ auto [It, Inserted] = PredicateTypes.try_emplace (key);
1016
+ if (Inserted)
1017
+ It->second = std::make_unique<PredicateType>(Lanes);
1018
+ return It->second .get ();
1016
1019
}
1017
1020
const PointerType *getPointerType (const Type *T, bool Const) {
1018
1021
PointerType PT (T, Const);
1019
1022
std::string key = PT.cName ();
1020
- if (PointerTypes.find (key) == PointerTypes.end ())
1021
- PointerTypes[key] = std::make_unique<PointerType>(PT);
1022
- return PointerTypes[key].get ();
1023
+ auto [It, Inserted] = PointerTypes.try_emplace (key);
1024
+ if (Inserted)
1025
+ It->second = std::make_unique<PointerType>(PT);
1026
+ return It->second .get ();
1023
1027
}
1024
1028
1025
1029
// Methods to construct a type from various pieces of Tablegen. These are
0 commit comments