Swift Bridging: use C++ instead of C bridging for the optimizer

This commit is contained in:
Erik Eckstein
2023-03-21 13:50:22 +01:00
parent a092ecb5c2
commit 010efc1ca6
18 changed files with 554 additions and 671 deletions

View File

@@ -336,42 +336,11 @@ void BasicCalleeAnalysis::print(llvm::raw_ostream &os) const {
// Swift Bridging
//===----------------------------------------------------------------------===//
BridgedCalleeList CalleeAnalysis_getCallees(BridgedCalleeAnalysis calleeAnalysis,
BridgedValue callee) {
BasicCalleeAnalysis *bca = static_cast<BasicCalleeAnalysis *>(calleeAnalysis.bca);
CalleeList cl = bca->getCalleeListOfValue(callee.getSILValue());
return {cl.getOpaquePtr(), cl.getOpaqueKind(), cl.isIncomplete()};
}
static BridgedCalleeAnalysis::IsDeinitBarrierFn instructionIsDeinitBarrierFunction;
static BridgedCalleeAnalysis::GetMemBehvaiorFn getMemBehvaiorFunction = nullptr;
BridgedCalleeList CalleeAnalysis_getDestructors(BridgedCalleeAnalysis calleeAnalysis,
SILType type,
SwiftInt isExactType) {
BasicCalleeAnalysis *bca = static_cast<BasicCalleeAnalysis *>(calleeAnalysis.bca);
CalleeList cl = bca->getDestructors(type, isExactType != 0);
return {cl.getOpaquePtr(), cl.getOpaqueKind(), cl.isIncomplete()};
}
SwiftInt BridgedFunctionArray_size(BridgedCalleeList callees) {
CalleeList cl = CalleeList::fromOpaque(callees.opaquePtr, callees.kind,
callees.incomplete);
return cl.end() - cl.begin();
}
BridgedFunction BridgedFunctionArray_get(BridgedCalleeList callees,
SwiftInt index) {
CalleeList cl = CalleeList::fromOpaque(callees.opaquePtr, callees.kind,
callees.incomplete);
auto iter = cl.begin() + index;
assert(index >= 0 && iter < cl.end());
return {*iter};
}
static InstructionIsDeinitBarrierFn instructionIsDeinitBarrierFunction;
static CalleeAnalysisGetMemBehvaiorFn getMemBehvaiorFunction = nullptr;
void CalleeAnalysis_register(
InstructionIsDeinitBarrierFn instructionIsDeinitBarrierFn,
CalleeAnalysisGetMemBehvaiorFn getMemBehvaiorFn) {
void BridgedCalleeAnalysis::registerAnalysis(IsDeinitBarrierFn instructionIsDeinitBarrierFn,
GetMemBehvaiorFn getMemBehvaiorFn) {
instructionIsDeinitBarrierFunction = instructionIsDeinitBarrierFn;
getMemBehvaiorFunction = getMemBehvaiorFn;
}