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;
107 static TBAATree buildTree(mlir::StringAttr functionName);
110 TBAATree(mlir::LLVM::TBAATypeDescriptorAttr anyAccess,
111 mlir::LLVM::TBAATypeDescriptorAttr dataRoot,
112 mlir::LLVM::TBAATypeDescriptorAttr boxMemberTypeDesc);
122 explicit TBAAForrest(
bool separatePerFunction =
true)
123 : separatePerFunction{separatePerFunction} {}
125 inline const TBAATree &operator[](mlir::func::FuncOp func) {
126 return getFuncTree(func.getSymNameAttr());
128 inline const TBAATree &operator[](mlir::LLVM::LLVMFuncOp func) {
131 mlir::Attribute attr = func->getAttr(getInternalFuncNameAttrName());
133 return getFuncTree(mlir::cast<mlir::StringAttr>(attr));
135 return getFuncTree(func.getSymNameAttr());
143 inline TBAATree &getMutableFuncTreeWithScope(mlir::func::FuncOp func,
144 llvm::StringRef scope) {
145 mlir::StringAttr name = func.getSymNameAttr();
147 name = mlir::StringAttr::get(name.getContext(),
148 llvm::Twine(name) +
" - " + scope);
149 return getFuncTree(name);
152 inline const TBAATree &getFuncTreeWithScope(mlir::func::FuncOp func,
153 llvm::StringRef scope) {
154 return getMutableFuncTreeWithScope(func, scope);
158 TBAATree &getFuncTree(mlir::StringAttr symName) {
159 if (!separatePerFunction)
160 symName = mlir::StringAttr::get(symName.getContext(),
"");
161 if (!trees.contains(symName))
162 trees.insert({symName, TBAATree::buildTree(symName)});
163 auto it = trees.find(symName);
164 assert(it != trees.end());
169 const bool separatePerFunction;
171 llvm::DenseMap<mlir::StringAttr, TBAATree> trees;