[llvm] [KernelInfo] Implement new LLVM IR pass for GPU code analysis (PR #102944)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 16 09:44:09 PDT 2024
================
@@ -0,0 +1,121 @@
+//=- KernelInfo.h - Kernel Analysis -------------------------------*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the KernelInfo, KernelInfoAnalysis, and KernelInfoPrinter
+// classes used to extract function properties from a GPU kernel.
+//
+// See llvm/docs/KernelInfo.rst.
+// ===---------------------------------------------------------------------===//
+
+#ifndef LLVM_ANALYSIS_KERNELINFO_H
+#define LLVM_ANALYSIS_KERNELINFO_H
+
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+
+namespace llvm {
+class DominatorTree;
+class Function;
+
+/// Data structure holding function info for kernels.
+class KernelInfo {
----------------
shiltian wrote:
It doesn't have to be multiple files. The variadic argument pass has target dependent stuff in the same file as well.
What I expect is a hierarchical modular data struct. Each target just minds their own business: add their own attributes in their own descriptor, implement their own analysis and print method, etc. For now it "seems" okay to have all of them in the same data structure and use if-else to print, because technically we only have two offloading targets, but this data structure will keep growing when we have more (looking at Intel), and for any of the target, most of the parts are useless.
For the future use, we can just have the analysis results at one place and return a reference.
https://github.com/llvm/llvm-project/pull/102944
More information about the llvm-commits
mailing list