@@ -566,6 +566,8 @@ class NodePrinter {
566
566
case Node::Kind::CanonicalPrespecializedGenericTypeCachingOnceToken:
567
567
case Node::Kind::AsyncFunctionPointer:
568
568
case Node::Kind::AutoDiffFunction:
569
+ case Node::Kind::AutoDiffSelfReorderingReabstractionThunk:
570
+ case Node::Kind::AutoDiffSubsetParametersThunk:
569
571
case Node::Kind::AutoDiffFunctionKind:
570
572
case Node::Kind::IndexSubset:
571
573
return false ;
@@ -1738,17 +1740,29 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
1738
1740
return nullptr ;
1739
1741
}
1740
1742
case Node::Kind::AutoDiffFunction: {
1741
- auto childIt = Node-> begin () ;
1742
- auto original = *childIt++;
1743
- NodePointer optionalGenSig =
1744
- (*childIt)-> getKind () == Node::Kind::DependentGenericSignature
1745
- ? *childIt++ : nullptr ;
1746
- auto kind = *childIt++ ;
1747
- auto paramIndices = *childIt++ ;
1748
- auto resultIndices = *childIt++ ;
1743
+ unsigned prefixEndIndex = 0 ;
1744
+ while (prefixEndIndex != Node-> getNumChildren () &&
1745
+ Node-> getChild (prefixEndIndex)-> getKind ()
1746
+ != Node::Kind::AutoDiffFunctionKind)
1747
+ ++prefixEndIndex ;
1748
+ auto kind = Node-> getChild (prefixEndIndex) ;
1749
+ auto paramIndices = Node-> getChild (prefixEndIndex + 1 ) ;
1750
+ auto resultIndices = Node-> getChild (prefixEndIndex + 2 ) ;
1749
1751
print (kind);
1750
1752
Printer << " of " ;
1751
- print (original);
1753
+ NodePointer optionalGenSig = nullptr ;
1754
+ for (unsigned i = 0 ; i < prefixEndIndex; ++i) {
1755
+ // The last node may be a generic signature. If so, print it later.
1756
+ if (i == prefixEndIndex - 1 &&
1757
+ Node->getChild (i)->getKind ()
1758
+ == Node::Kind::DependentGenericSignature) {
1759
+ optionalGenSig = Node->getChild (i);
1760
+ break ;
1761
+ }
1762
+ print (Node->getChild (i));
1763
+ }
1764
+ if (Options.ShortenThunk )
1765
+ return nullptr ;
1752
1766
Printer << " with respect to parameters " ;
1753
1767
print (paramIndices);
1754
1768
Printer << " and results " ;
@@ -1759,6 +1773,61 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
1759
1773
}
1760
1774
return nullptr ;
1761
1775
}
1776
+ case Node::Kind::AutoDiffSelfReorderingReabstractionThunk: {
1777
+ Printer << " autodiff self-reordering reabstraction thunk " ;
1778
+ auto childIt = Node->begin ();
1779
+ auto fromType = *childIt++;
1780
+ auto toType = *childIt++;
1781
+ if (Options.ShortenThunk ) {
1782
+ Printer << " for " ;
1783
+ print (fromType);
1784
+ return nullptr ;
1785
+ }
1786
+ NodePointer optionalGenSig =
1787
+ (*childIt)->getKind () == Node::Kind::DependentGenericSignature
1788
+ ? *childIt++ : nullptr ;
1789
+ Printer << " for " ;
1790
+ print (*childIt++); // kind
1791
+ if (optionalGenSig) {
1792
+ print (optionalGenSig);
1793
+ Printer << ' ' ;
1794
+ }
1795
+ Printer << " from " ;
1796
+ print (fromType);
1797
+ Printer << " to " ;
1798
+ print (toType);
1799
+ return nullptr ;
1800
+ }
1801
+ case Node::Kind::AutoDiffSubsetParametersThunk: {
1802
+ Printer << " autodiff subset parameters thunk for " ;
1803
+ auto currentIndex = Node->getNumChildren () - 1 ;
1804
+ auto toParamIndices = Node->getChild (currentIndex--);
1805
+ auto resultIndices = Node->getChild (currentIndex--);
1806
+ auto paramIndices = Node->getChild (currentIndex--);
1807
+ auto kind = Node->getChild (currentIndex--);
1808
+ print (kind);
1809
+ Printer << " from " ;
1810
+ // Print the "from" thing.
1811
+ if (currentIndex == 0 ) {
1812
+ print (Node->getFirstChild ()); // the "from" type
1813
+ } else {
1814
+ for (unsigned i = 0 ; i < currentIndex; ++i) // the "from" global
1815
+ print (Node->getChild (i));
1816
+ }
1817
+ if (Options.ShortenThunk )
1818
+ return nullptr ;
1819
+ Printer << " with respect to parameters " ;
1820
+ print (paramIndices);
1821
+ Printer << " and results " ;
1822
+ print (resultIndices);
1823
+ Printer << " to parameters " ;
1824
+ print (toParamIndices);
1825
+ if (currentIndex > 0 ) {
1826
+ Printer << " of type " ;
1827
+ print (Node->getChild (currentIndex)); // "to" type
1828
+ }
1829
+ return nullptr ;
1830
+ }
1762
1831
case Node::Kind::AutoDiffFunctionKind: {
1763
1832
auto kind = (AutoDiffFunctionKind)Node->getIndex ();
1764
1833
switch (kind) {
0 commit comments