Skip to content

Commit

Permalink
[AVX] Make StringInit Unique
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136491 91177308-0d34-0410-b5e6-96231b3b80d8
greened committed Jul 29, 2011

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2855b0f commit d0e9d04
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/TableGen/Record.cpp
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"

using namespace llvm;

@@ -565,7 +566,12 @@ IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
}

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) {

0 comments on commit d0e9d04

Please sign in to comment.