@@ -329,6 +329,30 @@ class NVPTXTargetCIRGenInfo : public TargetCIRGenInfo {
329
329
330
330
} // namespace
331
331
332
+ // ===----------------------------------------------------------------------===//
333
+ // AMDGPU ABI Implementation
334
+ // ===----------------------------------------------------------------------===//
335
+
336
+ namespace {
337
+
338
+ class AMDGPUABIInfo : public ABIInfo {
339
+ public:
340
+ AMDGPUABIInfo (CIRGenTypes &cgt) : ABIInfo(cgt) {}
341
+
342
+ cir::ABIArgInfo classifyReturnType (QualType retTy) const ;
343
+ cir::ABIArgInfo classifyArgumentType (QualType ty) const ;
344
+
345
+ void computeInfo (CIRGenFunctionInfo &fnInfo) const override ;
346
+ };
347
+
348
+ class AMDGPUTargetCIRGenInfo : public TargetCIRGenInfo {
349
+ public:
350
+ AMDGPUTargetCIRGenInfo (CIRGenTypes &cgt)
351
+ : TargetCIRGenInfo(std::make_unique<AMDGPUABIInfo>(cgt)) {}
352
+ };
353
+
354
+ } // namespace
355
+
332
356
// TODO(cir): remove the attribute once this gets used.
333
357
LLVM_ATTRIBUTE_UNUSED
334
358
static bool classifyReturnType (const CIRGenCXXABI &CXXABI,
@@ -495,6 +519,34 @@ void NVPTXABIInfo::computeInfo(CIRGenFunctionInfo &fnInfo) const {
495
519
fnInfo.getReturnInfo () = cir::ABIArgInfo::getDirect (CGT.convertType (retTy));
496
520
}
497
521
522
+ // Skeleton only. Implement when used in TargetLower stage.
523
+ cir::ABIArgInfo AMDGPUABIInfo::classifyReturnType (QualType retTy) const {
524
+ llvm_unreachable (" not yet implemented" );
525
+ }
526
+
527
+ cir::ABIArgInfo AMDGPUABIInfo::classifyArgumentType (QualType ty) const {
528
+ llvm_unreachable (" not yet implemented" );
529
+ }
530
+
531
+ void AMDGPUABIInfo::computeInfo (CIRGenFunctionInfo &fnInfo) const {
532
+ // Top level CIR has unlimited arguments and return types. Lowering for ABI
533
+ // specific concerns should happen during a lowering phase. Assume everything
534
+ // is direct for now.
535
+ for (CIRGenFunctionInfo::arg_iterator it = fnInfo.arg_begin (),
536
+ ie = fnInfo.arg_end ();
537
+ it != ie; ++it) {
538
+ if (testIfIsVoidTy (it->type ))
539
+ it->info = cir::ABIArgInfo::getIgnore ();
540
+ else
541
+ it->info = cir::ABIArgInfo::getDirect (CGT.convertType (it->type ));
542
+ }
543
+ auto retTy = fnInfo.getReturnType ();
544
+ if (testIfIsVoidTy (retTy))
545
+ fnInfo.getReturnInfo () = cir::ABIArgInfo::getIgnore ();
546
+ else
547
+ fnInfo.getReturnInfo () = cir::ABIArgInfo::getDirect (CGT.convertType (retTy));
548
+ }
549
+
498
550
ABIInfo::~ABIInfo () {}
499
551
500
552
bool ABIInfo::isPromotableIntegerTypeForABI (QualType Ty) const {
@@ -690,5 +742,9 @@ const TargetCIRGenInfo &CIRGenModule::getTargetCIRGenInfo() {
690
742
case llvm::Triple::nvptx64: {
691
743
return SetCIRGenInfo (new NVPTXTargetCIRGenInfo (genTypes));
692
744
}
745
+
746
+ case llvm::Triple::amdgcn: {
747
+ return SetCIRGenInfo (new AMDGPUTargetCIRGenInfo (genTypes));
748
+ }
693
749
}
694
750
}
0 commit comments