forked from OSchip/llvm-project
[AVX] Make StringInit Unique
Use a StringMap to ensure the StringInits are unique. This is especially important for AVX where we will have many smallish strings representing instruction prefixes, suffixes and the like. llvm-svn: 136491
This commit is contained in:
parent
a44263c0cc
commit
3ff33c9123
|
@ -21,6 +21,7 @@
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
@ -565,7 +566,12 @@ IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
const StringInit *StringInit::get(const std::string &V) {
|
const StringInit *StringInit::get(const std::string &V) {
|
||||||
return new StringInit(V);
|
typedef StringMap<StringInit *> Pool;
|
||||||
|
static Pool ThePool;
|
||||||
|
|
||||||
|
StringInit *&I = ThePool[V];
|
||||||
|
if (!I) I = new StringInit(V);
|
||||||
|
return I;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CodeInit *CodeInit::get(const std::string &V) {
|
const CodeInit *CodeInit::get(const std::string &V) {
|
||||||
|
|
Loading…
Reference in New Issue