@@ -135,7 +135,7 @@ struct ValueSet : IntrusiveSet {
135135/// This type should be a move-only type, but unfortunately we don't have move-only
136136/// types yet. Therefore it's needed to call `deinitialize()` explicitly to
137137/// destruct this data structure, e.g. in a `defer {}` block.
138- struct InstructionSet : IntrusiveSet {
138+ struct SpecificInstructionSet < InstType : Instruction > : IntrusiveSet {
139139
140140 private let context : BridgedPassContext
141141 private let bridged : BridgedNodeSet
@@ -145,25 +145,25 @@ struct InstructionSet : IntrusiveSet {
145145 self . bridged = self . context. allocNodeSet ( )
146146 }
147147
148- func contains( _ inst: Instruction ) -> Bool {
148+ func contains( _ inst: InstType ) -> Bool {
149149 bridged. containsInstruction ( inst. bridged)
150150 }
151151
152152 /// Returns true if `inst` was not contained in the set before inserting.
153153 @discardableResult
154- mutating func insert( _ inst: Instruction ) -> Bool {
154+ mutating func insert( _ inst: InstType ) -> Bool {
155155 bridged. insertInstruction ( inst. bridged)
156156 }
157157
158- mutating func erase( _ inst: Instruction ) {
158+ mutating func erase( _ inst: InstType ) {
159159 bridged. eraseInstruction ( inst. bridged)
160160 }
161161
162162 var description : String {
163163 let function = bridged. getFunction ( ) . function
164164 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) {
167167 d += inst. description + " \n "
168168 }
169169 }
@@ -177,6 +177,8 @@ struct InstructionSet : IntrusiveSet {
177177 }
178178}
179179
180+ typealias InstructionSet = SpecificInstructionSet < Instruction >
181+
180182/// A set of operands.
181183///
182184/// This is an extremely efficient implementation which does not need memory
0 commit comments