Skip to content

Commit

Permalink
Push unique_ptr a bit further through some APIs and simplify some cle…
Browse files Browse the repository at this point in the history
…anup

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222938 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dwblaikie committed Nov 28, 2014
1 parent 5a94a64 commit 47e9836
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ struct MatchableInfo {
/// matchable came from.
Record *const TheDef;

/// AsmString - The assembly string for this instruction (with variants
/// removed), e.g. "movsx $src, $dst".
std::string AsmString;

/// DefRec - This is the definition that it came from.
PointerUnion<const CodeGenInstruction*, const CodeGenInstAlias*> DefRec;

Expand All @@ -408,10 +412,6 @@ struct MatchableInfo {
/// MCInst.
SmallVector<ResOperand, 8> ResOperands;

/// AsmString - The assembly string for this instruction (with variants
/// removed), e.g. "movsx $src, $dst".
std::string AsmString;

/// Mnemonic - This is the first token of the matched instruction, its
/// mnemonic.
StringRef Mnemonic;
Expand All @@ -434,19 +434,14 @@ struct MatchableInfo {
bool HasDeprecation;

MatchableInfo(const CodeGenInstruction &CGI)
: AsmVariantID(0), TheDef(CGI.TheDef), DefRec(&CGI),
AsmString(CGI.AsmString) {
}
: AsmVariantID(0), TheDef(CGI.TheDef), AsmString(CGI.AsmString),
DefRec(&CGI) {}

MatchableInfo(const CodeGenInstAlias *Alias)
: AsmVariantID(0), TheDef(Alias->TheDef), DefRec(Alias),
AsmString(Alias->AsmString) {
}
MatchableInfo(std::unique_ptr<CodeGenInstAlias> Alias)
: AsmVariantID(0), TheDef(Alias->TheDef), AsmString(Alias->AsmString),
DefRec(Alias.release()) {}

~MatchableInfo() {
if (DefRec.is<const CodeGenInstAlias*>())
delete DefRec.get<const CodeGenInstAlias*>();
}
~MatchableInfo() { delete DefRec.dyn_cast<const CodeGenInstAlias *>(); }

// Two-operand aliases clone from the main matchable, but mark the second
// operand as a tied operand of the first for purposes of the assembler.
Expand Down Expand Up @@ -1359,8 +1354,8 @@ void AsmMatcherInfo::buildInfo() {
std::vector<Record*> AllInstAliases =
Records.getAllDerivedDefinitions("InstAlias");
for (unsigned i = 0, e = AllInstAliases.size(); i != e; ++i) {
CodeGenInstAlias *Alias =
new CodeGenInstAlias(AllInstAliases[i], AsmVariantNo, Target);
auto Alias = llvm::make_unique<CodeGenInstAlias>(AllInstAliases[i],
AsmVariantNo, Target);

// If the tblgen -match-prefix option is specified (for tblgen hackers),
// filter the set of instruction aliases we consider, based on the target
Expand All @@ -1369,7 +1364,7 @@ void AsmMatcherInfo::buildInfo() {
.startswith( MatchPrefix))
continue;

Matchables.emplace_front(Alias);
Matchables.emplace_front(std::move(Alias));
MatchableInfo *II = &Matchables.front();

II->initialize(*this, SingletonRegisters, AsmVariantNo, RegisterPrefix);
Expand Down

0 comments on commit 47e9836

Please sign in to comment.