@@ -249,14 +249,14 @@ void AMDGPUAsmPrinter::emitFunctionBodyEnd() {
249
249
getNameWithPrefix (KernelName, &MF->getFunction ());
250
250
getTargetStreamer ()->EmitAmdhsaKernelDescriptor (
251
251
STM, KernelName, getAmdhsaKernelDescriptor (*MF, CurrentProgramInfo),
252
- getMCExprValue ( CurrentProgramInfo.NumVGPRsForWavesPerEU , Context) ,
253
- getMCExprValue (CurrentProgramInfo. NumSGPRsForWavesPerEU , Context) -
254
- IsaInfo::getNumExtraSGPRs (
255
- &STM, getMCExprValue (CurrentProgramInfo. VCCUsed , Context),
256
- getMCExprValue ( CurrentProgramInfo.FlatUsed , Context) ,
257
- getTargetStreamer ()->getTargetID ()->isXnackOnOrAny ()),
258
- getMCExprValue (CurrentProgramInfo. VCCUsed , Context),
259
- getMCExprValue ( CurrentProgramInfo.FlatUsed , Context) );
252
+ CurrentProgramInfo.NumVGPRsForWavesPerEU ,
253
+ MCBinaryExpr::createSub (
254
+ CurrentProgramInfo. NumSGPRsForWavesPerEU ,
255
+ AMDGPUVariadicMCExpr::createExtraSGPRs (
256
+ CurrentProgramInfo.VCCUsed , CurrentProgramInfo. FlatUsed ,
257
+ getTargetStreamer ()->getTargetID ()->isXnackOnOrAny (), Context ),
258
+ Context),
259
+ CurrentProgramInfo.VCCUsed , CurrentProgramInfo. FlatUsed );
260
260
261
261
Streamer.popSection ();
262
262
}
@@ -431,9 +431,10 @@ void AMDGPUAsmPrinter::emitCommonFunctionComments(
431
431
false );
432
432
}
433
433
434
- uint16_t AMDGPUAsmPrinter::getAmdhsaKernelCodeProperties (
434
+ const MCExpr * AMDGPUAsmPrinter::getAmdhsaKernelCodeProperties (
435
435
const MachineFunction &MF) const {
436
436
const SIMachineFunctionInfo &MFI = *MF.getInfo <SIMachineFunctionInfo>();
437
+ MCContext &Ctx = MF.getContext ();
437
438
uint16_t KernelCodeProperties = 0 ;
438
439
const GCNUserSGPRUsageInfo &UserSGPRInfo = MFI.getUserSGPRInfo ();
439
440
@@ -466,11 +467,19 @@ uint16_t AMDGPUAsmPrinter::getAmdhsaKernelCodeProperties(
466
467
amdhsa::KERNEL_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32;
467
468
}
468
469
469
- if (getMCExprValue (CurrentProgramInfo.DynamicCallStack , MF.getContext ()) &&
470
- CodeObjectVersion >= AMDGPU::AMDHSA_COV5)
471
- KernelCodeProperties |= amdhsa::KERNEL_CODE_PROPERTY_USES_DYNAMIC_STACK;
472
-
473
- return KernelCodeProperties;
470
+ // CurrentProgramInfo.DynamicCallStack is a MCExpr and could be
471
+ // un-evaluatable at this point so it cannot be conditionally checked here.
472
+ // Instead, we'll directly shift the possibly unknown MCExpr into its place
473
+ // and bitwise-or it into KernelCodeProperties.
474
+ const MCExpr *KernelCodePropExpr =
475
+ MCConstantExpr::create (KernelCodeProperties, Ctx);
476
+ const MCExpr *OrValue = MCConstantExpr::create (
477
+ amdhsa::KERNEL_CODE_PROPERTY_USES_DYNAMIC_STACK_SHIFT, Ctx);
478
+ OrValue = MCBinaryExpr::createShl (CurrentProgramInfo.DynamicCallStack ,
479
+ OrValue, Ctx);
480
+ KernelCodePropExpr = MCBinaryExpr::createOr (KernelCodePropExpr, OrValue, Ctx);
481
+
482
+ return KernelCodePropExpr;
474
483
}
475
484
476
485
MCKernelDescriptor
@@ -493,11 +502,13 @@ AMDGPUAsmPrinter::getAmdhsaKernelDescriptor(const MachineFunction &MF,
493
502
494
503
KernelDescriptor.compute_pgm_rsrc1 = PI.getComputePGMRSrc1 (STM, Ctx);
495
504
KernelDescriptor.compute_pgm_rsrc2 = PI.getComputePGMRSrc2 (Ctx);
496
- KernelDescriptor.kernel_code_properties =
497
- MCConstantExpr::create (getAmdhsaKernelCodeProperties (MF), Ctx);
505
+ KernelDescriptor.kernel_code_properties = getAmdhsaKernelCodeProperties (MF);
498
506
499
- assert (STM.hasGFX90AInsts () ||
500
- getMCExprValue (CurrentProgramInfo.ComputePGMRSrc3GFX90A , Ctx) == 0 );
507
+ int64_t PGRM_Rsrc3 = 1 ;
508
+ bool EvaluatableRsrc3 =
509
+ CurrentProgramInfo.ComputePGMRSrc3GFX90A ->evaluateAsAbsolute (PGRM_Rsrc3);
510
+ assert (STM.hasGFX90AInsts () || !EvaluatableRsrc3 ||
511
+ static_cast <uint64_t >(PGRM_Rsrc3) == 0 );
501
512
KernelDescriptor.compute_pgm_rsrc3 = CurrentProgramInfo.ComputePGMRSrc3GFX90A ;
502
513
503
514
KernelDescriptor.kernarg_preload = MCConstantExpr::create (
0 commit comments