|
16 | 16 | #include "swift/AST/ProtocolConformance.h" |
17 | 17 | #include "swift/Basic/Statistic.h" |
18 | 18 | #include "swift/SIL/SILModule.h" |
| 19 | +#include "swift/SIL/SILBridgingUtils.h" |
| 20 | +#include "swift/SILOptimizer/OptimizerBridging.h" |
19 | 21 | #include "swift/SILOptimizer/Utils/InstOptUtils.h" |
20 | 22 | #include "llvm/Support/Compiler.h" |
21 | 23 |
|
@@ -318,3 +320,29 @@ void BasicCalleeAnalysis::print(llvm::raw_ostream &os) const { |
318 | 320 | } |
319 | 321 | } |
320 | 322 | } |
| 323 | + |
| 324 | +//===----------------------------------------------------------------------===// |
| 325 | +// Swift Bridging |
| 326 | +//===----------------------------------------------------------------------===// |
| 327 | + |
| 328 | +BridgedCalleeList CalleeAnalysis_getCallees(BridgedCalleeAnalysis calleeAnalysis, |
| 329 | + BridgedValue callee) { |
| 330 | + BasicCalleeAnalysis *bca = static_cast<BasicCalleeAnalysis *>(calleeAnalysis.bca); |
| 331 | + CalleeList cl = bca->getCalleeListOfValue(castToSILValue(callee)); |
| 332 | + return {cl.getOpaquePtr(), cl.getOpaqueKind(), cl.isIncomplete()}; |
| 333 | +} |
| 334 | + |
| 335 | +SwiftInt BridgedFunctionArray_size(BridgedCalleeList callees) { |
| 336 | + CalleeList cl = CalleeList::fromOpaque(callees.opaquePtr, callees.kind, |
| 337 | + callees.incomplete); |
| 338 | + return cl.end() - cl.begin(); |
| 339 | +} |
| 340 | + |
| 341 | +BridgedFunction BridgedFunctionArray_get(BridgedCalleeList callees, |
| 342 | + SwiftInt index) { |
| 343 | + CalleeList cl = CalleeList::fromOpaque(callees.opaquePtr, callees.kind, |
| 344 | + callees.incomplete); |
| 345 | + auto iter = cl.begin() + index; |
| 346 | + assert(index >= 0 && iter < cl.end()); |
| 347 | + return {*iter}; |
| 348 | +} |
0 commit comments