10b57cec5SDimitry Andric //===--- SIProgramInfo.h ----------------------------------------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric /// \file 10e8d8bef9SDimitry Andric /// Defines struct to track resource usage and hardware flags for kernels and 11e8d8bef9SDimitry Andric /// entry functions. 120b57cec5SDimitry Andric /// 130b57cec5SDimitry Andric // 140b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_SIPROGRAMINFO_H 170b57cec5SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_SIPROGRAMINFO_H 180b57cec5SDimitry Andric 19e8d8bef9SDimitry Andric #include "llvm/IR/CallingConv.h" 20*0fca6ea1SDimitry Andric #include "llvm/Support/Compiler.h" 21e8d8bef9SDimitry Andric #include <cstdint> 22e8d8bef9SDimitry Andric 230b57cec5SDimitry Andric namespace llvm { 240b57cec5SDimitry Andric 255f757f3fSDimitry Andric class GCNSubtarget; 26*0fca6ea1SDimitry Andric class MCContext; 27*0fca6ea1SDimitry Andric class MCExpr; 28*0fca6ea1SDimitry Andric class MachineFunction; 295f757f3fSDimitry Andric 300b57cec5SDimitry Andric /// Track resource usage for kernels / entry functions. 31*0fca6ea1SDimitry Andric struct LLVM_EXTERNAL_VISIBILITY SIProgramInfo { 320b57cec5SDimitry Andric // Fields set in PGM_RSRC1 pm4 packet. 33*0fca6ea1SDimitry Andric const MCExpr *VGPRBlocks = nullptr; 34*0fca6ea1SDimitry Andric const MCExpr *SGPRBlocks = nullptr; 350b57cec5SDimitry Andric uint32_t Priority = 0; 360b57cec5SDimitry Andric uint32_t FloatMode = 0; 370b57cec5SDimitry Andric uint32_t Priv = 0; 380b57cec5SDimitry Andric uint32_t DX10Clamp = 0; 390b57cec5SDimitry Andric uint32_t DebugMode = 0; 400b57cec5SDimitry Andric uint32_t IEEEMode = 0; 410b57cec5SDimitry Andric uint32_t WgpMode = 0; // GFX10+ 420b57cec5SDimitry Andric uint32_t MemOrdered = 0; // GFX10+ 435f757f3fSDimitry Andric uint32_t RrWgMode = 0; // GFX12+ 44*0fca6ea1SDimitry Andric const MCExpr *ScratchSize = nullptr; 450b57cec5SDimitry Andric 4606c3fb27SDimitry Andric // State used to calculate fields set in PGM_RSRC2 pm4 packet. 470b57cec5SDimitry Andric uint32_t LDSBlocks = 0; 48*0fca6ea1SDimitry Andric const MCExpr *ScratchBlocks = nullptr; 490b57cec5SDimitry Andric 5006c3fb27SDimitry Andric // Fields set in PGM_RSRC2 pm4 packet 51*0fca6ea1SDimitry Andric const MCExpr *ScratchEnable = nullptr; 5206c3fb27SDimitry Andric uint32_t UserSGPR = 0; 5306c3fb27SDimitry Andric uint32_t TrapHandlerEnable = 0; 5406c3fb27SDimitry Andric uint32_t TGIdXEnable = 0; 5506c3fb27SDimitry Andric uint32_t TGIdYEnable = 0; 5606c3fb27SDimitry Andric uint32_t TGIdZEnable = 0; 5706c3fb27SDimitry Andric uint32_t TGSizeEnable = 0; 5806c3fb27SDimitry Andric uint32_t TIdIGCompCount = 0; 5906c3fb27SDimitry Andric uint32_t EXCPEnMSB = 0; 6006c3fb27SDimitry Andric uint32_t LdsSize = 0; 6106c3fb27SDimitry Andric uint32_t EXCPEnable = 0; 6206c3fb27SDimitry Andric 63*0fca6ea1SDimitry Andric const MCExpr *ComputePGMRSrc3GFX90A = nullptr; 640b57cec5SDimitry Andric 65*0fca6ea1SDimitry Andric const MCExpr *NumVGPR = nullptr; 66*0fca6ea1SDimitry Andric const MCExpr *NumArchVGPR = nullptr; 67*0fca6ea1SDimitry Andric const MCExpr *NumAccVGPR = nullptr; 68*0fca6ea1SDimitry Andric const MCExpr *AccumOffset = nullptr; 69fe6060f1SDimitry Andric uint32_t TgSplit = 0; 70*0fca6ea1SDimitry Andric const MCExpr *NumSGPR = nullptr; 71fcaf7f86SDimitry Andric unsigned SGPRSpill = 0; 72fcaf7f86SDimitry Andric unsigned VGPRSpill = 0; 730b57cec5SDimitry Andric uint32_t LDSSize = 0; 74*0fca6ea1SDimitry Andric const MCExpr *FlatUsed = nullptr; 750b57cec5SDimitry Andric 760b57cec5SDimitry Andric // Number of SGPRs that meets number of waves per execution unit request. 77*0fca6ea1SDimitry Andric const MCExpr *NumSGPRsForWavesPerEU = nullptr; 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric // Number of VGPRs that meets number of waves per execution unit request. 80*0fca6ea1SDimitry Andric const MCExpr *NumVGPRsForWavesPerEU = nullptr; 810b57cec5SDimitry Andric 828bcb0991SDimitry Andric // Final occupancy. 83*0fca6ea1SDimitry Andric const MCExpr *Occupancy = nullptr; 848bcb0991SDimitry Andric 850b57cec5SDimitry Andric // Whether there is recursion, dynamic allocas, indirect calls or some other 860b57cec5SDimitry Andric // reason there may be statically unknown stack usage. 87*0fca6ea1SDimitry Andric const MCExpr *DynamicCallStack = nullptr; 880b57cec5SDimitry Andric 890b57cec5SDimitry Andric // Bonus information for debugging. 90*0fca6ea1SDimitry Andric const MCExpr *VCCUsed = nullptr; 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric SIProgramInfo() = default; 93e8d8bef9SDimitry Andric 94*0fca6ea1SDimitry Andric // The constructor sets the values for each member as shown in the struct. 95*0fca6ea1SDimitry Andric // However, setting the MCExpr members to their zero value equivalent 96*0fca6ea1SDimitry Andric // happens in reset together with (duplicated) value re-set for the 97*0fca6ea1SDimitry Andric // non-MCExpr members. 98*0fca6ea1SDimitry Andric void reset(const MachineFunction &MF); 99*0fca6ea1SDimitry Andric 100e8d8bef9SDimitry Andric /// Compute the value of the ComputePGMRsrc1 register. 101*0fca6ea1SDimitry Andric const MCExpr *getComputePGMRSrc1(const GCNSubtarget &ST, 102*0fca6ea1SDimitry Andric MCContext &Ctx) const; 103*0fca6ea1SDimitry Andric const MCExpr *getPGMRSrc1(CallingConv::ID CC, const GCNSubtarget &ST, 104*0fca6ea1SDimitry Andric MCContext &Ctx) const; 10506c3fb27SDimitry Andric 10606c3fb27SDimitry Andric /// Compute the value of the ComputePGMRsrc2 register. 107*0fca6ea1SDimitry Andric const MCExpr *getComputePGMRSrc2(MCContext &Ctx) const; 108*0fca6ea1SDimitry Andric const MCExpr *getPGMRSrc2(CallingConv::ID CC, MCContext &Ctx) const; 1090b57cec5SDimitry Andric }; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric } // namespace llvm 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_AMDGPU_SIPROGRAMINFO_H 114