Эх сурвалжийг харах

Merge branch 'master' of https://github.com/IUCompilerCourse/Essentials-of-Compilation

Jeremy Siek 2 жил өмнө
parent
commit
9c4700f381
3 өөрчлөгдсөн 15 нэмэгдсэн , 7 устгасан
  1. 3 1
      .github/workflows/ci.yml
  2. 8 2
      book.tex
  3. 4 4
      defs.tex

+ 3 - 1
.github/workflows/ci.yml

@@ -1,4 +1,6 @@
-on: push
+on:
+  push:
+  pull_request:
 jobs:
     build:
         runs-on: ubuntu-latest

+ 8 - 2
book.tex

@@ -3913,7 +3913,7 @@ programs.
 The \code{patch\_instructions} pass compiles from \LangXVar{} to
 \LangXInt{} by making sure that each instruction adheres to the
 restriction that at most one argument of an instruction may be a
-memory reference.
+memory reference. 
 
 We return to the following example.\\
 \begin{minipage}{0.5\textwidth}
@@ -3960,6 +3960,12 @@ from \key{rax} to the destination location, as follows.
    movq %rax, -16(%rbp)
 \end{lstlisting}
 
+There is a similar corner case that also needs to be dealt with. If
+one argument is an immediate integer larger than $2^{16}$ and the
+other is a memory reference, then the instruction is invalid.  One can
+fix this, for example, by first moving the immediate integer into
+\key{rax} and then using \key{rax} in place of the integer.
+
 \begin{exercise}
 \normalfont\normalsize Implement the \key{patch\_instructions} pass in
 \racket{\code{compiler.rkt}}\python{\code{compiler.py}}.
@@ -16952,7 +16958,7 @@ a local variable of the enclosing function:
 \begin{minipage}{\textwidth}
 {\if\edition\racketEd
 \begin{lstlisting}
-(define (f []) : Integer
+(define (f) : ( -> Integer)
   (let ([x 0])
     (let ([g (lambda: () : Integer x)])
       (begin

+ 4 - 4
defs.tex

@@ -45,7 +45,7 @@
 \newcommand{\LangFunRefM}{\Lang_{\mathsf{FunRef}}} %F1
 \newcommand{\LangFunRefAlloc}{\ensuremath{\Lang^{\mathsf{Alloc}}_{\mathsf{FunRef}}}} %R'4
 \newcommand{\LangLam}{$\Lang_\lambda$} %R5
-\newcommand{\LangLamFunRef}{$\Lang_\lambda^{\mathsf{FunRef}}$} 
+\newcommand{\LangLamFunRef}{$\Lang_\lambda^{\mathsf{FunRef}}$}
 \newcommand{\LangLamM}{\ensuremath{\Lang_\lambda}} %R5
 \newcommand{\LangCLam}{$\CLang_{\mathsf{Clos}}$} %C4
 \newcommand{\LangCLamM}{\CLang_{\mathsf{Clos}}} %C4
@@ -208,9 +208,9 @@
 \newcommand{\READ}{{\key{Call(Name('input\_int'),[])}}}
 \newcommand{\CREAD}{\key{input\_int()}}
 \newcommand{\NEG}[1]{{\key{UnaryOp(USub(),} #1\code{)}}}
-\newcommand{\ADD}[2]{{\key{BinOp}\LP #1\code{,} \key{Add()}\key{,}#2\code{)}}}
-\newcommand{\ADDP}[2]{{\key{BinOp}\LP #1\code{,} \key{Add()}\key{,}#2\code{)}}}
-\newcommand{\SUB}[2]{{\key{BinOp}\LP \key{Sub()}\key{,}#1\code{,}#2\code{)}}}
+\newcommand{\ADD}[2]{{\key{BinOp}\LP #1\code{,}\key{Add()}\key{,}#2\code{)}}}
+\newcommand{\ADDP}[2]{{\key{BinOp}\LP #1\code{,}\key{Add()}\key{,}#2\code{)}}}
+\newcommand{\SUB}[2]{{\key{BinOp}\LP #1\code{,}\key{Sub()}\key{,}#2\code{)}}}
 \newcommand{\PRINT}[1]{{\key{Expr}\LP\key{Call}\LP\key{Name}\LP\key{'print'}\RP\key{,}\LS#1\RS\RP\RP}}
 \newcommand{\CPRINT}[1]{\key{print}\LP #1\RP}
 \newcommand{\EXPR}[1]{{\key{Expr}\LP #1\RP}}