Skip to content

Commit 797336b

Browse files
authored
Revert "[AMDGPU] MCExpr-ify MC layer kernel descriptor" (llvm#86151)
Reverts llvm#80855
1 parent 4bf8dc1 commit 797336b

19 files changed

+304
-1988
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "AMDKernelCodeT.h"
2323
#include "GCNSubtarget.h"
2424
#include "MCTargetDesc/AMDGPUInstPrinter.h"
25-
#include "MCTargetDesc/AMDGPUMCKernelDescriptor.h"
2625
#include "MCTargetDesc/AMDGPUTargetStreamer.h"
2726
#include "R600AsmPrinter.h"
2827
#include "SIMachineFunctionInfo.h"
@@ -429,43 +428,38 @@ uint16_t AMDGPUAsmPrinter::getAmdhsaKernelCodeProperties(
429428
return KernelCodeProperties;
430429
}
431430

432-
MCKernelDescriptor
433-
AMDGPUAsmPrinter::getAmdhsaKernelDescriptor(const MachineFunction &MF,
434-
const SIProgramInfo &PI) const {
431+
amdhsa::kernel_descriptor_t AMDGPUAsmPrinter::getAmdhsaKernelDescriptor(
432+
const MachineFunction &MF,
433+
const SIProgramInfo &PI) const {
435434
const GCNSubtarget &STM = MF.getSubtarget<GCNSubtarget>();
436435
const Function &F = MF.getFunction();
437436
const SIMachineFunctionInfo *Info = MF.getInfo<SIMachineFunctionInfo>();
438-
MCContext &Ctx = MF.getContext();
439437

440-
MCKernelDescriptor KernelDescriptor;
438+
amdhsa::kernel_descriptor_t KernelDescriptor;
439+
memset(&KernelDescriptor, 0x0, sizeof(KernelDescriptor));
441440

442441
assert(isUInt<32>(PI.ScratchSize));
443442
assert(isUInt<32>(PI.getComputePGMRSrc1(STM)));
444443
assert(isUInt<32>(PI.getComputePGMRSrc2()));
445444

446-
KernelDescriptor.group_segment_fixed_size =
447-
MCConstantExpr::create(PI.LDSSize, Ctx);
448-
KernelDescriptor.private_segment_fixed_size =
449-
MCConstantExpr::create(PI.ScratchSize, Ctx);
445+
KernelDescriptor.group_segment_fixed_size = PI.LDSSize;
446+
KernelDescriptor.private_segment_fixed_size = PI.ScratchSize;
450447

451448
Align MaxKernArgAlign;
452-
KernelDescriptor.kernarg_size = MCConstantExpr::create(
453-
STM.getKernArgSegmentSize(F, MaxKernArgAlign), Ctx);
449+
KernelDescriptor.kernarg_size = STM.getKernArgSegmentSize(F, MaxKernArgAlign);
454450

455-
KernelDescriptor.compute_pgm_rsrc1 =
456-
MCConstantExpr::create(PI.getComputePGMRSrc1(STM), Ctx);
457-
KernelDescriptor.compute_pgm_rsrc2 =
458-
MCConstantExpr::create(PI.getComputePGMRSrc2(), Ctx);
459-
KernelDescriptor.kernel_code_properties =
460-
MCConstantExpr::create(getAmdhsaKernelCodeProperties(MF), Ctx);
451+
KernelDescriptor.compute_pgm_rsrc1 = PI.getComputePGMRSrc1(STM);
452+
KernelDescriptor.compute_pgm_rsrc2 = PI.getComputePGMRSrc2();
453+
KernelDescriptor.kernel_code_properties = getAmdhsaKernelCodeProperties(MF);
461454

462455
assert(STM.hasGFX90AInsts() || CurrentProgramInfo.ComputePGMRSrc3GFX90A == 0);
463-
KernelDescriptor.compute_pgm_rsrc3 = MCConstantExpr::create(
464-
STM.hasGFX90AInsts() ? CurrentProgramInfo.ComputePGMRSrc3GFX90A : 0, Ctx);
456+
if (STM.hasGFX90AInsts())
457+
KernelDescriptor.compute_pgm_rsrc3 =
458+
CurrentProgramInfo.ComputePGMRSrc3GFX90A;
465459

466-
KernelDescriptor.kernarg_preload = MCConstantExpr::create(
467-
AMDGPU::hasKernargPreload(STM) ? Info->getNumKernargPreloadedSGPRs() : 0,
468-
Ctx);
460+
if (AMDGPU::hasKernargPreload(STM))
461+
KernelDescriptor.kernarg_preload =
462+
static_cast<uint16_t>(Info->getNumKernargPreloadedSGPRs());
469463

470464
return KernelDescriptor;
471465
}

llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ class MCCodeEmitter;
2828
class MCOperand;
2929

3030
namespace AMDGPU {
31-
struct MCKernelDescriptor;
3231
namespace HSAMD {
3332
class MetadataStreamer;
3433
}
3534
} // namespace AMDGPU
3635

36+
namespace amdhsa {
37+
struct kernel_descriptor_t;
38+
}
39+
3740
class AMDGPUAsmPrinter final : public AsmPrinter {
3841
private:
3942
unsigned CodeObjectVersion;
@@ -72,9 +75,9 @@ class AMDGPUAsmPrinter final : public AsmPrinter {
7275
uint16_t getAmdhsaKernelCodeProperties(
7376
const MachineFunction &MF) const;
7477

75-
AMDGPU::MCKernelDescriptor
76-
getAmdhsaKernelDescriptor(const MachineFunction &MF,
77-
const SIProgramInfo &PI) const;
78+
amdhsa::kernel_descriptor_t getAmdhsaKernelDescriptor(
79+
const MachineFunction &MF,
80+
const SIProgramInfo &PI) const;
7881

7982
void initTargetStreamer(Module &M);
8083

0 commit comments

Comments
 (0)