Skip to content

Commit

Permalink
[CIR][CodeGen][NFC] Target-independent ABI handling for SpirKernel ca…
Browse files Browse the repository at this point in the history
…ll conv
  • Loading branch information
seven-mile committed Aug 8, 2024
1 parent 83d5272 commit 5fdef60
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
15 changes: 10 additions & 5 deletions clang/lib/CIR/CodeGen/CIRGenTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,11 +774,16 @@ const CIRGenFunctionInfo &CIRGenTypes::arrangeCIRFunctionInfo(
(void)inserted;
assert(inserted && "Recursively being processed?");

// Compute ABI inforamtion.
assert(info.getCC() != clang::CallingConv::CC_SpirFunction && "NYI");
assert(info.getCC() != CC_Swift && info.getCC() != CC_SwiftAsync &&
"Swift NYI");
getABIInfo().computeInfo(*FI);
// Compute ABI information.
if (CC == mlir::cir::CallingConv::SpirKernel) {
// Force target independent argument handling for the host visible
// kernel functions.
computeSPIRKernelABIInfo(CGM, *FI);
} else if (info.getCC() == CC_Swift || info.getCC() == CC_SwiftAsync) {
llvm_unreachable("Swift NYI");
} else {
getABIInfo().computeInfo(*FI);
}

// Loop over all of the computed argument and return value info. If any of
// them are direct or extend without a specified coerce type, specify the
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/CIR/CodeGen/TargetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,16 @@ class SPIRVABIInfo : public CommonSPIRABIInfo {
}
};
} // namespace

namespace cir {
void computeSPIRKernelABIInfo(CIRGenModule &CGM, CIRGenFunctionInfo &FI) {
if (CGM.getTarget().getTriple().isSPIRV())
SPIRVABIInfo(CGM.getTypes()).computeInfo(FI);
else
CommonSPIRABIInfo(CGM.getTypes()).computeInfo(FI);
}
} // namespace cir

namespace {

class CommonSPIRTargetCIRGenInfo : public TargetCIRGenInfo {
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/CIR/CodeGen/TargetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class TargetCIRGenInfo {
virtual ~TargetCIRGenInfo() {}
};

void computeSPIRKernelABIInfo(CIRGenModule &CGM, CIRGenFunctionInfo &FI);

} // namespace cir

#endif

0 comments on commit 5fdef60

Please sign in to comment.