[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)
S. Bharadwaj Yadavalli via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 11:51:20 PST 2024
================
@@ -63,17 +114,63 @@ void ComputedShaderFlags::print(raw_ostream &OS) const {
OS << ";\n";
}
+/// Insert the pair <Func, FlagMask> into the sorted vector
+/// FunctionFlags. The insertion is expected to be in-order and hence
+/// is done at the end of the already sorted list.
+void DXILModuleShaderFlagsInfo::insertInorderFunctionFlags(
+ const Function *Func, ComputedShaderFlags FlagMask) {
+ FunctionFlags.push_back({Func, FlagMask});
+}
+
+const SmallVector<std::pair<Function const *, ComputedShaderFlags>> &
+DXILModuleShaderFlagsInfo::getFunctionFlags() const {
+ return FunctionFlags;
+}
+
+const ComputedShaderFlags &DXILModuleShaderFlagsInfo::getModuleFlags() const {
+ return ModuleFlags;
+}
+
+Expected<const ComputedShaderFlags &>
+DXILModuleShaderFlagsInfo::getShaderFlagsMask(const Function *Func) const {
+ std::pair<Function const *, ComputedShaderFlags> V{Func, {}};
+ const auto *Iter = llvm::lower_bound(FunctionFlags, V);
----------------
bharadwajy wrote:
> Does this really return a pointer? I'd expect it to return an instance of an iterator as a value type.
`clang-tidy` suggested `const auto *` vs `const auto` - although either is fine. I used `const auto *` since it seemed to be a reasonable suggestion given `Iter` points to the content and is accessed using `->`. However, looks like the convention in LLVM is not to use `*`. So, changed to `const auto`.
https://github.com/llvm/llvm-project/pull/112967
More information about the llvm-commits
mailing list