//===----------------------------------------------------------------------===//
#include "CodeGenTarget.h"
+#include "llvm/ADT/CachedHashString.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
}
}
-static unsigned getConverterOperandID(const std::string &Name,
- SmallSetVector<std::string, 16> &Table,
- bool &IsNew) {
- IsNew = Table.insert(Name);
+static unsigned
+getConverterOperandID(const std::string &Name,
+ SmallSetVector<CachedHashString, 16> &Table,
+ bool &IsNew) {
+ IsNew = Table.insert(CachedHashString(Name));
unsigned ID = IsNew ? Table.size() - 1 : find(Table, Name) - Table.begin();
std::vector<std::unique_ptr<MatchableInfo>> &Infos,
bool HasMnemonicFirst, bool HasOptionalOperands,
raw_ostream &OS) {
- SmallSetVector<std::string, 16> OperandConversionKinds;
- SmallSetVector<std::string, 16> InstructionConversionKinds;
+ SmallSetVector<CachedHashString, 16> OperandConversionKinds;
+ SmallSetVector<CachedHashString, 16> InstructionConversionKinds;
std::vector<std::vector<uint8_t> > ConversionTable;
size_t MaxRowLength = 2; // minimum is custom converter plus terminator.
// Pre-populate the operand conversion kinds with the standard always
// available entries.
- OperandConversionKinds.insert("CVT_Done");
- OperandConversionKinds.insert("CVT_Reg");
- OperandConversionKinds.insert("CVT_Tied");
+ OperandConversionKinds.insert(CachedHashString("CVT_Done"));
+ OperandConversionKinds.insert(CachedHashString("CVT_Reg"));
+ OperandConversionKinds.insert(CachedHashString("CVT_Tied"));
enum { CVT_Done, CVT_Reg, CVT_Tied };
for (auto &II : Infos) {
II->ConversionFnKind = Signature;
// Check if we have already generated this signature.
- if (!InstructionConversionKinds.insert(Signature))
+ if (!InstructionConversionKinds.insert(CachedHashString(Signature)))
continue;
// Remember this converter for the kind enum.
unsigned KindID = OperandConversionKinds.size();
- OperandConversionKinds.insert("CVT_" +
- getEnumNameForToken(AsmMatchConverter));
+ OperandConversionKinds.insert(
+ CachedHashString("CVT_" + getEnumNameForToken(AsmMatchConverter)));
// Add the converter row for this instruction.
ConversionTable.emplace_back();
// Save the signature. If we already have it, don't add a new row
// to the table.
- if (!InstructionConversionKinds.insert(Signature))
+ if (!InstructionConversionKinds.insert(CachedHashString(Signature)))
continue;
// Add the row to the table.
// Output the operand conversion kind enum.
OS << "enum OperatorConversionKind {\n";
- for (const std::string &Converter : OperandConversionKinds)
+ for (const auto &Converter : OperandConversionKinds)
OS << " " << Converter << ",\n";
OS << " CVT_NUM_CONVERTERS\n";
OS << "};\n\n";
// Output the instruction conversion kind enum.
OS << "enum InstructionConversionKind {\n";
- for (const std::string &Signature : InstructionConversionKinds)
+ for (const auto &Signature : InstructionConversionKinds)
OS << " " << Signature << ",\n";
OS << " CVT_NUM_SIGNATURES\n";
OS << "};\n\n";
#include "CodeGenTarget.h"
#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/CachedHashString.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
typedef uint32_t DecoderFixup;
typedef std::vector<DecoderFixup> FixupList;
typedef std::vector<FixupList> FixupScopeList;
-typedef SmallSetVector<std::string, 16> PredicateSet;
-typedef SmallSetVector<std::string, 16> DecoderSet;
+typedef SmallSetVector<CachedHashString, 16> PredicateSet;
+typedef SmallSetVector<CachedHashString, 16> DecoderSet;
struct DecoderTableInfo {
DecoderTable Table;
FixupScopeList FixupStack;
// overkill for now, though.
// Make sure the predicate is in the table.
- Decoders.insert(StringRef(Decoder));
+ Decoders.insert(CachedHashString(Decoder));
// Now figure out the index for when we write out the table.
DecoderSet::const_iterator P = find(Decoders, Decoder.str());
return (unsigned)(P - Decoders.begin());
// overkill for now, though.
// Make sure the predicate is in the table.
- TableInfo.Predicates.insert(Predicate.str());
+ TableInfo.Predicates.insert(CachedHashString(Predicate));
// Now figure out the index for when we write out the table.
- PredicateSet::const_iterator P = find(TableInfo.Predicates, Predicate.str());
+ PredicateSet::const_iterator P = find(TableInfo.Predicates, Predicate);
return (unsigned)(P - TableInfo.Predicates.begin());
}