File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 13
13
#ifndef SWIFT_SIL_WRAPPERTYPES_H
14
14
#define SWIFT_SIL_WRAPPERTYPES_H
15
15
16
+ #include " swift/SIL/SILFunction.h"
16
17
#include " swift/SIL/SILInstruction.h"
17
18
18
19
namespace swift {
@@ -361,6 +362,43 @@ class ForwardingOperation {
361
362
// operation.
362
363
bool visitForwardedValues (function_ref<bool (SILValue)> visitor);
363
364
};
365
+
366
+ enum class FixedStorageSemanticsCallKind { None, CheckIndex, GetCount };
367
+
368
+ struct FixedStorageSemanticsCall {
369
+ ApplyInst *apply = nullptr ;
370
+ FixedStorageSemanticsCallKind kind = FixedStorageSemanticsCallKind::None;
371
+
372
+ FixedStorageSemanticsCall (SILInstruction *input) {
373
+ auto *applyInst = dyn_cast<ApplyInst>(input);
374
+ if (!applyInst) {
375
+ return ;
376
+ }
377
+ auto *callee = applyInst->getReferencedFunctionOrNull ();
378
+ if (!callee) {
379
+ return ;
380
+ }
381
+ for (auto &attr : callee->getSemanticsAttrs ()) {
382
+ if (attr == " fixed_storage.check_index" ) {
383
+ apply = applyInst;
384
+ kind = FixedStorageSemanticsCallKind::CheckIndex;
385
+ break ;
386
+ } else if (attr == " fixed_storage.get_count" ) {
387
+ apply = applyInst;
388
+ kind = FixedStorageSemanticsCallKind::GetCount;
389
+ break ;
390
+ }
391
+ }
392
+ }
393
+
394
+ FixedStorageSemanticsCallKind getKind () const { return kind; }
395
+ explicit operator bool () const { return apply != nullptr ; }
396
+ const ApplyInst *operator ->() const { return apply; }
397
+ ApplyInst *operator ->() { return apply; }
398
+ };
399
+
400
+ bool isFixedStorageSemanticsCallKind (SILFunction *function);
401
+
364
402
} // end namespace swift
365
403
366
404
#endif
Original file line number Diff line number Diff line change @@ -99,3 +99,13 @@ bool ForwardingOperation::visitForwardedValues(
99
99
return visitor (args[0 ]);
100
100
});
101
101
}
102
+
103
+ bool swift::isFixedStorageSemanticsCallKind (SILFunction *function) {
104
+ for (auto &attr : function->getSemanticsAttrs ()) {
105
+ if (attr == " fixed_storage.check_index" ||
106
+ attr == " fixed_storage.get_count" ) {
107
+ return true ;
108
+ }
109
+ }
110
+ return false ;
111
+ }
You can’t perform that action at this time.
0 commit comments