|
16 | 16 | //===----------------------------------------------------------------------===// |
17 | 17 |
|
18 | 18 | #define DEBUG_TYPE "irgensil" |
19 | | -#include "llvm/IR/DIBuilder.h" |
20 | | -#include "llvm/IR/Function.h" |
21 | | -#include "llvm/IR/Module.h" |
22 | | -#include "llvm/IR/Instructions.h" |
23 | | -#include "llvm/IR/IntrinsicInst.h" |
24 | | -#include "llvm/IR/InlineAsm.h" |
25 | | -#include "llvm/IR/Intrinsics.h" |
26 | | -#include "llvm/ADT/MapVector.h" |
27 | | -#include "llvm/ADT/SmallBitVector.h" |
28 | | -#include "llvm/ADT/TinyPtrVector.h" |
29 | | -#include "llvm/Support/SaveAndRestore.h" |
30 | | -#include "llvm/Support/Debug.h" |
31 | | -#include "llvm/Transforms/Utils/Local.h" |
32 | | -#include "clang/AST/ASTContext.h" |
33 | | -#include "clang/Basic/TargetInfo.h" |
34 | | -#include "swift/Basic/ExternalUnion.h" |
35 | | -#include "swift/Basic/Range.h" |
36 | | -#include "swift/Basic/STLExtras.h" |
37 | 19 | #include "swift/AST/ASTContext.h" |
38 | 20 | #include "swift/AST/IRGenOptions.h" |
39 | | -#include "swift/AST/Pattern.h" |
40 | 21 | #include "swift/AST/ParameterList.h" |
| 22 | +#include "swift/AST/Pattern.h" |
41 | 23 | #include "swift/AST/SubstitutionMap.h" |
42 | 24 | #include "swift/AST/Types.h" |
| 25 | +#include "swift/Basic/ExternalUnion.h" |
| 26 | +#include "swift/Basic/Range.h" |
| 27 | +#include "swift/Basic/STLExtras.h" |
43 | 28 | #include "swift/SIL/ApplySite.h" |
44 | 29 | #include "swift/SIL/Dominance.h" |
| 30 | +#include "swift/SIL/InstructionUtils.h" |
45 | 31 | #include "swift/SIL/PrettyStackTrace.h" |
46 | 32 | #include "swift/SIL/SILDebugScope.h" |
47 | 33 | #include "swift/SIL/SILDeclRef.h" |
48 | 34 | #include "swift/SIL/SILLinkage.h" |
49 | 35 | #include "swift/SIL/SILModule.h" |
50 | 36 | #include "swift/SIL/SILType.h" |
51 | 37 | #include "swift/SIL/SILVisitor.h" |
52 | | -#include "swift/SIL/InstructionUtils.h" |
| 38 | +#include "clang/AST/ASTContext.h" |
| 39 | +#include "clang/AST/DeclCXX.h" |
| 40 | +#include "clang/Basic/TargetInfo.h" |
53 | 41 | #include "clang/CodeGen/CodeGenABITypes.h" |
| 42 | +#include "clang/CodeGen/SwiftCallingConv.h" |
| 43 | +#include "llvm/ADT/MapVector.h" |
| 44 | +#include "llvm/ADT/SmallBitVector.h" |
| 45 | +#include "llvm/ADT/TinyPtrVector.h" |
| 46 | +#include "llvm/IR/DIBuilder.h" |
| 47 | +#include "llvm/IR/Function.h" |
| 48 | +#include "llvm/IR/InlineAsm.h" |
| 49 | +#include "llvm/IR/Instructions.h" |
| 50 | +#include "llvm/IR/IntrinsicInst.h" |
| 51 | +#include "llvm/IR/Intrinsics.h" |
| 52 | +#include "llvm/IR/Module.h" |
| 53 | +#include "llvm/Support/Debug.h" |
| 54 | +#include "llvm/Support/SaveAndRestore.h" |
| 55 | +#include "llvm/Transforms/Utils/Local.h" |
54 | 56 |
|
55 | 57 | #include "CallEmission.h" |
56 | 58 | #include "Explosion.h" |
@@ -990,6 +992,7 @@ class IRGenSILFunction : |
990 | 992 | void visitSuperMethodInst(SuperMethodInst *i); |
991 | 993 | void visitObjCMethodInst(ObjCMethodInst *i); |
992 | 994 | void visitObjCSuperMethodInst(ObjCSuperMethodInst *i); |
| 995 | + void visitCXXVirtualMethodInst(CXXVirtualMethodInst *i); |
993 | 996 | void visitWitnessMethodInst(WitnessMethodInst *i); |
994 | 997 |
|
995 | 998 | void visitAllocValueBufferInst(AllocValueBufferInst *i); |
@@ -5589,6 +5592,26 @@ void IRGenSILFunction::visitObjCMethodInst(swift::ObjCMethodInst *i) { |
5589 | 5592 | setLoweredObjCMethod(i, i->getMember()); |
5590 | 5593 | } |
5591 | 5594 |
|
| 5595 | +void IRGenSILFunction::visitCXXVirtualMethodInst(CXXVirtualMethodInst *i) { |
| 5596 | + auto *cxxMethod = cast<clang::CXXMethodDecl>( |
| 5597 | + i->getMember().getAbstractFunctionDecl()->getClangDecl()); |
| 5598 | + |
| 5599 | + auto signature = Signature::forCXXMethod( |
| 5600 | + IGM, cxxMethod, |
| 5601 | + i->getExtractedMethod()->getType().castTo<SILFunctionType>()); |
| 5602 | + |
| 5603 | + auto selfAddress = getLoweredAddress(i->getOperand()); |
| 5604 | + llvm::Value *self = selfAddress.getAddress(); |
| 5605 | + |
| 5606 | + auto *result = clang::CodeGen::swiftcall::lowerCXXVirtualMethodDeclReference( |
| 5607 | + IGM.getClangCGM(), cxxMethod, self, |
| 5608 | + selfAddress.getAlignment().asCharUnits(), signature.getType(), &Builder); |
| 5609 | + |
| 5610 | + setLoweredValue(i->getExtractedMethod(), FunctionPointer(result, signature)); |
| 5611 | + selfAddress = Address(self, selfAddress.getAlignment()); |
| 5612 | + setLoweredAddress(i->getAdjustedThisPtr(), selfAddress); |
| 5613 | +} |
| 5614 | + |
5592 | 5615 | void IRGenModule::emitSILStaticInitializers() { |
5593 | 5616 | SmallVector<SILFunction *, 8> StaticInitializers; |
5594 | 5617 | for (SILGlobalVariable &Global : getSILModule().getSILGlobals()) { |
|
0 commit comments