@@ -33,10 +33,15 @@ struct WitnessMetadata;
33
33
34
34
// / A plan for emitting a series of calls.
35
35
class CallEmission {
36
+ enum class State { Emitting, Finished };
37
+ State state = State::Emitting;
38
+
36
39
public:
37
40
IRGenFunction &IGF;
38
41
39
- private:
42
+ protected:
43
+ llvm::Value *selfValue;
44
+
40
45
// / The builtin/special arguments to pass to the call.
41
46
SmallVector<llvm::Value*, 8 > Args;
42
47
@@ -57,31 +62,35 @@ class CallEmission {
57
62
// / RemainingArgsForCallee, at least between calls.
58
63
bool EmittedCall;
59
64
60
- void setFromCallee ();
65
+ virtual void setFromCallee ();
61
66
void emitToUnmappedMemory (Address addr);
62
67
void emitToUnmappedExplosion (Explosion &out);
68
+ virtual void emitCallToUnmappedExplosion (llvm::CallInst *call, Explosion &out) = 0;
63
69
void emitYieldsToExplosion (Explosion &out);
64
70
llvm::CallInst *emitCallSite ();
65
71
72
+ CallEmission (IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee)
73
+ : IGF(IGF), selfValue(selfValue), CurCallee(std::move(callee)) {}
74
+
66
75
public:
67
- CallEmission (IRGenFunction &IGF, Callee &&callee)
68
- : IGF(IGF), CurCallee(std::move(callee)) {
69
- setFromCallee ();
70
- }
71
76
CallEmission (const CallEmission &other) = delete ;
72
77
CallEmission (CallEmission &&other);
73
78
CallEmission &operator =(const CallEmission &other) = delete ;
74
- ~CallEmission ();
79
+ virtual ~CallEmission ();
75
80
76
81
const Callee &getCallee () const { return CurCallee; }
77
82
78
83
SubstitutionMap getSubstitutions () const {
79
84
return CurCallee.getSubstitutions ();
80
85
}
81
86
87
+ virtual void begin ();
88
+ virtual void end ();
89
+ virtual SILType getParameterType (unsigned index) = 0;
82
90
// / 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;
85
94
86
95
void addAttribute (unsigned Index, llvm::Attribute::AttrKind Attr);
87
96
@@ -100,6 +109,9 @@ class CallEmission {
100
109
}
101
110
};
102
111
112
+ std::unique_ptr<CallEmission>
113
+ getCallEmission (IRGenFunction &IGF, llvm::Value *selfValue, Callee &&callee);
114
+
103
115
} // end namespace irgen
104
116
} // end namespace swift
105
117
0 commit comments