Skip to content

Commit 27d7abc

Browse files
committed
Parse/print [serialized] flag.
Manually verified parsing/printing. Chose not to add additional test for now to keep the test small.
1 parent 2073f86 commit 27d7abc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/ParseSIL/ParseSIL.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6808,6 +6808,7 @@ static void convertRequirements(Parser &P, SILFunction *F,
68086808

68096809
/// decl-sil-differentiability-witness ::=
68106810
/// 'sil_differentiability_witness'
6811+
/// ('[' 'serialized' ']')?
68116812
/// '[' 'parameters' index-subset ']'
68126813
/// '[' 'results' index-subset ']'
68136814
/// ('[' 'where' derivatve-generic-signature-requirements ']')?
@@ -6830,6 +6831,17 @@ bool SILParserTUState::parseSILDifferentiabilityWitness(Parser &P) {
68306831
if (!linkage)
68316832
linkage = SILLinkage::PublicExternal;
68326833

6834+
// Parse '[serialized]' flag (optional).
6835+
bool isSerialized = false;
6836+
if (P.Tok.is(tok::l_square) && P.peekToken().is(tok::identifier) &&
6837+
P.peekToken().getText() == "serialized") {
6838+
isSerialized = true;
6839+
P.consumeToken(tok::l_square);
6840+
P.consumeToken(tok::identifier);
6841+
if (P.parseToken(tok::r_square, diag::sil_diff_witness_expected_token, "]"))
6842+
return true;
6843+
}
6844+
68336845
Scope scope(&P, ScopeKind::TopLevel);
68346846
Scope body(&P, ScopeKind::FunctionBody);
68356847

@@ -6970,8 +6982,6 @@ bool SILParserTUState::parseSILDifferentiabilityWitness(Parser &P) {
69706982
return true;
69716983
}
69726984

6973-
// TODO(TF-893): Parse `isSerialized` flag.
6974-
bool isSerialized = false;
69756985
SILDifferentiabilityWitness::create(
69766986
M, *linkage, originalFn, parameterIndices, resultIndices,
69776987
derivativeGenSig, jvp, vjp, isSerialized);

lib/SIL/SILPrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,6 +3066,9 @@ void SILDifferentiabilityWitness::print(
30663066
// sil_differentiability_witness (linkage)?
30673067
OS << "sil_differentiability_witness ";
30683068
printLinkage(OS, linkage, ForDefinition);
3069+
// ([serialized])?
3070+
if (isSerialized())
3071+
OS << "[serialized] ";
30693072
// [parameters ...]
30703073
OS << "[parameters ";
30713074
interleave(getParameterIndices()->getIndices(),

0 commit comments

Comments
 (0)