[llvm] [AMDGPU][NewPM] Port "AMDGPUResourceUsageAnalysis" to NPM (PR #130959)

Vikram Hegde via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 12 22:57:30 PDT 2025


================
@@ -44,23 +45,43 @@ struct AMDGPUResourceUsageAnalysis : public MachineFunctionPass {
     SmallVector<const Function *, 16> Callees;
   };
 
-  AMDGPUResourceUsageAnalysis() : MachineFunctionPass(ID) {}
+  SIFunctionResourceInfo
+  analyzeResourceUsage(const MachineFunction &MF,
+                       uint32_t AssumedStackSizeForDynamicSizeObjects,
+                       uint32_t AssumedStackSizeForExternalCall) const;
+};
+
+struct AMDGPUResourceUsageAnalysisWrapperPass : public MachineFunctionPass {
+  using ResultT = AMDGPUResourceUsageAnalysisImpl::SIFunctionResourceInfo;
+  ResultT ResourceInfo;
+
+public:
+  static char ID;
+  AMDGPUResourceUsageAnalysisWrapperPass() : MachineFunctionPass(ID) {}
 
   bool runOnMachineFunction(MachineFunction &MF) override;
 
-  const SIFunctionResourceInfo &getResourceInfo() const { return ResourceInfo; }
+  const ResultT &getResourceInfo() const { return ResourceInfo; }
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.setPreservesAll();
     MachineFunctionPass::getAnalysisUsage(AU);
   }
+};
 
-private:
-  SIFunctionResourceInfo
-  analyzeResourceUsage(const MachineFunction &MF,
-                       uint32_t AssumedStackSizeForDynamicSizeObjects,
-                       uint32_t AssumedStackSizeForExternalCall) const;
-  SIFunctionResourceInfo ResourceInfo;
+class AMDGPUResourceUsageAnalysis
+    : public AnalysisInfoMixin<AMDGPUResourceUsageAnalysis> {
+  friend AnalysisInfoMixin<AMDGPUResourceUsageAnalysis>;
+  static AnalysisKey Key;
+
+  const TargetMachine *TM;
+
+public:
+  using Result = AMDGPUResourceUsageAnalysisImpl::SIFunctionResourceInfo;
+  Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
+
+  AMDGPUResourceUsageAnalysis(const TargetMachine *TM_) : TM(TM_) {}
 };
+
----------------
vikramRH wrote:

No, this analysis is used in AMDGPUAsmPrinter to gather resource usage info

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


More information about the llvm-commits mailing list