Phi-Funktion (Compilerbau)
Die Phi-Funktion (φ-Funktion) ist ein Konstrukt im Compilerbau.
Bei der internen Darstellung von Programmcode in der Static-Single-Assignment-Darstellung wird jede Variable nur einmal geschrieben. Da so in alternativen Zweigen verschiedene Variablen geschrieben werden, muss nach der Vereinigung des Kontrollflusses (z. B. nach einem if/then/else) das Problem gelöst werden, dass späterer Code nur auf eine Variable zugreifen kann.
Gelöst wird das Problem über die Phi-Funktion, die ihre Parameter abhängig vom tatsächlich genommenen Kontrollfluss als Ergebnis zurückgibt.
Sie ist keine deterministische Funktion, da ihr Ergebnis von nicht parametrisierten Nebeneffekten abhängt. Aus dem Ausdruck phi(a_1, a_2) allein lässt sich nicht folgern, ob das Ergebnis a_1 oder a_2 ist.
Beispiel
Der Code-Block <syntaxhighlight lang="C"> if (c)
a = b + d;
else
a = e + f;
x = 2 * a; </syntaxhighlight>
wird in der SSA-Form mit Hilfe der Phi-Funktion zu:
<syntaxhighlight lang="C"> if (c_1)
a_1 = b_1 + d_1;
else
a_2 = e_1 + f_1;
x_1 = 2 * phi(a_1, a_2); </syntaxhighlight>
Literatur
- {{#invoke:Vorlage:Literatur|f}}{{#if:
| {{#if: Vorlage:Cite book/ParamBool | Vorlage:Toter Link/archivebot | Vorlage:Webarchiv/archiv-bot }}
}}{{#invoke:TemplatePar|check
|all = title= |opt = vauthors= author= author-link= authorlink= author1= author-link1= author1-link= first= last= first1= last1= first2= last2= author2= first3= last3= author3= first4= last4= author4= first5= last5= author5= first6= last6= author6= first7= last7= author7= first8= last8= author8= others= coauthors= script-title= trans-title= orig-date= orig-year= chapter= chapter-url= editor= editor-first= editor-last= editor-first1= editor-last1= editor-first2= editor-last2= editor-first3= editor-last3= editor-link= editor-link1= language= format= others= series= issue= number= edition= volume= publisher= location= date= year= isbn= page= at= pages= arxiv= doi= jstor= bibcode= pmc= pmid= lccn= oclc= id= url= url-status= access-date= accessdate= archive-url= archiveurl= archive-date= archivedate= quote= url-access= ref= coauthors= origyear= archivebot= offline= |cat = Wikipedia:Vorlagenfehler/Vorlage:Cite book |errNS = 0 |template = Vorlage:Cite book |format = |preview = 1
}}Vorlage:Cite book/URLVorlage:Cite book/Meldung2{{#if: Vorlage:Cite book/ParamBool | Vorlage:Cite book/Meldung }}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
| Vorlage:Cite book/Meldung
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}}{{#ifeq:Appel, Andrew W.|^^||+1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}
- {{#invoke:Vorlage:Literatur|f}}{{#if:
| {{#if: Vorlage:Cite book/ParamBool | Vorlage:Toter Link/archivebot | Vorlage:Webarchiv/archiv-bot }}
}}{{#invoke:TemplatePar|check
|all = title= |opt = vauthors= author= author-link= authorlink= author1= author-link1= author1-link= first= last= first1= last1= first2= last2= author2= first3= last3= author3= first4= last4= author4= first5= last5= author5= first6= last6= author6= first7= last7= author7= first8= last8= author8= others= coauthors= script-title= trans-title= orig-date= orig-year= chapter= chapter-url= editor= editor-first= editor-last= editor-first1= editor-last1= editor-first2= editor-last2= editor-first3= editor-last3= editor-link= editor-link1= language= format= others= series= issue= number= edition= volume= publisher= location= date= year= isbn= page= at= pages= arxiv= doi= jstor= bibcode= pmc= pmid= lccn= oclc= id= url= url-status= access-date= accessdate= archive-url= archiveurl= archive-date= archivedate= quote= url-access= ref= coauthors= origyear= archivebot= offline= |cat = Wikipedia:Vorlagenfehler/Vorlage:Cite book |errNS = 0 |template = Vorlage:Cite book |format = |preview = 1
}}Vorlage:Cite book/URLVorlage:Cite book/Meldung2{{#if: Vorlage:Cite book/ParamBool | Vorlage:Cite book/Meldung }}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
| Vorlage:Cite book/Meldung
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}}{{#ifeq:Cooper, Keith D.; and Torczon, Linda|^^||+1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}
- {{#invoke:Vorlage:Literatur|f}}{{#if:
| {{#if: Vorlage:Cite book/ParamBool | Vorlage:Toter Link/archivebot | Vorlage:Webarchiv/archiv-bot }}
}}{{#invoke:TemplatePar|check
|all = title= |opt = vauthors= author= author-link= authorlink= author1= author-link1= author1-link= first= last= first1= last1= first2= last2= author2= first3= last3= author3= first4= last4= author4= first5= last5= author5= first6= last6= author6= first7= last7= author7= first8= last8= author8= others= coauthors= script-title= trans-title= orig-date= orig-year= chapter= chapter-url= editor= editor-first= editor-last= editor-first1= editor-last1= editor-first2= editor-last2= editor-first3= editor-last3= editor-link= editor-link1= language= format= others= series= issue= number= edition= volume= publisher= location= date= year= isbn= page= at= pages= arxiv= doi= jstor= bibcode= pmc= pmid= lccn= oclc= id= url= url-status= access-date= accessdate= archive-url= archiveurl= archive-date= archivedate= quote= url-access= ref= coauthors= origyear= archivebot= offline= |cat = Wikipedia:Vorlagenfehler/Vorlage:Cite book |errNS = 0 |template = Vorlage:Cite book |format = |preview = 1
}}Vorlage:Cite book/URLVorlage:Cite book/Meldung2{{#if: Vorlage:Cite book/ParamBool | Vorlage:Cite book/Meldung }}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
| Vorlage:Cite book/Meldung
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
}}{{#if: Vorlage:Cite book/ParamBool
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}}{{#ifeq:Muchnick, Steven S.|^^||+1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}{{#ifexpr: {{#ifeq:^^|^^|0|1}}{{#ifeq:^^|^^||+1}} > 1
| Vorlage:Cite book/Meldung
}}