mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[TableGen] Pass SmallVector to union_modes instead of returning a std::vector.
The number of modes is small so this should avoid a heap allocation. Also replace std::set with SmallSet.
This commit is contained in:
parent
fcafc059cd
commit
59da2ddc9a
@ -466,7 +466,8 @@ bool TypeInfer::EnforceSmallerThan(TypeSetByHwMode &Small,
|
||||
|
||||
assert(Small.hasDefault() && Big.hasDefault());
|
||||
|
||||
std::vector<unsigned> Modes = union_modes(Small, Big);
|
||||
SmallVector<unsigned, 4> Modes;
|
||||
union_modes(Small, Big, Modes);
|
||||
|
||||
// 1. Only allow integer or floating point types and make sure that
|
||||
// both sides are both integer or both floating point.
|
||||
@ -573,7 +574,9 @@ bool TypeInfer::EnforceVectorEltTypeIs(TypeSetByHwMode &Vec,
|
||||
if (Elem.empty())
|
||||
Changed |= EnforceScalar(Elem);
|
||||
|
||||
for (unsigned M : union_modes(Vec, Elem)) {
|
||||
SmallVector<unsigned, 4> Modes;
|
||||
union_modes(Vec, Elem, Modes);
|
||||
for (unsigned M : Modes) {
|
||||
TypeSetByHwMode::SetType &V = Vec.get(M);
|
||||
TypeSetByHwMode::SetType &E = Elem.get(M);
|
||||
|
||||
@ -656,7 +659,9 @@ bool TypeInfer::EnforceVectorSubVectorTypeIs(TypeSetByHwMode &Vec,
|
||||
if (Sub.empty())
|
||||
Changed |= EnforceVector(Sub);
|
||||
|
||||
for (unsigned M : union_modes(Vec, Sub)) {
|
||||
SmallVector<unsigned, 4> Modes;
|
||||
union_modes(Vec, Sub, Modes);
|
||||
for (unsigned M : Modes) {
|
||||
TypeSetByHwMode::SetType &S = Sub.get(M);
|
||||
TypeSetByHwMode::SetType &V = Vec.get(M);
|
||||
|
||||
@ -696,7 +701,9 @@ bool TypeInfer::EnforceSameNumElts(TypeSetByHwMode &V, TypeSetByHwMode &W) {
|
||||
return !Lengths.count(T.isVector() ? T.getVectorNumElements() : 0);
|
||||
};
|
||||
|
||||
for (unsigned M : union_modes(V, W)) {
|
||||
SmallVector<unsigned, 4> Modes;
|
||||
union_modes(V, W, Modes);
|
||||
for (unsigned M : Modes) {
|
||||
TypeSetByHwMode::SetType &VS = V.get(M);
|
||||
TypeSetByHwMode::SetType &WS = W.get(M);
|
||||
|
||||
@ -741,7 +748,9 @@ bool TypeInfer::EnforceSameSize(TypeSetByHwMode &A, TypeSetByHwMode &B) {
|
||||
return !Sizes.count(T.getSizeInBits());
|
||||
};
|
||||
|
||||
for (unsigned M : union_modes(A, B)) {
|
||||
SmallVector<unsigned, 4> Modes;
|
||||
union_modes(A, B, Modes);
|
||||
for (unsigned M : Modes) {
|
||||
TypeSetByHwMode::SetType &AS = A.get(M);
|
||||
TypeSetByHwMode::SetType &BS = B.get(M);
|
||||
TypeSizeSet AN, BN;
|
||||
|
@ -15,10 +15,10 @@
|
||||
#define LLVM_UTILS_TABLEGEN_INFOBYHWMODE_H
|
||||
|
||||
#include "CodeGenHwModes.h"
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/Support/MachineValueType.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -37,10 +37,10 @@ enum : unsigned {
|
||||
};
|
||||
|
||||
template <typename InfoT>
|
||||
std::vector<unsigned> union_modes(const InfoByHwMode<InfoT> &A,
|
||||
const InfoByHwMode<InfoT> &B) {
|
||||
std::vector<unsigned> V;
|
||||
std::set<unsigned> U;
|
||||
void union_modes(const InfoByHwMode<InfoT> &A,
|
||||
const InfoByHwMode<InfoT> &B,
|
||||
SmallVectorImpl<unsigned> &Modes) {
|
||||
SmallSet<unsigned, 4> U;
|
||||
for (const auto &P : A)
|
||||
U.insert(P.first);
|
||||
for (const auto &P : B)
|
||||
@ -49,12 +49,11 @@ std::vector<unsigned> union_modes(const InfoByHwMode<InfoT> &A,
|
||||
bool HasDefault = false;
|
||||
for (unsigned M : U)
|
||||
if (M != DefaultMode)
|
||||
V.push_back(M);
|
||||
Modes.push_back(M);
|
||||
else
|
||||
HasDefault = true;
|
||||
if (HasDefault)
|
||||
V.push_back(DefaultMode);
|
||||
return V;
|
||||
Modes.push_back(DefaultMode);
|
||||
}
|
||||
|
||||
template <typename InfoT>
|
||||
|
Loading…
Reference in New Issue
Block a user