Push unique_ptr a bit further through some APIs and simplify some cleanup

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222938 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-11-28 21:59:58 +00:00
parent 5a94a64542
commit 47e9836165

View File

@ -395,6 +395,10 @@ struct MatchableInfo {
/// matchable came from. /// matchable came from.
Record *const TheDef; 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. /// DefRec - This is the definition that it came from.
PointerUnion<const CodeGenInstruction*, const CodeGenInstAlias*> DefRec; PointerUnion<const CodeGenInstruction*, const CodeGenInstAlias*> DefRec;
@ -408,10 +412,6 @@ struct MatchableInfo {
/// MCInst. /// MCInst.
SmallVector<ResOperand, 8> ResOperands; 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 - This is the first token of the matched instruction, its
/// mnemonic. /// mnemonic.
StringRef Mnemonic; StringRef Mnemonic;
@ -434,19 +434,14 @@ struct MatchableInfo {
bool HasDeprecation; bool HasDeprecation;
MatchableInfo(const CodeGenInstruction &CGI) MatchableInfo(const CodeGenInstruction &CGI)
: AsmVariantID(0), TheDef(CGI.TheDef), DefRec(&CGI), : AsmVariantID(0), TheDef(CGI.TheDef), AsmString(CGI.AsmString),
AsmString(CGI.AsmString) { DefRec(&CGI) {}
}
MatchableInfo(const CodeGenInstAlias *Alias) MatchableInfo(std::unique_ptr<CodeGenInstAlias> Alias)
: AsmVariantID(0), TheDef(Alias->TheDef), DefRec(Alias), : AsmVariantID(0), TheDef(Alias->TheDef), AsmString(Alias->AsmString),
AsmString(Alias->AsmString) { DefRec(Alias.release()) {}
}
~MatchableInfo() { ~MatchableInfo() { delete DefRec.dyn_cast<const CodeGenInstAlias *>(); }
if (DefRec.is<const CodeGenInstAlias*>())
delete DefRec.get<const CodeGenInstAlias*>();
}
// Two-operand aliases clone from the main matchable, but mark the second // 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. // operand as a tied operand of the first for purposes of the assembler.
@ -1359,8 +1354,8 @@ void AsmMatcherInfo::buildInfo() {
std::vector<Record*> AllInstAliases = std::vector<Record*> AllInstAliases =
Records.getAllDerivedDefinitions("InstAlias"); Records.getAllDerivedDefinitions("InstAlias");
for (unsigned i = 0, e = AllInstAliases.size(); i != e; ++i) { for (unsigned i = 0, e = AllInstAliases.size(); i != e; ++i) {
CodeGenInstAlias *Alias = auto Alias = llvm::make_unique<CodeGenInstAlias>(AllInstAliases[i],
new CodeGenInstAlias(AllInstAliases[i], AsmVariantNo, Target); AsmVariantNo, Target);
// If the tblgen -match-prefix option is specified (for tblgen hackers), // If the tblgen -match-prefix option is specified (for tblgen hackers),
// filter the set of instruction aliases we consider, based on the target // filter the set of instruction aliases we consider, based on the target
@ -1369,7 +1364,7 @@ void AsmMatcherInfo::buildInfo() {
.startswith( MatchPrefix)) .startswith( MatchPrefix))
continue; continue;
Matchables.emplace_front(Alias); Matchables.emplace_front(std::move(Alias));
MatchableInfo *II = &Matchables.front(); MatchableInfo *II = &Matchables.front();
II->initialize(*this, SingletonRegisters, AsmVariantNo, RegisterPrefix); II->initialize(*this, SingletonRegisters, AsmVariantNo, RegisterPrefix);