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(func.getSymNameAttr());
142 inline const TBAATree &operator[](mlir::LLVM::LLVMFuncOp func) {
145 mlir::Attribute attr = func->getAttr(getInternalFuncNameAttrName());
147 return getFuncTree(mlir::cast<mlir::StringAttr>(attr));
149 return getFuncTree(func.getSymNameAttr());
157 inline TBAATree &getMutableFuncTreeWithScope(mlir::func::FuncOp func,
158 llvm::StringRef scope) {
159 mlir::StringAttr name = func.getSymNameAttr();
161 name = mlir::StringAttr::get(name.getContext(),
162 llvm::Twine(name) +
" - " + scope);
163 return getFuncTree(name);
166 inline const TBAATree &getFuncTreeWithScope(mlir::func::FuncOp func,
167 llvm::StringRef scope) {
168 return getMutableFuncTreeWithScope(func, scope);
172 TBAATree &getFuncTree(mlir::StringAttr symName) {
173 if (!separatePerFunction)
174 symName = mlir::StringAttr::get(symName.getContext(),
"");
175 if (!trees.contains(symName))
176 trees.insert({symName, TBAATree::buildTree(symName)});
177 auto it = trees.find(symName);
178 assert(it != trees.end());
183 const bool separatePerFunction;
185 llvm::DenseMap<mlir::StringAttr, TBAATree> trees;