================ @@ -771,18 +885,38 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo &ProgInfo, return false; }; - ProgInfo.NumArchVGPR = CreateExpr(Info.NumVGPR); - ProgInfo.NumAccVGPR = CreateExpr(Info.NumAGPR); - ProgInfo.NumVGPR = CreateExpr(Info.getTotalNumVGPRs(STM)); - ProgInfo.AccumOffset = - CreateExpr(alignTo(std::max(1, Info.NumVGPR), 4) / 4 - 1); + auto GetSymRefExpr = + [&](MCResourceInfo::ResourceInfoKind RIK) -> const MCExpr * { + MCSymbol *Sym = RI->getSymbol(MF.getName(), RIK); + return MCSymbolRefExpr::create(Sym, Ctx); + }; + + const MCExpr *ConstFour = MCConstantExpr::create(4, Ctx); + const MCExpr *ConstOne = MCConstantExpr::create(1, Ctx); + + using RIK = MCResourceInfo::ResourceInfoKind; + ProgInfo.NumArchVGPR = GetSymRefExpr(RIK::RIK_NumVGPR); + ProgInfo.NumAccVGPR = GetSymRefExpr(RIK::RIK_NumAGPR); + ProgInfo.NumVGPR = AMDGPUMCExpr::createTotalNumVGPR( + ProgInfo.NumAccVGPR, ProgInfo.NumArchVGPR, Ctx); + + // AccumOffset computed for the MCExpr equivalent of: + // alignTo(std::max(1, Info.NumVGPR), 4) / 4 - 1; + ProgInfo.AccumOffset = MCBinaryExpr::createSub( + MCBinaryExpr::createDiv( + AMDGPUMCExpr::createAlignTo( + AMDGPUMCExpr::createMax({ConstOne, ProgInfo.NumArchVGPR}, Ctx), + ConstFour, Ctx), + ConstFour, Ctx), + ConstOne, Ctx); ---------------- arsenm wrote:
Temporary variables and avoid so much wrapping? Move to computeAccumOffset helper? https://github.com/llvm/llvm-project/pull/102913 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits