[AVX] Make Inits Foldable

Manage Inits in a FoldingSet.  This provides several benefits:

- Memory for Inits is properly managed

- Duplicate Inits are folded into Flyweights, saving memory

- It enforces const-correctness, protecting against certain classes
  of bugs

The above benefits allow Inits to be used in more contexts, which in
turn provides more dynamism to TableGen.  This enhanced capability
will be used by the AVX code generator to a fold common patterns
together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Greene
2011-07-11 18:25:51 +00:00
parent 7ae0df4142
commit d4a9066c93
31 changed files with 1712 additions and 1002 deletions

View File

@@ -74,7 +74,8 @@ getCategoryFromDiagGroup(const Record *Group,
static std::string getDiagnosticCategory(const Record *R,
DiagGroupParentMap &DiagGroupParents) {
// If the diagnostic is in a group, and that group has a category, use it.
if (DefInit *Group = dynamic_cast<DefInit*>(R->getValueInit("Group"))) {
if (const DefInit *Group =
dynamic_cast<const DefInit*>(R->getValueInit("Group"))) {
// Check the diagnostic's diag group for a category.
std::string CatName = getCategoryFromDiagGroup(Group->getDef(),
DiagGroupParents);
@@ -159,7 +160,8 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) {
OS.write_escaped(R.getValueAsString("Text")) << '"';
// Warning associated with the diagnostic.
if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) {
if (const DefInit *DI =
dynamic_cast<const DefInit*>(R.getValueInit("Group"))) {
OS << ", \"";
OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"';
} else {
@@ -225,7 +227,7 @@ void ClangDiagGroupsEmitter::run(raw_ostream &OS) {
Records.getAllDerivedDefinitions("Diagnostic");
for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
const Record *R = Diags[i];
DefInit *DI = dynamic_cast<DefInit*>(R->getValueInit("Group"));
const DefInit *DI = dynamic_cast<const DefInit*>(R->getValueInit("Group"));
if (DI == 0) continue;
std::string GroupName = DI->getDef()->getValueAsString("GroupName");
DiagsInGroup[GroupName].DiagsInGroup.push_back(R);