summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/AsmMatcherEmitter.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-11-28 21:59:58 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-11-28 21:59:58 +0000
commit4e3c6cae3329a57eb94ce2f04fd06389a60140d2 (patch)
tree6737c3bde32ff3ae21a815e5a50fa417bdcc0735 /llvm/utils/TableGen/AsmMatcherEmitter.cpp
parentc58fa9b7a40a78dd34845e36dd42163054a45b16 (diff)
downloadbcm5719-llvm-4e3c6cae3329a57eb94ce2f04fd06389a60140d2.tar.gz
bcm5719-llvm-4e3c6cae3329a57eb94ce2f04fd06389a60140d2.zip
Push unique_ptr a bit further through some APIs and simplify some cleanup
llvm-svn: 222938
Diffstat (limited to 'llvm/utils/TableGen/AsmMatcherEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/AsmMatcherEmitter.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 5c0bb34686a..7940d4489e3 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -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;
@@ -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;
@@ -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.
@@ -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
@@ -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);
OpenPOWER on IntegriCloud