@@ -33,10 +33,15 @@ struct WitnessMetadata;
3333
3434// / A plan for emitting a series of calls.
3535class CallEmission {
36+ enum class State { Emitting, Finished };
37+ State state = State::Emitting;
38+
3639public:
3740 IRGenFunction &IGF;
3841
39- private:
42+ protected:
43+ llvm::Value *selfValue;
44+
4045 // / The builtin/special arguments to pass to the call.
4146 SmallVector<llvm::Value*, 8 > Args;
4247
@@ -57,31 +62,35 @@ class CallEmission {
5762 // / RemainingArgsForCallee, at least between calls.
5863 bool EmittedCall;
5964
60- void setFromCallee ();
65+ virtual void setFromCallee ();
6166 void emitToUnmappedMemory (Address addr);
6267 void emitToUnmappedExplosion (Explosion &out);
68+ virtual void emitCallToUnmappedExplosion (llvm::CallInst *call, Explosion &out) = 0;
6369 void emitYieldsToExplosion (Explosion &out);
6470 llvm::CallInst *emitCallSite ();
6571
72+ CallEmission (IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee)
73+ : IGF(IGF), selfValue(selfValue), CurCallee(std::move(callee)) {}
74+
6675public:
67- CallEmission (IRGenFunction &IGF, Callee &&callee)
68- : IGF(IGF), CurCallee(std::move(callee)) {
69- setFromCallee ();
70- }
7176 CallEmission (const CallEmission &other) = delete ;
7277 CallEmission (CallEmission &&other);
7378 CallEmission &operator =(const CallEmission &other) = delete ;
74- ~CallEmission ();
79+ virtual ~CallEmission ();
7580
7681 const Callee &getCallee () const { return CurCallee; }
7782
7883 SubstitutionMap getSubstitutions () const {
7984 return CurCallee.getSubstitutions ();
8085 }
8186
87+ virtual void begin ();
88+ virtual void end ();
89+ virtual SILType getParameterType (unsigned index) = 0;
8290 // / Set the arguments to the function from an explosion.
83- void setArgs (Explosion &arg, bool isOutlined,
84- WitnessMetadata *witnessMetadata = nullptr );
91+ virtual void setArgs (Explosion &arg, bool isOutlined,
92+ WitnessMetadata *witnessMetadata);
93+ virtual Address getCalleeErrorSlot (SILType errorType) = 0;
8594
8695 void addAttribute (unsigned Index, llvm::Attribute::AttrKind Attr);
8796
@@ -100,6 +109,9 @@ class CallEmission {
100109 }
101110};
102111
112+ std::unique_ptr<CallEmission>
113+ getCallEmission (IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee);
114+
103115} // end namespace irgen
104116} // end namespace swift
105117
0 commit comments