|
29 | 29 | #include "TargetInfo/AMDGPUTargetInfo.h"
|
30 | 30 | #include "Utils/AMDGPUBaseInfo.h"
|
31 | 31 | #include "Utils/AMDKernelCodeTUtils.h"
|
| 32 | +#include "Utils/SIDefinesUtils.h" |
32 | 33 | #include "llvm/Analysis/OptimizationRemarkEmitter.h"
|
33 | 34 | #include "llvm/BinaryFormat/ELF.h"
|
34 | 35 | #include "llvm/CodeGen/MachineFrameInfo.h"
|
@@ -1234,41 +1235,49 @@ void AMDGPUAsmPrinter::EmitPALMetadata(const MachineFunction &MF,
|
1234 | 1235 | auto &Ctx = MF.getContext();
|
1235 | 1236 |
|
1236 | 1237 | MD->setEntryPoint(CC, MF.getFunction().getName());
|
1237 |
| - MD->setNumUsedVgprs( |
1238 |
| - CC, getMCExprValue(CurrentProgramInfo.NumVGPRsForWavesPerEU, Ctx)); |
| 1238 | + MD->setNumUsedVgprs(CC, CurrentProgramInfo.NumVGPRsForWavesPerEU, Ctx); |
1239 | 1239 |
|
1240 | 1240 | // Only set AGPRs for supported devices
|
1241 | 1241 | const GCNSubtarget &STM = MF.getSubtarget<GCNSubtarget>();
|
1242 | 1242 | if (STM.hasMAIInsts()) {
|
1243 |
| - MD->setNumUsedAgprs(CC, getMCExprValue(CurrentProgramInfo.NumAccVGPR, Ctx)); |
| 1243 | + MD->setNumUsedAgprs(CC, CurrentProgramInfo.NumAccVGPR); |
1244 | 1244 | }
|
1245 | 1245 |
|
1246 |
| - MD->setNumUsedSgprs( |
1247 |
| - CC, getMCExprValue(CurrentProgramInfo.NumSGPRsForWavesPerEU, Ctx)); |
| 1246 | + MD->setNumUsedSgprs(CC, CurrentProgramInfo.NumSGPRsForWavesPerEU, Ctx); |
1248 | 1247 | if (MD->getPALMajorVersion() < 3) {
|
1249 |
| - MD->setRsrc1(CC, CurrentProgramInfo.getPGMRSrc1(CC, STM)); |
| 1248 | + MD->setRsrc1(CC, CurrentProgramInfo.getPGMRSrc1(CC, STM, Ctx), Ctx); |
1250 | 1249 | if (AMDGPU::isCompute(CC)) {
|
1251 |
| - MD->setRsrc2(CC, CurrentProgramInfo.getComputePGMRSrc2()); |
| 1250 | + MD->setRsrc2(CC, CurrentProgramInfo.getComputePGMRSrc2(Ctx), Ctx); |
1252 | 1251 | } else {
|
1253 |
| - if (getMCExprValue(CurrentProgramInfo.ScratchBlocks, Ctx) > 0) |
1254 |
| - MD->setRsrc2(CC, S_00B84C_SCRATCH_EN(1)); |
| 1252 | + const MCExpr *HasScratchBlocks = |
| 1253 | + MCBinaryExpr::createGT(CurrentProgramInfo.ScratchBlocks, |
| 1254 | + MCConstantExpr::create(0, Ctx), Ctx); |
| 1255 | + auto [Shift, Mask] = getShiftMask(C_00B84C_SCRATCH_EN); |
| 1256 | + MD->setRsrc2(CC, maskShiftSet(HasScratchBlocks, Mask, Shift, Ctx), Ctx); |
1255 | 1257 | }
|
1256 | 1258 | } else {
|
1257 | 1259 | MD->setHwStage(CC, ".debug_mode", (bool)CurrentProgramInfo.DebugMode);
|
1258 |
| - MD->setHwStage(CC, ".scratch_en", |
1259 |
| - (bool)getMCExprValue(CurrentProgramInfo.ScratchEnable, Ctx)); |
| 1260 | + MD->setHwStage(CC, ".scratch_en", msgpack::Type::Boolean, |
| 1261 | + CurrentProgramInfo.ScratchEnable); |
1260 | 1262 | EmitPALMetadataCommon(MD, CurrentProgramInfo, CC, STM);
|
1261 | 1263 | }
|
1262 | 1264 |
|
1263 | 1265 | // ScratchSize is in bytes, 16 aligned.
|
1264 | 1266 | MD->setScratchSize(
|
1265 |
| - CC, alignTo(getMCExprValue(CurrentProgramInfo.ScratchSize, Ctx), 16)); |
| 1267 | + CC, |
| 1268 | + AMDGPUVariadicMCExpr::createAlignTo(CurrentProgramInfo.ScratchSize, |
| 1269 | + MCConstantExpr::create(16, Ctx), Ctx), |
| 1270 | + Ctx); |
| 1271 | + |
1266 | 1272 | if (MF.getFunction().getCallingConv() == CallingConv::AMDGPU_PS) {
|
1267 | 1273 | unsigned ExtraLDSSize = STM.getGeneration() >= AMDGPUSubtarget::GFX11
|
1268 | 1274 | ? divideCeil(CurrentProgramInfo.LDSBlocks, 2)
|
1269 | 1275 | : CurrentProgramInfo.LDSBlocks;
|
1270 | 1276 | if (MD->getPALMajorVersion() < 3) {
|
1271 |
| - MD->setRsrc2(CC, S_00B02C_EXTRA_LDS_SIZE(ExtraLDSSize)); |
| 1277 | + MD->setRsrc2( |
| 1278 | + CC, |
| 1279 | + MCConstantExpr::create(S_00B02C_EXTRA_LDS_SIZE(ExtraLDSSize), Ctx), |
| 1280 | + Ctx); |
1272 | 1281 | MD->setSpiPsInputEna(MFI->getPSInputEnable());
|
1273 | 1282 | MD->setSpiPsInputAddr(MFI->getPSInputAddr());
|
1274 | 1283 | } else {
|
@@ -1315,20 +1324,19 @@ void AMDGPUAsmPrinter::emitPALFunctionMetadata(const MachineFunction &MF) {
|
1315 | 1324 |
|
1316 | 1325 | if (MD->getPALMajorVersion() < 3) {
|
1317 | 1326 | // Set compute registers
|
1318 |
| - MD->setRsrc1(CallingConv::AMDGPU_CS, |
1319 |
| - CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS, ST)); |
| 1327 | + MD->setRsrc1( |
| 1328 | + CallingConv::AMDGPU_CS, |
| 1329 | + CurrentProgramInfo.getPGMRSrc1(CallingConv::AMDGPU_CS, ST, Ctx), Ctx); |
1320 | 1330 | MD->setRsrc2(CallingConv::AMDGPU_CS,
|
1321 |
| - CurrentProgramInfo.getComputePGMRSrc2()); |
| 1331 | + CurrentProgramInfo.getComputePGMRSrc2(Ctx), Ctx); |
1322 | 1332 | } else {
|
1323 | 1333 | EmitPALMetadataCommon(MD, CurrentProgramInfo, CallingConv::AMDGPU_CS, ST);
|
1324 | 1334 | }
|
1325 | 1335 |
|
1326 | 1336 | // Set optional info
|
1327 | 1337 | MD->setFunctionLdsSize(FnName, CurrentProgramInfo.LDSSize);
|
1328 |
| - MD->setFunctionNumUsedVgprs( |
1329 |
| - FnName, getMCExprValue(CurrentProgramInfo.NumVGPRsForWavesPerEU, Ctx)); |
1330 |
| - MD->setFunctionNumUsedSgprs( |
1331 |
| - FnName, getMCExprValue(CurrentProgramInfo.NumSGPRsForWavesPerEU, Ctx)); |
| 1338 | + MD->setFunctionNumUsedVgprs(FnName, CurrentProgramInfo.NumVGPRsForWavesPerEU); |
| 1339 | + MD->setFunctionNumUsedSgprs(FnName, CurrentProgramInfo.NumSGPRsForWavesPerEU); |
1332 | 1340 | }
|
1333 | 1341 |
|
1334 | 1342 | // This is supposed to be log2(Size)
|
|
0 commit comments