37 SubtreeState() =
delete;
38 SubtreeState(
const SubtreeState &) =
delete;
39 SubtreeState(SubtreeState &&) =
default;
41 mlir::LLVM::TBAATagAttr
getTag(llvm::StringRef uniqueId)
const;
45 mlir::LLVM::TBAATagAttr
getTag()
const;
47 mlir::LLVM::TBAATypeDescriptorAttr getRoot()
const {
return parent; }
56 SubtreeState(mlir::MLIRContext *ctx, std::string name,
57 mlir::LLVM::TBAANodeAttr grandParent)
58 : parentId{std::move(name)}, context(ctx) {
59 parent = mlir::LLVM::TBAATypeDescriptorAttr::get(
60 context, parentId, mlir::LLVM::TBAAMemberAttr::get(grandParent, 0));
63 const std::string parentId;
64 mlir::MLIRContext *
const context;
65 mlir::LLVM::TBAATypeDescriptorAttr parent;
68 llvm::DenseMap<mlir::StringAttr, SubtreeState> namedSubtrees;
89 mlir::LLVM::TBAATypeDescriptorAttr anyAccessDesc;
90 mlir::LLVM::TBAATypeDescriptorAttr boxMemberTypeDesc;
91 mlir::LLVM::TBAATypeDescriptorAttr anyDataTypeDesc;
121 static TBAATree buildTree(mlir::StringAttr functionName);
124 TBAATree(mlir::LLVM::TBAATypeDescriptorAttr anyAccess,
125 mlir::LLVM::TBAATypeDescriptorAttr dataRoot,
126 mlir::LLVM::TBAATypeDescriptorAttr boxMemberTypeDesc);
136 explicit TBAAForrest(
bool separatePerFunction =
true)
137 : separatePerFunction{separatePerFunction} {}
139 inline const TBAATree &operator[](mlir::func::FuncOp func) {
140 return getFuncTree(getInternalOrSymbolName(func));
142 inline const TBAATree &operator[](mlir::LLVM::LLVMFuncOp func) {
143 return getFuncTree(getInternalOrSymbolName(func));
151 inline TBAATree &getMutableFuncTreeWithScope(mlir::func::FuncOp func,
152 llvm::StringRef scope) {
153 mlir::StringAttr name = getInternalOrSymbolName(func);
155 name = mlir::StringAttr::get(name.getContext(),
156 llvm::Twine(name) +
" - " + scope);
157 return getFuncTree(name);
160 inline const TBAATree &getFuncTreeWithScope(mlir::func::FuncOp func,
161 llvm::StringRef scope) {
162 return getMutableFuncTreeWithScope(func, scope);
166 template <
typename FuncOp>
167 static mlir::StringAttr getInternalOrSymbolName(FuncOp func) {
171 if (
auto name = func->template getAttrOfType<mlir::StringAttr>(
172 getInternalFuncNameAttrName()))
174 return func.getSymNameAttr();
177 TBAATree &getFuncTree(mlir::StringAttr symName) {
178 if (!separatePerFunction)
179 symName = mlir::StringAttr::get(symName.getContext(),
"");
180 if (!trees.contains(symName))
181 trees.insert({symName, TBAATree::buildTree(symName)});
182 auto it = trees.find(symName);
183 assert(it != trees.end());
188 const bool separatePerFunction;
190 llvm::DenseMap<mlir::StringAttr, TBAATree> trees;