@@ -135,7 +135,7 @@ struct ValueSet : IntrusiveSet {
135
135
/// This type should be a move-only type, but unfortunately we don't have move-only
136
136
/// types yet. Therefore it's needed to call `deinitialize()` explicitly to
137
137
/// destruct this data structure, e.g. in a `defer {}` block.
138
- struct InstructionSet : IntrusiveSet {
138
+ struct SpecificInstructionSet < InstType : Instruction > : IntrusiveSet {
139
139
140
140
private let context : BridgedPassContext
141
141
private let bridged : BridgedNodeSet
@@ -145,25 +145,25 @@ struct InstructionSet : IntrusiveSet {
145
145
self . bridged = self . context. allocNodeSet ( )
146
146
}
147
147
148
- func contains( _ inst: Instruction ) -> Bool {
148
+ func contains( _ inst: InstType ) -> Bool {
149
149
bridged. containsInstruction ( inst. bridged)
150
150
}
151
151
152
152
/// Returns true if `inst` was not contained in the set before inserting.
153
153
@discardableResult
154
- mutating func insert( _ inst: Instruction ) -> Bool {
154
+ mutating func insert( _ inst: InstType ) -> Bool {
155
155
bridged. insertInstruction ( inst. bridged)
156
156
}
157
157
158
- mutating func erase( _ inst: Instruction ) {
158
+ mutating func erase( _ inst: InstType ) {
159
159
bridged. eraseInstruction ( inst. bridged)
160
160
}
161
161
162
162
var description : String {
163
163
let function = bridged. getFunction ( ) . function
164
164
var d = " { \n "
165
- for inst in function. instructions {
166
- if contains ( inst) {
165
+ for i in function. instructions {
166
+ if let inst = i as? InstType , contains ( inst) {
167
167
d += inst. description + " \n "
168
168
}
169
169
}
@@ -177,6 +177,8 @@ struct InstructionSet : IntrusiveSet {
177
177
}
178
178
}
179
179
180
+ typealias InstructionSet = SpecificInstructionSet < Instruction >
181
+
180
182
/// A set of operands.
181
183
///
182
184
/// This is an extremely efficient implementation which does not need memory
0 commit comments