Skip to content

Commit c6d0f3a

Browse files
committed
[CIR][CodeGen][NFC] Target-independent ABI handling for SpirKernel call conv
1 parent 83d5272 commit c6d0f3a

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,10 @@ mlir::Type CIRGenTypes::ConvertType(QualType T) {
743743
return ResultType;
744744
}
745745

746+
namespace cir {
747+
void computeSPIRKernelABIInfo(CIRGenModule &CGM, CIRGenFunctionInfo &FI);
748+
} // namespace cir
749+
746750
const CIRGenFunctionInfo &CIRGenTypes::arrangeCIRFunctionInfo(
747751
CanQualType resultType, FnInfoOpts opts,
748752
llvm::ArrayRef<CanQualType> argTypes, FunctionType::ExtInfo info,
@@ -774,11 +778,16 @@ const CIRGenFunctionInfo &CIRGenTypes::arrangeCIRFunctionInfo(
774778
(void)inserted;
775779
assert(inserted && "Recursively being processed?");
776780

777-
// Compute ABI inforamtion.
778-
assert(info.getCC() != clang::CallingConv::CC_SpirFunction && "NYI");
779-
assert(info.getCC() != CC_Swift && info.getCC() != CC_SwiftAsync &&
780-
"Swift NYI");
781-
getABIInfo().computeInfo(*FI);
781+
// Compute ABI information.
782+
if (CC == mlir::cir::CallingConv::SpirKernel) {
783+
// Force target independent argument handling for the host visible
784+
// kernel functions.
785+
computeSPIRKernelABIInfo(CGM, *FI);
786+
} else if (info.getCC() == CC_Swift || info.getCC() == CC_SwiftAsync) {
787+
llvm_unreachable("Swift NYI");
788+
} else {
789+
getABIInfo().computeInfo(*FI);
790+
}
782791

783792
// Loop over all of the computed argument and return value info. If any of
784793
// them are direct or extend without a specified coerce type, specify the

clang/lib/CIR/CodeGen/TargetInfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ class SPIRVABIInfo : public CommonSPIRABIInfo {
264264
}
265265
};
266266
} // namespace
267+
268+
namespace cir {
269+
void computeSPIRKernelABIInfo(CIRGenModule &CGM, CIRGenFunctionInfo &FI) {
270+
if (CGM.getTarget().getTriple().isSPIRV())
271+
SPIRVABIInfo(CGM.getTypes()).computeInfo(FI);
272+
else
273+
CommonSPIRABIInfo(CGM.getTypes()).computeInfo(FI);
274+
}
275+
} // namespace cir
276+
267277
namespace {
268278

269279
class CommonSPIRTargetCIRGenInfo : public TargetCIRGenInfo {

0 commit comments

Comments
 (0)