File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,32 @@ class BasicBlockData {
213
213
}
214
214
return data[getIndex (block)];
215
215
}
216
+
217
+ // / Look up the state associated with \p block. Returns nullptr upon failure.
218
+ NullablePtr<Data> get (SILBasicBlock *block) const {
219
+ if (block->index < 0 )
220
+ return {nullptr };
221
+ Data *d = &const_cast <BasicBlockData *>(this )->data [getIndex (block)];
222
+ return NullablePtr<Data>(d);
223
+ }
224
+
225
+ // / If \p block is a new block, i.e. created after this BasicBlockData was
226
+ // / constructed, creates a new Data by calling
227
+ // / Data(std::forward<ArgTypes>(Args)...).
228
+ template <typename ... ArgTypes>
229
+ std::pair<Data *, bool > try_emplace (SILBasicBlock *block,
230
+ ArgTypes &&...Args) {
231
+ if (block->index != 0 ) {
232
+ return {&data[getIndex (block)], false };
233
+ }
234
+
235
+ assert (validForBlockOrder == function->BlockListChangeIdx &&
236
+ " BasicBlockData invalid because the function's block list changed" );
237
+ validForBlockOrder = ++function->BlockListChangeIdx ;
238
+ block->index = data.size ();
239
+ data.emplace_back (std::forward<ArgTypes>(Args)...);
240
+ return {&data.back (), true };
241
+ }
216
242
};
217
243
218
244
} // end swift namespace
You can’t perform that action at this time.
0 commit comments