# HG changeset patch # User Christian Urban # Date 1575336110 0 # Node ID 39e21a33ffb0ac0c894664fef16a767c37789bf2 # Parent 681c36b2af271ef6078601490b4eea89a91c635b updated diff -r 681c36b2af27 -r 39e21a33ffb0 progs/fact.fun --- a/progs/fact.fun Thu Nov 28 08:18:57 2019 +0000 +++ b/progs/fact.fun Tue Dec 03 01:21:50 2019 +0000 @@ -13,5 +13,5 @@ //fact(10) //facTi(10) -write(facTi(5 + 5)) +write(facTi(6)) diff -r 681c36b2af27 -r 39e21a33ffb0 slides/slides06.pdf Binary file slides/slides06.pdf has changed diff -r 681c36b2af27 -r 39e21a33ffb0 slides/slides06.tex --- a/slides/slides06.tex Thu Nov 28 08:18:57 2019 +0000 +++ b/slides/slides06.tex Tue Dec 03 01:21:50 2019 +0000 @@ -705,8 +705,7 @@ \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\begin{frame}[c] % \frametitle{Coursework: MkEps} @@ -748,8 +747,7 @@ % %\end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - +% \end{document} diff -r 681c36b2af27 -r 39e21a33ffb0 slides/slides09.pdf Binary file slides/slides09.pdf has changed diff -r 681c36b2af27 -r 39e21a33ffb0 slides/slides09.tex --- a/slides/slides09.tex Thu Nov 28 08:18:57 2019 +0000 +++ b/slides/slides09.tex Tue Dec 03 01:21:50 2019 +0000 @@ -40,7 +40,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c,fragile] -\frametitle{Functional Programming} +\frametitle{The Fun Language} \footnotesize \begin{textblock}{13}(0.9,3) @@ -64,7 +64,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[c,fragile] -\frametitle{Factorial on the JVM} +\frametitle{Factorial Funct.~on the JVM} \begin{textblock}{7}(1,1.8)\footnotesize \begin{minipage}{6cm} @@ -228,10 +228,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile,c] -\frametitle{LLVM Instructions} +\frametitle{LLVM-IR Instructions} \small -\begin{lstlisting}[language=LLVM] +\begin{lstlisting}[language=LLVM,xleftmargin=0mm] br i1 %var, label %if_br, label %else_br icmp eq i32 %x, %y ; for equal @@ -252,12 +252,13 @@ \bl{$(1 + a) + (3 + (b * 5))$}\bigskip\bigskip \begin{lstlisting}[language=LLVM] -let tmp0 = add 1 a in -let tmp1 = mul b 5 in -let tmp2 = add 3 tmp1 in -let tmp3 = add tmp0 tmp2 in - tmp3 -\end{lstlisting} +tmp0 = add 1 a +tmp1 = mul b 5 +tmp2 = add 3 tmp1 +tmp3 = add tmp0 tmp2 +\end{lstlisting}\bigskip\bigskip + +\hfill Static Single Assignment \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -294,12 +295,14 @@ abstract class KExp abstract class KVal +// K-Values case class KVar(s: String) extends KVal case class KNum(i: Int) extends KVal case class Kop(o: String, v1: KVal, v2: KVal) extends KVal case class KCall(o: String, vrs: List[KVal]) extends KVal case class KWrite(v: KVal) extends KVal +// K-Expressions case class KIf(x1: String, e1: KExp, e2: KExp) extends KExp case class KLet(x: String, v: KVal, e: KExp) extends KExp case class KReturn(v: KVal) extends KExp @@ -319,6 +322,8 @@ \end{lstlisting} \bigskip\bigskip +the continuation \texttt{k} can be thought of:\medskip + \small \begin{lstlisting}[language=LLVMIR,numbers=none,xleftmargin=30mm,escapeinside={(*@}{@*)}] let tmp0 = add 1 a in @@ -373,13 +378,13 @@ } ... } \end{lstlisting} - -\small +\mbox{}\\[-8mm]% +% \begin{lstlisting}[language=LLVMIR,numbers=none,xleftmargin=30mm,escapeinside={(*@}{@*)}] ... let z = op (*@$\Box_{y_1}$@*) (*@$\Box_{y_2}$@*) let tmp0 = add 1 a in -let tmp1 = mul (*@$\Box\!\!\!\!\raisebox{0.6mm}{\texttt{z}}$@*) 5 in +let tmp1 = mul (*@$\Box\!\!\!\!\raisebox{0.6mm}{\alert{\texttt{z}}}$@*) 5 in let tmp2 = add 3 tmp1 in let tmp3 = add tmp0 tmp2 in KReturn tmp3 @@ -401,35 +406,7 @@ ... } \end{lstlisting} -\bigskip\bigskip - -\small -\begin{lstlisting}[language=LLVMIR,numbers=none,xleftmargin=30mm,escapeinside={(*@}{@*)}] -let tmp0 = add 1 a in -let tmp1 = mul (*@$\Box$@*) 5 in -let tmp2 = add 3 tmp1 in -let tmp3 = add tmp0 tmp2 in - KReturn tmp3 -\end{lstlisting} - -\end{frame} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[fragile,c] -\frametitle{CPS-Translation} -\small - -\begin{lstlisting}[language=Scala,numbers=none] -def CPS(e: Exp)(k: KVal => KExp) : KExp = - e match { - ... - case Sequence(e1, e2) => - CPS(e1)(_ => CPS(e2)(y2 => k(y2))) - ... - } -\end{lstlisting} -\bigskip\bigskip +\bigskip \small \begin{lstlisting}[language=LLVMIR,numbers=none,xleftmargin=30mm,escapeinside={(*@}{@*)}] @@ -466,6 +443,43 @@ \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c,fragile] +\frametitle{The Basic Language, 1980+} + +\begin{lstlisting}[language={[Visual]Basic},numbers=none] + 5 LET S = 0 +10 INPUT V +20 PRINT "Input number" +30 IF N = 0 THEN GOTO 99 +40 FOR I = 1 TO N +45 LET S = S + V(I) +50 NEXT I +60 PRINT S/N +70 GOTO 5 +99 END +\end{lstlisting} + +\hfill ``Spaghetti Code'' +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[c,fragile] +\frametitle{Target Specific ASM} + +\begin{lstlisting}[language={},numbers=none] +llc -march=x86-64 fact.ll +llc -march=arm fact.ll + + +Intel: xorl %eax, %eax +ARM: mov pc, lr +\end{lstlisting} + +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%