@@ -959,7 +959,12 @@ class SILFunction
959
959
SILType mapTypeIntoContext (SILType type) const ;
960
960
961
961
// / Converts the given function definition to a declaration.
962
- void convertToDeclaration ();
962
+ void convertToDeclaration () {
963
+ assert (isDefinition () && " Can only convert definitions to declarations" );
964
+ clear ();
965
+ }
966
+
967
+ void clear ();
963
968
964
969
// / Return the identity substitutions necessary to forward this call if it is
965
970
// / generic.
@@ -969,9 +974,6 @@ class SILFunction
969
974
// Block List Access
970
975
// ===--------------------------------------------------------------------===//
971
976
972
- BlockListType &getBlocks () { return BlockList; }
973
- const BlockListType &getBlocks () const { return BlockList; }
974
-
975
977
using iterator = BlockListType::iterator;
976
978
using reverse_iterator = BlockListType::reverse_iterator;
977
979
using const_iterator = BlockListType::const_iterator;
@@ -995,9 +997,38 @@ class SILFunction
995
997
SILBasicBlock *createBasicBlockAfter (SILBasicBlock *afterBB);
996
998
SILBasicBlock *createBasicBlockBefore (SILBasicBlock *beforeBB);
997
999
998
- // / Splice the body of \p F into this function at end.
999
- void spliceBody (SILFunction *F) {
1000
- getBlocks ().splice (begin (), F->getBlocks ());
1000
+ // / Removes and destroys \p BB;
1001
+ void eraseBlock (SILBasicBlock *BB) {
1002
+ assert (BB->getParent () == this );
1003
+ BlockList.erase (BB);
1004
+ }
1005
+
1006
+ // / Transfer all blocks of \p F into this function, at the begin of the block
1007
+ // / list.
1008
+ void moveAllBlocksFromOtherFunction (SILFunction *F) {
1009
+ BlockList.splice (begin (), F->BlockList );
1010
+ }
1011
+
1012
+ // / Transfer \p blockInOtherFunction of another function into this function,
1013
+ // / before \p insertPointInThisFunction.
1014
+ void moveBlockFromOtherFunction (SILBasicBlock *blockInOtherFunction,
1015
+ iterator insertPointInThisFunction) {
1016
+ SILFunction *otherFunc = blockInOtherFunction->getParent ();
1017
+ assert (otherFunc != this );
1018
+ BlockList.splice (insertPointInThisFunction, otherFunc->BlockList ,
1019
+ blockInOtherFunction);
1020
+ }
1021
+
1022
+ // / Move block \p BB to immediately before the iterator \p IP.
1023
+ // /
1024
+ // / The block must be part of this function.
1025
+ void moveBlockBefore (SILBasicBlock *BB, SILFunction::iterator IP);
1026
+
1027
+ // / Move block \p BB to immediately after block \p After.
1028
+ // /
1029
+ // / The block must be part of this function.
1030
+ void moveBlockAfter (SILBasicBlock *BB, SILBasicBlock *After) {
1031
+ moveBlockBefore (BB, std::next (After->getIterator ()));
1001
1032
}
1002
1033
1003
1034
// / Return the unique basic block containing a return inst if it
0 commit comments