MLIR  20.0.0git
SymbolTableAnalysis.h
Go to the documentation of this file.
1 //===- SymbolTableAnalysis.h - Analysis for cached symbol tables --*- C++ -*-=//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_ANALYSIS_SYMBOLTABLEANALYSIS_H
10 #define MLIR_ANALYSIS_SYMBOLTABLEANALYSIS_H
11 
12 #include "mlir/IR/SymbolTable.h"
14 
15 namespace mlir {
16 /// This is a simple analysis that contains a symbol table collection and, for
17 /// simplicity, a reference to the top-level symbol table. This allows symbol
18 /// tables to be preserved across passes. Most often, symbol tables are
19 /// automatically kept up-to-date via the `insert` and `erase` functions.
21 public:
22  /// Create the symbol table analysis at the provided top-level operation and
23  /// instantiate the symbol table of the top-level operation.
25  : topLevelSymbolTable(symbolTables.getSymbolTable(op)) {}
26 
27  /// Get the symbol table collection.
28  SymbolTableCollection &getSymbolTables() { return symbolTables; }
29 
30  /// Get the top-level symbol table.
31  SymbolTable &getTopLevelSymbolTable() { return topLevelSymbolTable; }
32 
33  /// Get the top-level operation.
34  template <typename OpT>
35  OpT getTopLevelOp() {
36  return cast<OpT>(topLevelSymbolTable.getOp());
37  }
38 
39  /// Symbol tables are kept up-to-date by passes. Assume that the analysis
40  /// remains valid.
42  return false;
43  }
44 
45 private:
46  /// The symbol table collection containing cached symbol tables for all nested
47  /// symbol table operations.
48  SymbolTableCollection symbolTables;
49  /// The symbol table of the top-level operation.
50  SymbolTable &topLevelSymbolTable;
51 };
52 } // namespace mlir
53 
54 #endif // MLIR_ANALYSIS_SYMBOLTABLEANALYSIS_H
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
This is a simple analysis that contains a symbol table collection and, for simplicity,...
SymbolTableCollection & getSymbolTables()
Get the symbol table collection.
SymbolTable & getTopLevelSymbolTable()
Get the top-level symbol table.
SymbolTableAnalysis(Operation *op)
Create the symbol table analysis at the provided top-level operation and instantiate the symbol table...
OpT getTopLevelOp()
Get the top-level operation.
bool isInvalidated(const AnalysisManager::PreservedAnalyses &pa)
Symbol tables are kept up-to-date by passes.
This class represents a collection of SymbolTables.
Definition: SymbolTable.h:283
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Definition: SymbolTable.h:24
Operation * getOp() const
Returns the associated operation.
Definition: SymbolTable.h:79
A utility class to represent the analyses that are known to be preserved.
Include the generated interface declarations.