[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)

Damyan Pepper via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 16:48:56 PST 2024


================
@@ -60,21 +61,48 @@ struct ComputedShaderFlags {
     return FeatureFlags;
   }
 
-  static ComputedShaderFlags computeFlags(Module &M);
+  uint64_t getModuleFlags() const {
+    uint64_t ModuleFlags = 0;
+#define DXIL_MODULE_FLAG(DxilModuleBit, FlagName, Str)                         \
+  ModuleFlags |= FlagName ? getMask(DxilModuleBit) : 0ull;
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+    return ModuleFlags;
+  }
+
   void print(raw_ostream &OS = dbgs()) const;
   LLVM_DUMP_METHOD void dump() const { print(); }
 };
 
+struct DXILModuleShaderFlagsInfo {
+  bool initialize(const Module &M);
+  Expected<const ComputedShaderFlags &>
+  getShaderFlagsMask(const Function *Func) const;
+  bool hasShaderFlagsMask(const Function *Func) const;
+  const ComputedShaderFlags &getModuleFlags() const;
+  const SmallVector<std::pair<Function const *, ComputedShaderFlags>> &
+  getFunctionFlags() const;
+
+private:
+  // Shader Flag mask representing module-level properties. These are
+  // represented using the macro DXIL_MODULE_FLAG
+  ComputedShaderFlags ModuleFlags;
+  // Vector of Function-Shader Flag mask pairs representing properties of each
+  // of the functions in the module. Shader Flags of each function are those
+  // represented using the macro SHADER_FEATURE_FLAG.
+  SmallVector<std::pair<Function const *, ComputedShaderFlags>> FunctionFlags;
+  void updateFuctionFlags(ComputedShaderFlags &CSF, const Instruction &I);
----------------
damyanp wrote:

Probably best not to say that out loud in polite conversation :)

```suggestion
  void updateFunctionFlags(ComputedShaderFlags &CSF, const Instruction &I);
```



https://github.com/llvm/llvm-project/pull/112967


More information about the llvm-commits mailing list