20
20
#include " swift/AST/ASTTypeIDs.h"
21
21
#include " swift/AST/EvaluatorDependencies.h"
22
22
#include " swift/AST/SimpleRequest.h"
23
+ #include " swift/SIL/SILDeclRef.h"
23
24
24
25
namespace swift {
25
26
@@ -40,22 +41,30 @@ template<typename Request>
40
41
void reportEvaluatedRequest (UnifiedStatsReporter &stats,
41
42
const Request &request);
42
43
44
+ using SILRefsToEmit = llvm::SmallVector<SILDeclRef, 1 >;
45
+
43
46
// / Describes a file or module to be lowered to SIL.
44
47
struct ASTLoweringDescriptor {
45
48
llvm::PointerUnion<FileUnit *, ModuleDecl *> context;
46
49
Lowering::TypeConverter &conv;
47
50
const SILOptions &opts;
48
51
52
+ // / A specific set of SILDeclRefs to emit. If set, only these refs will be
53
+ // / emitted. Otherwise the entire \c context will be emitted.
54
+ Optional<SILRefsToEmit> refsToEmit;
55
+
49
56
friend llvm::hash_code hash_value (const ASTLoweringDescriptor &owner) {
50
57
return llvm::hash_combine (owner.context , (void *)&owner.conv ,
51
- (void *)&owner.opts );
58
+ (void *)&owner.opts ,
59
+ owner.refsToEmit );
52
60
}
53
61
54
62
friend bool operator ==(const ASTLoweringDescriptor &lhs,
55
63
const ASTLoweringDescriptor &rhs) {
56
64
return lhs.context == rhs.context &&
57
65
&lhs.conv == &rhs.conv &&
58
- &lhs.opts == &rhs.opts ;
66
+ &lhs.opts == &rhs.opts &&
67
+ lhs.refsToEmit == rhs.refsToEmit ;
59
68
}
60
69
61
70
friend bool operator !=(const ASTLoweringDescriptor &lhs,
@@ -65,14 +74,16 @@ struct ASTLoweringDescriptor {
65
74
66
75
public:
67
76
static ASTLoweringDescriptor
68
- forFile (FileUnit &sf, Lowering::TypeConverter &conv, const SILOptions &opts) {
69
- return ASTLoweringDescriptor{&sf, conv, opts};
77
+ forFile (FileUnit &sf, Lowering::TypeConverter &conv, const SILOptions &opts,
78
+ Optional<SILRefsToEmit> refsToEmit = None) {
79
+ return ASTLoweringDescriptor{&sf, conv, opts, refsToEmit};
70
80
}
71
81
72
- static ASTLoweringDescriptor forWholeModule (ModuleDecl *mod,
73
- Lowering::TypeConverter &conv,
74
- const SILOptions &opts) {
75
- return ASTLoweringDescriptor{mod, conv, opts};
82
+ static ASTLoweringDescriptor
83
+ forWholeModule (ModuleDecl *mod, Lowering::TypeConverter &conv,
84
+ const SILOptions &opts,
85
+ Optional<SILRefsToEmit> refsToEmit = None) {
86
+ return ASTLoweringDescriptor{mod, conv, opts, refsToEmit};
76
87
}
77
88
78
89
// / Retrieves the files to generate SIL for. If the descriptor is configured
0 commit comments